diff --git a/src/Makefile.am b/src/Makefile.am index 5ef109d069..f9240f7be2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -524,7 +524,14 @@ CLEANFILES = $(PTXS) cuda-ptxdump.h endif # default CFLAGS -AM_CFLAGS = ${OPTIMIZATION_CFLAGS} ${GCC_CFLAGS} ${CLANG_CFLAGS} ${SECCFLAGS} ${PCAP_CFLAGS} -Wall -Wno-unused-parameter -std=gnu99 -DLOCAL_STATE_DIR=\"$(localstatedir)\" +AM_CFLAGS = ${OPTIMIZATION_CFLAGS} ${GCC_CFLAGS} ${CLANG_CFLAGS} \ + ${SECCFLAGS} ${PCAP_CFLAGS} -DLOCAL_STATE_DIR=\"$(localstatedir)\" \ + -std=gnu99 \ + -Wall -Wno-unused-parameter -Wmissing-prototypes -Wmissing-declarations \ + -Wstrict-prototypes -Wwrite-strings -Wbad-function-cast \ + -Wformat-security -Wno-format-nonliteral -Wmissing-format-attribute \ + -funsigned-char + # different flags for different cases if DEBUG AM_CFLAGS += -ggdb -O0 diff --git a/src/alert-debuglog.c b/src/alert-debuglog.c index 4ab39c97d0..68ffd978f0 100644 --- a/src/alert-debuglog.c +++ b/src/alert-debuglog.c @@ -370,7 +370,7 @@ static TmEcode AlertDebugLogDecoderEvent(ThreadVars *tv, const Packet *p, void * return TM_ECODE_OK; } -static TmEcode AlertDebugLogThreadInit(ThreadVars *t, void *initdata, void **data) +static TmEcode AlertDebugLogThreadInit(ThreadVars *t, const void *initdata, void **data) { AlertDebugLogThread *aft = SCMalloc(sizeof(AlertDebugLogThread)); if (unlikely(aft == NULL)) diff --git a/src/alert-fastlog.c b/src/alert-fastlog.c index d475a6a38c..b7fcf5593d 100644 --- a/src/alert-fastlog.c +++ b/src/alert-fastlog.c @@ -67,7 +67,7 @@ * holding multiple alerts. */ #define MAX_FASTLOG_BUFFER_SIZE (2 * MAX_FASTLOG_ALERT_SIZE) -TmEcode AlertFastLogThreadInit(ThreadVars *, void *, void **); +TmEcode AlertFastLogThreadInit(ThreadVars *, const void *, void **); TmEcode AlertFastLogThreadDeinit(ThreadVars *, void *); void AlertFastLogRegisterTests(void); static void AlertFastLogDeInitCtx(OutputCtx *); @@ -134,7 +134,7 @@ int AlertFastLogger(ThreadVars *tv, void *data, const Packet *p) continue; } - char *action = ""; + const char *action = ""; if ((pa->action & ACTION_DROP) && EngineModeIsIPS()) { action = "[Drop] "; } else if (pa->action & ACTION_DROP) { @@ -182,7 +182,7 @@ int AlertFastLogger(ThreadVars *tv, void *data, const Packet *p) return TM_ECODE_OK; } -TmEcode AlertFastLogThreadInit(ThreadVars *t, void *initdata, void **data) +TmEcode AlertFastLogThreadInit(ThreadVars *t, const void *initdata, void **data) { AlertFastLogThread *aft = SCMalloc(sizeof(AlertFastLogThread)); if (unlikely(aft == NULL)) @@ -253,7 +253,7 @@ static void AlertFastLogDeInitCtx(OutputCtx *output_ctx) #ifdef UNITTESTS -static int AlertFastLogTest01() +static int AlertFastLogTest01(void) { int result = 0; uint8_t *buf = (uint8_t *) "GET /one/ HTTP/1.1\r\n" @@ -298,7 +298,7 @@ static int AlertFastLogTest01() return result; } -static int AlertFastLogTest02() +static int AlertFastLogTest02(void) { int result = 0; uint8_t *buf = (uint8_t *) "GET /one/ HTTP/1.1\r\n" diff --git a/src/alert-prelude.c b/src/alert-prelude.c index 9c55b28154..906f9d9b29 100644 --- a/src/alert-prelude.c +++ b/src/alert-prelude.c @@ -58,6 +58,8 @@ #include "stream.h" +#include "alert-prelude.h" + #ifndef PRELUDE /* Handle the case where no PRELUDE support is compiled in. */ diff --git a/src/alert-syslog.c b/src/alert-syslog.c index 8de1d3a9c2..51b78bf241 100644 --- a/src/alert-syslog.c +++ b/src/alert-syslog.c @@ -88,7 +88,7 @@ static void AlertSyslogDeInitCtx(OutputCtx *output_ctx) * \param conf The configuration node for this output. * \return A OutputCtx pointer on success, NULL on failure. */ -OutputCtx *AlertSyslogInitCtx(ConfNode *conf) +static OutputCtx *AlertSyslogInitCtx(ConfNode *conf) { const char *facility_s = ConfNodeLookupChildValue(conf, "facility"); if (facility_s == NULL) { @@ -146,7 +146,7 @@ OutputCtx *AlertSyslogInitCtx(ConfNode *conf) * \param initdata Pointer to the output context * \param data pointer to pointer to point to the AlertSyslogThread */ -static TmEcode AlertSyslogThreadInit(ThreadVars *t, void *initdata, void **data) +static TmEcode AlertSyslogThreadInit(ThreadVars *t, const void *initdata, void **data) { if(initdata == NULL) { SCLogDebug("Error getting context for AlertSyslog. \"initdata\" " @@ -200,7 +200,7 @@ static TmEcode AlertSyslogIPv4(ThreadVars *tv, const Packet *p, void *data) { AlertSyslogThread *ast = (AlertSyslogThread *)data; int i; - char *action = ""; + const char *action = ""; if (p->alerts.cnt == 0) return TM_ECODE_OK; @@ -257,7 +257,7 @@ static TmEcode AlertSyslogIPv6(ThreadVars *tv, const Packet *p, void *data) { AlertSyslogThread *ast = (AlertSyslogThread *)data; int i; - char *action = ""; + const char *action = ""; if (p->alerts.cnt == 0) return TM_ECODE_OK; @@ -318,7 +318,7 @@ static TmEcode AlertSyslogDecoderEvent(ThreadVars *tv, const Packet *p, void *da { AlertSyslogThread *ast = (AlertSyslogThread *)data; int i; - char *action = ""; + const char *action = ""; if (p->alerts.cnt == 0) return TM_ECODE_OK; diff --git a/src/alert-unified2-alert.c b/src/alert-unified2-alert.c index ac1fa7e291..4d92bcc703 100644 --- a/src/alert-unified2-alert.c +++ b/src/alert-unified2-alert.c @@ -218,8 +218,7 @@ typedef struct Unified2AlertThread_ { SC_ATOMIC_DECLARE(unsigned int, unified2_event_id); /**< Atomic counter, to link relative event */ /** prototypes */ -//TmEcode Unified2Alert (ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *); -TmEcode Unified2AlertThreadInit(ThreadVars *, void *, void **); +TmEcode Unified2AlertThreadInit(ThreadVars *, const void *, void **); TmEcode Unified2AlertThreadDeinit(ThreadVars *, void *); static int Unified2IPv4TypeAlert(ThreadVars *, const Packet *, void *); static int Unified2IPv6TypeAlert(ThreadVars *, const Packet *, void *); @@ -1147,7 +1146,7 @@ static int Unified2IPv4TypeAlert (ThreadVars *tv, const Packet *p, void *data) * \retval TM_ECODE_FAILED on failure */ -TmEcode Unified2AlertThreadInit(ThreadVars *t, void *initdata, void **data) +TmEcode Unified2AlertThreadInit(ThreadVars *t, const void *initdata, void **data) { Unified2AlertThread *aun = SCMalloc(sizeof(Unified2AlertThread)); if (unlikely(aun == NULL)) @@ -1406,7 +1405,7 @@ static int Unified2AlertOpenFileCtx(LogFileCtx *file_ctx, const char *prefix, gettimeofday(&ts, NULL); /* create the filename to use */ - char *log_dir; + const char *log_dir; log_dir = ConfigGetLogDirectory(); if (file_ctx->nostamp) { diff --git a/src/app-layer-dcerpc-common.h b/src/app-layer-dcerpc-common.h index 72fe4574fb..22001957ec 100644 --- a/src/app-layer-dcerpc-common.h +++ b/src/app-layer-dcerpc-common.h @@ -242,7 +242,7 @@ typedef struct DCERPCUDP_ { int32_t DCERPCParser(DCERPC *, uint8_t *, uint32_t); void hexdump(const void *buf, size_t len); -void printUUID(char *type, DCERPCUuidEntry *uuid); +void printUUID(const char *type, DCERPCUuidEntry *uuid); #endif /* __APP_LAYER_DCERPC_COMMON_H__ */ diff --git a/src/app-layer-dcerpc-udp.c b/src/app-layer-dcerpc-udp.c index 7852a4b0ba..ba2861055b 100644 --- a/src/app-layer-dcerpc-udp.c +++ b/src/app-layer-dcerpc-udp.c @@ -835,7 +835,7 @@ static int DCERPCUDPRegisterPatternsForProtocolDetection(void) void RegisterDCERPCUDPParsers(void) { - char *proto_name = "dcerpc"; + const char *proto_name = "dcerpc"; if (AppLayerProtoDetectConfProtoDetectionEnabled("udp", proto_name)) { AppLayerProtoDetectRegisterProtocol(ALPROTO_DCERPC, proto_name); @@ -871,7 +871,7 @@ void RegisterDCERPCUDPParsers(void) /** \test DCERPC UDP Header Parsing and UUID handling */ -int DCERPCUDPParserTest01(void) +static int DCERPCUDPParserTest01(void) { int result = 1; Flow f; diff --git a/src/app-layer-dcerpc.c b/src/app-layer-dcerpc.c index 38416a50d8..687f4127e9 100644 --- a/src/app-layer-dcerpc.c +++ b/src/app-layer-dcerpc.c @@ -143,7 +143,7 @@ void hexdump(/*Flow *f,*/ const void *buf, size_t len) * \brief printUUID function used to print UUID, Major and Minor Version Number * and if it was Accepted or Rejected in the BIND_ACK. */ -void printUUID(char *type, DCERPCUuidEntry *uuid) +void printUUID(const char *type, DCERPCUuidEntry *uuid) { uint8_t i = 0; if (uuid == NULL) { @@ -2091,7 +2091,7 @@ static int DCERPCRegisterPatternsForProtocolDetection(void) void RegisterDCERPCParsers(void) { - char *proto_name = "dcerpc"; + const char *proto_name = "dcerpc"; if (AppLayerProtoDetectConfProtoDetectionEnabled("tcp", proto_name)) { AppLayerProtoDetectRegisterProtocol(ALPROTO_DCERPC, proto_name); @@ -2144,7 +2144,7 @@ void RegisterDCERPCParsers(void) /* set this to 1 to see problem */ -int DCERPCParserTest01(void) +static int DCERPCParserTest01(void) { int result = 1; Flow f; @@ -2603,7 +2603,7 @@ end: /** \test DCERPC Request decoding and opnum parsing. */ -int DCERPCParserTest02(void) +static int DCERPCParserTest02(void) { int result = 1; Flow f; @@ -2806,7 +2806,7 @@ end: /** \test Test endianness handling */ -int DCERPCParserTest03(void) +static int DCERPCParserTest03(void) { int result = 1; Flow f; @@ -3003,7 +3003,7 @@ end: /** * \todo Needs to be rewritten */ -int DCERPCParserTest04(void) +static int DCERPCParserTest04(void) { /* AWS - Disabled this test since clamav FPs on the payloads used. * We will have to rewrite this test with new payloads. Will be done @@ -4363,7 +4363,7 @@ end: /** * \test General test. */ -int DCERPCParserTest05(void) +static int DCERPCParserTest05(void) { int result = 1; Flow f; @@ -4465,7 +4465,7 @@ end: /** * \test DCERPC fragmented bind PDU(one PDU which is frag'ed) */ -int DCERPCParserTest06(void) +static int DCERPCParserTest06(void) { int result = 1; Flow f; @@ -4631,7 +4631,7 @@ end: /** * \test DCERPC fragmented bind PDU(one PDU which is frag'ed). */ -int DCERPCParserTest07(void) +static int DCERPCParserTest07(void) { int result = 1; Flow f; @@ -4734,7 +4734,7 @@ end: /** * \test DCERPC fragmented bind PDU(one PDU which is frag'ed). */ -int DCERPCParserTest08(void) +static int DCERPCParserTest08(void) { int result = 1; Flow f; @@ -4795,7 +4795,7 @@ end: /** * \test DCERPC fragmented bind PDU(one PDU which is frag'ed). */ -int DCERPCParserTest09(void) +static int DCERPCParserTest09(void) { int result = 1; Flow f; @@ -4856,7 +4856,7 @@ end: /** * \test DCERPC fragmented PDU. */ -int DCERPCParserTest10(void) +static int DCERPCParserTest10(void) { int result = 1; Flow f; @@ -4956,7 +4956,7 @@ end: /** * \test DCERPC fragmented PDU. */ -int DCERPCParserTest11(void) +static int DCERPCParserTest11(void) { int result = 1; Flow f; @@ -5061,7 +5061,7 @@ end: /** * \test DCERPC fragmented PDU. */ -int DCERPCParserTest12(void) +static int DCERPCParserTest12(void) { int result = 1; Flow f; @@ -5143,7 +5143,7 @@ end: * \test Check if the parser accepts bind pdus that have context ids starting * from a non-zero value. */ -int DCERPCParserTest13(void) +static int DCERPCParserTest13(void) { int result = 1; Flow f; @@ -5228,7 +5228,7 @@ end: /** * \test Check for another endless loop with bind pdus. */ -int DCERPCParserTest14(void) +static int DCERPCParserTest14(void) { int result = 1; Flow f; @@ -5294,7 +5294,7 @@ end: /** * \test Check for another endless loop for bind_ack pdus. */ -int DCERPCParserTest15(void) +static int DCERPCParserTest15(void) { int result = 1; Flow f; @@ -5356,7 +5356,7 @@ end: /** * \test Check for correct internal ids for bind_acks. */ -int DCERPCParserTest16(void) +static int DCERPCParserTest16(void) { int result = 1; Flow f; @@ -5955,7 +5955,7 @@ end: /** * \test Check for correct internal ids for bind_acks + alter_contexts */ -int DCERPCParserTest17(void) +static int DCERPCParserTest17(void) { int result = 1; Flow f; @@ -6149,7 +6149,7 @@ end: /** * \test DCERPC fragmented PDU. */ -int DCERPCParserTest18(void) +static int DCERPCParserTest18(void) { int result = 1; Flow f; @@ -6228,7 +6228,7 @@ end: return result; } -int DCERPCParserTest19(void) +static int DCERPCParserTest19(void) { int result = 0; Flow f; diff --git a/src/app-layer-detect-proto.c b/src/app-layer-detect-proto.c index db7b911088..9a2460bce6 100644 --- a/src/app-layer-detect-proto.c +++ b/src/app-layer-detect-proto.c @@ -154,7 +154,7 @@ typedef struct AppLayerProtoDetectCtx_ { /* Indicates the protocols that have registered themselves * for protocol detection. This table is independent of the * ipproto. */ - char *alproto_names[ALPROTO_MAX]; + const char *alproto_names[ALPROTO_MAX]; } AppLayerProtoDetectCtx; /** @@ -636,7 +636,8 @@ AppLayerProtoDetectProbingParserElementDuplicate(AppLayerProtoDetectProbingParse SCReturnPtr(new_pe, "AppLayerProtoDetectProbingParserElement"); } -void AppLayerProtoDetectPrintProbingParsers(AppLayerProtoDetectProbingParser *pp) +#ifdef DEBUG +static void AppLayerProtoDetectPrintProbingParsers(AppLayerProtoDetectProbingParser *pp) { SCEnter(); @@ -772,6 +773,7 @@ void AppLayerProtoDetectPrintProbingParsers(AppLayerProtoDetectProbingParser *pp SCReturn; } +#endif static void AppLayerProtoDetectProbingParserElementAppend(AppLayerProtoDetectProbingParserElement **head_pe, AppLayerProtoDetectProbingParserElement *new_pe) @@ -1244,7 +1246,7 @@ static int AppLayerProtoDetectPMAddSignature(AppLayerProtoDetectPMCtx *ctx, Dete } static int AppLayerProtoDetectPMRegisterPattern(uint8_t ipproto, AppProto alproto, - char *pattern, + const char *pattern, uint16_t depth, uint16_t offset, uint8_t direction, uint8_t is_cs) @@ -1393,7 +1395,7 @@ int AppLayerProtoDetectPrepareState(void) * \param direction STREAM_TOSERVER or STREAM_TOCLIENT for dp or sp */ void AppLayerProtoDetectPPRegister(uint8_t ipproto, - char *portstr, + const char *portstr, AppProto alproto, uint16_t min_depth, uint16_t max_depth, uint8_t direction, @@ -1505,7 +1507,7 @@ int AppLayerProtoDetectPPParseConfPorts(const char *ipproto_name, /***** PM registration *****/ int AppLayerProtoDetectPMRegisterPatternCS(uint8_t ipproto, AppProto alproto, - char *pattern, + const char *pattern, uint16_t depth, uint16_t offset, uint8_t direction) { @@ -1520,7 +1522,7 @@ int AppLayerProtoDetectPMRegisterPatternCS(uint8_t ipproto, AppProto alproto, } int AppLayerProtoDetectPMRegisterPatternCI(uint8_t ipproto, AppProto alproto, - char *pattern, + const char *pattern, uint16_t depth, uint16_t offset, uint8_t direction) { @@ -1598,7 +1600,7 @@ int AppLayerProtoDetectDeSetup(void) SCReturnInt(0); } -void AppLayerProtoDetectRegisterProtocol(AppProto alproto, char *alproto_name) +void AppLayerProtoDetectRegisterProtocol(AppProto alproto, const char *alproto_name) { SCEnter(); @@ -1770,7 +1772,7 @@ void AppLayerProtoDetectSupportedIpprotos(AppProto alproto, uint8_t *ipprotos) SCReturn; } -AppProto AppLayerProtoDetectGetProtoByName(char *alproto_name) +AppProto AppLayerProtoDetectGetProtoByName(const char *alproto_name) { SCEnter(); @@ -1787,7 +1789,7 @@ AppProto AppLayerProtoDetectGetProtoByName(char *alproto_name) SCReturnCT(ALPROTO_UNKNOWN, "AppProto"); } -char *AppLayerProtoDetectGetProtoName(AppProto alproto) +const char *AppLayerProtoDetectGetProtoName(AppProto alproto) { return alpd_ctx.alproto_names[alproto]; } @@ -1830,12 +1832,12 @@ void AppLayerProtoDetectUnittestCtxRestore(void) SCReturn; } -int AppLayerProtoDetectTest01(void) +static int AppLayerProtoDetectTest01(void) { AppLayerProtoDetectUnittestCtxBackup(); AppLayerProtoDetectSetup(); - char *buf; + const char *buf; int r = 0; buf = "HTTP"; @@ -1863,15 +1865,14 @@ int AppLayerProtoDetectTest01(void) return r; } -int AppLayerProtoDetectTest02(void) +static int AppLayerProtoDetectTest02(void) { AppLayerProtoDetectUnittestCtxBackup(); AppLayerProtoDetectSetup(); - char *buf; int r = 0; - buf = "HTTP"; + const char *buf = "HTTP"; AppLayerProtoDetectPMRegisterPatternCS(IPPROTO_TCP, ALPROTO_HTTP, buf, 4, 0, STREAM_TOCLIENT); buf = "ftp"; AppLayerProtoDetectPMRegisterPatternCS(IPPROTO_TCP, ALPROTO_FTP, buf, 4, 0, STREAM_TOCLIENT); @@ -1912,13 +1913,13 @@ int AppLayerProtoDetectTest02(void) return r; } -int AppLayerProtoDetectTest03(void) +static int AppLayerProtoDetectTest03(void) { AppLayerProtoDetectUnittestCtxBackup(); AppLayerProtoDetectSetup(); uint8_t l7data[] = "HTTP/1.1 200 OK\r\nServer: Apache/1.0\r\n\r\n"; - char *buf; + const char *buf; int r = 0; Flow f; AppProto pm_results[ALPROTO_MAX]; @@ -1987,13 +1988,13 @@ int AppLayerProtoDetectTest03(void) return r; } -int AppLayerProtoDetectTest04(void) +static int AppLayerProtoDetectTest04(void) { AppLayerProtoDetectUnittestCtxBackup(); AppLayerProtoDetectSetup(); uint8_t l7data[] = "HTTP/1.1 200 OK\r\nServer: Apache/1.0\r\n\r\n"; - char *buf; + const char *buf; int r = 0; Flow f; AppProto pm_results[ALPROTO_MAX]; @@ -2056,13 +2057,13 @@ int AppLayerProtoDetectTest04(void) return r; } -int AppLayerProtoDetectTest05(void) +static int AppLayerProtoDetectTest05(void) { AppLayerProtoDetectUnittestCtxBackup(); AppLayerProtoDetectSetup(); uint8_t l7data[] = "HTTP/1.1 200 OK\r\nServer: Apache/1.0\r\n\r\nBlahblah"; - char *buf; + const char *buf; int r = 0; Flow f; AppProto pm_results[ALPROTO_MAX]; @@ -2131,13 +2132,13 @@ int AppLayerProtoDetectTest05(void) return r; } -int AppLayerProtoDetectTest06(void) +static int AppLayerProtoDetectTest06(void) { AppLayerProtoDetectUnittestCtxBackup(); AppLayerProtoDetectSetup(); uint8_t l7data[] = "220 Welcome to the OISF FTP server\r\n"; - char *buf; + const char *buf; int r = 0; Flow f; AppProto pm_results[ALPROTO_MAX]; @@ -2204,13 +2205,13 @@ int AppLayerProtoDetectTest06(void) return r; } -int AppLayerProtoDetectTest07(void) +static int AppLayerProtoDetectTest07(void) { AppLayerProtoDetectUnittestCtxBackup(); AppLayerProtoDetectSetup(); uint8_t l7data[] = "220 Welcome to the OISF HTTP/FTP server\r\n"; - char *buf; + const char *buf; int r = 0; Flow f; AppProto pm_results[ALPROTO_MAX]; @@ -2273,7 +2274,7 @@ int AppLayerProtoDetectTest07(void) return r; } -int AppLayerProtoDetectTest08(void) +static int AppLayerProtoDetectTest08(void) { AppLayerProtoDetectUnittestCtxBackup(); AppLayerProtoDetectSetup(); @@ -2298,7 +2299,7 @@ int AppLayerProtoDetectTest08(void) 0x20, 0x4c, 0x4d, 0x20, 0x30, 0x2e, 0x31, 0x32, 0x00 }; - char *buf; + const char *buf; int r = 0; Flow f; AppProto pm_results[ALPROTO_MAX]; @@ -2361,7 +2362,7 @@ int AppLayerProtoDetectTest08(void) return r; } -int AppLayerProtoDetectTest09(void) +static int AppLayerProtoDetectTest09(void) { AppLayerProtoDetectUnittestCtxBackup(); AppLayerProtoDetectSetup(); @@ -2382,7 +2383,7 @@ int AppLayerProtoDetectTest09(void) 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02 }; - char *buf; + const char *buf; int r = 0; Flow f; AppProto pm_results[ALPROTO_MAX]; @@ -2445,7 +2446,7 @@ int AppLayerProtoDetectTest09(void) return r; } -int AppLayerProtoDetectTest10(void) +static int AppLayerProtoDetectTest10(void) { AppLayerProtoDetectUnittestCtxBackup(); AppLayerProtoDetectSetup(); @@ -2461,7 +2462,7 @@ int AppLayerProtoDetectTest10(void) 0xeb, 0x1c, 0xc9, 0x11, 0x9f, 0xe8, 0x08, 0x00, 0x2b, 0x10, 0x48, 0x60, 0x02, 0x00, 0x00, 0x00 }; - char *buf; + const char *buf; int r = 0; Flow f; AppProto pm_results[ALPROTO_MAX]; @@ -2528,7 +2529,7 @@ int AppLayerProtoDetectTest10(void) * \test Why we still get http for connect... obviously because * we also match on the reply, duh */ -int AppLayerProtoDetectTest11(void) +static int AppLayerProtoDetectTest11(void) { AppLayerProtoDetectUnittestCtxBackup(); AppLayerProtoDetectSetup(); @@ -2627,7 +2628,7 @@ int AppLayerProtoDetectTest11(void) /** * \test AlpProtoSignature test */ -int AppLayerProtoDetectTest12(void) +static int AppLayerProtoDetectTest12(void) { AppLayerProtoDetectUnittestCtxBackup(); AppLayerProtoDetectSetup(); @@ -2678,7 +2679,7 @@ int AppLayerProtoDetectTest12(void) * \test What about if we add some sigs only for udp but call for tcp? * It should not detect any proto */ -int AppLayerProtoDetectTest13(void) +static int AppLayerProtoDetectTest13(void) { AppLayerProtoDetectUnittestCtxBackup(); AppLayerProtoDetectSetup(); @@ -2769,7 +2770,7 @@ int AppLayerProtoDetectTest13(void) * It should detect ALPROTO_HTTP (over udp). This is just a check * to ensure that TCP/UDP differences work correctly. */ -int AppLayerProtoDetectTest14(void) +static int AppLayerProtoDetectTest14(void) { AppLayerProtoDetectUnittestCtxBackup(); AppLayerProtoDetectSetup(); @@ -2856,7 +2857,7 @@ int AppLayerProtoDetectTest14(void) } typedef struct AppLayerProtoDetectPPTestDataElement_ { - char *alproto_name; + const char *alproto_name; AppProto alproto; uint16_t port; uint32_t alproto_mask; diff --git a/src/app-layer-detect-proto.h b/src/app-layer-detect-proto.h index 591ccbf5f8..f9a02236ec 100644 --- a/src/app-layer-detect-proto.h +++ b/src/app-layer-detect-proto.h @@ -61,7 +61,7 @@ int AppLayerProtoDetectPrepareState(void); /***** PP registration *****/ void AppLayerProtoDetectPPRegister(uint8_t ipproto, - char *portstr, + const char *portstr, AppProto alproto, uint16_t min_depth, uint16_t max_depth, uint8_t direction, @@ -84,14 +84,14 @@ int AppLayerProtoDetectPPParseConfPorts(const char *ipproto_name, * \brief Registers a case-sensitive pattern for protocol detection. */ int AppLayerProtoDetectPMRegisterPatternCS(uint8_t ipproto, AppProto alproto, - char *pattern, + const char *pattern, uint16_t depth, uint16_t offset, uint8_t direction); /** * \brief Registers a case-insensitive pattern for protocol detection. */ int AppLayerProtoDetectPMRegisterPatternCI(uint8_t ipproto, AppProto alproto, - char *pattern, + const char *pattern, uint16_t depth, uint16_t offset, uint8_t direction); @@ -134,7 +134,7 @@ int AppLayerProtoDetectDeSetup(void); * \retval 0 On success; * -1 On failure. */ -void AppLayerProtoDetectRegisterProtocol(AppProto alproto, char *alproto_name); +void AppLayerProtoDetectRegisterProtocol(AppProto alproto, const char *alproto_name); /** * \brief Given a protocol name, checks if proto detection is enabled in @@ -168,8 +168,8 @@ void AppLayerProtoDetectDestroyCtxThread(AppLayerProtoDetectThreadCtx *tctx); /***** Utility *****/ void AppLayerProtoDetectSupportedIpprotos(AppProto alproto, uint8_t *ipprotos); -AppProto AppLayerProtoDetectGetProtoByName(char *alproto_name); -char *AppLayerProtoDetectGetProtoName(AppProto alproto); +AppProto AppLayerProtoDetectGetProtoByName(const char *alproto_name); +const char *AppLayerProtoDetectGetProtoName(AppProto alproto); void AppLayerProtoDetectSupportedAppProtocols(AppProto *alprotos); /***** Unittests *****/ diff --git a/src/app-layer-dnp3.c b/src/app-layer-dnp3.c index 4d2efa165f..72e48e5f22 100644 --- a/src/app-layer-dnp3.c +++ b/src/app-layer-dnp3.c @@ -1583,7 +1583,7 @@ void RegisterDNP3Parsers(void) { SCEnter(); - char *proto_name = "dnp3"; + const char *proto_name = "dnp3"; if (AppLayerProtoDetectConfProtoDetectionEnabled("tcp", proto_name)) { @@ -2081,7 +2081,7 @@ static int DNP3ProbingParserTest(void) /** * \test Test a basic request/response. */ -int DNP3ParserTestRequestResponse(void) +static int DNP3ParserTestRequestResponse(void) { DNP3State *state = NULL; @@ -2231,7 +2231,7 @@ static int DNP3ParserTestUnsolicitedResponseConfirm(void) /** * \test Test flood state. */ -int DNP3ParserTestFlooded(void) +static int DNP3ParserTestFlooded(void) { DNP3State *state = NULL; diff --git a/src/app-layer-dns-tcp.c b/src/app-layer-dns-tcp.c index 4296a49c15..21b8817640 100644 --- a/src/app-layer-dns-tcp.c +++ b/src/app-layer-dns-tcp.c @@ -651,7 +651,7 @@ static uint16_t DNSTcpProbeResponse(uint8_t *input, uint32_t len, void RegisterDNSTCPParsers(void) { - char *proto_name = "dns"; + const char *proto_name = "dns"; /** DNS */ if (AppLayerProtoDetectConfProtoDetectionEnabled("tcp", proto_name)) { diff --git a/src/app-layer-dns-udp.c b/src/app-layer-dns-udp.c index 83d1834ce6..82354ca76b 100644 --- a/src/app-layer-dns-udp.c +++ b/src/app-layer-dns-udp.c @@ -383,7 +383,7 @@ static void DNSUDPConfigure(void) void RegisterDNSUDPParsers(void) { - char *proto_name = "dns"; + const char *proto_name = "dns"; /** DNS */ if (AppLayerProtoDetectConfProtoDetectionEnabled("udp", proto_name)) { diff --git a/src/app-layer-enip-common.c b/src/app-layer-enip-common.c index 3af8268145..844a5c91ac 100644 --- a/src/app-layer-enip-common.c +++ b/src/app-layer-enip-common.c @@ -41,7 +41,7 @@ * @param input * @param offset */ -int ENIPExtractUint8(uint8_t *res, uint8_t *input, uint16_t *offset, uint32_t input_len) +static int ENIPExtractUint8(uint8_t *res, uint8_t *input, uint16_t *offset, uint32_t input_len) { if (*offset > (input_len - sizeof(uint8_t))) @@ -61,7 +61,7 @@ int ENIPExtractUint8(uint8_t *res, uint8_t *input, uint16_t *offset, uint32_t in * @param input * @param offset */ -int ENIPExtractUint16(uint16_t *res, uint8_t *input, uint16_t *offset, uint32_t input_len) +static int ENIPExtractUint16(uint16_t *res, uint8_t *input, uint16_t *offset, uint32_t input_len) { if (*offset > (input_len - sizeof(uint16_t))) @@ -82,7 +82,7 @@ int ENIPExtractUint16(uint16_t *res, uint8_t *input, uint16_t *offset, uint32_t * @param input * @param offset */ -int ENIPExtractUint32(uint32_t *res, uint8_t *input, uint16_t *offset, uint32_t input_len) +static int ENIPExtractUint32(uint32_t *res, uint8_t *input, uint16_t *offset, uint32_t input_len) { if (*offset > (input_len - sizeof(uint32_t))) @@ -103,7 +103,7 @@ int ENIPExtractUint32(uint32_t *res, uint8_t *input, uint16_t *offset, uint32_t * @param input * @param offset */ -int ENIPExtractUint64(uint64_t *res, uint8_t *input, uint16_t *offset, uint32_t input_len) +static int ENIPExtractUint64(uint64_t *res, uint8_t *input, uint16_t *offset, uint32_t input_len) { if (*offset > (input_len - sizeof(uint64_t))) @@ -143,12 +143,12 @@ static CIPServiceEntry *CIPServiceAlloc(ENIPTransaction *tx) } - +#if 0 /** * \brief Delete service entry */ -void CIPServiceFree(void *s) +static void CIPServiceFree(void *s) { SCEnter(); if (s) @@ -173,8 +173,7 @@ void CIPServiceFree(void *s) } SCReturn; } - - +#endif /** * \brief Decode ENIP Encapsulation Header diff --git a/src/app-layer-enip.c b/src/app-layer-enip.c index d6218fa22f..27d1a5c7ec 100644 --- a/src/app-layer-enip.c +++ b/src/app-layer-enip.c @@ -61,7 +61,7 @@ SCEnumCharMap enip_decoder_event_table[ ] = { * * For ENIP we use a simple bool. */ -int ENIPGetAlstateProgress(void *tx, uint8_t direction) +static int ENIPGetAlstateProgress(void *tx, uint8_t direction) { return 1; } @@ -70,25 +70,26 @@ int ENIPGetAlstateProgress(void *tx, uint8_t direction) * * For ENIP we use a simple bool. */ -int ENIPGetAlstateProgressCompletionStatus(uint8_t direction) +static int ENIPGetAlstateProgressCompletionStatus(uint8_t direction) { return 1; } -DetectEngineState *ENIPGetTxDetectState(void *vtx) +static DetectEngineState *ENIPGetTxDetectState(void *vtx) { ENIPTransaction *tx = (ENIPTransaction *)vtx; return tx->de_state; } -int ENIPSetTxDetectState(void *state, void *vtx, DetectEngineState *s) +static int ENIPSetTxDetectState(void *state, void *vtx, DetectEngineState *s) { ENIPTransaction *tx = (ENIPTransaction *)vtx; tx->de_state = s; return 0; } -void *ENIPGetTx(void *alstate, uint64_t tx_id) { +static void *ENIPGetTx(void *alstate, uint64_t tx_id) +{ ENIPState *enip = (ENIPState *) alstate; ENIPTransaction *tx = NULL; @@ -106,11 +107,13 @@ void *ENIPGetTx(void *alstate, uint64_t tx_id) { return NULL; } -uint64_t ENIPGetTxCnt(void *alstate) { +static uint64_t ENIPGetTxCnt(void *alstate) +{ return ((uint64_t) ((ENIPState *) alstate)->transaction_max); } -AppLayerDecoderEvents *ENIPGetEvents(void *state, uint64_t id) { +static AppLayerDecoderEvents *ENIPGetEvents(void *state, uint64_t id) +{ ENIPState *enip = (ENIPState *) state; ENIPTransaction *tx; @@ -125,11 +128,13 @@ AppLayerDecoderEvents *ENIPGetEvents(void *state, uint64_t id) { return NULL; } -int ENIPHasEvents(void *state) { +static int ENIPHasEvents(void *state) +{ return (((ENIPState *) state)->events > 0); } -int ENIPStateGetEventInfo(const char *event_name, int *event_id, AppLayerEventType *event_type) { +static int ENIPStateGetEventInfo(const char *event_name, int *event_id, AppLayerEventType *event_type) +{ *event_id = SCMapEnumNameToValue(event_name, enip_decoder_event_table); if (*event_id == -1) { @@ -148,7 +153,7 @@ int ENIPStateGetEventInfo(const char *event_name, int *event_id, AppLayerEventTy * * return state */ -void *ENIPStateAlloc(void) +static void *ENIPStateAlloc(void) { SCLogDebug("ENIPStateAlloc"); void *s = SCMalloc(sizeof(ENIPState)); @@ -211,7 +216,7 @@ static void ENIPTransactionFree(ENIPTransaction *tx, ENIPState *state) /** \brief Free enip state * */ -void ENIPStateFree(void *s) +static void ENIPStateFree(void *s) { SCEnter(); SCLogDebug("ENIPStateFree"); @@ -265,7 +270,7 @@ static ENIPTransaction *ENIPTransactionAlloc(ENIPState *state) /** * \brief enip transaction cleanup callback */ -void ENIPStateTransactionFree(void *state, uint64_t tx_id) +static void ENIPStateTransactionFree(void *state, uint64_t tx_id) { SCEnter(); SCLogDebug("ENIPStateTransactionFree"); @@ -374,7 +379,7 @@ static uint16_t ENIPProbingParser(uint8_t *input, uint32_t input_len, void RegisterENIPUDPParsers(void) { SCEnter(); - char *proto_name = "enip"; + const char *proto_name = "enip"; if (AppLayerProtoDetectConfProtoDetectionEnabled("udp", proto_name)) { @@ -462,7 +467,7 @@ void RegisterENIPUDPParsers(void) void RegisterENIPTCPParsers(void) { SCEnter(); - char *proto_name = "enip"; + const char *proto_name = "enip"; if (AppLayerProtoDetectConfProtoDetectionEnabled("tcp", proto_name)) { @@ -555,7 +560,7 @@ static uint8_t listIdentity[] = {/* List ID */ 0x63, 0x00, /** * \brief Test if ENIP Packet matches signature */ -int ALDecodeENIPTest(void) +static int ALDecodeENIPTest(void) { AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); Flow f; diff --git a/src/app-layer-ftp.c b/src/app-layer-ftp.c index 7bdd404369..681f7ab9c2 100644 --- a/src/app-layer-ftp.c +++ b/src/app-layer-ftp.c @@ -400,7 +400,7 @@ static int FTPRegisterPatternsForProtocolDetection(void) void RegisterFTPParsers(void) { - char *proto_name = "ftp"; + const char *proto_name = "ftp"; /** FTP */ if (AppLayerProtoDetectConfProtoDetectionEnabled("tcp", proto_name)) { @@ -453,7 +453,7 @@ void FTPAtExitPrintStats(void) #ifdef UNITTESTS /** \test Send a get request in one chunk. */ -int FTPParserTest01(void) +static int FTPParserTest01(void) { int result = 1; Flow f; @@ -504,7 +504,7 @@ end: } /** \test Send a splitted get request. */ -int FTPParserTest03(void) +static int FTPParserTest03(void) { int result = 1; Flow f; @@ -581,7 +581,7 @@ end: } /** \test See how it deals with an incomplete request. */ -int FTPParserTest06(void) +static int FTPParserTest06(void) { int result = 1; Flow f; @@ -634,7 +634,7 @@ end: } /** \test See how it deals with an incomplete request in multiple chunks. */ -int FTPParserTest07(void) +static int FTPParserTest07(void) { int result = 1; Flow f; @@ -701,7 +701,7 @@ end: /** \test Test case where chunks are smaller than the delim length and the * last chunk is supposed to match the delim. */ -int FTPParserTest10(void) +static int FTPParserTest10(void) { int result = 1; Flow f; diff --git a/src/app-layer-htp-body.c b/src/app-layer-htp-body.c index 3520182a63..650b8f4805 100644 --- a/src/app-layer-htp-body.c +++ b/src/app-layer-htp-body.c @@ -44,6 +44,7 @@ #include "app-layer-protos.h" #include "app-layer-parser.h" #include "app-layer-htp.h" +#include "app-layer-htp-body.h" #include "util-spm.h" #include "util-debug.h" diff --git a/src/app-layer-htp-file.c b/src/app-layer-htp-file.c index 520f734c03..26ac3e529f 100644 --- a/src/app-layer-htp-file.c +++ b/src/app-layer-htp-file.c @@ -43,6 +43,7 @@ #include "app-layer-protos.h" #include "app-layer-parser.h" #include "app-layer-htp.h" +#include "app-layer-htp-file.h" #include "util-spm.h" #include "util-debug.h" diff --git a/src/app-layer-htp-libhtp.c b/src/app-layer-htp-libhtp.c index 69d862208d..3f040213fa 100644 --- a/src/app-layer-htp-libhtp.c +++ b/src/app-layer-htp-libhtp.c @@ -41,56 +41,7 @@ #include "suricata.h" #include "suricata-common.h" - - -/** - * \brief A direct flick off libhtp-0.5.x htp_is_lws(). - */ -static int SC_htp_is_lws(int c) -{ - if ((c == ' ') || (c == '\t')) return 1; - else return 0; -} - -/** - * \brief A direct flick off libhtp-0.5.x htp_parse_positive_integer_whitespace(). - */ -static int64_t SC_htp_parse_positive_integer_whitespace(unsigned char *data, size_t len, int base) -{ - if (len == 0) return -1003; - - size_t last_pos; - size_t pos = 0; - - // Ignore LWS before - while ((pos < len) && (SC_htp_is_lws(data[pos]))) pos++; - if (pos == len) return -1001; - - int64_t r = bstr_util_mem_to_pint(data + pos, len - pos, base, &last_pos); - if (r < 0) return r; - - // Move after the last digit - pos += last_pos; - - // Ignore LWS after - while (pos < len) { - if (!SC_htp_is_lws(data[pos])) { - return -1002; - } - - pos++; - } - - return r; -} - -/** - * \brief A direct flick off libhtp-0.5.x htp_parse_content_length() - */ -int64_t SC_htp_parse_content_length(bstr *b) -{ - return SC_htp_parse_positive_integer_whitespace((unsigned char *) bstr_ptr(b), bstr_len(b), 10); -} +#include "app-layer-htp-libhtp.h" /** * \brief Generates the normalized uri. diff --git a/src/app-layer-htp-libhtp.h b/src/app-layer-htp-libhtp.h index 4c4eb3cd9b..8f321152a2 100644 --- a/src/app-layer-htp-libhtp.h +++ b/src/app-layer-htp-libhtp.h @@ -46,6 +46,5 @@ #include "suricata-common.h" bstr *SCHTPGenerateNormalizedUri(htp_tx_t *tx, htp_uri_t *uri, int uri_include_all); -int64_t SC_htp_parse_content_length(bstr *b); #endif /* __APP_LAYER_HTP_LIBHTP__H__ */ diff --git a/src/app-layer-htp-mem.c b/src/app-layer-htp-mem.c index c9caefa2df..06bbe00f00 100644 --- a/src/app-layer-htp-mem.c +++ b/src/app-layer-htp-mem.c @@ -45,7 +45,7 @@ SC_ATOMIC_DECLARE(uint64_t, htp_memcap); void HTPParseMemcap() { - char *conf_val; + const char *conf_val; /** set config values for memcap, prealloc and hash_size */ if ((ConfGet("app-layer.protocols.http.memcap", &conf_val)) == 1) @@ -66,13 +66,13 @@ void HTPParseMemcap() SC_ATOMIC_INIT(htp_memcap); } -void HTPIncrMemuse(uint64_t size) +static void HTPIncrMemuse(uint64_t size) { (void) SC_ATOMIC_ADD(htp_memuse, size); return; } -void HTPDecrMemuse(uint64_t size) +static void HTPDecrMemuse(uint64_t size) { (void) SC_ATOMIC_SUB(htp_memuse, size); return; @@ -96,7 +96,7 @@ uint64_t HTPMemcapGlobalCounter(void) * \retval 1 if in bounds * \retval 0 if not in bounds */ -int HTPCheckMemcap(uint64_t size) +static int HTPCheckMemcap(uint64_t size) { if (htp_config_memcap == 0 || size + SC_ATOMIC_GET(htp_memuse) <= htp_config_memcap) return 1; diff --git a/src/app-layer-htp-mem.h b/src/app-layer-htp-mem.h index 1039c32ce6..8ac36057b6 100644 --- a/src/app-layer-htp-mem.h +++ b/src/app-layer-htp-mem.h @@ -17,7 +17,7 @@ #include "stream-tcp-reassemble.h" -void HTPParseMemcap(); +void HTPParseMemcap(void); void *HTPMalloc(size_t size); void *HTPCalloc(size_t n, size_t size); void *HTPRealloc(void *ptr, size_t orig_size, size_t size); diff --git a/src/app-layer-htp-xff.h b/src/app-layer-htp-xff.h index 1a3b67e16b..b02d95de2a 100644 --- a/src/app-layer-htp-xff.h +++ b/src/app-layer-htp-xff.h @@ -40,7 +40,7 @@ typedef struct HttpXFFCfg_ { uint8_t flags; /**< XFF operation mode and deployment */ - char *header; /**< XFF header name */ + const char *header; /**< XFF header name */ } HttpXFFCfg; void HttpXFFGetCfg(ConfNode *conf, HttpXFFCfg *result); diff --git a/src/app-layer-htp.c b/src/app-layer-htp.c index 18662870a7..43441fc767 100644 --- a/src/app-layer-htp.c +++ b/src/app-layer-htp.c @@ -234,7 +234,7 @@ static int HTPLookupPersonality(const char *str) return -1; } -void HTPSetEvent(HtpState *s, HtpTxUserData *htud, uint8_t e) +static void HTPSetEvent(HtpState *s, HtpTxUserData *htud, uint8_t e) { SCLogDebug("setting event %u", e); @@ -447,7 +447,7 @@ void AppLayerHtpEnableResponseBodyCallback(void) * * \initonly */ -void AppLayerHtpNeedMultipartHeader(void) +static void AppLayerHtpNeedMultipartHeader(void) { SCEnter(); AppLayerHtpEnableRequestBodyCallback(); @@ -475,7 +475,7 @@ void AppLayerHtpNeedFileInspection(void) /* below error messages updated up to libhtp 0.5.7 (git 379632278b38b9a792183694a4febb9e0dbd1e7a) */ struct { - char *msg; + const char *msg; int de; } htp_errors[] = { { "GZip decompressor: inflateInit2 failed", HTTP_DECODER_EVENT_GZIP_DECOMPRESSION_FAILED}, @@ -496,7 +496,7 @@ struct { }; struct { - char *msg; + const char *msg; int de; } htp_warnings[] = { { "GZip decompressor:", HTTP_DECODER_EVENT_GZIP_DECOMPRESSION_FAILED}, @@ -1201,7 +1201,7 @@ static void HtpRequestBodySetupBoundary(HtpTxUserData *htud, memcpy(boundary + 2, htud->boundary, htud->boundary_len); } -int HtpRequestBodyHandleMultipart(HtpState *hstate, HtpTxUserData *htud, void *tx, +static int HtpRequestBodyHandleMultipart(HtpState *hstate, HtpTxUserData *htud, void *tx, const uint8_t *chunks_buffer, uint32_t chunks_buffer_len) { int result = 0; @@ -1498,7 +1498,7 @@ end: /** \brief setup things for put request * \todo really needed? */ -int HtpRequestBodySetupPUT(htp_tx_data_t *d, HtpTxUserData *htud) +static int HtpRequestBodySetupPUT(htp_tx_data_t *d, HtpTxUserData *htud) { // if (d->tx->parsed_uri == NULL || d->tx->parsed_uri->path == NULL) { // return -1; @@ -1617,7 +1617,7 @@ end: return -1; } -int HtpResponseBodyHandle(HtpState *hstate, HtpTxUserData *htud, +static int HtpResponseBodyHandle(HtpState *hstate, HtpTxUserData *htud, htp_tx_t *tx, uint8_t *data, uint32_t data_len) { SCEnter(); @@ -1692,7 +1692,7 @@ end: * \param d pointer to the htp_tx_data_t structure (a chunk from htp lib) * \retval int HTP_OK if all goes well */ -int HTPCallbackRequestBodyData(htp_tx_data_t *d) +static int HTPCallbackRequestBodyData(htp_tx_data_t *d) { SCEnter(); @@ -1809,7 +1809,7 @@ end: * \param d pointer to the htp_tx_data_t structure (a chunk from htp lib) * \retval int HTP_OK if all goes well */ -int HTPCallbackResponseBodyData(htp_tx_data_t *d) +static int HTPCallbackResponseBodyData(htp_tx_data_t *d) { SCEnter(); @@ -2195,7 +2195,7 @@ static void HTPConfigSetDefaultsPhase1(HTPCfgRec *cfg_prec) * before the callback set by Phase2() is called. We need this, since * the callback in Phase2() generates the normalized uri which utilizes * the query and path. */ -static void HTPConfigSetDefaultsPhase2(char *name, HTPCfgRec *cfg_prec) +static void HTPConfigSetDefaultsPhase2(const char *name, HTPCfgRec *cfg_prec) { /* randomize inspection size if needed */ if (cfg_prec->randomize) { @@ -2664,7 +2664,7 @@ static int HTPStateGetAlstateProgressCompletionStatus(uint8_t direction) return (direction & STREAM_TOSERVER) ? HTP_REQUEST_COMPLETE : HTP_RESPONSE_COMPLETE; } -int HTPStateGetEventInfo(const char *event_name, +static int HTPStateGetEventInfo(const char *event_name, int *event_id, AppLayerEventType *event_type) { *event_id = SCMapEnumNameToValue(event_name, http_decoder_event_table); @@ -2742,13 +2742,13 @@ static int HTPSetTxMpmIDs(void *vtx, uint64_t mpm_ids) static int HTPRegisterPatternsForProtocolDetection(void) { - char *methods[] = { "GET", "PUT", "POST", "HEAD", "TRACE", "OPTIONS", + const char *methods[] = { "GET", "PUT", "POST", "HEAD", "TRACE", "OPTIONS", "CONNECT", "DELETE", "PATCH", "PROPFIND", "PROPPATCH", "MKCOL", "COPY", "MOVE", "LOCK", "UNLOCK", "CHECKOUT", "UNCHECKOUT", "CHECKIN", "UPDATE", "LABEL", "REPORT", "MKWORKSPACE", "MKACTIVITY", "MERGE", "INVALID", "VERSION-CONTROL", "BASELINE-CONTROL", NULL}; - char *spacings[] = { "|20|", "|09|", NULL }; - char *versions[] = { "HTTP/0.9", "HTTP/1.0", "HTTP/1.1", NULL }; + const char *spacings[] = { "|20|", "|09|", NULL }; + const char *versions[] = { "HTTP/0.9", "HTTP/1.0", "HTTP/1.1", NULL }; int methods_pos; int spacings_pos; @@ -2796,7 +2796,7 @@ void RegisterHTPParsers(void) { SCEnter(); - char *proto_name = "http"; + const char *proto_name = "http"; /** HTTP */ if (AppLayerProtoDetectConfProtoDetectionEnabled("tcp", proto_name)) { @@ -2868,7 +2868,7 @@ void HtpConfigRestoreBackup(void) /** \test Test case where chunks are sent in smaller chunks and check the * response of the parser from HTP library. */ -int HTPParserTest01(void) +static int HTPParserTest01(void) { int result = 0; Flow *f = NULL; @@ -3022,7 +3022,7 @@ end: } /** \test See how it deals with an incomplete request. */ -int HTPParserTest02(void) +static int HTPParserTest02(void) { int result = 0; Flow *f = NULL; @@ -3080,7 +3080,7 @@ end: /** \test Test case where method is invalid and data is sent in smaller chunks * and check the response of the parser from HTP library. */ -int HTPParserTest03(void) +static int HTPParserTest03(void) { int result = 0; Flow *f = NULL; @@ -3150,7 +3150,7 @@ end: /** \test Test case where invalid data is sent and check the response of the * parser from HTP library. */ -int HTPParserTest04(void) +static int HTPParserTest04(void) { int result = 0; Flow *f = NULL; @@ -3211,7 +3211,7 @@ end: /** \test Test both sides of a http stream mixed up to see if the HTP parser * properly parsed them and also keeps them separated. */ -int HTPParserTest05(void) +static int HTPParserTest05(void) { int result = 0; Flow *f = NULL; @@ -3331,7 +3331,7 @@ end: /** \test Test proper chunked encoded response body */ -int HTPParserTest06(void) +static int HTPParserTest06(void) { int result = 0; Flow *f = NULL; @@ -3450,7 +3450,7 @@ end: /** \test */ -int HTPParserTest07(void) +static int HTPParserTest07(void) { int result = 0; Flow *f = NULL; @@ -3542,7 +3542,7 @@ end: /** \test Abort */ -int HTPParserTest08(void) +static int HTPParserTest08(void) { int result = 0; Flow *f = NULL; @@ -3629,7 +3629,7 @@ end: /** \test Abort */ -int HTPParserTest09(void) +static int HTPParserTest09(void) { int result = 0; Flow *f = NULL; @@ -3715,7 +3715,7 @@ end: /** \test Host:www.google.com <- missing space between name:value (rfc violation) */ -int HTPParserTest10(void) +static int HTPParserTest10(void) { int result = 0; Flow *f = NULL; @@ -3983,7 +3983,7 @@ static int HTPParserTest12(void) /** \test Host:www.google.com0dName: Value0d0a <- missing space between name:value (rfc violation) */ -int HTPParserTest13(void) +static int HTPParserTest13(void) { int result = 0; Flow *f = NULL; @@ -4077,7 +4077,7 @@ end: } /** \test Test basic config */ -int HTPParserConfigTest01(void) +static int HTPParserConfigTest01(void) { int ret = 0; char input[] = "\ @@ -4256,7 +4256,7 @@ end: } /** \test Test config builds radix correctly */ -int HTPParserConfigTest02(void) +static int HTPParserConfigTest02(void) { int ret = 0; char input[] = "\ @@ -4352,7 +4352,7 @@ end: } /** \test Test traffic is handled by the correct htp config */ -int HTPParserConfigTest03(void) +static int HTPParserConfigTest03(void) { int result = 1; Flow *f = NULL; @@ -4393,7 +4393,7 @@ libhtp:\n\ HTPConfigure(); - char *addr = "192.168.10.42"; + const char *addr = "192.168.10.42"; memset(&ssn, 0, sizeof(ssn)); @@ -4486,7 +4486,7 @@ end: /* disabled when we upgraded to libhtp 0.5.x */ #if 0 -int HTPParserConfigTest04(void) +static int HTPParserConfigTest04(void) { int result = 0; @@ -4592,7 +4592,7 @@ libhtp:\n\ HtpConfigCreateBackup(); ConfYamlLoadString(input, strlen(input)); HTPConfigure(); - char *addr = "4.3.2.1"; + const char *addr = "4.3.2.1"; memset(&ssn, 0, sizeof(ssn)); f = UTHBuildFlow(AF_INET, "1.2.3.4", addr, 1024, 80); @@ -4762,7 +4762,7 @@ libhtp:\n\ HtpConfigCreateBackup(); ConfYamlLoadString(input, strlen(input)); HTPConfigure(); - char *addr = "4.3.2.1"; + const char *addr = "4.3.2.1"; memset(&ssn, 0, sizeof(ssn)); f = UTHBuildFlow(AF_INET, "1.2.3.4", addr, 1024, 80); @@ -4930,7 +4930,7 @@ libhtp:\n\ HtpConfigCreateBackup(); ConfYamlLoadString(input, strlen(input)); HTPConfigure(); - char *addr = "4.3.2.1"; + const char *addr = "4.3.2.1"; memset(&ssn, 0, sizeof(ssn)); f = UTHBuildFlow(AF_INET, "1.2.3.4", addr, 1024, 80); @@ -5068,7 +5068,7 @@ libhtp:\n\ HtpConfigCreateBackup(); ConfYamlLoadString(input, strlen(input)); HTPConfigure(); - char *addr = "4.3.2.1"; + const char *addr = "4.3.2.1"; memset(&ssn, 0, sizeof(ssn)); f = UTHBuildFlow(AF_INET, "1.2.3.4", addr, 1024, 80); @@ -5179,7 +5179,7 @@ libhtp:\n\ HtpConfigCreateBackup(); ConfYamlLoadString(input, strlen(input)); HTPConfigure(); - char *addr = "4.3.2.1"; + const char *addr = "4.3.2.1"; memset(&ssn, 0, sizeof(ssn)); f = UTHBuildFlow(AF_INET, "1.2.3.4", addr, 1024, 80); @@ -5290,7 +5290,7 @@ libhtp:\n\ HtpConfigCreateBackup(); ConfYamlLoadString(input, strlen(input)); HTPConfigure(); - char *addr = "4.3.2.1"; + const char *addr = "4.3.2.1"; memset(&ssn, 0, sizeof(ssn)); f = UTHBuildFlow(AF_INET, "1.2.3.4", addr, 1024, 80); @@ -5402,7 +5402,7 @@ libhtp:\n\ HtpConfigCreateBackup(); ConfYamlLoadString(input, strlen(input)); HTPConfigure(); - char *addr = "4.3.2.1"; + const char *addr = "4.3.2.1"; memset(&ssn, 0, sizeof(ssn)); f = UTHBuildFlow(AF_INET, "1.2.3.4", addr, 1024, 80); @@ -5511,7 +5511,7 @@ libhtp:\n\ HtpConfigCreateBackup(); ConfYamlLoadString(input, strlen(input)); HTPConfigure(); - char *addr = "4.3.2.1"; + const char *addr = "4.3.2.1"; memset(&ssn, 0, sizeof(ssn)); f = UTHBuildFlow(AF_INET, "1.2.3.4", addr, 1024, 80); @@ -5621,7 +5621,7 @@ libhtp:\n\ HtpConfigCreateBackup(); ConfYamlLoadString(input, strlen(input)); HTPConfigure(); - char *addr = "4.3.2.1"; + const char *addr = "4.3.2.1"; memset(&ssn, 0, sizeof(ssn)); f = UTHBuildFlow(AF_INET, "1.2.3.4", addr, 1024, 80); @@ -5847,7 +5847,7 @@ end: } /** \test Test really long request, this should result in HTTP_DECODER_EVENT_REQUEST_FIELD_TOO_LONG */ -int HTPParserTest14(void) +static int HTPParserTest14(void) { int result = 0; Flow *f = NULL; @@ -5989,7 +5989,7 @@ end: /** \test Test really long request (same as HTPParserTest14), now with config * update to allow it */ -int HTPParserTest15(void) +static int HTPParserTest15(void) { int result = 0; Flow *f = NULL; @@ -6113,7 +6113,7 @@ end: } /** \test Test unusual delims in request line HTTP_DECODER_EVENT_REQUEST_FIELD_TOO_LONG */ -int HTPParserTest16(void) +static int HTPParserTest16(void) { int result = 0; Flow *f = NULL; @@ -6200,7 +6200,7 @@ end: } /** \test CONNECT with plain text HTTP being tunneled */ -int HTPParserTest17(void) +static int HTPParserTest17(void) { int result = 0; Flow *f = NULL; @@ -6323,7 +6323,7 @@ end: } /** \test CONNECT with plain text HTTP being tunneled */ -int HTPParserTest18(void) +static int HTPParserTest18(void) { int result = 0; Flow *f = NULL; @@ -6456,7 +6456,7 @@ end: } /** \test CONNECT with TLS content (start of it at least) */ -int HTPParserTest19(void) +static int HTPParserTest19(void) { int result = 0; Flow *f = NULL; diff --git a/src/app-layer-htp.h b/src/app-layer-htp.h index b8f4f29b70..60e89a84f6 100644 --- a/src/app-layer-htp.h +++ b/src/app-layer-htp.h @@ -264,10 +264,6 @@ void HTPParserRegisterTests(void); void HTPAtExitPrintStats(void); void HTPFreeConfig(void); -htp_tx_t *HTPTransactionMain(const HtpState *); - -int HTPCallbackRequestBodyData(htp_tx_data_t *); -int HtpTransactionGetLoggableId(Flow *); void HtpBodyPrint(HtpBody *); void HtpBodyFree(HtpBody *); /* To free the state from unittests using app-layer-htp */ diff --git a/src/app-layer-modbus.c b/src/app-layer-modbus.c index 97fd4be0d7..a4754dfdc9 100644 --- a/src/app-layer-modbus.c +++ b/src/app-layer-modbus.c @@ -171,7 +171,8 @@ typedef struct ModbusHeader_ ModbusHeader; static uint32_t request_flood = MODBUS_CONFIG_DEFAULT_REQUEST_FLOOD; static uint32_t stream_depth = MODBUS_CONFIG_DEFAULT_STREAM_DEPTH; -int ModbusStateGetEventInfo(const char *event_name, int *event_id, AppLayerEventType *event_type) { +static int ModbusStateGetEventInfo(const char *event_name, int *event_id, AppLayerEventType *event_type) +{ *event_id = SCMapEnumNameToValue(event_name, modbus_decoder_event_table); if (*event_id == -1) { @@ -186,7 +187,8 @@ int ModbusStateGetEventInfo(const char *event_name, int *event_id, AppLayerEvent return 0; } -void ModbusSetEvent(ModbusState *modbus, uint8_t e) { +static void ModbusSetEvent(ModbusState *modbus, uint8_t e) +{ if (modbus && modbus->curr) { SCLogDebug("modbus->curr->decoder_events %p", modbus->curr->decoder_events); AppLayerDecoderEventsSetEventRaw(&modbus->curr->decoder_events, e); @@ -196,7 +198,8 @@ void ModbusSetEvent(ModbusState *modbus, uint8_t e) { SCLogDebug("couldn't set event %u", e); } -AppLayerDecoderEvents *ModbusGetEvents(void *state, uint64_t id) { +static AppLayerDecoderEvents *ModbusGetEvents(void *state, uint64_t id) +{ ModbusState *modbus = (ModbusState *) state; ModbusTransaction *tx; @@ -211,11 +214,13 @@ AppLayerDecoderEvents *ModbusGetEvents(void *state, uint64_t id) { return NULL; } -int ModbusHasEvents(void *state) { +static int ModbusHasEvents(void *state) +{ return (((ModbusState *) state)->events > 0); } -int ModbusGetAlstateProgress(void *modbus_tx, uint8_t direction) { +static int ModbusGetAlstateProgress(void *modbus_tx, uint8_t direction) +{ ModbusTransaction *tx = (ModbusTransaction *) modbus_tx; ModbusState *modbus = tx->modbus; @@ -232,11 +237,13 @@ int ModbusGetAlstateProgress(void *modbus_tx, uint8_t direction) { /** \brief Get value for 'complete' status in Modbus */ -int ModbusGetAlstateProgressCompletionStatus(uint8_t direction) { +static int ModbusGetAlstateProgressCompletionStatus(uint8_t direction) +{ return 1; } -void *ModbusGetTx(void *alstate, uint64_t tx_id) { +static void *ModbusGetTx(void *alstate, uint64_t tx_id) +{ ModbusState *modbus = (ModbusState *) alstate; ModbusTransaction *tx = NULL; @@ -255,13 +262,13 @@ void *ModbusGetTx(void *alstate, uint64_t tx_id) { return NULL; } -void ModbusSetTxLogged(void *alstate, void *vtx, uint32_t logger) +static void ModbusSetTxLogged(void *alstate, void *vtx, uint32_t logger) { ModbusTransaction *tx = (ModbusTransaction *)vtx; tx->logged |= logger; } -int ModbusGetTxLogged(void *alstate, void *vtx, uint32_t logger) +static int ModbusGetTxLogged(void *alstate, void *vtx, uint32_t logger) { ModbusTransaction *tx = (ModbusTransaction *)vtx; if (tx->logged & logger) @@ -270,7 +277,8 @@ int ModbusGetTxLogged(void *alstate, void *vtx, uint32_t logger) return 0; } -uint64_t ModbusGetTxCnt(void *alstate) { +static uint64_t ModbusGetTxCnt(void *alstate) +{ return ((uint64_t) ((ModbusState *) alstate)->transaction_max); } @@ -283,7 +291,8 @@ uint64_t ModbusGetTxCnt(void *alstate) { * \retval tx or NULL if not found */ static ModbusTransaction *ModbusTxFindByTransaction(const ModbusState *modbus, - const uint16_t transactionId) { + const uint16_t transactionId) +{ ModbusTransaction *tx = NULL; if (modbus->curr == NULL) @@ -363,7 +372,8 @@ static void ModbusTxFree(ModbusTransaction *tx) { /** * \brief Modbus transaction cleanup callback */ -void ModbusStateTxFree(void *state, uint64_t tx_id) { +static void ModbusStateTxFree(void *state, uint64_t tx_id) +{ SCEnter(); ModbusState *modbus = (ModbusState *) state; ModbusTransaction *tx = NULL, *ttx; @@ -1439,13 +1449,13 @@ static uint16_t ModbusProbingParser(uint8_t *input, return ALPROTO_MODBUS; } -DetectEngineState *ModbusGetTxDetectState(void *vtx) +static DetectEngineState *ModbusGetTxDetectState(void *vtx) { ModbusTransaction *tx = (ModbusTransaction *)vtx; return tx->de_state; } -int ModbusSetTxDetectState(void *state, void *vtx, DetectEngineState *s) +static int ModbusSetTxDetectState(void *state, void *vtx, DetectEngineState *s) { ModbusTransaction *tx = (ModbusTransaction *)vtx; tx->de_state = s; @@ -1458,7 +1468,7 @@ int ModbusSetTxDetectState(void *state, void *vtx, DetectEngineState *s) void RegisterModbusParsers(void) { SCEnter(); - char *proto_name = "modbus"; + const char *proto_name = "modbus"; /* Modbus application protocol V1.1b3 */ if (AppLayerProtoDetectConfProtoDetectionEnabled("tcp", proto_name)) { diff --git a/src/app-layer-smb.c b/src/app-layer-smb.c index 9c8031261f..fee5ec2f17 100644 --- a/src/app-layer-smb.c +++ b/src/app-layer-smb.c @@ -1567,7 +1567,7 @@ static int SMBRegisterPatternsForProtocolDetection(void) void RegisterSMBParsers(void) { - char *proto_name = "smb"; + const char *proto_name = "smb"; if (AppLayerProtoDetectConfProtoDetectionEnabled("tcp", proto_name)) { AppLayerProtoDetectRegisterProtocol(ALPROTO_SMB, proto_name); @@ -1631,7 +1631,7 @@ void RegisterSMBParsers(void) /** * \test SMBParserTest01 tests the NBSS and SMB header decoding */ -int SMBParserTest01(void) +static int SMBParserTest01(void) { int result = 0; Flow f; @@ -1703,7 +1703,7 @@ end: /** * \test SMBParserTest02 tests the NBSS, SMB, and DCERPC over SMB header decoding */ -int SMBParserTest02(void) +static int SMBParserTest02(void) { int result = 0; Flow f; @@ -1781,7 +1781,7 @@ end: return result; } -int SMBParserTest03(void) +static int SMBParserTest03(void) { int result = 0; Flow f; @@ -2088,7 +2088,7 @@ end: return result; } -int SMBParserTest04(void) +static int SMBParserTest04(void) { int result = 0; Flow f; @@ -2219,7 +2219,7 @@ end: return result; } -int SMBParserTest05(void) +static int SMBParserTest05(void) { AppLayerProtoDetectUnittestCtxBackup(); AppLayerProtoDetectSetup(); @@ -2320,7 +2320,7 @@ int SMBParserTest05(void) return result; } -int SMBParserTest06(void) +static int SMBParserTest06(void) { AppLayerProtoDetectUnittestCtxBackup(); AppLayerProtoDetectSetup(); @@ -2404,7 +2404,7 @@ int SMBParserTest06(void) return result; } -int SMBParserTest07(void) +static int SMBParserTest07(void) { int result = 0; Flow f; @@ -2465,7 +2465,7 @@ end: return result; } -int SMBParserTest08(void) +static int SMBParserTest08(void) { int result = 0; Flow f; @@ -2569,7 +2569,7 @@ end: return result; } -int SMBParserTest09(void) +static int SMBParserTest09(void) { int result = 0; Flow f; @@ -2691,7 +2691,7 @@ end: * \test Test to temporarily to show the direction demaraction issue in the * smb parser. */ -int SMBParserTest10(void) +static int SMBParserTest10(void) { int result = 0; Flow f; diff --git a/src/app-layer-smb2.c b/src/app-layer-smb2.c index 58821cb13d..8e0012ace7 100644 --- a/src/app-layer-smb2.c +++ b/src/app-layer-smb2.c @@ -597,7 +597,7 @@ static void SMB2StateFree(void *s) void RegisterSMB2Parsers(void) { /** SMB2 */ - char *proto_name = "smb2"; + const char *proto_name = "smb2"; if (AppLayerProtoDetectConfProtoDetectionEnabled("tcp", proto_name)) { AppLayerParserRegisterParser(IPPROTO_TCP, ALPROTO_SMB2, STREAM_TOSERVER, SMB2Parse); @@ -617,7 +617,7 @@ void RegisterSMB2Parsers(void) /* UNITTESTS */ #ifdef UNITTESTS -int SMB2ParserTest01(void) +static int SMB2ParserTest01(void) { int result = 1; Flow f; diff --git a/src/app-layer-smtp.c b/src/app-layer-smtp.c index a87e08e921..56fd838fcd 100644 --- a/src/app-layer-smtp.c +++ b/src/app-layer-smtp.c @@ -328,7 +328,7 @@ static void SMTPConfigure(void) { SCReturn; } -void SMTPSetEvent(SMTPState *s, uint8_t e) +static void SMTPSetEvent(SMTPState *s, uint8_t e) { SCLogDebug("setting event %u", e); @@ -1472,7 +1472,7 @@ static void SMTPFreeMpmState(void) } } -int SMTPStateGetEventInfo(const char *event_name, +static int SMTPStateGetEventInfo(const char *event_name, int *event_id, AppLayerEventType *event_type) { *event_id = SCMapEnumNameToValue(event_name, smtp_decoder_event_table); @@ -1640,7 +1640,7 @@ static int SMTPSetTxDetectState(void *state, void *vtx, DetectEngineState *s) */ void RegisterSMTPParsers(void) { - char *proto_name = "smtp"; + const char *proto_name = "smtp"; if (AppLayerProtoDetectConfProtoDetectionEnabled("tcp", proto_name)) { AppLayerProtoDetectRegisterProtocol(ALPROTO_SMTP, proto_name); diff --git a/src/app-layer-ssh.c b/src/app-layer-ssh.c index b7a5b2be43..7629776903 100644 --- a/src/app-layer-ssh.c +++ b/src/app-layer-ssh.c @@ -616,7 +616,7 @@ static int SSHRegisterPatternsForProtocolDetection(void) */ void RegisterSSHParsers(void) { - char *proto_name = "ssh"; + const char *proto_name = "ssh"; if (AppLayerProtoDetectConfProtoDetectionEnabled("tcp", proto_name)) { AppLayerProtoDetectRegisterProtocol(ALPROTO_SSH, proto_name); diff --git a/src/app-layer-ssl.c b/src/app-layer-ssl.c index 0215eed77d..a2c05cbc23 100644 --- a/src/app-layer-ssl.c +++ b/src/app-layer-ssl.c @@ -152,19 +152,19 @@ void SSLSetEvent(SSLState *ssl_state, uint8_t event) ssl_state->events++; } -AppLayerDecoderEvents *SSLGetEvents(void *state, uint64_t id) +static AppLayerDecoderEvents *SSLGetEvents(void *state, uint64_t id) { SSLState *ssl_state = (SSLState *)state; return ssl_state->decoder_events; } -int SSLHasEvents(void *state) +static int SSLHasEvents(void *state) { SSLState *ssl_state = (SSLState *)state; return (ssl_state->events > 0); } -int SSLStateHasTxDetectState(void *state) +static int SSLStateHasTxDetectState(void *state) { SSLState *ssl_state = (SSLState *)state; if (ssl_state->de_state) @@ -173,39 +173,39 @@ int SSLStateHasTxDetectState(void *state) return 0; } -int SSLSetTxDetectState(void *state, void *vtx, DetectEngineState *de_state) +static int SSLSetTxDetectState(void *state, void *vtx, DetectEngineState *de_state) { SSLState *ssl_state = (SSLState *)state; ssl_state->de_state = de_state; return 0; } -DetectEngineState *SSLGetTxDetectState(void *vtx) +static DetectEngineState *SSLGetTxDetectState(void *vtx) { SSLState *ssl_state = (SSLState *)vtx; return ssl_state->de_state; } -void *SSLGetTx(void *state, uint64_t tx_id) +static void *SSLGetTx(void *state, uint64_t tx_id) { SSLState *ssl_state = (SSLState *)state; return ssl_state; } -uint64_t SSLGetTxCnt(void *state) +static uint64_t SSLGetTxCnt(void *state) { /* single tx */ return 1; } -void SSLSetTxLogged(void *state, void *tx, uint32_t logger) +static void SSLSetTxLogged(void *state, void *tx, uint32_t logger) { SSLState *ssl_state = (SSLState *)state; if (ssl_state) ssl_state->logged |= logger; } -int SSLGetTxLogged(void *state, void *tx, uint32_t logger) +static int SSLGetTxLogged(void *state, void *tx, uint32_t logger) { SSLState *ssl_state = (SSLState *)state; if (ssl_state && (ssl_state->logged & logger)) @@ -214,12 +214,12 @@ int SSLGetTxLogged(void *state, void *tx, uint32_t logger) return 0; } -int SSLGetAlstateProgressCompletionStatus(uint8_t direction) +static int SSLGetAlstateProgressCompletionStatus(uint8_t direction) { return TLS_STATE_FINISHED; } -int SSLGetAlstateProgress(void *tx, uint8_t direction) +static int SSLGetAlstateProgress(void *tx, uint8_t direction) { SSLState *ssl_state = (SSLState *)tx; @@ -1520,14 +1520,14 @@ static int SSLDecode(Flow *f, uint8_t direction, void *alstate, AppLayerParserSt return 1; } -int SSLParseClientRecord(Flow *f, void *alstate, AppLayerParserState *pstate, +static int SSLParseClientRecord(Flow *f, void *alstate, AppLayerParserState *pstate, uint8_t *input, uint32_t input_len, void *local_data) { return SSLDecode(f, 0 /* toserver */, alstate, pstate, input, input_len); } -int SSLParseServerRecord(Flow *f, void *alstate, AppLayerParserState *pstate, +static int SSLParseServerRecord(Flow *f, void *alstate, AppLayerParserState *pstate, uint8_t *input, uint32_t input_len, void *local_data) { @@ -1538,7 +1538,7 @@ int SSLParseServerRecord(Flow *f, void *alstate, AppLayerParserState *pstate, * \internal * \brief Function to allocate the SSL state memory. */ -void *SSLStateAlloc(void) +static void *SSLStateAlloc(void) { SSLState *ssl_state = SCMalloc(sizeof(SSLState)); if (unlikely(ssl_state == NULL)) @@ -1555,7 +1555,7 @@ void *SSLStateAlloc(void) * \internal * \brief Function to free the SSL state memory. */ -void SSLStateFree(void *p) +static void SSLStateFree(void *p) { SSLState *ssl_state = (SSLState *)p; SSLCertsChain *item; @@ -1602,7 +1602,7 @@ void SSLStateFree(void *p) return; } -void SSLStateTransactionFree(void *state, uint64_t tx_id) +static void SSLStateTransactionFree(void *state, uint64_t tx_id) { /* do nothing */ } @@ -1622,7 +1622,7 @@ static uint16_t SSLProbingParser(uint8_t *input, uint32_t ilen, uint32_t *offset return ALPROTO_FAILED; } -int SSLStateGetEventInfo(const char *event_name, +static int SSLStateGetEventInfo(const char *event_name, int *event_id, AppLayerEventType *event_type) { *event_id = SCMapEnumNameToValue(event_name, tls_decoder_event_table); @@ -1788,7 +1788,7 @@ static int SSLRegisterPatternsForProtocolDetection(void) */ void RegisterSSLParsers(void) { - char *proto_name = "tls"; + const char *proto_name = "tls"; /** SSLv2 and SSLv23*/ if (AppLayerProtoDetectConfProtoDetectionEnabled("tcp", proto_name)) { diff --git a/src/app-layer-template.c b/src/app-layer-template.c index fd5bc7cc88..a0f6cb9a86 100644 --- a/src/app-layer-template.c +++ b/src/app-layer-template.c @@ -452,7 +452,7 @@ static int TemplateSetTxDetectState(void *state, void *vtx, void RegisterTemplateParsers(void) { - char *proto_name = "template"; + const char *proto_name = "template"; /* TEMPLATE_START_REMOVE */ if (ConfGetNode("app-layer.protocols.template") == NULL) { diff --git a/src/app-layer.c b/src/app-layer.c index 873182b07e..737b1861c9 100644 --- a/src/app-layer.c +++ b/src/app-layer.c @@ -84,8 +84,8 @@ AppLayerCounterNames applayer_counter_names[FLOW_PROTO_APPLAYER_MAX][ALPROTO_MAX /* counter id's. Used that runtime. */ AppLayerCounters applayer_counters[FLOW_PROTO_APPLAYER_MAX][ALPROTO_MAX]; -void AppLayerSetupCounters(); -void AppLayerDeSetupCounters(); +void AppLayerSetupCounters(void); +void AppLayerDeSetupCounters(void); /***** L7 layer dispatchers *****/ @@ -672,10 +672,10 @@ AppProto AppLayerGetProtoByName(char *alproto_name) SCReturnCT(r, "AppProto"); } -char *AppLayerGetProtoName(AppProto alproto) +const char *AppLayerGetProtoName(AppProto alproto) { SCEnter(); - char * r = AppLayerProtoDetectGetProtoName(alproto); + const char * r = AppLayerProtoDetectGetProtoName(alproto); SCReturnCT(r, "char *"); } diff --git a/src/app-layer.h b/src/app-layer.h index e7e83c6292..a82713ae98 100644 --- a/src/app-layer.h +++ b/src/app-layer.h @@ -71,7 +71,7 @@ AppProto AppLayerGetProtoByName(char *alproto_name); * * \retval String representation of the protocol. */ -char *AppLayerGetProtoName(AppProto alproto); +const char *AppLayerGetProtoName(AppProto alproto); void AppLayerListSupportedProtocols(void); diff --git a/src/conf-yaml-loader.c b/src/conf-yaml-loader.c index 6f40ab784e..c04ce1b1e2 100644 --- a/src/conf-yaml-loader.c +++ b/src/conf-yaml-loader.c @@ -26,6 +26,7 @@ #include #include "suricata-common.h" #include "conf.h" +#include "conf-yaml-loader.h" #include "util-path.h" #include "util-debug.h" #include "util-unittest.h" @@ -871,7 +872,7 @@ ConfYamlOverrideTest(void) " child1:\n" " key: value\n" ; - char *value; + const char *value; ConfCreateContextBackup(); ConfInit(); @@ -918,7 +919,7 @@ ConfYamlOverrideFinalTest(void) if (ConfYamlLoadString(config, strlen(config)) != 0) return 0; - char *default_log_dir; + const char *default_log_dir; if (!ConfGet("default-log-dir", &default_log_dir)) return 0; diff --git a/src/conf.c b/src/conf.c index 59e5aef47a..cf05a4940f 100644 --- a/src/conf.c +++ b/src/conf.c @@ -217,7 +217,7 @@ ConfNode *ConfGetRootNode(void) * * \retval 1 if the value was set otherwise 0. */ -int ConfSet(const char *name, char *val) +int ConfSet(const char *name, const char *val) { ConfNode *node = ConfGetNodeOrCreate(name, 0); if (node == NULL || node->final) { @@ -296,7 +296,7 @@ done: * * \retval 1 if the value was set otherwise 0. */ -int ConfSetFinal(const char *name, char *val) +int ConfSetFinal(const char *name, const char *val) { ConfNode *node = ConfGetNodeOrCreate(name, 1); if (node == NULL) { @@ -328,7 +328,7 @@ int ConfSetFinal(const char *name, char *val) * \retval 1 will be returned if the name is found, otherwise 0 will * be returned. */ -int ConfGet(const char *name, char **vptr) +int ConfGet(const char *name, const char **vptr) { ConfNode *node = ConfGetNode(name); if (node == NULL) { @@ -341,7 +341,7 @@ int ConfGet(const char *name, char **vptr) } } -int ConfGetChildValue(const ConfNode *base, const char *name, char **vptr) +int ConfGetChildValue(const ConfNode *base, const char *name, const char **vptr) { ConfNode *node = ConfNodeLookupChild(base, name); @@ -357,7 +357,7 @@ int ConfGetChildValue(const ConfNode *base, const char *name, char **vptr) int ConfGetChildValueWithDefault(const ConfNode *base, const ConfNode *dflt, - const char *name, char **vptr) + const char *name, const char **vptr) { int ret = ConfGetChildValue(base, name, vptr); /* Get 'default' value */ @@ -379,7 +379,7 @@ int ConfGetChildValueWithDefault(const ConfNode *base, const ConfNode *dflt, */ int ConfGetInt(const char *name, intmax_t *val) { - char *strval = NULL; + const char *strval = NULL; intmax_t tmpint; char *endptr; @@ -399,7 +399,7 @@ int ConfGetInt(const char *name, intmax_t *val) int ConfGetChildValueInt(const ConfNode *base, const char *name, intmax_t *val) { - char *strval = NULL; + const char *strval = NULL; intmax_t tmpint; char *endptr; @@ -441,7 +441,7 @@ int ConfGetChildValueIntWithDefault(const ConfNode *base, const ConfNode *dflt, */ int ConfGetBool(const char *name, int *val) { - char *strval = NULL; + const char *strval = NULL; *val = 0; if (ConfGet(name, &strval) != 1) @@ -454,7 +454,7 @@ int ConfGetBool(const char *name, int *val) int ConfGetChildValueBool(const ConfNode *base, const char *name, int *val) { - char *strval = NULL; + const char *strval = NULL; *val = 0; if (ConfGetChildValue(base, name, &strval) == 0) @@ -490,7 +490,7 @@ int ConfGetChildValueBoolWithDefault(const ConfNode *base, const ConfNode *dflt, */ int ConfValIsTrue(const char *val) { - char *trues[] = {"1", "yes", "true", "on"}; + const char *trues[] = {"1", "yes", "true", "on"}; size_t u; for (u = 0; u < sizeof(trues) / sizeof(trues[0]); u++) { @@ -515,7 +515,7 @@ int ConfValIsTrue(const char *val) */ int ConfValIsFalse(const char *val) { - char *falses[] = {"0", "no", "false", "off"}; + const char *falses[] = {"0", "no", "false", "off"}; size_t u; for (u = 0; u < sizeof(falses) / sizeof(falses[0]); u++) { @@ -539,7 +539,7 @@ int ConfValIsFalse(const char *val) */ int ConfGetDouble(const char *name, double *val) { - char *strval = NULL; + const char *strval = NULL; double tmpdo; char *endptr; @@ -569,7 +569,7 @@ int ConfGetDouble(const char *name, double *val) */ int ConfGetFloat(const char *name, float *val) { - char *strval = NULL; + const char *strval = NULL; double tmpfl; char *endptr; @@ -807,7 +807,7 @@ int ConfNodeChildValueIsTrue(const ConfNode *node, const char *key) */ char *ConfLoadCompleteIncludePath(const char *file) { - char *defaultpath = NULL; + const char *defaultpath = NULL; char *path = NULL; /* Path not specified */ @@ -891,7 +891,7 @@ int ConfNodeIsSequence(const ConfNode *node) static int ConfTestGetNonExistant(void) { char name[] = "non-existant-value"; - char *value; + const char *value; FAIL_IF(ConfGet(name, &value)); PASS; @@ -904,7 +904,7 @@ static int ConfTestSetAndGet(void) { char name[] = "some-name"; char value[] = "some-value"; - char *value0; + const char *value0; FAIL_IF(ConfSet(name, value) != 1); FAIL_IF(ConfGet(name, &value0) != 1); @@ -925,7 +925,7 @@ static int ConfTestOverrideValue1(void) char name[] = "some-name"; char value0[] = "some-value"; char value1[] = "new-value"; - char *val; + const char *val; FAIL_IF(ConfSet(name, value0) != 1); FAIL_IF(ConfSet(name, value1) != 1); @@ -946,7 +946,7 @@ static int ConfTestOverrideValue2(void) char name[] = "some-name"; char value0[] = "some-value"; char value1[] = "new-value"; - char *val; + const char *val; FAIL_IF(ConfSetFinal(name, value0) != 1); FAIL_IF(ConfSet(name, value1) != 0); @@ -991,13 +991,13 @@ static int ConfTestGetInt(void) static int ConfTestGetBool(void) { char name[] = "some-bool"; - char *trues[] = { + const char *trues[] = { "1", "on", "ON", "yes", "YeS", "true", "TRUE", }; - char *falses[] = { + const char *falses[] = { "0", "something", "off", "OFF", @@ -1024,7 +1024,7 @@ static int ConfTestGetBool(void) static int ConfNodeLookupChildTest(void) { - char *test_vals[] = { "one", "two", "three" }; + const char *test_vals[] = { "one", "two", "three" }; size_t u; ConfNode *parent = ConfNodeNew(); @@ -1066,7 +1066,7 @@ static int ConfNodeLookupChildTest(void) static int ConfNodeLookupChildValueTest(void) { - char *test_vals[] = { "one", "two", "three" }; + const char *test_vals[] = { "one", "two", "three" }; size_t u; ConfNode *parent = ConfNodeNew(); @@ -1102,7 +1102,7 @@ static int ConfNodeLookupChildValueTest(void) static int ConfGetChildValueWithDefaultTest(void) { - char *val = ""; + const char *val = ""; ConfCreateContextBackup(); ConfInit(); ConfSet("af-packet.0.interface", "eth0"); @@ -1297,7 +1297,7 @@ static int ConfNodePruneTest(void) PASS; } -int ConfNodeIsSequenceTest(void) +static int ConfNodeIsSequenceTest(void) { ConfNode *node = ConfNodeNew(); FAIL_IF(node == NULL); diff --git a/src/conf.h b/src/conf.h index 2318580a65..f831bf8da9 100644 --- a/src/conf.h +++ b/src/conf.h @@ -56,14 +56,14 @@ typedef struct ConfNode_ { void ConfInit(void); void ConfDeInit(void); ConfNode *ConfGetRootNode(void); -int ConfGet(const char *name, char **vptr); +int ConfGet(const char *name, const char **vptr); int ConfGetInt(const char *name, intmax_t *val); int ConfGetBool(const char *name, int *val); int ConfGetDouble(const char *name, double *val); int ConfGetFloat(const char *name, float *val); -int ConfSet(const char *name, char *val); +int ConfSet(const char *name, const char *val); int ConfSetFromString(const char *input, int final); -int ConfSetFinal(const char *name, char *val); +int ConfSetFinal(const char *name, const char *val); void ConfDump(void); void ConfNodeDump(const ConfNode *node, const char *prefix); ConfNode *ConfNodeNew(void); @@ -74,17 +74,18 @@ void ConfRestoreContextBackup(void); ConfNode *ConfNodeLookupChild(const ConfNode *node, const char *key); const char *ConfNodeLookupChildValue(const ConfNode *node, const char *key); void ConfNodeRemove(ConfNode *); -void ConfRegisterTests(); +void ConfRegisterTests(void); int ConfNodeChildValueIsTrue(const ConfNode *node, const char *key); int ConfValIsTrue(const char *val); int ConfValIsFalse(const char *val); void ConfNodePrune(ConfNode *node); +int ConfRemove(const char *name); ConfNode *ConfNodeLookupKeyValue(const ConfNode *base, const char *key, const char *value); -int ConfGetChildValue(const ConfNode *base, const char *name, char **vptr); +int ConfGetChildValue(const ConfNode *base, const char *name, const char **vptr); int ConfGetChildValueInt(const ConfNode *base, const char *name, intmax_t *val); int ConfGetChildValueBool(const ConfNode *base, const char *name, int *val); -int ConfGetChildValueWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name, char **vptr); +int ConfGetChildValueWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name, const char **vptr); int ConfGetChildValueIntWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name, intmax_t *val); int ConfGetChildValueBoolWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name, int *val); char *ConfLoadCompleteIncludePath(const char *); diff --git a/src/counters.c b/src/counters.c index 494f3a8f30..e1780e9fbb 100644 --- a/src/counters.c +++ b/src/counters.c @@ -267,7 +267,7 @@ static void StatsInitCtx(void) * \brief Releases the resources alloted to the output context of the * Stats API */ -static void StatsReleaseCtx() +static void StatsReleaseCtx(void) { if (stats_ctx == NULL) { SCLogDebug("Counter module has been disabled"); @@ -528,7 +528,7 @@ static void StatsReleaseCounter(StatsCounter *pc) * present counter on success * \retval 0 on failure */ -static uint16_t StatsRegisterQualifiedCounter(char *name, char *tm_name, +static uint16_t StatsRegisterQualifiedCounter(const char *name, const char *tm_name, StatsPublicThreadContext *pctx, int type_q, uint64_t (*Func)(void)) { @@ -883,7 +883,7 @@ void StatsSpawnThreads(void) * \retval id Counter id for the newly registered counter, or the already * present counter */ -uint16_t StatsRegisterCounter(char *name, struct ThreadVars_ *tv) +uint16_t StatsRegisterCounter(const char *name, struct ThreadVars_ *tv) { uint16_t id = StatsRegisterQualifiedCounter(name, (tv->thread_group_name != NULL) ? tv->thread_group_name : tv->name, @@ -904,7 +904,7 @@ uint16_t StatsRegisterCounter(char *name, struct ThreadVars_ *tv) * \retval id Counter id for the newly registered counter, or the already * present counter */ -uint16_t StatsRegisterAvgCounter(char *name, struct ThreadVars_ *tv) +uint16_t StatsRegisterAvgCounter(const char *name, struct ThreadVars_ *tv) { uint16_t id = StatsRegisterQualifiedCounter(name, (tv->thread_group_name != NULL) ? tv->thread_group_name : tv->name, @@ -925,7 +925,7 @@ uint16_t StatsRegisterAvgCounter(char *name, struct ThreadVars_ *tv) * \retval the counter id for the newly registered counter, or the already * present counter */ -uint16_t StatsRegisterMaxCounter(char *name, struct ThreadVars_ *tv) +uint16_t StatsRegisterMaxCounter(const char *name, struct ThreadVars_ *tv) { uint16_t id = StatsRegisterQualifiedCounter(name, (tv->thread_group_name != NULL) ? tv->thread_group_name : tv->name, @@ -944,7 +944,7 @@ uint16_t StatsRegisterMaxCounter(char *name, struct ThreadVars_ *tv) * \retval id Counter id for the newly registered counter, or the already * present counter */ -uint16_t StatsRegisterGlobalCounter(char *name, uint64_t (*Func)(void)) +uint16_t StatsRegisterGlobalCounter(const char *name, uint64_t (*Func)(void)) { #ifdef UNITTESTS if (stats_ctx == NULL) @@ -964,7 +964,7 @@ typedef struct CountersIdType_ { const char *string; } CountersIdType; -uint32_t CountersIdHashFunc(HashTable *ht, void *data, uint16_t datalen) +static uint32_t CountersIdHashFunc(HashTable *ht, void *data, uint16_t datalen) { CountersIdType *t = (CountersIdType *)data; uint32_t hash = 0; @@ -980,7 +980,7 @@ uint32_t CountersIdHashFunc(HashTable *ht, void *data, uint16_t datalen) return hash; } -char CountersIdHashCompareFunc(void *data1, uint16_t datalen1, +static char CountersIdHashCompareFunc(void *data1, uint16_t datalen1, void *data2, uint16_t datalen2) { CountersIdType *t1 = (CountersIdType *)data1; @@ -1004,7 +1004,7 @@ char CountersIdHashCompareFunc(void *data1, uint16_t datalen1, return 0; } -void CountersIdHashFreeFunc(void *data) +static void CountersIdHashFreeFunc(void *data) { SCFree(data); } @@ -1232,13 +1232,13 @@ void StatsReleaseCounters(StatsCounter *head) return; } -/** - * \brief Releases the StatsPrivateThreadContext allocated by the user, for storing and - * updating local counter values +/** \internal + * \brief Releases the StatsPrivateThreadContext allocated by the user, + * for storing and updating local counter values * * \param pca Pointer to the StatsPrivateThreadContext */ -void StatsReleasePrivateThreadContext(StatsPrivateThreadContext *pca) +static void StatsReleasePrivateThreadContext(StatsPrivateThreadContext *pca) { if (pca != NULL) { if (pca->head != NULL) { @@ -1274,7 +1274,7 @@ void StatsThreadCleanup(ThreadVars *tv) * \retval id Counter id for the newly registered counter, or the already * present counter */ -static uint16_t RegisterCounter(char *name, char *tm_name, +static uint16_t RegisterCounter(const char *name, const char *tm_name, StatsPublicThreadContext *pctx) { uint16_t id = StatsRegisterQualifiedCounter(name, tm_name, pctx, @@ -1282,7 +1282,7 @@ static uint16_t RegisterCounter(char *name, char *tm_name, return id; } -static int StatsTestCounterReg02() +static int StatsTestCounterReg02(void) { StatsPublicThreadContext pctx; @@ -1291,7 +1291,7 @@ static int StatsTestCounterReg02() return RegisterCounter(NULL, NULL, &pctx) == 0; } -static int StatsTestCounterReg03() +static int StatsTestCounterReg03(void) { StatsPublicThreadContext pctx; int result; @@ -1305,7 +1305,7 @@ static int StatsTestCounterReg03() return result; } -static int StatsTestCounterReg04() +static int StatsTestCounterReg04(void) { StatsPublicThreadContext pctx; int result; @@ -1323,7 +1323,7 @@ static int StatsTestCounterReg04() return result; } -static int StatsTestGetCntArray05() +static int StatsTestGetCntArray05(void) { ThreadVars tv; int id; @@ -1340,7 +1340,7 @@ static int StatsTestGetCntArray05() return (r == -1) ? 1 : 0; } -static int StatsTestGetCntArray06() +static int StatsTestGetCntArray06(void) { ThreadVars tv; int id; @@ -1362,7 +1362,7 @@ static int StatsTestGetCntArray06() return result; } -static int StatsTestCntArraySize07() +static int StatsTestCntArraySize07(void) { ThreadVars tv; StatsPrivateThreadContext *pca = NULL; @@ -1389,7 +1389,7 @@ static int StatsTestCntArraySize07() PASS_IF(result == 2); } -static int StatsTestUpdateCounter08() +static int StatsTestUpdateCounter08(void) { ThreadVars tv; StatsPrivateThreadContext *pca = NULL; @@ -1414,7 +1414,7 @@ static int StatsTestUpdateCounter08() return result == 101; } -static int StatsTestUpdateCounter09() +static int StatsTestUpdateCounter09(void) { ThreadVars tv; StatsPrivateThreadContext *pca = NULL; @@ -1443,7 +1443,7 @@ static int StatsTestUpdateCounter09() return result; } -static int StatsTestUpdateGlobalCounter10() +static int StatsTestUpdateGlobalCounter10(void) { ThreadVars tv; StatsPrivateThreadContext *pca = NULL; @@ -1477,7 +1477,7 @@ static int StatsTestUpdateGlobalCounter10() return result; } -static int StatsTestCounterValues11() +static int StatsTestCounterValues11(void) { ThreadVars tv; StatsPrivateThreadContext *pca = NULL; @@ -1518,7 +1518,7 @@ static int StatsTestCounterValues11() #endif -void StatsRegisterTests() +void StatsRegisterTests(void) { #ifdef UNITTESTS UtRegisterTest("StatsTestCounterReg02", StatsTestCounterReg02); diff --git a/src/counters.h b/src/counters.h index 39fa0bc7f0..800463cbc0 100644 --- a/src/counters.h +++ b/src/counters.h @@ -113,10 +113,10 @@ void StatsRegisterTests(void); void StatsReleaseResources(void); /* counter registration functions */ -uint16_t StatsRegisterCounter(char *, struct ThreadVars_ *); -uint16_t StatsRegisterAvgCounter(char *, struct ThreadVars_ *); -uint16_t StatsRegisterMaxCounter(char *, struct ThreadVars_ *); -uint16_t StatsRegisterGlobalCounter(char *cname, uint64_t (*Func)(void)); +uint16_t StatsRegisterCounter(const char *, struct ThreadVars_ *); +uint16_t StatsRegisterAvgCounter(const char *, struct ThreadVars_ *); +uint16_t StatsRegisterMaxCounter(const char *, struct ThreadVars_ *); +uint16_t StatsRegisterGlobalCounter(const char *cname, uint64_t (*Func)(void)); /* functions used to update local counter values */ void StatsAddUI64(struct ThreadVars_ *, uint16_t, uint64_t); diff --git a/src/decode-ethernet.h b/src/decode-ethernet.h index 33f443da84..7008ebc08d 100644 --- a/src/decode-ethernet.h +++ b/src/decode-ethernet.h @@ -54,5 +54,7 @@ typedef struct EthernetHdr_ { uint16_t eth_type; } __attribute__((__packed__)) EthernetHdr; +void DecodeEthernetRegisterTests(void); + #endif /* __DECODE_ETHERNET_H__ */ diff --git a/src/decode-events.h b/src/decode-events.h index 048ac45571..9330b2bd2e 100644 --- a/src/decode-events.h +++ b/src/decode-events.h @@ -263,7 +263,7 @@ enum { /* supported decoder events */ struct DecodeEvents_ { - char *event_name; + const char *event_name; uint8_t code; }; extern const struct DecodeEvents_ DEvents[DECODE_EVENT_MAX]; diff --git a/src/decode-icmpv4.c b/src/decode-icmpv4.c index 1cfaf78078..2aaca710c5 100644 --- a/src/decode-icmpv4.c +++ b/src/decode-icmpv4.c @@ -47,7 +47,7 @@ /** * Note, this is the IP header, plus a bit of the original packet, not the whole thing! */ -int DecodePartialIPV4( Packet* p, uint8_t* partial_packet, uint16_t len ) +static int DecodePartialIPV4(Packet* p, uint8_t* partial_packet, uint16_t len) { /** Check the sizes, the header must fit at least */ if (len < IPV4_HEADER_LEN) { diff --git a/src/decode-icmpv6.c b/src/decode-icmpv6.c index dc01d121c1..18509db385 100644 --- a/src/decode-icmpv6.c +++ b/src/decode-icmpv6.c @@ -56,7 +56,7 @@ * * \retval void No return value */ -void DecodePartialIPV6(Packet *p, uint8_t *partial_packet, uint16_t len ) +static void DecodePartialIPV6(Packet *p, uint8_t *partial_packet, uint16_t len ) { /** Check the sizes, the header must fit at least */ if (len < IPV6_HEADER_LEN) { diff --git a/src/decode-ipv4.c b/src/decode-ipv4.c index 3b5ee64942..38e7525d17 100644 --- a/src/decode-ipv4.c +++ b/src/decode-ipv4.c @@ -623,7 +623,7 @@ int DecodeIPV4(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, u #ifdef UNITTESTS /** \test IPV4 with no options. */ -int DecodeIPV4OptionsNONETest01(void) +static int DecodeIPV4OptionsNONETest01(void) { uint8_t raw_opts[] = { }; Packet *p = PacketGetFromAlloc(); @@ -639,7 +639,7 @@ int DecodeIPV4OptionsNONETest01(void) } /** \test IPV4 with EOL option. */ -int DecodeIPV4OptionsEOLTest01(void) +static int DecodeIPV4OptionsEOLTest01(void) { uint8_t raw_opts[] = { IPV4_OPT_EOL, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 @@ -655,7 +655,7 @@ int DecodeIPV4OptionsEOLTest01(void) } /** \test IPV4 with NOP option. */ -int DecodeIPV4OptionsNOPTest01(void) +static int DecodeIPV4OptionsNOPTest01(void) { uint8_t raw_opts[] = { IPV4_OPT_NOP, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 @@ -671,7 +671,7 @@ int DecodeIPV4OptionsNOPTest01(void) } /** \test IPV4 with RR option. */ -int DecodeIPV4OptionsRRTest01(void) +static int DecodeIPV4OptionsRRTest01(void) { uint8_t raw_opts[] = { IPV4_OPT_RR, 0x27, 0x08, 0xc0, 0xa8, 0x2a, 0x64, 0x00, @@ -693,7 +693,7 @@ int DecodeIPV4OptionsRRTest01(void) } /** \test IPV4 with RR option (len too large). */ -int DecodeIPV4OptionsRRTest02(void) +static int DecodeIPV4OptionsRRTest02(void) { uint8_t raw_opts[] = { IPV4_OPT_RR, 0xff, 0x08, 0xc0, 0xa8, 0x2a, 0x64, 0x00, @@ -715,7 +715,7 @@ int DecodeIPV4OptionsRRTest02(void) } /** \test IPV4 with RR option (ptr too large). */ -int DecodeIPV4OptionsRRTest03(void) +static int DecodeIPV4OptionsRRTest03(void) { uint8_t raw_opts[] = { IPV4_OPT_RR, 0x27, 0xff, 0xc0, 0xa8, 0x2a, 0x64, 0x00, @@ -737,7 +737,7 @@ int DecodeIPV4OptionsRRTest03(void) } /** \test IPV4 with RR option (ptr not in 4 byte increment). */ -int DecodeIPV4OptionsRRTest04(void) +static int DecodeIPV4OptionsRRTest04(void) { uint8_t raw_opts[] = { IPV4_OPT_RR, 0x27, 0x05, 0xc0, 0xa8, 0x2a, 0x64, 0x00, @@ -759,7 +759,7 @@ int DecodeIPV4OptionsRRTest04(void) } /** \test IPV4 with QS option. */ -int DecodeIPV4OptionsQSTest01(void) +static int DecodeIPV4OptionsQSTest01(void) { uint8_t raw_opts[] = { IPV4_OPT_QS, 0x08, 0x0d, 0x00, 0xbe, 0xef, 0x00, 0x00 @@ -777,7 +777,7 @@ int DecodeIPV4OptionsQSTest01(void) } /** \test IPV4 with QS option (len too small) */ -int DecodeIPV4OptionsQSTest02(void) +static int DecodeIPV4OptionsQSTest02(void) { uint8_t raw_opts[] = { IPV4_OPT_QS, 0x07, 0x0d, 0x00, 0xbe, 0xef, 0x00, 0x00 @@ -795,7 +795,7 @@ int DecodeIPV4OptionsQSTest02(void) } /** \test IPV4 with TS option. */ -int DecodeIPV4OptionsTSTest01(void) +static int DecodeIPV4OptionsTSTest01(void) { uint8_t raw_opts[] = { IPV4_OPT_TS, 0x24, 0x0d, 0x01, 0x0a, 0x0a, 0x0a, 0x69, @@ -817,7 +817,7 @@ int DecodeIPV4OptionsTSTest01(void) } /** \test IPV4 with TS option (ptr too small). */ -int DecodeIPV4OptionsTSTest02(void) +static int DecodeIPV4OptionsTSTest02(void) { uint8_t raw_opts[] = { IPV4_OPT_TS, 0x24, 0x04, 0x01, 0x0a, 0x0a, 0x0a, 0x69, @@ -839,7 +839,7 @@ int DecodeIPV4OptionsTSTest02(void) } /** \test IPV4 with TS option (ptr too large). */ -int DecodeIPV4OptionsTSTest03(void) +static int DecodeIPV4OptionsTSTest03(void) { uint8_t raw_opts[] = { IPV4_OPT_TS, 0x24, 0xff, 0x01, 0x0a, 0x0a, 0x0a, 0x69, @@ -861,7 +861,7 @@ int DecodeIPV4OptionsTSTest03(void) } /** \test IPV4 with TS option (ptr not valid). */ -int DecodeIPV4OptionsTSTest04(void) +static int DecodeIPV4OptionsTSTest04(void) { uint8_t raw_opts[] = { IPV4_OPT_TS, 0x24, 0x0a, 0x01, 0x0a, 0x0a, 0x0a, 0x69, @@ -883,7 +883,7 @@ int DecodeIPV4OptionsTSTest04(void) } /** \test IPV4 with SEC option. */ -int DecodeIPV4OptionsSECTest01(void) +static int DecodeIPV4OptionsSECTest01(void) { uint8_t raw_opts[] = { IPV4_OPT_SEC, 0x0b, 0xf1, 0x35, 0x00, 0x00, 0x00, 0x00, @@ -902,7 +902,7 @@ int DecodeIPV4OptionsSECTest01(void) } /** \test IPV4 with SEC option (invalid length). */ -int DecodeIPV4OptionsSECTest02(void) +static int DecodeIPV4OptionsSECTest02(void) { uint8_t raw_opts[] = { IPV4_OPT_SEC, 0x0a, 0xf1, 0x35, 0x00, 0x00, 0x00, 0x00, @@ -921,7 +921,7 @@ int DecodeIPV4OptionsSECTest02(void) } /** \test IPV4 with LSRR option. */ -int DecodeIPV4OptionsLSRRTest01(void) +static int DecodeIPV4OptionsLSRRTest01(void) { uint8_t raw_opts[] = { IPV4_OPT_LSRR, 0x27, 0x08, 0xc0, 0xa8, 0x2a, 0x64, 0x00, @@ -943,7 +943,7 @@ int DecodeIPV4OptionsLSRRTest01(void) } /** \test IPV4 with LSRR option (len too large). */ -int DecodeIPV4OptionsLSRRTest02(void) +static int DecodeIPV4OptionsLSRRTest02(void) { uint8_t raw_opts[] = { IPV4_OPT_LSRR, 0xff, 0x08, 0xc0, 0xa8, 0x2a, 0x64, 0x00, @@ -965,7 +965,7 @@ int DecodeIPV4OptionsLSRRTest02(void) } /** \test IPV4 with LSRR option (ptr too large). */ -int DecodeIPV4OptionsLSRRTest03(void) +static int DecodeIPV4OptionsLSRRTest03(void) { uint8_t raw_opts[] = { IPV4_OPT_LSRR, 0x27, 0xff, 0xc0, 0xa8, 0x2a, 0x64, 0x00, @@ -987,7 +987,7 @@ int DecodeIPV4OptionsLSRRTest03(void) } /** \test IPV4 with LSRR option (ptr not in 4 byte increment). */ -int DecodeIPV4OptionsLSRRTest04(void) +static int DecodeIPV4OptionsLSRRTest04(void) { uint8_t raw_opts[] = { IPV4_OPT_LSRR, 0x27, 0x05, 0xc0, 0xa8, 0x2a, 0x64, 0x00, @@ -1009,7 +1009,7 @@ int DecodeIPV4OptionsLSRRTest04(void) } /** \test IPV4 with CIPSO option. */ -int DecodeIPV4OptionsCIPSOTest01(void) +static int DecodeIPV4OptionsCIPSOTest01(void) { uint8_t raw_opts[] = { IPV4_OPT_CIPSO, 0x18, 0x00, 0x00, 0x00, 0x05, 0x05, 0x12, @@ -1029,7 +1029,7 @@ int DecodeIPV4OptionsCIPSOTest01(void) } /** \test IPV4 with SID option. */ -int DecodeIPV4OptionsSIDTest01(void) +static int DecodeIPV4OptionsSIDTest01(void) { uint8_t raw_opts[] = { IPV4_OPT_SID, 0x04, 0xbe, 0xef, 0x00, 0x00, 0x00, 0x00 @@ -1047,7 +1047,7 @@ int DecodeIPV4OptionsSIDTest01(void) } /** \test IPV4 with SID option (len invalid. */ -int DecodeIPV4OptionsSIDTest02(void) +static int DecodeIPV4OptionsSIDTest02(void) { uint8_t raw_opts[] = { IPV4_OPT_SID, 0x05, 0xbe, 0xef, 0x00, 0x00, 0x00, 0x00 @@ -1065,7 +1065,7 @@ int DecodeIPV4OptionsSIDTest02(void) } /** \test IPV4 with SSRR option. */ -int DecodeIPV4OptionsSSRRTest01(void) +static int DecodeIPV4OptionsSSRRTest01(void) { uint8_t raw_opts[] = { IPV4_OPT_SSRR, 0x27, 0x08, 0xc0, 0xa8, 0x2a, 0x64, 0x00, @@ -1087,7 +1087,7 @@ int DecodeIPV4OptionsSSRRTest01(void) } /** \test IPV4 with SSRR option (len too large). */ -int DecodeIPV4OptionsSSRRTest02(void) +static int DecodeIPV4OptionsSSRRTest02(void) { uint8_t raw_opts[] = { IPV4_OPT_SSRR, 0xff, 0x08, 0xc0, 0xa8, 0x2a, 0x64, 0x00, @@ -1109,7 +1109,7 @@ int DecodeIPV4OptionsSSRRTest02(void) } /** \test IPV4 with SSRR option (ptr too large). */ -int DecodeIPV4OptionsSSRRTest03(void) +static int DecodeIPV4OptionsSSRRTest03(void) { uint8_t raw_opts[] = { IPV4_OPT_SSRR, 0x27, 0xff, 0xc0, 0xa8, 0x2a, 0x64, 0x00, @@ -1131,7 +1131,7 @@ int DecodeIPV4OptionsSSRRTest03(void) } /** \test IPV4 with SSRR option (ptr not in 4 byte increment). */ -int DecodeIPV4OptionsSSRRTest04(void) +static int DecodeIPV4OptionsSSRRTest04(void) { uint8_t raw_opts[] = { IPV4_OPT_SSRR, 0x27, 0x05, 0xc0, 0xa8, 0x2a, 0x64, 0x00, @@ -1153,7 +1153,7 @@ int DecodeIPV4OptionsSSRRTest04(void) } /** \test IPV4 with RTRALT option. */ -int DecodeIPV4OptionsRTRALTTest01(void) +static int DecodeIPV4OptionsRTRALTTest01(void) { uint8_t raw_opts[] = { IPV4_OPT_RTRALT, 0x04, 0xbe, 0xef, 0x00, 0x00, 0x00, 0x00 @@ -1171,7 +1171,7 @@ int DecodeIPV4OptionsRTRALTTest01(void) } /** \test IPV4 with RTRALT option (len invalid. */ -int DecodeIPV4OptionsRTRALTTest02(void) +static int DecodeIPV4OptionsRTRALTTest02(void) { uint8_t raw_opts[] = { IPV4_OPT_RTRALT, 0x05, 0xbe, 0xef, 0x00, 0x00, 0x00, 0x00 @@ -1221,7 +1221,7 @@ static int IPV4CalculateInvalidChecksumtest02(void) /** * \test IPV4 defrag and packet recursion level test */ -int DecodeIPV4DefragTest01(void) +static int DecodeIPV4DefragTest01(void) { uint8_t pkt1[] = { 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad, @@ -1345,7 +1345,7 @@ end: * \test Don't send IPv4 fragments to the upper layer decoder and * and packet recursion level test. */ -int DecodeIPV4DefragTest02(void) +static int DecodeIPV4DefragTest02(void) { uint8_t pkt1[] = { 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad, @@ -1476,7 +1476,7 @@ end: /** * \test IPV4 defrag and flow retrieval test. */ -int DecodeIPV4DefragTest03(void) +static int DecodeIPV4DefragTest03(void) { uint8_t pkt[] = { 0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad, diff --git a/src/decode-teredo.c b/src/decode-teredo.c index 208760277d..531946c89b 100644 --- a/src/decode-teredo.c +++ b/src/decode-teredo.c @@ -35,6 +35,7 @@ #include "suricata-common.h" #include "decode.h" #include "decode-ipv6.h" +#include "decode-teredo.h" #include "util-debug.h" #define TEREDO_ORIG_INDICATION_LENGTH 8 diff --git a/src/decode.c b/src/decode.c index 4b064c8300..2f12d3a130 100644 --- a/src/decode.c +++ b/src/decode.c @@ -549,7 +549,7 @@ inline int PacketSetData(Packet *p, uint8_t *pktdata, int pktlen) const char *PktSrcToString(enum PktSrcEnum pkt_src) { - char *pkt_src_str = ""; + const char *pkt_src_str = ""; switch (pkt_src) { case PKT_SRC_WIRE: pkt_src_str = "wire/pcap"; diff --git a/src/decode.h b/src/decode.h index 16ab1a43e8..c3fe72e0e5 100644 --- a/src/decode.h +++ b/src/decode.h @@ -948,6 +948,13 @@ int DecodeGRE(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint16_t, P int DecodeVLAN(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint16_t, PacketQueue *); int DecodeMPLS(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint16_t, PacketQueue *); int DecodeERSPAN(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint16_t, PacketQueue *); +int DecodeTEMPLATE(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t, PacketQueue *); + +#ifdef UNITTESTS +void DecodeIPV6FragHeader(Packet *p, uint8_t *pkt, + uint16_t hdrextlen, uint16_t plen, + uint16_t prev_hdrextlen); +#endif void AddressDebugPrint(Address *); diff --git a/src/defrag-hash.c b/src/defrag-hash.c index 9087f26ace..bb9d666574 100644 --- a/src/defrag-hash.c +++ b/src/defrag-hash.c @@ -41,7 +41,7 @@ void DefragTrackerMoveToSpare(DefragTracker *h) (void) SC_ATOMIC_SUB(defragtracker_counter, 1); } -DefragTracker *DefragTrackerAlloc(void) +static DefragTracker *DefragTrackerAlloc(void) { if (!(DEFRAG_CHECK_MEMCAP(sizeof(DefragTracker)))) { return NULL; @@ -63,7 +63,7 @@ error: return NULL; } -void DefragTrackerFree(DefragTracker *dt) +static void DefragTrackerFree(DefragTracker *dt) { if (dt != NULL) { DefragTrackerClearMemory(dt); @@ -140,7 +140,7 @@ void DefragInitConfig(char quiet) defrag_config.prealloc = DEFRAG_DEFAULT_PREALLOC; /* Check if we have memcap and hash_size defined at config */ - char *conf_val; + const char *conf_val; uint32_t configval = 0; /** set config values for memcap, prealloc and hash_size */ diff --git a/src/defrag-queue.h b/src/defrag-queue.h index 87b5f4d18b..63a58d0786 100644 --- a/src/defrag-queue.h +++ b/src/defrag-queue.h @@ -72,7 +72,7 @@ typedef struct DefragTrackerQueue_ #endif /* prototypes */ -DefragTrackerQueue *DefragTrackerQueueNew(); +DefragTrackerQueue *DefragTrackerQueueNew(void); DefragTrackerQueue *DefragTrackerQueueInit(DefragTrackerQueue *); void DefragTrackerQueueDestroy (DefragTrackerQueue *); diff --git a/src/defrag-timeout.c b/src/defrag-timeout.c index 663ee3b595..f9428e0fe9 100644 --- a/src/defrag-timeout.c +++ b/src/defrag-timeout.c @@ -24,16 +24,7 @@ #include "suricata-common.h" #include "defrag.h" #include "defrag-hash.h" - -uint32_t DefragTrackerGetSpareCount(void) -{ - return DefragTrackerSpareQueueGetSize(); -} - -uint32_t DefragTrackerGetActiveCount(void) -{ - return SC_ATOMIC_GET(defragtracker_counter); -} +#include "defrag-timeout.h" /** \internal * \brief See if we can really discard this tracker. Check use_cnt reference. diff --git a/src/defrag.c b/src/defrag.c index 11cda60e99..838440f5d4 100644 --- a/src/defrag.c +++ b/src/defrag.c @@ -1119,10 +1119,6 @@ error: return NULL; } -void DecodeIPV6FragHeader(Packet *p, uint8_t *pkt, - uint16_t hdrextlen, uint16_t plen, - uint16_t prev_hdrextlen); - static Packet *IPV6BuildTestPacket(uint8_t proto, uint32_t id, uint16_t off, int mf, const char content, int content_len) { diff --git a/src/detect-ack.c b/src/detect-ack.c index 0d36096a4d..6de42c698e 100644 --- a/src/detect-ack.c +++ b/src/detect-ack.c @@ -43,7 +43,7 @@ #include "util-debug.h" /* prototypes */ -static int DetectAckSetup(DetectEngineCtx *, Signature *, char *); +static int DetectAckSetup(DetectEngineCtx *, Signature *, const char *); static int DetectAckMatch(ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); static void DetectAckRegisterTests(void); @@ -103,7 +103,7 @@ static int DetectAckMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx, * \retval 0 on Success * \retval -1 on Failure */ -static int DetectAckSetup(DetectEngineCtx *de_ctx, Signature *s, char *optstr) +static int DetectAckSetup(DetectEngineCtx *de_ctx, Signature *s, const char *optstr) { DetectAckData *data = NULL; SigMatch *sm = NULL; diff --git a/src/detect-app-layer-event.c b/src/detect-app-layer-event.c index b69ace9d8e..02e58560a1 100644 --- a/src/detect-app-layer-event.c +++ b/src/detect-app-layer-event.c @@ -50,7 +50,7 @@ static int DetectAppLayerEventPktMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p, const Signature *s, const SigMatchCtx *ctx); -static int DetectAppLayerEventSetupP1(DetectEngineCtx *, Signature *, char *); +static int DetectAppLayerEventSetupP1(DetectEngineCtx *, Signature *, const char *); static void DetectAppLayerEventRegisterTests(void); static void DetectAppLayerEventFree(void *); static int DetectEngineAptEventInspect(ThreadVars *tv, @@ -319,7 +319,7 @@ static int DetectAppLayerEventSetupP2(Signature *s, return 0; } -static int DetectAppLayerEventSetupP1(DetectEngineCtx *de_ctx, Signature *s, char *arg) +static int DetectAppLayerEventSetupP1(DetectEngineCtx *de_ctx, Signature *s, const char *arg) { DetectAppLayerEventData *data = NULL; SigMatch *sm = NULL; @@ -425,7 +425,7 @@ static int DetectAppLayerEventTestGetEventInfo(const char *event_name, } -int DetectAppLayerEventTest01(void) +static int DetectAppLayerEventTest01(void) { AppLayerParserBackupParserTable(); AppLayerParserRegisterGetEventInfo(IPPROTO_TCP, ALPROTO_SMTP, @@ -460,7 +460,7 @@ int DetectAppLayerEventTest01(void) return result; } -int DetectAppLayerEventTest02(void) +static int DetectAppLayerEventTest02(void) { AppLayerParserBackupParserTable(); @@ -558,7 +558,7 @@ int DetectAppLayerEventTest02(void) return result; } -int DetectAppLayerEventTest03(void) +static int DetectAppLayerEventTest03(void) { ThreadVars tv; TcpReassemblyThreadCtx *ra_ctx = NULL; @@ -645,7 +645,7 @@ int DetectAppLayerEventTest03(void) PASS; } -int DetectAppLayerEventTest04(void) +static int DetectAppLayerEventTest04(void) { ThreadVars tv; TcpReassemblyThreadCtx *ra_ctx = NULL; @@ -728,7 +728,7 @@ int DetectAppLayerEventTest04(void) PASS; } -int DetectAppLayerEventTest05(void) +static int DetectAppLayerEventTest05(void) { ThreadVars tv; TcpReassemblyThreadCtx *ra_ctx = NULL; diff --git a/src/detect-app-layer-protocol.c b/src/detect-app-layer-protocol.c index 5761d2b87d..e40af9eab4 100644 --- a/src/detect-app-layer-protocol.c +++ b/src/detect-app-layer-protocol.c @@ -86,29 +86,10 @@ static int DetectAppLayerProtocolPacketMatch(ThreadVars *tv, SCReturnInt(r); } -static DetectAppLayerProtocolData *DetectAppLayerProtocolParse(const char *arg) +static DetectAppLayerProtocolData *DetectAppLayerProtocolParse(const char *arg, bool negate) { DetectAppLayerProtocolData *data; AppProto alproto = ALPROTO_UNKNOWN; - uint8_t negated = 0; - - if (arg == NULL) { - SCLogError(SC_ERR_INVALID_SIGNATURE, "app-layer-protocol keyword " - "supplied with no arguments. This keyword needs " - "an argument."); - return NULL; - } - - while (*arg != '\0' && isspace((unsigned char)*arg)) - arg++; - - if (arg[0] == '!') { - negated = 1; - arg++; - } - - while (*arg != '\0' && isspace((unsigned char)*arg)) - arg++; if (strcmp(arg, "failed") == 0) { alproto = ALPROTO_FAILED; @@ -125,7 +106,7 @@ static DetectAppLayerProtocolData *DetectAppLayerProtocolParse(const char *arg) if (unlikely(data == NULL)) return NULL; data->alproto = alproto; - data->negated = negated; + data->negated = negate; return data; } @@ -148,7 +129,7 @@ static _Bool HasConflicts(const DetectAppLayerProtocolData *us, } static int DetectAppLayerProtocolSetup(DetectEngineCtx *de_ctx, - Signature *s, char *arg) + Signature *s, const char *arg) { DetectAppLayerProtocolData *data = NULL; SigMatch *sm = NULL; @@ -161,7 +142,7 @@ static int DetectAppLayerProtocolSetup(DetectEngineCtx *de_ctx, goto error; } - data = DetectAppLayerProtocolParse(arg); + data = DetectAppLayerProtocolParse(arg, s->init_data->negated); if (data == NULL) goto error; @@ -285,6 +266,8 @@ void DetectAppLayerProtocolRegister(void) DetectAppLayerProtocolFree; sigmatch_table[DETECT_AL_APP_LAYER_PROTOCOL].RegisterTests = DetectAppLayerProtocolRegisterTests; + sigmatch_table[DETECT_AL_APP_LAYER_PROTOCOL].flags = + (SIGMATCH_QUOTES_OPTIONAL|SIGMATCH_HANDLE_NEGATION); sigmatch_table[DETECT_AL_APP_LAYER_PROTOCOL].SetupPrefilter = PrefilterSetupAppProto; @@ -299,7 +282,7 @@ void DetectAppLayerProtocolRegister(void) static int DetectAppLayerProtocolTest01(void) { - DetectAppLayerProtocolData *data = DetectAppLayerProtocolParse("http"); + DetectAppLayerProtocolData *data = DetectAppLayerProtocolParse("http", false); FAIL_IF_NULL(data); FAIL_IF(data->alproto != ALPROTO_HTTP); FAIL_IF(data->negated != 0); @@ -309,7 +292,7 @@ static int DetectAppLayerProtocolTest01(void) static int DetectAppLayerProtocolTest02(void) { - DetectAppLayerProtocolData *data = DetectAppLayerProtocolParse("!http"); + DetectAppLayerProtocolData *data = DetectAppLayerProtocolParse("http", true); FAIL_IF_NULL(data); FAIL_IF(data->alproto != ALPROTO_HTTP); FAIL_IF(data->negated == 0); @@ -470,7 +453,7 @@ static int DetectAppLayerProtocolTest10(void) static int DetectAppLayerProtocolTest11(void) { - DetectAppLayerProtocolData *data = DetectAppLayerProtocolParse("failed"); + DetectAppLayerProtocolData *data = DetectAppLayerProtocolParse("failed", false); FAIL_IF_NULL(data); FAIL_IF(data->alproto != ALPROTO_FAILED); FAIL_IF(data->negated != 0); @@ -480,7 +463,7 @@ static int DetectAppLayerProtocolTest11(void) static int DetectAppLayerProtocolTest12(void) { - DetectAppLayerProtocolData *data = DetectAppLayerProtocolParse("!failed"); + DetectAppLayerProtocolData *data = DetectAppLayerProtocolParse("failed", true); FAIL_IF_NULL(data); FAIL_IF(data->alproto != ALPROTO_FAILED); FAIL_IF(data->negated == 0); diff --git a/src/detect-asn1.c b/src/detect-asn1.c index 7bdc57957a..2f659c7b6b 100644 --- a/src/detect-asn1.c +++ b/src/detect-asn1.c @@ -44,7 +44,7 @@ const char *ASN_DELIM = " \t,\n"; static int DetectAsn1Match(ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectAsn1Setup (DetectEngineCtx *, Signature *, char *); +static int DetectAsn1Setup (DetectEngineCtx *, Signature *, const char *); static void DetectAsn1RegisterTests(void); static void DetectAsn1Free(void *); @@ -197,7 +197,7 @@ static int DetectAsn1Match(ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet * \retval fd pointer to DetectAsn1Data on success * \retval NULL on failure */ -static DetectAsn1Data *DetectAsn1Parse(char *asn1str) +static DetectAsn1Data *DetectAsn1Parse(const char *instr) { DetectAsn1Data *fd = NULL; char *tok = NULL; @@ -207,10 +207,15 @@ static DetectAsn1Data *DetectAsn1Parse(char *asn1str) uint8_t flags = 0; char *saveptr = NULL; + char *asn1str = SCStrdup(instr); + if (asn1str == NULL) + return NULL; + tok = strtok_r(asn1str, ASN_DELIM, &saveptr); if (tok == NULL) { SCLogError(SC_ERR_INVALID_VALUE, "Malformed asn1 argument: %s", asn1str); + SCFree(asn1str); return NULL; } @@ -289,7 +294,7 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -static int DetectAsn1Setup(DetectEngineCtx *de_ctx, Signature *s, char *asn1str) +static int DetectAsn1Setup(DetectEngineCtx *de_ctx, Signature *s, const char *asn1str) { DetectAsn1Data *ad = NULL; SigMatch *sm = NULL; @@ -1078,7 +1083,7 @@ static int DetectAsn1TestReal01(void) if (p[0] == NULL || p[1] == NULL) goto end; - char *sigs[3]; + const char *sigs[3]; sigs[0]= "alert ip any any -> any any (msg:\"Testing id 1\"; " "content:\"Pablo\"; asn1:absolute_offset 0, " "oversize_length 130; sid:1;)"; @@ -1157,7 +1162,7 @@ static int DetectAsn1TestReal02(void) if (p[0] == NULL || p[1] == NULL) goto end; - char *sigs[3]; + const char *sigs[3]; sigs[0]= "alert ip any any -> any any (msg:\"Testing id 1\"; " "content:\"Pablo\"; asn1:absolute_offset 0, " "oversize_length 140; sid:1;)"; @@ -1216,7 +1221,7 @@ static int DetectAsn1TestReal03(void) if (p[0] == NULL || p[1] == NULL) goto end; - char *sigs[3]; + const char *sigs[3]; /* This should match the first packet */ sigs[0]= "alert ip any any -> any any (msg:\"Testing id 1\"; " "asn1:absolute_offset 0, double_overflow; sid:1;)"; @@ -1295,7 +1300,7 @@ static int DetectAsn1TestReal04(void) if (p[0] == NULL || p[1] == NULL) goto end; - char *sigs[3]; + const char *sigs[3]; sigs[0]= "alert ip any any -> any any (msg:\"Testing id 1\"; " "content:\"Pablo\"; asn1:absolute_offset 0, " "oversize_length 140; sid:1;)"; diff --git a/src/detect-base64-data.c b/src/detect-base64-data.c index 97fd2e09b7..e9d72b11c4 100644 --- a/src/detect-base64-data.c +++ b/src/detect-base64-data.c @@ -20,10 +20,11 @@ #include "detect-engine.h" #include "detect-engine-content-inspection.h" #include "detect-parse.h" +#include "detect-base64-data.h" #include "util-unittest.h" -static int DetectBase64DataSetup(DetectEngineCtx *, Signature *, char *); +static int DetectBase64DataSetup(DetectEngineCtx *, Signature *, const char *); static void DetectBase64DataRegisterTests(void); void DetectBase64DataRegister(void) @@ -41,7 +42,7 @@ void DetectBase64DataRegister(void) } static int DetectBase64DataSetup(DetectEngineCtx *de_ctx, Signature *s, - char *str) + const char *str) { SigMatch *pm = NULL; @@ -58,7 +59,7 @@ static int DetectBase64DataSetup(DetectEngineCtx *de_ctx, Signature *s, } int DetectBase64DataDoMatch(DetectEngineCtx *de_ctx, - DetectEngineThreadCtx *det_ctx, Signature *s, Flow *f) + DetectEngineThreadCtx *det_ctx, const Signature *s, Flow *f) { if (det_ctx->base64_decoded_len) { return DetectEngineContentInspection(de_ctx, det_ctx, s, diff --git a/src/detect-base64-decode.c b/src/detect-base64-decode.c index 354b85dd99..3fad962c1f 100644 --- a/src/detect-base64-decode.c +++ b/src/detect-base64-decode.c @@ -32,7 +32,7 @@ static const char decode_pattern[] = "\\s*(bytes\\s+(\\d+),?)?" static pcre *decode_pcre = NULL; static pcre_extra *decode_pcre_study = NULL; -static int DetectBase64DecodeSetup(DetectEngineCtx *, Signature *, char *); +static int DetectBase64DecodeSetup(DetectEngineCtx *, Signature *, const char *); static void DetectBase64DecodeFree(void *); static void DetectBase64DecodeRegisterTests(void); @@ -168,7 +168,7 @@ error: } static int DetectBase64DecodeSetup(DetectEngineCtx *de_ctx, Signature *s, - char *str) + const char *str) { uint32_t bytes = 0; uint32_t offset = 0; diff --git a/src/detect-bypass.c b/src/detect-bypass.c index 6d77fbefa4..f415d65299 100644 --- a/src/detect-bypass.c +++ b/src/detect-bypass.c @@ -36,6 +36,7 @@ #include "detect-engine-mpm.h" #include "detect-engine-state.h" #include "detect-engine-sigorder.h" +#include "detect-bypass.h" #include "flow.h" #include "flow-var.h" @@ -51,7 +52,7 @@ static int DetectBypassMatch(ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectBypassSetup(DetectEngineCtx *, Signature *, char *); +static int DetectBypassSetup(DetectEngineCtx *, Signature *, const char *); static void DetectBypassRegisterTests(void); /** @@ -69,7 +70,7 @@ void DetectBypassRegister(void) sigmatch_table[DETECT_BYPASS].flags = SIGMATCH_NOOPT; } -static int DetectBypassSetup(DetectEngineCtx *de_ctx, Signature *s, char *str) +static int DetectBypassSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str) { SigMatch *sm = NULL; @@ -102,13 +103,13 @@ static int DetectBypassMatch(ThreadVars *tv, DetectEngineThreadCtx *det_ctx, Pac #ifdef UNITTESTS static int callback_var = 0; -static int BypassCallback() +static int BypassCallback(Packet *p) { callback_var = 1; return 1; } -static void ResetCallbackVar() +static void ResetCallbackVar(void) { callback_var = 0; } @@ -177,7 +178,7 @@ static int DetectBypassTestSig01(void) de_ctx->flags |= DE_QUIET; - char *sigs[3]; + const char *sigs[3]; sigs[0] = "alert tcp any any -> any any (bypass; content:\"GET \"; sid:1;)"; sigs[1] = "alert http any any -> any any " "(bypass; content:\"message\"; http_server_body; " diff --git a/src/detect-byte-extract.c b/src/detect-byte-extract.c index 6a19310500..262b382868 100644 --- a/src/detect-byte-extract.c +++ b/src/detect-byte-extract.c @@ -89,7 +89,7 @@ static pcre *parse_regex; static pcre_extra *parse_regex_study; -static int DetectByteExtractSetup(DetectEngineCtx *, Signature *, char *); +static int DetectByteExtractSetup(DetectEngineCtx *, Signature *, const char *); static void DetectByteExtractRegisterTests(void); static void DetectByteExtractFree(void *); @@ -206,7 +206,7 @@ int DetectByteExtractDoMatch(DetectEngineThreadCtx *det_ctx, const SigMatchData * \param bed On success an instance containing the parsed data. * On failure, NULL. */ -static inline DetectByteExtractData *DetectByteExtractParse(char *arg) +static inline DetectByteExtractData *DetectByteExtractParse(const char *arg) { DetectByteExtractData *bed = NULL; #define MAX_SUBSTRINGS 100 @@ -504,7 +504,7 @@ static inline DetectByteExtractData *DetectByteExtractParse(char *arg) * \retval 0 On success. * \retval -1 On failure. */ -static int DetectByteExtractSetup(DetectEngineCtx *de_ctx, Signature *s, char *arg) +static int DetectByteExtractSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg) { SigMatch *sm = NULL; SigMatch *prev_pm = NULL; diff --git a/src/detect-bytejump.c b/src/detect-bytejump.c index 272b23ebdd..6cb70aff9b 100644 --- a/src/detect-bytejump.c +++ b/src/detect-bytejump.c @@ -62,8 +62,8 @@ static pcre_extra *parse_regex_study; static int DetectBytejumpMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p, const Signature *s, const SigMatchCtx *ctx); -static DetectBytejumpData *DetectBytejumpParse(char *optstr, char **offset); -static int DetectBytejumpSetup(DetectEngineCtx *de_ctx, Signature *s, char *optstr); +static DetectBytejumpData *DetectBytejumpParse(const char *optstr, char **offset); +static int DetectBytejumpSetup(DetectEngineCtx *de_ctx, Signature *s, const char *optstr); static void DetectBytejumpFree(void *ptr); static void DetectBytejumpRegisterTests(void); @@ -309,7 +309,7 @@ static int DetectBytejumpMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx, return 1; } -static DetectBytejumpData *DetectBytejumpParse(char *optstr, char **offset) +static DetectBytejumpData *DetectBytejumpParse(const char *optstr, char **offset) { DetectBytejumpData *data = NULL; char args[10][64]; @@ -503,7 +503,7 @@ error: return NULL; } -static int DetectBytejumpSetup(DetectEngineCtx *de_ctx, Signature *s, char *optstr) +static int DetectBytejumpSetup(DetectEngineCtx *de_ctx, Signature *s, const char *optstr) { SigMatch *sm = NULL; SigMatch *prev_pm = NULL; diff --git a/src/detect-bytetest.c b/src/detect-bytetest.c index 4ad7f53e83..4dcb3127fe 100644 --- a/src/detect-bytetest.c +++ b/src/detect-bytetest.c @@ -64,7 +64,7 @@ static pcre_extra *parse_regex_study; static int DetectBytetestMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p, const Signature *s, const SigMatchCtx *ctx); -static int DetectBytetestSetup(DetectEngineCtx *de_ctx, Signature *s, char *optstr); +static int DetectBytetestSetup(DetectEngineCtx *de_ctx, Signature *s, const char *optstr); static void DetectBytetestFree(void *ptr); static void DetectBytetestRegisterTests(void); @@ -241,7 +241,7 @@ static int DetectBytetestMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx, ((DetectBytetestData *)ctx)->flags, 0, 0); } -static DetectBytetestData *DetectBytetestParse(char *optstr, char **value, char **offset) +static DetectBytetestData *DetectBytetestParse(const char *optstr, char **value, char **offset) { DetectBytetestData *data = NULL; char *args[9] = { @@ -429,7 +429,7 @@ error: return NULL; } -static int DetectBytetestSetup(DetectEngineCtx *de_ctx, Signature *s, char *optstr) +static int DetectBytetestSetup(DetectEngineCtx *de_ctx, Signature *s, const char *optstr) { SigMatch *sm = NULL; SigMatch *prev_pm = NULL; diff --git a/src/detect-cipservice.c b/src/detect-cipservice.c index b142d8d558..14491f4972 100644 --- a/src/detect-cipservice.c +++ b/src/detect-cipservice.c @@ -39,7 +39,7 @@ /** * \brief CIP Service Detect Prototypes */ -static int DetectCipServiceSetup(DetectEngineCtx *, Signature *, char *); +static int DetectCipServiceSetup(DetectEngineCtx *, Signature *, const char *); static void DetectCipServiceFree(void *); static void DetectCipServiceRegisterTests(void); static int g_cip_buffer_id = 0; @@ -200,7 +200,7 @@ error: * \retval -1 on Failure */ static int DetectCipServiceSetup(DetectEngineCtx *de_ctx, Signature *s, - char *rulestr) + const char *rulestr) { SCEnter(); @@ -293,7 +293,7 @@ static void DetectCipServiceRegisterTests(void) /** * \brief ENIP Commond Detect Prototypes */ -static int DetectEnipCommandSetup(DetectEngineCtx *, Signature *, char *); +static int DetectEnipCommandSetup(DetectEngineCtx *, Signature *, const char *); static void DetectEnipCommandFree(void *); static void DetectEnipCommandRegisterTests(void); static int g_enip_buffer_id = 0; @@ -372,7 +372,7 @@ error: * \retval -1 on Failure */ static int DetectEnipCommandSetup(DetectEngineCtx *de_ctx, Signature *s, - char *rulestr) + const char *rulestr) { DetectEnipCommandData *enipcmdd = NULL; SigMatch *sm = NULL; diff --git a/src/detect-classtype.c b/src/detect-classtype.c index edf5555163..036a9c8c41 100644 --- a/src/detect-classtype.c +++ b/src/detect-classtype.c @@ -42,7 +42,7 @@ static pcre *regex = NULL; static pcre_extra *regex_study = NULL; -static int DetectClasstypeSetup(DetectEngineCtx *, Signature *, char *); +static int DetectClasstypeSetup(DetectEngineCtx *, Signature *, const char *); static void DetectClasstypeRegisterTests(void); /** @@ -68,20 +68,13 @@ void DetectClasstypeRegister(void) * * \retval bool success or failure. */ -static int DetectClasstypeParseRawString(char *rawstr, char *out, size_t outsize) +static int DetectClasstypeParseRawString(const char *rawstr, char *out, size_t outsize) { #define MAX_SUBSTRINGS 30 int ret = 0; int ov[MAX_SUBSTRINGS]; size_t len = strlen(rawstr); - /* get rid of the double quotes if present */ - if (rawstr[0] == '\"' && rawstr[strlen(rawstr) - 1] == '\"') { - rawstr++; - rawstr[strlen(rawstr) - 1] = '\0'; - len -= 2; - } - ret = pcre_exec(regex, regex_study, rawstr, len, 0, 0, ov, 30); if (ret < 0) { SCLogError(SC_ERR_PCRE_MATCH, "Invalid Classtype in Signature"); @@ -110,7 +103,7 @@ static int DetectClasstypeParseRawString(char *rawstr, char *out, size_t outsize * \retval 0 On success * \retval -1 On failure */ -static int DetectClasstypeSetup(DetectEngineCtx *de_ctx, Signature *s, char *rawstr) +static int DetectClasstypeSetup(DetectEngineCtx *de_ctx, Signature *s, const char *rawstr) { char parsed_ct_name[1024] = ""; SCClassConfClasstype *ct = NULL; @@ -153,7 +146,7 @@ static int DetectClasstypeSetup(DetectEngineCtx *de_ctx, Signature *s, char *raw * \test Check that supplying an invalid classtype in the rule, results in the * rule being invalidated. */ -static int DetectClasstypeTest01() +static int DetectClasstypeTest01(void) { int result = 0; @@ -182,7 +175,7 @@ end: * properly, with rules containing invalid classtypes being rejected * and the ones containing valid classtypes parsed and returned. */ -static int DetectClasstypeTest02() +static int DetectClasstypeTest02(void) { int result = 0; Signature *last = NULL; @@ -248,7 +241,7 @@ end: * \test Check that the signatures are assigned priority based on classtype they * are given. */ -static int DetectClasstypeTest03() +static int DetectClasstypeTest03(void) { int result = 0; Signature *last = NULL; diff --git a/src/detect-content.c b/src/detect-content.c index 687360a622..fb33934685 100644 --- a/src/detect-content.c +++ b/src/detect-content.c @@ -303,33 +303,6 @@ void DetectContentPrint(DetectContentData *cd) SCLogDebug("-----------"); } -/** - * \brief Print list of DETECT_CONTENT SigMatch's allocated in a - * SigMatch list, from the current sm to the end - * \param sm pointer to the current SigMatch to start printing from - */ -void DetectContentPrintAll(SigMatch *sm) -{ -#ifdef DEBUG - if (SCLogDebugEnabled()) { - int i = 0; - - if (sm == NULL) - return; - - SigMatch *first_sm = sm; - - /* Print all of them */ - for (; first_sm != NULL; first_sm = first_sm->next) { - if (first_sm->type == DETECT_CONTENT) { - SCLogDebug("Printing SigMatch DETECT_CONTENT %d", ++i); - DetectContentPrint((DetectContentData*)first_sm->ctx); - } - } - } -#endif /* DEBUG */ -} - /** * \brief Function to setup a content pattern. * @@ -340,7 +313,7 @@ void DetectContentPrintAll(SigMatch *sm) * \retval -1 if error * \retval 0 if all was ok */ -int DetectContentSetup(DetectEngineCtx *de_ctx, Signature *s, char *contentstr) +int DetectContentSetup(DetectEngineCtx *de_ctx, Signature *s, const char *contentstr) { DetectContentData *cd = NULL; SigMatch *sm = NULL; @@ -393,6 +366,33 @@ void DetectContentFree(void *ptr) } #ifdef UNITTESTS /* UNITTESTS */ +/** + * \brief Print list of DETECT_CONTENT SigMatch's allocated in a + * SigMatch list, from the current sm to the end + * \param sm pointer to the current SigMatch to start printing from + */ +static void DetectContentPrintAll(SigMatch *sm) +{ +#ifdef DEBUG + if (SCLogDebugEnabled()) { + int i = 0; + + if (sm == NULL) + return; + + SigMatch *first_sm = sm; + + /* Print all of them */ + for (; first_sm != NULL; first_sm = first_sm->next) { + if (first_sm->type == DETECT_CONTENT) { + SCLogDebug("Printing SigMatch DETECT_CONTENT %d", ++i); + DetectContentPrint((DetectContentData*)first_sm->ctx); + } + } + } +#endif /* DEBUG */ +} + static int g_file_data_buffer_id = 0; static int g_dce_stub_data_buffer_id = 0; @@ -633,7 +633,7 @@ static int DetectContentParseTest08 (void) * \retval return 1 if match * \retval return 0 if not */ -static int DetectContentLongPatternMatchTest(uint8_t *raw_eth_pkt, uint16_t pktsize, char *sig, +static int DetectContentLongPatternMatchTest(uint8_t *raw_eth_pkt, uint16_t pktsize, const char *sig, uint32_t sid) { int result = 0; @@ -705,7 +705,7 @@ end: /** * \brief Wrapper for DetectContentLongPatternMatchTest */ -static int DetectContentLongPatternMatchTestWrp(char *sig, uint32_t sid) +static int DetectContentLongPatternMatchTestWrp(const char *sig, uint32_t sid) { /** Real packet with the following tcp data: * "Hi, this is a big test to check content matches of splitted" @@ -740,9 +740,9 @@ static int DetectContentLongPatternMatchTestWrp(char *sig, uint32_t sid) /** * \test Check if we match a normal pattern (not splitted) */ -static int DetectContentLongPatternMatchTest01() +static int DetectContentLongPatternMatchTest01(void) { - char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";" + const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";" " content:\"Hi, this is a big test\"; sid:1;)"; return DetectContentLongPatternMatchTestWrp(sig, 1); } @@ -750,9 +750,9 @@ static int DetectContentLongPatternMatchTest01() /** * \test Check if we match a splitted pattern */ -static int DetectContentLongPatternMatchTest02() +static int DetectContentLongPatternMatchTest02(void) { - char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";" + const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";" " content:\"Hi, this is a big test to check content matches of" " splitted patterns between multiple chunks!\"; sid:1;)"; return DetectContentLongPatternMatchTestWrp(sig, 1); @@ -762,10 +762,10 @@ static int DetectContentLongPatternMatchTest02() * \test Check that we don't match the signature if one of the splitted * chunks doesn't match the packet */ -static int DetectContentLongPatternMatchTest03() +static int DetectContentLongPatternMatchTest03(void) { /** The last chunk of the content should not match */ - char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";" + const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";" " content:\"Hi, this is a big test to check content matches of" " splitted patterns between multiple splitted chunks!\"; sid:1;)"; return (DetectContentLongPatternMatchTestWrp(sig, 1) == 0) ? 1: 0; @@ -774,9 +774,9 @@ static int DetectContentLongPatternMatchTest03() /** * \test Check if we match multiple content (not splitted) */ -static int DetectContentLongPatternMatchTest04() +static int DetectContentLongPatternMatchTest04(void) { - char *sig = "alert tcp any any -> any any (msg:\"Nothing..\"; " + const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\"; " " content:\"Hi, this is\"; depth:15 ;content:\"a big test\"; " " within:15; content:\"to check content matches of\"; " " within:30; content:\"splitted patterns\"; distance:1; " @@ -790,9 +790,9 @@ static int DetectContentLongPatternMatchTest04() * Here we should specify only contents that fit in 32 bytes * Each of them with their modifier values */ -static int DetectContentLongPatternMatchTest05() +static int DetectContentLongPatternMatchTest05(void) { - char *sig = "alert tcp any any -> any any (msg:\"Nothing..\"; " + const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\"; " " content:\"Hi, this is a big\"; depth:17; " " isdataat:30, relative; " " content:\"test\"; within: 5; distance:1; " @@ -810,9 +810,9 @@ static int DetectContentLongPatternMatchTest05() * Here we should specify contents that fit and contents that must be splitted * Each of them with their modifier values */ -static int DetectContentLongPatternMatchTest06() +static int DetectContentLongPatternMatchTest06(void) { - char *sig = "alert tcp any any -> any any (msg:\"Nothing..\"; " + const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\"; " " content:\"Hi, this is a big test to check cont\"; depth:36;" " content:\"ent matches\"; within:11; distance:0; " " content:\"of splitted patterns between multiple\"; " @@ -826,9 +826,9 @@ static int DetectContentLongPatternMatchTest06() * \test Check if we match contents that are in the payload * but not in the same order as specified in the signature */ -static int DetectContentLongPatternMatchTest07() +static int DetectContentLongPatternMatchTest07(void) { - char *sig = "alert tcp any any -> any any (msg:\"Nothing..\"; " + const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\"; " " content:\"chunks!\"; " " content:\"content matches\"; offset:32; depth:47; " " content:\"of splitted patterns between multiple\"; " @@ -841,9 +841,9 @@ static int DetectContentLongPatternMatchTest07() * \test Check if we match contents that are in the payload * but not in the same order as specified in the signature */ -static int DetectContentLongPatternMatchTest08() +static int DetectContentLongPatternMatchTest08(void) { - char *sig = "alert tcp any any -> any any (msg:\"Nothing..\"; " + const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\"; " " content:\"ent matches\"; " " content:\"of splitted patterns between multiple\"; " " within:38; distance:1; " @@ -857,9 +857,9 @@ static int DetectContentLongPatternMatchTest08() * \test Check if we match contents that are in the payload * but not in the same order as specified in the signature */ -static int DetectContentLongPatternMatchTest09() +static int DetectContentLongPatternMatchTest09(void) { - char *sig = "alert tcp any any -> any any (msg:\"Nothing..\"; " + const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\"; " " content:\"ent matches\"; " " content:\"of splitted patterns between multiple\"; " " offset:47; depth:85; " @@ -873,9 +873,9 @@ static int DetectContentLongPatternMatchTest09() /** * \test Check if we match two consecutive simple contents */ -static int DetectContentLongPatternMatchTest10() +static int DetectContentLongPatternMatchTest10(void) { - char *sig = "alert tcp any any -> any any (msg:\"Nothing..\"; " + const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\"; " " content:\"Hi, this is a big test to check \"; " " content:\"con\"; " " sid:1;)"; @@ -885,9 +885,9 @@ static int DetectContentLongPatternMatchTest10() /** * \test Check if we match two contents of length 1 */ -static int DetectContentLongPatternMatchTest11() +static int DetectContentLongPatternMatchTest11(void) { - char *sig = "alert tcp any any -> any any (msg:\"Nothing..\"; " + const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\"; " " content:\"H\"; " " content:\"i\"; " " sid:1;)"; @@ -917,7 +917,7 @@ static int DetectContentParseTest09(void) static int DetectContentParseTest17(void) { int result = 0; - char *sigstr = "alert tcp any any -> any any (msg:\"Dummy\"; " + const char *sigstr = "alert tcp any any -> any any (msg:\"Dummy\"; " "content:\"one\"; content:\"two\"; within:2; sid:1;)"; DetectEngineCtx *de_ctx = DetectEngineCtxInit(); @@ -1857,7 +1857,7 @@ end: return result; } -static int SigTestPositiveTestContent(char *rule, uint8_t *buf) +static int SigTestPositiveTestContent(const char *rule, uint8_t *buf) { uint16_t buflen = strlen((char *)buf); Packet *p = NULL; @@ -2136,7 +2136,7 @@ static int DetectContentParseTest45(void) PASS; } -static int SigTestNegativeTestContent(char *rule, uint8_t *buf) +static int SigTestNegativeTestContent(const char *rule, uint8_t *buf) { uint16_t buflen = strlen((char *)buf); Packet *p = NULL; @@ -2525,7 +2525,7 @@ end: return result; } -static int DetectLongContentTestCommon(char *sig, uint32_t sid) +static int DetectLongContentTestCommon(const char *sig, uint32_t sid) { /* Packet with 512 A's in it for testing long content. */ static uint8_t pkt[739] = { @@ -2631,7 +2631,7 @@ static int DetectLongContentTestCommon(char *sig, uint32_t sid) static int DetectLongContentTest1(void) { /* Signature with 256 A's. */ - char *sig = "alert tcp any any -> any any (msg:\"Test Rule\"; content:\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"; sid:1;)"; + const char *sig = "alert tcp any any -> any any (msg:\"Test Rule\"; content:\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"; sid:1;)"; return DetectLongContentTestCommon(sig, 1); } @@ -2639,7 +2639,7 @@ static int DetectLongContentTest1(void) static int DetectLongContentTest2(void) { /* Signature with 512 A's. */ - char *sig = "alert tcp any any -> any any (msg:\"Test Rule\"; content:\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"; sid:1;)"; + const char *sig = "alert tcp any any -> any any (msg:\"Test Rule\"; content:\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"; sid:1;)"; return DetectLongContentTestCommon(sig, 1); } @@ -2647,7 +2647,7 @@ static int DetectLongContentTest2(void) static int DetectLongContentTest3(void) { /* Signature with 513 A's. */ - char *sig = "alert tcp any any -> any any (msg:\"Test Rule\"; content:\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"; sid:1;)"; + const char *sig = "alert tcp any any -> any any (msg:\"Test Rule\"; content:\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"; sid:1;)"; return !DetectLongContentTestCommon(sig, 1); } diff --git a/src/detect-content.h b/src/detect-content.h index fd21706774..d5f64ff0b4 100644 --- a/src/detect-content.h +++ b/src/detect-content.h @@ -112,7 +112,7 @@ int DetectContentDataParse(const char *keyword, const char *contentstr, DetectContentData *DetectContentParseEncloseQuotes(SpmGlobalThreadCtx *spm_global_thread_ctx, const char *contentstr); -int DetectContentSetup(DetectEngineCtx *de_ctx, Signature *s, char *contentstr); +int DetectContentSetup(DetectEngineCtx *de_ctx, Signature *s, const char *contentstr); void DetectContentPrint(DetectContentData *); void DetectContentFree(void *); diff --git a/src/detect-csum.c b/src/detect-csum.c index 7f9c307a79..cf2027b2a6 100644 --- a/src/detect-csum.c +++ b/src/detect-csum.c @@ -42,43 +42,43 @@ /* prototypes for the "ipv4-csum" rule keyword */ static int DetectIPV4CsumMatch(ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectIPV4CsumSetup(DetectEngineCtx *, Signature *, char *); +static int DetectIPV4CsumSetup(DetectEngineCtx *, Signature *, const char *); static void DetectIPV4CsumFree(void *); /* prototypes for the "tcpv4-csum" rule keyword */ static int DetectTCPV4CsumMatch(ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectTCPV4CsumSetup(DetectEngineCtx *, Signature *, char *); +static int DetectTCPV4CsumSetup(DetectEngineCtx *, Signature *, const char *); static void DetectTCPV4CsumFree(void *); /* prototypes for the "tcpv6-csum" rule keyword */ static int DetectTCPV6CsumMatch(ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectTCPV6CsumSetup(DetectEngineCtx *, Signature *, char *); +static int DetectTCPV6CsumSetup(DetectEngineCtx *, Signature *, const char *); static void DetectTCPV6CsumFree(void *); /* prototypes for the "udpv4-csum" rule keyword */ static int DetectUDPV4CsumMatch(ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectUDPV4CsumSetup(DetectEngineCtx *, Signature *, char *); +static int DetectUDPV4CsumSetup(DetectEngineCtx *, Signature *, const char *); static void DetectUDPV4CsumFree(void *); /* prototypes for the "udpv6-csum" rule keyword */ static int DetectUDPV6CsumMatch(ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectUDPV6CsumSetup(DetectEngineCtx *, Signature *, char *); +static int DetectUDPV6CsumSetup(DetectEngineCtx *, Signature *, const char *); static void DetectUDPV6CsumFree(void *); /* prototypes for the "icmpv4-csum" rule keyword */ static int DetectICMPV4CsumMatch(ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectICMPV4CsumSetup(DetectEngineCtx *, Signature *, char *); +static int DetectICMPV4CsumSetup(DetectEngineCtx *, Signature *, const char *); static void DetectICMPV4CsumFree(void *); /* prototypes for the "icmpv6-csum" rule keyword */ static int DetectICMPV6CsumMatch(ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectICMPV6CsumSetup(DetectEngineCtx *, Signature *, char *); +static int DetectICMPV6CsumSetup(DetectEngineCtx *, Signature *, const char *); static void DetectICMPV6CsumFree(void *); static void DetectCsumRegisterTests(void); @@ -266,7 +266,7 @@ static int DetectIPV4CsumMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx, * * \retval 0 on success, -1 on failure */ -static int DetectIPV4CsumSetup(DetectEngineCtx *de_ctx, Signature *s, char *csum_str) +static int DetectIPV4CsumSetup(DetectEngineCtx *de_ctx, Signature *s, const char *csum_str) { DetectCsumData *cd = NULL; SigMatch *sm = NULL; @@ -363,7 +363,7 @@ static int DetectTCPV4CsumMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx, * * \retval 0 on success, -1 on failure */ -static int DetectTCPV4CsumSetup(DetectEngineCtx *de_ctx, Signature *s, char *csum_str) +static int DetectTCPV4CsumSetup(DetectEngineCtx *de_ctx, Signature *s, const char *csum_str) { DetectCsumData *cd = NULL; SigMatch *sm = NULL; @@ -460,7 +460,7 @@ static int DetectTCPV6CsumMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx, * * \retval 0 on success, -1 on failure */ -static int DetectTCPV6CsumSetup(DetectEngineCtx *de_ctx, Signature *s, char *csum_str) +static int DetectTCPV6CsumSetup(DetectEngineCtx *de_ctx, Signature *s, const char *csum_str) { DetectCsumData *cd = NULL; SigMatch *sm = NULL; @@ -557,7 +557,7 @@ static int DetectUDPV4CsumMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx, * * \retval 0 on success, -1 on failure */ -static int DetectUDPV4CsumSetup(DetectEngineCtx *de_ctx, Signature *s, char *csum_str) +static int DetectUDPV4CsumSetup(DetectEngineCtx *de_ctx, Signature *s, const char *csum_str) { DetectCsumData *cd = NULL; SigMatch *sm = NULL; @@ -654,7 +654,7 @@ static int DetectUDPV6CsumMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx, * * \retval 0 on success, -1 on failure */ -static int DetectUDPV6CsumSetup(DetectEngineCtx *de_ctx, Signature *s, char *csum_str) +static int DetectUDPV6CsumSetup(DetectEngineCtx *de_ctx, Signature *s, const char *csum_str) { DetectCsumData *cd = NULL; SigMatch *sm = NULL; @@ -749,7 +749,7 @@ static int DetectICMPV4CsumMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx, * * \retval 0 on success, -1 on failure */ -static int DetectICMPV4CsumSetup(DetectEngineCtx *de_ctx, Signature *s, char *csum_str) +static int DetectICMPV4CsumSetup(DetectEngineCtx *de_ctx, Signature *s, const char *csum_str) { DetectCsumData *cd = NULL; SigMatch *sm = NULL; @@ -849,7 +849,7 @@ static int DetectICMPV6CsumMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx, * * \retval 0 on success, -1 on failure */ -static int DetectICMPV6CsumSetup(DetectEngineCtx *de_ctx, Signature *s, char *csum_str) +static int DetectICMPV6CsumSetup(DetectEngineCtx *de_ctx, Signature *s, const char *csum_str) { DetectCsumData *cd = NULL; SigMatch *sm = NULL; @@ -944,7 +944,7 @@ static int DetectCsumValidArgsTestParse01(void) DetectEngineCtxFree(de_ctx);\ } -int DetectCsumInvalidArgsTestParse02(void) +static int DetectCsumInvalidArgsTestParse02(void) { TEST2(ipv4); TEST2(tcpv4); @@ -975,7 +975,7 @@ int DetectCsumInvalidArgsTestParse02(void) DetectEngineCtxFree(de_ctx);\ } -int DetectCsumValidArgsTestParse03(void) +static int DetectCsumValidArgsTestParse03(void) { TEST3(ipv4, DETECT_IPV4_CSUM); TEST3(tcpv4, DETECT_TCPV4_CSUM); diff --git a/src/detect-dce-iface.c b/src/detect-dce-iface.c index dd37326e1f..472399e0f6 100644 --- a/src/detect-dce-iface.c +++ b/src/detect-dce-iface.c @@ -55,7 +55,7 @@ static pcre_extra *parse_regex_study = NULL; static int DetectDceIfaceMatch(ThreadVars *, DetectEngineThreadCtx *, Flow *, uint8_t, void *, void *, const Signature *, const SigMatchCtx *); -static int DetectDceIfaceSetup(DetectEngineCtx *, Signature *, char *); +static int DetectDceIfaceSetup(DetectEngineCtx *, Signature *, const char *); static void DetectDceIfaceFree(void *); static void DetectDceIfaceRegisterTests(void); static int g_dce_generic_list_id = 0; @@ -365,7 +365,7 @@ end: * \retval 0 on success, -1 on failure. */ -static int DetectDceIfaceSetup(DetectEngineCtx *de_ctx, Signature *s, char *arg) +static int DetectDceIfaceSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg) { DetectDceIfaceData *did = NULL; SigMatch *sm = NULL; diff --git a/src/detect-dce-opnum.c b/src/detect-dce-opnum.c index 9098a47150..f76d522f0a 100644 --- a/src/detect-dce-opnum.c +++ b/src/detect-dce-opnum.c @@ -56,7 +56,7 @@ static pcre_extra *parse_regex_study = NULL; static int DetectDceOpnumMatch(ThreadVars *, DetectEngineThreadCtx *, Flow *, uint8_t, void *, void *, const Signature *, const SigMatchCtx *); -static int DetectDceOpnumSetup(DetectEngineCtx *, Signature *, char *); +static int DetectDceOpnumSetup(DetectEngineCtx *, Signature *, const char *); static void DetectDceOpnumFree(void *); static void DetectDceOpnumRegisterTests(void); static int g_dce_generic_list_id = 0; @@ -285,7 +285,7 @@ static int DetectDceOpnumMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx, * \retval 0 on success, -1 on failure */ -static int DetectDceOpnumSetup(DetectEngineCtx *de_ctx, Signature *s, char *arg) +static int DetectDceOpnumSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg) { DetectDceOpnumData *dod = NULL; SigMatch *sm = NULL; diff --git a/src/detect-dce-stub-data.c b/src/detect-dce-stub-data.c index ea3d37624b..50c8c9925c 100644 --- a/src/detect-dce-stub-data.c +++ b/src/detect-dce-stub-data.c @@ -57,7 +57,7 @@ #define BUFFER_NAME "dce_stub_data" #define KEYWORD_NAME "dce_stub_data" -static int DetectDceStubDataSetup(DetectEngineCtx *, Signature *, char *); +static int DetectDceStubDataSetup(DetectEngineCtx *, Signature *, const char *); static void DetectDceStubDataRegisterTests(void); static int g_dce_stub_data_buffer_id = 0; @@ -235,7 +235,7 @@ void DetectDceStubDataRegister(void) * \retval 0 on success, -1 on failure */ -static int DetectDceStubDataSetup(DetectEngineCtx *de_ctx, Signature *s, char *arg) +static int DetectDceStubDataSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg) { if (DetectSignatureSetAppProto(s, ALPROTO_DCERPC) != 0) return -1; diff --git a/src/detect-depth.c b/src/detect-depth.c index 18453178f9..b65821bb41 100644 --- a/src/detect-depth.c +++ b/src/detect-depth.c @@ -33,6 +33,7 @@ #include "detect-content.h" #include "detect-uricontent.h" #include "detect-byte-extract.h" +#include "detect-depth.h" #include "flow-var.h" #include "app-layer.h" @@ -40,7 +41,7 @@ #include "util-byte.h" #include "util-debug.h" -static int DetectDepthSetup (DetectEngineCtx *, Signature *, char *); +static int DetectDepthSetup (DetectEngineCtx *, Signature *, const char *); void DetectDepthRegister (void) { @@ -53,24 +54,12 @@ void DetectDepthRegister (void) sigmatch_table[DETECT_DEPTH].RegisterTests = NULL; } -static int DetectDepthSetup (DetectEngineCtx *de_ctx, Signature *s, char *depthstr) +static int DetectDepthSetup (DetectEngineCtx *de_ctx, Signature *s, const char *depthstr) { - char *str = depthstr; - char dubbed = 0; + const char *str = depthstr; SigMatch *pm = NULL; int ret = -1; - /* Strip leading and trailing "s. */ - if (depthstr[0] == '\"') { - str = SCStrdup(depthstr + 1); - if (unlikely(str == NULL)) - goto end; - if (strlen(str) && str[strlen(str) - 1] == '\"') { - str[strlen(str) - 1] = '\0'; - } - dubbed = 1; - } - /* retrive the sm to apply the depth against */ pm = DetectGetLastSMFromLists(s, DETECT_CONTENT, -1); if (pm == NULL) { @@ -131,7 +120,5 @@ static int DetectDepthSetup (DetectEngineCtx *de_ctx, Signature *s, char *depths ret = 0; end: - if (dubbed) - SCFree(str); return ret; } diff --git a/src/detect-detection-filter.c b/src/detect-detection-filter.c index f209f6991e..f091db86b4 100644 --- a/src/detect-detection-filter.c +++ b/src/detect-detection-filter.c @@ -53,7 +53,7 @@ static pcre_extra *parse_regex_study; static int DetectDetectionFilterMatch(ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectDetectionFilterSetup(DetectEngineCtx *, Signature *, char *); +static int DetectDetectionFilterSetup(DetectEngineCtx *, Signature *, const char *); static void DetectDetectionFilterRegisterTests(void); static void DetectDetectionFilterFree(void *); @@ -90,7 +90,7 @@ static int DetectDetectionFilterMatch (ThreadVars *thv, DetectEngineThreadCtx *d * \retval df pointer to DetectThresholdData on success * \retval NULL on failure */ -static DetectThresholdData *DetectDetectionFilterParse (char *rawstr) +static DetectThresholdData *DetectDetectionFilterParse (const char *rawstr) { DetectThresholdData *df = NULL; #define MAX_SUBSTRINGS 30 @@ -207,7 +207,7 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -static int DetectDetectionFilterSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr) +static int DetectDetectionFilterSetup (DetectEngineCtx *de_ctx, Signature *s, const char *rawstr) { SCEnter(); DetectThresholdData *df = NULL; diff --git a/src/detect-distance.c b/src/detect-distance.c index 869a145026..b40ded90ee 100644 --- a/src/detect-distance.c +++ b/src/detect-distance.c @@ -37,6 +37,7 @@ #include "detect-uricontent.h" #include "detect-pcre.h" #include "detect-byte-extract.h" +#include "detect-distance.h" #include "flow-var.h" @@ -45,7 +46,7 @@ #include "detect-bytejump.h" #include "util-unittest-helper.h" -static int DetectDistanceSetup(DetectEngineCtx *, Signature *, char *); +static int DetectDistanceSetup(DetectEngineCtx *, Signature *, const char *); static void DetectDistanceRegisterTests(void); void DetectDistanceRegister(void) @@ -60,24 +61,12 @@ void DetectDistanceRegister(void) } static int DetectDistanceSetup (DetectEngineCtx *de_ctx, Signature *s, - char *distancestr) + const char *distancestr) { - char *str = distancestr; - char dubbed = 0; + const char *str = distancestr; SigMatch *pm = NULL; int ret = -1; - /* Strip leading and trailing "s. */ - if (distancestr[0] == '\"') { - str = SCStrdup(distancestr + 1); - if (unlikely(str == NULL)) - goto end; - if (strlen(str) && str[strlen(str) - 1] == '\"') { - str[strlen(str) - 1] = '\0'; - } - dubbed = 1; - } - /* retrieve the sm to apply the distance against */ pm = DetectGetLastSMFromLists(s, DETECT_CONTENT, -1); if (pm == NULL) { @@ -154,8 +143,6 @@ static int DetectDistanceSetup (DetectEngineCtx *de_ctx, Signature *s, ret = 0; end: - if (dubbed) - SCFree(str); return ret; } diff --git a/src/detect-dnp3.c b/src/detect-dnp3.c index e152ad92e0..a979391d54 100644 --- a/src/detect-dnp3.c +++ b/src/detect-dnp3.c @@ -184,7 +184,7 @@ static int DetectEngineInspectDNP3(ThreadVars *tv, DetectEngineCtx *de_ctx, * \retval The function code as an integer if successul, -1 on * failure. */ -static int DetectDNP3FuncParseFunctionCode(char *str, uint8_t *fc) +static int DetectDNP3FuncParseFunctionCode(const char *str, uint8_t *fc) { if (ByteExtractStringUint8(fc, 10, strlen(str), str) >= 0) { return 1; @@ -202,7 +202,7 @@ static int DetectDNP3FuncParseFunctionCode(char *str, uint8_t *fc) return 0; } -static int DetectDNP3FuncSetup(DetectEngineCtx *de_ctx, Signature *s, char *str) +static int DetectDNP3FuncSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str) { SCEnter(); DetectDNP3 *dnp3 = NULL; @@ -243,7 +243,7 @@ error: SCReturnInt(-1); } -static int DetectDNP3IndParseByName(char *str, uint16_t *flags) +static int DetectDNP3IndParseByName(const char *str, uint16_t *flags) { char tmp[strlen(str) + 1]; char *p, *last = NULL; @@ -273,7 +273,7 @@ static int DetectDNP3IndParseByName(char *str, uint16_t *flags) return 1; } -static int DetectDNP3IndParse(char *str, uint16_t *flags) +static int DetectDNP3IndParse(const char *str, uint16_t *flags) { *flags = 0; @@ -289,7 +289,7 @@ static int DetectDNP3IndParse(char *str, uint16_t *flags) return 0; } -static int DetectDNP3IndSetup(DetectEngineCtx *de_ctx, Signature *s, char *str) +static int DetectDNP3IndSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str) { SCEnter(); DetectDNP3 *detect = NULL; @@ -363,7 +363,7 @@ static int DetectDNP3ObjParse(const char *str, uint8_t *group, uint8_t *var) return 1; } -static int DetectDNP3ObjSetup(DetectEngineCtx *de_ctx, Signature *s, char *str) +static int DetectDNP3ObjSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str) { SCEnter(); uint8_t group; @@ -523,7 +523,7 @@ static void DetectDNP3ObjRegister(void) SCReturn; } -static int DetectDNP3DataSetup(DetectEngineCtx *de_ctx, Signature *s, char *str) +static int DetectDNP3DataSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str) { SCEnter(); s->init_data->list = g_dnp3_data_buffer_id; diff --git a/src/detect-dnp3.h b/src/detect-dnp3.h index b8230db7c9..7479d7841a 100644 --- a/src/detect-dnp3.h +++ b/src/detect-dnp3.h @@ -22,7 +22,7 @@ * Struct for mapping symbolic names to values. */ typedef struct DNP3Mapping_ { - char *name; + const char *name; uint16_t value; } DNP3Mapping; diff --git a/src/detect-dns-query.c b/src/detect-dns-query.c index e50fc03d3b..edd899fe4d 100644 --- a/src/detect-dns-query.c +++ b/src/detect-dns-query.c @@ -58,7 +58,7 @@ #include "util-unittest-helper.h" -static int DetectDnsQuerySetup (DetectEngineCtx *, Signature *, char *); +static int DetectDnsQuerySetup (DetectEngineCtx *, Signature *, const char *); static void DetectDnsQueryRegisterTests(void); static int g_dns_query_buffer_id = 0; @@ -114,7 +114,7 @@ void DetectDnsQueryRegister (void) * \retval -1 On failure */ -static int DetectDnsQuerySetup(DetectEngineCtx *de_ctx, Signature *s, char *str) +static int DetectDnsQuerySetup(DetectEngineCtx *de_ctx, Signature *s, const char *str) { s->init_data->list = g_dns_query_buffer_id; s->alproto = ALPROTO_DNS; diff --git a/src/detect-dsize.c b/src/detect-dsize.c index 5f7b7575b5..b645a37363 100644 --- a/src/detect-dsize.c +++ b/src/detect-dsize.c @@ -51,7 +51,7 @@ static pcre_extra *parse_regex_study; static int DetectDsizeMatch (ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectDsizeSetup (DetectEngineCtx *, Signature *s, char *str); +static int DetectDsizeSetup (DetectEngineCtx *, Signature *s, const char *str); static void DsizeRegisterTests(void); static void DetectDsizeFree(void *); @@ -134,7 +134,7 @@ static int DetectDsizeMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Pack * \retval dd pointer to DetectDsizeData on success * \retval NULL on failure */ -DetectDsizeData *DetectDsizeParse (char *rawstr) +static DetectDsizeData *DetectDsizeParse (const char *rawstr) { DetectDsizeData *dd = NULL; #define MAX_SUBSTRINGS 30 @@ -251,7 +251,7 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -static int DetectDsizeSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr) +static int DetectDsizeSetup (DetectEngineCtx *de_ctx, Signature *s, const char *rawstr) { DetectDsizeData *dd = NULL; SigMatch *sm = NULL; @@ -386,7 +386,7 @@ static _Bool PrefilterDsizeIsPrefilterable(const Signature *s) * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse01 (void) +static int DsizeTestParse01 (void) { DetectDsizeData *dd = NULL; dd = DetectDsizeParse("1"); @@ -404,7 +404,7 @@ int DsizeTestParse01 (void) * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse02 (void) +static int DsizeTestParse02 (void) { DetectDsizeData *dd = NULL; dd = DetectDsizeParse(">10"); @@ -422,7 +422,7 @@ int DsizeTestParse02 (void) * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse03 (void) +static int DsizeTestParse03 (void) { DetectDsizeData *dd = NULL; dd = DetectDsizeParse("<100"); @@ -440,7 +440,7 @@ int DsizeTestParse03 (void) * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse04 (void) +static int DsizeTestParse04 (void) { DetectDsizeData *dd = NULL; dd = DetectDsizeParse("1<>2"); @@ -458,7 +458,7 @@ int DsizeTestParse04 (void) * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse05 (void) +static int DsizeTestParse05 (void) { int result = 0; DetectDsizeData *dd = NULL; @@ -479,7 +479,7 @@ int DsizeTestParse05 (void) * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse06 (void) +static int DsizeTestParse06 (void) { int result = 0; DetectDsizeData *dd = NULL; @@ -500,7 +500,7 @@ int DsizeTestParse06 (void) * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse07 (void) +static int DsizeTestParse07 (void) { int result = 0; DetectDsizeData *dd = NULL; @@ -521,7 +521,7 @@ int DsizeTestParse07 (void) * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse08 (void) +static int DsizeTestParse08 (void) { int result = 0; DetectDsizeData *dd = NULL; @@ -542,7 +542,7 @@ int DsizeTestParse08 (void) * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse09 (void) +static int DsizeTestParse09 (void) { DetectDsizeData *dd = NULL; dd = DetectDsizeParse("A"); @@ -560,7 +560,7 @@ int DsizeTestParse09 (void) * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse10 (void) +static int DsizeTestParse10 (void) { DetectDsizeData *dd = NULL; dd = DetectDsizeParse(">10<>10"); @@ -578,7 +578,7 @@ int DsizeTestParse10 (void) * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse11 (void) +static int DsizeTestParse11 (void) { DetectDsizeData *dd = NULL; dd = DetectDsizeParse("<>10"); @@ -596,7 +596,7 @@ int DsizeTestParse11 (void) * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse12 (void) +static int DsizeTestParse12 (void) { DetectDsizeData *dd = NULL; dd = DetectDsizeParse("1<>"); @@ -614,7 +614,7 @@ int DsizeTestParse12 (void) * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse13 (void) +static int DsizeTestParse13 (void) { int result = 0; DetectDsizeData *dd = NULL; @@ -635,7 +635,7 @@ int DsizeTestParse13 (void) * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse14 (void) +static int DsizeTestParse14 (void) { DetectDsizeData *dd = NULL; dd = DetectDsizeParse(""); @@ -653,7 +653,7 @@ int DsizeTestParse14 (void) * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse15 (void) +static int DsizeTestParse15 (void) { DetectDsizeData *dd = NULL; dd = DetectDsizeParse(" "); @@ -671,7 +671,7 @@ int DsizeTestParse15 (void) * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse16 (void) +static int DsizeTestParse16 (void) { DetectDsizeData *dd = NULL; dd = DetectDsizeParse("2<>1"); @@ -689,7 +689,7 @@ int DsizeTestParse16 (void) * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse17 (void) +static int DsizeTestParse17 (void) { int result = 0; DetectDsizeData *dd = NULL; @@ -710,7 +710,7 @@ int DsizeTestParse17 (void) * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse18 (void) +static int DsizeTestParse18 (void) { int result = 0; DetectDsizeData *dd = NULL; @@ -731,7 +731,7 @@ int DsizeTestParse18 (void) * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse19 (void) +static int DsizeTestParse19 (void) { int result = 0; DetectDsizeData *dd = NULL; @@ -752,7 +752,7 @@ int DsizeTestParse19 (void) * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse20 (void) +static int DsizeTestParse20 (void) { int result = 0; DetectDsizeData *dd = NULL; @@ -772,7 +772,7 @@ int DsizeTestParse20 (void) * dsize keyword by creating 2 rules and matching a crafted packet * against them. Only the first one shall trigger. */ -int DetectDsizeIcmpv6Test01 (void) +static int DetectDsizeIcmpv6Test01 (void) { int result = 0; diff --git a/src/detect-engine-address-ipv4.c b/src/detect-engine-address-ipv4.c index 7de2af6a89..93f745bbf6 100644 --- a/src/detect-engine-address-ipv4.c +++ b/src/detect-engine-address-ipv4.c @@ -33,6 +33,7 @@ #include "util-unittest.h" #include "detect-engine-address.h" +#include "detect-engine-address-ipv4.h" #include "detect-engine-siggroup.h" #include "detect-engine-port.h" diff --git a/src/detect-engine-address-ipv6.c b/src/detect-engine-address-ipv6.c index 2195ae10df..3ee3cfec40 100644 --- a/src/detect-engine-address-ipv6.c +++ b/src/detect-engine-address-ipv6.c @@ -33,6 +33,7 @@ #include "util-unittest.h" #include "detect-engine-address.h" +#include "detect-engine-address-ipv6.h" #include "detect-engine-siggroup.h" #include "detect-engine-port.h" @@ -811,7 +812,7 @@ int DetectAddressJoinIPv6(DetectEngineCtx *de_ctx, DetectAddress *target, #ifdef UNITTESTS -int AddressTestIPv6Gt01(void) +static int AddressTestIPv6Gt01(void) { int result = 0; @@ -824,7 +825,7 @@ int AddressTestIPv6Gt01(void) return result; } -int AddressTestIPv6Gt02(void) +static int AddressTestIPv6Gt02(void) { int result = 0; @@ -837,7 +838,7 @@ int AddressTestIPv6Gt02(void) return result; } -int AddressTestIPv6Gt03(void) +static int AddressTestIPv6Gt03(void) { int result = 0; @@ -850,7 +851,7 @@ int AddressTestIPv6Gt03(void) return result; } -int AddressTestIPv6Gt04(void) +static int AddressTestIPv6Gt04(void) { int result = 0; @@ -863,7 +864,7 @@ int AddressTestIPv6Gt04(void) return result; } -int AddressTestIPv6Lt01(void) +static int AddressTestIPv6Lt01(void) { int result = 0; @@ -876,7 +877,7 @@ int AddressTestIPv6Lt01(void) return result; } -int AddressTestIPv6Lt02(void) +static int AddressTestIPv6Lt02(void) { int result = 0; @@ -889,7 +890,7 @@ int AddressTestIPv6Lt02(void) return result; } -int AddressTestIPv6Lt03(void) +static int AddressTestIPv6Lt03(void) { int result = 0; @@ -902,7 +903,7 @@ int AddressTestIPv6Lt03(void) return result; } -int AddressTestIPv6Lt04(void) +static int AddressTestIPv6Lt04(void) { int result = 0; @@ -915,7 +916,7 @@ int AddressTestIPv6Lt04(void) return result; } -int AddressTestIPv6Eq01(void) +static int AddressTestIPv6Eq01(void) { int result = 0; @@ -928,7 +929,7 @@ int AddressTestIPv6Eq01(void) return result; } -int AddressTestIPv6Eq02(void) +static int AddressTestIPv6Eq02(void) { int result = 0; @@ -941,7 +942,7 @@ int AddressTestIPv6Eq02(void) return result; } -int AddressTestIPv6Eq03(void) +static int AddressTestIPv6Eq03(void) { int result = 0; @@ -954,7 +955,7 @@ int AddressTestIPv6Eq03(void) return result; } -int AddressTestIPv6Eq04(void) +static int AddressTestIPv6Eq04(void) { int result = 0; @@ -967,7 +968,7 @@ int AddressTestIPv6Eq04(void) return result; } -int AddressTestIPv6Le01(void) +static int AddressTestIPv6Le01(void) { int result = 0; @@ -980,7 +981,7 @@ int AddressTestIPv6Le01(void) return result; } -int AddressTestIPv6Le02(void) +static int AddressTestIPv6Le02(void) { int result = 0; @@ -993,7 +994,7 @@ int AddressTestIPv6Le02(void) return result; } -int AddressTestIPv6Le03(void) +static int AddressTestIPv6Le03(void) { int result = 0; @@ -1006,7 +1007,7 @@ int AddressTestIPv6Le03(void) return result; } -int AddressTestIPv6Le04(void) +static int AddressTestIPv6Le04(void) { int result = 0; @@ -1019,7 +1020,7 @@ int AddressTestIPv6Le04(void) return result; } -int AddressTestIPv6Le05(void) +static int AddressTestIPv6Le05(void) { int result = 0; @@ -1041,7 +1042,7 @@ int AddressTestIPv6Le05(void) return result; } -int AddressTestIPv6Ge01(void) +static int AddressTestIPv6Ge01(void) { int result = 0; @@ -1054,7 +1055,7 @@ int AddressTestIPv6Ge01(void) return result; } -int AddressTestIPv6Ge02(void) +static int AddressTestIPv6Ge02(void) { int result = 0; @@ -1067,7 +1068,7 @@ int AddressTestIPv6Ge02(void) return result; } -int AddressTestIPv6Ge03(void) +static int AddressTestIPv6Ge03(void) { int result = 0; @@ -1080,7 +1081,7 @@ int AddressTestIPv6Ge03(void) return result; } -int AddressTestIPv6Ge04(void) +static int AddressTestIPv6Ge04(void) { int result = 0; @@ -1093,7 +1094,7 @@ int AddressTestIPv6Ge04(void) return result; } -int AddressTestIPv6Ge05(void) +static int AddressTestIPv6Ge05(void) { int result = 0; @@ -1115,7 +1116,7 @@ int AddressTestIPv6Ge05(void) return result; } -int AddressTestIPv6SubOne01(void) +static int AddressTestIPv6SubOne01(void) { int result = 0; @@ -1144,7 +1145,7 @@ int AddressTestIPv6SubOne01(void) return result; } -int AddressTestIPv6SubOne02(void) +static int AddressTestIPv6SubOne02(void) { int result = 0; @@ -1173,7 +1174,7 @@ int AddressTestIPv6SubOne02(void) return result; } -int AddressTestIPv6AddOne01(void) +static int AddressTestIPv6AddOne01(void) { int result = 0; @@ -1202,7 +1203,7 @@ int AddressTestIPv6AddOne01(void) return result; } -int AddressTestIPv6AddOne02(void) +static int AddressTestIPv6AddOne02(void) { int result = 0; diff --git a/src/detect-engine-address-ipv6.h b/src/detect-engine-address-ipv6.h index dedf090bff..2556e55b21 100644 --- a/src/detect-engine-address-ipv6.h +++ b/src/detect-engine-address-ipv6.h @@ -30,6 +30,12 @@ int AddressIPv6Eq(Address *, Address *); int AddressIPv6Le(Address *, Address *); int AddressIPv6Ge(Address *, Address *); +int AddressIPv6LeU32(uint32_t *a, uint32_t *b); +int AddressIPv6LtU32(uint32_t *a, uint32_t *b); +int AddressIPv6GtU32(uint32_t *a, uint32_t *b); +int AddressIPv6EqU32(uint32_t *a, uint32_t *b); +int AddressIPv6GeU32(uint32_t *a, uint32_t *b); + int DetectAddressCutNotIPv6(DetectAddress *, DetectAddress **); int DetectAddressCmpIPv6(DetectAddress *a, DetectAddress *b); diff --git a/src/detect-engine-address.c b/src/detect-engine-address.c index 079ec36dc0..694a764aca 100644 --- a/src/detect-engine-address.c +++ b/src/detect-engine-address.c @@ -495,7 +495,7 @@ static void DetectAddressParseIPv6CIDR(int cidr, struct in6_addr *in6) * \retval 0 On successfully parsing the address string. * \retval -1 On failure. */ -int DetectAddressParseString(DetectAddress *dd, char *str) +int DetectAddressParseString(DetectAddress *dd, const char *str) { char *ip = NULL; char *ip2 = NULL; @@ -677,7 +677,7 @@ error: * \retval dd Pointer to the DetectAddress instance containing the address * range details from the parsed ip string */ -static DetectAddress *DetectAddressParseSingle(char *str) +static DetectAddress *DetectAddressParseSingle(const char *str) { DetectAddress *dd; @@ -712,7 +712,7 @@ error: * \retval 0 On success. * \retval -1 On failure. */ -int DetectAddressSetup(DetectAddressHead *gh, char *s) +static int DetectAddressSetup(DetectAddressHead *gh, const char *s) { DetectAddress *ad = NULL; DetectAddress *ad2 = NULL; @@ -823,7 +823,7 @@ static int DetectAddressParse2(const DetectEngineCtx *de_ctx, int depth = 0; size_t size = strlen(s); char address[8196] = ""; - char *rule_var_address = NULL; + const char *rule_var_address = NULL; char *temp_rule_var_address = NULL; SCLogDebug("s %s negate %s", s, negate ? "true" : "false"); @@ -947,13 +947,16 @@ static int DetectAddressParse2(const DetectEngineCtx *de_ctx, } SCLogDebug("rule_var_address %s", rule_var_address); - temp_rule_var_address = rule_var_address; if ((negate + n_set) % 2) { temp_rule_var_address = SCMalloc(strlen(rule_var_address) + 3); if (unlikely(temp_rule_var_address == NULL)) goto error; snprintf(temp_rule_var_address, strlen(rule_var_address) + 3, "[%s]", rule_var_address); + } else { + temp_rule_var_address = SCStrdup(rule_var_address); + if (unlikely(temp_rule_var_address == NULL)) + goto error; } @@ -966,8 +969,7 @@ static int DetectAddressParse2(const DetectEngineCtx *de_ctx, } d_set = 0; n_set = 0; - if (temp_rule_var_address != rule_var_address) - SCFree(temp_rule_var_address); + SCFree(temp_rule_var_address); } else { address[x - 1] = '\0'; @@ -1014,13 +1016,16 @@ static int DetectAddressParse2(const DetectEngineCtx *de_ctx, } SCLogDebug("rule_var_address %s", rule_var_address); - temp_rule_var_address = rule_var_address; if ((negate + n_set) % 2) { temp_rule_var_address = SCMalloc(strlen(rule_var_address) + 3); if (unlikely(temp_rule_var_address == NULL)) goto error; snprintf(temp_rule_var_address, strlen(rule_var_address) + 3, "[%s]", rule_var_address); + } else { + temp_rule_var_address = SCStrdup(rule_var_address); + if (unlikely(temp_rule_var_address == NULL)) + goto error; } if (DetectAddressParse2(de_ctx, gh, ghn, temp_rule_var_address, @@ -1031,8 +1036,7 @@ static int DetectAddressParse2(const DetectEngineCtx *de_ctx, goto error; } d_set = 0; - if (temp_rule_var_address != rule_var_address) - SCFree(temp_rule_var_address); + SCFree(temp_rule_var_address); } else { if (!((negate + n_set) % 2)) { SCLogDebug("DetectAddressSetup into gh, %s", address); @@ -1407,7 +1411,7 @@ void DetectAddressMapFree(DetectEngineCtx *de_ctx) return; } -int DetectAddressMapAdd(DetectEngineCtx *de_ctx, const char *string, +static int DetectAddressMapAdd(DetectEngineCtx *de_ctx, const char *string, DetectAddressHead *address) { DetectAddressMap *map = SCCalloc(1, sizeof(*map)); @@ -1425,7 +1429,7 @@ int DetectAddressMapAdd(DetectEngineCtx *de_ctx, const char *string, return 0; } -const DetectAddressHead *DetectAddressMapLookup(DetectEngineCtx *de_ctx, +static const DetectAddressHead *DetectAddressMapLookup(DetectEngineCtx *de_ctx, const char *string) { DetectAddressMap map = { (char *)string, NULL }; @@ -1987,7 +1991,7 @@ typedef struct UTHValidateDetectAddressHeadRange_ { const char *two; } UTHValidateDetectAddressHeadRange; -int UTHValidateDetectAddressHead(DetectAddressHead *gh, int nranges, UTHValidateDetectAddressHeadRange *expectations) +static int UTHValidateDetectAddressHead(DetectAddressHead *gh, int nranges, UTHValidateDetectAddressHeadRange *expectations) { int expect = nranges; int have = 0; @@ -2015,7 +2019,7 @@ int UTHValidateDetectAddressHead(DetectAddressHead *gh, int nranges, UTHValidate return TRUE; } -int AddressTestParse01(void) +static int AddressTestParse01(void) { DetectAddress *dd = DetectAddressParseSingle("1.2.3.4"); @@ -2027,7 +2031,7 @@ int AddressTestParse01(void) return 0; } -int AddressTestParse02(void) +static int AddressTestParse02(void) { int result = 1; DetectAddress *dd = DetectAddressParseSingle("1.2.3.4"); @@ -2046,7 +2050,7 @@ int AddressTestParse02(void) return 0; } -int AddressTestParse03(void) +static int AddressTestParse03(void) { DetectAddress *dd = DetectAddressParseSingle("1.2.3.4/255.255.255.0"); @@ -2058,7 +2062,7 @@ int AddressTestParse03(void) return 0; } -int AddressTestParse04(void) +static int AddressTestParse04(void) { int result = 1; DetectAddress *dd = DetectAddressParseSingle("1.2.3.4/255.255.255.0"); @@ -2076,7 +2080,7 @@ int AddressTestParse04(void) return 0; } -int AddressTestParse05(void) +static int AddressTestParse05(void) { DetectAddress *dd = DetectAddressParseSingle("1.2.3.4/24"); @@ -2088,7 +2092,7 @@ int AddressTestParse05(void) return 0; } -int AddressTestParse06(void) +static int AddressTestParse06(void) { int result = 1; DetectAddress *dd = DetectAddressParseSingle("1.2.3.4/24"); @@ -2106,7 +2110,7 @@ int AddressTestParse06(void) return 0; } -int AddressTestParse07(void) +static int AddressTestParse07(void) { DetectAddress *dd = DetectAddressParseSingle("2001::/3"); @@ -2118,7 +2122,7 @@ int AddressTestParse07(void) return 0; } -int AddressTestParse08(void) +static int AddressTestParse08(void) { int result = 1; DetectAddress *dd = DetectAddressParseSingle("2001::/3"); @@ -2140,7 +2144,7 @@ int AddressTestParse08(void) return 0; } -int AddressTestParse09(void) +static int AddressTestParse09(void) { DetectAddress *dd = DetectAddressParseSingle("2001::1/128"); @@ -2152,7 +2156,7 @@ int AddressTestParse09(void) return 0; } -int AddressTestParse10(void) +static int AddressTestParse10(void) { int result = 1; DetectAddress *dd = DetectAddressParseSingle("2001::/128"); @@ -2174,7 +2178,7 @@ int AddressTestParse10(void) return 0; } -int AddressTestParse11(void) +static int AddressTestParse11(void) { DetectAddress *dd = DetectAddressParseSingle("2001::/48"); @@ -2186,7 +2190,7 @@ int AddressTestParse11(void) return 0; } -int AddressTestParse12(void) +static int AddressTestParse12(void) { int result = 1; DetectAddress *dd = DetectAddressParseSingle("2001::/48"); @@ -2207,7 +2211,7 @@ int AddressTestParse12(void) return 0; } -int AddressTestParse13(void) +static int AddressTestParse13(void) { DetectAddress *dd = DetectAddressParseSingle("2001::/16"); @@ -2219,7 +2223,7 @@ int AddressTestParse13(void) return 0; } -int AddressTestParse14(void) +static int AddressTestParse14(void) { int result = 1; DetectAddress *dd = DetectAddressParseSingle("2001::/16"); @@ -2240,7 +2244,7 @@ int AddressTestParse14(void) return 0; } -int AddressTestParse15(void) +static int AddressTestParse15(void) { DetectAddress *dd = DetectAddressParseSingle("2001::/0"); @@ -2252,7 +2256,7 @@ int AddressTestParse15(void) return 0; } -int AddressTestParse16(void) +static int AddressTestParse16(void) { int result = 1; DetectAddress *dd = DetectAddressParseSingle("2001::/0"); @@ -2273,7 +2277,7 @@ int AddressTestParse16(void) return 0; } -int AddressTestParse17(void) +static int AddressTestParse17(void) { DetectAddress *dd = DetectAddressParseSingle("1.2.3.4-1.2.3.6"); @@ -2285,7 +2289,7 @@ int AddressTestParse17(void) return 0; } -int AddressTestParse18(void) +static int AddressTestParse18(void) { int result = 1; DetectAddress *dd = DetectAddressParseSingle("1.2.3.4-1.2.3.6"); @@ -2303,7 +2307,7 @@ int AddressTestParse18(void) return 0; } -int AddressTestParse19(void) +static int AddressTestParse19(void) { DetectAddress *dd = DetectAddressParseSingle("1.2.3.6-1.2.3.4"); @@ -2315,7 +2319,7 @@ int AddressTestParse19(void) return 1; } -int AddressTestParse20(void) +static int AddressTestParse20(void) { DetectAddress *dd = DetectAddressParseSingle("2001::1-2001::4"); @@ -2327,7 +2331,7 @@ int AddressTestParse20(void) return 0; } -int AddressTestParse21(void) +static int AddressTestParse21(void) { int result = 1; DetectAddress *dd = DetectAddressParseSingle("2001::1-2001::4"); @@ -2348,7 +2352,7 @@ int AddressTestParse21(void) return 0; } -int AddressTestParse22(void) +static int AddressTestParse22(void) { DetectAddress *dd = DetectAddressParseSingle("2001::4-2001::1"); @@ -2360,7 +2364,7 @@ int AddressTestParse22(void) return 1; } -int AddressTestParse23(void) +static int AddressTestParse23(void) { DetectAddress *dd = DetectAddressParseSingle("any"); @@ -2372,7 +2376,7 @@ int AddressTestParse23(void) return 0; } -int AddressTestParse24(void) +static int AddressTestParse24(void) { DetectAddress *dd = DetectAddressParseSingle("Any"); @@ -2384,7 +2388,7 @@ int AddressTestParse24(void) return 0; } -int AddressTestParse25(void) +static int AddressTestParse25(void) { DetectAddress *dd = DetectAddressParseSingle("ANY"); @@ -2396,7 +2400,7 @@ int AddressTestParse25(void) return 0; } -int AddressTestParse26(void) +static int AddressTestParse26(void) { int result = 0; DetectAddress *dd = DetectAddressParseSingle("any"); @@ -2412,7 +2416,7 @@ int AddressTestParse26(void) return 0; } -int AddressTestParse27(void) +static int AddressTestParse27(void) { DetectAddress *dd = DetectAddressParseSingle("!192.168.0.1"); @@ -2424,7 +2428,7 @@ int AddressTestParse27(void) return 0; } -int AddressTestParse28(void) +static int AddressTestParse28(void) { int result = 0; DetectAddress *dd = DetectAddressParseSingle("!1.2.3.4"); @@ -2442,7 +2446,7 @@ int AddressTestParse28(void) return 0; } -int AddressTestParse29(void) +static int AddressTestParse29(void) { DetectAddress *dd = DetectAddressParseSingle("!1.2.3.0/24"); @@ -2454,7 +2458,7 @@ int AddressTestParse29(void) return 0; } -int AddressTestParse30(void) +static int AddressTestParse30(void) { int result = 0; DetectAddress *dd = DetectAddressParseSingle("!1.2.3.4/24"); @@ -2476,7 +2480,7 @@ int AddressTestParse30(void) /** * \test make sure !any is rejected */ -int AddressTestParse31(void) +static int AddressTestParse31(void) { DetectAddress *dd = DetectAddressParseSingle("!any"); @@ -2488,7 +2492,7 @@ int AddressTestParse31(void) return 1; } -int AddressTestParse32(void) +static int AddressTestParse32(void) { DetectAddress *dd = DetectAddressParseSingle("!2001::1"); @@ -2500,7 +2504,7 @@ int AddressTestParse32(void) return 0; } -int AddressTestParse33(void) +static int AddressTestParse33(void) { int result = 0; DetectAddress *dd = DetectAddressParseSingle("!2001::1"); @@ -2519,7 +2523,7 @@ int AddressTestParse33(void) return 0; } -int AddressTestParse34(void) +static int AddressTestParse34(void) { DetectAddress *dd = DetectAddressParseSingle("!2001::/16"); @@ -2531,7 +2535,7 @@ int AddressTestParse34(void) return 0; } -int AddressTestParse35(void) +static int AddressTestParse35(void) { int result = 0; DetectAddress *dd = DetectAddressParseSingle("!2001::/16"); @@ -2553,7 +2557,7 @@ int AddressTestParse35(void) return 0; } -int AddressTestParse36(void) +static int AddressTestParse36(void) { int result = 1; DetectAddress *dd = DetectAddressParseSingle("ffff::/16"); @@ -2577,7 +2581,7 @@ int AddressTestParse36(void) return 0; } -int AddressTestParse37(void) +static int AddressTestParse37(void) { int result = 1; DetectAddress *dd = DetectAddressParseSingle("::/0"); @@ -2600,7 +2604,7 @@ int AddressTestParse37(void) return 0; } -int AddressTestMatch01(void) +static int AddressTestMatch01(void) { DetectAddress *dd = NULL; int result = 1; @@ -2625,7 +2629,7 @@ int AddressTestMatch01(void) return 0; } -int AddressTestMatch02(void) +static int AddressTestMatch02(void) { DetectAddress *dd = NULL; int result = 1; @@ -2650,7 +2654,7 @@ int AddressTestMatch02(void) return 0; } -int AddressTestMatch03(void) +static int AddressTestMatch03(void) { DetectAddress *dd = NULL; int result = 1; @@ -2675,7 +2679,7 @@ int AddressTestMatch03(void) return 0; } -int AddressTestMatch04(void) +static int AddressTestMatch04(void) { DetectAddress *dd = NULL; int result = 1; @@ -2700,7 +2704,7 @@ int AddressTestMatch04(void) return 0; } -int AddressTestMatch05(void) +static int AddressTestMatch05(void) { DetectAddress *dd = NULL; int result = 1; @@ -2725,7 +2729,7 @@ int AddressTestMatch05(void) return 0; } -int AddressTestMatch06(void) +static int AddressTestMatch06(void) { DetectAddress *dd = NULL; int result = 1; @@ -2750,7 +2754,7 @@ int AddressTestMatch06(void) return 0; } -int AddressTestMatch07(void) +static int AddressTestMatch07(void) { DetectAddress *dd = NULL; int result = 1; @@ -2775,7 +2779,7 @@ int AddressTestMatch07(void) return 0; } -int AddressTestMatch08(void) +static int AddressTestMatch08(void) { DetectAddress *dd = NULL; int result = 1; @@ -2800,7 +2804,7 @@ int AddressTestMatch08(void) return 0; } -int AddressTestMatch09(void) +static int AddressTestMatch09(void) { DetectAddress *dd = NULL; int result = 1; @@ -2825,7 +2829,7 @@ int AddressTestMatch09(void) return 0; } -int AddressTestMatch10(void) +static int AddressTestMatch10(void) { DetectAddress *dd = NULL; int result = 1; @@ -2850,7 +2854,7 @@ int AddressTestMatch10(void) return 0; } -int AddressTestMatch11(void) +static int AddressTestMatch11(void) { DetectAddress *dd = NULL; int result = 1; @@ -2875,7 +2879,7 @@ int AddressTestMatch11(void) return 0; } -int AddressTestCmp01(void) +static int AddressTestCmp01(void) { DetectAddress *da = NULL, *db = NULL; int result = 1; @@ -2898,7 +2902,7 @@ error: return 0; } -int AddressTestCmp02(void) +static int AddressTestCmp02(void) { DetectAddress *da = NULL, *db = NULL; int result = 1; @@ -2921,7 +2925,7 @@ error: return 0; } -int AddressTestCmp03(void) +static int AddressTestCmp03(void) { DetectAddress *da = NULL, *db = NULL; int result = 1; @@ -2944,7 +2948,7 @@ error: return 0; } -int AddressTestCmp04(void) +static int AddressTestCmp04(void) { DetectAddress *da = NULL, *db = NULL; int result = 1; @@ -2967,7 +2971,7 @@ error: return 0; } -int AddressTestCmp05(void) +static int AddressTestCmp05(void) { DetectAddress *da = NULL, *db = NULL; int result = 1; @@ -2990,7 +2994,7 @@ error: return 0; } -int AddressTestCmp06(void) +static int AddressTestCmp06(void) { DetectAddress *da = NULL, *db = NULL; int result = 1; @@ -3013,7 +3017,7 @@ error: return 0; } -int AddressTestCmpIPv407(void) +static int AddressTestCmpIPv407(void) { DetectAddress *da = NULL, *db = NULL; int result = 1; @@ -3036,7 +3040,7 @@ error: return 0; } -int AddressTestCmpIPv408(void) +static int AddressTestCmpIPv408(void) { DetectAddress *da = NULL, *db = NULL; int result = 1; @@ -3059,7 +3063,7 @@ error: return 0; } -int AddressTestCmp07(void) +static int AddressTestCmp07(void) { DetectAddress *da = NULL, *db = NULL; int result = 1; @@ -3082,7 +3086,7 @@ error: return 0; } -int AddressTestCmp08(void) +static int AddressTestCmp08(void) { DetectAddress *da = NULL, *db = NULL; int result = 1; @@ -3105,7 +3109,7 @@ error: return 0; } -int AddressTestCmp09(void) +static int AddressTestCmp09(void) { DetectAddress *da = NULL, *db = NULL; int result = 1; @@ -3128,7 +3132,7 @@ error: return 0; } -int AddressTestCmp10(void) +static int AddressTestCmp10(void) { DetectAddress *da = NULL, *db = NULL; int result = 1; @@ -3151,7 +3155,7 @@ error: return 0; } -int AddressTestCmp11(void) +static int AddressTestCmp11(void) { DetectAddress *da = NULL, *db = NULL; int result = 1; @@ -3174,7 +3178,7 @@ error: return 0; } -int AddressTestCmp12(void) +static int AddressTestCmp12(void) { DetectAddress *da = NULL, *db = NULL; int result = 1; @@ -3197,7 +3201,7 @@ error: return 0; } -int AddressTestAddressGroupSetup01(void) +static int AddressTestAddressGroupSetup01(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -3212,7 +3216,7 @@ int AddressTestAddressGroupSetup01(void) return result; } -int AddressTestAddressGroupSetup02(void) +static int AddressTestAddressGroupSetup02(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -3227,7 +3231,7 @@ int AddressTestAddressGroupSetup02(void) return result; } -int AddressTestAddressGroupSetup03(void) +static int AddressTestAddressGroupSetup03(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -3249,7 +3253,7 @@ int AddressTestAddressGroupSetup03(void) return result; } -int AddressTestAddressGroupSetup04(void) +static int AddressTestAddressGroupSetup04(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -3277,7 +3281,7 @@ int AddressTestAddressGroupSetup04(void) return result; } -int AddressTestAddressGroupSetup05(void) +static int AddressTestAddressGroupSetup05(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -3305,7 +3309,7 @@ int AddressTestAddressGroupSetup05(void) return result; } -int AddressTestAddressGroupSetup06(void) +static int AddressTestAddressGroupSetup06(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -3327,7 +3331,7 @@ int AddressTestAddressGroupSetup06(void) return result; } -int AddressTestAddressGroupSetup07(void) +static int AddressTestAddressGroupSetup07(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -3348,7 +3352,7 @@ int AddressTestAddressGroupSetup07(void) return result; } -int AddressTestAddressGroupSetup08(void) +static int AddressTestAddressGroupSetup08(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -3369,7 +3373,7 @@ int AddressTestAddressGroupSetup08(void) return result; } -int AddressTestAddressGroupSetup09(void) +static int AddressTestAddressGroupSetup09(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -3390,7 +3394,7 @@ int AddressTestAddressGroupSetup09(void) return result; } -int AddressTestAddressGroupSetup10(void) +static int AddressTestAddressGroupSetup10(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -3411,7 +3415,7 @@ int AddressTestAddressGroupSetup10(void) return result; } -int AddressTestAddressGroupSetup11(void) +static int AddressTestAddressGroupSetup11(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -3450,7 +3454,7 @@ int AddressTestAddressGroupSetup11(void) return result; } -int AddressTestAddressGroupSetup12 (void) +static int AddressTestAddressGroupSetup12 (void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -3489,7 +3493,7 @@ int AddressTestAddressGroupSetup12 (void) return result; } -int AddressTestAddressGroupSetup13(void) +static int AddressTestAddressGroupSetup13(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -3528,7 +3532,7 @@ int AddressTestAddressGroupSetup13(void) return result; } -int AddressTestAddressGroupSetupIPv414(void) +static int AddressTestAddressGroupSetupIPv414(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -3562,7 +3566,7 @@ int AddressTestAddressGroupSetupIPv414(void) return result; } -int AddressTestAddressGroupSetupIPv415(void) +static int AddressTestAddressGroupSetupIPv415(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -3586,7 +3590,7 @@ int AddressTestAddressGroupSetupIPv415(void) return result; } -int AddressTestAddressGroupSetupIPv416(void) +static int AddressTestAddressGroupSetupIPv416(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -3610,7 +3614,7 @@ int AddressTestAddressGroupSetupIPv416(void) return result; } -int AddressTestAddressGroupSetup14(void) +static int AddressTestAddressGroupSetup14(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -3625,7 +3629,7 @@ int AddressTestAddressGroupSetup14(void) return result; } -int AddressTestAddressGroupSetup15(void) +static int AddressTestAddressGroupSetup15(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -3640,7 +3644,7 @@ int AddressTestAddressGroupSetup15(void) return result; } -int AddressTestAddressGroupSetup16(void) +static int AddressTestAddressGroupSetup16(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -3662,7 +3666,7 @@ int AddressTestAddressGroupSetup16(void) return result; } -int AddressTestAddressGroupSetup17(void) +static int AddressTestAddressGroupSetup17(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -3690,7 +3694,7 @@ int AddressTestAddressGroupSetup17(void) return result; } -int AddressTestAddressGroupSetup18(void) +static int AddressTestAddressGroupSetup18(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -3718,7 +3722,7 @@ int AddressTestAddressGroupSetup18(void) return result; } -int AddressTestAddressGroupSetup19(void) +static int AddressTestAddressGroupSetup19(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -3740,7 +3744,7 @@ int AddressTestAddressGroupSetup19(void) return result; } -int AddressTestAddressGroupSetup20(void) +static int AddressTestAddressGroupSetup20(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -3761,7 +3765,7 @@ int AddressTestAddressGroupSetup20(void) return result; } -int AddressTestAddressGroupSetup21(void) +static int AddressTestAddressGroupSetup21(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -3782,7 +3786,7 @@ int AddressTestAddressGroupSetup21(void) return result; } -int AddressTestAddressGroupSetup22(void) +static int AddressTestAddressGroupSetup22(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -3803,7 +3807,7 @@ int AddressTestAddressGroupSetup22(void) return result; } -int AddressTestAddressGroupSetup23(void) +static int AddressTestAddressGroupSetup23(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -3824,7 +3828,7 @@ int AddressTestAddressGroupSetup23(void) return result; } -int AddressTestAddressGroupSetup24(void) +static int AddressTestAddressGroupSetup24(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -3894,7 +3898,7 @@ int AddressTestAddressGroupSetup24(void) return result; } -int AddressTestAddressGroupSetup25(void) +static int AddressTestAddressGroupSetup25(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -3964,7 +3968,7 @@ int AddressTestAddressGroupSetup25(void) return result; } -int AddressTestAddressGroupSetup26(void) +static int AddressTestAddressGroupSetup26(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -4034,7 +4038,7 @@ int AddressTestAddressGroupSetup26(void) return result; } -int AddressTestAddressGroupSetup27(void) +static int AddressTestAddressGroupSetup27(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -4049,7 +4053,7 @@ int AddressTestAddressGroupSetup27(void) return result; } -int AddressTestAddressGroupSetup28(void) +static int AddressTestAddressGroupSetup28(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -4064,7 +4068,7 @@ int AddressTestAddressGroupSetup28(void) return result; } -int AddressTestAddressGroupSetup29(void) +static int AddressTestAddressGroupSetup29(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -4079,7 +4083,7 @@ int AddressTestAddressGroupSetup29(void) return result; } -int AddressTestAddressGroupSetup30(void) +static int AddressTestAddressGroupSetup30(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -4094,7 +4098,7 @@ int AddressTestAddressGroupSetup30(void) return result; } -int AddressTestAddressGroupSetup31(void) +static int AddressTestAddressGroupSetup31(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -4109,7 +4113,7 @@ int AddressTestAddressGroupSetup31(void) return result; } -int AddressTestAddressGroupSetup32(void) +static int AddressTestAddressGroupSetup32(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -4124,7 +4128,7 @@ int AddressTestAddressGroupSetup32(void) return result; } -int AddressTestAddressGroupSetup33(void) +static int AddressTestAddressGroupSetup33(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -4139,7 +4143,7 @@ int AddressTestAddressGroupSetup33(void) return result; } -int AddressTestAddressGroupSetup34(void) +static int AddressTestAddressGroupSetup34(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -4154,7 +4158,7 @@ int AddressTestAddressGroupSetup34(void) return result; } -int AddressTestAddressGroupSetup35(void) +static int AddressTestAddressGroupSetup35(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -4169,7 +4173,7 @@ int AddressTestAddressGroupSetup35(void) return result; } -int AddressTestAddressGroupSetup36 (void) +static int AddressTestAddressGroupSetup36 (void) { int result = 0; @@ -4184,7 +4188,7 @@ int AddressTestAddressGroupSetup36 (void) return result; } -int AddressTestAddressGroupSetup37(void) +static int AddressTestAddressGroupSetup37(void) { int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -4417,7 +4421,7 @@ static int AddressTestAddressGroupSetup48(void) return result; } -int AddressTestCutIPv401(void) +static int AddressTestCutIPv401(void) { DetectAddress *a, *b, *c; a = DetectAddressParseSingle("1.2.3.0/255.255.255.0"); @@ -4438,7 +4442,7 @@ error: return 0; } -int AddressTestCutIPv402(void) +static int AddressTestCutIPv402(void) { DetectAddress *a, *b, *c; a = DetectAddressParseSingle("1.2.3.0/255.255.255.0"); @@ -4462,7 +4466,7 @@ error: return 0; } -int AddressTestCutIPv403(void) +static int AddressTestCutIPv403(void) { DetectAddress *a, *b, *c; a = DetectAddressParseSingle("1.2.3.0/255.255.255.0"); @@ -4493,7 +4497,7 @@ error: return 0; } -int AddressTestCutIPv404(void) +static int AddressTestCutIPv404(void) { DetectAddress *a, *b, *c; a = DetectAddressParseSingle("1.2.3.3-1.2.3.6"); @@ -4525,7 +4529,7 @@ error: return 0; } -int AddressTestCutIPv405(void) +static int AddressTestCutIPv405(void) { DetectAddress *a, *b, *c; a = DetectAddressParseSingle("1.2.3.3-1.2.3.6"); @@ -4556,7 +4560,7 @@ error: return 0; } -int AddressTestCutIPv406(void) +static int AddressTestCutIPv406(void) { DetectAddress *a, *b, *c; a = DetectAddressParseSingle("1.2.3.0-1.2.3.9"); @@ -4587,7 +4591,7 @@ error: return 0; } -int AddressTestCutIPv407(void) +static int AddressTestCutIPv407(void) { DetectAddress *a, *b, *c; a = DetectAddressParseSingle("1.2.3.0-1.2.3.6"); @@ -4616,7 +4620,7 @@ error: return 0; } -int AddressTestCutIPv408(void) +static int AddressTestCutIPv408(void) { DetectAddress *a, *b, *c; a = DetectAddressParseSingle("1.2.3.3-1.2.3.9"); @@ -4645,7 +4649,7 @@ error: return 0; } -int AddressTestCutIPv409(void) +static int AddressTestCutIPv409(void) { DetectAddress *a, *b, *c; a = DetectAddressParseSingle("1.2.3.0-1.2.3.9"); @@ -4674,7 +4678,7 @@ error: return 0; } -int AddressTestCutIPv410(void) +static int AddressTestCutIPv410(void) { DetectAddress *a, *b, *c; a = DetectAddressParseSingle("1.2.3.0-1.2.3.9"); @@ -4705,7 +4709,7 @@ error: return 0; } -int AddressTestParseInvalidMask01(void) +static int AddressTestParseInvalidMask01(void) { int result = 1; DetectAddress *dd = NULL; @@ -4718,7 +4722,7 @@ int AddressTestParseInvalidMask01(void) return result; } -int AddressTestParseInvalidMask02(void) +static int AddressTestParseInvalidMask02(void) { int result = 1; DetectAddress *dd = NULL; @@ -4731,7 +4735,7 @@ int AddressTestParseInvalidMask02(void) return result; } -int AddressTestParseInvalidMask03(void) +static int AddressTestParseInvalidMask03(void) { int result = 1; DetectAddress *dd = NULL; @@ -4744,7 +4748,7 @@ int AddressTestParseInvalidMask03(void) return result; } -int AddressConfVarsTest01(void) +static int AddressConfVarsTest01(void) { static const char *dummy_conf_string = "%YAML 1.1\n" @@ -4780,7 +4784,7 @@ int AddressConfVarsTest01(void) return result; } -int AddressConfVarsTest02(void) +static int AddressConfVarsTest02(void) { static const char *dummy_conf_string = "%YAML 1.1\n" @@ -4816,7 +4820,7 @@ int AddressConfVarsTest02(void) return result; } -int AddressConfVarsTest03(void) +static int AddressConfVarsTest03(void) { static const char *dummy_conf_string = "%YAML 1.1\n" @@ -4852,7 +4856,7 @@ int AddressConfVarsTest03(void) return result; } -int AddressConfVarsTest04(void) +static int AddressConfVarsTest04(void) { static const char *dummy_conf_string = "%YAML 1.1\n" @@ -4888,7 +4892,7 @@ int AddressConfVarsTest04(void) return result; } -int AddressConfVarsTest05(void) +static int AddressConfVarsTest05(void) { static const char *dummy_conf_string = "%YAML 1.1\n" diff --git a/src/detect-engine-address.h b/src/detect-engine-address.h index 8c5d1256f0..d1944c1154 100644 --- a/src/detect-engine-address.h +++ b/src/detect-engine-address.h @@ -31,7 +31,7 @@ DetectAddressHead *DetectAddressHeadInit(void); void DetectAddressHeadFree(DetectAddressHead *); void DetectAddressHeadCleanup(DetectAddressHead *); -int DetectAddressParseString(DetectAddress *, char *); +int DetectAddressParseString(DetectAddress *, const char *); int DetectAddressParse(const DetectEngineCtx *, DetectAddressHead *, const char *); DetectAddress *DetectAddressInit(void); diff --git a/src/detect-engine-analyzer.c b/src/detect-engine-analyzer.c index 51ac3930aa..aabffe0ea1 100644 --- a/src/detect-engine-analyzer.c +++ b/src/detect-engine-analyzer.c @@ -216,7 +216,7 @@ int SetupFPAnalyzer(void) if (fp_engine_analysis_set == 0) return 0; - char *log_dir; + const char *log_dir; log_dir = ConfigGetLogDirectory(); snprintf(log_path, sizeof(log_path), "%s/%s", log_dir, "rules_fast_pattern.txt"); @@ -267,7 +267,7 @@ int SetupRuleAnalyzer(void) rule_warnings_only = 1; } if (enabled) { - char *log_dir; + const char *log_dir; log_dir = ConfigGetLogDirectory(); snprintf(log_path, sizeof(log_path), "%s/%s", log_dir, "rules_analysis.txt"); rule_engine_analysis_FD = fopen(log_path, "w"); diff --git a/src/detect-engine-analyzer.h b/src/detect-engine-analyzer.h index d9a8081595..1a46d0a877 100644 --- a/src/detect-engine-analyzer.h +++ b/src/detect-engine-analyzer.h @@ -32,7 +32,7 @@ void CleanupFPAnalyzer(void); int SetupRuleAnalyzer(void); void CleanupRuleAnalyzer (void); -int PerCentEncodingSetup (); +int PerCentEncodingSetup (void); int PerCentEncodingMatch (uint8_t *content, uint8_t content_len); void EngineAnalysisFP(Signature *s, char *line); diff --git a/src/detect-engine-dcepayload.c b/src/detect-engine-dcepayload.c index a680b1e74d..152f79e89e 100644 --- a/src/detect-engine-dcepayload.c +++ b/src/detect-engine-dcepayload.c @@ -36,6 +36,7 @@ #include "detect-byte-extract.h" #include "detect-content.h" #include "detect-engine-content-inspection.h" +#include "detect-engine-dcepayload.h" #include "stream-tcp.h" @@ -88,10 +89,10 @@ static int DcePayloadTest15(void) Flow f; int r; - char *sig1 = "alert tcp any any -> any any " + const char *sig1 = "alert tcp any any -> any any " "(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; " "byte_test:2,=,14080,0,relative,dce; sid:1;)"; - char *sig2 = "alert tcp any any -> any any " + const char *sig2 = "alert tcp any any -> any any " "(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; " "byte_test:2,=,46,5,relative,dce; sid:2;)"; @@ -205,10 +206,10 @@ static int DcePayloadTest16(void) Flow f; int r; - char *sig1 = "alert tcp any any -> any any " + const char *sig1 = "alert tcp any any -> any any " "(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; " "byte_test:2,=,55,0,relative; sid:1;)"; - char *sig2 = "alert tcp any any -> any any " + const char *sig2 = "alert tcp any any -> any any " "(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; " "byte_test:2,=,11776,5,relative; sid:2;)"; @@ -322,10 +323,10 @@ static int DcePayloadTest17(void) Flow f; int r; - char *sig1 = "alert tcp any any -> any any " + const char *sig1 = "alert tcp any any -> any any " "(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; " "byte_test:2,=,55,0,relative,big; sid:1;)"; - char *sig2 = "alert tcp any any -> any any " + const char *sig2 = "alert tcp any any -> any any " "(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; " "byte_test:2,=,46,5,relative,little; sid:2;)"; @@ -439,10 +440,10 @@ static int DcePayloadTest18(void) Flow f; int r; - char *sig1 = "alert tcp any any -> any any " + const char *sig1 = "alert tcp any any -> any any " "(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; " "byte_jump:2,0,relative,dce; byte_test:2,=,46,0,relative,dce; sid:1;)"; - char *sig2 = "alert tcp any any -> any any " + const char *sig2 = "alert tcp any any -> any any " "(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; " "byte_jump:2,2,relative,dce; byte_test:2,=,14080,0,relative; sid:2;)"; @@ -556,10 +557,10 @@ static int DcePayloadTest19(void) Flow f; int r; - char *sig1 = "alert tcp any any -> any any " + const char *sig1 = "alert tcp any any -> any any " "(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; " "byte_jump:2,0,relative; byte_test:2,=,46,0,relative,dce; sid:1;)"; - char *sig2 = "alert tcp any any -> any any " + const char *sig2 = "alert tcp any any -> any any " "(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; " "byte_jump:2,2,relative; byte_test:2,=,14080,0,relative; sid:2;)"; @@ -673,10 +674,10 @@ static int DcePayloadTest20(void) Flow f; int r; - char *sig1 = "alert tcp any any -> any any " + const char *sig1 = "alert tcp any any -> any any " "(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; " "byte_jump:2,0,relative,big; byte_test:2,=,46,0,relative,dce; sid:1;)"; - char *sig2 = "alert tcp any any -> any any " + const char *sig2 = "alert tcp any any -> any any " "(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; " "byte_jump:2,2,little,relative; byte_test:2,=,14080,0,relative; sid:2;)"; @@ -784,7 +785,7 @@ static int DcePayloadTest21(void) Flow f; int r; - char *sig1 = "alert tcp any any -> any any " + const char *sig1 = "alert tcp any any -> any any " "(msg:\"testing dce consecutive relative matches\"; dce_stub_data; " "content:\"this\"; distance:0; content:\"is\"; within:6; content:\"big\"; within:8; " "content:\"string\"; within:8; sid:1;)"; @@ -886,7 +887,7 @@ static int DcePayloadTest22(void) Flow f; int r; - char *sig1 = "alert tcp any any -> any any " + const char *sig1 = "alert tcp any any -> any any " "(msg:\"testing dce consecutive relative matches\"; dce_stub_data; " "content:\"this\"; distance:0; content:\"is\"; within:9; content:\"big\"; within:12; " "content:\"string\"; within:8; sid:1;)"; @@ -988,7 +989,7 @@ static int DcePayloadTest23(void) Flow f; int r; - char *sig1 = "alert tcp any any -> any any " + const char *sig1 = "alert tcp any any -> any any " "(msg:\"testing dce consecutive relative matches\"; dce_stub_data; " "content:\"now\"; distance:0; content:\"this\"; distance:-20; " "content:\"is\"; within:12; content:\"big\"; within:8; " @@ -3206,7 +3207,7 @@ static int DcePayloadTest42(void) Flow f; int r; - char *sig1 = "alert tcp any any -> any any " + const char *sig1 = "alert tcp any any -> any any " "(msg:\"testing dce consecutive relative matches\"; dce_stub_data; " "content:\"fix\"; distance:0; content:\"this\"; within:6; " "content:!\"and\"; distance:0; sid:1;)"; @@ -3310,7 +3311,7 @@ static int DcePayloadTest43(void) Flow f; int r; - char *sig1 = "alert tcp any any -> any any " + const char *sig1 = "alert tcp any any -> any any " "(msg:\"testing dce consecutive relative matches\"; dce_stub_data; " "pcre:/super/R; content:\"nova\"; within:7; sid:1;)"; diff --git a/src/detect-engine-dns.c b/src/detect-engine-dns.c index 314b095685..2891d08831 100644 --- a/src/detect-engine-dns.c +++ b/src/detect-engine-dns.c @@ -42,6 +42,7 @@ #include "app-layer-parser.h" #include "app-layer-protos.h" #include "app-layer-dns-common.h" +#include "detect-engine-dns.h" #include "util-unittest.h" #include "util-unittest-helper.h" diff --git a/src/detect-engine-enip.c b/src/detect-engine-enip.c index 8d87319617..3dcb681a82 100644 --- a/src/detect-engine-enip.c +++ b/src/detect-engine-enip.c @@ -72,7 +72,7 @@ void PrintENIPAL(ENIPTransaction *enip_data) * @param svc - the CIP service entry * * @param cipserviced - the CIP service rule */ -int CIPPathMatch(CIPServiceEntry *svc, DetectCipServiceData *cipserviced) +static int CIPPathMatch(CIPServiceEntry *svc, DetectCipServiceData *cipserviced) { uint16_t class = 0; uint16_t attrib = 0; @@ -161,7 +161,7 @@ int CIPPathMatch(CIPServiceEntry *svc, DetectCipServiceData *cipserviced) * * @param cipserviced - the CIP service rule */ -int CIPServiceMatch(ENIPTransaction *enip_data, +static int CIPServiceMatch(ENIPTransaction *enip_data, DetectCipServiceData *cipserviced) { int count = 1; diff --git a/src/detect-engine-event.c b/src/detect-engine-event.c index 06fcfe1086..fd5ea8e6d7 100644 --- a/src/detect-engine-event.c +++ b/src/detect-engine-event.c @@ -49,9 +49,9 @@ static pcre_extra *parse_regex_study; static int DetectEngineEventMatch (ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectEngineEventSetup (DetectEngineCtx *, Signature *, char *); -static int DetectDecodeEventSetup (DetectEngineCtx *, Signature *, char *); -static int DetectStreamEventSetup (DetectEngineCtx *, Signature *, char *); +static int DetectEngineEventSetup (DetectEngineCtx *, Signature *, const char *); +static int DetectDecodeEventSetup (DetectEngineCtx *, Signature *, const char *); +static int DetectStreamEventSetup (DetectEngineCtx *, Signature *, const char *); static void DetectEngineEventFree (void *); void EngineEventRegisterTests(void); @@ -116,7 +116,7 @@ static int DetectEngineEventMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx * \retval de pointer to DetectFlowData on success * \retval NULL on failure */ -DetectEngineEventData *DetectEngineEventParse (char *rawstr) +static DetectEngineEventData *DetectEngineEventParse (const char *rawstr) { int i; DetectEngineEventData *de = NULL; @@ -180,7 +180,7 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -static int _DetectEngineEventSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr, int smtype) +static int DetectEngineEventSetupDo (DetectEngineCtx *de_ctx, Signature *s, const char *rawstr, int smtype) { DetectEngineEventData *de = NULL; SigMatch *sm = NULL; @@ -208,9 +208,9 @@ error: } -static int DetectEngineEventSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr) +static int DetectEngineEventSetup (DetectEngineCtx *de_ctx, Signature *s, const char *rawstr) { - return _DetectEngineEventSetup (de_ctx, s, rawstr, DETECT_ENGINE_EVENT); + return DetectEngineEventSetupDo (de_ctx, s, rawstr, DETECT_ENGINE_EVENT); } /** @@ -230,20 +230,20 @@ static void DetectEngineEventFree(void *ptr) * \brief this function Setup the 'decode-event' keyword by setting the correct * signature type */ -static int DetectDecodeEventSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr) +static int DetectDecodeEventSetup (DetectEngineCtx *de_ctx, Signature *s, const char *rawstr) { char drawstr[MAX_SUBSTRINGS * 2] = "decoder."; /* decoder:$EVENT alias command develop as decode-event:decoder.$EVENT */ strlcat(drawstr, rawstr, 2 * MAX_SUBSTRINGS - strlen("decoder.") - 1); - return _DetectEngineEventSetup(de_ctx, s, drawstr, DETECT_DECODE_EVENT); + return DetectEngineEventSetupDo(de_ctx, s, drawstr, DETECT_DECODE_EVENT); } /** * \brief this function Setup the 'stream-event' keyword by resolving the alias */ -static int DetectStreamEventSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr) +static int DetectStreamEventSetup (DetectEngineCtx *de_ctx, Signature *s, const char *rawstr) { char srawstr[MAX_SUBSTRINGS * 2] = "stream."; @@ -261,7 +261,7 @@ static int DetectStreamEventSetup (DetectEngineCtx *de_ctx, Signature *s, char * /** * \test EngineEventTestParse01 is a test for a valid decode-event value */ -int EngineEventTestParse01 (void) +static int EngineEventTestParse01 (void) { DetectEngineEventData *de = NULL; de = DetectEngineEventParse("decoder.ipv4.pkt_too_small"); @@ -277,7 +277,7 @@ int EngineEventTestParse01 (void) /** * \test EngineEventTestParse02 is a test for a valid upper + lower case decode-event value */ -int EngineEventTestParse02 (void) +static int EngineEventTestParse02 (void) { DetectEngineEventData *de = NULL; de = DetectEngineEventParse("decoder.PPP.pkt_too_small"); @@ -292,7 +292,7 @@ int EngineEventTestParse02 (void) /** * \test EngineEventTestParse03 is a test for a valid upper case decode-event value */ -int EngineEventTestParse03 (void) +static int EngineEventTestParse03 (void) { DetectEngineEventData *de = NULL; de = DetectEngineEventParse("decoder.IPV6.PKT_TOO_SMALL"); @@ -307,7 +307,7 @@ int EngineEventTestParse03 (void) /** * \test EngineEventTestParse04 is a test for an invalid upper case decode-event value */ -int EngineEventTestParse04 (void) +static int EngineEventTestParse04 (void) { DetectEngineEventData *de = NULL; de = DetectEngineEventParse("decoder.IPV6.INVALID_EVENT"); @@ -322,7 +322,7 @@ int EngineEventTestParse04 (void) /** * \test EngineEventTestParse05 is a test for an invalid char into the decode-event value */ -int EngineEventTestParse05 (void) +static int EngineEventTestParse05 (void) { DetectEngineEventData *de = NULL; de = DetectEngineEventParse("decoder.IPV-6,INVALID_CHAR"); @@ -337,7 +337,7 @@ int EngineEventTestParse05 (void) /** * \test EngineEventTestParse06 is a test for match function with valid decode-event value */ -int EngineEventTestParse06 (void) +static int EngineEventTestParse06 (void) { Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) diff --git a/src/detect-engine-file.c b/src/detect-engine-file.c index 771a4c2983..8abb017ce6 100644 --- a/src/detect-engine-file.c +++ b/src/detect-engine-file.c @@ -39,6 +39,7 @@ #include "detect-engine-hcd.h" #include "detect-engine-hrud.h" #include "detect-engine-dcepayload.h" +#include "detect-engine-file.h" #include "stream-tcp.h" #include "stream-tcp-private.h" @@ -73,7 +74,7 @@ * \note flow is not locked at this time */ static int DetectFileInspect(ThreadVars *tv, DetectEngineThreadCtx *det_ctx, - Flow *f, Signature *s, const SigMatchData *smd, + Flow *f, const Signature *s, const SigMatchData *smd, uint8_t flags, FileContainer *ffc) { int r = 0; @@ -230,7 +231,7 @@ static int DetectFileInspect(ThreadVars *tv, DetectEngineThreadCtx *det_ctx, */ int DetectFileInspectHttp(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, - Signature *s, const SigMatchData *smd, + const Signature *s, const SigMatchData *smd, Flow *f, uint8_t flags, void *alstate, void *tx, uint64_t tx_id) { int r = DETECT_ENGINE_INSPECT_SIG_NO_MATCH; @@ -275,7 +276,7 @@ int DetectFileInspectHttp(ThreadVars *tv, */ int DetectFileInspectSmtp(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, - Signature *s, const SigMatchData *smd, + const Signature *s, const SigMatchData *smd, Flow *f, uint8_t flags, void *alstate, void *tx, uint64_t tx_id) { SCEnter(); diff --git a/src/detect-engine-filedata-smtp.c b/src/detect-engine-filedata-smtp.c index 60f24d62e9..face62d9d6 100644 --- a/src/detect-engine-filedata-smtp.c +++ b/src/detect-engine-filedata-smtp.c @@ -34,6 +34,7 @@ #include "detect-engine-state.h" #include "detect-engine-content-inspection.h" #include "detect-engine-prefilter.h" +#include "detect-engine-filedata-smtp.h" #include "flow-util.h" #include "util-debug.h" @@ -175,7 +176,7 @@ end: int DetectEngineInspectSMTPFiledata(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, - Signature *s, const SigMatchData *smd, + const Signature *s, const SigMatchData *smd, Flow *f, uint8_t flags, void *alstate, void *tx, uint64_t tx_id) { SMTPState *smtp_state = (SMTPState *)alstate; diff --git a/src/detect-engine-hcbd.c b/src/detect-engine-hcbd.c index eb00951bfc..8a8eedbc54 100644 --- a/src/detect-engine-hcbd.c +++ b/src/detect-engine-hcbd.c @@ -43,6 +43,7 @@ #include "detect-engine-state.h" #include "detect-engine-content-inspection.h" #include "detect-engine-prefilter.h" +#include "detect-engine-hcbd.h" #include "flow-util.h" #include "util-debug.h" @@ -258,7 +259,7 @@ int PrefilterTxHttpRequestBodyRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx) int DetectEngineInspectHttpClientBody(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, - Signature *s, const SigMatchData *smd, + const Signature *s, const SigMatchData *smd, Flow *f, uint8_t flags, void *alstate, void *tx, uint64_t tx_id) { HtpState *htp_state = (HtpState *)alstate; diff --git a/src/detect-engine-hsbd.c b/src/detect-engine-hsbd.c index 58727dca01..fdf76977fb 100644 --- a/src/detect-engine-hsbd.c +++ b/src/detect-engine-hsbd.c @@ -43,6 +43,7 @@ #include "detect-engine-state.h" #include "detect-engine-content-inspection.h" #include "detect-engine-prefilter.h" +#include "detect-engine-hsbd.h" #include "flow-util.h" #include "util-debug.h" @@ -263,7 +264,7 @@ int PrefilterTxHttpResponseBodyRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx) int DetectEngineInspectHttpServerBody(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, - Signature *s, const SigMatchData *smd, + const Signature *s, const SigMatchData *smd, Flow *f, uint8_t flags, void *alstate, void *tx, uint64_t tx_id) { HtpState *htp_state = (HtpState *)alstate; diff --git a/src/detect-engine-iponly.c b/src/detect-engine-iponly.c index bd47567781..28264b434b 100644 --- a/src/detect-engine-iponly.c +++ b/src/detect-engine-iponly.c @@ -66,7 +66,7 @@ * * \retval IPOnlyCIDRItem address of the new instance */ -static IPOnlyCIDRItem *IPOnlyCIDRItemNew() +static IPOnlyCIDRItem *IPOnlyCIDRItemNew(void) { SCEnter(); IPOnlyCIDRItem *item = NULL; @@ -103,7 +103,7 @@ static uint8_t IPOnlyCIDRItemCompare(IPOnlyCIDRItem *head, * \retval 0 On successfully parsing the address string. * \retval -1 On failure. */ -static int IPOnlyCIDRItemParseSingle(IPOnlyCIDRItem *dd, char *str) +static int IPOnlyCIDRItemParseSingle(IPOnlyCIDRItem *dd, const char *str) { char buf[256] = ""; char *ip = NULL, *ip2 = NULL; @@ -590,7 +590,7 @@ static IPOnlyCIDRItem *IPOnlyCIDRListParse2(const DetectEngineCtx *de_ctx, int depth = 0; size_t size = strlen(s); char address[8196] = ""; - char *rule_var_address = NULL; + const char *rule_var_address = NULL; char *temp_rule_var_address = NULL; IPOnlyCIDRItem *head; IPOnlyCIDRItem *subhead; @@ -635,16 +635,19 @@ static IPOnlyCIDRItem *IPOnlyCIDRListParse2(const DetectEngineCtx *de_ctx, if (rule_var_address == NULL) goto error; - temp_rule_var_address = rule_var_address; if ((negate + n_set) % 2) { temp_rule_var_address = SCMalloc(strlen(rule_var_address) + 3); - if (unlikely(temp_rule_var_address == NULL)) { goto error; } snprintf(temp_rule_var_address, strlen(rule_var_address) + 3, "[%s]", rule_var_address); + } else { + temp_rule_var_address = SCStrdup(rule_var_address); + if (unlikely(temp_rule_var_address == NULL)) { + goto error; + } } subhead = IPOnlyCIDRListParse2(de_ctx, temp_rule_var_address, @@ -654,8 +657,7 @@ static IPOnlyCIDRItem *IPOnlyCIDRListParse2(const DetectEngineCtx *de_ctx, d_set = 0; n_set = 0; - if (temp_rule_var_address != rule_var_address) - SCFree(temp_rule_var_address); + SCFree(temp_rule_var_address); } else { address[x - 1] = '\0'; @@ -695,7 +697,6 @@ static IPOnlyCIDRItem *IPOnlyCIDRListParse2(const DetectEngineCtx *de_ctx, if (rule_var_address == NULL) goto error; - temp_rule_var_address = rule_var_address; if ((negate + n_set) % 2) { temp_rule_var_address = SCMalloc(strlen(rule_var_address) + 3); if (unlikely(temp_rule_var_address == NULL)) { @@ -703,6 +704,11 @@ static IPOnlyCIDRItem *IPOnlyCIDRListParse2(const DetectEngineCtx *de_ctx, } snprintf(temp_rule_var_address, strlen(rule_var_address) + 3, "[%s]", rule_var_address); + } else { + temp_rule_var_address = SCStrdup(rule_var_address); + if (unlikely(temp_rule_var_address == NULL)) { + goto error; + } } subhead = IPOnlyCIDRListParse2(de_ctx, temp_rule_var_address, (negate + n_set) % 2); @@ -710,8 +716,7 @@ static IPOnlyCIDRItem *IPOnlyCIDRListParse2(const DetectEngineCtx *de_ctx, d_set = 0; - if (temp_rule_var_address != rule_var_address) - SCFree(temp_rule_var_address); + SCFree(temp_rule_var_address); } else { subhead = IPOnlyCIDRItemNew(); if (subhead == NULL) @@ -1810,7 +1815,7 @@ static int IPOnlyTestSig05(void) p[0] = UTHBuildPacket((uint8_t *)buf, buflen, IPPROTO_TCP); - char *sigs[numsigs]; + const char *sigs[numsigs]; sigs[0]= "alert tcp 192.168.1.5 any -> any any (msg:\"Testing src ip (sid 1)\"; sid:1;)"; sigs[1]= "alert tcp any any -> 192.168.1.1 any (msg:\"Testing dst ip (sid 2)\"; sid:2;)"; sigs[2]= "alert tcp 192.168.1.5 any -> 192.168.1.1 any (msg:\"Testing src/dst ip (sid 3)\"; sid:3;)"; @@ -1847,7 +1852,7 @@ static int IPOnlyTestSig06(void) p[0] = UTHBuildPacketSrcDst((uint8_t *)buf, buflen, IPPROTO_TCP, "80.58.0.33", "195.235.113.3"); - char *sigs[numsigs]; + const char *sigs[numsigs]; sigs[0]= "alert tcp 192.168.1.5 any -> any any (msg:\"Testing src ip (sid 1)\"; sid:1;)"; sigs[1]= "alert tcp any any -> 192.168.1.1 any (msg:\"Testing dst ip (sid 2)\"; sid:2;)"; sigs[2]= "alert tcp 192.168.1.5 any -> 192.168.1.1 any (msg:\"Testing src/dst ip (sid 3)\"; sid:3;)"; @@ -1926,7 +1931,7 @@ static int IPOnlyTestSig08(void) p[0] = UTHBuildPacketSrcDst((uint8_t *)buf, buflen, IPPROTO_TCP,"192.168.1.1","192.168.1.5"); - char *sigs[numsigs]; + const char *sigs[numsigs]; sigs[0]= "alert tcp 192.168.1.5 any -> 192.168.0.0/16 any (msg:\"Testing src/dst ip (sid 1)\"; sid:1;)"; sigs[1]= "alert tcp [192.168.1.2,192.168.1.5,192.168.1.4] any -> 192.168.1.1 any (msg:\"Testing src/dst ip (sid 2)\"; sid:2;)"; sigs[2]= "alert tcp [192.168.1.0/24,!192.168.1.1] any -> 192.168.1.1 any (msg:\"Testing src/dst ip (sid 3)\"; sid:3;)"; @@ -1963,7 +1968,7 @@ static int IPOnlyTestSig09(void) p[0] = UTHBuildPacketIPV6SrcDst((uint8_t *)buf, buflen, IPPROTO_TCP, "3FFE:FFFF:7654:FEDA:1245:BA98:3210:4565", "3FFE:FFFF:7654:FEDA:1245:BA98:3210:4562"); - char *sigs[numsigs]; + const char *sigs[numsigs]; sigs[0]= "alert tcp 3FFE:FFFF:7654:FEDA:1245:BA98:3210:4565 any -> any any (msg:\"Testing src ip (sid 1)\"; sid:1;)"; sigs[1]= "alert tcp any any -> 3FFE:FFFF:7654:FEDA:1245:BA98:3210:4562 any (msg:\"Testing dst ip (sid 2)\"; sid:2;)"; sigs[2]= "alert tcp 3FFE:FFFF:7654:FEDA:1245:BA98:3210:4565 any -> 3FFE:FFFF:7654:FEDA:1245:BA98:3210:4562 any (msg:\"Testing src/dst ip (sid 3)\"; sid:3;)"; @@ -2000,7 +2005,7 @@ static int IPOnlyTestSig10(void) p[0] = UTHBuildPacketIPV6SrcDst((uint8_t *)buf, buflen, IPPROTO_TCP, "3FFE:FFFF:7654:FEDA:1245:BA98:3210:4562", "3FFE:FFFF:7654:FEDA:1245:BA98:3210:4565"); - char *sigs[numsigs]; + const char *sigs[numsigs]; sigs[0]= "alert tcp 3FFE:FFFF:7654:FEDA:1245:BA98:3210:4565 any -> any any (msg:\"Testing src ip (sid 1)\"; sid:1;)"; sigs[1]= "alert tcp any any -> 3FFE:FFFF:7654:FEDA:1245:BA98:3210:4562 any (msg:\"Testing dst ip (sid 2)\"; sid:2;)"; sigs[2]= "alert tcp 3FFE:FFFF:7654:FEDA:1245:BA98:3210:4565 any -> 3FFE:FFFF:7654:FEDA:1245:BA98:3210:4562 any (msg:\"Testing src/dst ip (sid 3)\"; sid:3;)"; @@ -2081,7 +2086,7 @@ static int IPOnlyTestSig12(void) p[0] = UTHBuildPacketIPV6SrcDst((uint8_t *)buf, buflen, IPPROTO_TCP,"3FBE:FFFF:7654:FEDA:1245:BA98:3210:4562","3FBE:FFFF:7654:FEDA:1245:BA98:3210:4565"); p[1] = UTHBuildPacketSrcDst((uint8_t *)buf, buflen, IPPROTO_TCP,"195.85.1.1","80.198.1.5"); - char *sigs[numsigs]; + const char *sigs[numsigs]; sigs[0]= "alert tcp 3FFE:FFFF:7654:FEDA:1245:BA98:3210:4565,192.168.1.1 any -> 3FFE:FFFF:7654:FEDA:0:0:0:0/64,192.168.1.5 any (msg:\"Testing src/dst ip (sid 1)\"; sid:1;)"; sigs[1]= "alert tcp [192.168.1.1,3FFE:FFFF:7654:FEDA:1245:BA98:3210:4565,192.168.1.4,192.168.1.5,!192.168.1.0/24] any -> [3FFE:FFFF:7654:FEDA:1245:BA98:3210:4562,192.168.1.0/24] any (msg:\"Testing src/dst ip (sid 2)\"; sid:2;)"; sigs[2]= "alert tcp [3FFE:FFFF:7654:FEDA:0:0:0:0/64,!3FFE:FFFF:7654:FEDA:1245:BA98:3210:4562,192.168.1.1] any -> [3FFE:FFFF:7654:FEDA:1245:BA98:3210:4562,192.168.1.5] any (msg:\"Testing src/dst ip (sid 3)\"; sid:3;)"; @@ -2158,7 +2163,7 @@ static int IPOnlyTestSig15(void) p[0]->flags |= PKT_HAS_FLOW; p[0]->flowflags |= FLOW_PKT_TOSERVER; - char *sigs[numsigs]; + const char *sigs[numsigs]; sigs[0]= "alert tcp 192.168.1.5 any -> any any (msg:\"Testing src ip (sid 1)\"; " "flowbits:set,one; sid:1;)"; sigs[1]= "alert tcp any any -> 192.168.1.1 any (msg:\"Testing dst ip (sid 2)\"; " @@ -2202,7 +2207,7 @@ static int IPOnlyTestSig16(void) p[0] = UTHBuildPacketSrcDst((uint8_t *)buf, buflen, IPPROTO_TCP, "100.100.0.0", "50.0.0.0"); - char *sigs[numsigs]; + const char *sigs[numsigs]; sigs[0]= "alert tcp !100.100.0.1 any -> any any (msg:\"Testing src ip (sid 1)\"; sid:1;)"; sigs[1]= "alert tcp any any -> !50.0.0.1 any (msg:\"Testing dst ip (sid 2)\"; sid:2;)"; @@ -2233,7 +2238,7 @@ static int IPOnlyTestSig17(void) p[0] = UTHBuildPacketSrcDst((uint8_t *)buf, buflen, IPPROTO_ICMP, "100.100.0.0", "50.0.0.0"); - char *sigs[numsigs]; + const char *sigs[numsigs]; sigs[0]= "alert ip 100.100.0.0 80 -> any any (msg:\"Testing src ip (sid 1)\"; sid:1;)"; sigs[1]= "alert ip any any -> 50.0.0.0 123 (msg:\"Testing dst ip (sid 2)\"; sid:2;)"; diff --git a/src/detect-engine-loader.c b/src/detect-engine-loader.c index 1c4ad0872b..390f858002 100644 --- a/src/detect-engine-loader.c +++ b/src/detect-engine-loader.c @@ -192,7 +192,7 @@ typedef struct DetectLoaderThreadData_ { uint32_t instance; } DetectLoaderThreadData; -static TmEcode DetectLoaderThreadInit(ThreadVars *t, void *initdata, void **data) +static TmEcode DetectLoaderThreadInit(ThreadVars *t, const void *initdata, void **data) { DetectLoaderThreadData *ftd = SCCalloc(1, sizeof(DetectLoaderThreadData)); if (ftd == NULL) @@ -263,7 +263,7 @@ static TmEcode DetectLoader(ThreadVars *th_v, void *thread_data) } /** \brief spawn the detect loader manager thread */ -void DetectLoaderThreadSpawn() +void DetectLoaderThreadSpawn(void) { int i; for (i = 0; i < num_loaders; i++) { diff --git a/src/detect-engine-loader.h b/src/detect-engine-loader.h index de28bdaf77..6b8aa5cf9e 100644 --- a/src/detect-engine-loader.h +++ b/src/detect-engine-loader.h @@ -50,8 +50,8 @@ int DetectLoaderQueueTask(int loader_id, LoaderFunc Func, void *func_ctx); int DetectLoadersSync(void); void DetectLoadersInit(void); -void TmThreadContinueDetectLoaderThreads(); -void DetectLoaderThreadSpawn(); +void TmThreadContinueDetectLoaderThreads(void); +void DetectLoaderThreadSpawn(void); void TmModuleDetectLoaderRegister (void); #endif /* __DETECT_ENGINE_LOADER_H__ */ diff --git a/src/detect-engine-mpm.c b/src/detect-engine-mpm.c index bd7dbc40f3..82f53dbbe2 100644 --- a/src/detect-engine-mpm.c +++ b/src/detect-engine-mpm.c @@ -349,7 +349,7 @@ int SignatureHasStreamContent(const Signature *s) */ uint16_t PatternMatchDefaultMatcher(void) { - char *mpm_algo; + const char *mpm_algo; uint16_t mpm_algo_val = mpm_default_matcher; /* Get the mpm algo defined in config file by the user */ @@ -862,7 +862,7 @@ void MpmStoreReportStats(const DetectEngineCtx *de_ctx) if (appstats[x] == 0) continue; const char *name = de_ctx->app_mpms[x].reg->name; - char *direction = de_ctx->app_mpms[x].reg->direction == SIG_FLAG_TOSERVER ? "toserver" : "toclient"; + const char *direction = de_ctx->app_mpms[x].reg->direction == SIG_FLAG_TOSERVER ? "toserver" : "toclient"; SCLogPerf("AppLayer MPM \"%s %s\": %u", direction, name, appstats[x]); } } @@ -884,7 +884,7 @@ void MpmStoreFree(DetectEngineCtx *de_ctx) return; } -void MpmStoreSetup(const DetectEngineCtx *de_ctx, MpmStore *ms) +static void MpmStoreSetup(const DetectEngineCtx *de_ctx, MpmStore *ms) { const Signature *s = NULL; uint32_t sig; diff --git a/src/detect-engine-mpm.h b/src/detect-engine-mpm.h index d3fee45229..91511689f0 100644 --- a/src/detect-engine-mpm.h +++ b/src/detect-engine-mpm.h @@ -57,8 +57,6 @@ void DetectEngineThreadCtxInfo(ThreadVars *, DetectEngineThreadCtx *); TmEcode DetectEngineThreadCtxInit(ThreadVars *, void *, void **); TmEcode DetectEngineThreadCtxDeinit(ThreadVars *, void *); -void DbgPrintSearchStats(); - int SignatureHasPacketContent(const Signature *); int SignatureHasStreamContent(const Signature *); diff --git a/src/detect-engine-payload.c b/src/detect-engine-payload.c index 22d860659e..83f3c27912 100644 --- a/src/detect-engine-payload.c +++ b/src/detect-engine-payload.c @@ -34,6 +34,7 @@ #include "detect-engine-content-inspection.h" #include "detect-engine-prefilter.h" #include "detect-engine-state.h" +#include "detect-engine-payload.h" #include "stream.h" #include "stream-tcp.h" @@ -150,7 +151,7 @@ int PrefilterPktPayloadRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx) * \retval 1 match */ int DetectEngineInspectPacketPayload(DetectEngineCtx *de_ctx, - DetectEngineThreadCtx *det_ctx, Signature *s, Flow *f, Packet *p) + DetectEngineThreadCtx *det_ctx, const Signature *s, Flow *f, Packet *p) { SCEnter(); int r = 0; diff --git a/src/detect-engine-port.c b/src/detect-engine-port.c index 661cb47686..db0ab8354f 100644 --- a/src/detect-engine-port.c +++ b/src/detect-engine-port.c @@ -56,7 +56,7 @@ static int DetectPortCutNot(DetectPort *, DetectPort **); static int DetectPortCut(DetectEngineCtx *, DetectPort *, DetectPort *, DetectPort **); -DetectPort *PortParse(char *str); +DetectPort *PortParse(const char *str); int DetectPortIsValidRange(char *); /** @@ -65,7 +65,7 @@ int DetectPortIsValidRange(char *); * \retval sgh Pointer to the newly created DetectPort on success; or NULL in * case of error. */ -DetectPort *DetectPortInit(void) +static DetectPort *DetectPortInit(void) { DetectPort *dp = SCMalloc(sizeof(DetectPort)); if (unlikely(dp == NULL)) @@ -94,28 +94,6 @@ void DetectPortFree(DetectPort *dp) SCFree(dp); } -/** - * \brief Used to see if the exact same portrange exists in the list - * - * \param head Pointer to the DetectPort list head - * \param dp DetectPort to search in the DetectPort list - * - * \retval returns a ptr to the match, or NULL if no match - */ -DetectPort *DetectPortLookup(DetectPort *head, DetectPort *dp) -{ - DetectPort *cur; - - if (head != NULL) { - for (cur = head; cur != NULL; cur = cur->next) { - if (DetectPortCmp(cur, dp) == PORT_EQ) - return cur; - } - } - - return NULL; -} - /** * \brief Helper function used to print the list of ports * present in this DetectPort list. @@ -158,50 +136,6 @@ void DetectPortCleanupList (DetectPort *head) } } -/** - * \brief Do a sorted insert, where the top of the list should be the biggest - * port range. - * - * \todo XXX current sorting only works for overlapping ranges - * - * \param head Pointer to the DetectPort list head - * \param dp Pointer to DetectPort to search in the DetectPort list - * \retval 0 if dp is added correctly - */ -int DetectPortAdd(DetectPort **head, DetectPort *dp) -{ - DetectPort *cur, *prev_cur = NULL; - - //SCLogDebug("DetectPortAdd: adding "); DetectPortPrint(ag); SCLogDebug(""); - - if (*head != NULL) { - for (cur = *head; cur != NULL; cur = cur->next) { - prev_cur = cur; - int r = DetectPortCmp(dp,cur); - if (r == PORT_EB) { - /* insert here */ - dp->prev = cur->prev; - dp->next = cur; - - cur->prev = dp; - if (*head == cur) { - *head = dp; - } else { - dp->prev->next = dp; - } - return 0; - } - } - dp->prev = prev_cur; - if (prev_cur != NULL) - prev_cur->next = dp; - } else { - *head = dp; - } - - return 0; -} - /** * \brief Copy and insert the new DetectPort, with a copy list of sigs * @@ -762,7 +696,7 @@ error: * \retval 1 if port is in the range (it match) * \retval 0 if port is not in the range * */ -int DetectPortMatch(DetectPort *dp, uint16_t port) +static int DetectPortMatch(DetectPort *dp, uint16_t port) { if (port >= dp->port && port <= dp->port2) { @@ -871,7 +805,7 @@ static int DetectPortParseInsert(DetectPort **head, DetectPort *new) * \retval 0 on success * \retval -1 on error */ -static int DetectPortParseInsertString(DetectPort **head, char *s) +static int DetectPortParseInsertString(DetectPort **head, const char *s) { DetectPort *ad = NULL, *ad_any = NULL; int r = 0; @@ -960,7 +894,8 @@ error: */ static int DetectPortParseDo(const DetectEngineCtx *de_ctx, DetectPort **head, DetectPort **nhead, - char *s, int negate, ResolvedVariablesList *var_list) + const char *s, int negate, + ResolvedVariablesList *var_list) { size_t u = 0; size_t x = 0; @@ -969,7 +904,7 @@ static int DetectPortParseDo(const DetectEngineCtx *de_ctx, int depth = 0; size_t size = strlen(s); char address[1024] = ""; - char *rule_var_port = NULL; + const char *rule_var_port = NULL; int r = 0; SCLogDebug("head %p, *head %p, negate %d", head, *head, negate); @@ -1028,15 +963,18 @@ static int DetectPortParseDo(const DetectEngineCtx *de_ctx, "\"!$HTTP_PORTS\" instead of !$HTTP_PORTS. See issue #295.", s); goto error; } - temp_rule_var_port = rule_var_port; if (negate == 1 || n_set == 1) { alloc_rule_var_port = SCMalloc(strlen(rule_var_port) + 3); if (unlikely(alloc_rule_var_port == NULL)) goto error; snprintf(alloc_rule_var_port, strlen(rule_var_port) + 3, "[%s]", rule_var_port); - temp_rule_var_port = alloc_rule_var_port; + } else { + alloc_rule_var_port = SCStrdup(rule_var_port); + if (unlikely(alloc_rule_var_port == NULL)) + goto error; } + temp_rule_var_port = alloc_rule_var_port; r = DetectPortParseDo(de_ctx, head, nhead, temp_rule_var_port, (negate + n_set) % 2, var_list);//negate? negate: n_set); if (r == -1) @@ -1044,8 +982,7 @@ static int DetectPortParseDo(const DetectEngineCtx *de_ctx, d_set = 0; n_set = 0; - if (alloc_rule_var_port != NULL) - SCFree(alloc_rule_var_port); + SCFree(alloc_rule_var_port); } else { address[x - 1] = '\0'; SCLogDebug("Parsed port from DetectPortParseDo - %s", address); @@ -1095,23 +1032,25 @@ static int DetectPortParseDo(const DetectEngineCtx *de_ctx, "\"!$HTTP_PORTS\" instead of !$HTTP_PORTS. See issue #295.", s); goto error; } - temp_rule_var_port = rule_var_port; if ((negate + n_set) % 2) { alloc_rule_var_port = SCMalloc(strlen(rule_var_port) + 3); if (unlikely(alloc_rule_var_port == NULL)) goto error; snprintf(alloc_rule_var_port, strlen(rule_var_port) + 3, "[%s]", rule_var_port); - temp_rule_var_port = alloc_rule_var_port; + } else { + alloc_rule_var_port = SCStrdup(rule_var_port); + if (unlikely(alloc_rule_var_port == NULL)) + goto error; } + temp_rule_var_port = alloc_rule_var_port; r = DetectPortParseDo(de_ctx, head, nhead, temp_rule_var_port, (negate + n_set) % 2, var_list); if (r == -1) goto error; d_set = 0; - if (alloc_rule_var_port != NULL) - SCFree(alloc_rule_var_port); + SCFree(alloc_rule_var_port); } else { if (!((negate + n_set) % 2)) { r = DetectPortParseInsertString(head,address); @@ -1149,7 +1088,7 @@ error: * \retval 0 no * \retval 1 yes */ -int DetectPortIsCompletePortSpace(DetectPort *p) +static int DetectPortIsCompletePortSpace(DetectPort *p) { uint16_t next_port = 0; @@ -1189,7 +1128,7 @@ int DetectPortIsCompletePortSpace(DetectPort *p) * \retval 0 on success * \retval -1 on error */ -int DetectPortParseMergeNotPorts(DetectPort **head, DetectPort **nhead) +static int DetectPortParseMergeNotPorts(DetectPort **head, DetectPort **nhead) { DetectPort *ad = NULL; DetectPort *ag, *ag2; @@ -1352,7 +1291,7 @@ int DetectPortTestConfVars(void) * \retval -1 on error */ int DetectPortParse(const DetectEngineCtx *de_ctx, - DetectPort **head, char *str) + DetectPort **head, const char *str) { int r; @@ -1388,7 +1327,7 @@ error: * \retval DetectPort pointer of the parse string on success * \retval NULL on error */ -DetectPort *PortParse(char *str) +DetectPort *PortParse(const char *str) { char *port2 = NULL; DetectPort *dp = NULL; @@ -1607,11 +1546,55 @@ void DetectPortHashFree(DetectEngineCtx *de_ctx) /*---------------------- Unittests -------------------------*/ #ifdef UNITTESTS +/** + * \brief Do a sorted insert, where the top of the list should be the biggest + * port range. + * + * \todo XXX current sorting only works for overlapping ranges + * + * \param head Pointer to the DetectPort list head + * \param dp Pointer to DetectPort to search in the DetectPort list + * \retval 0 if dp is added correctly + */ +static int PortTestDetectPortAdd(DetectPort **head, DetectPort *dp) +{ + DetectPort *cur, *prev_cur = NULL; + + //SCLogDebug("DetectPortAdd: adding "); DetectPortPrint(ag); SCLogDebug(""); + + if (*head != NULL) { + for (cur = *head; cur != NULL; cur = cur->next) { + prev_cur = cur; + int r = DetectPortCmp(dp,cur); + if (r == PORT_EB) { + /* insert here */ + dp->prev = cur->prev; + dp->next = cur; + + cur->prev = dp; + if (*head == cur) { + *head = dp; + } else { + dp->prev->next = dp; + } + return 0; + } + } + dp->prev = prev_cur; + if (prev_cur != NULL) + prev_cur->next = dp; + } else { + *head = dp; + } + + return 0; +} + /** * \test Check if a DetectPort is properly allocated */ -int PortTestParse01 (void) +static int PortTestParse01 (void) { DetectPort *dd = NULL; @@ -1627,7 +1610,7 @@ int PortTestParse01 (void) /** * \test Check if two ports are properly allocated in the DetectPort group */ -int PortTestParse02 (void) +static int PortTestParse02 (void) { DetectPort *dd = NULL; int result = 0; @@ -1649,7 +1632,7 @@ int PortTestParse02 (void) /** * \test Check if two port ranges are properly allocated in the DetectPort group */ -int PortTestParse03 (void) +static int PortTestParse03 (void) { DetectPort *dd = NULL; int result = 0; @@ -1672,7 +1655,7 @@ int PortTestParse03 (void) /** * \test Check if a negated port range is properly allocated in the DetectPort */ -int PortTestParse04 (void) +static int PortTestParse04 (void) { DetectPort *dd = NULL; @@ -1689,7 +1672,7 @@ int PortTestParse04 (void) * \test Check if a negated port range is properly fragmented in the allowed * real groups, ex !80:81 should allow 0:79 and 82:65535 */ -int PortTestParse05 (void) +static int PortTestParse05 (void) { DetectPort *dd = NULL; int result = 0; @@ -1716,7 +1699,7 @@ end: /** * \test Check if we copy a DetectPort correctly */ -int PortTestParse06 (void) +static int PortTestParse06 (void) { DetectPort *dd = NULL, *copy = NULL; int result = 0; @@ -1770,7 +1753,7 @@ end: * \test Check if a negated port range is properly fragmented in the allowed * real groups */ -int PortTestParse07 (void) +static int PortTestParse07 (void) { DetectPort *dd = NULL; int result = 0; @@ -1797,7 +1780,7 @@ end: /** * \test Check if we dont allow invalid port range specification */ -int PortTestParse08 (void) +static int PortTestParse08 (void) { DetectPort *dd = NULL; int result = 0; @@ -1815,7 +1798,7 @@ end: /** * \test Check if we autocomplete correctly an open range */ -int PortTestParse09 (void) +static int PortTestParse09 (void) { DetectPort *dd = NULL; int result = 0; @@ -1839,7 +1822,7 @@ end: /** * \test Test we don't allow a port that is too big */ -int PortTestParse10 (void) +static int PortTestParse10 (void) { DetectPort *dd = NULL; int result = 0; @@ -1859,7 +1842,7 @@ end: /** * \test Test second port of range being too big */ -int PortTestParse11 (void) +static int PortTestParse11 (void) { DetectPort *dd = NULL; int result = 0; @@ -1879,7 +1862,7 @@ end: /** * \test Test second port of range being just right */ -int PortTestParse12 (void) +static int PortTestParse12 (void) { DetectPort *dd = NULL; int result = 0; @@ -1899,7 +1882,7 @@ end: /** * \test Test first port of range being too big */ -int PortTestParse13 (void) +static int PortTestParse13 (void) { DetectPort *dd = NULL; int result = 0; @@ -1919,7 +1902,7 @@ end: /** * \test Test merging port groups */ -int PortTestParse14 (void) +static int PortTestParse14 (void) { DetectPort *dd = NULL; int result = 0; @@ -1946,7 +1929,7 @@ end: /** * \test Test merging negated port groups */ -int PortTestParse15 (void) +static int PortTestParse15 (void) { DetectPort *dd = NULL; int result = 0; @@ -1970,7 +1953,7 @@ end: /** * \test Test parse, copy and cmp functions */ -int PortTestParse16 (void) +static int PortTestParse16 (void) { DetectPort *dd = NULL, *copy = NULL; int result = 0; @@ -2025,7 +2008,7 @@ end: /** * \test Test general functions */ -int PortTestFunctions01(void) +static int PortTestFunctions01(void) { DetectPort *head = NULL; DetectPort *dp1= NULL; @@ -2053,7 +2036,7 @@ int PortTestFunctions01(void) goto end; /* Add */ - r = DetectPortAdd(&head, dp1); + r = PortTestDetectPortAdd(&head, dp1); if (r != 0 || head->next == NULL) goto end; if (!(head->port == 101)) @@ -2087,7 +2070,7 @@ end: /** * \test Test general functions */ -int PortTestFunctions02(void) +static int PortTestFunctions02(void) { DetectPort *head = NULL; DetectPort *dp1= NULL; @@ -2137,7 +2120,7 @@ end: /** * \test Test general functions */ -int PortTestFunctions03(void) +static int PortTestFunctions03(void) { DetectPort *dp1= NULL; DetectPort *dp2= NULL; @@ -2203,7 +2186,7 @@ end: /** * \test Test general functions */ -int PortTestFunctions04(void) +static int PortTestFunctions04(void) { DetectPort *dp1= NULL; DetectPort *dp2= NULL; @@ -2431,7 +2414,7 @@ static int PortTestFunctions07(void) * \retval return 1 if match * \retval return 0 if not */ -int PortTestMatchReal(uint8_t *raw_eth_pkt, uint16_t pktsize, char *sig, +static int PortTestMatchReal(uint8_t *raw_eth_pkt, uint16_t pktsize, const char *sig, uint32_t sid) { int result = 0; @@ -2446,7 +2429,7 @@ int PortTestMatchReal(uint8_t *raw_eth_pkt, uint16_t pktsize, char *sig, /** * \brief Wrapper for PortTestMatchReal */ -int PortTestMatchRealWrp(char *sig, uint32_t sid) +static int PortTestMatchRealWrp(const char *sig, uint32_t sid) { /* Real HTTP packeth doing a GET method * tcp.sport=47370 tcp.dport=80 @@ -2517,19 +2500,19 @@ int PortTestMatchRealWrp(char *sig, uint32_t sid) /** * \test Check if we match a dest port */ -int PortTestMatchReal01() +static int PortTestMatchReal01(void) { /* tcp.sport=47370 tcp.dport=80 */ - char *sig = "alert tcp any any -> any 80 (msg:\"Nothing..\"; content:\"GET\"; sid:1;)"; + const char *sig = "alert tcp any any -> any 80 (msg:\"Nothing..\"; content:\"GET\"; sid:1;)"; return PortTestMatchRealWrp(sig, 1); } /** * \test Check if we match a source port */ -int PortTestMatchReal02() +static int PortTestMatchReal02(void) { - char *sig = "alert tcp any 47370 -> any any (msg:\"Nothing..\";" + const char *sig = "alert tcp any 47370 -> any any (msg:\"Nothing..\";" " content:\"GET\"; sid:1;)"; return PortTestMatchRealWrp(sig, 1); } @@ -2537,9 +2520,9 @@ int PortTestMatchReal02() /** * \test Check if we match both of them */ -int PortTestMatchReal03() +static int PortTestMatchReal03(void) { - char *sig = "alert tcp any 47370 -> any 80 (msg:\"Nothing..\";" + const char *sig = "alert tcp any 47370 -> any 80 (msg:\"Nothing..\";" " content:\"GET\"; sid:1;)"; return PortTestMatchRealWrp(sig, 1); } @@ -2547,9 +2530,9 @@ int PortTestMatchReal03() /** * \test Check if we negate dest ports correctly */ -int PortTestMatchReal04() +static int PortTestMatchReal04(void) { - char *sig = "alert tcp any any -> any !80 (msg:\"Nothing..\";" + const char *sig = "alert tcp any any -> any !80 (msg:\"Nothing..\";" " content:\"GET\"; sid:1;)"; return (PortTestMatchRealWrp(sig, 1) == 0)? 1 : 0; } @@ -2557,9 +2540,9 @@ int PortTestMatchReal04() /** * \test Check if we negate source ports correctly */ -int PortTestMatchReal05() +static int PortTestMatchReal05(void) { - char *sig = "alert tcp any !47370 -> any any (msg:\"Nothing..\";" + const char *sig = "alert tcp any !47370 -> any any (msg:\"Nothing..\";" " content:\"GET\"; sid:1;)"; return (PortTestMatchRealWrp(sig, 1) == 0)? 1 : 0; } @@ -2567,9 +2550,9 @@ int PortTestMatchReal05() /** * \test Check if we negate both ports correctly */ -int PortTestMatchReal06() +static int PortTestMatchReal06(void) { - char *sig = "alert tcp any !47370 -> any !80 (msg:\"Nothing..\";" + const char *sig = "alert tcp any !47370 -> any !80 (msg:\"Nothing..\";" " content:\"GET\"; sid:1;)"; return (PortTestMatchRealWrp(sig, 1) == 0)? 1 : 0; } @@ -2577,9 +2560,9 @@ int PortTestMatchReal06() /** * \test Check if we match a dest port range */ -int PortTestMatchReal07() +static int PortTestMatchReal07(void) { - char *sig = "alert tcp any any -> any 70:100 (msg:\"Nothing..\";" + const char *sig = "alert tcp any any -> any 70:100 (msg:\"Nothing..\";" " content:\"GET\"; sid:1;)"; return PortTestMatchRealWrp(sig, 1); } @@ -2587,9 +2570,9 @@ int PortTestMatchReal07() /** * \test Check if we match a source port range */ -int PortTestMatchReal08() +static int PortTestMatchReal08(void) { - char *sig = "alert tcp any 47000:50000 -> any any (msg:\"Nothing..\";" + const char *sig = "alert tcp any 47000:50000 -> any any (msg:\"Nothing..\";" " content:\"GET\"; sid:1;)"; return PortTestMatchRealWrp(sig, 1); } @@ -2597,9 +2580,9 @@ int PortTestMatchReal08() /** * \test Check if we match both port ranges */ -int PortTestMatchReal09() +static int PortTestMatchReal09(void) { - char *sig = "alert tcp any 47000:50000 -> any 70:100 (msg:\"Nothing..\";" + const char *sig = "alert tcp any 47000:50000 -> any 70:100 (msg:\"Nothing..\";" " content:\"GET\"; sid:1;)"; return PortTestMatchRealWrp(sig, 1); } @@ -2607,9 +2590,9 @@ int PortTestMatchReal09() /** * \test Check if we negate a dest port range */ -int PortTestMatchReal10() +static int PortTestMatchReal10(void) { - char *sig = "alert tcp any any -> any !70:100 (msg:\"Nothing..\";" + const char *sig = "alert tcp any any -> any !70:100 (msg:\"Nothing..\";" " content:\"GET\"; sid:1;)"; return (PortTestMatchRealWrp(sig, 1) == 0)? 1 : 0; } @@ -2617,9 +2600,9 @@ int PortTestMatchReal10() /** * \test Check if we negate a source port range */ -int PortTestMatchReal11() +static int PortTestMatchReal11(void) { - char *sig = "alert tcp any !47000:50000 -> any any (msg:\"Nothing..\";" + const char *sig = "alert tcp any !47000:50000 -> any any (msg:\"Nothing..\";" " content:\"GET\"; sid:1;)"; return (PortTestMatchRealWrp(sig, 1) == 0)? 1 : 0; } @@ -2627,9 +2610,9 @@ int PortTestMatchReal11() /** * \test Check if we negate both port ranges */ -int PortTestMatchReal12() +static int PortTestMatchReal12(void) { - char *sig = "alert tcp any !47000:50000 -> any !70:100 (msg:\"Nothing..\";" + const char *sig = "alert tcp any !47000:50000 -> any !70:100 (msg:\"Nothing..\";" " content:\"GET\"; sid:1;)"; return (PortTestMatchRealWrp(sig, 1) == 0)? 1 : 0; } @@ -2637,9 +2620,9 @@ int PortTestMatchReal12() /** * \test Check if we autocomplete ranges correctly */ -int PortTestMatchReal13() +static int PortTestMatchReal13(void) { - char *sig = "alert tcp any 47000:50000 -> any !81: (msg:\"Nothing..\";" + const char *sig = "alert tcp any 47000:50000 -> any !81: (msg:\"Nothing..\";" " content:\"GET\"; sid:1;)"; return PortTestMatchRealWrp(sig, 1); } @@ -2647,9 +2630,9 @@ int PortTestMatchReal13() /** * \test Check if we autocomplete ranges correctly */ -int PortTestMatchReal14() +static int PortTestMatchReal14(void) { - char *sig = "alert tcp any !48000:50000 -> any :100 (msg:\"Nothing..\";" + const char *sig = "alert tcp any !48000:50000 -> any :100 (msg:\"Nothing..\";" " content:\"GET\"; sid:1;)"; return PortTestMatchRealWrp(sig, 1); } @@ -2657,9 +2640,9 @@ int PortTestMatchReal14() /** * \test Check if we autocomplete ranges correctly */ -int PortTestMatchReal15() +static int PortTestMatchReal15(void) { - char *sig = "alert tcp any :50000 -> any 81:100 (msg:\"Nothing..\";" + const char *sig = "alert tcp any :50000 -> any 81:100 (msg:\"Nothing..\";" " content:\"GET\"; sid:1;)"; return (PortTestMatchRealWrp(sig, 1) == 0)? 1 : 0; } @@ -2667,9 +2650,9 @@ int PortTestMatchReal15() /** * \test Check if we separate ranges correctly */ -int PortTestMatchReal16() +static int PortTestMatchReal16(void) { - char *sig = "alert tcp any 100: -> any ![0:79,81:65535] (msg:\"Nothing..\";" + const char *sig = "alert tcp any 100: -> any ![0:79,81:65535] (msg:\"Nothing..\";" " content:\"GET\"; sid:1;)"; return PortTestMatchRealWrp(sig, 1); } @@ -2677,9 +2660,9 @@ int PortTestMatchReal16() /** * \test Check if we separate ranges correctly */ -int PortTestMatchReal17() +static int PortTestMatchReal17(void) { - char *sig = "alert tcp any ![0:39999,48000:50000] -> any ![0:80,82:65535] " + const char *sig = "alert tcp any ![0:39999,48000:50000] -> any ![0:80,82:65535] " "(msg:\"Nothing..\"; content:\"GET\"; sid:1;)"; return (PortTestMatchRealWrp(sig, 1) == 0)? 1 : 0; } @@ -2687,9 +2670,9 @@ int PortTestMatchReal17() /** * \test Check if we separate ranges correctly */ -int PortTestMatchReal18() +static int PortTestMatchReal18(void) { - char *sig = "alert tcp any ![0:39999,48000:50000] -> any 80 (msg:\"Nothing" + const char *sig = "alert tcp any ![0:39999,48000:50000] -> any 80 (msg:\"Nothing" " at all\"; content:\"GET\"; sid:1;)"; return PortTestMatchRealWrp(sig, 1); } @@ -2697,9 +2680,9 @@ int PortTestMatchReal18() /** * \test Check if we separate ranges correctly */ -int PortTestMatchReal19() +static int PortTestMatchReal19(void) { - char *sig = "alert tcp any any -> any 80 (msg:\"Nothing..\";" + const char *sig = "alert tcp any any -> any 80 (msg:\"Nothing..\";" " content:\"GET\"; sid:1;)"; return PortTestMatchRealWrp(sig, 1); } diff --git a/src/detect-engine-port.h b/src/detect-engine-port.h index 924f710ce8..ed0b950c7a 100644 --- a/src/detect-engine-port.h +++ b/src/detect-engine-port.h @@ -25,7 +25,7 @@ #define __DETECT_PORT_H__ /* prototypes */ -int DetectPortParse(const DetectEngineCtx *, DetectPort **head, char *str); +int DetectPortParse(const DetectEngineCtx *, DetectPort **head, const char *str); DetectPort *DetectPortCopy(DetectEngineCtx *, DetectPort *); DetectPort *DetectPortCopySingle(DetectEngineCtx *, DetectPort *); diff --git a/src/detect-engine-prefilter.c b/src/detect-engine-prefilter.c index ed6ce40054..d8c9fa3129 100644 --- a/src/detect-engine-prefilter.c +++ b/src/detect-engine-prefilter.c @@ -587,6 +587,7 @@ static const PrefilterStore *PrefilterStoreGetStore(const uint32_t id) return store; } +#ifdef PROFILING /** \warning slow */ const char *PrefilterStoreGetName(const uint32_t id) { @@ -605,3 +606,4 @@ const char *PrefilterStoreGetName(const uint32_t id) SCMutexUnlock(&g_prefilter_mutex); return name; } +#endif diff --git a/src/detect-engine-profile.c b/src/detect-engine-profile.c index 971c222ad6..90a9102ce2 100644 --- a/src/detect-engine-profile.c +++ b/src/detect-engine-profile.c @@ -30,6 +30,7 @@ #include "output-json.h" #include "util-buffer.h" #include "util-print.h" +#include "detect-engine-profile.h" #ifdef PROFILING #ifdef HAVE_LIBJANSSON diff --git a/src/detect-engine-proto.c b/src/detect-engine-proto.c index 0d2d4193ee..80a022372b 100644 --- a/src/detect-engine-proto.c +++ b/src/detect-engine-proto.c @@ -44,36 +44,6 @@ #include "util-unittest-helper.h" #include "util-debug.h" -/** - * \brief Function to initialize the protocol detection and - * allocate memory to the DetectProto structure. - * - * \retval DetectProto instance pointer if successful otherwise NULL - */ - -DetectProto *DetectProtoInit(void) -{ - DetectProto *dp = SCMalloc(sizeof(DetectProto)); - if (unlikely(dp == NULL)) - return NULL; - memset(dp,0,sizeof(DetectProto)); - - return dp; -} - -/** - * \brief Free a DetectProto object - * - * \param dp Pointer to the DetectProto instance to be freed - */ -void DetectProtoFree(DetectProto *dp) -{ - if (dp == NULL) - return; - - SCFree(dp); -} - /** * \brief Parses a protocol sent as a string. * @@ -83,7 +53,7 @@ void DetectProtoFree(DetectProto *dp) * * \retval >=0 If proto is detected, -1 otherwise. */ -int DetectProtoParse(DetectProto *dp, char *str) +int DetectProtoParse(DetectProto *dp, const char *str) { if (strcasecmp(str, "tcp") == 0) { dp->proto[IPPROTO_TCP / 8] |= 1 << (IPPROTO_TCP % 8); @@ -184,7 +154,7 @@ int DetectProtoContainsProto(const DetectProto *dp, int proto) * setup the signature with passed values. */ static int DetectProtoInitTest(DetectEngineCtx **de_ctx, Signature **sig, - DetectProto *dp, char *str) + DetectProto *dp, const char *str) { char fullstr[1024]; int result = 0; diff --git a/src/detect-engine-proto.h b/src/detect-engine-proto.h index 05f8f4bef5..4e4c031110 100644 --- a/src/detect-engine-proto.h +++ b/src/detect-engine-proto.h @@ -39,7 +39,7 @@ typedef struct DetectProto_ { } DetectProto; /* prototypes */ -int DetectProtoParse(DetectProto *dp, char *str); +int DetectProtoParse(DetectProto *dp, const char *str); int DetectProtoContainsProto(const DetectProto *, int); void DetectProtoTests(void); diff --git a/src/detect-engine-siggroup.c b/src/detect-engine-siggroup.c index 28996a5e91..93ca8fa86b 100644 --- a/src/detect-engine-siggroup.c +++ b/src/detect-engine-siggroup.c @@ -195,7 +195,7 @@ void SigGroupHeadFree(SigGroupHead *sgh) * * \retval hash The generated hash value. */ -uint32_t SigGroupHeadHashFunc(HashListTable *ht, void *data, uint16_t datalen) +static uint32_t SigGroupHeadHashFunc(HashListTable *ht, void *data, uint16_t datalen) { SigGroupHead *sgh = (SigGroupHead *)data; uint32_t hash = 0; @@ -223,7 +223,7 @@ uint32_t SigGroupHeadHashFunc(HashListTable *ht, void *data, uint16_t datalen) * \retval 1 If the 2 SigGroupHeads sent as args match. * \retval 0 If the 2 SigGroupHeads sent as args do not match. */ -char SigGroupHeadCompareFunc(void *data1, uint16_t len1, void *data2, +static char SigGroupHeadCompareFunc(void *data1, uint16_t len1, void *data2, uint16_t len2) { SigGroupHead *sgh1 = (SigGroupHead *)data1; diff --git a/src/detect-engine-sigorder.c b/src/detect-engine-sigorder.c index 737e493653..642df90f77 100644 --- a/src/detect-engine-sigorder.c +++ b/src/detect-engine-sigorder.c @@ -818,7 +818,7 @@ void SCSigSignatureOrderingModuleCleanup(DetectEngineCtx *de_ctx) /**********Unittests**********/ DetectEngineCtx *DetectEngineCtxInit(void); -Signature *SigInit(DetectEngineCtx *, char *); +Signature *SigInit(DetectEngineCtx *, const char *); void SigFree(Signature *); void DetectEngineCtxFree(DetectEngineCtx *); @@ -860,111 +860,66 @@ static int SCSigOrderingTest01(void) static int SCSigOrderingTest02(void) { - int result = 0; - Signature *prevsig = NULL, *sig = NULL; + Signature *sig = NULL; DetectEngineCtx *de_ctx = DetectEngineCtxInit(); - if (de_ctx == NULL) - goto end; + FAIL_IF(de_ctx == NULL); - sig = SigInit(de_ctx, "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:0; depth:4; pcre:\"/220[- ]/\"; rev:4; sid:1;)"); - if (sig == NULL) { - goto end; - } - prevsig = sig; - de_ctx->sig_list = sig; + sig = DetectEngineAppendSig(de_ctx, + "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:0; depth:4; pcre:\"/220[- ]/\"; rev:4; sid:1;)"); + FAIL_IF_NULL(sig); - sig = SigInit(de_ctx, "drop tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:0; depth:4; pcre:\"/220[- ]/\"; rev:4; sid:2;)"); - if (sig == NULL) { - goto end; - } - prevsig->next = sig; - prevsig = sig; - - sig = SigInit(de_ctx, "drop tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:10; depth:4; pcre:\"/220[- ]/\"; rev:4; sid:3;)"); - if (sig == NULL) { - goto end; - } - prevsig->next = sig; - prevsig = sig; + sig = DetectEngineAppendSig(de_ctx, + "drop tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:0; depth:4; pcre:\"/220[- ]/\"; rev:4; sid:2;)"); + FAIL_IF_NULL(sig); - sig = SigInit(de_ctx, "pass tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:0; depth:4; pcre:\"/220[- ]/\"; flowvar:http_host,\"www.oisf.net\"; rev:4; priority:1; sid:4;)"); - if (sig == NULL) { - goto end; - } - prevsig->next = sig; - prevsig = sig; + sig = DetectEngineAppendSig(de_ctx, + "drop tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:10; depth:4; pcre:\"/220[- ]/\"; rev:4; sid:3;)"); + FAIL_IF_NULL(sig); - sig = SigInit(de_ctx, "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:0; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:1; sid:5;)"); - if (sig == NULL) { - goto end; - } - prevsig->next = sig; - prevsig = sig; + sig = DetectEngineAppendSig(de_ctx, + "pass tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:0; depth:4; pcre:\"/220[- ]/\"; flowvar:http_host,\"www.oisf.net\"; rev:4; priority:1; sid:4;)"); + FAIL_IF_NULL(sig); - sig = SigInit(de_ctx, "pass tcp any !21:902 -> any any (msg:\"Testing sigordering\"; pcre:\"/^User-Agent: (?P.*)\\r\\n/m\"; content:\"220\"; offset:10; depth:4; rev:4; priority:3; sid:6;)"); - if (sig == NULL) { - goto end; - } - prevsig->next = sig; - prevsig = sig; + sig = DetectEngineAppendSig(de_ctx, + "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:0; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:1; sid:5;)"); + FAIL_IF_NULL(sig); - sig = SigInit(de_ctx, "pass tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:10; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:3; sid:7;)"); - if (sig == NULL) { - goto end; - } - prevsig->next = sig; - prevsig = sig; + sig = DetectEngineAppendSig(de_ctx, + "pass tcp any !21:902 -> any any (msg:\"Testing sigordering\"; pcre:\"/^User-Agent: (?P.*)\\r\\n/m\"; content:\"220\"; offset:10; depth:4; rev:4; priority:3; sid:6;)"); + FAIL_IF_NULL(sig); - sig = SigInit(de_ctx, "pass tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:10; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:2; sid:8;)"); - if (sig == NULL) { - goto end; - } - prevsig->next = sig; - prevsig = sig; + sig = DetectEngineAppendSig(de_ctx, + "pass tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:10; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:3; sid:7;)"); + FAIL_IF_NULL(sig); + sig = DetectEngineAppendSig(de_ctx, + "pass tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:10; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:2; sid:8;)"); + FAIL_IF_NULL(sig); - sig = SigInit(de_ctx, "drop tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:10; depth:4; pcre:\"/^User-Agent: (?P.*)\\r\\n/m\"; rev:4; priority:3; flowbits:set,TEST.one; flowbits:noalert; sid:9;)"); - if (sig == NULL) { - goto end; - } - prevsig->next = sig; - prevsig = sig; + sig = DetectEngineAppendSig(de_ctx, + "drop tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:10; depth:4; pcre:\"/^User-Agent: (?P.*)\\r\\n/m\"; rev:4; priority:3; flowbits:set,TEST.one; flowbits:noalert; sid:9;)"); + FAIL_IF_NULL(sig); - sig = SigInit(de_ctx, "pass tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:3; sid:10;)"); - if (sig == NULL) { - goto end; - } - prevsig->next = sig; - prevsig = sig; + sig = DetectEngineAppendSig(de_ctx, + "pass tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:3; sid:10;)"); + FAIL_IF_NULL(sig); - sig = SigInit(de_ctx, "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; sid:11;)"); - if (sig == NULL) { - goto end; - } - prevsig->next = sig; - prevsig = sig; + sig = DetectEngineAppendSig(de_ctx, + "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; sid:11;)"); + FAIL_IF_NULL(sig); - sig = SigInit(de_ctx, "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; sid:12;)"); - if (sig == NULL) { - goto end; - } - prevsig->next = sig; - prevsig = sig; + sig = DetectEngineAppendSig(de_ctx, + "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:11; depth:4; pcre:\"/220[- ]/\"; rev:4; sid:12;)"); + FAIL_IF_NULL(sig); - sig = SigInit(de_ctx, "drop tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:12; depth:4; pcre:\"/220[- ]/\"; rev:4; pktvar:http_host,\"www.oisf.net\"; priority:2; flowbits:isnotset,TEST.two; sid:13;)"); - if (sig == NULL) { - goto end; - } - prevsig->next = sig; - prevsig = sig; + sig = DetectEngineAppendSig(de_ctx, + "drop tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:12; depth:4; pcre:\"/220[- ]/\"; rev:4; pktvar:http_host,\"www.oisf.net\"; priority:2; flowbits:isnotset,TEST.two; sid:13;)"); + FAIL_IF_NULL(sig); - sig = SigInit(de_ctx, "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:12; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:2; flowbits:set,TEST.two; sid:14;)"); - if (sig == NULL) { - goto end; - } - prevsig->next = sig; - prevsig = sig; + sig = DetectEngineAppendSig(de_ctx, + "alert tcp any !21:902 -> any any (msg:\"Testing sigordering\"; content:\"220\"; offset:12; depth:4; pcre:\"/220[- ]/\"; rev:4; priority:2; flowbits:set,TEST.two; sid:14;)"); + FAIL_IF_NULL(sig); SCSigRegisterSignatureOrderingFunc(de_ctx, SCSigOrderByActionCompare); SCSigRegisterSignatureOrderingFunc(de_ctx, SCSigOrderByFlowbitsCompare); @@ -973,8 +928,6 @@ static int SCSigOrderingTest02(void) SCSigRegisterSignatureOrderingFunc(de_ctx, SCSigOrderByPriorityCompare); SCSigOrderSignatures(de_ctx); - result = 1; - sig = de_ctx->sig_list; #ifdef DEBUG @@ -987,43 +940,41 @@ static int SCSigOrderingTest02(void) sig = de_ctx->sig_list; /* pass */ - result &= (sig->id == 6); + FAIL_IF_NOT(sig->id == 6); sig = sig->next; - result &= (sig->id == 4); + FAIL_IF_NOT(sig->id == 4); sig = sig->next; - result &= (sig->id == 8); + FAIL_IF_NOT(sig->id == 8); sig = sig->next; - result &= (sig->id == 7); + FAIL_IF_NOT(sig->id == 7); sig = sig->next; - result &= (sig->id == 10); + FAIL_IF_NOT(sig->id == 10); sig = sig->next; /* drops */ - result &= (sig->id == 9); + FAIL_IF_NOT(sig->id == 9); sig = sig->next; - result &= (sig->id == 13); + FAIL_IF_NOT(sig->id == 13); sig = sig->next; - result &= (sig->id == 2); + FAIL_IF_NOT(sig->id == 2); sig = sig->next; - result &= (sig->id == 3); + FAIL_IF_NOT(sig->id == 3); sig = sig->next; /* alerts */ - result &= (sig->id == 14); + FAIL_IF_NOT(sig->id == 14); sig = sig->next; - result &= (sig->id == 5); + FAIL_IF_NOT(sig->id == 5); sig = sig->next; - result &= (sig->id == 1); + FAIL_IF_NOT(sig->id == 1); sig = sig->next; - result &= (sig->id == 11); + FAIL_IF_NOT(sig->id == 11); sig = sig->next; - result &= (sig->id == 12); + FAIL_IF_NOT(sig->id == 12); sig = sig->next; -end: - if (de_ctx != NULL) - DetectEngineCtxFree(de_ctx); - return result; + DetectEngineCtxFree(de_ctx); + PASS; } static int SCSigOrderingTest03(void) @@ -2095,7 +2046,7 @@ static int SCSigOrderingTest12(void) goto end; de_ctx->flags |= DE_QUIET; - char *sigs[2]; + const char *sigs[2]; sigs[0] = "alert tcp any any -> any any (content:\"test\"; dsize:>0; flowbits:isset,one; flowbits:set,two; sid:1;)"; sigs[1] = "alert tcp any any -> any any (content:\"test\"; dsize:>0; flowbits:set,one; sid:2;)"; UTHAppendSigs(de_ctx, sigs, 2); diff --git a/src/detect-engine-tag.c b/src/detect-engine-tag.c index 3716d982e1..df96473573 100644 --- a/src/detect-engine-tag.c +++ b/src/detect-engine-tag.c @@ -375,7 +375,7 @@ static void TagHandlePacketFlow(Flow *f, Packet *p) } } -void TagHandlePacketHost(Host *host, Packet *p) +static void TagHandlePacketHost(Host *host, Packet *p) { DetectTagDataEntry *tde = NULL; DetectTagDataEntry *prev = NULL; @@ -591,7 +591,7 @@ int TagTimeoutCheck(Host *host, struct timeval *tv) /** * \test host tagging: packets */ -int DetectTagTestPacket01 (void) +static int DetectTagTestPacket01 (void) { int result = 0; uint8_t *buf = (uint8_t *)"Hi all!"; @@ -622,7 +622,7 @@ int DetectTagTestPacket01 (void) "192.168.1.5", "192.168.1.11", 41424, 80); - char *sigs[5]; + const char *sigs[5]; sigs[0]= "alert tcp any any -> any any (msg:\"Testing tag 1\"; content:\"Hi all\"; tag:host,3,packets,src; sid:1;)"; sigs[1]= "alert tcp any any -> any any (msg:\"Testing tag 2\"; content:\"Hi all\"; tag:host,4,packets,dst; sid:2;)"; sigs[2]= "alert tcp any any -> any any (msg:\"Testing tag 2\"; content:\"no match\"; sid:3;)"; @@ -688,7 +688,7 @@ int DetectTagTestPacket01 (void) /** * \test host tagging: seconds */ -int DetectTagTestPacket02 (void) +static int DetectTagTestPacket02 (void) { int result = 0; uint8_t *buf = (uint8_t *)"Hi all!"; @@ -736,7 +736,7 @@ int DetectTagTestPacket02 (void) "192.168.1.5", "192.168.1.11", 41424, 80); - char *sigs[5]; + const char *sigs[5]; sigs[0]= "alert tcp any any -> any any (msg:\"Testing tag 1\"; content:\"Hi all\"; tag:host,3,seconds,src; sid:1;)"; sigs[1]= "alert tcp any any -> any any (msg:\"Testing tag 2\"; content:\"Hi all\"; tag:host,8,seconds,dst; sid:2;)"; sigs[2]= "alert tcp any any -> any any (msg:\"Testing tag 2\"; content:\"no match\"; sid:3;)"; @@ -857,7 +857,7 @@ static int DetectTagTestPacket03 (void) "192.168.1.5", "192.168.1.11", 41424, 80); - char *sigs[5]; + const char *sigs[5]; sigs[0]= "alert tcp any any -> any any (msg:\"Testing tag 1\"; content:\"Hi all\"; tag:host, 150, bytes, src; sid:1;)"; sigs[1]= "alert tcp any any -> any any (msg:\"Testing tag 2\"; content:\"Hi all\"; tag:host, 150, bytes, dst; sid:2;)"; sigs[2]= "alert tcp any any -> any any (msg:\"Testing tag 2\"; content:\"no match\"; sid:3;)"; @@ -991,7 +991,7 @@ static int DetectTagTestPacket04 (void) "192.168.1.5", "192.168.1.1", 80, 41424); - char *sigs[5]; + const char *sigs[5]; sigs[0]= "alert tcp any any -> any any (msg:\"Testing tag 1\"; content:\"Hi all\"; tag:session,4,packets; sid:1;)"; sigs[1]= "alert tcp any any -> any any (msg:\"Testing tag 2\"; content:\"blahblah\"; sid:2;)"; sigs[2]= "alert tcp any any -> any any (msg:\"Testing tag 2\"; content:\"no match\"; sid:3;)"; @@ -1132,7 +1132,7 @@ static int DetectTagTestPacket05 (void) "192.168.1.5", "192.168.1.1", 80, 41424); - char *sigs[5]; + const char *sigs[5]; sigs[0]= "alert tcp any any -> any any (msg:\"Testing tag 1\"; content:\"Hi all\"; tag:session,8,seconds; sid:1;)"; sigs[1]= "alert tcp any any -> any any (msg:\"Testing tag 2\"; content:\"blahblah\"; sid:2;)"; sigs[2]= "alert tcp any any -> any any (msg:\"Testing tag 2\"; content:\"no match\"; sid:3;)"; @@ -1278,7 +1278,7 @@ static int DetectTagTestPacket06 (void) "192.168.1.5", "192.168.1.1", 80, 41424); - char *sigs[5]; + const char *sigs[5]; sigs[0]= "alert tcp any any -> any any (msg:\"Testing tag 1\"; content:\"Hi all\"; tag:session,150,bytes; sid:1;)"; sigs[1]= "alert tcp any any -> any any (msg:\"Testing tag 2\"; content:\"blahblah\"; sid:2;)"; sigs[2]= "alert tcp any any -> any any (msg:\"Testing tag 2\"; content:\"no match\"; sid:3;)"; @@ -1420,7 +1420,7 @@ static int DetectTagTestPacket07 (void) "192.168.1.5", "192.168.1.1", 80, 41424); - char *sigs[5]; + const char *sigs[5]; sigs[0]= "alert tcp any any -> any any (msg:\"Testing tag 1\"; content:\"Hi all\"; tag:session,150,bytes; sid:1;)"; sigs[1]= "alert tcp any any -> any any (msg:\"Testing tag 2\"; content:\"blahblah\"; sid:2;)"; sigs[2]= "alert tcp any any -> any any (msg:\"Testing tag 2\"; content:\"no match\"; sid:3;)"; diff --git a/src/detect-engine-template.c b/src/detect-engine-template.c index c7d751a151..c5a712c66a 100644 --- a/src/detect-engine-template.c +++ b/src/detect-engine-template.c @@ -33,12 +33,12 @@ #include "suricata-common.h" #include "stream.h" #include "detect-engine-content-inspection.h" - +#include "detect-engine-template.h" #include "app-layer-template.h" int DetectEngineInspectTemplateBuffer(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, - Signature *s, const SigMatchData *smd, + const Signature *s, const SigMatchData *smd, Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id) { TemplateTransaction *tx = (TemplateTransaction *)txv; diff --git a/src/detect-engine-threshold.c b/src/detect-engine-threshold.c index 27e84d8e90..e639332bb1 100644 --- a/src/detect-engine-threshold.c +++ b/src/detect-engine-threshold.c @@ -221,7 +221,7 @@ static DetectThresholdEntry *ThresholdHostLookupEntry(Host *h, uint32_t sid, uin return e; } -int ThresholdHandlePacketSuppress(Packet *p, const DetectThresholdData *td, uint32_t sid, uint32_t gid) +static int ThresholdHandlePacketSuppress(Packet *p, const DetectThresholdData *td, uint32_t sid, uint32_t gid) { int ret = 0; DetectAddress *m = NULL; @@ -286,7 +286,7 @@ static inline void RateFilterSetAction(Packet *p, PacketAlert *pa, uint8_t new_a * \retval 1 normal match * \retval 0 no match */ -int ThresholdHandlePacketHost(Host *h, Packet *p, const DetectThresholdData *td, +static int ThresholdHandlePacketHost(Host *h, Packet *p, const DetectThresholdData *td, uint32_t sid, uint32_t gid, PacketAlert *pa) { int ret = 0; diff --git a/src/detect-engine-tls.c b/src/detect-engine-tls.c index 4912da776c..b90c803ccc 100644 --- a/src/detect-engine-tls.c +++ b/src/detect-engine-tls.c @@ -41,6 +41,7 @@ #include "app-layer-parser.h" #include "app-layer-protos.h" #include "app-layer-ssl.h" +#include "detect-engine-tls.h" #include "util-unittest.h" #include "util-unittest-helper.h" @@ -174,7 +175,7 @@ int PrefilterTxTlsIssuerRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx) */ int DetectEngineInspectTlsIssuer(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, - Signature *s, const SigMatchData *smd, + const Signature *s, const SigMatchData *smd, Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id) { uint8_t *buffer; @@ -249,7 +250,7 @@ int PrefilterTxTlsSubjectRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx) */ int DetectEngineInspectTlsSubject(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, - Signature *s, const SigMatchData *smd, + const Signature *s, const SigMatchData *smd, Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id) { uint8_t *buffer; @@ -323,7 +324,7 @@ int PrefilterTxTlsSerialRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx) * \retval 1 Match */ int DetectEngineInspectTlsSerial(ThreadVars *tv, DetectEngineCtx *de_ctx, - DetectEngineThreadCtx *det_ctx, Signature *s, + DetectEngineThreadCtx *det_ctx, const Signature *s, const SigMatchData *smd, Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id) @@ -349,7 +350,7 @@ int DetectEngineInspectTlsSerial(ThreadVars *tv, DetectEngineCtx *de_ctx, int DetectEngineInspectTlsValidity(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, - Signature *s, const SigMatchData *smd, + const Signature *s, const SigMatchData *smd, Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id) { diff --git a/src/detect-engine-uri.c b/src/detect-engine-uri.c index b09333c284..154296ad8e 100644 --- a/src/detect-engine-uri.c +++ b/src/detect-engine-uri.c @@ -33,6 +33,7 @@ #include "detect-engine-state.h" #include "detect-engine-content-inspection.h" #include "detect-engine-prefilter.h" +#include "detect-engine-uri.h" #include "flow-util.h" #include "util-debug.h" @@ -106,7 +107,7 @@ int PrefilterTxUriRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx) */ int DetectEngineInspectHttpUri(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, - Signature *s, const SigMatchData *smd, + const Signature *s, const SigMatchData *smd, Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id) { HtpTxUserData *tx_ud = htp_tx_get_user_data(txv); diff --git a/src/detect-engine.c b/src/detect-engine.c index 973db79b84..f84bba21e0 100644 --- a/src/detect-engine.c +++ b/src/detect-engine.c @@ -408,7 +408,7 @@ static void DetectBufferTypeFreeFunc(void *data) } } -int DetectBufferTypeInit(void) +static int DetectBufferTypeInit(void) { BUG_ON(g_buffer_type_hash); g_buffer_type_hash = HashListTableInit(256, @@ -420,8 +420,8 @@ int DetectBufferTypeInit(void) return 0; } - -void DetectBufferTypeFree(void) +#if 0 +static void DetectBufferTypeFree(void) { if (g_buffer_type_hash == NULL) return; @@ -430,8 +430,8 @@ void DetectBufferTypeFree(void) g_buffer_type_hash = NULL; return; } - -int DetectBufferTypeAdd(const char *string) +#endif +static int DetectBufferTypeAdd(const char *string) { DetectBufferType *map = SCCalloc(1, sizeof(*map)); if (map == NULL) @@ -445,7 +445,7 @@ int DetectBufferTypeAdd(const char *string) return map->id; } -DetectBufferType *DetectBufferTypeLookupByName(const char *string) +static DetectBufferType *DetectBufferTypeLookupByName(const char *string) { DetectBufferType map = { (char *)string, NULL, 0, 0, 0, NULL, NULL }; @@ -507,7 +507,7 @@ const char *DetectBufferTypeGetNameById(const int id) return g_buffer_type_map[id]->string; } -const DetectBufferType *DetectBufferTypeGetById(const int id) +static const DetectBufferType *DetectBufferTypeGetById(const int id) { BUG_ON(id < 0 || id >= g_buffer_type_id); BUG_ON(g_buffer_type_map == NULL); @@ -1182,10 +1182,10 @@ void DetectEngineCtxFree(DetectEngineCtx *de_ctx) static int DetectEngineCtxLoadConf(DetectEngineCtx *de_ctx) { uint8_t profile = ENGINE_PROFILE_UNKNOWN; - char *max_uniq_toclient_groups_str = NULL; - char *max_uniq_toserver_groups_str = NULL; - char *sgh_mpm_context = NULL; - char *de_ctx_profile = NULL; + const char *max_uniq_toclient_groups_str = NULL; + const char *max_uniq_toserver_groups_str = NULL; + const char *sgh_mpm_context = NULL; + const char *de_ctx_profile = NULL; (void)ConfGet("detect.profile", &de_ctx_profile); (void)ConfGet("detect.sgh-mpm-context", &sgh_mpm_context); @@ -1405,7 +1405,7 @@ static int DetectEngineCtxLoadConf(DetectEngineCtx *de_ctx) /* parse port grouping whitelisting settings */ - char *ports = NULL; + const char *ports = NULL; (void)ConfGet("detect.grouping.tcp-whitelist", &ports); if (ports) { SCLogConfig("grouping: tcp-whitelist %s", ports); @@ -1453,7 +1453,7 @@ static int DetectEngineCtxLoadConf(DetectEngineCtx *de_ctx) } de_ctx->prefilter_setting = DETECT_PREFILTER_MPM; - char *pf_setting = NULL; + const char *pf_setting = NULL; if (ConfGet("detect.prefilter.default", &pf_setting) == 1 && pf_setting) { if (strcasecmp(pf_setting, "mpm") == 0) { de_ctx->prefilter_setting = DETECT_PREFILTER_MPM; @@ -1906,7 +1906,7 @@ static DetectEngineThreadCtx *DetectEngineThreadCtxInitForReload( return det_ctx; } -void DetectEngineThreadCtxFree(DetectEngineThreadCtx *det_ctx) +static void DetectEngineThreadCtxFree(DetectEngineThreadCtx *det_ctx) { #ifdef DEBUG SCLogInfo("PACKET PKT_STREAM_ADD: %"PRIu64, det_ctx->pkt_stream_add_cnt); @@ -2355,7 +2355,7 @@ static int DetectLoaderFuncLoadTenant(void *vctx, int loader_id) return 0; } -int DetectLoaderSetupLoadTenant(uint32_t tenant_id, const char *yaml) +static int DetectLoaderSetupLoadTenant(uint32_t tenant_id, const char *yaml) { TenantLoaderCtx *t = SCCalloc(1, sizeof(*t)); if (t == NULL) @@ -2379,7 +2379,7 @@ static int DetectLoaderFuncReloadTenant(void *vctx, int loader_id) return 0; } -int DetectLoaderSetupReloadTenant(uint32_t tenant_id, const char *yaml, int reload_cnt) +static int DetectLoaderSetupReloadTenant(uint32_t tenant_id, const char *yaml, int reload_cnt) { DetectEngineCtx *old_de_ctx = DetectEngineGetByTenantId(tenant_id); if (old_de_ctx == NULL) @@ -2456,7 +2456,7 @@ int DetectEngineMultiTenantSetup(void) SCMutexLock(&master->lock); master->multi_tenant_enabled = 1; - char *handler = NULL; + const char *handler = NULL; if (ConfGet("multi-detect.selector", &handler) == 1) { SCLogConfig("multi-tenant selector type %s", handler); @@ -3067,7 +3067,7 @@ const char *DetectSigmatchListEnumToString(enum DetectSigmatchListEnum type) #ifdef UNITTESTS -static int DetectEngineInitYamlConf(char *conf) +static int DetectEngineInitYamlConf(const char *conf) { ConfCreateContextBackup(); ConfInit(); @@ -3084,7 +3084,7 @@ static void DetectEngineDeInitYamlConf(void) static int DetectEngineTest01(void) { - char *conf = + const char *conf = "%YAML 1.1\n" "---\n" "detect-engine:\n" @@ -3122,7 +3122,7 @@ static int DetectEngineTest01(void) static int DetectEngineTest02(void) { - char *conf = + const char *conf = "%YAML 1.1\n" "---\n" "detect-engine:\n" @@ -3160,7 +3160,7 @@ static int DetectEngineTest02(void) static int DetectEngineTest03(void) { - char *conf = + const char *conf = "%YAML 1.1\n" "---\n" "detect-engine:\n" @@ -3198,7 +3198,7 @@ static int DetectEngineTest03(void) static int DetectEngineTest04(void) { - char *conf = + const char *conf = "%YAML 1.1\n" "---\n" "detect-engine:\n" @@ -3236,7 +3236,7 @@ static int DetectEngineTest04(void) static int DetectEngineTest08(void) { - char *conf = + const char *conf = "%YAML 1.1\n" "---\n" "detect-engine:\n" @@ -3270,7 +3270,7 @@ static int DetectEngineTest08(void) /** \test bug 892 bad values */ static int DetectEngineTest09(void) { - char *conf = + const char *conf = "%YAML 1.1\n" "---\n" "detect-engine:\n" @@ -3306,7 +3306,6 @@ static int DetectEngineTest09(void) void DetectEngineRegisterTests() { - #ifdef UNITTESTS UtRegisterTest("DetectEngineTest01", DetectEngineTest01); UtRegisterTest("DetectEngineTest02", DetectEngineTest02); @@ -3315,6 +3314,5 @@ void DetectEngineRegisterTests() UtRegisterTest("DetectEngineTest08", DetectEngineTest08); UtRegisterTest("DetectEngineTest09", DetectEngineTest09); #endif - return; } diff --git a/src/detect-fast-pattern.c b/src/detect-fast-pattern.c index ce492cb455..0211cbf176 100644 --- a/src/detect-fast-pattern.c +++ b/src/detect-fast-pattern.c @@ -42,7 +42,7 @@ static pcre *parse_regex = NULL; static pcre_extra *parse_regex_study = NULL; -static int DetectFastPatternSetup(DetectEngineCtx *, Signature *, char *); +static int DetectFastPatternSetup(DetectEngineCtx *, Signature *, const char *); void DetectFastPatternRegisterTests(void); /* holds the list of sm match lists that need to be searched for a keyword @@ -154,7 +154,7 @@ void DetectFastPatternRegister(void) * \retval 0 On success. * \retval -1 On failure. */ -static int DetectFastPatternSetup(DetectEngineCtx *de_ctx, Signature *s, char *arg) +static int DetectFastPatternSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg) { #define MAX_SUBSTRINGS 30 int ret = 0, res = 0; @@ -337,7 +337,7 @@ static int g_http_raw_uri_buffer_id = 0; /** * \test Checks if a fast_pattern is registered in a Signature */ -int DetectFastPatternTest01(void) +static int DetectFastPatternTest01(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -378,7 +378,7 @@ int DetectFastPatternTest01(void) /** * \test Checks if a fast_pattern is registered in a Signature */ -int DetectFastPatternTest02(void) +static int DetectFastPatternTest02(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -406,7 +406,7 @@ int DetectFastPatternTest02(void) * \test Checks that we have no fast_pattern registerd for a Signature when the * Signature doesn't contain a fast_pattern */ -int DetectFastPatternTest03(void) +static int DetectFastPatternTest03(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -447,7 +447,7 @@ int DetectFastPatternTest03(void) * \test Checks that a fast_pattern is not registered in a Signature, when we * supply a fast_pattern with an argument */ -int DetectFastPatternTest04(void) +static int DetectFastPatternTest04(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -472,7 +472,7 @@ int DetectFastPatternTest04(void) * \test Checks to make sure that other sigs work that should when fast_pattern is inspecting on the same payload * */ -int DetectFastPatternTest14(void) +static int DetectFastPatternTest14(void) { uint8_t *buf = (uint8_t *) "Dummy is our name. Oh yes. From right here " "right now, all the way to hangover. right. strings5_imp now here " @@ -535,7 +535,7 @@ end: /** * \test Checks if a fast_pattern is registered in a Signature */ -int DetectFastPatternTest15(void) +static int DetectFastPatternTest15(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -576,7 +576,7 @@ int DetectFastPatternTest15(void) /** * \test Checks if a fast_pattern is registered in a Signature */ -int DetectFastPatternTest16(void) +static int DetectFastPatternTest16(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -614,7 +614,7 @@ int DetectFastPatternTest16(void) return result; } -int DetectFastPatternTest17(void) +static int DetectFastPatternTest17(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -650,7 +650,7 @@ int DetectFastPatternTest17(void) return result; } -int DetectFastPatternTest18(void) +static int DetectFastPatternTest18(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -686,7 +686,7 @@ int DetectFastPatternTest18(void) return result; } -int DetectFastPatternTest19(void) +static int DetectFastPatternTest19(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -708,7 +708,7 @@ int DetectFastPatternTest19(void) return result; } -int DetectFastPatternTest20(void) +static int DetectFastPatternTest20(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -730,7 +730,7 @@ int DetectFastPatternTest20(void) return result; } -int DetectFastPatternTest21(void) +static int DetectFastPatternTest21(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -752,7 +752,7 @@ int DetectFastPatternTest21(void) return result; } -int DetectFastPatternTest22(void) +static int DetectFastPatternTest22(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -774,7 +774,7 @@ int DetectFastPatternTest22(void) return result; } -int DetectFastPatternTest23(void) +static int DetectFastPatternTest23(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -796,7 +796,7 @@ int DetectFastPatternTest23(void) return result; } -int DetectFastPatternTest24(void) +static int DetectFastPatternTest24(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -818,7 +818,7 @@ int DetectFastPatternTest24(void) return result; } -int DetectFastPatternTest25(void) +static int DetectFastPatternTest25(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -840,7 +840,7 @@ int DetectFastPatternTest25(void) return result; } -int DetectFastPatternTest26(void) +static int DetectFastPatternTest26(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -862,7 +862,7 @@ int DetectFastPatternTest26(void) return result; } -int DetectFastPatternTest27(void) +static int DetectFastPatternTest27(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -884,7 +884,7 @@ int DetectFastPatternTest27(void) return result; } -int DetectFastPatternTest28(void) +static int DetectFastPatternTest28(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -915,7 +915,7 @@ int DetectFastPatternTest28(void) return result; } -int DetectFastPatternTest29(void) +static int DetectFastPatternTest29(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -945,7 +945,7 @@ int DetectFastPatternTest29(void) return result; } -int DetectFastPatternTest30(void) +static int DetectFastPatternTest30(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -975,7 +975,7 @@ int DetectFastPatternTest30(void) return result; } -int DetectFastPatternTest31(void) +static int DetectFastPatternTest31(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1005,7 +1005,7 @@ int DetectFastPatternTest31(void) return result; } -int DetectFastPatternTest32(void) +static int DetectFastPatternTest32(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1036,7 +1036,7 @@ int DetectFastPatternTest32(void) return result; } -int DetectFastPatternTest33(void) +static int DetectFastPatternTest33(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1058,7 +1058,7 @@ int DetectFastPatternTest33(void) return result; } -int DetectFastPatternTest34(void) +static int DetectFastPatternTest34(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1080,7 +1080,7 @@ int DetectFastPatternTest34(void) return result; } -int DetectFastPatternTest35(void) +static int DetectFastPatternTest35(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1102,7 +1102,7 @@ int DetectFastPatternTest35(void) return result; } -int DetectFastPatternTest36(void) +static int DetectFastPatternTest36(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1124,7 +1124,7 @@ int DetectFastPatternTest36(void) return result; } -int DetectFastPatternTest37(void) +static int DetectFastPatternTest37(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1154,7 +1154,7 @@ int DetectFastPatternTest37(void) return result; } -int DetectFastPatternTest38(void) +static int DetectFastPatternTest38(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1184,7 +1184,7 @@ int DetectFastPatternTest38(void) return result; } -int DetectFastPatternTest39(void) +static int DetectFastPatternTest39(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1214,7 +1214,7 @@ int DetectFastPatternTest39(void) return result; } -int DetectFastPatternTest40(void) +static int DetectFastPatternTest40(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1244,7 +1244,7 @@ int DetectFastPatternTest40(void) return result; } -int DetectFastPatternTest41(void) +static int DetectFastPatternTest41(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1274,7 +1274,7 @@ int DetectFastPatternTest41(void) return result; } -int DetectFastPatternTest42(void) +static int DetectFastPatternTest42(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1304,7 +1304,7 @@ int DetectFastPatternTest42(void) return result; } -int DetectFastPatternTest43(void) +static int DetectFastPatternTest43(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1334,7 +1334,7 @@ int DetectFastPatternTest43(void) return result; } -int DetectFastPatternTest44(void) +static int DetectFastPatternTest44(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1364,7 +1364,7 @@ int DetectFastPatternTest44(void) return result; } -int DetectFastPatternTest45(void) +static int DetectFastPatternTest45(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1394,7 +1394,7 @@ int DetectFastPatternTest45(void) return result; } -int DetectFastPatternTest46(void) +static int DetectFastPatternTest46(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1416,7 +1416,7 @@ int DetectFastPatternTest46(void) return result; } -int DetectFastPatternTest47(void) +static int DetectFastPatternTest47(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1438,7 +1438,7 @@ int DetectFastPatternTest47(void) return result; } -int DetectFastPatternTest48(void) +static int DetectFastPatternTest48(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1460,7 +1460,7 @@ int DetectFastPatternTest48(void) return result; } -int DetectFastPatternTest49(void) +static int DetectFastPatternTest49(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1491,7 +1491,7 @@ int DetectFastPatternTest49(void) return result; } -int DetectFastPatternTest50(void) +static int DetectFastPatternTest50(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1513,7 +1513,7 @@ int DetectFastPatternTest50(void) return result; } -int DetectFastPatternTest51(void) +static int DetectFastPatternTest51(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1535,7 +1535,7 @@ int DetectFastPatternTest51(void) return result; } -int DetectFastPatternTest52(void) +static int DetectFastPatternTest52(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1557,7 +1557,7 @@ int DetectFastPatternTest52(void) return result; } -int DetectFastPatternTest53(void) +static int DetectFastPatternTest53(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1587,7 +1587,7 @@ int DetectFastPatternTest53(void) /** * \test Checks if a fast_pattern is registered in a Signature for uricontent. */ -int DetectFastPatternTest54(void) +static int DetectFastPatternTest54(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -1628,7 +1628,7 @@ int DetectFastPatternTest54(void) /** * \test Checks if a fast_pattern is registered in a Signature for uricontent. */ -int DetectFastPatternTest55(void) +static int DetectFastPatternTest55(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -1666,7 +1666,7 @@ int DetectFastPatternTest55(void) return result; } -int DetectFastPatternTest56(void) +static int DetectFastPatternTest56(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -1702,7 +1702,7 @@ int DetectFastPatternTest56(void) return result; } -int DetectFastPatternTest57(void) +static int DetectFastPatternTest57(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -1738,7 +1738,7 @@ int DetectFastPatternTest57(void) return result; } -int DetectFastPatternTest58(void) +static int DetectFastPatternTest58(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1760,7 +1760,7 @@ int DetectFastPatternTest58(void) return result; } -int DetectFastPatternTest59(void) +static int DetectFastPatternTest59(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1782,7 +1782,7 @@ int DetectFastPatternTest59(void) return result; } -int DetectFastPatternTest60(void) +static int DetectFastPatternTest60(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1804,7 +1804,7 @@ int DetectFastPatternTest60(void) return result; } -int DetectFastPatternTest61(void) +static int DetectFastPatternTest61(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1826,7 +1826,7 @@ int DetectFastPatternTest61(void) return result; } -int DetectFastPatternTest62(void) +static int DetectFastPatternTest62(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1848,7 +1848,7 @@ int DetectFastPatternTest62(void) return result; } -int DetectFastPatternTest63(void) +static int DetectFastPatternTest63(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1870,7 +1870,7 @@ int DetectFastPatternTest63(void) return result; } -int DetectFastPatternTest64(void) +static int DetectFastPatternTest64(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1892,7 +1892,7 @@ int DetectFastPatternTest64(void) return result; } -int DetectFastPatternTest65(void) +static int DetectFastPatternTest65(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1914,7 +1914,7 @@ int DetectFastPatternTest65(void) return result; } -int DetectFastPatternTest66(void) +static int DetectFastPatternTest66(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1936,7 +1936,7 @@ int DetectFastPatternTest66(void) return result; } -int DetectFastPatternTest67(void) +static int DetectFastPatternTest67(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1967,7 +1967,7 @@ int DetectFastPatternTest67(void) return result; } -int DetectFastPatternTest68(void) +static int DetectFastPatternTest68(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1997,7 +1997,7 @@ int DetectFastPatternTest68(void) return result; } -int DetectFastPatternTest69(void) +static int DetectFastPatternTest69(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2027,7 +2027,7 @@ int DetectFastPatternTest69(void) return result; } -int DetectFastPatternTest70(void) +static int DetectFastPatternTest70(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2057,7 +2057,7 @@ int DetectFastPatternTest70(void) return result; } -int DetectFastPatternTest71(void) +static int DetectFastPatternTest71(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2088,7 +2088,7 @@ int DetectFastPatternTest71(void) return result; } -int DetectFastPatternTest72(void) +static int DetectFastPatternTest72(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2110,7 +2110,7 @@ int DetectFastPatternTest72(void) return result; } -int DetectFastPatternTest73(void) +static int DetectFastPatternTest73(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2132,7 +2132,7 @@ int DetectFastPatternTest73(void) return result; } -int DetectFastPatternTest74(void) +static int DetectFastPatternTest74(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2154,7 +2154,7 @@ int DetectFastPatternTest74(void) return result; } -int DetectFastPatternTest75(void) +static int DetectFastPatternTest75(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2176,7 +2176,7 @@ int DetectFastPatternTest75(void) return result; } -int DetectFastPatternTest76(void) +static int DetectFastPatternTest76(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2206,7 +2206,7 @@ int DetectFastPatternTest76(void) return result; } -int DetectFastPatternTest77(void) +static int DetectFastPatternTest77(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2236,7 +2236,7 @@ int DetectFastPatternTest77(void) return result; } -int DetectFastPatternTest78(void) +static int DetectFastPatternTest78(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2266,7 +2266,7 @@ int DetectFastPatternTest78(void) return result; } -int DetectFastPatternTest79(void) +static int DetectFastPatternTest79(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2296,7 +2296,7 @@ int DetectFastPatternTest79(void) return result; } -int DetectFastPatternTest80(void) +static int DetectFastPatternTest80(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2326,7 +2326,7 @@ int DetectFastPatternTest80(void) return result; } -int DetectFastPatternTest81(void) +static int DetectFastPatternTest81(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2356,7 +2356,7 @@ int DetectFastPatternTest81(void) return result; } -int DetectFastPatternTest82(void) +static int DetectFastPatternTest82(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2386,7 +2386,7 @@ int DetectFastPatternTest82(void) return result; } -int DetectFastPatternTest83(void) +static int DetectFastPatternTest83(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2416,7 +2416,7 @@ int DetectFastPatternTest83(void) return result; } -int DetectFastPatternTest84(void) +static int DetectFastPatternTest84(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2449,7 +2449,7 @@ int DetectFastPatternTest84(void) return result; } -int DetectFastPatternTest85(void) +static int DetectFastPatternTest85(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2471,7 +2471,7 @@ int DetectFastPatternTest85(void) return result; } -int DetectFastPatternTest86(void) +static int DetectFastPatternTest86(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2493,7 +2493,7 @@ int DetectFastPatternTest86(void) return result; } -int DetectFastPatternTest87(void) +static int DetectFastPatternTest87(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2515,7 +2515,7 @@ int DetectFastPatternTest87(void) return result; } -int DetectFastPatternTest88(void) +static int DetectFastPatternTest88(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2546,7 +2546,7 @@ int DetectFastPatternTest88(void) return result; } -int DetectFastPatternTest89(void) +static int DetectFastPatternTest89(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2568,7 +2568,7 @@ int DetectFastPatternTest89(void) return result; } -int DetectFastPatternTest90(void) +static int DetectFastPatternTest90(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2590,7 +2590,7 @@ int DetectFastPatternTest90(void) return result; } -int DetectFastPatternTest91(void) +static int DetectFastPatternTest91(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2612,7 +2612,7 @@ int DetectFastPatternTest91(void) return result; } -int DetectFastPatternTest92(void) +static int DetectFastPatternTest92(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2639,7 +2639,7 @@ int DetectFastPatternTest92(void) /* http_uri fast_pattern tests v */ -int DetectFastPatternTest93(void) +static int DetectFastPatternTest93(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2673,7 +2673,7 @@ int DetectFastPatternTest93(void) /** * \test Checks if a fast_pattern is registered in a Signature for uricontent. */ -int DetectFastPatternTest94(void) +static int DetectFastPatternTest94(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -2714,7 +2714,7 @@ int DetectFastPatternTest94(void) /** * \test Checks if a fast_pattern is registered in a Signature for uricontent. */ -int DetectFastPatternTest95(void) +static int DetectFastPatternTest95(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -2752,7 +2752,7 @@ int DetectFastPatternTest95(void) return result; } -int DetectFastPatternTest96(void) +static int DetectFastPatternTest96(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -2788,7 +2788,7 @@ int DetectFastPatternTest96(void) return result; } -int DetectFastPatternTest97(void) +static int DetectFastPatternTest97(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -2824,7 +2824,7 @@ int DetectFastPatternTest97(void) return result; } -int DetectFastPatternTest98(void) +static int DetectFastPatternTest98(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2846,7 +2846,7 @@ int DetectFastPatternTest98(void) return result; } -int DetectFastPatternTest99(void) +static int DetectFastPatternTest99(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2868,7 +2868,7 @@ int DetectFastPatternTest99(void) return result; } -int DetectFastPatternTest100(void) +static int DetectFastPatternTest100(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2890,7 +2890,7 @@ int DetectFastPatternTest100(void) return result; } -int DetectFastPatternTest101(void) +static int DetectFastPatternTest101(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2912,7 +2912,7 @@ int DetectFastPatternTest101(void) return result; } -int DetectFastPatternTest102(void) +static int DetectFastPatternTest102(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2934,7 +2934,7 @@ int DetectFastPatternTest102(void) return result; } -int DetectFastPatternTest103(void) +static int DetectFastPatternTest103(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2956,7 +2956,7 @@ int DetectFastPatternTest103(void) return result; } -int DetectFastPatternTest104(void) +static int DetectFastPatternTest104(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2978,7 +2978,7 @@ int DetectFastPatternTest104(void) return result; } -int DetectFastPatternTest105(void) +static int DetectFastPatternTest105(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -3000,7 +3000,7 @@ int DetectFastPatternTest105(void) return result; } -int DetectFastPatternTest106(void) +static int DetectFastPatternTest106(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -3022,7 +3022,7 @@ int DetectFastPatternTest106(void) return result; } -int DetectFastPatternTest107(void) +static int DetectFastPatternTest107(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -3053,7 +3053,7 @@ int DetectFastPatternTest107(void) return result; } -int DetectFastPatternTest108(void) +static int DetectFastPatternTest108(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -3083,7 +3083,7 @@ int DetectFastPatternTest108(void) return result; } -int DetectFastPatternTest109(void) +static int DetectFastPatternTest109(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -3113,7 +3113,7 @@ int DetectFastPatternTest109(void) return result; } -int DetectFastPatternTest110(void) +static int DetectFastPatternTest110(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -3143,7 +3143,7 @@ int DetectFastPatternTest110(void) return result; } -int DetectFastPatternTest111(void) +static int DetectFastPatternTest111(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -3174,7 +3174,7 @@ int DetectFastPatternTest111(void) return result; } -int DetectFastPatternTest112(void) +static int DetectFastPatternTest112(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -3196,7 +3196,7 @@ int DetectFastPatternTest112(void) return result; } -int DetectFastPatternTest113(void) +static int DetectFastPatternTest113(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -3218,7 +3218,7 @@ int DetectFastPatternTest113(void) return result; } -int DetectFastPatternTest114(void) +static int DetectFastPatternTest114(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -3240,7 +3240,7 @@ int DetectFastPatternTest114(void) return result; } -int DetectFastPatternTest115(void) +static int DetectFastPatternTest115(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -3262,7 +3262,7 @@ int DetectFastPatternTest115(void) return result; } -int DetectFastPatternTest116(void) +static int DetectFastPatternTest116(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -3292,7 +3292,7 @@ int DetectFastPatternTest116(void) return result; } -int DetectFastPatternTest117(void) +static int DetectFastPatternTest117(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -3322,7 +3322,7 @@ int DetectFastPatternTest117(void) return result; } -int DetectFastPatternTest118(void) +static int DetectFastPatternTest118(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -3352,7 +3352,7 @@ int DetectFastPatternTest118(void) return result; } -int DetectFastPatternTest119(void) +static int DetectFastPatternTest119(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -3382,7 +3382,7 @@ int DetectFastPatternTest119(void) return result; } -int DetectFastPatternTest120(void) +static int DetectFastPatternTest120(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -3412,7 +3412,7 @@ int DetectFastPatternTest120(void) return result; } -int DetectFastPatternTest121(void) +static int DetectFastPatternTest121(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -3442,7 +3442,7 @@ int DetectFastPatternTest121(void) return result; } -int DetectFastPatternTest122(void) +static int DetectFastPatternTest122(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -3472,7 +3472,7 @@ int DetectFastPatternTest122(void) return result; } -int DetectFastPatternTest123(void) +static int DetectFastPatternTest123(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -3502,7 +3502,7 @@ int DetectFastPatternTest123(void) return result; } -int DetectFastPatternTest124(void) +static int DetectFastPatternTest124(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -3535,7 +3535,7 @@ int DetectFastPatternTest124(void) return result; } -int DetectFastPatternTest125(void) +static int DetectFastPatternTest125(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -3557,7 +3557,7 @@ int DetectFastPatternTest125(void) return result; } -int DetectFastPatternTest126(void) +static int DetectFastPatternTest126(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -3579,7 +3579,7 @@ int DetectFastPatternTest126(void) return result; } -int DetectFastPatternTest127(void) +static int DetectFastPatternTest127(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -3601,7 +3601,7 @@ int DetectFastPatternTest127(void) return result; } -int DetectFastPatternTest128(void) +static int DetectFastPatternTest128(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -3632,7 +3632,7 @@ int DetectFastPatternTest128(void) return result; } -int DetectFastPatternTest129(void) +static int DetectFastPatternTest129(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -3654,7 +3654,7 @@ int DetectFastPatternTest129(void) return result; } -int DetectFastPatternTest130(void) +static int DetectFastPatternTest130(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -3676,7 +3676,7 @@ int DetectFastPatternTest130(void) return result; } -int DetectFastPatternTest131(void) +static int DetectFastPatternTest131(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -3698,7 +3698,7 @@ int DetectFastPatternTest131(void) return result; } -int DetectFastPatternTest132(void) +static int DetectFastPatternTest132(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -3720,7 +3720,7 @@ int DetectFastPatternTest132(void) return result; } -int DetectFastPatternTest133(void) +static int DetectFastPatternTest133(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -3756,7 +3756,7 @@ int DetectFastPatternTest133(void) /* http_client_body fast_pattern tests v */ -int DetectFastPatternTest134(void) +static int DetectFastPatternTest134(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -3790,7 +3790,7 @@ int DetectFastPatternTest134(void) /** * \test Checks if a fast_pattern is registered in a Signature for uricontent. */ -int DetectFastPatternTest135(void) +static int DetectFastPatternTest135(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -3827,7 +3827,7 @@ int DetectFastPatternTest135(void) /** * \test Checks if a fast_pattern is registered in a Signature for uricontent. */ -int DetectFastPatternTest136(void) +static int DetectFastPatternTest136(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -3860,7 +3860,7 @@ int DetectFastPatternTest136(void) return result; } -int DetectFastPatternTest137(void) +static int DetectFastPatternTest137(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -3894,7 +3894,7 @@ int DetectFastPatternTest137(void) return result; } -int DetectFastPatternTest138(void) +static int DetectFastPatternTest138(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -3928,7 +3928,7 @@ int DetectFastPatternTest138(void) return result; } -int DetectFastPatternTest139(void) +static int DetectFastPatternTest139(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -3950,7 +3950,7 @@ int DetectFastPatternTest139(void) return result; } -int DetectFastPatternTest140(void) +static int DetectFastPatternTest140(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -3972,7 +3972,7 @@ int DetectFastPatternTest140(void) return result; } -int DetectFastPatternTest141(void) +static int DetectFastPatternTest141(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -3994,7 +3994,7 @@ int DetectFastPatternTest141(void) return result; } -int DetectFastPatternTest142(void) +static int DetectFastPatternTest142(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4016,7 +4016,7 @@ int DetectFastPatternTest142(void) return result; } -int DetectFastPatternTest143(void) +static int DetectFastPatternTest143(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4038,7 +4038,7 @@ int DetectFastPatternTest143(void) return result; } -int DetectFastPatternTest144(void) +static int DetectFastPatternTest144(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4060,7 +4060,7 @@ int DetectFastPatternTest144(void) return result; } -int DetectFastPatternTest145(void) +static int DetectFastPatternTest145(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4082,7 +4082,7 @@ int DetectFastPatternTest145(void) return result; } -int DetectFastPatternTest146(void) +static int DetectFastPatternTest146(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4104,7 +4104,7 @@ int DetectFastPatternTest146(void) return result; } -int DetectFastPatternTest147(void) +static int DetectFastPatternTest147(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4126,7 +4126,7 @@ int DetectFastPatternTest147(void) return result; } -int DetectFastPatternTest148(void) +static int DetectFastPatternTest148(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4157,7 +4157,7 @@ int DetectFastPatternTest148(void) return result; } -int DetectFastPatternTest149(void) +static int DetectFastPatternTest149(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4187,7 +4187,7 @@ int DetectFastPatternTest149(void) return result; } -int DetectFastPatternTest150(void) +static int DetectFastPatternTest150(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4217,7 +4217,7 @@ int DetectFastPatternTest150(void) return result; } -int DetectFastPatternTest151(void) +static int DetectFastPatternTest151(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4247,7 +4247,7 @@ int DetectFastPatternTest151(void) return result; } -int DetectFastPatternTest152(void) +static int DetectFastPatternTest152(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4278,7 +4278,7 @@ int DetectFastPatternTest152(void) return result; } -int DetectFastPatternTest153(void) +static int DetectFastPatternTest153(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4300,7 +4300,7 @@ int DetectFastPatternTest153(void) return result; } -int DetectFastPatternTest154(void) +static int DetectFastPatternTest154(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4322,7 +4322,7 @@ int DetectFastPatternTest154(void) return result; } -int DetectFastPatternTest155(void) +static int DetectFastPatternTest155(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4344,7 +4344,7 @@ int DetectFastPatternTest155(void) return result; } -int DetectFastPatternTest156(void) +static int DetectFastPatternTest156(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4366,7 +4366,7 @@ int DetectFastPatternTest156(void) return result; } -int DetectFastPatternTest157(void) +static int DetectFastPatternTest157(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4396,7 +4396,7 @@ int DetectFastPatternTest157(void) return result; } -int DetectFastPatternTest158(void) +static int DetectFastPatternTest158(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4426,7 +4426,7 @@ int DetectFastPatternTest158(void) return result; } -int DetectFastPatternTest159(void) +static int DetectFastPatternTest159(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4456,7 +4456,7 @@ int DetectFastPatternTest159(void) return result; } -int DetectFastPatternTest160(void) +static int DetectFastPatternTest160(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4486,7 +4486,7 @@ int DetectFastPatternTest160(void) return result; } -int DetectFastPatternTest161(void) +static int DetectFastPatternTest161(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4516,7 +4516,7 @@ int DetectFastPatternTest161(void) return result; } -int DetectFastPatternTest162(void) +static int DetectFastPatternTest162(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4546,7 +4546,7 @@ int DetectFastPatternTest162(void) return result; } -int DetectFastPatternTest163(void) +static int DetectFastPatternTest163(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4576,7 +4576,7 @@ int DetectFastPatternTest163(void) return result; } -int DetectFastPatternTest164(void) +static int DetectFastPatternTest164(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4606,7 +4606,7 @@ int DetectFastPatternTest164(void) return result; } -int DetectFastPatternTest165(void) +static int DetectFastPatternTest165(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4639,7 +4639,7 @@ int DetectFastPatternTest165(void) return result; } -int DetectFastPatternTest166(void) +static int DetectFastPatternTest166(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4661,7 +4661,7 @@ int DetectFastPatternTest166(void) return result; } -int DetectFastPatternTest167(void) +static int DetectFastPatternTest167(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4683,7 +4683,7 @@ int DetectFastPatternTest167(void) return result; } -int DetectFastPatternTest168(void) +static int DetectFastPatternTest168(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4705,7 +4705,7 @@ int DetectFastPatternTest168(void) return result; } -int DetectFastPatternTest169(void) +static int DetectFastPatternTest169(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4736,7 +4736,7 @@ int DetectFastPatternTest169(void) return result; } -int DetectFastPatternTest170(void) +static int DetectFastPatternTest170(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4758,7 +4758,7 @@ int DetectFastPatternTest170(void) return result; } -int DetectFastPatternTest171(void) +static int DetectFastPatternTest171(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4780,7 +4780,7 @@ int DetectFastPatternTest171(void) return result; } -int DetectFastPatternTest172(void) +static int DetectFastPatternTest172(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4802,7 +4802,7 @@ int DetectFastPatternTest172(void) return result; } -int DetectFastPatternTest173(void) +static int DetectFastPatternTest173(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4824,7 +4824,7 @@ int DetectFastPatternTest173(void) return result; } -int DetectFastPatternTest174(void) +static int DetectFastPatternTest174(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4860,7 +4860,7 @@ int DetectFastPatternTest174(void) /* content fast_pattern tests v */ -int DetectFastPatternTest175(void) +static int DetectFastPatternTest175(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4882,7 +4882,7 @@ int DetectFastPatternTest175(void) return result; } -int DetectFastPatternTest176(void) +static int DetectFastPatternTest176(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4904,7 +4904,7 @@ int DetectFastPatternTest176(void) return result; } -int DetectFastPatternTest177(void) +static int DetectFastPatternTest177(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4926,7 +4926,7 @@ int DetectFastPatternTest177(void) return result; } -int DetectFastPatternTest178(void) +static int DetectFastPatternTest178(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4952,7 +4952,7 @@ int DetectFastPatternTest178(void) /* http_header fast_pattern tests v */ -int DetectFastPatternTest179(void) +static int DetectFastPatternTest179(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -4988,7 +4988,7 @@ int DetectFastPatternTest179(void) /** * \test Checks if a fast_pattern is registered in a Signature for uricontent. */ -int DetectFastPatternTest180(void) +static int DetectFastPatternTest180(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -5025,7 +5025,7 @@ int DetectFastPatternTest180(void) /** * \test Checks if a fast_pattern is registered in a Signature for uricontent. */ -int DetectFastPatternTest181(void) +static int DetectFastPatternTest181(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -5058,7 +5058,7 @@ int DetectFastPatternTest181(void) return result; } -int DetectFastPatternTest182(void) +static int DetectFastPatternTest182(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -5092,7 +5092,7 @@ int DetectFastPatternTest182(void) return result; } -int DetectFastPatternTest183(void) +static int DetectFastPatternTest183(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -5126,7 +5126,7 @@ int DetectFastPatternTest183(void) return result; } -int DetectFastPatternTest184(void) +static int DetectFastPatternTest184(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -5148,7 +5148,7 @@ int DetectFastPatternTest184(void) return result; } -int DetectFastPatternTest185(void) +static int DetectFastPatternTest185(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -5170,7 +5170,7 @@ int DetectFastPatternTest185(void) return result; } -int DetectFastPatternTest186(void) +static int DetectFastPatternTest186(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -5192,7 +5192,7 @@ int DetectFastPatternTest186(void) return result; } -int DetectFastPatternTest187(void) +static int DetectFastPatternTest187(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -5214,7 +5214,7 @@ int DetectFastPatternTest187(void) return result; } -int DetectFastPatternTest188(void) +static int DetectFastPatternTest188(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -5236,7 +5236,7 @@ int DetectFastPatternTest188(void) return result; } -int DetectFastPatternTest189(void) +static int DetectFastPatternTest189(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -5258,7 +5258,7 @@ int DetectFastPatternTest189(void) return result; } -int DetectFastPatternTest190(void) +static int DetectFastPatternTest190(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -5280,7 +5280,7 @@ int DetectFastPatternTest190(void) return result; } -int DetectFastPatternTest191(void) +static int DetectFastPatternTest191(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -5302,7 +5302,7 @@ int DetectFastPatternTest191(void) return result; } -int DetectFastPatternTest192(void) +static int DetectFastPatternTest192(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -5324,7 +5324,7 @@ int DetectFastPatternTest192(void) return result; } -int DetectFastPatternTest193(void) +static int DetectFastPatternTest193(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -5355,7 +5355,7 @@ int DetectFastPatternTest193(void) return result; } -int DetectFastPatternTest194(void) +static int DetectFastPatternTest194(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -5385,7 +5385,7 @@ int DetectFastPatternTest194(void) return result; } -int DetectFastPatternTest195(void) +static int DetectFastPatternTest195(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -5415,7 +5415,7 @@ int DetectFastPatternTest195(void) return result; } -int DetectFastPatternTest196(void) +static int DetectFastPatternTest196(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -5445,7 +5445,7 @@ int DetectFastPatternTest196(void) return result; } -int DetectFastPatternTest197(void) +static int DetectFastPatternTest197(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -5476,7 +5476,7 @@ int DetectFastPatternTest197(void) return result; } -int DetectFastPatternTest198(void) +static int DetectFastPatternTest198(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -5498,7 +5498,7 @@ int DetectFastPatternTest198(void) return result; } -int DetectFastPatternTest199(void) +static int DetectFastPatternTest199(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -5520,7 +5520,7 @@ int DetectFastPatternTest199(void) return result; } -int DetectFastPatternTest200(void) +static int DetectFastPatternTest200(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -5542,7 +5542,7 @@ int DetectFastPatternTest200(void) return result; } -int DetectFastPatternTest201(void) +static int DetectFastPatternTest201(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -5564,7 +5564,7 @@ int DetectFastPatternTest201(void) return result; } -int DetectFastPatternTest202(void) +static int DetectFastPatternTest202(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -5594,7 +5594,7 @@ int DetectFastPatternTest202(void) return result; } -int DetectFastPatternTest203(void) +static int DetectFastPatternTest203(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -5624,7 +5624,7 @@ int DetectFastPatternTest203(void) return result; } -int DetectFastPatternTest204(void) +static int DetectFastPatternTest204(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -5654,7 +5654,7 @@ int DetectFastPatternTest204(void) return result; } -int DetectFastPatternTest205(void) +static int DetectFastPatternTest205(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -5684,7 +5684,7 @@ int DetectFastPatternTest205(void) return result; } -int DetectFastPatternTest206(void) +static int DetectFastPatternTest206(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -5714,7 +5714,7 @@ int DetectFastPatternTest206(void) return result; } -int DetectFastPatternTest207(void) +static int DetectFastPatternTest207(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -5744,7 +5744,7 @@ int DetectFastPatternTest207(void) return result; } -int DetectFastPatternTest208(void) +static int DetectFastPatternTest208(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -5774,7 +5774,7 @@ int DetectFastPatternTest208(void) return result; } -int DetectFastPatternTest209(void) +static int DetectFastPatternTest209(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -5804,7 +5804,7 @@ int DetectFastPatternTest209(void) return result; } -int DetectFastPatternTest210(void) +static int DetectFastPatternTest210(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -5837,7 +5837,7 @@ int DetectFastPatternTest210(void) return result; } -int DetectFastPatternTest211(void) +static int DetectFastPatternTest211(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -5859,7 +5859,7 @@ int DetectFastPatternTest211(void) return result; } -int DetectFastPatternTest212(void) +static int DetectFastPatternTest212(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -5881,7 +5881,7 @@ int DetectFastPatternTest212(void) return result; } -int DetectFastPatternTest213(void) +static int DetectFastPatternTest213(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -5903,7 +5903,7 @@ int DetectFastPatternTest213(void) return result; } -int DetectFastPatternTest214(void) +static int DetectFastPatternTest214(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -5934,7 +5934,7 @@ int DetectFastPatternTest214(void) return result; } -int DetectFastPatternTest215(void) +static int DetectFastPatternTest215(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -5956,7 +5956,7 @@ int DetectFastPatternTest215(void) return result; } -int DetectFastPatternTest216(void) +static int DetectFastPatternTest216(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -5978,7 +5978,7 @@ int DetectFastPatternTest216(void) return result; } -int DetectFastPatternTest217(void) +static int DetectFastPatternTest217(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -6000,7 +6000,7 @@ int DetectFastPatternTest217(void) return result; } -int DetectFastPatternTest218(void) +static int DetectFastPatternTest218(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -6022,7 +6022,7 @@ int DetectFastPatternTest218(void) return result; } -int DetectFastPatternTest219(void) +static int DetectFastPatternTest219(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -6058,7 +6058,7 @@ int DetectFastPatternTest219(void) /* http_raw_header fast_pattern tests v */ -int DetectFastPatternTest220(void) +static int DetectFastPatternTest220(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -6094,7 +6094,7 @@ int DetectFastPatternTest220(void) /** * \test Checks if a fast_pattern is registered in a Signature for uricontent. */ -int DetectFastPatternTest221(void) +static int DetectFastPatternTest221(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -6131,7 +6131,7 @@ int DetectFastPatternTest221(void) /** * \test Checks if a fast_pattern is registered in a Signature for uricontent. */ -int DetectFastPatternTest222(void) +static int DetectFastPatternTest222(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -6164,7 +6164,7 @@ int DetectFastPatternTest222(void) return result; } -int DetectFastPatternTest223(void) +static int DetectFastPatternTest223(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -6198,7 +6198,7 @@ int DetectFastPatternTest223(void) return result; } -int DetectFastPatternTest224(void) +static int DetectFastPatternTest224(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -6232,7 +6232,7 @@ int DetectFastPatternTest224(void) return result; } -int DetectFastPatternTest225(void) +static int DetectFastPatternTest225(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -6254,7 +6254,7 @@ int DetectFastPatternTest225(void) return result; } -int DetectFastPatternTest226(void) +static int DetectFastPatternTest226(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -6276,7 +6276,7 @@ int DetectFastPatternTest226(void) return result; } -int DetectFastPatternTest227(void) +static int DetectFastPatternTest227(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -6298,7 +6298,7 @@ int DetectFastPatternTest227(void) return result; } -int DetectFastPatternTest228(void) +static int DetectFastPatternTest228(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -6320,7 +6320,7 @@ int DetectFastPatternTest228(void) return result; } -int DetectFastPatternTest229(void) +static int DetectFastPatternTest229(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -6342,7 +6342,7 @@ int DetectFastPatternTest229(void) return result; } -int DetectFastPatternTest230(void) +static int DetectFastPatternTest230(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -6364,7 +6364,7 @@ int DetectFastPatternTest230(void) return result; } -int DetectFastPatternTest231(void) +static int DetectFastPatternTest231(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -6386,7 +6386,7 @@ int DetectFastPatternTest231(void) return result; } -int DetectFastPatternTest232(void) +static int DetectFastPatternTest232(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -6408,7 +6408,7 @@ int DetectFastPatternTest232(void) return result; } -int DetectFastPatternTest233(void) +static int DetectFastPatternTest233(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -6430,7 +6430,7 @@ int DetectFastPatternTest233(void) return result; } -int DetectFastPatternTest234(void) +static int DetectFastPatternTest234(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -6461,7 +6461,7 @@ int DetectFastPatternTest234(void) return result; } -int DetectFastPatternTest235(void) +static int DetectFastPatternTest235(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -6491,7 +6491,7 @@ int DetectFastPatternTest235(void) return result; } -int DetectFastPatternTest236(void) +static int DetectFastPatternTest236(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -6521,7 +6521,7 @@ int DetectFastPatternTest236(void) return result; } -int DetectFastPatternTest237(void) +static int DetectFastPatternTest237(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -6551,7 +6551,7 @@ int DetectFastPatternTest237(void) return result; } -int DetectFastPatternTest238(void) +static int DetectFastPatternTest238(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -6582,7 +6582,7 @@ int DetectFastPatternTest238(void) return result; } -int DetectFastPatternTest239(void) +static int DetectFastPatternTest239(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -6604,7 +6604,7 @@ int DetectFastPatternTest239(void) return result; } -int DetectFastPatternTest240(void) +static int DetectFastPatternTest240(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -6626,7 +6626,7 @@ int DetectFastPatternTest240(void) return result; } -int DetectFastPatternTest241(void) +static int DetectFastPatternTest241(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -6648,7 +6648,7 @@ int DetectFastPatternTest241(void) return result; } -int DetectFastPatternTest242(void) +static int DetectFastPatternTest242(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -6670,7 +6670,7 @@ int DetectFastPatternTest242(void) return result; } -int DetectFastPatternTest243(void) +static int DetectFastPatternTest243(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -6700,7 +6700,7 @@ int DetectFastPatternTest243(void) return result; } -int DetectFastPatternTest244(void) +static int DetectFastPatternTest244(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -6730,7 +6730,7 @@ int DetectFastPatternTest244(void) return result; } -int DetectFastPatternTest245(void) +static int DetectFastPatternTest245(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -6760,7 +6760,7 @@ int DetectFastPatternTest245(void) return result; } -int DetectFastPatternTest246(void) +static int DetectFastPatternTest246(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -6790,7 +6790,7 @@ int DetectFastPatternTest246(void) return result; } -int DetectFastPatternTest247(void) +static int DetectFastPatternTest247(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -6820,7 +6820,7 @@ int DetectFastPatternTest247(void) return result; } -int DetectFastPatternTest248(void) +static int DetectFastPatternTest248(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -6850,7 +6850,7 @@ int DetectFastPatternTest248(void) return result; } -int DetectFastPatternTest249(void) +static int DetectFastPatternTest249(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -6880,7 +6880,7 @@ int DetectFastPatternTest249(void) return result; } -int DetectFastPatternTest250(void) +static int DetectFastPatternTest250(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -6910,7 +6910,7 @@ int DetectFastPatternTest250(void) return result; } -int DetectFastPatternTest251(void) +static int DetectFastPatternTest251(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -6943,7 +6943,7 @@ int DetectFastPatternTest251(void) return result; } -int DetectFastPatternTest252(void) +static int DetectFastPatternTest252(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -6965,7 +6965,7 @@ int DetectFastPatternTest252(void) return result; } -int DetectFastPatternTest253(void) +static int DetectFastPatternTest253(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -6987,7 +6987,7 @@ int DetectFastPatternTest253(void) return result; } -int DetectFastPatternTest254(void) +static int DetectFastPatternTest254(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -7009,7 +7009,7 @@ int DetectFastPatternTest254(void) return result; } -int DetectFastPatternTest255(void) +static int DetectFastPatternTest255(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -7040,7 +7040,7 @@ int DetectFastPatternTest255(void) return result; } -int DetectFastPatternTest256(void) +static int DetectFastPatternTest256(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -7062,7 +7062,7 @@ int DetectFastPatternTest256(void) return result; } -int DetectFastPatternTest257(void) +static int DetectFastPatternTest257(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -7084,7 +7084,7 @@ int DetectFastPatternTest257(void) return result; } -int DetectFastPatternTest258(void) +static int DetectFastPatternTest258(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -7106,7 +7106,7 @@ int DetectFastPatternTest258(void) return result; } -int DetectFastPatternTest259(void) +static int DetectFastPatternTest259(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -7128,7 +7128,7 @@ int DetectFastPatternTest259(void) return result; } -int DetectFastPatternTest260(void) +static int DetectFastPatternTest260(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -7164,7 +7164,7 @@ int DetectFastPatternTest260(void) /* http_method fast_pattern tests v */ -int DetectFastPatternTest261(void) +static int DetectFastPatternTest261(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -7200,7 +7200,7 @@ int DetectFastPatternTest261(void) /** * \test Checks if a fast_pattern is registered in a Signature for uricontent. */ -int DetectFastPatternTest262(void) +static int DetectFastPatternTest262(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -7237,7 +7237,7 @@ int DetectFastPatternTest262(void) /** * \test Checks if a fast_pattern is registered in a Signature for uricontent. */ -int DetectFastPatternTest263(void) +static int DetectFastPatternTest263(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -7270,7 +7270,7 @@ int DetectFastPatternTest263(void) return result; } -int DetectFastPatternTest264(void) +static int DetectFastPatternTest264(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -7304,7 +7304,7 @@ int DetectFastPatternTest264(void) return result; } -int DetectFastPatternTest265(void) +static int DetectFastPatternTest265(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -7338,7 +7338,7 @@ int DetectFastPatternTest265(void) return result; } -int DetectFastPatternTest266(void) +static int DetectFastPatternTest266(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -7360,7 +7360,7 @@ int DetectFastPatternTest266(void) return result; } -int DetectFastPatternTest267(void) +static int DetectFastPatternTest267(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -7382,7 +7382,7 @@ int DetectFastPatternTest267(void) return result; } -int DetectFastPatternTest268(void) +static int DetectFastPatternTest268(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -7404,7 +7404,7 @@ int DetectFastPatternTest268(void) return result; } -int DetectFastPatternTest269(void) +static int DetectFastPatternTest269(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -7426,7 +7426,7 @@ int DetectFastPatternTest269(void) return result; } -int DetectFastPatternTest270(void) +static int DetectFastPatternTest270(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -7448,7 +7448,7 @@ int DetectFastPatternTest270(void) return result; } -int DetectFastPatternTest271(void) +static int DetectFastPatternTest271(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -7470,7 +7470,7 @@ int DetectFastPatternTest271(void) return result; } -int DetectFastPatternTest272(void) +static int DetectFastPatternTest272(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -7492,7 +7492,7 @@ int DetectFastPatternTest272(void) return result; } -int DetectFastPatternTest273(void) +static int DetectFastPatternTest273(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -7514,7 +7514,7 @@ int DetectFastPatternTest273(void) return result; } -int DetectFastPatternTest274(void) +static int DetectFastPatternTest274(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -7536,7 +7536,7 @@ int DetectFastPatternTest274(void) return result; } -int DetectFastPatternTest275(void) +static int DetectFastPatternTest275(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -7567,7 +7567,7 @@ int DetectFastPatternTest275(void) return result; } -int DetectFastPatternTest276(void) +static int DetectFastPatternTest276(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -7597,7 +7597,7 @@ int DetectFastPatternTest276(void) return result; } -int DetectFastPatternTest277(void) +static int DetectFastPatternTest277(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -7627,7 +7627,7 @@ int DetectFastPatternTest277(void) return result; } -int DetectFastPatternTest278(void) +static int DetectFastPatternTest278(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -7657,7 +7657,7 @@ int DetectFastPatternTest278(void) return result; } -int DetectFastPatternTest279(void) +static int DetectFastPatternTest279(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -7688,7 +7688,7 @@ int DetectFastPatternTest279(void) return result; } -int DetectFastPatternTest280(void) +static int DetectFastPatternTest280(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -7710,7 +7710,7 @@ int DetectFastPatternTest280(void) return result; } -int DetectFastPatternTest281(void) +static int DetectFastPatternTest281(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -7732,7 +7732,7 @@ int DetectFastPatternTest281(void) return result; } -int DetectFastPatternTest282(void) +static int DetectFastPatternTest282(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -7754,7 +7754,7 @@ int DetectFastPatternTest282(void) return result; } -int DetectFastPatternTest283(void) +static int DetectFastPatternTest283(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -7776,7 +7776,7 @@ int DetectFastPatternTest283(void) return result; } -int DetectFastPatternTest284(void) +static int DetectFastPatternTest284(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -7806,7 +7806,7 @@ int DetectFastPatternTest284(void) return result; } -int DetectFastPatternTest285(void) +static int DetectFastPatternTest285(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -7836,7 +7836,7 @@ int DetectFastPatternTest285(void) return result; } -int DetectFastPatternTest286(void) +static int DetectFastPatternTest286(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -7866,7 +7866,7 @@ int DetectFastPatternTest286(void) return result; } -int DetectFastPatternTest287(void) +static int DetectFastPatternTest287(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -7896,7 +7896,7 @@ int DetectFastPatternTest287(void) return result; } -int DetectFastPatternTest288(void) +static int DetectFastPatternTest288(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -7926,7 +7926,7 @@ int DetectFastPatternTest288(void) return result; } -int DetectFastPatternTest289(void) +static int DetectFastPatternTest289(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -7956,7 +7956,7 @@ int DetectFastPatternTest289(void) return result; } -int DetectFastPatternTest290(void) +static int DetectFastPatternTest290(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -7986,7 +7986,7 @@ int DetectFastPatternTest290(void) return result; } -int DetectFastPatternTest291(void) +static int DetectFastPatternTest291(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -8016,7 +8016,7 @@ int DetectFastPatternTest291(void) return result; } -int DetectFastPatternTest292(void) +static int DetectFastPatternTest292(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -8049,7 +8049,7 @@ int DetectFastPatternTest292(void) return result; } -int DetectFastPatternTest293(void) +static int DetectFastPatternTest293(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -8071,7 +8071,7 @@ int DetectFastPatternTest293(void) return result; } -int DetectFastPatternTest294(void) +static int DetectFastPatternTest294(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -8093,7 +8093,7 @@ int DetectFastPatternTest294(void) return result; } -int DetectFastPatternTest295(void) +static int DetectFastPatternTest295(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -8115,7 +8115,7 @@ int DetectFastPatternTest295(void) return result; } -int DetectFastPatternTest296(void) +static int DetectFastPatternTest296(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -8146,7 +8146,7 @@ int DetectFastPatternTest296(void) return result; } -int DetectFastPatternTest297(void) +static int DetectFastPatternTest297(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -8168,7 +8168,7 @@ int DetectFastPatternTest297(void) return result; } -int DetectFastPatternTest298(void) +static int DetectFastPatternTest298(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -8190,7 +8190,7 @@ int DetectFastPatternTest298(void) return result; } -int DetectFastPatternTest299(void) +static int DetectFastPatternTest299(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -8212,7 +8212,7 @@ int DetectFastPatternTest299(void) return result; } -int DetectFastPatternTest300(void) +static int DetectFastPatternTest300(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -8234,7 +8234,7 @@ int DetectFastPatternTest300(void) return result; } -int DetectFastPatternTest301(void) +static int DetectFastPatternTest301(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -8270,7 +8270,7 @@ int DetectFastPatternTest301(void) /* http_cookie fast_pattern tests v */ -int DetectFastPatternTest302(void) +static int DetectFastPatternTest302(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -8306,7 +8306,7 @@ int DetectFastPatternTest302(void) /** * \test Checks if a fast_pattern is registered in a Signature for uricontent. */ -int DetectFastPatternTest303(void) +static int DetectFastPatternTest303(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -8343,7 +8343,7 @@ int DetectFastPatternTest303(void) /** * \test Checks if a fast_pattern is registered in a Signature for uricontent. */ -int DetectFastPatternTest304(void) +static int DetectFastPatternTest304(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -8376,7 +8376,7 @@ int DetectFastPatternTest304(void) return result; } -int DetectFastPatternTest305(void) +static int DetectFastPatternTest305(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -8410,7 +8410,7 @@ int DetectFastPatternTest305(void) return result; } -int DetectFastPatternTest306(void) +static int DetectFastPatternTest306(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -8444,7 +8444,7 @@ int DetectFastPatternTest306(void) return result; } -int DetectFastPatternTest307(void) +static int DetectFastPatternTest307(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -8466,7 +8466,7 @@ int DetectFastPatternTest307(void) return result; } -int DetectFastPatternTest308(void) +static int DetectFastPatternTest308(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -8488,7 +8488,7 @@ int DetectFastPatternTest308(void) return result; } -int DetectFastPatternTest309(void) +static int DetectFastPatternTest309(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -8510,7 +8510,7 @@ int DetectFastPatternTest309(void) return result; } -int DetectFastPatternTest310(void) +static int DetectFastPatternTest310(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -8532,7 +8532,7 @@ int DetectFastPatternTest310(void) return result; } -int DetectFastPatternTest311(void) +static int DetectFastPatternTest311(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -8554,7 +8554,7 @@ int DetectFastPatternTest311(void) return result; } -int DetectFastPatternTest312(void) +static int DetectFastPatternTest312(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -8576,7 +8576,7 @@ int DetectFastPatternTest312(void) return result; } -int DetectFastPatternTest313(void) +static int DetectFastPatternTest313(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -8598,7 +8598,7 @@ int DetectFastPatternTest313(void) return result; } -int DetectFastPatternTest314(void) +static int DetectFastPatternTest314(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -8620,7 +8620,7 @@ int DetectFastPatternTest314(void) return result; } -int DetectFastPatternTest315(void) +static int DetectFastPatternTest315(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -8642,7 +8642,7 @@ int DetectFastPatternTest315(void) return result; } -int DetectFastPatternTest316(void) +static int DetectFastPatternTest316(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -8673,7 +8673,7 @@ int DetectFastPatternTest316(void) return result; } -int DetectFastPatternTest317(void) +static int DetectFastPatternTest317(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -8703,7 +8703,7 @@ int DetectFastPatternTest317(void) return result; } -int DetectFastPatternTest318(void) +static int DetectFastPatternTest318(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -8733,7 +8733,7 @@ int DetectFastPatternTest318(void) return result; } -int DetectFastPatternTest319(void) +static int DetectFastPatternTest319(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -8763,7 +8763,7 @@ int DetectFastPatternTest319(void) return result; } -int DetectFastPatternTest320(void) +static int DetectFastPatternTest320(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -8794,7 +8794,7 @@ int DetectFastPatternTest320(void) return result; } -int DetectFastPatternTest321(void) +static int DetectFastPatternTest321(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -8816,7 +8816,7 @@ int DetectFastPatternTest321(void) return result; } -int DetectFastPatternTest322(void) +static int DetectFastPatternTest322(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -8838,7 +8838,7 @@ int DetectFastPatternTest322(void) return result; } -int DetectFastPatternTest323(void) +static int DetectFastPatternTest323(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -8860,7 +8860,7 @@ int DetectFastPatternTest323(void) return result; } -int DetectFastPatternTest324(void) +static int DetectFastPatternTest324(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -8882,7 +8882,7 @@ int DetectFastPatternTest324(void) return result; } -int DetectFastPatternTest325(void) +static int DetectFastPatternTest325(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -8912,7 +8912,7 @@ int DetectFastPatternTest325(void) return result; } -int DetectFastPatternTest326(void) +static int DetectFastPatternTest326(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -8942,7 +8942,7 @@ int DetectFastPatternTest326(void) return result; } -int DetectFastPatternTest327(void) +static int DetectFastPatternTest327(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -8972,7 +8972,7 @@ int DetectFastPatternTest327(void) return result; } -int DetectFastPatternTest328(void) +static int DetectFastPatternTest328(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -9002,7 +9002,7 @@ int DetectFastPatternTest328(void) return result; } -int DetectFastPatternTest329(void) +static int DetectFastPatternTest329(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -9032,7 +9032,7 @@ int DetectFastPatternTest329(void) return result; } -int DetectFastPatternTest330(void) +static int DetectFastPatternTest330(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -9062,7 +9062,7 @@ int DetectFastPatternTest330(void) return result; } -int DetectFastPatternTest331(void) +static int DetectFastPatternTest331(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -9092,7 +9092,7 @@ int DetectFastPatternTest331(void) return result; } -int DetectFastPatternTest332(void) +static int DetectFastPatternTest332(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -9122,7 +9122,7 @@ int DetectFastPatternTest332(void) return result; } -int DetectFastPatternTest333(void) +static int DetectFastPatternTest333(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -9155,7 +9155,7 @@ int DetectFastPatternTest333(void) return result; } -int DetectFastPatternTest334(void) +static int DetectFastPatternTest334(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -9177,7 +9177,7 @@ int DetectFastPatternTest334(void) return result; } -int DetectFastPatternTest335(void) +static int DetectFastPatternTest335(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -9199,7 +9199,7 @@ int DetectFastPatternTest335(void) return result; } -int DetectFastPatternTest336(void) +static int DetectFastPatternTest336(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -9221,7 +9221,7 @@ int DetectFastPatternTest336(void) return result; } -int DetectFastPatternTest337(void) +static int DetectFastPatternTest337(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -9252,7 +9252,7 @@ int DetectFastPatternTest337(void) return result; } -int DetectFastPatternTest338(void) +static int DetectFastPatternTest338(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -9274,7 +9274,7 @@ int DetectFastPatternTest338(void) return result; } -int DetectFastPatternTest339(void) +static int DetectFastPatternTest339(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -9296,7 +9296,7 @@ int DetectFastPatternTest339(void) return result; } -int DetectFastPatternTest340(void) +static int DetectFastPatternTest340(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -9318,7 +9318,7 @@ int DetectFastPatternTest340(void) return result; } -int DetectFastPatternTest341(void) +static int DetectFastPatternTest341(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -9340,7 +9340,7 @@ int DetectFastPatternTest341(void) return result; } -int DetectFastPatternTest342(void) +static int DetectFastPatternTest342(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -9376,7 +9376,7 @@ int DetectFastPatternTest342(void) /* http_raw_uri fast_pattern tests v */ -int DetectFastPatternTest343(void) +static int DetectFastPatternTest343(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -9412,7 +9412,7 @@ int DetectFastPatternTest343(void) /** * \test Checks if a fast_pattern is registered in a Signature for uricontent. */ -int DetectFastPatternTest344(void) +static int DetectFastPatternTest344(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -9449,7 +9449,7 @@ int DetectFastPatternTest344(void) /** * \test Checks if a fast_pattern is registered in a Signature for uricontent. */ -int DetectFastPatternTest345(void) +static int DetectFastPatternTest345(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -9482,7 +9482,7 @@ int DetectFastPatternTest345(void) return result; } -int DetectFastPatternTest346(void) +static int DetectFastPatternTest346(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -9516,7 +9516,7 @@ int DetectFastPatternTest346(void) return result; } -int DetectFastPatternTest347(void) +static int DetectFastPatternTest347(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -9550,7 +9550,7 @@ int DetectFastPatternTest347(void) return result; } -int DetectFastPatternTest348(void) +static int DetectFastPatternTest348(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -9573,7 +9573,7 @@ int DetectFastPatternTest348(void) return result; } -int DetectFastPatternTest349(void) +static int DetectFastPatternTest349(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -9596,7 +9596,7 @@ int DetectFastPatternTest349(void) return result; } -int DetectFastPatternTest350(void) +static int DetectFastPatternTest350(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -9619,7 +9619,7 @@ int DetectFastPatternTest350(void) return result; } -int DetectFastPatternTest351(void) +static int DetectFastPatternTest351(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -9642,7 +9642,7 @@ int DetectFastPatternTest351(void) return result; } -int DetectFastPatternTest352(void) +static int DetectFastPatternTest352(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -9665,7 +9665,7 @@ int DetectFastPatternTest352(void) return result; } -int DetectFastPatternTest353(void) +static int DetectFastPatternTest353(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -9688,7 +9688,7 @@ int DetectFastPatternTest353(void) return result; } -int DetectFastPatternTest354(void) +static int DetectFastPatternTest354(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -9711,7 +9711,7 @@ int DetectFastPatternTest354(void) return result; } -int DetectFastPatternTest355(void) +static int DetectFastPatternTest355(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -9734,7 +9734,7 @@ int DetectFastPatternTest355(void) return result; } -int DetectFastPatternTest356(void) +static int DetectFastPatternTest356(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -9757,7 +9757,7 @@ int DetectFastPatternTest356(void) return result; } -int DetectFastPatternTest357(void) +static int DetectFastPatternTest357(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -9790,7 +9790,7 @@ int DetectFastPatternTest357(void) return result; } -int DetectFastPatternTest358(void) +static int DetectFastPatternTest358(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -9822,7 +9822,7 @@ int DetectFastPatternTest358(void) return result; } -int DetectFastPatternTest359(void) +static int DetectFastPatternTest359(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -9854,7 +9854,7 @@ int DetectFastPatternTest359(void) return result; } -int DetectFastPatternTest360(void) +static int DetectFastPatternTest360(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -9886,7 +9886,7 @@ int DetectFastPatternTest360(void) return result; } -int DetectFastPatternTest361(void) +static int DetectFastPatternTest361(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -9918,7 +9918,7 @@ int DetectFastPatternTest361(void) return result; } -int DetectFastPatternTest362(void) +static int DetectFastPatternTest362(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -9941,7 +9941,7 @@ int DetectFastPatternTest362(void) return result; } -int DetectFastPatternTest363(void) +static int DetectFastPatternTest363(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -9964,7 +9964,7 @@ int DetectFastPatternTest363(void) return result; } -int DetectFastPatternTest364(void) +static int DetectFastPatternTest364(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -9987,7 +9987,7 @@ int DetectFastPatternTest364(void) return result; } -int DetectFastPatternTest365(void) +static int DetectFastPatternTest365(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -10010,7 +10010,7 @@ int DetectFastPatternTest365(void) return result; } -int DetectFastPatternTest366(void) +static int DetectFastPatternTest366(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -10042,7 +10042,7 @@ int DetectFastPatternTest366(void) return result; } -int DetectFastPatternTest367(void) +static int DetectFastPatternTest367(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -10074,7 +10074,7 @@ int DetectFastPatternTest367(void) return result; } -int DetectFastPatternTest368(void) +static int DetectFastPatternTest368(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -10106,7 +10106,7 @@ int DetectFastPatternTest368(void) return result; } -int DetectFastPatternTest369(void) +static int DetectFastPatternTest369(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -10138,7 +10138,7 @@ int DetectFastPatternTest369(void) return result; } -int DetectFastPatternTest370(void) +static int DetectFastPatternTest370(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -10170,7 +10170,7 @@ int DetectFastPatternTest370(void) return result; } -int DetectFastPatternTest371(void) +static int DetectFastPatternTest371(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -10202,7 +10202,7 @@ int DetectFastPatternTest371(void) return result; } -int DetectFastPatternTest372(void) +static int DetectFastPatternTest372(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -10234,7 +10234,7 @@ int DetectFastPatternTest372(void) return result; } -int DetectFastPatternTest373(void) +static int DetectFastPatternTest373(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -10266,7 +10266,7 @@ int DetectFastPatternTest373(void) return result; } -int DetectFastPatternTest374(void) +static int DetectFastPatternTest374(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -10301,7 +10301,7 @@ int DetectFastPatternTest374(void) return result; } -int DetectFastPatternTest375(void) +static int DetectFastPatternTest375(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -10325,7 +10325,7 @@ int DetectFastPatternTest375(void) return result; } -int DetectFastPatternTest376(void) +static int DetectFastPatternTest376(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -10349,7 +10349,7 @@ int DetectFastPatternTest376(void) return result; } -int DetectFastPatternTest377(void) +static int DetectFastPatternTest377(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -10373,7 +10373,7 @@ int DetectFastPatternTest377(void) return result; } -int DetectFastPatternTest378(void) +static int DetectFastPatternTest378(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -10406,7 +10406,7 @@ int DetectFastPatternTest378(void) return result; } -int DetectFastPatternTest379(void) +static int DetectFastPatternTest379(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -10430,7 +10430,7 @@ int DetectFastPatternTest379(void) return result; } -int DetectFastPatternTest380(void) +static int DetectFastPatternTest380(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -10454,7 +10454,7 @@ int DetectFastPatternTest380(void) return result; } -int DetectFastPatternTest381(void) +static int DetectFastPatternTest381(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -10478,7 +10478,7 @@ int DetectFastPatternTest381(void) return result; } -int DetectFastPatternTest382(void) +static int DetectFastPatternTest382(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -10502,7 +10502,7 @@ int DetectFastPatternTest382(void) return result; } -int DetectFastPatternTest383(void) +static int DetectFastPatternTest383(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -10540,7 +10540,7 @@ int DetectFastPatternTest383(void) /* http_stat_msg fast_pattern tests v */ -int DetectFastPatternTest384(void) +static int DetectFastPatternTest384(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -10576,7 +10576,7 @@ int DetectFastPatternTest384(void) /** * \test Checks if a fast_pattern is registered in a Signature for uricontent. */ -int DetectFastPatternTest385(void) +static int DetectFastPatternTest385(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -10613,7 +10613,7 @@ int DetectFastPatternTest385(void) /** * \test Checks if a fast_pattern is registered in a Signature for uricontent. */ -int DetectFastPatternTest386(void) +static int DetectFastPatternTest386(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -10646,7 +10646,7 @@ int DetectFastPatternTest386(void) return result; } -int DetectFastPatternTest387(void) +static int DetectFastPatternTest387(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -10682,7 +10682,7 @@ int DetectFastPatternTest387(void) return result; } -int DetectFastPatternTest388(void) +static int DetectFastPatternTest388(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -10719,7 +10719,7 @@ int DetectFastPatternTest388(void) return result; } -int DetectFastPatternTest389(void) +static int DetectFastPatternTest389(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -10742,7 +10742,7 @@ int DetectFastPatternTest389(void) return result; } -int DetectFastPatternTest390(void) +static int DetectFastPatternTest390(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -10765,7 +10765,7 @@ int DetectFastPatternTest390(void) return result; } -int DetectFastPatternTest391(void) +static int DetectFastPatternTest391(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -10788,7 +10788,7 @@ int DetectFastPatternTest391(void) return result; } -int DetectFastPatternTest392(void) +static int DetectFastPatternTest392(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -10811,7 +10811,7 @@ int DetectFastPatternTest392(void) return result; } -int DetectFastPatternTest393(void) +static int DetectFastPatternTest393(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -10834,7 +10834,7 @@ int DetectFastPatternTest393(void) return result; } -int DetectFastPatternTest394(void) +static int DetectFastPatternTest394(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -10857,7 +10857,7 @@ int DetectFastPatternTest394(void) return result; } -int DetectFastPatternTest395(void) +static int DetectFastPatternTest395(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -10880,7 +10880,7 @@ int DetectFastPatternTest395(void) return result; } -int DetectFastPatternTest396(void) +static int DetectFastPatternTest396(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -10903,7 +10903,7 @@ int DetectFastPatternTest396(void) return result; } -int DetectFastPatternTest397(void) +static int DetectFastPatternTest397(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -10926,7 +10926,7 @@ int DetectFastPatternTest397(void) return result; } -int DetectFastPatternTest398(void) +static int DetectFastPatternTest398(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -10959,7 +10959,7 @@ int DetectFastPatternTest398(void) return result; } -int DetectFastPatternTest399(void) +static int DetectFastPatternTest399(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -10991,7 +10991,7 @@ int DetectFastPatternTest399(void) return result; } -int DetectFastPatternTest400(void) +static int DetectFastPatternTest400(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -11023,7 +11023,7 @@ int DetectFastPatternTest400(void) return result; } -int DetectFastPatternTest401(void) +static int DetectFastPatternTest401(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -11055,7 +11055,7 @@ int DetectFastPatternTest401(void) return result; } -int DetectFastPatternTest402(void) +static int DetectFastPatternTest402(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -11087,7 +11087,7 @@ int DetectFastPatternTest402(void) return result; } -int DetectFastPatternTest403(void) +static int DetectFastPatternTest403(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -11110,7 +11110,7 @@ int DetectFastPatternTest403(void) return result; } -int DetectFastPatternTest404(void) +static int DetectFastPatternTest404(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -11133,7 +11133,7 @@ int DetectFastPatternTest404(void) return result; } -int DetectFastPatternTest405(void) +static int DetectFastPatternTest405(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -11156,7 +11156,7 @@ int DetectFastPatternTest405(void) return result; } -int DetectFastPatternTest406(void) +static int DetectFastPatternTest406(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -11179,7 +11179,7 @@ int DetectFastPatternTest406(void) return result; } -int DetectFastPatternTest407(void) +static int DetectFastPatternTest407(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -11211,7 +11211,7 @@ int DetectFastPatternTest407(void) return result; } -int DetectFastPatternTest408(void) +static int DetectFastPatternTest408(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -11243,7 +11243,7 @@ int DetectFastPatternTest408(void) return result; } -int DetectFastPatternTest409(void) +static int DetectFastPatternTest409(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -11275,7 +11275,7 @@ int DetectFastPatternTest409(void) return result; } -int DetectFastPatternTest410(void) +static int DetectFastPatternTest410(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -11307,7 +11307,7 @@ int DetectFastPatternTest410(void) return result; } -int DetectFastPatternTest411(void) +static int DetectFastPatternTest411(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -11339,7 +11339,7 @@ int DetectFastPatternTest411(void) return result; } -int DetectFastPatternTest412(void) +static int DetectFastPatternTest412(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -11371,7 +11371,7 @@ int DetectFastPatternTest412(void) return result; } -int DetectFastPatternTest413(void) +static int DetectFastPatternTest413(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -11403,7 +11403,7 @@ int DetectFastPatternTest413(void) return result; } -int DetectFastPatternTest414(void) +static int DetectFastPatternTest414(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -11435,7 +11435,7 @@ int DetectFastPatternTest414(void) return result; } -int DetectFastPatternTest415(void) +static int DetectFastPatternTest415(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -11470,7 +11470,7 @@ int DetectFastPatternTest415(void) return result; } -int DetectFastPatternTest416(void) +static int DetectFastPatternTest416(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -11494,7 +11494,7 @@ int DetectFastPatternTest416(void) return result; } -int DetectFastPatternTest417(void) +static int DetectFastPatternTest417(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -11518,7 +11518,7 @@ int DetectFastPatternTest417(void) return result; } -int DetectFastPatternTest418(void) +static int DetectFastPatternTest418(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -11542,7 +11542,7 @@ int DetectFastPatternTest418(void) return result; } -int DetectFastPatternTest419(void) +static int DetectFastPatternTest419(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -11575,7 +11575,7 @@ int DetectFastPatternTest419(void) return result; } -int DetectFastPatternTest420(void) +static int DetectFastPatternTest420(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -11599,7 +11599,7 @@ int DetectFastPatternTest420(void) return result; } -int DetectFastPatternTest421(void) +static int DetectFastPatternTest421(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -11623,7 +11623,7 @@ int DetectFastPatternTest421(void) return result; } -int DetectFastPatternTest422(void) +static int DetectFastPatternTest422(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -11647,7 +11647,7 @@ int DetectFastPatternTest422(void) return result; } -int DetectFastPatternTest423(void) +static int DetectFastPatternTest423(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -11671,7 +11671,7 @@ int DetectFastPatternTest423(void) return result; } -int DetectFastPatternTest424(void) +static int DetectFastPatternTest424(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -11709,7 +11709,7 @@ int DetectFastPatternTest424(void) /* http_stat_code fast_pattern tests v */ -int DetectFastPatternTest425(void) +static int DetectFastPatternTest425(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -11745,7 +11745,7 @@ int DetectFastPatternTest425(void) /** * \test Checks if a fast_pattern is registered in a Signature for uricontent. */ -int DetectFastPatternTest426(void) +static int DetectFastPatternTest426(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -11782,7 +11782,7 @@ int DetectFastPatternTest426(void) /** * \test Checks if a fast_pattern is registered in a Signature for uricontent. */ -int DetectFastPatternTest427(void) +static int DetectFastPatternTest427(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -11815,7 +11815,7 @@ int DetectFastPatternTest427(void) return result; } -int DetectFastPatternTest428(void) +static int DetectFastPatternTest428(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -11852,7 +11852,7 @@ int DetectFastPatternTest428(void) return result; } -int DetectFastPatternTest429(void) +static int DetectFastPatternTest429(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -11889,7 +11889,7 @@ int DetectFastPatternTest429(void) return result; } -int DetectFastPatternTest430(void) +static int DetectFastPatternTest430(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -11912,7 +11912,7 @@ int DetectFastPatternTest430(void) return result; } -int DetectFastPatternTest431(void) +static int DetectFastPatternTest431(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -11935,7 +11935,7 @@ int DetectFastPatternTest431(void) return result; } -int DetectFastPatternTest432(void) +static int DetectFastPatternTest432(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -11958,7 +11958,7 @@ int DetectFastPatternTest432(void) return result; } -int DetectFastPatternTest433(void) +static int DetectFastPatternTest433(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -11981,7 +11981,7 @@ int DetectFastPatternTest433(void) return result; } -int DetectFastPatternTest434(void) +static int DetectFastPatternTest434(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -12004,7 +12004,7 @@ int DetectFastPatternTest434(void) return result; } -int DetectFastPatternTest435(void) +static int DetectFastPatternTest435(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -12027,7 +12027,7 @@ int DetectFastPatternTest435(void) return result; } -int DetectFastPatternTest436(void) +static int DetectFastPatternTest436(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -12050,7 +12050,7 @@ int DetectFastPatternTest436(void) return result; } -int DetectFastPatternTest437(void) +static int DetectFastPatternTest437(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -12073,7 +12073,7 @@ int DetectFastPatternTest437(void) return result; } -int DetectFastPatternTest438(void) +static int DetectFastPatternTest438(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -12096,7 +12096,7 @@ int DetectFastPatternTest438(void) return result; } -int DetectFastPatternTest439(void) +static int DetectFastPatternTest439(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -12129,7 +12129,7 @@ int DetectFastPatternTest439(void) return result; } -int DetectFastPatternTest440(void) +static int DetectFastPatternTest440(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -12161,7 +12161,7 @@ int DetectFastPatternTest440(void) return result; } -int DetectFastPatternTest441(void) +static int DetectFastPatternTest441(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -12193,7 +12193,7 @@ int DetectFastPatternTest441(void) return result; } -int DetectFastPatternTest442(void) +static int DetectFastPatternTest442(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -12225,7 +12225,7 @@ int DetectFastPatternTest442(void) return result; } -int DetectFastPatternTest443(void) +static int DetectFastPatternTest443(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -12257,7 +12257,7 @@ int DetectFastPatternTest443(void) return result; } -int DetectFastPatternTest444(void) +static int DetectFastPatternTest444(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -12280,7 +12280,7 @@ int DetectFastPatternTest444(void) return result; } -int DetectFastPatternTest445(void) +static int DetectFastPatternTest445(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -12303,7 +12303,7 @@ int DetectFastPatternTest445(void) return result; } -int DetectFastPatternTest446(void) +static int DetectFastPatternTest446(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -12326,7 +12326,7 @@ int DetectFastPatternTest446(void) return result; } -int DetectFastPatternTest447(void) +static int DetectFastPatternTest447(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -12349,7 +12349,7 @@ int DetectFastPatternTest447(void) return result; } -int DetectFastPatternTest448(void) +static int DetectFastPatternTest448(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -12381,7 +12381,7 @@ int DetectFastPatternTest448(void) return result; } -int DetectFastPatternTest449(void) +static int DetectFastPatternTest449(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -12413,7 +12413,7 @@ int DetectFastPatternTest449(void) return result; } -int DetectFastPatternTest450(void) +static int DetectFastPatternTest450(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -12445,7 +12445,7 @@ int DetectFastPatternTest450(void) return result; } -int DetectFastPatternTest451(void) +static int DetectFastPatternTest451(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -12477,7 +12477,7 @@ int DetectFastPatternTest451(void) return result; } -int DetectFastPatternTest452(void) +static int DetectFastPatternTest452(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -12509,7 +12509,7 @@ int DetectFastPatternTest452(void) return result; } -int DetectFastPatternTest453(void) +static int DetectFastPatternTest453(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -12541,7 +12541,7 @@ int DetectFastPatternTest453(void) return result; } -int DetectFastPatternTest454(void) +static int DetectFastPatternTest454(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -12573,7 +12573,7 @@ int DetectFastPatternTest454(void) return result; } -int DetectFastPatternTest455(void) +static int DetectFastPatternTest455(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -12605,7 +12605,7 @@ int DetectFastPatternTest455(void) return result; } -int DetectFastPatternTest456(void) +static int DetectFastPatternTest456(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -12640,7 +12640,7 @@ int DetectFastPatternTest456(void) return result; } -int DetectFastPatternTest457(void) +static int DetectFastPatternTest457(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -12664,7 +12664,7 @@ int DetectFastPatternTest457(void) return result; } -int DetectFastPatternTest458(void) +static int DetectFastPatternTest458(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -12688,7 +12688,7 @@ int DetectFastPatternTest458(void) return result; } -int DetectFastPatternTest459(void) +static int DetectFastPatternTest459(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -12712,7 +12712,7 @@ int DetectFastPatternTest459(void) return result; } -int DetectFastPatternTest460(void) +static int DetectFastPatternTest460(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -12745,7 +12745,7 @@ int DetectFastPatternTest460(void) return result; } -int DetectFastPatternTest461(void) +static int DetectFastPatternTest461(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -12769,7 +12769,7 @@ int DetectFastPatternTest461(void) return result; } -int DetectFastPatternTest462(void) +static int DetectFastPatternTest462(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -12793,7 +12793,7 @@ int DetectFastPatternTest462(void) return result; } -int DetectFastPatternTest463(void) +static int DetectFastPatternTest463(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -12817,7 +12817,7 @@ int DetectFastPatternTest463(void) return result; } -int DetectFastPatternTest464(void) +static int DetectFastPatternTest464(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -12841,7 +12841,7 @@ int DetectFastPatternTest464(void) return result; } -int DetectFastPatternTest465(void) +static int DetectFastPatternTest465(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -12879,7 +12879,7 @@ int DetectFastPatternTest465(void) /* http_server_body fast_pattern tests v */ -int DetectFastPatternTest466(void) +static int DetectFastPatternTest466(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -12916,7 +12916,7 @@ int DetectFastPatternTest466(void) /** * \test Checks if a fast_pattern is registered in a Signature for uricontent. */ -int DetectFastPatternTest467(void) +static int DetectFastPatternTest467(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -12953,7 +12953,7 @@ int DetectFastPatternTest467(void) /** * \test Checks if a fast_pattern is registered in a Signature for uricontent. */ -int DetectFastPatternTest468(void) +static int DetectFastPatternTest468(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -12986,7 +12986,7 @@ int DetectFastPatternTest468(void) return result; } -int DetectFastPatternTest469(void) +static int DetectFastPatternTest469(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -13022,7 +13022,7 @@ int DetectFastPatternTest469(void) return result; } -int DetectFastPatternTest470(void) +static int DetectFastPatternTest470(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -13059,7 +13059,7 @@ int DetectFastPatternTest470(void) return result; } -int DetectFastPatternTest471(void) +static int DetectFastPatternTest471(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -13082,7 +13082,7 @@ int DetectFastPatternTest471(void) return result; } -int DetectFastPatternTest472(void) +static int DetectFastPatternTest472(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -13105,7 +13105,7 @@ int DetectFastPatternTest472(void) return result; } -int DetectFastPatternTest473(void) +static int DetectFastPatternTest473(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -13128,7 +13128,7 @@ int DetectFastPatternTest473(void) return result; } -int DetectFastPatternTest474(void) +static int DetectFastPatternTest474(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -13151,7 +13151,7 @@ int DetectFastPatternTest474(void) return result; } -int DetectFastPatternTest475(void) +static int DetectFastPatternTest475(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -13174,7 +13174,7 @@ int DetectFastPatternTest475(void) return result; } -int DetectFastPatternTest476(void) +static int DetectFastPatternTest476(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -13197,7 +13197,7 @@ int DetectFastPatternTest476(void) return result; } -int DetectFastPatternTest477(void) +static int DetectFastPatternTest477(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -13220,7 +13220,7 @@ int DetectFastPatternTest477(void) return result; } -int DetectFastPatternTest478(void) +static int DetectFastPatternTest478(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -13243,7 +13243,7 @@ int DetectFastPatternTest478(void) return result; } -int DetectFastPatternTest479(void) +static int DetectFastPatternTest479(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -13266,7 +13266,7 @@ int DetectFastPatternTest479(void) return result; } -int DetectFastPatternTest480(void) +static int DetectFastPatternTest480(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -13299,7 +13299,7 @@ int DetectFastPatternTest480(void) return result; } -int DetectFastPatternTest481(void) +static int DetectFastPatternTest481(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -13332,7 +13332,7 @@ int DetectFastPatternTest481(void) return result; } -int DetectFastPatternTest482(void) +static int DetectFastPatternTest482(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -13365,7 +13365,7 @@ int DetectFastPatternTest482(void) return result; } -int DetectFastPatternTest483(void) +static int DetectFastPatternTest483(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -13398,7 +13398,7 @@ int DetectFastPatternTest483(void) return result; } -int DetectFastPatternTest484(void) +static int DetectFastPatternTest484(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -13431,7 +13431,7 @@ int DetectFastPatternTest484(void) return result; } -int DetectFastPatternTest485(void) +static int DetectFastPatternTest485(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -13454,7 +13454,7 @@ int DetectFastPatternTest485(void) return result; } -int DetectFastPatternTest486(void) +static int DetectFastPatternTest486(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -13477,7 +13477,7 @@ int DetectFastPatternTest486(void) return result; } -int DetectFastPatternTest487(void) +static int DetectFastPatternTest487(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -13500,7 +13500,7 @@ int DetectFastPatternTest487(void) return result; } -int DetectFastPatternTest488(void) +static int DetectFastPatternTest488(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -13523,7 +13523,7 @@ int DetectFastPatternTest488(void) return result; } -int DetectFastPatternTest489(void) +static int DetectFastPatternTest489(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -13556,7 +13556,7 @@ int DetectFastPatternTest489(void) return result; } -int DetectFastPatternTest490(void) +static int DetectFastPatternTest490(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -13589,7 +13589,7 @@ int DetectFastPatternTest490(void) return result; } -int DetectFastPatternTest491(void) +static int DetectFastPatternTest491(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -13622,7 +13622,7 @@ int DetectFastPatternTest491(void) return result; } -int DetectFastPatternTest492(void) +static int DetectFastPatternTest492(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -13655,7 +13655,7 @@ int DetectFastPatternTest492(void) return result; } -int DetectFastPatternTest493(void) +static int DetectFastPatternTest493(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -13688,7 +13688,7 @@ int DetectFastPatternTest493(void) return result; } -int DetectFastPatternTest494(void) +static int DetectFastPatternTest494(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -13721,7 +13721,7 @@ int DetectFastPatternTest494(void) return result; } -int DetectFastPatternTest495(void) +static int DetectFastPatternTest495(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -13754,7 +13754,7 @@ int DetectFastPatternTest495(void) return result; } -int DetectFastPatternTest496(void) +static int DetectFastPatternTest496(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -13787,7 +13787,7 @@ int DetectFastPatternTest496(void) return result; } -int DetectFastPatternTest497(void) +static int DetectFastPatternTest497(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -13823,7 +13823,7 @@ int DetectFastPatternTest497(void) return result; } -int DetectFastPatternTest498(void) +static int DetectFastPatternTest498(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -13847,7 +13847,7 @@ int DetectFastPatternTest498(void) return result; } -int DetectFastPatternTest499(void) +static int DetectFastPatternTest499(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -13871,7 +13871,7 @@ int DetectFastPatternTest499(void) return result; } -int DetectFastPatternTest500(void) +static int DetectFastPatternTest500(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -13895,7 +13895,7 @@ int DetectFastPatternTest500(void) return result; } -int DetectFastPatternTest501(void) +static int DetectFastPatternTest501(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -13929,7 +13929,7 @@ int DetectFastPatternTest501(void) return result; } -int DetectFastPatternTest502(void) +static int DetectFastPatternTest502(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -13953,7 +13953,7 @@ int DetectFastPatternTest502(void) return result; } -int DetectFastPatternTest503(void) +static int DetectFastPatternTest503(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -13977,7 +13977,7 @@ int DetectFastPatternTest503(void) return result; } -int DetectFastPatternTest504(void) +static int DetectFastPatternTest504(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -14001,7 +14001,7 @@ int DetectFastPatternTest504(void) return result; } -int DetectFastPatternTest505(void) +static int DetectFastPatternTest505(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -14025,7 +14025,7 @@ int DetectFastPatternTest505(void) return result; } -int DetectFastPatternTest506(void) +static int DetectFastPatternTest506(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -14084,7 +14084,7 @@ static int DetectFastPatternTest507(void) /** * \test Checks if a fast_pattern is registered in a Signature for uricontent. */ -int DetectFastPatternTest508(void) +static int DetectFastPatternTest508(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -14121,7 +14121,7 @@ int DetectFastPatternTest508(void) /** * \test Checks if a fast_pattern is registered in a Signature for uricontent. */ -int DetectFastPatternTest509(void) +static int DetectFastPatternTest509(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -14154,7 +14154,7 @@ int DetectFastPatternTest509(void) return result; } -int DetectFastPatternTest510(void) +static int DetectFastPatternTest510(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -14190,7 +14190,7 @@ int DetectFastPatternTest510(void) return result; } -int DetectFastPatternTest511(void) +static int DetectFastPatternTest511(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -14227,7 +14227,7 @@ int DetectFastPatternTest511(void) return result; } -int DetectFastPatternTest512(void) +static int DetectFastPatternTest512(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -14250,7 +14250,7 @@ int DetectFastPatternTest512(void) return result; } -int DetectFastPatternTest513(void) +static int DetectFastPatternTest513(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -14273,7 +14273,7 @@ int DetectFastPatternTest513(void) return result; } -int DetectFastPatternTest514(void) +static int DetectFastPatternTest514(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -14296,7 +14296,7 @@ int DetectFastPatternTest514(void) return result; } -int DetectFastPatternTest515(void) +static int DetectFastPatternTest515(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -14319,7 +14319,7 @@ int DetectFastPatternTest515(void) return result; } -int DetectFastPatternTest516(void) +static int DetectFastPatternTest516(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -14342,7 +14342,7 @@ int DetectFastPatternTest516(void) return result; } -int DetectFastPatternTest517(void) +static int DetectFastPatternTest517(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -14365,7 +14365,7 @@ int DetectFastPatternTest517(void) return result; } -int DetectFastPatternTest518(void) +static int DetectFastPatternTest518(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -14388,7 +14388,7 @@ int DetectFastPatternTest518(void) return result; } -int DetectFastPatternTest519(void) +static int DetectFastPatternTest519(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -14411,7 +14411,7 @@ int DetectFastPatternTest519(void) return result; } -int DetectFastPatternTest520(void) +static int DetectFastPatternTest520(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -14434,7 +14434,7 @@ int DetectFastPatternTest520(void) return result; } -int DetectFastPatternTest521(void) +static int DetectFastPatternTest521(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -14467,7 +14467,7 @@ int DetectFastPatternTest521(void) return result; } -int DetectFastPatternTest522(void) +static int DetectFastPatternTest522(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -14500,7 +14500,7 @@ int DetectFastPatternTest522(void) return result; } -int DetectFastPatternTest523(void) +static int DetectFastPatternTest523(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -14533,7 +14533,7 @@ int DetectFastPatternTest523(void) return result; } -int DetectFastPatternTest524(void) +static int DetectFastPatternTest524(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -14566,7 +14566,7 @@ int DetectFastPatternTest524(void) return result; } -int DetectFastPatternTest525(void) +static int DetectFastPatternTest525(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -14599,7 +14599,7 @@ int DetectFastPatternTest525(void) return result; } -int DetectFastPatternTest526(void) +static int DetectFastPatternTest526(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -14622,7 +14622,7 @@ int DetectFastPatternTest526(void) return result; } -int DetectFastPatternTest527(void) +static int DetectFastPatternTest527(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -14645,7 +14645,7 @@ int DetectFastPatternTest527(void) return result; } -int DetectFastPatternTest528(void) +static int DetectFastPatternTest528(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -14668,7 +14668,7 @@ int DetectFastPatternTest528(void) return result; } -int DetectFastPatternTest529(void) +static int DetectFastPatternTest529(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -14691,7 +14691,7 @@ int DetectFastPatternTest529(void) return result; } -int DetectFastPatternTest530(void) +static int DetectFastPatternTest530(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -14724,7 +14724,7 @@ int DetectFastPatternTest530(void) return result; } -int DetectFastPatternTest531(void) +static int DetectFastPatternTest531(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -14757,7 +14757,7 @@ int DetectFastPatternTest531(void) return result; } -int DetectFastPatternTest532(void) +static int DetectFastPatternTest532(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -14790,7 +14790,7 @@ int DetectFastPatternTest532(void) return result; } -int DetectFastPatternTest533(void) +static int DetectFastPatternTest533(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -14823,7 +14823,7 @@ int DetectFastPatternTest533(void) return result; } -int DetectFastPatternTest534(void) +static int DetectFastPatternTest534(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -14856,7 +14856,7 @@ int DetectFastPatternTest534(void) return result; } -int DetectFastPatternTest535(void) +static int DetectFastPatternTest535(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -14889,7 +14889,7 @@ int DetectFastPatternTest535(void) return result; } -int DetectFastPatternTest536(void) +static int DetectFastPatternTest536(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -14922,7 +14922,7 @@ int DetectFastPatternTest536(void) return result; } -int DetectFastPatternTest537(void) +static int DetectFastPatternTest537(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -14955,7 +14955,7 @@ int DetectFastPatternTest537(void) return result; } -int DetectFastPatternTest538(void) +static int DetectFastPatternTest538(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -14991,7 +14991,7 @@ int DetectFastPatternTest538(void) return result; } -int DetectFastPatternTest539(void) +static int DetectFastPatternTest539(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -15015,7 +15015,7 @@ int DetectFastPatternTest539(void) return result; } -int DetectFastPatternTest540(void) +static int DetectFastPatternTest540(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -15039,7 +15039,7 @@ int DetectFastPatternTest540(void) return result; } -int DetectFastPatternTest541(void) +static int DetectFastPatternTest541(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -15063,7 +15063,7 @@ int DetectFastPatternTest541(void) return result; } -int DetectFastPatternTest542(void) +static int DetectFastPatternTest542(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -15097,7 +15097,7 @@ int DetectFastPatternTest542(void) return result; } -int DetectFastPatternTest543(void) +static int DetectFastPatternTest543(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -15121,7 +15121,7 @@ int DetectFastPatternTest543(void) return result; } -int DetectFastPatternTest544(void) +static int DetectFastPatternTest544(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -15145,7 +15145,7 @@ int DetectFastPatternTest544(void) return result; } -int DetectFastPatternTest545(void) +static int DetectFastPatternTest545(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -15169,7 +15169,7 @@ int DetectFastPatternTest545(void) return result; } -int DetectFastPatternTest546(void) +static int DetectFastPatternTest546(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -15193,7 +15193,7 @@ int DetectFastPatternTest546(void) return result; } -int DetectFastPatternTest547(void) +static int DetectFastPatternTest547(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -15232,7 +15232,7 @@ int DetectFastPatternTest547(void) /* http_user_agent fast_pattern tests v */ -int DetectFastPatternTest548(void) +static int DetectFastPatternTest548(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -15269,7 +15269,7 @@ int DetectFastPatternTest548(void) /** * \test Checks if a fast_pattern is registered in a Signature for uricontent. */ -int DetectFastPatternTest549(void) +static int DetectFastPatternTest549(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -15306,7 +15306,7 @@ int DetectFastPatternTest549(void) /** * \test Checks if a fast_pattern is registered in a Signature for uricontent. */ -int DetectFastPatternTest550(void) +static int DetectFastPatternTest550(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -15339,7 +15339,7 @@ int DetectFastPatternTest550(void) return result; } -int DetectFastPatternTest551(void) +static int DetectFastPatternTest551(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -15375,7 +15375,7 @@ int DetectFastPatternTest551(void) return result; } -int DetectFastPatternTest552(void) +static int DetectFastPatternTest552(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -15412,7 +15412,7 @@ int DetectFastPatternTest552(void) return result; } -int DetectFastPatternTest553(void) +static int DetectFastPatternTest553(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -15435,7 +15435,7 @@ int DetectFastPatternTest553(void) return result; } -int DetectFastPatternTest554(void) +static int DetectFastPatternTest554(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -15458,7 +15458,7 @@ int DetectFastPatternTest554(void) return result; } -int DetectFastPatternTest555(void) +static int DetectFastPatternTest555(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -15481,7 +15481,7 @@ int DetectFastPatternTest555(void) return result; } -int DetectFastPatternTest556(void) +static int DetectFastPatternTest556(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -15504,7 +15504,7 @@ int DetectFastPatternTest556(void) return result; } -int DetectFastPatternTest557(void) +static int DetectFastPatternTest557(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -15527,7 +15527,7 @@ int DetectFastPatternTest557(void) return result; } -int DetectFastPatternTest558(void) +static int DetectFastPatternTest558(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -15550,7 +15550,7 @@ int DetectFastPatternTest558(void) return result; } -int DetectFastPatternTest559(void) +static int DetectFastPatternTest559(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -15573,7 +15573,7 @@ int DetectFastPatternTest559(void) return result; } -int DetectFastPatternTest560(void) +static int DetectFastPatternTest560(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -15596,7 +15596,7 @@ int DetectFastPatternTest560(void) return result; } -int DetectFastPatternTest561(void) +static int DetectFastPatternTest561(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -15619,7 +15619,7 @@ int DetectFastPatternTest561(void) return result; } -int DetectFastPatternTest562(void) +static int DetectFastPatternTest562(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -15652,7 +15652,7 @@ int DetectFastPatternTest562(void) return result; } -int DetectFastPatternTest563(void) +static int DetectFastPatternTest563(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -15684,7 +15684,7 @@ int DetectFastPatternTest563(void) return result; } -int DetectFastPatternTest564(void) +static int DetectFastPatternTest564(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -15716,7 +15716,7 @@ int DetectFastPatternTest564(void) return result; } -int DetectFastPatternTest565(void) +static int DetectFastPatternTest565(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -15748,7 +15748,7 @@ int DetectFastPatternTest565(void) return result; } -int DetectFastPatternTest566(void) +static int DetectFastPatternTest566(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -15780,7 +15780,7 @@ int DetectFastPatternTest566(void) return result; } -int DetectFastPatternTest567(void) +static int DetectFastPatternTest567(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -15803,7 +15803,7 @@ int DetectFastPatternTest567(void) return result; } -int DetectFastPatternTest568(void) +static int DetectFastPatternTest568(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -15826,7 +15826,7 @@ int DetectFastPatternTest568(void) return result; } -int DetectFastPatternTest569(void) +static int DetectFastPatternTest569(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -15849,7 +15849,7 @@ int DetectFastPatternTest569(void) return result; } -int DetectFastPatternTest570(void) +static int DetectFastPatternTest570(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -15872,7 +15872,7 @@ int DetectFastPatternTest570(void) return result; } -int DetectFastPatternTest571(void) +static int DetectFastPatternTest571(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -15904,7 +15904,7 @@ int DetectFastPatternTest571(void) return result; } -int DetectFastPatternTest572(void) +static int DetectFastPatternTest572(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -15936,7 +15936,7 @@ int DetectFastPatternTest572(void) return result; } -int DetectFastPatternTest573(void) +static int DetectFastPatternTest573(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -15968,7 +15968,7 @@ int DetectFastPatternTest573(void) return result; } -int DetectFastPatternTest574(void) +static int DetectFastPatternTest574(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -16000,7 +16000,7 @@ int DetectFastPatternTest574(void) return result; } -int DetectFastPatternTest575(void) +static int DetectFastPatternTest575(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -16032,7 +16032,7 @@ int DetectFastPatternTest575(void) return result; } -int DetectFastPatternTest576(void) +static int DetectFastPatternTest576(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -16064,7 +16064,7 @@ int DetectFastPatternTest576(void) return result; } -int DetectFastPatternTest577(void) +static int DetectFastPatternTest577(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -16096,7 +16096,7 @@ int DetectFastPatternTest577(void) return result; } -int DetectFastPatternTest578(void) +static int DetectFastPatternTest578(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -16128,7 +16128,7 @@ int DetectFastPatternTest578(void) return result; } -int DetectFastPatternTest579(void) +static int DetectFastPatternTest579(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -16163,7 +16163,7 @@ int DetectFastPatternTest579(void) return result; } -int DetectFastPatternTest580(void) +static int DetectFastPatternTest580(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -16187,7 +16187,7 @@ int DetectFastPatternTest580(void) return result; } -int DetectFastPatternTest581(void) +static int DetectFastPatternTest581(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -16211,7 +16211,7 @@ int DetectFastPatternTest581(void) return result; } -int DetectFastPatternTest582(void) +static int DetectFastPatternTest582(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -16235,7 +16235,7 @@ int DetectFastPatternTest582(void) return result; } -int DetectFastPatternTest583(void) +static int DetectFastPatternTest583(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -16268,7 +16268,7 @@ int DetectFastPatternTest583(void) return result; } -int DetectFastPatternTest584(void) +static int DetectFastPatternTest584(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -16292,7 +16292,7 @@ int DetectFastPatternTest584(void) return result; } -int DetectFastPatternTest585(void) +static int DetectFastPatternTest585(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -16316,7 +16316,7 @@ int DetectFastPatternTest585(void) return result; } -int DetectFastPatternTest586(void) +static int DetectFastPatternTest586(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -16340,7 +16340,7 @@ int DetectFastPatternTest586(void) return result; } -int DetectFastPatternTest587(void) +static int DetectFastPatternTest587(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -16364,7 +16364,7 @@ int DetectFastPatternTest587(void) return result; } -int DetectFastPatternTest588(void) +static int DetectFastPatternTest588(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -16402,7 +16402,7 @@ int DetectFastPatternTest588(void) /* http_host fast_pattern tests v */ -int DetectFastPatternTest589(void) +static int DetectFastPatternTest589(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -16438,7 +16438,7 @@ int DetectFastPatternTest589(void) /** * \test Checks if a fast_pattern is registered in a Signature for uricontent. */ -int DetectFastPatternTest590(void) +static int DetectFastPatternTest590(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -16475,7 +16475,7 @@ int DetectFastPatternTest590(void) /** * \test Checks if a fast_pattern is registered in a Signature for uricontent. */ -int DetectFastPatternTest591(void) +static int DetectFastPatternTest591(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -16508,7 +16508,7 @@ int DetectFastPatternTest591(void) return result; } -int DetectFastPatternTest592(void) +static int DetectFastPatternTest592(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -16544,7 +16544,7 @@ int DetectFastPatternTest592(void) return result; } -int DetectFastPatternTest593(void) +static int DetectFastPatternTest593(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -16581,7 +16581,7 @@ int DetectFastPatternTest593(void) return result; } -int DetectFastPatternTest594(void) +static int DetectFastPatternTest594(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -16604,7 +16604,7 @@ int DetectFastPatternTest594(void) return result; } -int DetectFastPatternTest595(void) +static int DetectFastPatternTest595(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -16627,7 +16627,7 @@ int DetectFastPatternTest595(void) return result; } -int DetectFastPatternTest596(void) +static int DetectFastPatternTest596(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -16650,7 +16650,7 @@ int DetectFastPatternTest596(void) return result; } -int DetectFastPatternTest597(void) +static int DetectFastPatternTest597(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -16673,7 +16673,7 @@ int DetectFastPatternTest597(void) return result; } -int DetectFastPatternTest598(void) +static int DetectFastPatternTest598(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -16696,7 +16696,7 @@ int DetectFastPatternTest598(void) return result; } -int DetectFastPatternTest599(void) +static int DetectFastPatternTest599(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -16719,7 +16719,7 @@ int DetectFastPatternTest599(void) return result; } -int DetectFastPatternTest600(void) +static int DetectFastPatternTest600(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -16742,7 +16742,7 @@ int DetectFastPatternTest600(void) return result; } -int DetectFastPatternTest601(void) +static int DetectFastPatternTest601(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -16765,7 +16765,7 @@ int DetectFastPatternTest601(void) return result; } -int DetectFastPatternTest602(void) +static int DetectFastPatternTest602(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -16788,7 +16788,7 @@ int DetectFastPatternTest602(void) return result; } -int DetectFastPatternTest603(void) +static int DetectFastPatternTest603(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -16821,7 +16821,7 @@ int DetectFastPatternTest603(void) return result; } -int DetectFastPatternTest604(void) +static int DetectFastPatternTest604(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -16853,7 +16853,7 @@ int DetectFastPatternTest604(void) return result; } -int DetectFastPatternTest605(void) +static int DetectFastPatternTest605(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -16885,7 +16885,7 @@ int DetectFastPatternTest605(void) return result; } -int DetectFastPatternTest606(void) +static int DetectFastPatternTest606(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -16917,7 +16917,7 @@ int DetectFastPatternTest606(void) return result; } -int DetectFastPatternTest607(void) +static int DetectFastPatternTest607(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -16949,7 +16949,7 @@ int DetectFastPatternTest607(void) return result; } -int DetectFastPatternTest608(void) +static int DetectFastPatternTest608(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -16972,7 +16972,7 @@ int DetectFastPatternTest608(void) return result; } -int DetectFastPatternTest609(void) +static int DetectFastPatternTest609(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -16995,7 +16995,7 @@ int DetectFastPatternTest609(void) return result; } -int DetectFastPatternTest610(void) +static int DetectFastPatternTest610(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -17018,7 +17018,7 @@ int DetectFastPatternTest610(void) return result; } -int DetectFastPatternTest611(void) +static int DetectFastPatternTest611(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -17041,7 +17041,7 @@ int DetectFastPatternTest611(void) return result; } -int DetectFastPatternTest612(void) +static int DetectFastPatternTest612(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -17073,7 +17073,7 @@ int DetectFastPatternTest612(void) return result; } -int DetectFastPatternTest613(void) +static int DetectFastPatternTest613(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -17105,7 +17105,7 @@ int DetectFastPatternTest613(void) return result; } -int DetectFastPatternTest614(void) +static int DetectFastPatternTest614(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -17137,7 +17137,7 @@ int DetectFastPatternTest614(void) return result; } -int DetectFastPatternTest615(void) +static int DetectFastPatternTest615(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -17169,7 +17169,7 @@ int DetectFastPatternTest615(void) return result; } -int DetectFastPatternTest616(void) +static int DetectFastPatternTest616(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -17201,7 +17201,7 @@ int DetectFastPatternTest616(void) return result; } -int DetectFastPatternTest617(void) +static int DetectFastPatternTest617(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -17233,7 +17233,7 @@ int DetectFastPatternTest617(void) return result; } -int DetectFastPatternTest618(void) +static int DetectFastPatternTest618(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -17265,7 +17265,7 @@ int DetectFastPatternTest618(void) return result; } -int DetectFastPatternTest619(void) +static int DetectFastPatternTest619(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -17297,7 +17297,7 @@ int DetectFastPatternTest619(void) return result; } -int DetectFastPatternTest620(void) +static int DetectFastPatternTest620(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -17332,7 +17332,7 @@ int DetectFastPatternTest620(void) return result; } -int DetectFastPatternTest621(void) +static int DetectFastPatternTest621(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -17356,7 +17356,7 @@ int DetectFastPatternTest621(void) return result; } -int DetectFastPatternTest622(void) +static int DetectFastPatternTest622(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -17380,7 +17380,7 @@ int DetectFastPatternTest622(void) return result; } -int DetectFastPatternTest623(void) +static int DetectFastPatternTest623(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -17404,7 +17404,7 @@ int DetectFastPatternTest623(void) return result; } -int DetectFastPatternTest624(void) +static int DetectFastPatternTest624(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -17437,7 +17437,7 @@ int DetectFastPatternTest624(void) return result; } -int DetectFastPatternTest625(void) +static int DetectFastPatternTest625(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -17461,7 +17461,7 @@ int DetectFastPatternTest625(void) return result; } -int DetectFastPatternTest626(void) +static int DetectFastPatternTest626(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -17485,7 +17485,7 @@ int DetectFastPatternTest626(void) return result; } -int DetectFastPatternTest627(void) +static int DetectFastPatternTest627(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -17509,7 +17509,7 @@ int DetectFastPatternTest627(void) return result; } -int DetectFastPatternTest628(void) +static int DetectFastPatternTest628(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -17533,7 +17533,7 @@ int DetectFastPatternTest628(void) return result; } -int DetectFastPatternTest629(void) +static int DetectFastPatternTest629(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -17571,7 +17571,7 @@ int DetectFastPatternTest629(void) /* http_rawhost fast_pattern tests v */ -int DetectFastPatternTest630(void) +static int DetectFastPatternTest630(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -17608,7 +17608,7 @@ int DetectFastPatternTest630(void) /** * \test Checks if a fast_pattern is registered in a Signature for uricontent. */ -int DetectFastPatternTest631(void) +static int DetectFastPatternTest631(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -17647,7 +17647,7 @@ int DetectFastPatternTest631(void) /** * \test Checks if a fast_pattern is registered in a Signature for uricontent. */ -int DetectFastPatternTest632(void) +static int DetectFastPatternTest632(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -17682,7 +17682,7 @@ int DetectFastPatternTest632(void) return result; } -int DetectFastPatternTest633(void) +static int DetectFastPatternTest633(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -17719,7 +17719,7 @@ int DetectFastPatternTest633(void) return result; } -int DetectFastPatternTest634(void) +static int DetectFastPatternTest634(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -17757,7 +17757,7 @@ int DetectFastPatternTest634(void) return result; } -int DetectFastPatternTest635(void) +static int DetectFastPatternTest635(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -17780,7 +17780,7 @@ int DetectFastPatternTest635(void) return result; } -int DetectFastPatternTest636(void) +static int DetectFastPatternTest636(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -17803,7 +17803,7 @@ int DetectFastPatternTest636(void) return result; } -int DetectFastPatternTest637(void) +static int DetectFastPatternTest637(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -17826,7 +17826,7 @@ int DetectFastPatternTest637(void) return result; } -int DetectFastPatternTest638(void) +static int DetectFastPatternTest638(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -17849,7 +17849,7 @@ int DetectFastPatternTest638(void) return result; } -int DetectFastPatternTest639(void) +static int DetectFastPatternTest639(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -17872,7 +17872,7 @@ int DetectFastPatternTest639(void) return result; } -int DetectFastPatternTest640(void) +static int DetectFastPatternTest640(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -17895,7 +17895,7 @@ int DetectFastPatternTest640(void) return result; } -int DetectFastPatternTest641(void) +static int DetectFastPatternTest641(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -17918,7 +17918,7 @@ int DetectFastPatternTest641(void) return result; } -int DetectFastPatternTest642(void) +static int DetectFastPatternTest642(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -17941,7 +17941,7 @@ int DetectFastPatternTest642(void) return result; } -int DetectFastPatternTest643(void) +static int DetectFastPatternTest643(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -17964,7 +17964,7 @@ int DetectFastPatternTest643(void) return result; } -int DetectFastPatternTest644(void) +static int DetectFastPatternTest644(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -17998,7 +17998,7 @@ int DetectFastPatternTest644(void) return result; } -int DetectFastPatternTest645(void) +static int DetectFastPatternTest645(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -18031,7 +18031,7 @@ int DetectFastPatternTest645(void) return result; } -int DetectFastPatternTest646(void) +static int DetectFastPatternTest646(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -18064,7 +18064,7 @@ int DetectFastPatternTest646(void) return result; } -int DetectFastPatternTest647(void) +static int DetectFastPatternTest647(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -18097,7 +18097,7 @@ int DetectFastPatternTest647(void) return result; } -int DetectFastPatternTest648(void) +static int DetectFastPatternTest648(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -18130,7 +18130,7 @@ int DetectFastPatternTest648(void) return result; } -int DetectFastPatternTest649(void) +static int DetectFastPatternTest649(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -18153,7 +18153,7 @@ int DetectFastPatternTest649(void) return result; } -int DetectFastPatternTest650(void) +static int DetectFastPatternTest650(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -18176,7 +18176,7 @@ int DetectFastPatternTest650(void) return result; } -int DetectFastPatternTest651(void) +static int DetectFastPatternTest651(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -18199,7 +18199,7 @@ int DetectFastPatternTest651(void) return result; } -int DetectFastPatternTest652(void) +static int DetectFastPatternTest652(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -18222,7 +18222,7 @@ int DetectFastPatternTest652(void) return result; } -int DetectFastPatternTest653(void) +static int DetectFastPatternTest653(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -18255,7 +18255,7 @@ int DetectFastPatternTest653(void) return result; } -int DetectFastPatternTest654(void) +static int DetectFastPatternTest654(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -18288,7 +18288,7 @@ int DetectFastPatternTest654(void) return result; } -int DetectFastPatternTest655(void) +static int DetectFastPatternTest655(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -18321,7 +18321,7 @@ int DetectFastPatternTest655(void) return result; } -int DetectFastPatternTest656(void) +static int DetectFastPatternTest656(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -18354,7 +18354,7 @@ int DetectFastPatternTest656(void) return result; } -int DetectFastPatternTest657(void) +static int DetectFastPatternTest657(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -18387,7 +18387,7 @@ int DetectFastPatternTest657(void) return result; } -int DetectFastPatternTest658(void) +static int DetectFastPatternTest658(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -18420,7 +18420,7 @@ int DetectFastPatternTest658(void) return result; } -int DetectFastPatternTest659(void) +static int DetectFastPatternTest659(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -18453,7 +18453,7 @@ int DetectFastPatternTest659(void) return result; } -int DetectFastPatternTest660(void) +static int DetectFastPatternTest660(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -18486,7 +18486,7 @@ int DetectFastPatternTest660(void) return result; } -int DetectFastPatternTest661(void) +static int DetectFastPatternTest661(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -18522,7 +18522,7 @@ int DetectFastPatternTest661(void) return result; } -int DetectFastPatternTest662(void) +static int DetectFastPatternTest662(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -18546,7 +18546,7 @@ int DetectFastPatternTest662(void) return result; } -int DetectFastPatternTest663(void) +static int DetectFastPatternTest663(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -18570,7 +18570,7 @@ int DetectFastPatternTest663(void) return result; } -int DetectFastPatternTest664(void) +static int DetectFastPatternTest664(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -18594,7 +18594,7 @@ int DetectFastPatternTest664(void) return result; } -int DetectFastPatternTest665(void) +static int DetectFastPatternTest665(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -18628,7 +18628,7 @@ int DetectFastPatternTest665(void) return result; } -int DetectFastPatternTest666(void) +static int DetectFastPatternTest666(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -18652,7 +18652,7 @@ int DetectFastPatternTest666(void) return result; } -int DetectFastPatternTest667(void) +static int DetectFastPatternTest667(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -18676,7 +18676,7 @@ int DetectFastPatternTest667(void) return result; } -int DetectFastPatternTest668(void) +static int DetectFastPatternTest668(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -18700,7 +18700,7 @@ int DetectFastPatternTest668(void) return result; } -int DetectFastPatternTest669(void) +static int DetectFastPatternTest669(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -18724,7 +18724,7 @@ int DetectFastPatternTest669(void) return result; } -int DetectFastPatternTest670(void) +static int DetectFastPatternTest670(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -18766,10 +18766,10 @@ int DetectFastPatternTest670(void) * - if 2 unique patterns get unique ids. * - if 2 duplicate patterns, with no chop set get unique ids. */ -int DetectFastPatternTest671(void) +static int DetectFastPatternTest671(void) { int no_of_sigs = 6; - char *sigs[no_of_sigs]; + const char *sigs[no_of_sigs]; Signature *s[no_of_sigs]; DetectEngineCtx *de_ctx = NULL; DetectContentData *cd = NULL; @@ -19273,7 +19273,7 @@ void DetectFastPatternRegisterTests(void) UtRegisterTest("DetectFastPatternTest413", DetectFastPatternTest413); UtRegisterTest("DetectFastPatternTest414", DetectFastPatternTest414); UtRegisterTest("DetectFastPatternTest415", DetectFastPatternTest415); - UtRegisterTest("DetectFastPatternTest416", DetectFastPatternTest415); + UtRegisterTest("DetectFastPatternTest416", DetectFastPatternTest416); UtRegisterTest("DetectFastPatternTest417", DetectFastPatternTest417); UtRegisterTest("DetectFastPatternTest418", DetectFastPatternTest418); UtRegisterTest("DetectFastPatternTest419", DetectFastPatternTest419); diff --git a/src/detect-file-data.c b/src/detect-file-data.c index 3c5e5b5d41..326ebbf784 100644 --- a/src/detect-file-data.c +++ b/src/detect-file-data.c @@ -36,6 +36,7 @@ #include "detect-engine-filedata-smtp.h" #include "detect-engine-hsbd.h" +#include "detect-file-data.h" #include "flow.h" #include "flow-var.h" @@ -46,7 +47,7 @@ #include "util-unittest.h" #include "util-unittest-helper.h" -static int DetectFiledataSetup (DetectEngineCtx *, Signature *, char *); +static int DetectFiledataSetup (DetectEngineCtx *, Signature *, const char *); static void DetectFiledataRegisterTests(void); static void DetectFiledataSetupCallback(Signature *s); static int g_file_data_buffer_id = 0; @@ -97,7 +98,7 @@ void DetectFiledataRegister(void) * \retval 0 on Success * \retval -1 on Failure */ -static int DetectFiledataSetup (DetectEngineCtx *de_ctx, Signature *s, char *str) +static int DetectFiledataSetup (DetectEngineCtx *de_ctx, Signature *s, const char *str) { SCEnter(); diff --git a/src/detect-file-hash-common.c b/src/detect-file-hash-common.c index 3e5d433d98..baa14818c3 100644 --- a/src/detect-file-hash-common.c +++ b/src/detect-file-hash-common.c @@ -46,7 +46,7 @@ * \retval -1 the hexadecimal string is invalid * \retval 1 the hexadecimal string was read successfully */ -int ReadHashString(uint8_t *hash, char *string, char *filename, int line_no, +int ReadHashString(uint8_t *hash, const char *string, const char *filename, int line_no, uint16_t expected_len) { if (strlen(string) != expected_len) { @@ -86,7 +86,7 @@ int ReadHashString(uint8_t *hash, char *string, char *filename, int line_no, * \retval -1 failed to load the hash into the hash table * \retval 1 successfully loaded the has into the hash table */ -int LoadHashTable(ROHashTable *hash_table, char *string, char *filename, +int LoadHashTable(ROHashTable *hash_table, const char *string, const char *filename, int line_no, uint32_t type) { /* allocate the maximum size a hash can have (in this case is SHA256, 32 bytes) */ @@ -206,7 +206,7 @@ static const char *hexcodes = "ABCDEFabcdef0123456789"; * \retval NULL on failure */ static DetectFileHashData *DetectFileHashParse (const DetectEngineCtx *de_ctx, - char *str, uint32_t type) + const char *str, uint32_t type) { DetectFileHashData *filehash = NULL; FILE *fp = NULL; @@ -302,7 +302,7 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -int DetectFileHashSetup (DetectEngineCtx *de_ctx, Signature *s, char *str, +int DetectFileHashSetup (DetectEngineCtx *de_ctx, Signature *s, const char *str, uint32_t type, int list) { DetectFileHashData *filehash = NULL; diff --git a/src/detect-file-hash-common.h b/src/detect-file-hash-common.h index 68fd34dd6f..c05ca9ec9f 100644 --- a/src/detect-file-hash-common.h +++ b/src/detect-file-hash-common.h @@ -34,12 +34,12 @@ typedef struct DetectFileHashData_ { } DetectFileHashData; /* prototypes */ -int ReadHashString(uint8_t *, char *, char *, int, uint16_t); -int LoadHashTable(ROHashTable *, char *, char *, int, uint32_t); +int ReadHashString(uint8_t *, const char *, const char *, int, uint16_t); +int LoadHashTable(ROHashTable *, const char *, const char *, int, uint32_t); int DetectFileHashMatch(ThreadVars *, DetectEngineThreadCtx *, Flow *, uint8_t, File *, const Signature *, const SigMatchCtx *); -int DetectFileHashSetup(DetectEngineCtx *, Signature *, char *, uint32_t, int); +int DetectFileHashSetup(DetectEngineCtx *, Signature *, const char *, uint32_t, int); void DetectFileHashFree(void *); #endif /* __UTIL_DETECT_FILE_HASH_H__ */ diff --git a/src/detect-fileext.c b/src/detect-fileext.c index 5483901c21..73160a426b 100644 --- a/src/detect-fileext.c +++ b/src/detect-fileext.c @@ -53,7 +53,7 @@ static int DetectFileextMatch (ThreadVars *, DetectEngineThreadCtx *, Flow *, uint8_t, File *, const Signature *, const SigMatchCtx *); -static int DetectFileextSetup (DetectEngineCtx *, Signature *, char *); +static int DetectFileextSetup (DetectEngineCtx *, Signature *, const char *); static void DetectFileextRegisterTests(void); static void DetectFileextFree(void *); static int g_file_match_list_id = 0; @@ -198,7 +198,7 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -static int DetectFileextSetup (DetectEngineCtx *de_ctx, Signature *s, char *str) +static int DetectFileextSetup (DetectEngineCtx *de_ctx, Signature *s, const char *str) { DetectFileextData *fileext= NULL; SigMatch *sm = NULL; diff --git a/src/detect-filemagic.c b/src/detect-filemagic.c index eeb3805bfc..0cdad2c77d 100644 --- a/src/detect-filemagic.c +++ b/src/detect-filemagic.c @@ -78,7 +78,7 @@ void DetectFilemagicRegister(void) static int DetectFilemagicMatch (ThreadVars *, DetectEngineThreadCtx *, Flow *, uint8_t, File *, const Signature *, const SigMatchCtx *); -static int DetectFilemagicSetup (DetectEngineCtx *, Signature *, char *); +static int DetectFilemagicSetup (DetectEngineCtx *, Signature *, const char *); static void DetectFilemagicRegisterTests(void); static void DetectFilemagicFree(void *); static int g_file_match_list_id = 0; @@ -144,7 +144,7 @@ int FilemagicGlobalLookup(File *file) * \retval -1 error * \retval 0 ok */ -int FilemagicThreadLookup(magic_t *ctx, File *file) +static int FilemagicThreadLookup(magic_t *ctx, File *file) { if (ctx == NULL || file == NULL || FileDataSize(file) == 0) { SCReturnInt(-1); @@ -291,7 +291,7 @@ error: static void *DetectFilemagicThreadInit(void *data) { - char *filename = NULL; + const char *filename = NULL; FILE *fd = NULL; DetectFilemagicData *filemagic = (DetectFilemagicData *)data; BUG_ON(filemagic == NULL); @@ -362,7 +362,7 @@ static void DetectFilemagicThreadFree(void *ctx) * \retval 0 on Success * \retval -1 on Failure */ -static int DetectFilemagicSetup (DetectEngineCtx *de_ctx, Signature *s, char *str) +static int DetectFilemagicSetup (DetectEngineCtx *de_ctx, Signature *s, const char *str) { DetectFilemagicData *filemagic = NULL; SigMatch *sm = NULL; diff --git a/src/detect-filemd5.c b/src/detect-filemd5.c index 29320832fc..8134290abf 100644 --- a/src/detect-filemd5.c +++ b/src/detect-filemd5.c @@ -33,7 +33,7 @@ #ifndef HAVE_NSS -static int DetectFileMd5SetupNoSupport (DetectEngineCtx *a, Signature *b, char *c) +static int DetectFileMd5SetupNoSupport (DetectEngineCtx *a, Signature *b, const char *c) { SCLogError(SC_ERR_NO_MD5_SUPPORT, "no MD5 calculation support built in, needed for filemd5 keyword"); return -1; @@ -59,7 +59,7 @@ void DetectFileMd5Register(void) static int g_file_match_list_id = 0; -static int DetectFileMd5Setup (DetectEngineCtx *, Signature *, char *); +static int DetectFileMd5Setup (DetectEngineCtx *, Signature *, const char *); static void DetectFileMd5RegisterTests(void); /** @@ -92,13 +92,13 @@ void DetectFileMd5Register(void) * \retval 0 on Success * \retval -1 on Failure */ -static int DetectFileMd5Setup (DetectEngineCtx *de_ctx, Signature *s, char *str) +static int DetectFileMd5Setup (DetectEngineCtx *de_ctx, Signature *s, const char *str) { return DetectFileHashSetup(de_ctx, s, str, DETECT_FILEMD5, g_file_match_list_id); } #ifdef UNITTESTS -static int MD5MatchLookupString(ROHashTable *hash, char *string) +static int MD5MatchLookupString(ROHashTable *hash, const char *string) { uint8_t md5[16]; if (ReadHashString(md5, string, "file", 88, 32) == 1) { diff --git a/src/detect-filename.c b/src/detect-filename.c index 840df3a31f..d67148d6f2 100644 --- a/src/detect-filename.c +++ b/src/detect-filename.c @@ -54,7 +54,7 @@ static int DetectFilenameMatch (ThreadVars *, DetectEngineThreadCtx *, Flow *, uint8_t, File *, const Signature *, const SigMatchCtx *); -static int DetectFilenameSetup (DetectEngineCtx *, Signature *, char *); +static int DetectFilenameSetup (DetectEngineCtx *, Signature *, const char *); static void DetectFilenameRegisterTests(void); static void DetectFilenameFree(void *); static int g_file_match_list_id = 0; @@ -215,7 +215,7 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -static int DetectFilenameSetup (DetectEngineCtx *de_ctx, Signature *s, char *str) +static int DetectFilenameSetup (DetectEngineCtx *de_ctx, Signature *s, const char *str) { DetectFilenameData *filename = NULL; SigMatch *sm = NULL; diff --git a/src/detect-filesha1.c b/src/detect-filesha1.c index 84fd689296..feb2b908b4 100644 --- a/src/detect-filesha1.c +++ b/src/detect-filesha1.c @@ -34,7 +34,7 @@ #ifndef HAVE_NSS -static int DetectFileSha1SetupNoSupport (DetectEngineCtx *a, Signature *b, char *c) +static int DetectFileSha1SetupNoSupport (DetectEngineCtx *a, Signature *b, const char *c) { SCLogError(SC_ERR_NO_SHA1_SUPPORT, "no SHA-1 calculation support built in, needed for filesha1 keyword"); return -1; @@ -58,7 +58,7 @@ void DetectFileSha1Register(void) #else /* HAVE_NSS */ -static int DetectFileSha1Setup (DetectEngineCtx *, Signature *, char *); +static int DetectFileSha1Setup (DetectEngineCtx *, Signature *, const char *); static void DetectFileSha1RegisterTests(void); static int g_file_match_list_id = 0; @@ -92,13 +92,13 @@ void DetectFileSha1Register(void) * \retval 0 on Success * \retval -1 on Failure */ -static int DetectFileSha1Setup (DetectEngineCtx *de_ctx, Signature *s, char *str) +static int DetectFileSha1Setup (DetectEngineCtx *de_ctx, Signature *s, const char *str) { return DetectFileHashSetup(de_ctx, s, str, DETECT_FILESHA1, g_file_match_list_id); } #ifdef UNITTESTS -static int SHA1MatchLookupString(ROHashTable *hash, char *string) +static int SHA1MatchLookupString(ROHashTable *hash, const char *string) { uint8_t sha1[20]; if (ReadHashString(sha1, string, "file", 88, 40) == 1) { diff --git a/src/detect-filesha256.c b/src/detect-filesha256.c index 59f06d2f78..9fd068fe4e 100644 --- a/src/detect-filesha256.c +++ b/src/detect-filesha256.c @@ -34,7 +34,7 @@ #ifndef HAVE_NSS -static int DetectFileSha256SetupNoSupport (DetectEngineCtx *a, Signature *b, char *c) +static int DetectFileSha256SetupNoSupport (DetectEngineCtx *a, Signature *b, const char *c) { SCLogError(SC_ERR_NO_SHA256_SUPPORT, "no SHA-256 calculation support built in, needed for filesha256 keyword"); return -1; @@ -58,7 +58,7 @@ void DetectFileSha256Register(void) #else /* HAVE_NSS */ -static int DetectFileSha256Setup (DetectEngineCtx *, Signature *, char *); +static int DetectFileSha256Setup (DetectEngineCtx *, Signature *, const char *); static void DetectFileSha256RegisterTests(void); static int g_file_match_list_id = 0; @@ -92,13 +92,13 @@ void DetectFileSha256Register(void) * \retval 0 on Success * \retval -1 on Failure */ -static int DetectFileSha256Setup (DetectEngineCtx *de_ctx, Signature *s, char *str) +static int DetectFileSha256Setup (DetectEngineCtx *de_ctx, Signature *s, const char *str) { return DetectFileHashSetup(de_ctx, s, str, DETECT_FILESHA256, g_file_match_list_id); } #ifdef UNITTESTS -static int SHA256MatchLookupString(ROHashTable *hash, char *string) +static int SHA256MatchLookupString(ROHashTable *hash, const char *string) { uint8_t sha256[32]; if (ReadHashString(sha256, string, "file", 88, 64) == 1) { diff --git a/src/detect-filesize.c b/src/detect-filesize.c index 151579f27b..48c1a0e2ee 100644 --- a/src/detect-filesize.c +++ b/src/detect-filesize.c @@ -51,7 +51,7 @@ static pcre_extra *parse_regex_study; /*prototypes*/ static int DetectFilesizeMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Flow *f, uint8_t flags, File *file, const Signature *s, const SigMatchCtx *m); -static int DetectFilesizeSetup (DetectEngineCtx *, Signature *, char *); +static int DetectFilesizeSetup (DetectEngineCtx *, Signature *, const char *); static void DetectFilesizeFree (void *); static void DetectFilesizeRegisterTests (void); static int g_file_match_list_id = 0; @@ -135,7 +135,7 @@ static int DetectFilesizeMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, F * \retval fsd pointer to DetectFilesizeData on success * \retval NULL on failure */ -static DetectFilesizeData *DetectFilesizeParse (char *str) +static DetectFilesizeData *DetectFilesizeParse (const char *str) { DetectFilesizeData *fsd = NULL; @@ -272,7 +272,7 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -static int DetectFilesizeSetup (DetectEngineCtx *de_ctx, Signature *s, char *str) +static int DetectFilesizeSetup (DetectEngineCtx *de_ctx, Signature *s, const char *str) { SCEnter(); DetectFilesizeData *fsd = NULL; @@ -410,7 +410,7 @@ static int DetectFilesizeParseTest05(void) */ static int DetectFilesizeInitTest(DetectEngineCtx **de_ctx, Signature **sig, - DetectFilesizeData **fsd, char *str) + DetectFilesizeData **fsd, const char *str) { char fullstr[1024]; int result = 0; diff --git a/src/detect-filestore.c b/src/detect-filestore.c index d64b9b44d8..666b6e36ef 100644 --- a/src/detect-filestore.c +++ b/src/detect-filestore.c @@ -61,7 +61,7 @@ static pcre_extra *parse_regex_study; static int DetectFilestoreMatch (ThreadVars *, DetectEngineThreadCtx *, Flow *, uint8_t, File *, const Signature *, const SigMatchCtx *); -static int DetectFilestoreSetup (DetectEngineCtx *, Signature *, char *); +static int DetectFilestoreSetup (DetectEngineCtx *, Signature *, const char *); static void DetectFilestoreFree(void *); static void DetectFilestoreRegisterTests(void); static int g_file_match_list_id = 0; @@ -287,7 +287,7 @@ static int DetectFilestoreMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, * \retval 0 on Success * \retval -1 on Failure */ -static int DetectFilestoreSetup (DetectEngineCtx *de_ctx, Signature *s, char *str) +static int DetectFilestoreSetup (DetectEngineCtx *de_ctx, Signature *s, const char *str) { SCEnter(); diff --git a/src/detect-flags.c b/src/detect-flags.c index 72ac60d729..6959277399 100644 --- a/src/detect-flags.c +++ b/src/detect-flags.c @@ -60,7 +60,7 @@ static pcre_extra *parse_regex_study; static int DetectFlagsMatch (ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectFlagsSetup (DetectEngineCtx *, Signature *, char *); +static int DetectFlagsSetup (DetectEngineCtx *, Signature *, const char *); static void DetectFlagsFree(void *); static _Bool PrefilterTcpFlagsIsPrefilterable(const Signature *s); @@ -163,7 +163,7 @@ static int DetectFlagsMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Pack * \retval de pointer to DetectFlagsData on success * \retval NULL on failure */ -static DetectFlagsData *DetectFlagsParse (char *rawstr) +static DetectFlagsData *DetectFlagsParse (const char *rawstr) { SCEnter(); @@ -477,7 +477,7 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -static int DetectFlagsSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr) +static int DetectFlagsSetup (DetectEngineCtx *de_ctx, Signature *s, const char *rawstr) { DetectFlagsData *de = NULL; SigMatch *sm = NULL; diff --git a/src/detect-flow.c b/src/detect-flow.c index bde0341651..2d5c7a0c1f 100644 --- a/src/detect-flow.c +++ b/src/detect-flow.c @@ -51,7 +51,7 @@ static pcre_extra *parse_regex_study; int DetectFlowMatch (ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectFlowSetup (DetectEngineCtx *, Signature *, char *); +static int DetectFlowSetup (DetectEngineCtx *, Signature *, const char *); void DetectFlowRegisterTests(void); void DetectFlowFree(void *); @@ -166,7 +166,7 @@ int DetectFlowMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p, * \retval fd pointer to DetectFlowData on success * \retval NULL on failure */ -DetectFlowData *DetectFlowParse (char *flowstr) +static DetectFlowData *DetectFlowParse (const char *flowstr) { DetectFlowData *fd = NULL; char *args[3] = {NULL,NULL,NULL}; @@ -326,7 +326,7 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -int DetectFlowSetup (DetectEngineCtx *de_ctx, Signature *s, char *flowstr) +int DetectFlowSetup (DetectEngineCtx *de_ctx, Signature *s, const char *flowstr) { DetectFlowData *fd = NULL; SigMatch *sm = NULL; @@ -452,7 +452,7 @@ static _Bool PrefilterFlowIsPrefilterable(const Signature *s) * \test DetectFlowTestParse01 is a test to make sure that we return "something" * when given valid flow opt */ -int DetectFlowTestParse01 (void) +static int DetectFlowTestParse01 (void) { DetectFlowData *fd = NULL; fd = DetectFlowParse("established"); @@ -464,7 +464,7 @@ int DetectFlowTestParse01 (void) /** * \test DetectFlowTestParse02 is a test for setting the established flow opt */ -int DetectFlowTestParse02 (void) +static int DetectFlowTestParse02 (void) { DetectFlowData *fd = NULL; fd = DetectFlowParse("established"); @@ -477,7 +477,7 @@ int DetectFlowTestParse02 (void) /** * \test DetectFlowTestParse03 is a test for setting the stateless flow opt */ -int DetectFlowTestParse03 (void) +static int DetectFlowTestParse03 (void) { DetectFlowData *fd = NULL; fd = DetectFlowParse("stateless"); @@ -490,7 +490,7 @@ int DetectFlowTestParse03 (void) /** * \test DetectFlowTestParse04 is a test for setting the to_client flow opt */ -int DetectFlowTestParse04 (void) +static int DetectFlowTestParse04 (void) { DetectFlowData *fd = NULL; fd = DetectFlowParse("to_client"); @@ -503,7 +503,7 @@ int DetectFlowTestParse04 (void) /** * \test DetectFlowTestParse05 is a test for setting the to_server flow opt */ -int DetectFlowTestParse05 (void) +static int DetectFlowTestParse05 (void) { DetectFlowData *fd = NULL; fd = DetectFlowParse("to_server"); @@ -516,7 +516,7 @@ int DetectFlowTestParse05 (void) /** * \test DetectFlowTestParse06 is a test for setting the from_server flow opt */ -int DetectFlowTestParse06 (void) +static int DetectFlowTestParse06 (void) { DetectFlowData *fd = NULL; fd = DetectFlowParse("from_server"); @@ -529,7 +529,7 @@ int DetectFlowTestParse06 (void) /** * \test DetectFlowTestParse07 is a test for setting the from_client flow opt */ -int DetectFlowTestParse07 (void) +static int DetectFlowTestParse07 (void) { DetectFlowData *fd = NULL; fd = DetectFlowParse("from_client"); @@ -542,7 +542,7 @@ int DetectFlowTestParse07 (void) /** * \test DetectFlowTestParse08 is a test for setting the established,to_client flow opts */ -int DetectFlowTestParse08 (void) +static int DetectFlowTestParse08 (void) { DetectFlowData *fd = NULL; fd = DetectFlowParse("established,to_client"); @@ -555,7 +555,7 @@ int DetectFlowTestParse08 (void) /** * \test DetectFlowTestParse09 is a test for setting the to_client,stateless flow opts (order of state,dir reversed) */ -int DetectFlowTestParse09 (void) +static int DetectFlowTestParse09 (void) { DetectFlowData *fd = NULL; fd = DetectFlowParse("to_client,stateless"); @@ -570,7 +570,7 @@ int DetectFlowTestParse09 (void) /** * \test DetectFlowTestParse10 is a test for setting the from_server,stateless flow opts (order of state,dir reversed) */ -int DetectFlowTestParse10 (void) +static int DetectFlowTestParse10 (void) { DetectFlowData *fd = NULL; fd = DetectFlowParse("from_server,stateless"); @@ -585,7 +585,7 @@ int DetectFlowTestParse10 (void) /** * \test DetectFlowTestParse11 is a test for setting the from_server,stateless flow opts with spaces all around */ -int DetectFlowTestParse11 (void) +static int DetectFlowTestParse11 (void) { DetectFlowData *fd = NULL; fd = DetectFlowParse(" from_server , stateless "); @@ -601,7 +601,7 @@ int DetectFlowTestParse11 (void) * \test DetectFlowTestParseNocase01 is a test to make sure that we return "something" * when given valid flow opt */ -int DetectFlowTestParseNocase01 (void) +static int DetectFlowTestParseNocase01 (void) { DetectFlowData *fd = NULL; fd = DetectFlowParse("ESTABLISHED"); @@ -613,7 +613,7 @@ int DetectFlowTestParseNocase01 (void) /** * \test DetectFlowTestParseNocase02 is a test for setting the established flow opt */ -int DetectFlowTestParseNocase02 (void) +static int DetectFlowTestParseNocase02 (void) { DetectFlowData *fd = NULL; fd = DetectFlowParse("ESTABLISHED"); @@ -627,7 +627,7 @@ int DetectFlowTestParseNocase02 (void) /** * \test DetectFlowTestParseNocase03 is a test for setting the stateless flow opt */ -int DetectFlowTestParseNocase03 (void) +static int DetectFlowTestParseNocase03 (void) { DetectFlowData *fd = NULL; fd = DetectFlowParse("STATELESS"); @@ -639,7 +639,7 @@ int DetectFlowTestParseNocase03 (void) /** * \test DetectFlowTestParseNocase04 is a test for setting the to_client flow opt */ -int DetectFlowTestParseNocase04 (void) +static int DetectFlowTestParseNocase04 (void) { DetectFlowData *fd = NULL; fd = DetectFlowParse("TO_CLIENT"); @@ -652,7 +652,7 @@ int DetectFlowTestParseNocase04 (void) /** * \test DetectFlowTestParseNocase05 is a test for setting the to_server flow opt */ -int DetectFlowTestParseNocase05 (void) +static int DetectFlowTestParseNocase05 (void) { DetectFlowData *fd = NULL; fd = DetectFlowParse("TO_SERVER"); @@ -665,7 +665,7 @@ int DetectFlowTestParseNocase05 (void) /** * \test DetectFlowTestParseNocase06 is a test for setting the from_server flow opt */ -int DetectFlowTestParseNocase06 (void) +static int DetectFlowTestParseNocase06 (void) { DetectFlowData *fd = NULL; fd = DetectFlowParse("FROM_SERVER"); @@ -678,7 +678,7 @@ int DetectFlowTestParseNocase06 (void) /** * \test DetectFlowTestParseNocase07 is a test for setting the from_client flow opt */ -int DetectFlowTestParseNocase07 (void) +static int DetectFlowTestParseNocase07 (void) { DetectFlowData *fd = NULL; fd = DetectFlowParse("FROM_CLIENT"); @@ -691,7 +691,7 @@ int DetectFlowTestParseNocase07 (void) /** * \test DetectFlowTestParseNocase08 is a test for setting the established,to_client flow opts */ -int DetectFlowTestParseNocase08 (void) +static int DetectFlowTestParseNocase08 (void) { DetectFlowData *fd = NULL; fd = DetectFlowParse("ESTABLISHED,TO_CLIENT"); @@ -706,7 +706,7 @@ int DetectFlowTestParseNocase08 (void) /** * \test DetectFlowTestParseNocase09 is a test for setting the to_client,stateless flow opts (order of state,dir reversed) */ -int DetectFlowTestParseNocase09 (void) +static int DetectFlowTestParseNocase09 (void) { DetectFlowData *fd = NULL; fd = DetectFlowParse("TO_CLIENT,STATELESS"); @@ -721,7 +721,7 @@ int DetectFlowTestParseNocase09 (void) /** * \test DetectFlowTestParseNocase10 is a test for setting the from_server,stateless flow opts (order of state,dir reversed) */ -int DetectFlowTestParseNocase10 (void) +static int DetectFlowTestParseNocase10 (void) { DetectFlowData *fd = NULL; fd = DetectFlowParse("FROM_SERVER,STATELESS"); @@ -736,7 +736,7 @@ int DetectFlowTestParseNocase10 (void) /** * \test DetectFlowTestParseNocase11 is a test for setting the from_server,stateless flow opts with spaces all around */ -int DetectFlowTestParseNocase11 (void) +static int DetectFlowTestParseNocase11 (void) { DetectFlowData *fd = NULL; fd = DetectFlowParse(" FROM_SERVER , STATELESS "); @@ -751,7 +751,7 @@ int DetectFlowTestParseNocase11 (void) /** * \test DetectFlowTestParse12 is a test for setting an invalid seperator : */ -int DetectFlowTestParse12 (void) +static int DetectFlowTestParse12 (void) { DetectFlowData *fd = NULL; fd = DetectFlowParse("from_server:stateless"); @@ -762,7 +762,7 @@ int DetectFlowTestParse12 (void) /** * \test DetectFlowTestParse13 is a test for an invalid option */ -int DetectFlowTestParse13 (void) +static int DetectFlowTestParse13 (void) { DetectFlowData *fd = NULL; fd = DetectFlowParse("invalidoptiontest"); @@ -773,7 +773,7 @@ int DetectFlowTestParse13 (void) /** * \test DetectFlowTestParse14 is a test for a empty option */ -int DetectFlowTestParse14 (void) +static int DetectFlowTestParse14 (void) { DetectFlowData *fd = NULL; fd = DetectFlowParse(""); @@ -784,7 +784,7 @@ int DetectFlowTestParse14 (void) /** * \test DetectFlowTestParse15 is a test for an invalid combo of options established,stateless */ -int DetectFlowTestParse15 (void) +static int DetectFlowTestParse15 (void) { DetectFlowData *fd = NULL; fd = DetectFlowParse("established,stateless"); @@ -795,7 +795,7 @@ int DetectFlowTestParse15 (void) /** * \test DetectFlowTestParse16 is a test for an invalid combo of options to_client,to_server */ -int DetectFlowTestParse16 (void) +static int DetectFlowTestParse16 (void) { DetectFlowData *fd = NULL; fd = DetectFlowParse("to_client,to_server"); @@ -807,7 +807,7 @@ int DetectFlowTestParse16 (void) * \test DetectFlowTestParse16 is a test for an invalid combo of options to_client,from_server * flowbit flags are the same */ -int DetectFlowTestParse17 (void) +static int DetectFlowTestParse17 (void) { DetectFlowData *fd = NULL; fd = DetectFlowParse("to_client,from_server"); @@ -818,7 +818,7 @@ int DetectFlowTestParse17 (void) /** * \test DetectFlowTestParse18 is a test for setting the from_server,stateless,only_stream flow opts (order of state,dir reversed) */ -int DetectFlowTestParse18 (void) +static int DetectFlowTestParse18 (void) { DetectFlowData *fd = NULL; fd = DetectFlowParse("from_server,established,only_stream"); @@ -834,7 +834,7 @@ int DetectFlowTestParse18 (void) /** * \test DetectFlowTestParseNocase18 is a test for setting the from_server,stateless,only_stream flow opts (order of state,dir reversed) */ -int DetectFlowTestParseNocase18 (void) +static int DetectFlowTestParseNocase18 (void) { DetectFlowData *fd = NULL; fd = DetectFlowParse("FROM_SERVER,ESTABLISHED,ONLY_STREAM"); @@ -851,7 +851,7 @@ int DetectFlowTestParseNocase18 (void) /** * \test DetectFlowTestParse19 is a test for one to many options passed to DetectFlowParse */ -int DetectFlowTestParse19 (void) +static int DetectFlowTestParse19 (void) { DetectFlowData *fd = NULL; fd = DetectFlowParse("from_server,established,only_stream,a"); @@ -862,7 +862,7 @@ int DetectFlowTestParse19 (void) /** * \test DetectFlowTestParse20 is a test for setting from_server, established, no_stream */ -int DetectFlowTestParse20 (void) +static int DetectFlowTestParse20 (void) { DetectFlowData *fd = NULL; fd = DetectFlowParse("from_server,established,no_stream"); @@ -878,7 +878,7 @@ int DetectFlowTestParse20 (void) /** * \test DetectFlowTestParse20 is a test for setting from_server, established, no_stream */ -int DetectFlowTestParseNocase20 (void) +static int DetectFlowTestParseNocase20 (void) { DetectFlowData *fd = NULL; fd = DetectFlowParse("FROM_SERVER,ESTABLISHED,NO_STREAM"); @@ -894,7 +894,7 @@ int DetectFlowTestParseNocase20 (void) /** * \test DetectFlowTestParse21 is a test for an invalid opt between to valid opts */ -int DetectFlowTestParse21 (void) +static int DetectFlowTestParse21 (void) { DetectFlowData *fd = NULL; fd = DetectFlowParse("from_server,a,no_stream"); @@ -914,7 +914,7 @@ static int DetectFlowSigTest01(void) Packet *p = UTHBuildPacket(buf, buflen, IPPROTO_TCP); FAIL_IF_NULL(p); - char *sig1 = "alert tcp any any -> any any (msg:\"dummy\"; " + const char *sig1 = "alert tcp any any -> any any (msg:\"dummy\"; " "content:\"nova\"; flow:no_stream; sid:1;)"; memset(&dtv, 0, sizeof(DecodeThreadVars)); diff --git a/src/detect-flowbits.c b/src/detect-flowbits.c index 34d4eaf121..56abce0bfc 100644 --- a/src/detect-flowbits.c +++ b/src/detect-flowbits.c @@ -51,7 +51,7 @@ static pcre_extra *parse_regex_study; int DetectFlowbitMatch (ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectFlowbitSetup (DetectEngineCtx *, Signature *, char *); +static int DetectFlowbitSetup (DetectEngineCtx *, Signature *, const char *); void DetectFlowbitFree (void *); void FlowBitsRegisterTests(void); @@ -149,7 +149,7 @@ int DetectFlowbitMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p return 0; } -static int DetectFlowbitParse(char *str, char *cmd, int cmd_len, char *name, +static int DetectFlowbitParse(const char *str, char *cmd, int cmd_len, char *name, int name_len) { const int max_substrings = 30; @@ -196,7 +196,7 @@ static int DetectFlowbitParse(char *str, char *cmd, int cmd_len, char *name, return 1; } -int DetectFlowbitSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr) +int DetectFlowbitSetup (DetectEngineCtx *de_ctx, Signature *s, const char *rawstr) { DetectFlowbitsData *cd = NULL; SigMatch *sm = NULL; diff --git a/src/detect-flowint.c b/src/detect-flowint.c index 76bcb1a5a7..f2c6162066 100644 --- a/src/detect-flowint.c +++ b/src/detect-flowint.c @@ -55,7 +55,7 @@ static pcre_extra *parse_regex_study; int DetectFlowintMatch(ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectFlowintSetup(DetectEngineCtx *, Signature *, char *); +static int DetectFlowintSetup(DetectEngineCtx *, Signature *, const char *); void DetectFlowintFree(void *); void DetectFlowintRegisterTests(void); @@ -218,7 +218,7 @@ end: * \retval NULL if invalid option * \retval DetectFlowintData pointer with the flowint parsed */ -DetectFlowintData *DetectFlowintParse(DetectEngineCtx *de_ctx, char *rawstr) +static DetectFlowintData *DetectFlowintParse(DetectEngineCtx *de_ctx, const char *rawstr) { DetectFlowintData *sfd = NULL; char *varname = NULL; @@ -357,7 +357,7 @@ error: * \retval 0 if all is ok * \retval -1 if we find any problem */ -static int DetectFlowintSetup(DetectEngineCtx *de_ctx, Signature *s, char *rawstr) +static int DetectFlowintSetup(DetectEngineCtx *de_ctx, Signature *s, const char *rawstr) { DetectFlowintData *sfd = NULL; SigMatch *sm = NULL; @@ -422,10 +422,11 @@ void DetectFlowintFree(void *tmp) } } +#ifdef UNITTESTS /** * \brief This is a helper funtion used for debugging purposes */ -void DetectFlowintPrintData(DetectFlowintData *sfd) +static void DetectFlowintPrintData(DetectFlowintData *sfd) { if (sfd == NULL) { SCLogDebug("DetectFlowintPrintData: Error, DetectFlowintData == NULL!"); @@ -447,12 +448,11 @@ void DetectFlowintPrintData(DetectFlowintData *sfd) } } -#ifdef UNITTESTS /** * \test DetectFlowintTestParseVal01 is a test to make sure that we set the * DetectFlowint correctly for setting a valid target value */ -int DetectFlowintTestParseVal01(void) +static int DetectFlowintTestParseVal01(void) { int result = 0; DetectFlowintData *sfd = NULL; @@ -479,7 +479,7 @@ int DetectFlowintTestParseVal01(void) * \test DetectFlowintTestParseVar01 is a test to make sure that we set the * DetectFlowint correctly for setting a valid target variable */ -int DetectFlowintTestParseVar01(void) +static int DetectFlowintTestParseVar01(void) { int result = 0; DetectFlowintData *sfd = NULL; @@ -509,7 +509,7 @@ int DetectFlowintTestParseVar01(void) * \test DetectFlowintTestParseVal02 is a test to make sure that we set the * DetectFlowint correctly for adding a valid target value */ -int DetectFlowintTestParseVal02(void) +static int DetectFlowintTestParseVal02(void) { int result = 0; DetectFlowintData *sfd = NULL; @@ -536,7 +536,7 @@ int DetectFlowintTestParseVal02(void) * \test DetectFlowintTestParseVar02 is a test to make sure that we set the * DetectFlowint correctly for adding a valid target variable */ -int DetectFlowintTestParseVar02(void) +static int DetectFlowintTestParseVar02(void) { int result = 0; DetectFlowintData *sfd = NULL; @@ -566,7 +566,7 @@ int DetectFlowintTestParseVar02(void) * \test DetectFlowintTestParseVal03 is a test to make sure that we set the * DetectFlowint correctly for substract a valid target value */ -int DetectFlowintTestParseVal03(void) +static int DetectFlowintTestParseVal03(void) { int result = 0; DetectFlowintData *sfd = NULL; @@ -593,7 +593,7 @@ int DetectFlowintTestParseVal03(void) * \test DetectFlowintTestParseVar03 is a test to make sure that we set the * DetectFlowint correctly for substract a valid target variable */ -int DetectFlowintTestParseVar03(void) +static int DetectFlowintTestParseVar03(void) { int result = 0; DetectFlowintData *sfd = NULL; @@ -624,7 +624,7 @@ int DetectFlowintTestParseVar03(void) * \test DetectFlowintTestParseVal04 is a test to make sure that we set the * DetectFlowint correctly for checking if equal to a valid target value */ -int DetectFlowintTestParseVal04(void) +static int DetectFlowintTestParseVal04(void) { int result = 0; DetectFlowintData *sfd = NULL; @@ -651,7 +651,7 @@ int DetectFlowintTestParseVal04(void) * \test DetectFlowintTestParseVar04 is a test to make sure that we set the * DetectFlowint correctly for checking if equal to a valid target variable */ -int DetectFlowintTestParseVar04(void) +static int DetectFlowintTestParseVar04(void) { int result = 0; DetectFlowintData *sfd = NULL; @@ -681,7 +681,7 @@ int DetectFlowintTestParseVar04(void) * \test DetectFlowintTestParseVal05 is a test to make sure that we set the * DetectFlowint correctly for cheking if not equal to a valid target value */ -int DetectFlowintTestParseVal05(void) +static int DetectFlowintTestParseVal05(void) { int result = 0; DetectFlowintData *sfd = NULL; @@ -708,7 +708,7 @@ int DetectFlowintTestParseVal05(void) * \test DetectFlowintTestParseVar05 is a test to make sure that we set the * DetectFlowint correctly for checking if not equal to a valid target variable */ -int DetectFlowintTestParseVar05(void) +static int DetectFlowintTestParseVar05(void) { int result = 0; DetectFlowintData *sfd = NULL; @@ -738,7 +738,7 @@ int DetectFlowintTestParseVar05(void) * \test DetectFlowintTestParseVal06 is a test to make sure that we set the * DetectFlowint correctly for cheking if greater than a valid target value */ -int DetectFlowintTestParseVal06(void) +static int DetectFlowintTestParseVal06(void) { int result = 0; DetectFlowintData *sfd = NULL; @@ -765,7 +765,7 @@ int DetectFlowintTestParseVal06(void) * \test DetectFlowintTestParseVar06 is a test to make sure that we set the * DetectFlowint correctly for checking if greater than a valid target variable */ -int DetectFlowintTestParseVar06(void) +static int DetectFlowintTestParseVar06(void) { int result = 0; DetectFlowintData *sfd = NULL; @@ -795,7 +795,7 @@ int DetectFlowintTestParseVar06(void) * \test DetectFlowintTestParseVal07 is a test to make sure that we set the * DetectFlowint correctly for cheking if greater or equal than a valid target value */ -int DetectFlowintTestParseVal07(void) +static int DetectFlowintTestParseVal07(void) { int result = 0; DetectFlowintData *sfd = NULL; @@ -822,7 +822,7 @@ int DetectFlowintTestParseVal07(void) * \test DetectFlowintTestParseVar07 is a test to make sure that we set the * DetectFlowint correctly for checking if greater or equal than a valid target variable */ -int DetectFlowintTestParseVar07(void) +static int DetectFlowintTestParseVar07(void) { int result = 0; DetectFlowintData *sfd = NULL; @@ -852,7 +852,7 @@ int DetectFlowintTestParseVar07(void) * \test DetectFlowintTestParseVal08 is a test to make sure that we set the * DetectFlowint correctly for cheking if lower or equal than a valid target value */ -int DetectFlowintTestParseVal08(void) +static int DetectFlowintTestParseVal08(void) { int result = 0; DetectFlowintData *sfd = NULL; @@ -879,7 +879,7 @@ int DetectFlowintTestParseVal08(void) * \test DetectFlowintTestParseVar08 is a test to make sure that we set the * DetectFlowint correctly for checking if lower or equal than a valid target variable */ -int DetectFlowintTestParseVar08(void) +static int DetectFlowintTestParseVar08(void) { int result = 0; DetectFlowintData *sfd = NULL; @@ -909,7 +909,7 @@ int DetectFlowintTestParseVar08(void) * \test DetectFlowintTestParseVal09 is a test to make sure that we set the * DetectFlowint correctly for cheking if lower than a valid target value */ -int DetectFlowintTestParseVal09(void) +static int DetectFlowintTestParseVal09(void) { int result = 0; DetectFlowintData *sfd = NULL; @@ -936,7 +936,7 @@ int DetectFlowintTestParseVal09(void) * \test DetectFlowintTestParseVar09 is a test to make sure that we set the * DetectFlowint correctly for checking if lower than a valid target variable */ -int DetectFlowintTestParseVar09(void) +static int DetectFlowintTestParseVar09(void) { int result = 0; DetectFlowintData *sfd = NULL; @@ -966,7 +966,7 @@ int DetectFlowintTestParseVar09(void) * \test DetectFlowintTestParseVar09 is a test to make sure that handle the * isset keyword correctly */ -int DetectFlowintTestParseIsset10(void) +static int DetectFlowintTestParseIsset10(void) { int result = 1; DetectFlowintData *sfd = NULL; @@ -1009,7 +1009,7 @@ int DetectFlowintTestParseIsset10(void) * \test DetectFlowintTestParseInvalidSyntaxis01 is a test to make sure that we dont set the * DetectFlowint for a invalid input option */ -int DetectFlowintTestParseInvalidSyntaxis01(void) +static int DetectFlowintTestParseInvalidSyntaxis01(void) { int result = 1; DetectFlowintData *sfd = NULL; @@ -1095,7 +1095,7 @@ error: * a "noalert", so we can do all increments * silently until we reach 6 next packets counted */ -int DetectFlowintTestPacket01Real() +static int DetectFlowintTestPacket01Real(void) { Packet *p = NULL; ThreadVars th_v; @@ -1107,7 +1107,7 @@ int DetectFlowintTestPacket01Real() de_ctx->flags |= DE_QUIET; - char *sigs[5]; + const char *sigs[5]; sigs[0] = "alert tcp any any -> any any (msg:\"Setting a flowint counter\"; content:\"GET\"; flowint:myvar,=,1; flowint:maxvar,=,6; sid:101;)"; sigs[1] = "alert tcp any any -> any any (msg:\"Adding to flowint counter\"; content:\"Unauthorized\"; flowint: myvar,+,2; sid:102;)"; sigs[2] = "alert tcp any any -> any any (msg:\"if the flowint counter is 3 create a new counter\"; content:\"Unauthorized\"; flowint: myvar,==,3; flowint: cntpackets, =, 0; sid:103;)"; @@ -1168,7 +1168,7 @@ int DetectFlowintTestPacket01Real() * \test DetectFlowintTestPacket02Real * \brief like DetectFlowintTestPacket01Real but using isset/notset keywords */ -static int DetectFlowintTestPacket02Real() +static int DetectFlowintTestPacket02Real(void) { Packet *p = NULL; ThreadVars th_v; @@ -1180,7 +1180,7 @@ static int DetectFlowintTestPacket02Real() de_ctx->flags |= DE_QUIET; - char *sigs[5]; + const char *sigs[5]; sigs[0] = "alert tcp any any -> any any (msg:\"Setting a flowint counter\"; content:\"GET\"; flowint: myvar, notset; flowint:maxvar,notset; flowint: myvar,=,1; flowint: maxvar,=,6; sid:101;)"; sigs[1] = "alert tcp any any -> any any (msg:\"Adding to flowint counter\"; content:\"Unauthorized\"; flowint:myvar,isset; flowint: myvar,+,2; sid:102;)"; sigs[2] = "alert tcp any any -> any any (msg:\"if the flowint counter is 3 create a new counter\"; content:\"Unauthorized\"; flowint: myvar, isset; flowint: myvar,==,3; flowint:cntpackets,notset; flowint: cntpackets, =, 0; sid:103;)"; @@ -1241,7 +1241,7 @@ static int DetectFlowintTestPacket02Real() * \test DetectFlowintTestPacket03Real * \brief Check the behaviour of isset/notset */ -int DetectFlowintTestPacket03Real() +static int DetectFlowintTestPacket03Real(void) { Packet *p = NULL; ThreadVars th_v; @@ -1253,7 +1253,7 @@ int DetectFlowintTestPacket03Real() de_ctx->flags |= DE_QUIET; - char *sigs[3]; + const char *sigs[3]; sigs[0] = "alert tcp any any -> any any (msg:\"check notset\"; content:\"GET\"; flowint: myvar, notset; flowint: myvar,=,0; flowint: other,=,10; sid:101;)"; sigs[1] = "alert tcp any any -> any any (msg:\"check isset\"; content:\"Unauthorized\"; flowint:myvar,isset; flowint: other,isset; sid:102;)"; sigs[2] = "alert tcp any any -> any any (msg:\"check notset\"; content:\"Unauthorized\"; flowint:lala,isset; sid:103;)"; diff --git a/src/detect-flowvar.c b/src/detect-flowvar.c index e7f13b6fdf..3025df14f1 100644 --- a/src/detect-flowvar.c +++ b/src/detect-flowvar.c @@ -47,7 +47,7 @@ static pcre_extra *parse_regex_study; int DetectFlowvarMatch (ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectFlowvarSetup (DetectEngineCtx *, Signature *, char *); +static int DetectFlowvarSetup (DetectEngineCtx *, Signature *, const char *); static int DetectFlowvarPostMatch(ThreadVars *tv, DetectEngineThreadCtx *det_ctx, Packet *p, const Signature *s, const SigMatchCtx *ctx); static void DetectFlowvarDataFree(void *ptr); @@ -114,7 +114,7 @@ int DetectFlowvarMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p return ret; } -static int DetectFlowvarSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr) +static int DetectFlowvarSetup (DetectEngineCtx *de_ctx, Signature *s, const char *rawstr) { DetectFlowvarData *fd = NULL; SigMatch *sm = NULL; diff --git a/src/detect-fragbits.c b/src/detect-fragbits.c index fd1fbf18a3..3349ab3480 100644 --- a/src/detect-fragbits.c +++ b/src/detect-fragbits.c @@ -50,7 +50,7 @@ * Regex * fragbits: [!+*](MDR) */ -#define PARSE_REGEX "^\\s*(?:([\\+\\*!]))?\\s*([MDR]+)" +#define PARSE_REGEX "^(?:([\\+\\*!]))?\\s*([MDR]+)" /** * FragBits args[0] *(3) +(2) !(1) @@ -70,7 +70,7 @@ static pcre_extra *parse_regex_study; static int DetectFragBitsMatch (ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectFragBitsSetup (DetectEngineCtx *, Signature *, char *); +static int DetectFragBitsSetup (DetectEngineCtx *, Signature *, const char *); static void DetectFragBitsFree(void *); static int PrefilterSetupFragBits(SigGroupHead *sgh); @@ -163,7 +163,7 @@ static int DetectFragBitsMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, * \retval de pointer to DetectFragBitsData on success * \retval NULL on failure */ -static DetectFragBitsData *DetectFragBitsParse (char *rawstr) +static DetectFragBitsData *DetectFragBitsParse (const char *rawstr) { DetectFragBitsData *de = NULL; #define MAX_SUBSTRINGS 30 @@ -175,16 +175,13 @@ static DetectFragBitsData *DetectFragBitsParse (char *rawstr) int i; ret = pcre_exec(parse_regex, parse_regex_study, rawstr, strlen(rawstr), 0, 0, ov, MAX_SUBSTRINGS); - if (ret < 1) { SCLogError(SC_ERR_PCRE_MATCH, "pcre_exec parse error, ret %" PRId32 ", string %s", ret, rawstr); goto error; } for (i = 0; i < (ret - 1); i++) { - - res = pcre_get_substring((char *)rawstr, ov, MAX_SUBSTRINGS,i + 1, &str_ptr); - + res = pcre_get_substring((char *)rawstr, ov, MAX_SUBSTRINGS, i + 1, &str_ptr); if (res < 0) { SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre_get_substring failed"); goto error; @@ -193,7 +190,7 @@ static DetectFragBitsData *DetectFragBitsParse (char *rawstr) args[i] = (char *)str_ptr; } - if(args[1] == NULL) { + if (args[1] == NULL) { SCLogError(SC_ERR_INVALID_VALUE, "invalid value"); goto error; } @@ -206,25 +203,19 @@ static DetectFragBitsData *DetectFragBitsParse (char *rawstr) /** First parse args[0] */ - if(args[0]) { - + if (args[0] && strlen(args[0])) { ptr = args[0]; - - while (*ptr != '\0') { - switch (*ptr) { - case '!': - de->modifier = MODIFIER_NOT; - break; - case '+': - de->modifier = MODIFIER_PLUS; - break; - case '*': - de->modifier = MODIFIER_ANY; - break; - } - ptr++; + switch (*ptr) { + case '!': + de->modifier = MODIFIER_NOT; + break; + case '+': + de->modifier = MODIFIER_PLUS; + break; + case '*': + de->modifier = MODIFIER_ANY; + break; } - } /** Second parse first set of fragbits */ @@ -286,14 +277,14 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -static int DetectFragBitsSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr) +static int DetectFragBitsSetup (DetectEngineCtx *de_ctx, Signature *s, const char *rawstr) { DetectFragBitsData *de = NULL; SigMatch *sm = NULL; de = DetectFragBitsParse(rawstr); if (de == NULL) - goto error; + return -1; sm = SigMatchAlloc(); if (sm == NULL) @@ -308,8 +299,8 @@ static int DetectFragBitsSetup (DetectEngineCtx *de_ctx, Signature *s, char *raw return 0; error: - if (de) SCFree(de); - if (sm) SCFree(sm); + if (de) + SCFree(de); return -1; } @@ -475,8 +466,7 @@ static int FragBitsTestParse03 (void) 0x00 ,0x0e ,0x10 ,0x00 ,0x04 ,0x81 ,0x6f ,0x0b, 0x51}; Packet *p = SCMalloc(SIZE_OF_PACKET); - if (unlikely(p == NULL)) - return 0; + FAIL_IF(unlikely(p == NULL)); ThreadVars tv; DecodeThreadVars dtv; IPV4Hdr ipv4h; @@ -498,31 +488,22 @@ static int FragBitsTestParse03 (void) de = DetectFragBitsParse("D"); - if (de == NULL || (de->fragbits != FRAGBITS_HAVE_DF)) - goto error; + FAIL_IF(de == NULL || (de->fragbits != FRAGBITS_HAVE_DF)); sm = SigMatchAlloc(); - if (sm == NULL) - goto error; + FAIL_IF(sm == NULL); sm->type = DETECT_FRAGBITS; sm->ctx = (SigMatchCtx *)de; ret = DetectFragBitsMatch(&tv, NULL, p, NULL, sm->ctx); + FAIL_IF(ret == 0); - if(ret) { - if (de) SCFree(de); - if (sm) SCFree(sm); - SCFree(p); - return 1; - } - -error: FlowShutdown(); - if (de) SCFree(de); - if (sm) SCFree(sm); + SCFree(de); + SCFree(sm); SCFree(p); - return 0; + PASS; } /** @@ -572,8 +553,7 @@ static int FragBitsTestParse04 (void) 0x00 ,0x0e ,0x10 ,0x00 ,0x04 ,0x81 ,0x6f ,0x0b, 0x51}; Packet *p = SCMalloc(SIZE_OF_PACKET); - if (unlikely(p == NULL)) - return 0; + FAIL_IF(unlikely(p == NULL)); ThreadVars tv; DecodeThreadVars dtv; IPV4Hdr ipv4h; @@ -596,35 +576,24 @@ static int FragBitsTestParse04 (void) de = DetectFragBitsParse("!D"); - if (de == NULL || (de->fragbits != FRAGBITS_HAVE_DF) || (de->modifier != MODIFIER_NOT)) - goto error; + FAIL_IF(de == NULL); + FAIL_IF(de->fragbits != FRAGBITS_HAVE_DF); + FAIL_IF(de->modifier != MODIFIER_NOT); sm = SigMatchAlloc(); - if (sm == NULL) - goto error; + FAIL_IF(sm == NULL); sm->type = DETECT_FRAGBITS; sm->ctx = (SigMatchCtx *)de; ret = DetectFragBitsMatch(&tv, NULL, p, NULL, sm->ctx); - - if(ret) { - if (de) SCFree(de); - if (sm) SCFree(sm); - PACKET_RECYCLE(p); - FlowShutdown(); - SCFree(p); - return 0; - } - - /* Error expected. */ -error: - if (de) SCFree(de); - if (sm) SCFree(sm); + FAIL_IF(ret); + SCFree(de); + SCFree(sm); PACKET_RECYCLE(p); FlowShutdown(); SCFree(p); - return 1; + PASS; } #endif /* UNITTESTS */ diff --git a/src/detect-fragoffset.c b/src/detect-fragoffset.c index 5f7a9ec2ed..5f5eacc8a3 100644 --- a/src/detect-fragoffset.c +++ b/src/detect-fragoffset.c @@ -46,7 +46,7 @@ static pcre_extra *parse_regex_study; static int DetectFragOffsetMatch(ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectFragOffsetSetup(DetectEngineCtx *, Signature *, char *); +static int DetectFragOffsetSetup(DetectEngineCtx *, Signature *, const char *); void DetectFragOffsetRegisterTests(void); void DetectFragOffsetFree(void *); @@ -136,7 +136,7 @@ static int DetectFragOffsetMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, * \retval fragoff pointer to DetectFragOffsetData on success * \retval NULL on failure */ -DetectFragOffsetData *DetectFragOffsetParse (char *fragoffsetstr) +static DetectFragOffsetData *DetectFragOffsetParse (const char *fragoffsetstr) { DetectFragOffsetData *fragoff = NULL; char *substr[3] = {NULL, NULL, NULL}; @@ -217,7 +217,7 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -static int DetectFragOffsetSetup (DetectEngineCtx *de_ctx, Signature *s, char *fragoffsetstr) +static int DetectFragOffsetSetup (DetectEngineCtx *de_ctx, Signature *s, const char *fragoffsetstr) { DetectFragOffsetData *fragoff = NULL; SigMatch *sm = NULL; @@ -329,7 +329,7 @@ static _Bool PrefilterFragOffsetIsPrefilterable(const Signature *s) /** * \test DetectFragOffsetParseTest01 is a test for setting a valid fragoffset value */ -int DetectFragOffsetParseTest01 (void) +static int DetectFragOffsetParseTest01 (void) { DetectFragOffsetData *fragoff = NULL; fragoff = DetectFragOffsetParse("300"); @@ -344,7 +344,7 @@ int DetectFragOffsetParseTest01 (void) * \test DetectFragOffsetParseTest02 is a test for setting a valid fragoffset value * with spaces all around */ -int DetectFragOffsetParseTest02 (void) +static int DetectFragOffsetParseTest02 (void) { DetectFragOffsetData *fragoff = NULL; fragoff = DetectFragOffsetParse(">300"); @@ -358,7 +358,7 @@ int DetectFragOffsetParseTest02 (void) /** * \test DetectFragOffsetParseTest03 is a test for setting an invalid fragoffset value */ -int DetectFragOffsetParseTest03 (void) +static int DetectFragOffsetParseTest03 (void) { DetectFragOffsetData *fragoff = NULL; fragoff = DetectFragOffsetParse("badc"); @@ -374,7 +374,7 @@ int DetectFragOffsetParseTest03 (void) * fragoffset keyword by creating 2 rules and matching a crafted packet * against them. Only the first one shall trigger. */ -int DetectFragOffsetMatchTest01 (void) +static int DetectFragOffsetMatchTest01 (void) { int result = 0; Packet *p = SCMalloc(SIZE_OF_PACKET); diff --git a/src/detect-ftpbounce.c b/src/detect-ftpbounce.c index 0e595e582d..64816f0c78 100644 --- a/src/detect-ftpbounce.c +++ b/src/detect-ftpbounce.c @@ -51,7 +51,7 @@ static int DetectFtpbounceALMatch(ThreadVars *, DetectEngineThreadCtx *, Flow *, uint8_t, void *, void *, const Signature *, const SigMatchCtx *); -static int DetectFtpbounceSetup(DetectEngineCtx *, Signature *, char *); +static int DetectFtpbounceSetup(DetectEngineCtx *, Signature *, const char *); static void DetectFtpbounceRegisterTests(void); static int g_ftp_request_list_id = 0; @@ -220,7 +220,7 @@ static int DetectFtpbounceALMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx, * \retval 0 on Success * \retval -1 on Failure */ -int DetectFtpbounceSetup(DetectEngineCtx *de_ctx, Signature *s, char *ftpbouncestr) +int DetectFtpbounceSetup(DetectEngineCtx *de_ctx, Signature *s, const char *ftpbouncestr) { SCEnter(); diff --git a/src/detect-geoip.c b/src/detect-geoip.c index 1af990c1e4..29fab52f0a 100644 --- a/src/detect-geoip.c +++ b/src/detect-geoip.c @@ -39,7 +39,7 @@ #ifndef HAVE_GEOIP -static int DetectGeoipSetupNoSupport (DetectEngineCtx *a, Signature *b, char *c) +static int DetectGeoipSetupNoSupport (DetectEngineCtx *a, Signature *b, const char *c) { SCLogError(SC_ERR_NO_GEOIP_SUPPORT, "no GeoIP support built in, needed for geoip keyword"); return -1; @@ -61,10 +61,9 @@ void DetectGeoipRegister(void) #include - static int DetectGeoipMatch(ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectGeoipSetup(DetectEngineCtx *, Signature *, char *); +static int DetectGeoipSetup(DetectEngineCtx *, Signature *, const char *); static void DetectGeoipRegisterTests(void); static void DetectGeoipDataFree(void *); @@ -211,7 +210,7 @@ static int DetectGeoipMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx, * \retval pointer to DetectGeoipData on success * \retval NULL on failure */ -static DetectGeoipData *DetectGeoipDataParse (char *str) +static DetectGeoipData *DetectGeoipDataParse (const char *str) { DetectGeoipData *geoipdata = NULL; uint16_t pos = 0; @@ -264,8 +263,7 @@ static DetectGeoipData *DetectGeoipDataParse (char *str) if (geoipdata->flags != GEOIP_MATCH_NO_FLAG && skiplocationparsing == 0) { /* Parse location string: for now just the country code(s) */ - if (str[prevpos] == '!') - { + if (str[prevpos] == '!') { geoipdata->flags |= GEOIP_MATCH_NEGATED; prevpos++; /* dot not copy the ! */ } @@ -324,7 +322,7 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -static int DetectGeoipSetup(DetectEngineCtx *de_ctx, Signature *s, char *optstr) +static int DetectGeoipSetup(DetectEngineCtx *de_ctx, Signature *s, const char *optstr) { DetectGeoipData *geoipdata = NULL; SigMatch *sm = NULL; @@ -370,111 +368,83 @@ static void DetectGeoipDataFree(void *ptr) #ifdef UNITTESTS -static int GeoipParseTest(char *rule, int ncountries, char **countries, uint32_t flags) +static int GeoipParseTest(const char *rule, int ncountries, const char **countries, uint32_t flags) { DetectEngineCtx *de_ctx = NULL; - int result = 0; Signature *s = NULL; DetectGeoipData *data = NULL; de_ctx = DetectEngineCtxInit(); - if (de_ctx == NULL) - goto end; - + FAIL_IF(de_ctx == NULL); de_ctx->flags |= DE_QUIET; - de_ctx->sig_list = SigInit(de_ctx, rule); - if (de_ctx->sig_list == NULL) { - printf("sig parse failed: "); - goto end; - } + de_ctx->sig_list = SigInit(de_ctx, rule); + FAIL_IF(de_ctx->sig_list == NULL); s = de_ctx->sig_list; - if (s->sm_lists_tail[DETECT_SM_LIST_MATCH] == NULL) { - printf("empty server body list: "); - goto end; - } + FAIL_IF(s->sm_lists_tail[DETECT_SM_LIST_MATCH] == NULL); - if (s->sm_lists_tail[DETECT_SM_LIST_MATCH]->type != DETECT_GEOIP) { - printf("last sm not geoip: "); - goto end; - } + FAIL_IF(s->sm_lists_tail[DETECT_SM_LIST_MATCH]->type != DETECT_GEOIP); data = (DetectGeoipData *)s->sm_lists_tail[DETECT_SM_LIST_MATCH]->ctx; - if (data->flags != flags) { - printf("flags not right: (flags=%d)",data->flags); - goto end; - } + FAIL_IF(data->flags != flags); - if (data->nlocations!=ncountries) - { - printf("wrong number of parsed countries: "); - goto end; - } + FAIL_IF(data->nlocations!=ncountries); for (int i=0; ilocation[i],countries[i])!=0) - { - printf("wrong parsed country code: "); - goto end; - } + FAIL_IF(strcmp((char *)data->location[i],countries[i])!=0); } - result = 1; -end: - SigGroupCleanup(de_ctx); - SigCleanSignatures(de_ctx); DetectEngineCtxFree(de_ctx); - - return result; + PASS; } static int GeoipParseTest01(void) { - char *ccodes[1] = {"US"}; + const char *ccodes[1] = {"US"}; return GeoipParseTest("alert tcp any any -> any any (geoip:US;sid:1;)", 1, ccodes, GEOIP_MATCH_ANY_FLAG); } static int GeoipParseTest02(void) { - char *ccodes[1] = {"US"}; + const char *ccodes[1] = {"US"}; return GeoipParseTest("alert tcp any any -> any any (geoip:!US;sid:1;)", 1, ccodes, GEOIP_MATCH_ANY_FLAG | GEOIP_MATCH_NEGATED); } static int GeoipParseTest03(void) { - char *ccodes[1] = {"US"}; + const char *ccodes[1] = {"US"}; return GeoipParseTest("alert tcp any any -> any any (geoip:!US;sid:1;)", 1, ccodes, GEOIP_MATCH_ANY_FLAG | GEOIP_MATCH_NEGATED); } static int GeoipParseTest04(void) { - char *ccodes[1] = {"US"}; + const char *ccodes[1] = {"US"}; return GeoipParseTest("alert tcp any any -> any any (geoip:src,US;sid:1;)", 1, ccodes, GEOIP_MATCH_SRC_FLAG); } static int GeoipParseTest05(void) { - char *ccodes[1] = {"US"}; + const char *ccodes[1] = {"US"}; return GeoipParseTest("alert tcp any any -> any any (geoip:dst,!US;sid:1;)", 1, ccodes, GEOIP_MATCH_DST_FLAG | GEOIP_MATCH_NEGATED); } static int GeoipParseTest06(void) { - char *ccodes[3] = {"US", "ES", "UK"}; + const char *ccodes[3] = {"US", "ES", "UK"}; return GeoipParseTest("alert tcp any any -> any any (geoip:US,ES,UK;sid:1;)", 3, ccodes, GEOIP_MATCH_ANY_FLAG); } static int GeoipParseTest07(void) { - char *ccodes[3] = {"US", "ES", "UK"}; + const char *ccodes[3] = {"US", "ES", "UK"}; return GeoipParseTest("alert tcp any any -> any any (geoip:both,!US,ES,UK;sid:1;)", 3, ccodes, GEOIP_MATCH_BOTH_FLAG | GEOIP_MATCH_NEGATED); } @@ -483,7 +453,7 @@ static int GeoipParseTest07(void) * \internal * \brief This test tests geoip success and failure. */ -static int GeoipMatchTest(char *rule, char *srcip, char *dstip) +static int GeoipMatchTest(const char *rule, const char *srcip, const char *dstip) { uint8_t *buf = (uint8_t *) "GET / HTTP/1.0\r\n\r\n"; uint16_t buflen = strlen((char *)buf); diff --git a/src/detect-gid.c b/src/detect-gid.c index 5fe93e494c..9dca683685 100644 --- a/src/detect-gid.c +++ b/src/detect-gid.c @@ -36,7 +36,7 @@ #include "util-unittest.h" #include "util-debug.h" -static int DetectGidSetup (DetectEngineCtx *, Signature *, char *); +static int DetectGidSetup (DetectEngineCtx *, Signature *, const char *); /** * \brief Registration function for gid: keyword @@ -64,23 +64,8 @@ void DetectGidRegister (void) * \retval 0 on Success * \retval -1 on Failure */ -static int DetectGidSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr) +static int DetectGidSetup (DetectEngineCtx *de_ctx, Signature *s, const char *rawstr) { - char *str = rawstr; - char duped = 0; - - /* Strip leading and trailing "s. */ - if (rawstr[0] == '\"') { - str = SCStrdup(rawstr + 1); - if (unlikely(str == NULL)) { - return -1; - } - if (strlen(str) && str[strlen(str) - 1] == '\"') { - str[strlen(str) - 1] = '\"'; - } - duped = 1; - } - unsigned long gid = 0; char *endptr = NULL; gid = strtoul(rawstr, &endptr, 10); @@ -96,13 +81,9 @@ static int DetectGidSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr) s->gid = (uint32_t)gid; - if (duped) - SCFree(str); return 0; error: - if (duped) - SCFree(str); return -1; } diff --git a/src/detect-hostbits.c b/src/detect-hostbits.c index bf1b728824..addca7c374 100644 --- a/src/detect-hostbits.c +++ b/src/detect-hostbits.c @@ -70,7 +70,7 @@ static pcre_extra *parse_regex_study; static int DetectHostbitMatch (ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectHostbitSetup (DetectEngineCtx *, Signature *, char *); +static int DetectHostbitSetup (DetectEngineCtx *, Signature *, const char *); void DetectHostbitFree (void *); void HostBitsRegisterTests(void); @@ -318,7 +318,7 @@ static int DetectHostbitParse(const char *str, char *cmd, int cmd_len, return 1; } -int DetectHostbitSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr) +int DetectHostbitSetup (DetectEngineCtx *de_ctx, Signature *s, const char *rawstr) { DetectXbitsData *cd = NULL; SigMatch *sm = NULL; diff --git a/src/detect-http-accept-enc.c b/src/detect-http-accept-enc.c index 94e3c62158..5d4c6caf07 100644 --- a/src/detect-http-accept-enc.c +++ b/src/detect-http-accept-enc.c @@ -39,6 +39,7 @@ #define KEYWORD_TOSERVER 1 #include "detect-http-headers-stub.h" +#include "detect-http-accept-enc.h" void RegisterHttpHeadersAcceptEnc(void) { diff --git a/src/detect-http-accept-lang.c b/src/detect-http-accept-lang.c index 2d1a57032b..9d4806057f 100644 --- a/src/detect-http-accept-lang.c +++ b/src/detect-http-accept-lang.c @@ -39,6 +39,7 @@ #define KEYWORD_TOSERVER 1 #include "detect-http-headers-stub.h" +#include "detect-http-accept-lang.h" void RegisterHttpHeadersAcceptLang(void) { diff --git a/src/detect-http-accept.c b/src/detect-http-accept.c index 080bf4eeaf..ac6df6d11d 100644 --- a/src/detect-http-accept.c +++ b/src/detect-http-accept.c @@ -39,6 +39,7 @@ #define KEYWORD_TOSERVER 1 #include "detect-http-headers-stub.h" +#include "detect-http-accept.h" void RegisterHttpHeadersAccept(void) { diff --git a/src/detect-http-client-body.c b/src/detect-http-client-body.c index c9da5d0247..13ffe54707 100644 --- a/src/detect-http-client-body.c +++ b/src/detect-http-client-body.c @@ -58,7 +58,7 @@ #include "detect-engine-hcbd.h" #include "stream-tcp.h" -static int DetectHttpClientBodySetup(DetectEngineCtx *, Signature *, char *); +static int DetectHttpClientBodySetup(DetectEngineCtx *, Signature *, const char *); static void DetectHttpClientBodyRegisterTests(void); static void DetectHttpClientBodyFree(void *); static void DetectHttpClientBodySetupCallback(Signature *s); @@ -115,7 +115,7 @@ static void DetectHttpClientBodySetupCallback(Signature *s) * \retval 0 On success * \retval -1 On failure */ -int DetectHttpClientBodySetup(DetectEngineCtx *de_ctx, Signature *s, char *arg) +int DetectHttpClientBodySetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg) { return DetectEngineContentModifierBufferSetup(de_ctx, s, arg, DETECT_AL_HTTP_CLIENT_BODY, @@ -1737,7 +1737,7 @@ end: -int DetectHttpClientBodyTest22(void) +static int DetectHttpClientBodyTest22(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1792,7 +1792,7 @@ int DetectHttpClientBodyTest22(void) return result; } -int DetectHttpClientBodyTest23(void) +static int DetectHttpClientBodyTest23(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1846,7 +1846,7 @@ int DetectHttpClientBodyTest23(void) return result; } -int DetectHttpClientBodyTest24(void) +static int DetectHttpClientBodyTest24(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1900,7 +1900,7 @@ int DetectHttpClientBodyTest24(void) return result; } -int DetectHttpClientBodyTest25(void) +static int DetectHttpClientBodyTest25(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1956,7 +1956,7 @@ int DetectHttpClientBodyTest25(void) return result; } -int DetectHttpClientBodyTest26(void) +static int DetectHttpClientBodyTest26(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2013,7 +2013,7 @@ int DetectHttpClientBodyTest26(void) return result; } -int DetectHttpClientBodyTest27(void) +static int DetectHttpClientBodyTest27(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2039,7 +2039,7 @@ int DetectHttpClientBodyTest27(void) return result; } -int DetectHttpClientBodyTest28(void) +static int DetectHttpClientBodyTest28(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2095,7 +2095,7 @@ int DetectHttpClientBodyTest28(void) return result; } -int DetectHttpClientBodyTest29(void) +static int DetectHttpClientBodyTest29(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2139,7 +2139,7 @@ int DetectHttpClientBodyTest29(void) return result; } -int DetectHttpClientBodyTest30(void) +static int DetectHttpClientBodyTest30(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2183,7 +2183,7 @@ int DetectHttpClientBodyTest30(void) return result; } -int DetectHttpClientBodyTest31(void) +static int DetectHttpClientBodyTest31(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2207,7 +2207,7 @@ int DetectHttpClientBodyTest31(void) return result; } -int DetectHttpClientBodyTest32(void) +static int DetectHttpClientBodyTest32(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2231,7 +2231,7 @@ int DetectHttpClientBodyTest32(void) return result; } -int DetectHttpClientBodyTest33(void) +static int DetectHttpClientBodyTest33(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2255,7 +2255,7 @@ int DetectHttpClientBodyTest33(void) return result; } -int DetectHttpClientBodyTest34(void) +static int DetectHttpClientBodyTest34(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2306,7 +2306,7 @@ int DetectHttpClientBodyTest34(void) return result; } -int DetectHttpClientBodyTest35(void) +static int DetectHttpClientBodyTest35(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2357,7 +2357,7 @@ int DetectHttpClientBodyTest35(void) return result; } -int DetectHttpClientBodyTest36(void) +static int DetectHttpClientBodyTest36(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; diff --git a/src/detect-http-connection.c b/src/detect-http-connection.c index e53f74aa04..b2cc8ce80a 100644 --- a/src/detect-http-connection.c +++ b/src/detect-http-connection.c @@ -39,6 +39,7 @@ #define KEYWORD_TOSERVER 1 #include "detect-http-headers-stub.h" +#include "detect-http-connection.h" void RegisterHttpHeadersConnection(void) { diff --git a/src/detect-http-content-len.c b/src/detect-http-content-len.c index cbce16259d..63593a2348 100644 --- a/src/detect-http-content-len.c +++ b/src/detect-http-content-len.c @@ -40,6 +40,7 @@ #define KEYWORD_TOCLIENT 1 #include "detect-http-headers-stub.h" +#include "detect-http-content-len.h" void RegisterHttpHeadersContentLen(void) { diff --git a/src/detect-http-content-type.c b/src/detect-http-content-type.c index 5ca85b6986..c76e2c1921 100644 --- a/src/detect-http-content-type.c +++ b/src/detect-http-content-type.c @@ -40,6 +40,7 @@ #define KEYWORD_TOCLIENT 1 #include "detect-http-headers-stub.h" +#include "detect-http-content-type.h" void RegisterHttpHeadersContentType(void) { diff --git a/src/detect-http-cookie.c b/src/detect-http-cookie.c index 4a6fde1901..1a24fffad4 100644 --- a/src/detect-http-cookie.c +++ b/src/detect-http-cookie.c @@ -61,7 +61,7 @@ #include "detect-engine-hcd.h" #include "stream-tcp.h" -static int DetectHttpCookieSetup (DetectEngineCtx *, Signature *, char *); +static int DetectHttpCookieSetup (DetectEngineCtx *, Signature *, const char *); static void DetectHttpCookieRegisterTests(void); static void DetectHttpCookieFree(void *); static void DetectHttpCookieSetupCallback(Signature *s); @@ -129,7 +129,7 @@ void DetectHttpCookieFree(void *ptr) * \retval -1 On failure */ -static int DetectHttpCookieSetup(DetectEngineCtx *de_ctx, Signature *s, char *str) +static int DetectHttpCookieSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str) { return DetectEngineContentModifierBufferSetup(de_ctx, s, str, DETECT_AL_HTTP_COOKIE, diff --git a/src/detect-http-header-names.c b/src/detect-http-header-names.c index 177ab6ae31..44f1cf0018 100644 --- a/src/detect-http-header-names.c +++ b/src/detect-http-header-names.c @@ -44,6 +44,7 @@ #include "detect-content.h" #include "detect-pcre.h" #include "detect-http-header-common.h" +#include "detect-http-header-names.h" #include "flow.h" #include "flow-var.h" @@ -212,7 +213,7 @@ static void PrefilterTxHttpRequestTrailers(DetectEngineThreadCtx *det_ctx, } } #endif -int PrefilterTxHttpRequestHeaderNamesRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx) +static int PrefilterTxHttpRequestHeaderNamesRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx) { SCEnter(); @@ -292,7 +293,7 @@ static void PrefilterTxHttpResponseTrailers(DetectEngineThreadCtx *det_ctx, } } #endif -int PrefilterTxHttpResponseHeaderNamesRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx) +static int PrefilterTxHttpResponseHeaderNamesRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx) { SCEnter(); @@ -309,7 +310,7 @@ int PrefilterTxHttpResponseHeaderNamesRegister(SigGroupHead *sgh, MpmCtx *mpm_ct #endif } -int InspectEngineHttpHeaderNames(ThreadVars *tv, +static int InspectEngineHttpHeaderNames(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, const Signature *s, const SigMatchData *smd, Flow *f, uint8_t flags, void *alstate, void *tx, uint64_t tx_id) @@ -357,7 +358,7 @@ int InspectEngineHttpHeaderNames(ThreadVars *tv, * \retval 0 On success. * \retval -1 On failure. */ -int DetectHttpHeaderNamesSetup(DetectEngineCtx *de_ctx, Signature *s, char *arg) +static int DetectHttpHeaderNamesSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg) { s->init_data->list = g_buffer_id; return 0; diff --git a/src/detect-http-header.c b/src/detect-http-header.c index e38f6e55d4..522cc13a1a 100644 --- a/src/detect-http-header.c +++ b/src/detect-http-header.c @@ -63,7 +63,7 @@ #include "detect-http-header-common.h" #include "stream-tcp.h" -static int DetectHttpHeaderSetup(DetectEngineCtx *, Signature *, char *); +static int DetectHttpHeaderSetup(DetectEngineCtx *, Signature *, const char *); static void DetectHttpHeaderRegisterTests(void); static void DetectHttpHeaderSetupCallback(Signature *); static int g_http_header_buffer_id = 0; @@ -359,7 +359,7 @@ static int DetectEngineInspectHttpHeader(ThreadVars *tv, * \retval 0 On success. * \retval -1 On failure. */ -static int DetectHttpHeaderSetup(DetectEngineCtx *de_ctx, Signature *s, char *arg) +static int DetectHttpHeaderSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg) { return DetectEngineContentModifierBufferSetup(de_ctx, s, arg, DETECT_AL_HTTP_HEADER, @@ -1509,7 +1509,7 @@ end: return result; } -int DetectHttpHeaderTest20(void) +static int DetectHttpHeaderTest20(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1553,7 +1553,7 @@ int DetectHttpHeaderTest20(void) return result; } -int DetectHttpHeaderTest21(void) +static int DetectHttpHeaderTest21(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1597,7 +1597,7 @@ int DetectHttpHeaderTest21(void) return result; } -int DetectHttpHeaderTest22(void) +static int DetectHttpHeaderTest22(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1621,7 +1621,7 @@ int DetectHttpHeaderTest22(void) return result; } -int DetectHttpHeaderTest23(void) +static int DetectHttpHeaderTest23(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1645,7 +1645,7 @@ int DetectHttpHeaderTest23(void) return result; } -int DetectHttpHeaderTest24(void) +static int DetectHttpHeaderTest24(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1669,7 +1669,7 @@ int DetectHttpHeaderTest24(void) return result; } -int DetectHttpHeaderTest25(void) +static int DetectHttpHeaderTest25(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1720,7 +1720,7 @@ int DetectHttpHeaderTest25(void) return result; } -int DetectHttpHeaderTest26(void) +static int DetectHttpHeaderTest26(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1771,7 +1771,7 @@ int DetectHttpHeaderTest26(void) return result; } -int DetectHttpHeaderTest27(void) +static int DetectHttpHeaderTest27(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; diff --git a/src/detect-http-headers-stub.h b/src/detect-http-headers-stub.h index 2267671311..81818f5bc1 100644 --- a/src/detect-http-headers-stub.h +++ b/src/detect-http-headers-stub.h @@ -316,7 +316,7 @@ static int InspectEngineHttpResponseHeader(ThreadVars *tv, * \retval 0 On success. * \retval -1 On failure. */ -static int DetectHttpHeadersSetup(DetectEngineCtx *de_ctx, Signature *s, char *arg) +static int DetectHttpHeadersSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg) { s->init_data->list = g_buffer_id; return 0; diff --git a/src/detect-http-headers.c b/src/detect-http-headers.c index 807bac6142..8bcef4b5bf 100644 --- a/src/detect-http-headers.c +++ b/src/detect-http-headers.c @@ -22,6 +22,7 @@ #include "detect-http-content-len.h" #include "detect-http-content-type.h" #include "detect-http-referer.h" +#include "detect-http-headers.h" void DetectHttpHeadersRegister(void) { diff --git a/src/detect-http-hh.c b/src/detect-http-hh.c index 4f0c45ead5..382263aaa3 100644 --- a/src/detect-http-hh.c +++ b/src/detect-http-hh.c @@ -59,7 +59,7 @@ #include "detect-http-hh.h" #include "detect-engine-hhhd.h" -static int DetectHttpHHSetup(DetectEngineCtx *, Signature *, char *); +static int DetectHttpHHSetup(DetectEngineCtx *, Signature *, const char *); static void DetectHttpHHRegisterTests(void); static void DetectHttpHHFree(void *); static void DetectHttpHostSetupCallback(Signature *s); @@ -112,7 +112,7 @@ void DetectHttpHHRegister(void) * \retval 0 On success * \retval -1 On failure */ -int DetectHttpHHSetup(DetectEngineCtx *de_ctx, Signature *s, char *arg) +static int DetectHttpHHSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg) { return DetectEngineContentModifierBufferSetup(de_ctx, s, arg, DETECT_AL_HTTP_HOST, @@ -1470,7 +1470,7 @@ end: return result; } -int DetectHttpHHTest22(void) +static int DetectHttpHHTest22(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1525,7 +1525,7 @@ int DetectHttpHHTest22(void) return result; } -int DetectHttpHHTest23(void) +static int DetectHttpHHTest23(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1579,7 +1579,7 @@ int DetectHttpHHTest23(void) return result; } -int DetectHttpHHTest24(void) +static int DetectHttpHHTest24(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1633,7 +1633,7 @@ int DetectHttpHHTest24(void) return result; } -int DetectHttpHHTest25(void) +static int DetectHttpHHTest25(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1689,7 +1689,7 @@ int DetectHttpHHTest25(void) return result; } -int DetectHttpHHTest26(void) +static int DetectHttpHHTest26(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1746,7 +1746,7 @@ int DetectHttpHHTest26(void) return result; } -int DetectHttpHHTest27(void) +static int DetectHttpHHTest27(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1772,7 +1772,7 @@ int DetectHttpHHTest27(void) return result; } -int DetectHttpHHTest28(void) +static int DetectHttpHHTest28(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1828,7 +1828,7 @@ int DetectHttpHHTest28(void) return result; } -int DetectHttpHHTest29(void) +static int DetectHttpHHTest29(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1872,7 +1872,7 @@ int DetectHttpHHTest29(void) return result; } -int DetectHttpHHTest30(void) +static int DetectHttpHHTest30(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1916,7 +1916,7 @@ int DetectHttpHHTest30(void) return result; } -int DetectHttpHHTest31(void) +static int DetectHttpHHTest31(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1940,7 +1940,7 @@ int DetectHttpHHTest31(void) return result; } -int DetectHttpHHTest32(void) +static int DetectHttpHHTest32(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1964,7 +1964,7 @@ int DetectHttpHHTest32(void) return result; } -int DetectHttpHHTest33(void) +static int DetectHttpHHTest33(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1988,7 +1988,7 @@ int DetectHttpHHTest33(void) return result; } -int DetectHttpHHTest34(void) +static int DetectHttpHHTest34(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2039,7 +2039,7 @@ int DetectHttpHHTest34(void) return result; } -int DetectHttpHHTest35(void) +static int DetectHttpHHTest35(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2090,7 +2090,7 @@ int DetectHttpHHTest35(void) return result; } -int DetectHttpHHTest36(void) +static int DetectHttpHHTest36(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; diff --git a/src/detect-http-hrh.c b/src/detect-http-hrh.c index 620cacaa25..ebefcb2369 100644 --- a/src/detect-http-hrh.c +++ b/src/detect-http-hrh.c @@ -59,7 +59,7 @@ #include "detect-http-hrh.h" #include "detect-engine-hrhhd.h" -static int DetectHttpHRHSetup(DetectEngineCtx *, Signature *, char *); +static int DetectHttpHRHSetup(DetectEngineCtx *, Signature *, const char *); static void DetectHttpHRHRegisterTests(void); static void DetectHttpHRHFree(void *); static void DetectHttpHostRawSetupCallback(Signature *); @@ -108,7 +108,7 @@ void DetectHttpHRHRegister(void) * \retval 0 On success * \retval -1 On failure */ -int DetectHttpHRHSetup(DetectEngineCtx *de_ctx, Signature *s, char *arg) +int DetectHttpHRHSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg) { return DetectEngineContentModifierBufferSetup(de_ctx, s, arg, DETECT_AL_HTTP_RAW_HOST, @@ -1416,7 +1416,7 @@ end: return result; } -int DetectHttpHRHTest22(void) +static int DetectHttpHRHTest22(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1471,7 +1471,7 @@ int DetectHttpHRHTest22(void) return result; } -int DetectHttpHRHTest23(void) +static int DetectHttpHRHTest23(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1525,7 +1525,7 @@ int DetectHttpHRHTest23(void) return result; } -int DetectHttpHRHTest24(void) +static int DetectHttpHRHTest24(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1579,7 +1579,7 @@ int DetectHttpHRHTest24(void) return result; } -int DetectHttpHRHTest25(void) +static int DetectHttpHRHTest25(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1635,7 +1635,7 @@ int DetectHttpHRHTest25(void) return result; } -int DetectHttpHRHTest26(void) +static int DetectHttpHRHTest26(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1692,7 +1692,7 @@ int DetectHttpHRHTest26(void) return result; } -int DetectHttpHRHTest27(void) +static int DetectHttpHRHTest27(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1718,7 +1718,7 @@ int DetectHttpHRHTest27(void) return result; } -int DetectHttpHRHTest28(void) +static int DetectHttpHRHTest28(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1774,7 +1774,7 @@ int DetectHttpHRHTest28(void) return result; } -int DetectHttpHRHTest29(void) +static int DetectHttpHRHTest29(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1818,7 +1818,7 @@ int DetectHttpHRHTest29(void) return result; } -int DetectHttpHRHTest30(void) +static int DetectHttpHRHTest30(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1862,7 +1862,7 @@ int DetectHttpHRHTest30(void) return result; } -int DetectHttpHRHTest31(void) +static int DetectHttpHRHTest31(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1886,7 +1886,7 @@ int DetectHttpHRHTest31(void) return result; } -int DetectHttpHRHTest32(void) +static int DetectHttpHRHTest32(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1910,7 +1910,7 @@ int DetectHttpHRHTest32(void) return result; } -int DetectHttpHRHTest33(void) +static int DetectHttpHRHTest33(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1934,7 +1934,7 @@ int DetectHttpHRHTest33(void) return result; } -int DetectHttpHRHTest34(void) +static int DetectHttpHRHTest34(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1985,7 +1985,7 @@ int DetectHttpHRHTest34(void) return result; } -int DetectHttpHRHTest35(void) +static int DetectHttpHRHTest35(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2036,7 +2036,7 @@ int DetectHttpHRHTest35(void) return result; } -int DetectHttpHRHTest36(void) +static int DetectHttpHRHTest36(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; diff --git a/src/detect-http-method.c b/src/detect-http-method.c index 1559ff5928..0e7424ae86 100644 --- a/src/detect-http-method.c +++ b/src/detect-http-method.c @@ -61,7 +61,7 @@ #include "stream-tcp.h" static int g_http_method_buffer_id = 0; -static int DetectHttpMethodSetup(DetectEngineCtx *, Signature *, char *); +static int DetectHttpMethodSetup(DetectEngineCtx *, Signature *, const char *); void DetectHttpMethodRegisterTests(void); void DetectHttpMethodFree(void *); static void DetectHttpMethodSetupCallback(Signature *s); @@ -112,7 +112,7 @@ void DetectHttpMethodRegister(void) * \retval 0 on Success. * \retval -1 on Failure. */ -static int DetectHttpMethodSetup(DetectEngineCtx *de_ctx, Signature *s, char *str) +static int DetectHttpMethodSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str) { return DetectEngineContentModifierBufferSetup(de_ctx, s, str, DETECT_AL_HTTP_METHOD, @@ -176,7 +176,7 @@ static _Bool DetectHttpMethodValidateCallback(const Signature *s) #include "stream-tcp-reassemble.h" /** \test Check a signature with content */ -int DetectHttpMethodTest01(void) +static int DetectHttpMethodTest01(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -206,7 +206,7 @@ int DetectHttpMethodTest01(void) } /** \test Check a signature without content (fail) */ -int DetectHttpMethodTest02(void) +static int DetectHttpMethodTest02(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -233,7 +233,7 @@ int DetectHttpMethodTest02(void) } /** \test Check a signature with parameter (fail) */ -int DetectHttpMethodTest03(void) +static int DetectHttpMethodTest03(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -261,7 +261,7 @@ int DetectHttpMethodTest03(void) } /** \test Check a signature with fast_pattern (should work) */ -int DetectHttpMethodTest04(void) +static int DetectHttpMethodTest04(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -290,7 +290,7 @@ int DetectHttpMethodTest04(void) } /** \test Check a signature with rawbytes (fail) */ -int DetectHttpMethodTest05(void) +static int DetectHttpMethodTest05(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -366,7 +366,7 @@ static int DetectHttpMethodTest12(void) } /** \test Check a signature with method + within and pcre with /M (should work) */ -int DetectHttpMethodTest13(void) +static int DetectHttpMethodTest13(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -395,7 +395,7 @@ int DetectHttpMethodTest13(void) } /** \test Check a signature with method + within and pcre without /M (should fail) */ -int DetectHttpMethodTest14(void) +static int DetectHttpMethodTest14(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -424,7 +424,7 @@ int DetectHttpMethodTest14(void) } /** \test Check a signature with method + within and pcre with /M (should work) */ -int DetectHttpMethodTest15(void) +static int DetectHttpMethodTest15(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; diff --git a/src/detect-http-protocol.c b/src/detect-http-protocol.c index 65f064c3cd..0b458ed5ac 100644 --- a/src/detect-http-protocol.c +++ b/src/detect-http-protocol.c @@ -44,6 +44,7 @@ #include "detect-content.h" #include "detect-pcre.h" #include "detect-http-header-common.h" +#include "detect-http-protocol.h" #include "flow.h" #include "flow-var.h" @@ -193,7 +194,7 @@ static int InspectEngineHttpProtocol(ThreadVars *tv, return DETECT_ENGINE_INSPECT_SIG_NO_MATCH; } -int DetectHttpProtocolSetup(DetectEngineCtx *de_ctx, Signature *s, char *arg) +static int DetectHttpProtocolSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg) { s->init_data->list = g_buffer_id; return 0; diff --git a/src/detect-http-raw-header.c b/src/detect-http-raw-header.c index 96ea83cc42..98b5f7687e 100644 --- a/src/detect-http-raw-header.c +++ b/src/detect-http-raw-header.c @@ -60,7 +60,7 @@ #include "detect-engine-hrhd.h" #include "stream-tcp.h" -static int DetectHttpRawHeaderSetup(DetectEngineCtx *, Signature *, char *); +static int DetectHttpRawHeaderSetup(DetectEngineCtx *, Signature *, const char *); static void DetectHttpRawHeaderRegisterTests(void); static void DetectHttpRawHeaderFree(void *); static _Bool DetectHttpRawHeaderValidateCallback(const Signature *s); @@ -135,7 +135,7 @@ void DetectHttpRawHeaderFree(void *ptr) * \retval 0 On success. * \retval -1 On failure. */ -int DetectHttpRawHeaderSetup(DetectEngineCtx *de_ctx, Signature *s, char *arg) +int DetectHttpRawHeaderSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg) { return DetectEngineContentModifierBufferSetup(de_ctx, s, arg, DETECT_AL_HTTP_RAW_HEADER, @@ -1260,7 +1260,7 @@ end: return result; } -int DetectHttpRawHeaderTest20(void) +static int DetectHttpRawHeaderTest20(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1304,7 +1304,7 @@ int DetectHttpRawHeaderTest20(void) return result; } -int DetectHttpRawHeaderTest21(void) +static int DetectHttpRawHeaderTest21(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1348,7 +1348,7 @@ int DetectHttpRawHeaderTest21(void) return result; } -int DetectHttpRawHeaderTest22(void) +static int DetectHttpRawHeaderTest22(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1372,7 +1372,7 @@ int DetectHttpRawHeaderTest22(void) return result; } -int DetectHttpRawHeaderTest23(void) +static int DetectHttpRawHeaderTest23(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1396,7 +1396,7 @@ int DetectHttpRawHeaderTest23(void) return result; } -int DetectHttpRawHeaderTest24(void) +static int DetectHttpRawHeaderTest24(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1420,7 +1420,7 @@ int DetectHttpRawHeaderTest24(void) return result; } -int DetectHttpRawHeaderTest25(void) +static int DetectHttpRawHeaderTest25(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1471,7 +1471,7 @@ int DetectHttpRawHeaderTest25(void) return result; } -int DetectHttpRawHeaderTest26(void) +static int DetectHttpRawHeaderTest26(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1522,7 +1522,7 @@ int DetectHttpRawHeaderTest26(void) return result; } -int DetectHttpRawHeaderTest27(void) +static int DetectHttpRawHeaderTest27(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; diff --git a/src/detect-http-raw-uri.c b/src/detect-http-raw-uri.c index 801e2aac20..f3db9e0f2f 100644 --- a/src/detect-http-raw-uri.c +++ b/src/detect-http-raw-uri.c @@ -55,7 +55,7 @@ #include "detect-engine-hrud.h" #include "stream-tcp.h" -static int DetectHttpRawUriSetup(DetectEngineCtx *, Signature *, char *); +static int DetectHttpRawUriSetup(DetectEngineCtx *, Signature *, const char *); static void DetectHttpRawUriRegisterTests(void); static void DetectHttpRawUriSetupCallback(Signature *s); static int g_http_raw_uri_buffer_id = 0; @@ -100,7 +100,7 @@ void DetectHttpRawUriRegister(void) * \retval 0 On success. * \retval -1 On failure. */ -static int DetectHttpRawUriSetup(DetectEngineCtx *de_ctx, Signature *s, char *arg) +static int DetectHttpRawUriSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg) { return DetectEngineContentModifierBufferSetup(de_ctx, s, arg, DETECT_AL_HTTP_RAW_URI, @@ -124,7 +124,7 @@ static void DetectHttpRawUriSetupCallback(Signature *s) * \test Checks if a http_raw_uri is registered in a Signature, if content is not * specified in the signature. */ -int DetectHttpRawUriTest01(void) +static int DetectHttpRawUriTest01(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -148,7 +148,7 @@ end: * \test Checks if a http_raw_uri is registered in a Signature, if some parameter * is specified with http_raw_uri in the signature. */ -int DetectHttpRawUriTest02(void) +static int DetectHttpRawUriTest02(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -172,7 +172,7 @@ end: /** * \test Checks if a http_raw_uri is registered in a Signature. */ -int DetectHttpRawUriTest03(void) +static int DetectHttpRawUriTest03(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; @@ -220,7 +220,7 @@ end: * \test Checks if a http_raw_uri is registered in a Signature, when rawbytes is * also specified in the signature. */ -int DetectHttpRawUriTest04(void) +static int DetectHttpRawUriTest04(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -248,7 +248,7 @@ int DetectHttpRawUriTest04(void) * \test Checks if a http_raw_uri is successfully converted to a rawuricontent. * */ -int DetectHttpRawUriTest05(void) +static int DetectHttpRawUriTest05(void) { DetectEngineCtx *de_ctx = NULL; Signature *s = NULL; @@ -272,7 +272,7 @@ int DetectHttpRawUriTest05(void) goto end; } - char *str = "we are testing http_raw_uri keyword"; + const char *str = "we are testing http_raw_uri keyword"; int uricomp = memcmp((const char *) ((DetectContentData*)s->sm_lists[g_http_raw_uri_buffer_id]->ctx)->content, str, @@ -293,7 +293,7 @@ end: return result; } -int DetectHttpRawUriTest12(void) +static int DetectHttpRawUriTest12(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -340,7 +340,7 @@ int DetectHttpRawUriTest12(void) return result; } -int DetectHttpRawUriTest13(void) +static int DetectHttpRawUriTest13(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -387,7 +387,7 @@ int DetectHttpRawUriTest13(void) return result; } -int DetectHttpRawUriTest14(void) +static int DetectHttpRawUriTest14(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -411,7 +411,7 @@ int DetectHttpRawUriTest14(void) return result; } -int DetectHttpRawUriTest15(void) +static int DetectHttpRawUriTest15(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -435,7 +435,7 @@ int DetectHttpRawUriTest15(void) return result; } -int DetectHttpRawUriTest16(void) +static int DetectHttpRawUriTest16(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -459,7 +459,7 @@ int DetectHttpRawUriTest16(void) return result; } -int DetectHttpRawUriTest17(void) +static int DetectHttpRawUriTest17(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -506,7 +506,7 @@ int DetectHttpRawUriTest17(void) return result; } -int DetectHttpRawUriTest18(void) +static int DetectHttpRawUriTest18(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; diff --git a/src/detect-http-referer.c b/src/detect-http-referer.c index edb48c18b9..8f4687417e 100644 --- a/src/detect-http-referer.c +++ b/src/detect-http-referer.c @@ -39,6 +39,7 @@ #define KEYWORD_TOSERVER 1 #include "detect-http-headers-stub.h" +#include "detect-http-referer.h" void RegisterHttpHeadersReferer(void) { diff --git a/src/detect-http-request-line.c b/src/detect-http-request-line.c index d8bfc0872d..0c194e1254 100644 --- a/src/detect-http-request-line.c +++ b/src/detect-http-request-line.c @@ -60,7 +60,7 @@ #include "stream-tcp.h" #include "detect-http-request-line.h" -static int DetectHttpRequestLineSetup(DetectEngineCtx *, Signature *, char *); +static int DetectHttpRequestLineSetup(DetectEngineCtx *, Signature *, const char *); static void DetectHttpRequestLineRegisterTests(void); static int PrefilterTxHttpRequestLineRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx); static int DetectEngineInspectHttpRequestLine(ThreadVars *tv, @@ -113,7 +113,7 @@ void DetectHttpRequestLineRegister(void) * \retval 0 On success * \retval -1 On failure */ -static int DetectHttpRequestLineSetup(DetectEngineCtx *de_ctx, Signature *s, char *arg) +static int DetectHttpRequestLineSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg) { s->init_data->list = g_http_request_line_buffer_id; s->alproto = ALPROTO_HTTP; diff --git a/src/detect-http-response-line.c b/src/detect-http-response-line.c index f35e393a35..1f1e95606e 100644 --- a/src/detect-http-response-line.c +++ b/src/detect-http-response-line.c @@ -60,7 +60,7 @@ #include "stream-tcp.h" #include "detect-http-response-line.h" -static int DetectHttpResponseLineSetup(DetectEngineCtx *, Signature *, char *); +static int DetectHttpResponseLineSetup(DetectEngineCtx *, Signature *, const char *); static void DetectHttpResponseLineRegisterTests(void); static int PrefilterTxHttpResponseLineRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx); static int DetectEngineInspectHttpResponseLine(ThreadVars *tv, @@ -113,7 +113,7 @@ void DetectHttpResponseLineRegister(void) * \retval 0 On success * \retval -1 On failure */ -static int DetectHttpResponseLineSetup(DetectEngineCtx *de_ctx, Signature *s, char *arg) +static int DetectHttpResponseLineSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg) { s->init_data->list = g_http_response_line_id; s->alproto = ALPROTO_HTTP; diff --git a/src/detect-http-server-body.c b/src/detect-http-server-body.c index 145995e839..a1901ef0fc 100644 --- a/src/detect-http-server-body.c +++ b/src/detect-http-server-body.c @@ -59,7 +59,7 @@ #include "detect-http-server-body.h" #include "stream-tcp.h" -static int DetectHttpServerBodySetup(DetectEngineCtx *, Signature *, char *); +static int DetectHttpServerBodySetup(DetectEngineCtx *, Signature *, const char *); static void DetectHttpServerBodyRegisterTests(void); static void DetectHttpServerBodyFree(void *); @@ -96,7 +96,7 @@ void DetectHttpServerBodyRegister(void) * \retval 0 On success * \retval -1 On failure */ -int DetectHttpServerBodySetup(DetectEngineCtx *de_ctx, Signature *s, char *arg) +int DetectHttpServerBodySetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg) { return DetectEngineContentModifierBufferSetup(de_ctx, s, arg, DETECT_AL_HTTP_SERVER_BODY, @@ -1786,7 +1786,7 @@ end: return result; } -int DetectHttpServerBodyTest22(void) +static int DetectHttpServerBodyTest22(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1841,7 +1841,7 @@ int DetectHttpServerBodyTest22(void) return result; } -int DetectHttpServerBodyTest23(void) +static int DetectHttpServerBodyTest23(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1895,7 +1895,7 @@ int DetectHttpServerBodyTest23(void) return result; } -int DetectHttpServerBodyTest24(void) +static int DetectHttpServerBodyTest24(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1949,7 +1949,7 @@ int DetectHttpServerBodyTest24(void) return result; } -int DetectHttpServerBodyTest25(void) +static int DetectHttpServerBodyTest25(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2005,7 +2005,7 @@ int DetectHttpServerBodyTest25(void) return result; } -int DetectHttpServerBodyTest26(void) +static int DetectHttpServerBodyTest26(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2062,7 +2062,7 @@ int DetectHttpServerBodyTest26(void) } /** \test invalid combination for content: distance, depth, http_server_body */ -int DetectHttpServerBodyTest27(void) +static int DetectHttpServerBodyTest27(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2088,7 +2088,7 @@ int DetectHttpServerBodyTest27(void) return result; } -int DetectHttpServerBodyTest28(void) +static int DetectHttpServerBodyTest28(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2144,7 +2144,7 @@ int DetectHttpServerBodyTest28(void) return result; } -int DetectHttpServerBodyTest29(void) +static int DetectHttpServerBodyTest29(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2188,7 +2188,7 @@ int DetectHttpServerBodyTest29(void) return result; } -int DetectHttpServerBodyTest30(void) +static int DetectHttpServerBodyTest30(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2232,7 +2232,7 @@ int DetectHttpServerBodyTest30(void) return result; } -int DetectHttpServerBodyTest31(void) +static int DetectHttpServerBodyTest31(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2256,7 +2256,7 @@ int DetectHttpServerBodyTest31(void) return result; } -int DetectHttpServerBodyTest32(void) +static int DetectHttpServerBodyTest32(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2280,7 +2280,7 @@ int DetectHttpServerBodyTest32(void) return result; } -int DetectHttpServerBodyTest33(void) +static int DetectHttpServerBodyTest33(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2304,7 +2304,7 @@ int DetectHttpServerBodyTest33(void) return result; } -int DetectHttpServerBodyTest34(void) +static int DetectHttpServerBodyTest34(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2349,7 +2349,7 @@ int DetectHttpServerBodyTest34(void) return result; } -int DetectHttpServerBodyTest35(void) +static int DetectHttpServerBodyTest35(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2400,7 +2400,7 @@ int DetectHttpServerBodyTest35(void) return result; } -int DetectHttpServerBodyTest36(void) +static int DetectHttpServerBodyTest36(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; diff --git a/src/detect-http-start.c b/src/detect-http-start.c index 1937da1a5d..1bf59ed6df 100644 --- a/src/detect-http-start.c +++ b/src/detect-http-start.c @@ -44,6 +44,7 @@ #include "detect-content.h" #include "detect-pcre.h" #include "detect-http-header-common.h" +#include "detect-http-start.h" #include "flow.h" #include "flow-var.h" @@ -282,7 +283,7 @@ static int InspectEngineHttpStart(ThreadVars *tv, return DETECT_ENGINE_INSPECT_SIG_NO_MATCH; } -static int DetectHttpStartSetup(DetectEngineCtx *de_ctx, Signature *s, char *arg) +static int DetectHttpStartSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg) { s->init_data->list = g_buffer_id; return 0; diff --git a/src/detect-http-stat-code.c b/src/detect-http-stat-code.c index 4821ad10db..9fc9e40660 100644 --- a/src/detect-http-stat-code.c +++ b/src/detect-http-stat-code.c @@ -63,7 +63,7 @@ #include "stream-tcp-private.h" #include "stream-tcp.h" -static int DetectHttpStatCodeSetup(DetectEngineCtx *, Signature *, char *); +static int DetectHttpStatCodeSetup(DetectEngineCtx *, Signature *, const char *); static void DetectHttpStatCodeRegisterTests(void); static void DetectHttpStatCodeSetupCallback(Signature *); static int g_http_stat_code_buffer_id = 0; @@ -110,7 +110,7 @@ void DetectHttpStatCodeRegister (void) * \retval -1 On failure */ -static int DetectHttpStatCodeSetup(DetectEngineCtx *de_ctx, Signature *s, char *arg) +static int DetectHttpStatCodeSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg) { return DetectEngineContentModifierBufferSetup(de_ctx, s, arg, DETECT_AL_HTTP_STAT_CODE, @@ -131,7 +131,7 @@ static void DetectHttpStatCodeSetupCallback(Signature *s) * specified in the signature or rawbyes is specified or fast_pattern is * provided in the signature. */ -int DetectHttpStatCodeTest01(void) +static int DetectHttpStatCodeTest01(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -181,7 +181,7 @@ end: * \test Checks if a http_stat_code is registered in a Signature and also checks * the nocase */ -int DetectHttpStatCodeTest02(void) +static int DetectHttpStatCodeTest02(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; diff --git a/src/detect-http-stat-msg.c b/src/detect-http-stat-msg.c index e12b8d1ba6..49a793cad2 100644 --- a/src/detect-http-stat-msg.c +++ b/src/detect-http-stat-msg.c @@ -63,7 +63,7 @@ #include "stream-tcp-private.h" #include "stream-tcp.h" -static int DetectHttpStatMsgSetup(DetectEngineCtx *, Signature *, char *); +static int DetectHttpStatMsgSetup(DetectEngineCtx *, Signature *, const char *); static void DetectHttpStatMsgRegisterTests(void); static void DetectHttpStatMsgSetupCallback(Signature *s); static int g_http_stat_msg_buffer_id = 0; @@ -110,7 +110,7 @@ void DetectHttpStatMsgRegister (void) * \retval -1 On failure */ -static int DetectHttpStatMsgSetup(DetectEngineCtx *de_ctx, Signature *s, char *arg) +static int DetectHttpStatMsgSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg) { return DetectEngineContentModifierBufferSetup(de_ctx, s, arg, DETECT_AL_HTTP_STAT_MSG, @@ -131,7 +131,7 @@ static void DetectHttpStatMsgSetupCallback(Signature *s) * specified in the signature or rawbyes is specified or fast_pattern is * provided in the signature. */ -int DetectHttpStatMsgTest01(void) +static int DetectHttpStatMsgTest01(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -173,7 +173,7 @@ end: * \test Checks if a http_stat_msg is registered in a Signature and also checks * the nocase */ -int DetectHttpStatMsgTest02(void) +static int DetectHttpStatMsgTest02(void) { SigMatch *sm = NULL; DetectEngineCtx *de_ctx = NULL; diff --git a/src/detect-http-ua.c b/src/detect-http-ua.c index 4291bc276f..c9019387b5 100644 --- a/src/detect-http-ua.c +++ b/src/detect-http-ua.c @@ -59,7 +59,7 @@ #include "detect-http-ua.h" #include "detect-engine-hua.h" -static int DetectHttpUASetup(DetectEngineCtx *, Signature *, char *); +static int DetectHttpUASetup(DetectEngineCtx *, Signature *, const char *); static void DetectHttpUARegisterTests(void); static void DetectHttpUAFree(void *); static void DetectHttpUASetupCallback(Signature *); @@ -109,7 +109,7 @@ void DetectHttpUARegister(void) * \retval 0 On success * \retval -1 On failure */ -int DetectHttpUASetup(DetectEngineCtx *de_ctx, Signature *s, char *arg) +int DetectHttpUASetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg) { return DetectEngineContentModifierBufferSetup(de_ctx, s, arg, DETECT_AL_HTTP_USER_AGENT, @@ -1431,7 +1431,7 @@ end: -int DetectHttpUATest22(void) +static int DetectHttpUATest22(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1486,7 +1486,7 @@ int DetectHttpUATest22(void) return result; } -int DetectHttpUATest23(void) +static int DetectHttpUATest23(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1540,7 +1540,7 @@ int DetectHttpUATest23(void) return result; } -int DetectHttpUATest24(void) +static int DetectHttpUATest24(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1594,7 +1594,7 @@ int DetectHttpUATest24(void) return result; } -int DetectHttpUATest25(void) +static int DetectHttpUATest25(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1650,7 +1650,7 @@ int DetectHttpUATest25(void) return result; } -int DetectHttpUATest26(void) +static int DetectHttpUATest26(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1707,7 +1707,7 @@ int DetectHttpUATest26(void) return result; } -int DetectHttpUATest27(void) +static int DetectHttpUATest27(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1733,7 +1733,7 @@ int DetectHttpUATest27(void) return result; } -int DetectHttpUATest28(void) +static int DetectHttpUATest28(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1789,7 +1789,7 @@ int DetectHttpUATest28(void) return result; } -int DetectHttpUATest29(void) +static int DetectHttpUATest29(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1833,7 +1833,7 @@ int DetectHttpUATest29(void) return result; } -int DetectHttpUATest30(void) +static int DetectHttpUATest30(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1877,7 +1877,7 @@ int DetectHttpUATest30(void) return result; } -int DetectHttpUATest31(void) +static int DetectHttpUATest31(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1901,7 +1901,7 @@ int DetectHttpUATest31(void) return result; } -int DetectHttpUATest32(void) +static int DetectHttpUATest32(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1925,7 +1925,7 @@ int DetectHttpUATest32(void) return result; } -int DetectHttpUATest33(void) +static int DetectHttpUATest33(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -1949,7 +1949,7 @@ int DetectHttpUATest33(void) return result; } -int DetectHttpUATest34(void) +static int DetectHttpUATest34(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2000,7 +2000,7 @@ int DetectHttpUATest34(void) return result; } -int DetectHttpUATest35(void) +static int DetectHttpUATest35(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -2051,7 +2051,7 @@ int DetectHttpUATest35(void) return result; } -int DetectHttpUATest36(void) +static int DetectHttpUATest36(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; diff --git a/src/detect-http-uri.c b/src/detect-http-uri.c index f42548f590..30bc5ea61c 100644 --- a/src/detect-http-uri.c +++ b/src/detect-http-uri.c @@ -104,7 +104,7 @@ void DetectHttpUriRegister (void) * \retval -1 On failure */ -int DetectHttpUriSetup(DetectEngineCtx *de_ctx, Signature *s, char *str) +int DetectHttpUriSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str) { return DetectEngineContentModifierBufferSetup(de_ctx, s, str, DETECT_AL_HTTP_URI, @@ -273,7 +273,7 @@ static int DetectHttpUriTest05(void) goto end; } - char *str = "we are testing http_uri keyword"; + const char *str = "we are testing http_uri keyword"; int uricomp = memcmp((const char *)((DetectContentData*) s->sm_lists[g_http_uri_buffer_id]->ctx)->content, str, strlen(str)-1); int urilen = ((DetectContentData*) s->sm_lists_tail[g_http_uri_buffer_id]->ctx)->content_len; if (uricomp != 0 || diff --git a/src/detect-http-uri.h b/src/detect-http-uri.h index b55df07e33..4db00ac2d5 100644 --- a/src/detect-http-uri.h +++ b/src/detect-http-uri.h @@ -25,7 +25,7 @@ #define _DETECT_HTTP_URI_H /* prototypes */ -int DetectHttpUriSetup (DetectEngineCtx *, Signature *, char *); +int DetectHttpUriSetup (DetectEngineCtx *, Signature *, const char *); void DetectHttpUriRegister (void); #endif /* _DETECT_HTTP_URI_H */ diff --git a/src/detect-icmp-id.c b/src/detect-icmp-id.c index 4e9c1f9a41..1c8b5b1ff3 100644 --- a/src/detect-icmp-id.c +++ b/src/detect-icmp-id.c @@ -45,7 +45,7 @@ static pcre_extra *parse_regex_study; static int DetectIcmpIdMatch(ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectIcmpIdSetup(DetectEngineCtx *, Signature *, char *); +static int DetectIcmpIdSetup(DetectEngineCtx *, Signature *, const char *); void DetectIcmpIdRegisterTests(void); void DetectIcmpIdFree(void *); static int PrefilterSetupIcmpId(SigGroupHead *sgh); @@ -153,7 +153,7 @@ static int DetectIcmpIdMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Pac * \retval iid pointer to DetectIcmpIdData on success * \retval NULL on failure */ -DetectIcmpIdData *DetectIcmpIdParse (char *icmpidstr) +static DetectIcmpIdData *DetectIcmpIdParse (const char *icmpidstr) { DetectIcmpIdData *iid = NULL; char *substr[3] = {NULL, NULL, NULL}; @@ -228,7 +228,7 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -static int DetectIcmpIdSetup (DetectEngineCtx *de_ctx, Signature *s, char *icmpidstr) +static int DetectIcmpIdSetup (DetectEngineCtx *de_ctx, Signature *s, const char *icmpidstr) { DetectIcmpIdData *iid = NULL; SigMatch *sm = NULL; @@ -326,7 +326,7 @@ static _Bool PrefilterIcmpIdIsPrefilterable(const Signature *s) /** * \test DetectIcmpIdParseTest01 is a test for setting a valid icmp_id value */ -int DetectIcmpIdParseTest01 (void) +static int DetectIcmpIdParseTest01 (void) { DetectIcmpIdData *iid = NULL; iid = DetectIcmpIdParse("300"); @@ -341,7 +341,7 @@ int DetectIcmpIdParseTest01 (void) * \test DetectIcmpIdParseTest02 is a test for setting a valid icmp_id value * with spaces all around */ -int DetectIcmpIdParseTest02 (void) +static int DetectIcmpIdParseTest02 (void) { DetectIcmpIdData *iid = NULL; iid = DetectIcmpIdParse(" 300 "); @@ -356,7 +356,7 @@ int DetectIcmpIdParseTest02 (void) * \test DetectIcmpIdParseTest03 is a test for setting a valid icmp_id value * with quotation marks */ -int DetectIcmpIdParseTest03 (void) +static int DetectIcmpIdParseTest03 (void) { DetectIcmpIdData *iid = NULL; iid = DetectIcmpIdParse("\"300\""); @@ -371,7 +371,7 @@ int DetectIcmpIdParseTest03 (void) * \test DetectIcmpIdParseTest04 is a test for setting a valid icmp_id value * with quotation marks and spaces all around */ -int DetectIcmpIdParseTest04 (void) +static int DetectIcmpIdParseTest04 (void) { DetectIcmpIdData *iid = NULL; iid = DetectIcmpIdParse(" \" 300 \""); @@ -386,7 +386,7 @@ int DetectIcmpIdParseTest04 (void) * \test DetectIcmpIdParseTest05 is a test for setting an invalid icmp_id * value with missing quotation marks */ -int DetectIcmpIdParseTest05 (void) +static int DetectIcmpIdParseTest05 (void) { DetectIcmpIdData *iid = NULL; iid = DetectIcmpIdParse("\"300"); @@ -402,7 +402,7 @@ int DetectIcmpIdParseTest05 (void) * icmp_id keyword by creating 2 rules and matching a crafted packet * against them. Only the first one shall trigger. */ -int DetectIcmpIdMatchTest01 (void) +static int DetectIcmpIdMatchTest01 (void) { int result = 0; Packet *p = NULL; @@ -465,7 +465,7 @@ end: * against them. The packet is an ICMP packet with no "id" field, * therefore the rule should not trigger. */ -int DetectIcmpIdMatchTest02 (void) +static int DetectIcmpIdMatchTest02 (void) { int result = 0; diff --git a/src/detect-icmp-seq.c b/src/detect-icmp-seq.c index 8ef19c0512..60a3e58cff 100644 --- a/src/detect-icmp-seq.c +++ b/src/detect-icmp-seq.c @@ -45,7 +45,7 @@ static pcre_extra *parse_regex_study; static int DetectIcmpSeqMatch(ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectIcmpSeqSetup(DetectEngineCtx *, Signature *, char *); +static int DetectIcmpSeqSetup(DetectEngineCtx *, Signature *, const char *); void DetectIcmpSeqRegisterTests(void); void DetectIcmpSeqFree(void *); static int PrefilterSetupIcmpSeq(SigGroupHead *sgh); @@ -155,7 +155,7 @@ static int DetectIcmpSeqMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Pa * \retval iseq pointer to DetectIcmpSeqData on success * \retval NULL on failure */ -DetectIcmpSeqData *DetectIcmpSeqParse (char *icmpseqstr) +static DetectIcmpSeqData *DetectIcmpSeqParse (const char *icmpseqstr) { DetectIcmpSeqData *iseq = NULL; char *substr[3] = {NULL, NULL, NULL}; @@ -231,7 +231,7 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -static int DetectIcmpSeqSetup (DetectEngineCtx *de_ctx, Signature *s, char *icmpseqstr) +static int DetectIcmpSeqSetup (DetectEngineCtx *de_ctx, Signature *s, const char *icmpseqstr) { DetectIcmpSeqData *iseq = NULL; SigMatch *sm = NULL; @@ -329,7 +329,7 @@ static _Bool PrefilterIcmpSeqIsPrefilterable(const Signature *s) /** * \test DetectIcmpSeqParseTest01 is a test for setting a valid icmp_seq value */ -int DetectIcmpSeqParseTest01 (void) +static int DetectIcmpSeqParseTest01 (void) { DetectIcmpSeqData *iseq = NULL; iseq = DetectIcmpSeqParse("300"); @@ -344,7 +344,7 @@ int DetectIcmpSeqParseTest01 (void) * \test DetectIcmpSeqParseTest02 is a test for setting a valid icmp_seq value * with spaces all around */ -int DetectIcmpSeqParseTest02 (void) +static int DetectIcmpSeqParseTest02 (void) { DetectIcmpSeqData *iseq = NULL; iseq = DetectIcmpSeqParse(" 300 "); @@ -358,7 +358,7 @@ int DetectIcmpSeqParseTest02 (void) /** * \test DetectIcmpSeqParseTest03 is a test for setting an invalid icmp_seq value */ -int DetectIcmpSeqParseTest03 (void) +static int DetectIcmpSeqParseTest03 (void) { DetectIcmpSeqData *iseq = NULL; iseq = DetectIcmpSeqParse("badc"); @@ -374,7 +374,7 @@ int DetectIcmpSeqParseTest03 (void) * icmp_seq keyword by creating 2 rules and matching a crafted packet * against them. Only the first one shall trigger. */ -int DetectIcmpSeqMatchTest01 (void) +static int DetectIcmpSeqMatchTest01 (void) { int result = 0; Packet *p = NULL; diff --git a/src/detect-icode.c b/src/detect-icode.c index e832f5bbfa..1de36486aa 100644 --- a/src/detect-icode.c +++ b/src/detect-icode.c @@ -48,7 +48,7 @@ static pcre_extra *parse_regex_study; static int DetectICodeMatch(ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectICodeSetup(DetectEngineCtx *, Signature *, char *); +static int DetectICodeSetup(DetectEngineCtx *, Signature *, const char *); void DetectICodeRegisterTests(void); void DetectICodeFree(void *); @@ -144,7 +144,7 @@ static int DetectICodeMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Pack * \retval icd pointer to DetectICodeData on success * \retval NULL on failure */ -DetectICodeData *DetectICodeParse(char *icodestr) +static DetectICodeData *DetectICodeParse(const char *icodestr) { DetectICodeData *icd = NULL; char *args[3] = {NULL, NULL, NULL}; @@ -248,7 +248,7 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -static int DetectICodeSetup(DetectEngineCtx *de_ctx, Signature *s, char *icodestr) +static int DetectICodeSetup(DetectEngineCtx *de_ctx, Signature *s, const char *icodestr) { DetectICodeData *icd = NULL; @@ -358,7 +358,7 @@ static _Bool PrefilterICodeIsPrefilterable(const Signature *s) /** * \test DetectICodeParseTest01 is a test for setting a valid icode value */ -int DetectICodeParseTest01(void) +static int DetectICodeParseTest01(void) { DetectICodeData *icd = NULL; int result = 0; @@ -375,7 +375,7 @@ int DetectICodeParseTest01(void) * \test DetectICodeParseTest02 is a test for setting a valid icode value * with ">" operator */ -int DetectICodeParseTest02(void) +static int DetectICodeParseTest02(void) { DetectICodeData *icd = NULL; int result = 0; @@ -392,7 +392,7 @@ int DetectICodeParseTest02(void) * \test DetectICodeParseTest03 is a test for setting a valid icode value * with "<" operator */ -int DetectICodeParseTest03(void) +static int DetectICodeParseTest03(void) { DetectICodeData *icd = NULL; int result = 0; @@ -409,7 +409,7 @@ int DetectICodeParseTest03(void) * \test DetectICodeParseTest04 is a test for setting a valid icode value * with "<>" operator */ -int DetectICodeParseTest04(void) +static int DetectICodeParseTest04(void) { DetectICodeData *icd = NULL; int result = 0; @@ -426,7 +426,7 @@ int DetectICodeParseTest04(void) * \test DetectICodeParseTest05 is a test for setting a valid icode value * with spaces all around */ -int DetectICodeParseTest05(void) +static int DetectICodeParseTest05(void) { DetectICodeData *icd = NULL; int result = 0; @@ -443,7 +443,7 @@ int DetectICodeParseTest05(void) * \test DetectICodeParseTest06 is a test for setting a valid icode value * with ">" operator and spaces all around */ -int DetectICodeParseTest06(void) +static int DetectICodeParseTest06(void) { DetectICodeData *icd = NULL; int result = 0; @@ -460,7 +460,7 @@ int DetectICodeParseTest06(void) * \test DetectICodeParseTest07 is a test for setting a valid icode value * with "<>" operator and spaces all around */ -int DetectICodeParseTest07(void) +static int DetectICodeParseTest07(void) { DetectICodeData *icd = NULL; int result = 0; @@ -476,7 +476,7 @@ int DetectICodeParseTest07(void) /** * \test DetectICodeParseTest08 is a test for setting an invalid icode value */ -int DetectICodeParseTest08(void) +static int DetectICodeParseTest08(void) { DetectICodeData *icd = NULL; icd = DetectICodeParse("> 8 <> 20"); @@ -491,7 +491,7 @@ int DetectICodeParseTest08(void) * keyword by creating 5 rules and matching a crafted packet against * them. 4 out of 5 rules shall trigger. */ -int DetectICodeMatchTest01(void) +static int DetectICodeMatchTest01(void) { Packet *p = NULL; diff --git a/src/detect-id.c b/src/detect-id.c index cdc32ebc1a..066baa25f6 100644 --- a/src/detect-id.c +++ b/src/detect-id.c @@ -51,7 +51,7 @@ static pcre_extra *parse_regex_study; static int DetectIdMatch (ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectIdSetup (DetectEngineCtx *, Signature *, char *); +static int DetectIdSetup (DetectEngineCtx *, Signature *, const char *); void DetectIdRegisterTests(void); void DetectIdFree(void *); @@ -117,7 +117,7 @@ static int DetectIdMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet * \retval id_d pointer to DetectIdData on success * \retval NULL on failure */ -DetectIdData *DetectIdParse (char *idstr) +static DetectIdData *DetectIdParse (const char *idstr) { uint32_t temp; DetectIdData *id_d = NULL; @@ -195,7 +195,7 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -int DetectIdSetup (DetectEngineCtx *de_ctx, Signature *s, char *idstr) +int DetectIdSetup (DetectEngineCtx *de_ctx, Signature *s, const char *idstr) { DetectIdData *id_d = NULL; SigMatch *sm = NULL; @@ -299,7 +299,7 @@ static _Bool PrefilterIdIsPrefilterable(const Signature *s) * \test DetectIdTestParse01 is a test to make sure that we parse the "id" * option correctly when given valid id option */ -int DetectIdTestParse01 (void) +static int DetectIdTestParse01 (void) { DetectIdData *id_d = NULL; id_d = DetectIdParse(" 35402 "); @@ -316,7 +316,7 @@ int DetectIdTestParse01 (void) * option correctly when given an invalid id option * it should return id_d = NULL */ -int DetectIdTestParse02 (void) +static int DetectIdTestParse02 (void) { DetectIdData *id_d = NULL; id_d = DetectIdParse("65537"); @@ -333,7 +333,7 @@ int DetectIdTestParse02 (void) * option correctly when given an invalid id option * it should return id_d = NULL */ -int DetectIdTestParse03 (void) +static int DetectIdTestParse03 (void) { DetectIdData *id_d = NULL; id_d = DetectIdParse("12what?"); @@ -349,7 +349,7 @@ int DetectIdTestParse03 (void) * \test DetectIdTestParse04 is a test to make sure that we parse the "id" * option correctly when given valid id option but wrapped with "'s */ -int DetectIdTestParse04 (void) +static int DetectIdTestParse04 (void) { DetectIdData *id_d = NULL; /* yep, look if we trim blank spaces correctly and ignore "'s */ @@ -366,7 +366,7 @@ int DetectIdTestParse04 (void) * \test DetectIdTestSig01 * \brief Test to check "id" keyword with constructed packets */ -int DetectIdTestMatch01(void) +static int DetectIdTestMatch01(void) { int result = 0; uint8_t *buf = (uint8_t *)"Hi all!"; @@ -388,7 +388,7 @@ int DetectIdTestMatch01(void) /* UDP IP id = 91011 */ p[2]->ip4h->ip_id = htons(5101); - char *sigs[3]; + const char *sigs[3]; sigs[0]= "alert ip any any -> any any (msg:\"Testing id 1\"; id:1234; sid:1;)"; sigs[1]= "alert ip any any -> any any (msg:\"Testing id 2\"; id:5678; sid:2;)"; sigs[2]= "alert ip any any -> any any (msg:\"Testing id 3\"; id:5101; sid:3;)"; diff --git a/src/detect-ipopts.c b/src/detect-ipopts.c index 33addb855b..ed826b58e9 100644 --- a/src/detect-ipopts.c +++ b/src/detect-ipopts.c @@ -45,7 +45,7 @@ static pcre_extra *parse_regex_study; static int DetectIpOptsMatch (ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectIpOptsSetup (DetectEngineCtx *, Signature *, char *); +static int DetectIpOptsSetup (DetectEngineCtx *, Signature *, const char *); void IpOptsRegisterTests(void); void DetectIpOptsFree(void *); @@ -123,7 +123,7 @@ static int DetectIpOptsMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Pac * \retval de pointer to DetectIpOptsData on success * \retval NULL on failure */ -DetectIpOptsData *DetectIpOptsParse (char *rawstr) +static DetectIpOptsData *DetectIpOptsParse (const char *rawstr) { int i; DetectIpOptsData *de = NULL; @@ -171,7 +171,7 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -static int DetectIpOptsSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr) +static int DetectIpOptsSetup (DetectEngineCtx *de_ctx, Signature *s, const char *rawstr) { DetectIpOptsData *de = NULL; SigMatch *sm = NULL; @@ -221,7 +221,7 @@ void DetectIpOptsFree(void *de_ptr) * \retval 1 on succces * \retval 0 on failure */ -int IpOptsTestParse01 (void) +static int IpOptsTestParse01 (void) { DetectIpOptsData *de = NULL; de = DetectIpOptsParse("lsrr"); @@ -239,7 +239,7 @@ int IpOptsTestParse01 (void) * \retval 1 on succces * \retval 0 on failure */ -int IpOptsTestParse02 (void) +static int IpOptsTestParse02 (void) { DetectIpOptsData *de = NULL; de = DetectIpOptsParse("invalidopt"); @@ -257,7 +257,7 @@ int IpOptsTestParse02 (void) * \retval 1 on succces * \retval 0 on failure */ -int IpOptsTestParse03 (void) +static int IpOptsTestParse03 (void) { Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) @@ -307,7 +307,7 @@ error: * \retval 1 on succces * \retval 0 on failure */ -int IpOptsTestParse04 (void) +static int IpOptsTestParse04 (void) { Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) diff --git a/src/detect-ipproto.c b/src/detect-ipproto.c index 944b03817d..0eba42e6ca 100644 --- a/src/detect-ipproto.c +++ b/src/detect-ipproto.c @@ -46,16 +46,12 @@ /** * \brief Regex for parsing our options */ -#define PARSE_REGEX "^\\s*" \ - "([!<>]?)" \ - "\\s*([^\\s]+)" \ - "\\s*$" +#define PARSE_REGEX "^([!<>]?)\\s*([^\\s]+)$" static pcre *parse_regex; static pcre_extra *parse_regex_study; -static int DetectIPProtoSetup(DetectEngineCtx *, Signature *, char *); -static DetectIPProtoData *DetectIPProtoParse(const char *); +static int DetectIPProtoSetup(DetectEngineCtx *, Signature *, const char *); static void DetectIPProtoRegisterTests(void); static void DetectIPProtoFree(void *); @@ -68,6 +64,7 @@ void DetectIPProtoRegister(void) sigmatch_table[DETECT_IPPROTO].Setup = DetectIPProtoSetup; sigmatch_table[DETECT_IPPROTO].Free = DetectIPProtoFree; sigmatch_table[DETECT_IPPROTO].RegisterTests = DetectIPProtoRegisterTests; + sigmatch_table[DETECT_IPPROTO].flags = SIGMATCH_QUOTES_OPTIONAL; DetectSetupParseRegexes(PARSE_REGEX, &parse_regex, &parse_regex_study); } @@ -174,19 +171,6 @@ static int DetectIPProtoTypePresentForOP(Signature *s, uint8_t op) return 0; } -/* Updated by AS. Please do not remove this unused code. - * Need it as we redo this code once we solve ipproto - * multiple uses */ -#if 0 -static int DetectIPProtoQSortCompare(const void *a, const void *b) -{ - const uint8_t *one = a; - const uint8_t *two = b; - - return ((int)*one - *two); -} -#endif - /** * \internal * \brief Setup ip_proto keyword. @@ -197,13 +181,13 @@ static int DetectIPProtoQSortCompare(const void *a, const void *b) * * \return Non-zero on error */ -static int DetectIPProtoSetup(DetectEngineCtx *de_ctx, Signature *s, char *optstr) +static int DetectIPProtoSetup(DetectEngineCtx *de_ctx, Signature *s, const char *optstr) { SigMatch *sm = NULL; DetectIPProtoData *data = NULL; int i; - data = DetectIPProtoParse((const char *)optstr); + data = DetectIPProtoParse(optstr); if (data == NULL) { goto error; } @@ -276,14 +260,6 @@ static int DetectIPProtoSetup(DetectEngineCtx *de_ctx, Signature *s, char *optst "both gt and lt ipprotos, with the lt being " "lower than gt value"); goto error; - /* Updated by AS. Please do not remove this unused code. Need it - * as we redo this code once we solve ipproto multiple uses */ -#if 0 - s->proto.proto[data->proto / 8] |= 0xfe << (data->proto % 8); - for (i = (data->proto / 8) + 1; i < (256 / 8); i++) { - s->proto.proto[i] = 0xff; - } -#endif } else { for (i = 0; i < (data->proto / 8); i++) { s->proto.proto[i] = 0; @@ -315,46 +291,10 @@ static int DetectIPProtoSetup(DetectEngineCtx *de_ctx, Signature *s, char *optst if (temp_sm != NULL) { data_temp = (DetectIPProtoData *)temp_sm->ctx; if (data_temp->proto <= data->proto) { - /* Updated by AS. Please do not remove this unused code. - * Need it as we redo this code once we solve ipproto - * multiple uses */ SCLogError(SC_ERR_INVALID_SIGNATURE, "can't have " "both gt and lt ipprotos, with the lt being " "lower than gt value"); goto error; -#if 0 - s->proto.proto[data->proto / 8] |= 0xfe << (data->proto % 8); - for (i = (data->proto / 8) + 1; i < (256 / 8); i++) { - s->proto.proto[i] = 0xff; - } - temp_sm = s->sm_lists[DETECT_SM_LIST_MATCH]; - uint8_t *not_protos = NULL; - int not_protos_len = 0; - while (temp_sm != NULL) { - if (temp_sm->type == DETECT_IPPROTO && - ((DetectIPProtoData *)temp_sm->ctx)->op == DETECT_IPPROTO_OP_NOT) { - DetectIPProtoData *data_temp = temp_sm->ctx; - not_protos = SCRealloc(not_protos, - (not_protos_len + 1) * sizeof(uint8_t)); - if (not_protos == NULL) - goto error; - not_protos[not_protos_len] = data_temp->proto; - not_protos_len++; - } - temp_sm = temp_sm->next; - } - qsort(not_protos, not_protos_len, sizeof(uint8_t), - DetectIPProtoQSortCompare); - int j = 0; - while (j < not_protos_len) { - if (not_protos[j] < data->proto) { - ; - } else { - s->proto.proto[not_protos[j] / 8] &= ~(1 << (not_protos[j] % 8)); - } - j++; - } -#endif } else { for (i = 0; i < (data->proto / 8); i++) { s->proto.proto[i] = 0; @@ -391,19 +331,10 @@ static int DetectIPProtoSetup(DetectEngineCtx *de_ctx, Signature *s, char *optst if (temp_sm != NULL) { DetectIPProtoData *data_temp = (DetectIPProtoData *)temp_sm->ctx; if (data_temp->proto >= data->proto) { - /* Updated by AS. Please do not remove this unused code. - * Need it as we redo this code once we solve ipproto - * multiple uses */ SCLogError(SC_ERR_INVALID_SIGNATURE, "can't use a have " "both gt and lt ipprotos, with the lt being " "lower than gt value"); goto error; -#if 0 - for (i = 0; i < (data->proto / 8); i++) { - s->proto.proto[i] = 0xff; - } - s->proto.proto[data->proto / 8] |= ~(0xff << (data->proto % 8));; -#endif } else { for (i = 0; i < (data->proto / 8); i++) { s->proto.proto[i] &= 0xff; @@ -435,46 +366,10 @@ static int DetectIPProtoSetup(DetectEngineCtx *de_ctx, Signature *s, char *optst if (temp_sm != NULL) { data_temp = (DetectIPProtoData *)temp_sm->ctx; if (data_temp->proto >= data->proto) { - /* Updated by AS. Please do not remove this unused code. - * Need it as we redo this code once we solve ipproto - * multiple uses */ SCLogError(SC_ERR_INVALID_SIGNATURE, "can't have " "both gt and lt ipprotos, with the lt being " "lower than gt value"); goto error; -#if 0 - for (i = 0; i < (data->proto / 8); i++) { - s->proto.proto[i] = 0xff; - } - s->proto.proto[data->proto / 8] |= ~(0xff << (data->proto % 8)); - temp_sm = s->sm_lists[DETECT_SM_LIST_MATCH]; - uint8_t *not_protos = NULL; - int not_protos_len = 0; - while (temp_sm != NULL) { - if (temp_sm->type == DETECT_IPPROTO && - ((DetectIPProtoData *)temp_sm->ctx)->op == DETECT_IPPROTO_OP_NOT) { - DetectIPProtoData *data_temp = temp_sm->ctx; - not_protos = SCRealloc(not_protos, - (not_protos_len + 1) * sizeof(uint8_t)); - if (not_protos == NULL) - goto error; - not_protos[not_protos_len] = data_temp->proto; - not_protos_len++; - } - temp_sm = temp_sm->next; - } - qsort(not_protos, not_protos_len, sizeof(uint8_t), - DetectIPProtoQSortCompare); - int j = 0; - while (j < not_protos_len) { - if (not_protos[j] < data->proto) { - s->proto.proto[not_protos[j] / 8] &= ~(1 << (not_protos[j] % 8)); - } else { - ; - } - j++; - } -#endif } else { for (i = 0; i < (data->proto / 8); i++) { s->proto.proto[i] &= 0xFF; @@ -565,17 +460,9 @@ static void DetectIPProtoFree(void *ptr) */ static int DetectIPProtoTestParse01(void) { - int result = 0; - DetectIPProtoData *data = NULL; - data = DetectIPProtoParse("999"); - if (data == NULL) { - result = 1; - } - - if (data) - SCFree(data); - - return result; + DetectIPProtoData *data = DetectIPProtoParse("999"); + FAIL_IF_NOT(data == NULL); + PASS; } /** @@ -583,17 +470,9 @@ static int DetectIPProtoTestParse01(void) */ static int DetectIPProtoTestParse02(void) { - int result = 0; - DetectIPProtoData *data = NULL; - data = DetectIPProtoParse("foobarbooeek"); - if (data == NULL) { - result = 1; - } - - if (data) - SCFree(data); - - return result; + DetectIPProtoData *data = DetectIPProtoParse("foobarbooeek"); + FAIL_IF_NOT(data == NULL); + PASS; } /** @@ -601,35 +480,25 @@ static int DetectIPProtoTestParse02(void) */ static int DetectIPProtoTestSetup01(void) { - int result = 0; - Signature *sig; - char *value_str = "14"; + const char *value_str = "14"; int value = atoi(value_str); int i; - if ((sig = SigAlloc()) == NULL) - goto end; + Signature *sig = SigAlloc(); + FAIL_IF_NULL(sig); sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; sig->proto.flags |= DETECT_PROTO_ANY; DetectIPProtoSetup(NULL, sig, value_str); for (i = 0; i < (value / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value / 8] != 0x40) { - goto end; + FAIL_IF(sig->proto.proto[i] != 0); } + FAIL_IF(sig->proto.proto[value / 8] != 0x40); for (i = (value / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; + FAIL_IF(sig->proto.proto[i] != 0); } - - result = 1; - -end: SigFree(sig); - return result; + PASS; } /** @@ -639,7 +508,7 @@ static int DetectIPProtoTestSetup02(void) { int result = 0; Signature *sig = NULL; - char *value_str = "tcp"; + const char *value_str = "tcp"; struct protoent *pent = getprotobyname(value_str); if (pent == NULL) { goto end; @@ -680,7 +549,7 @@ static int DetectIPProtoTestSetup03(void) { int result = 0; Signature *sig; - char *value_str = "<14"; + const char *value_str = "<14"; int value = 14; int i; @@ -716,7 +585,7 @@ static int DetectIPProtoTestSetup04(void) { int result = 0; Signature *sig; - char *value_str = ">14"; + const char *value_str = ">14"; int value = 14; int i; @@ -752,7 +621,7 @@ static int DetectIPProtoTestSetup05(void) { int result = 0; Signature *sig; - char *value_str = "!14"; + const char *value_str = "!14"; int value = 14; int i; @@ -788,8 +657,8 @@ static int DetectIPProtoTestSetup06(void) { int result = 0; Signature *sig; - char *value1_str = "14"; - char *value2_str = "15"; + const char *value1_str = "14"; + const char *value2_str = "15"; if ((sig = SigAlloc()) == NULL) goto end; @@ -815,8 +684,8 @@ static int DetectIPProtoTestSetup07(void) { int result = 0; Signature *sig; - char *value1_str = "14"; - char *value2_str = "<15"; + const char *value1_str = "14"; + const char *value2_str = "<15"; if ((sig = SigAlloc()) == NULL) goto end; @@ -842,8 +711,8 @@ static int DetectIPProtoTestSetup08(void) { int result = 0; Signature *sig; - char *value1_str = "14"; - char *value2_str = ">15"; + const char *value1_str = "14"; + const char *value2_str = ">15"; if ((sig = SigAlloc()) == NULL) goto end; @@ -869,8 +738,8 @@ static int DetectIPProtoTestSetup09(void) { int result = 0; Signature *sig; - char *value1_str = "14"; - char *value2_str = "!15"; + const char *value1_str = "14"; + const char *value2_str = "!15"; if ((sig = SigAlloc()) == NULL) goto end; @@ -896,8 +765,8 @@ static int DetectIPProtoTestSetup10(void) { int result = 0; Signature *sig; - char *value1_str = ">14"; - char *value2_str = "15"; + const char *value1_str = ">14"; + const char *value2_str = "15"; if ((sig = SigAlloc()) == NULL) goto end; @@ -923,8 +792,8 @@ static int DetectIPProtoTestSetup11(void) { int result = 0; Signature *sig; - char *value1_str = "<14"; - char *value2_str = "15"; + const char *value1_str = "<14"; + const char *value2_str = "15"; if ((sig = SigAlloc()) == NULL) goto end; @@ -950,8 +819,8 @@ static int DetectIPProtoTestSetup12(void) { int result = 0; Signature *sig; - char *value1_str = "!14"; - char *value2_str = "15"; + const char *value1_str = "!14"; + const char *value2_str = "15"; if ((sig = SigAlloc()) == NULL) goto end; @@ -977,8 +846,8 @@ static int DetectIPProtoTestSetup13(void) { int result = 0; Signature *sig; - char *value1_str = ">14"; - char *value2_str = ">15"; + const char *value1_str = ">14"; + const char *value2_str = ">15"; if ((sig = SigAlloc()) == NULL) goto end; @@ -1001,8 +870,8 @@ static int DetectIPProtoTestSetup14(void) { int result = 0; Signature *sig; - char *value1_str = "<14"; - char *value2_str = "<15"; + const char *value1_str = "<14"; + const char *value2_str = "<15"; if ((sig = SigAlloc()) == NULL) goto end; @@ -1025,9 +894,9 @@ static int DetectIPProtoTestSetup15(void) { int result = 0; Signature *sig; - char *value1_str = "<14"; + const char *value1_str = "<14"; int value1 = 14; - char *value2_str = ">34"; + const char *value2_str = ">34"; int i; if ((sig = SigAlloc()) == NULL) @@ -1057,57 +926,14 @@ static int DetectIPProtoTestSetup15(void) SigFree(sig); return result; -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "<14"; - int value1 = 14; - char *value2_str = ">34"; - int value2 = 34; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x3F) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xF8) { - goto end; - } - for (i = (value2 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif } static int DetectIPProtoTestSetup16(void) { int result = 0; Signature *sig; - char *value1_str = "<14"; - char *value2_str = ">34"; + const char *value1_str = "<14"; + const char *value2_str = ">34"; int value2 = 34; int i; @@ -1138,58 +964,15 @@ static int DetectIPProtoTestSetup16(void) SigFree(sig); return result; -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "<14"; - int value1 = 14; - char *value2_str = ">34"; - int value2 = 34; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x3F) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xF8) { - goto end; - } - for (i = (value2 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif } static int DetectIPProtoTestSetup17(void) { int result = 0; Signature *sig; - char *value1_str = "<11"; + const char *value1_str = "<11"; int value1 = 11; - char *value2_str = ">13"; + const char *value2_str = ">13"; int i; if ((sig = SigAlloc()) == NULL) @@ -1219,12 +1002,14 @@ static int DetectIPProtoTestSetup17(void) SigFree(sig); return result; -#if 0 +} + +static int DetectIPProtoTestSetup18(void) +{ int result = 0; Signature *sig; - char *value1_str = "<11"; - int value1 = 11; - char *value2_str = ">13"; + const char *value1_str = "<11"; + const char *value2_str = ">13"; int value2 = 13; int i; @@ -1233,40 +1018,38 @@ static int DetectIPProtoTestSetup17(void) sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) + for (i = 0; i < (value2 / 8); i++) { + if (sig->proto.proto[i] != 0) goto end; } - if (sig->proto.proto[value1 / 8] != 0xC7) { - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xC7) { + if (sig->proto.proto[value2 / 8] != 0xC0) { goto end; } for (i = (value2 / 8) + 1; i < (256 / 8); i++) { if (sig->proto.proto[i] != 0xFF) goto end; } + if (DetectIPProtoSetup(NULL, sig, value1_str) == 0) + goto end; result = 1; end: SigFree(sig); return result; -#endif + } -static int DetectIPProtoTestSetup18(void) +static int DetectIPProtoTestSetup19(void) { int result = 0; Signature *sig; - char *value1_str = "<11"; - char *value2_str = ">13"; - int value2 = 13; + const char *value1_str = "<11"; + int value1 = 11; + const char *value2_str = "!13"; + const char *value3_str = ">36"; int i; if ((sig = SigAlloc()) == NULL) @@ -1274,20 +1057,22 @@ static int DetectIPProtoTestSetup18(void) sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; sig->proto.flags |= DETECT_PROTO_ANY; + if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) + goto end; if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) goto end; - for (i = 0; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0) + for (i = 0; i < (value1 / 8); i++) { + if (sig->proto.proto[i] != 0xFF) goto end; } - if (sig->proto.proto[value2 / 8] != 0xC0) { + if (sig->proto.proto[value1 / 8] != 0x07) { goto end; } - for (i = (value2 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) + for (i = (value1 / 8) + 1; i < (256 / 8); i++) { + if (sig->proto.proto[i] != 0) goto end; } - if (DetectIPProtoSetup(NULL, sig, value1_str) == 0) + if (DetectIPProtoSetup(NULL, sig, value3_str) == 0) goto end; result = 1; @@ -1295,14 +1080,15 @@ static int DetectIPProtoTestSetup18(void) end: SigFree(sig); return result; +} -#if 0 +static int DetectIPProtoTestSetup20(void) +{ int result = 0; Signature *sig; - char *value1_str = "<11"; + const char *value1_str = "<11"; int value1 = 11; - char *value2_str = ">13"; - int value2 = 13; + const char *value3_str = ">36"; int i; if ((sig = SigAlloc()) == NULL) @@ -1310,41 +1096,37 @@ static int DetectIPProtoTestSetup18(void) sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) goto end; for (i = 0; i < (value1 / 8); i++) { if (sig->proto.proto[i] != 0xFF) goto end; } - if (sig->proto.proto[value1 / 8] != 0xC7) { - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xC7) { + if (sig->proto.proto[value1 / 8] != 0x07) { goto end; } - for (i = (value2 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) + for (i = (value1 / 8) + 1; i < (256 / 8); i++) { + if (sig->proto.proto[i] != 0) goto end; } + if (DetectIPProtoSetup(NULL, sig, value3_str) == 0) + goto end; result = 1; end: SigFree(sig); return result; -#endif } -static int DetectIPProtoTestSetup19(void) +static int DetectIPProtoTestSetup21(void) { int result = 0; Signature *sig; - char *value1_str = "<11"; + const char *value1_str = "<11"; int value1 = 11; - char *value2_str = "!13"; - char *value3_str = ">36"; + const char *value2_str = "!13"; + const char *value3_str = ">36"; int i; if ((sig = SigAlloc()) == NULL) @@ -1352,10 +1134,10 @@ static int DetectIPProtoTestSetup19(void) sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) goto end; + if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) + goto end; for (i = 0; i < (value1 / 8); i++) { if (sig->proto.proto[i] != 0xFF) goto end; @@ -1375,14 +1157,15 @@ static int DetectIPProtoTestSetup19(void) end: SigFree(sig); return result; +} -#if 0 +static int DetectIPProtoTestSetup22(void) +{ int result = 0; Signature *sig; - char *value1_str = "<11"; - int value1 = 11; - char *value2_str = "!13"; - char *value3_str = ">36"; + const char *value1_str = "<11"; + const char *value2_str = "!13"; + const char *value3_str = ">36"; int value3 = 36; int i; @@ -1391,20 +1174,11 @@ static int DetectIPProtoTestSetup19(void) sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) goto end; if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x07) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value3 / 8); i++) { + for (i = 0; i < (value3 / 8); i++) { if (sig->proto.proto[i] != 0) goto end; } @@ -1415,22 +1189,23 @@ static int DetectIPProtoTestSetup19(void) if (sig->proto.proto[i] != 0xFF) goto end; } + if (DetectIPProtoSetup(NULL, sig, value1_str) == 0) + goto end; result = 1; end: SigFree(sig); return result; -#endif } -static int DetectIPProtoTestSetup20(void) +static int DetectIPProtoTestSetup23(void) { int result = 0; Signature *sig; - char *value1_str = "<11"; - int value1 = 11; - char *value3_str = ">36"; + const char *value1_str = "<11"; + const char *value3_str = ">36"; + int value3 = 36; int i; if ((sig = SigAlloc()) == NULL) @@ -1438,20 +1213,20 @@ static int DetectIPProtoTestSetup20(void) sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) + if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) + for (i = 0; i < (value3 / 8); i++) { + if (sig->proto.proto[i] != 0) goto end; } - if (sig->proto.proto[value1 / 8] != 0x07) { + if (sig->proto.proto[value3 / 8] != 0xE0) { goto end; } - for (i = (value1 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0) + for (i = (value3 / 8) + 1; i < (256 / 8); i++) { + if (sig->proto.proto[i] != 0xFF) goto end; } - if (DetectIPProtoSetup(NULL, sig, value3_str) == 0) + if (DetectIPProtoSetup(NULL, sig, value1_str) == 0) goto end; result = 1; @@ -1459,14 +1234,15 @@ static int DetectIPProtoTestSetup20(void) end: SigFree(sig); return result; +} -#if 0 +static int DetectIPProtoTestSetup24(void) +{ int result = 0; Signature *sig; - char *value1_str = "<11"; - int value1 = 11; - char *value2_str = "!13"; - char *value3_str = ">36"; + const char *value1_str = "<11"; + const char *value2_str = "!13"; + const char *value3_str = ">36"; int value3 = 36; int i; @@ -1475,20 +1251,11 @@ static int DetectIPProtoTestSetup20(void) sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) goto end; if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x07) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value3 / 8); i++) { + for (i = 0; i < (value3 / 8); i++) { if (sig->proto.proto[i] != 0) goto end; } @@ -1499,23 +1266,24 @@ static int DetectIPProtoTestSetup20(void) if (sig->proto.proto[i] != 0xFF) goto end; } + if (DetectIPProtoSetup(NULL, sig, value1_str) == 0) + goto end; result = 1; end: SigFree(sig); return result; -#endif } -static int DetectIPProtoTestSetup21(void) +static int DetectIPProtoTestSetup33(void) { int result = 0; Signature *sig; - char *value1_str = "<11"; + const char *value1_str = "<11"; int value1 = 11; - char *value2_str = "!13"; - char *value3_str = ">36"; + const char *value2_str = "!34"; + const char *value3_str = ">36"; int i; if ((sig = SigAlloc()) == NULL) @@ -1546,14 +1314,16 @@ static int DetectIPProtoTestSetup21(void) end: SigFree(sig); return result; +} -#if 0 +static int DetectIPProtoTestSetup34(void) +{ int result = 0; Signature *sig; - char *value1_str = "<11"; + const char *value1_str = "<11"; int value1 = 11; - char *value2_str = "!13"; - char *value3_str = ">36"; + const char *value2_str = "!34"; + const char *value3_str = ">36"; int value3 = 36; int i; @@ -1564,18 +1334,9 @@ static int DetectIPProtoTestSetup21(void) sig->proto.flags |= DETECT_PROTO_ANY; if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) goto end; for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x07) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value3 / 8); i++) { if (sig->proto.proto[i] != 0) goto end; } @@ -1586,22 +1347,23 @@ static int DetectIPProtoTestSetup21(void) if (sig->proto.proto[i] != 0xFF) goto end; } + if (DetectIPProtoSetup(NULL, sig, value1_str) == 0) + goto end; result = 1; end: SigFree(sig); return result; -#endif } -static int DetectIPProtoTestSetup22(void) +static int DetectIPProtoTestSetup36(void) { int result = 0; Signature *sig; - char *value1_str = "<11"; - char *value2_str = "!13"; - char *value3_str = ">36"; + const char *value1_str = "<11"; + const char *value2_str = "!34"; + const char *value3_str = ">36"; int value3 = 36; int i; @@ -1610,10 +1372,10 @@ static int DetectIPProtoTestSetup22(void) sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) goto end; + if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) + goto end; for (i = 0; i < (value3 / 8); i++) { if (sig->proto.proto[i] != 0) goto end; @@ -1633,15 +1395,17 @@ static int DetectIPProtoTestSetup22(void) end: SigFree(sig); return result; +} -#if 0 +static int DetectIPProtoTestSetup43(void) +{ int result = 0; Signature *sig; - char *value1_str = "<11"; - int value1 = 11; - char *value2_str = "!13"; - char *value3_str = ">36"; - int value3 = 36; + const char *value1_str = "!4"; + int value1 = 4; + const char *value2_str = "<13"; + int value2 = 13; + const char *value3_str = ">34"; int i; if ((sig = SigAlloc()) == NULL) @@ -1649,46 +1413,42 @@ static int DetectIPProtoTestSetup22(void) sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) + if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) + if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) + if (sig->proto.proto[value1 / 8] != 0xEF) { goto end; - for (i = 0; i < (value1 / 8); i++) { + } + for (i = (value1 / 8) + 1; i < (value2 / 8); i++) { if (sig->proto.proto[i] != 0xFF) goto end; } - if (sig->proto.proto[value1 / 8] != 0x07) { + if (sig->proto.proto[value2 / 8] != 0x1F) { goto end; } - for (i = (value1 / 8) + 1; i < (value3 / 8); i++) { + for (i = (value2 / 8) + 1; i < 256 / 8; i++) { if (sig->proto.proto[i] != 0) goto end; } - if (sig->proto.proto[value3 / 8] != 0xE0) { + if (DetectIPProtoSetup(NULL, sig, value3_str) == 0) goto end; - } - for (i = (value3 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } result = 1; end: SigFree(sig); return result; -#endif } -static int DetectIPProtoTestSetup23(void) +static int DetectIPProtoTestSetup44(void) { int result = 0; Signature *sig; - char *value1_str = "<11"; - char *value3_str = ">36"; - int value3 = 36; + const char *value1_str = "!4"; + const char *value2_str = "<13"; + const char *value3_str = ">34"; + int value3 = 34; int i; if ((sig = SigAlloc()) == NULL) @@ -1696,20 +1456,22 @@ static int DetectIPProtoTestSetup23(void) sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; sig->proto.flags |= DETECT_PROTO_ANY; + if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) + goto end; if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) goto end; for (i = 0; i < (value3 / 8); i++) { if (sig->proto.proto[i] != 0) goto end; } - if (sig->proto.proto[value3 / 8] != 0xE0) { + if (sig->proto.proto[value3 / 8] != 0xF8) { goto end; } - for (i = (value3 / 8) + 1; i < (256 / 8); i++) { + for (i = (value3 / 8) + 1; i < 256 / 8; i++) { if (sig->proto.proto[i] != 0xFF) goto end; } - if (DetectIPProtoSetup(NULL, sig, value1_str) == 0) + if (DetectIPProtoSetup(NULL, sig, value2_str) == 0) goto end; result = 1; @@ -1717,15 +1479,17 @@ static int DetectIPProtoTestSetup23(void) end: SigFree(sig); return result; +} -#if 0 +static int DetectIPProtoTestSetup45(void) +{ int result = 0; Signature *sig; - char *value1_str = "<11"; - int value1 = 11; - char *value2_str = "!13"; - char *value3_str = ">36"; - int value3 = 36; + const char *value1_str = "!4"; + int value1 = 4; + const char *value2_str = "<13"; + int value2 = 13; + const char *value3_str = ">34"; int i; if ((sig = SigAlloc()) == NULL) @@ -1733,47 +1497,42 @@ static int DetectIPProtoTestSetup23(void) sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) + if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) goto end; if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) + if (sig->proto.proto[value1 / 8] != 0xEF) { goto end; - for (i = 0; i < (value1 / 8); i++) { + } + for (i = (value1 / 8) + 1; i < (value2 / 8); i++) { if (sig->proto.proto[i] != 0xFF) goto end; } - if (sig->proto.proto[value1 / 8] != 0x07) { + if (sig->proto.proto[value2 / 8] != 0x1F) { goto end; } - for (i = (value1 / 8) + 1; i < (value3 / 8); i++) { + for (i = (value2 / 8) + 1; i < 256 / 8; i++) { if (sig->proto.proto[i] != 0) goto end; } - if (sig->proto.proto[value3 / 8] != 0xE0) { + if (DetectIPProtoSetup(NULL, sig, value3_str) == 0) goto end; - } - for (i = (value3 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } result = 1; end: SigFree(sig); return result; -#endif } -static int DetectIPProtoTestSetup24(void) +static int DetectIPProtoTestSetup56(void) { int result = 0; Signature *sig; - char *value1_str = "<11"; - char *value2_str = "!13"; - char *value3_str = ">36"; - int value3 = 36; + const char *value1_str = "<13"; + int value1 = 13; + const char *value2_str = ">34"; + const char *value3_str = "!37"; int i; if ((sig = SigAlloc()) == NULL) @@ -1781,86 +1540,38 @@ static int DetectIPProtoTestSetup24(void) sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xE0) { - goto end; - } - for (i = (value3 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value1_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "<11"; - int value1 = 11; - char *value2_str = "!13"; - char *value3_str = ">36"; - int value3 = 36; - int i; - - if ((sig = SigAlloc()) == NULL) + if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; for (i = 0; i < (value1 / 8); i++) { if (sig->proto.proto[i] != 0xFF) goto end; } - if (sig->proto.proto[value1 / 8] != 0x07) { + if (sig->proto.proto[value1 / 8] != 0x1F) { goto end; } - for (i = (value1 / 8) + 1; i < (value3 / 8); i++) { + for (i = (value1 / 8) + 1; i < 256 / 8; i++) { if (sig->proto.proto[i] != 0) goto end; } - if (sig->proto.proto[value3 / 8] != 0xE0) { + if (DetectIPProtoSetup(NULL, sig, value2_str) == 0) goto end; - } - for (i = (value3 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } result = 1; end: SigFree(sig); return result; -#endif } -static int DetectIPProtoTestSetup25(void) +static int DetectIPProtoTestSetup75(void) { int result = 0; Signature *sig; - char *value1_str = "<11"; - int value1 = 11; - char *value2_str = "!18"; - char *value3_str = ">36"; + const char *value1_str = "!8"; + const char *value2_str = ">10"; + int value2 = 10; int i; if ((sig = SigAlloc()) == NULL) @@ -1872,34 +1583,32 @@ static int DetectIPProtoTestSetup25(void) goto end; if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) + for (i = 0; i < (value2 / 8); i++) { + if (sig->proto.proto[i] != 0) goto end; } - if (sig->proto.proto[value1 / 8] != 0x07) { + if (sig->proto.proto[value2 / 8] != 0xF8) { goto end; } - for (i = (value1 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0) + for (i = (value2 / 8) + 1; i < (256 / 8); i++) { + if (sig->proto.proto[i] != 0xFF) goto end; } - if (DetectIPProtoSetup(NULL, sig, value3_str) == 0) - goto end; result = 1; end: SigFree(sig); return result; +} -#if 0 +static int DetectIPProtoTestSetup76(void) +{ int result = 0; Signature *sig; - char *value1_str = "<11"; - int value1 = 11; - char *value2_str = "!18"; - char *value3_str = ">36"; - int value3 = 36; + const char *value1_str = "!8"; + const char *value2_str = ">10"; + int value2 = 10; int i; if ((sig = SigAlloc()) == NULL) @@ -1907,27 +1616,18 @@ static int DetectIPProtoTestSetup25(void) sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x07) { + if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) goto end; - } - for (i = (value1 / 8) + 1; i < (value3 / 8); i++) { + for (i = 0; i < (value2 / 8); i++) { if (sig->proto.proto[i] != 0) goto end; } - if (sig->proto.proto[value3 / 8] != 0xE0) { + if (sig->proto.proto[value2 / 8] != 0xF8) { goto end; } - for (i = (value3 / 8) + 1; i < (256 / 8); i++) { + for (i = (value2 / 8) + 1; i < (256 / 8); i++) { if (sig->proto.proto[i] != 0xFF) goto end; } @@ -1937,16 +1637,15 @@ static int DetectIPProtoTestSetup25(void) end: SigFree(sig); return result; -#endif } -static int DetectIPProtoTestSetup26(void) +static int DetectIPProtoTestSetup129(void) { int result = 0; Signature *sig; - char *value1_str = "<11"; - int value1 = 11; - char *value3_str = ">36"; + const char *value1_str = "<10"; + int value1 = 10; + const char *value2_str = ">10"; int i; if ((sig = SigAlloc()) == NULL) @@ -1960,14 +1659,14 @@ static int DetectIPProtoTestSetup26(void) if (sig->proto.proto[i] != 0xFF) goto end; } - if (sig->proto.proto[value1 / 8] != 0x07) { + if (sig->proto.proto[value1 / 8] != 0x03) { goto end; } - for (i = (value1 / 8) + 1; i < (256 / 8); i++) { + for (i = (value1 / 8) + 1; i < 256 / 8; i++) { if (sig->proto.proto[i] != 0) goto end; } - if (DetectIPProtoSetup(NULL, sig, value3_str) == 0) + if (DetectIPProtoSetup(NULL, sig, value2_str) == 0) goto end; result = 1; @@ -1975,14 +1674,15 @@ static int DetectIPProtoTestSetup26(void) end: SigFree(sig); return result; -#if 0 +} + +static int DetectIPProtoTestSetup130(void) +{ int result = 0; Signature *sig; - char *value1_str = "<11"; - int value1 = 11; - char *value2_str = "!18"; - char *value3_str = ">36"; - int value3 = 36; + const char *value1_str = "<10"; + const char *value2_str = ">10"; + int value2 = 10; int i; if ((sig = SigAlloc()) == NULL) @@ -1990,27 +1690,18 @@ static int DetectIPProtoTestSetup26(void) sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x07) { + if (DetectIPProtoSetup(NULL, sig, value1_str) == 0) goto end; - } - for (i = (value1 / 8) + 1; i < (value3 / 8); i++) { + for (i = 0; i < (value2 / 8); i++) { if (sig->proto.proto[i] != 0) goto end; } - if (sig->proto.proto[value3 / 8] != 0xE0) { + if (sig->proto.proto[value2 / 8] != 0xF8) { goto end; } - for (i = (value3 / 8) + 1; i < (256 / 8); i++) { + for (i = (value2 / 8) + 1; i < 256 / 8; i++) { if (sig->proto.proto[i] != 0xFF) goto end; } @@ -2020,17 +1711,15 @@ static int DetectIPProtoTestSetup26(void) end: SigFree(sig); return result; -#endif } -static int DetectIPProtoTestSetup27(void) +static int DetectIPProtoTestSetup131(void) { int result = 0; Signature *sig; - char *value1_str = "<11"; - int value1 = 11; - char *value2_str = "!18"; - char *value3_str = ">36"; + const char *value1_str = "<10"; + int value1 = 10; + const char *value2_str = "!10"; int i; if ((sig = SigAlloc()) == NULL) @@ -2038,66 +1727,19 @@ static int DetectIPProtoTestSetup27(void) sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x07) { - goto end; - } - for (i = (value1 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value3_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "<11"; - int value1 = 11; - char *value2_str = "!18"; - char *value3_str = ">36"; - int value3 = 36; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; for (i = 0; i < (value1 / 8); i++) { if (sig->proto.proto[i] != 0xFF) goto end; } - if (sig->proto.proto[value1 / 8] != 0x07) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xE0) { + if (sig->proto.proto[value1 / 8] != 0x03) { goto end; } - for (i = (value3 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) + for (i = (value1 / 8) + 1; i < 256 / 8; i++) { + if (sig->proto.proto[i] != 0x0) goto end; } @@ -2106,17 +1748,15 @@ static int DetectIPProtoTestSetup27(void) end: SigFree(sig); return result; -#endif } -static int DetectIPProtoTestSetup28(void) +static int DetectIPProtoTestSetup132(void) { int result = 0; Signature *sig; - char *value1_str = "<11"; - char *value2_str = "!18"; - char *value3_str = ">36"; - int value3 = 36; + const char *value1_str = "<10"; + int value1 = 10; + const char *value2_str = "!10"; int i; if ((sig = SigAlloc()) == NULL) @@ -2126,7004 +1766,17 @@ static int DetectIPProtoTestSetup28(void) sig->proto.flags |= DETECT_PROTO_ANY; if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xE0) { + if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) goto end; - } - for (i = (value3 / 8) + 1; i < (256 / 8); i++) { + for (i = 0; i < (value1 / 8); i++) { if (sig->proto.proto[i] != 0xFF) goto end; } - if (DetectIPProtoSetup(NULL, sig, value1_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "<11"; - int value1 = 11; - char *value2_str = "!18"; - char *value3_str = ">36"; - int value3 = 36; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x07) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xE0) { - goto end; - } - for (i = (value3 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup29(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "<11"; - char *value3_str = ">36"; - int value3 = 36; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xE0) { - goto end; - } - for (i = (value3 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value1_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "<11"; - int value1 = 11; - char *value2_str = "!18"; - char *value3_str = ">36"; - int value3 = 36; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x07) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xE0) { - goto end; - } - for (i = (value3 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup30(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "<11"; - char *value2_str = "!18"; - char *value3_str = ">36"; - int value3 = 36; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xE0) { - goto end; - } - for (i = (value3 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value1_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "<11"; - int value1 = 11; - char *value2_str = "!18"; - char *value3_str = ">36"; - int value3 = 36; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x07) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xE0) { - goto end; - } - for (i = (value3 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup31(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "<11"; - int value1 = 11; - char *value2_str = "!34"; - char *value3_str = ">36"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x07) { - goto end; - } - for (i = (value1 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value3_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "<11"; - int value1 = 11; - char *value2_str = "!34"; - char *value3_str = ">36"; - int value3 = 36; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x07) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xE0) { - goto end; - } - for (i = (value3 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup32(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "<11"; - int value1 = 11; - char *value3_str = ">36"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x07) { - goto end; - } - for (i = (value1 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value3_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "<11"; - int value1 = 11; - char *value2_str = "!34"; - char *value3_str = ">36"; - int value3 = 36; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x07) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xE0) { - goto end; - } - for (i = (value3 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup33(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "<11"; - int value1 = 11; - char *value2_str = "!34"; - char *value3_str = ">36"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x07) { - goto end; - } - for (i = (value1 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value3_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "<11"; - int value1 = 11; - char *value2_str = "!34"; - char *value3_str = ">36"; - int value3 = 36; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x07) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xE0) { - goto end; - } - for (i = (value3 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup34(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "<11"; - int value1 = 11; - char *value2_str = "!34"; - char *value3_str = ">36"; - int value3 = 36; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xE0) { - goto end; - } - for (i = (value3 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value1_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "<11"; - int value1 = 11; - char *value2_str = "!34"; - char *value3_str = ">36"; - int value3 = 36; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup35(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "<11"; - char *value3_str = ">36"; - int value3 = 36; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xE0) { - goto end; - } - for (i = (value3 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value1_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "<11"; - int value1 = 11; - char *value2_str = "!34"; - char *value3_str = ">36"; - int value3 = 36; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x07) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xE0) { - goto end; - } - for (i = (value3 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup36(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "<11"; - char *value2_str = "!34"; - char *value3_str = ">36"; - int value3 = 36; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xE0) { - goto end; - } - for (i = (value3 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value1_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "<11"; - int value1 = 11; - char *value2_str = "!34"; - char *value3_str = ">36"; - int value3 = 36; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x07) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xE0) { - goto end; - } - for (i = (value3 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup37(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "<10"; - int value1 = 10; - char *value2_str = "!12"; - char *value3_str = ">14"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x03) { - goto end; - } - for (i = (value1 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0x0) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value3_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "<10"; - int value1 = 10; - char *value2_str = "!12"; - char *value3_str = ">14"; - int value3 = 14; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x83) { - goto end; - } - for (i = (value3 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup38(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "<10"; - int value1 = 10; - char *value3_str = ">14"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x03) { - goto end; - } - for (i = (value1 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value3_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "<10"; - int value1 = 10; - char *value2_str = "!12"; - char *value3_str = ">14"; - int value3 = 14; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x83) { - goto end; - } - for (i = (value3 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup39(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "<10"; - int value1 = 10; - char *value2_str = "!12"; - char *value3_str = ">14"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x03) { - goto end; - } - for (i = (value1 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value3_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "<10"; - int value1 = 10; - char *value2_str = "!12"; - char *value3_str = ">14"; - int value3 = 14; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x83) { - goto end; - } - for (i = (value3 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup40(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "<10"; - int value1 = 10; - char *value2_str = "!12"; - char *value3_str = ">14"; - int value3 = 14; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x80) { - goto end; - } - for (i = (value3 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value1_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "<10"; - int value1 = 10; - char *value2_str = "!12"; - char *value3_str = ">14"; - int value3 = 14; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x83) { - goto end; - } - for (i = (value3 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup41(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "<10"; - int value1 = 10; - char *value3_str = ">14"; - int value3 = 14; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x80) { - goto end; - } - for (i = (value3 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value1_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "<10"; - int value1 = 10; - char *value2_str = "!12"; - char *value3_str = ">14"; - int value3 = 14; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x83) { - goto end; - } - for (i = (value3 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup42(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "<10"; - int value1 = 10; - char *value2_str = "!12"; - char *value3_str = ">14"; - int value3 = 14; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x80) { - goto end; - } - for (i = (value3 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value1_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "<10"; - int value1 = 10; - char *value2_str = "!12"; - char *value3_str = ">14"; - int value3 = 14; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x83) { - goto end; - } - for (i = (value3 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup43(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!4"; - int value1 = 4; - char *value2_str = "<13"; - int value2 = 13; - char *value3_str = ">34"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (sig->proto.proto[value1 / 8] != 0xEF) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0x1F) { - goto end; - } - for (i = (value2 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value3_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "!4"; - int value1 = 4; - char *value2_str = "<13"; - int value2 = 13; - char *value3_str = ">34"; - int value3 = 34; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (sig->proto.proto[value1 / 8] != 0xEF) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0x1F) { - goto end; - } - for (i = (value2 / 8) + 1; i < value3 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xF8) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup44(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!4"; - char *value2_str = "<13"; - char *value3_str = ">34"; - int value3 = 34; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xF8) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value2_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "!4"; - int value1 = 4; - char *value2_str = "<13"; - int value2 = 13; - char *value3_str = ">34"; - int value3 = 34; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (sig->proto.proto[value1 / 8] != 0xEF) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0x1F) { - goto end; - } - for (i = (value2 / 8) + 1; i < value3 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xF8) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup45(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!4"; - int value1 = 4; - char *value2_str = "<13"; - int value2 = 13; - char *value3_str = ">34"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (sig->proto.proto[value1 / 8] != 0xEF) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0x1F) { - goto end; - } - for (i = (value2 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value3_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "!4"; - int value1 = 4; - char *value2_str = "<13"; - int value2 = 13; - char *value3_str = ">34"; - int value3 = 34; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (sig->proto.proto[value1 / 8] != 0xEF) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0x1F) { - goto end; - } - for (i = (value2 / 8) + 1; i < value3 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xF8) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup46(void) -{ - int result = 0; - Signature *sig; - char *value2_str = "<13"; - int value2 = 13; - char *value3_str = ">34"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0x1F) { - goto end; - } - for (i = (value2 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value3_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "!4"; - int value1 = 4; - char *value2_str = "<13"; - int value2 = 13; - char *value3_str = ">34"; - int value3 = 34; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (sig->proto.proto[value1 / 8] != 0xEF) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0x1F) { - goto end; - } - for (i = (value2 / 8) + 1; i < value3 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xF8) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup47(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!4"; - char *value2_str = "<13"; - char *value3_str = ">34"; - int value3 = 34; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xF8) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value2_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "!4"; - int value1 = 4; - char *value2_str = "<13"; - int value2 = 13; - char *value3_str = ">34"; - int value3 = 34; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (sig->proto.proto[value1 / 8] != 0xEF) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0x1F) { - goto end; - } - for (i = (value2 / 8) + 1; i < value3 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xF8) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup48(void) -{ - int result = 0; - Signature *sig; - char *value2_str = "<13"; - char *value3_str = ">34"; - int value3 = 34; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xF8) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value2_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "!4"; - int value1 = 4; - char *value2_str = "<13"; - int value2 = 13; - char *value3_str = ">34"; - int value3 = 34; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (sig->proto.proto[value1 / 8] != 0xEF) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0x1F) { - goto end; - } - for (i = (value2 / 8) + 1; i < value3 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xF8) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup49(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!11"; - int value1 = 11; - char *value2_str = "<13"; - int value2 = 13; - char *value3_str = ">34"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x17) { - goto end; - } - for (i = (value2 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value3_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "!11"; - int value1 = 11; - char *value2_str = "<13"; - int value2 = 13; - char *value3_str = ">34"; - int value3 = 34; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x17) { - goto end; - } - for (i = (value2 / 8) + 1; i < value3 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xF8) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup50(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!11"; - char *value2_str = "<13"; - char *value3_str = ">34"; - int value3 = 34; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < value3 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xF8) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value2_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "!11"; - int value1 = 11; - char *value2_str = "<13"; - int value2 = 13; - char *value3_str = ">34"; - int value3 = 34; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x17) { - goto end; - } - for (i = (value2 / 8) + 1; i < value3 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xF8) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup51(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!11"; - int value1 = 11; - char *value2_str = "<13"; - int value2 = 13; - char *value3_str = ">34"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x17) { - goto end; - } - for (i = (value2 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value3_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "!11"; - int value1 = 11; - char *value2_str = "<13"; - int value2 = 13; - char *value3_str = ">34"; - int value3 = 34; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x17) { - goto end; - } - for (i = (value2 / 8) + 1; i < value3 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xF8) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup52(void) -{ - int result = 0; - Signature *sig; - char *value2_str = "<13"; - int value2 = 13; - char *value3_str = ">34"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0x1F) { - goto end; - } - for (i = (value2 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value3_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "!11"; - int value1 = 11; - char *value2_str = "<13"; - int value2 = 13; - char *value3_str = ">34"; - int value3 = 34; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x17) { - goto end; - } - for (i = (value2 / 8) + 1; i < value3 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xF8) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup53(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!11"; - char *value2_str = "<13"; - char *value3_str = ">34"; - int value3 = 34; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < value3 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xF8) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value2_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "!11"; - int value1 = 11; - char *value2_str = "<13"; - int value2 = 13; - char *value3_str = ">34"; - int value3 = 34; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x17) { - goto end; - } - for (i = (value2 / 8) + 1; i < value3 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xF8) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup54(void) -{ - int result = 0; - Signature *sig; - char *value2_str = "<13"; - char *value3_str = ">34"; - int value3 = 34; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xF8) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value2_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "!11"; - int value1 = 11; - char *value2_str = "<13"; - int value2 = 13; - char *value3_str = ">34"; - int value3 = 34; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x17) { - goto end; - } - for (i = (value2 / 8) + 1; i < value3 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xF8) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup55(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "<13"; - int value1 = 13; - char *value2_str = ">34"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x1F) { - goto end; - } - for (i = (value1 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value2_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "<13"; - int value1 = 13; - char *value2_str = ">34"; - int value2 = 34; - char *value3_str = "!37"; - int value3 = 37; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x1F) { - goto end; - } - for (i = (value1 / 8) + 1; i < value2 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xD8) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup56(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "<13"; - int value1 = 13; - char *value2_str = ">34"; - char *value3_str = "!37"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x1F) { - goto end; - } - for (i = (value1 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value2_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "<13"; - int value1 = 13; - char *value2_str = ">34"; - int value2 = 34; - char *value3_str = "!37"; - int value3 = 37; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x1F) { - goto end; - } - for (i = (value1 / 8) + 1; i < value2 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xD8) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup57(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "<13"; - char *value2_str = ">34"; - int value2 = 34; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < value2 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xF8) { - goto end; - } - for (i = (value2 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value1_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "<13"; - int value1 = 13; - char *value2_str = ">34"; - int value2 = 34; - char *value3_str = "!37"; - int value3 = 37; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x1F) { - goto end; - } - for (i = (value1 / 8) + 1; i < value2 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xD8) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup58(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "<13"; - char *value2_str = ">34"; - int value2 = 34; - char *value3_str = "!37"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < value2 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xD8) { - goto end; - } - for (i = (value2 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value1_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "<13"; - int value1 = 13; - char *value2_str = ">34"; - int value2 = 34; - char *value3_str = "!37"; - int value3 = 37; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x1F) { - goto end; - } - for (i = (value1 / 8) + 1; i < value2 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xD8) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup59(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "<13"; - int value1 = 13; - char *value2_str = ">34"; - char *value3_str = "!37"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x1F) { - goto end; - } - for (i = (value1 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value2_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "<13"; - int value1 = 13; - char *value2_str = ">34"; - int value2 = 34; - char *value3_str = "!37"; - int value3 = 37; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x1F) { - goto end; - } - for (i = (value1 / 8) + 1; i < value2 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xD8) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup60(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "<13"; - char *value2_str = ">34"; - int value2 = 34; - char *value3_str = "!37"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < value2 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xD8) { - goto end; - } - for (i = (value2 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value1_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "<13"; - int value1 = 13; - char *value2_str = ">34"; - int value2 = 34; - char *value3_str = "!37"; - int value3 = 37; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x1F) { - goto end; - } - for (i = (value1 / 8) + 1; i < value2 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xD8) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup61(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "<13"; - int value1 = 13; - char *value2_str = ">34"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x1F) { - goto end; - } - for (i = (value1 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value2_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "<13"; - int value1 = 13; - char *value2_str = ">34"; - int value2 = 34; - char *value3_str = "!44"; - int value3 = 44; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x1F) { - goto end; - } - for (i = (value1 / 8) + 1; i < value2 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xF8) { - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xEF) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup62(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "<13"; - int value1 = 13; - char *value2_str = ">34"; - char *value3_str = "!44"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x1F) { - goto end; - } - for (i = (value1 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value2_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "<13"; - int value1 = 13; - char *value2_str = ">34"; - int value2 = 34; - char *value3_str = "!44"; - int value3 = 44; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x1F) { - goto end; - } - for (i = (value1 / 8) + 1; i < value2 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xF8) { - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xEF) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup63(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "<13"; - char *value2_str = ">34"; - int value2 = 34; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < value2 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xF8) { - goto end; - } - for (i = (value2 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value1_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "<13"; - int value1 = 13; - char *value2_str = ">34"; - int value2 = 34; - char *value3_str = "!44"; - int value3 = 44; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x1F) { - goto end; - } - for (i = (value1 / 8) + 1; i < value2 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xF8) { - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xEF) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup64(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "<13"; - char *value2_str = ">34"; - int value2 = 34; - char *value3_str = "!44"; - int value3 = 44; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < value2 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xF8) { - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xEF) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value1_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "<13"; - int value1 = 13; - char *value2_str = ">34"; - int value2 = 34; - char *value3_str = "!44"; - int value3 = 44; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x1F) { - goto end; - } - for (i = (value1 / 8) + 1; i < value2 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xF8) { - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xEF) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup65(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "<13"; - int value1 = 13; - char *value2_str = ">34"; - char *value3_str = "!44"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x1F) { - goto end; - } - for (i = (value1 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value2_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "<13"; - int value1 = 13; - char *value2_str = ">34"; - int value2 = 34; - char *value3_str = "!44"; - int value3 = 44; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x1F) { - goto end; - } - for (i = (value1 / 8) + 1; i < value2 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xF8) { - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xEF) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup66(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "<13"; - char *value2_str = ">34"; - int value2 = 34; - char *value3_str = "!44"; - int value3 = 44; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < value2 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xF8) { - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xEF) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value1_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; - -#if 0 - int result = 0; - Signature *sig; - char *value1_str = "<13"; - int value1 = 13; - char *value2_str = ">34"; - int value2 = 34; - char *value3_str = "!44"; - int value3 = 44; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x1F) { - goto end; - } - for (i = (value1 / 8) + 1; i < value2 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xF8) { - goto end; - } - if (sig->proto.proto[value3 / 8] != 0xEF) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -#endif -} - -static int DetectIPProtoTestSetup67(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">14"; - int value1 = 14; - char *value2_str = "<34"; - int value2 = 34; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x80) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0x03) { - goto end; - } - for (i = (value2 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0x0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup68(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">14"; - int value1 = 14; - char *value2_str = "<34"; - int value2 = 34; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x80) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0x03) { - goto end; - } - for (i = (value2 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0x0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup69(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "<14"; - int value2 = 14; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x38) { - goto end; - } - for (i = (value2 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0x0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup70(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "<14"; - int value2 = 14; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x38) { - goto end; - } - for (i = (value2 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0x0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup71(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "!14"; - int value2 = 14; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xB8) { - goto end; - } - for (i = (value2 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup72(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "!14"; - int value2 = 14; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xB8) { - goto end; - } - for (i = (value2 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup73(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "!34"; - int value2 = 34; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xF8) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xFB) { - goto end; - } - for (i = (value2 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup74(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "!34"; - int value2 = 34; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xF8) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xFB) { - goto end; - } - for (i = (value2 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup75(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!8"; - char *value2_str = ">10"; - int value2 = 10; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xF8) { - goto end; - } - for (i = (value2 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup76(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!8"; - char *value2_str = ">10"; - int value2 = 10; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xF8) { - goto end; - } - for (i = (value2 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup77(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!4"; - char *value2_str = ">10"; - int value2 = 10; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xF8) { - goto end; - } - for (i = (value2 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup78(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!4"; - char *value2_str = ">10"; - int value2 = 10; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xF8) { - goto end; - } - for (i = (value2 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup79(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!4"; - int value1 = 4; - char *value2_str = "<10"; - int value2 = 10; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (sig->proto.proto[value1 / 8] != 0xEF) { - goto end; - } - if (sig->proto.proto[value2 / 8] != 0x03) { - goto end; - } - for (i = (value2 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup80(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!4"; - int value1 = 4; - char *value2_str = "<10"; - int value2 = 10; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (sig->proto.proto[value1 / 8] != 0xEF) { - goto end; - } - if (sig->proto.proto[value2 / 8] != 0x03) { - goto end; - } - for (i = (value2 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup81(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!9"; - int value1 = 9; - char *value2_str = "<13"; - int value2 = 13; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x1D) { - goto end; - } - for (i = (value2 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup82(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!9"; - int value1 = 9; - char *value2_str = "<13"; - int value2 = 13; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x1D) { - goto end; - } - for (i = (value2 / 8) + 1; i < (256 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup83(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "<10"; - int value1 = 10; - char *value2_str = "!13"; - int value2 = 13; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x03) { - goto end; - } - for (i = (value2 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup84(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "<10"; - int value1 = 10; - char *value2_str = "!13"; - int value2 = 13; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x03) { - goto end; - } - for (i = (value2 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup85(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "<10"; - int value1 = 10; - char *value2_str = "!35"; - int value2 = 35; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x03) { - goto end; - } - for (i = (value2 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup86(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "<10"; - int value1 = 10; - char *value2_str = "!35"; - int value2 = 35; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x03) { - goto end; - } - for (i = (value2 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup87(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!4"; - char *value2_str = ">10"; - int value2 = 10; - char *value3_str = "<35"; - int value3 = 35; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xF8) { - goto end; - } - for (i = (value2 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0x07) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0x0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup88(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!4"; - char *value2_str = ">10"; - int value2 = 10; - char *value3_str = "<35"; - int value3 = 35; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xF8) { - goto end; - } - for (i = (value2 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0x07) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0x0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup89(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!4"; - char *value2_str = ">10"; - int value2 = 10; - char *value3_str = "<35"; - int value3 = 35; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xF8) { - goto end; - } - for (i = (value2 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0x07) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0x0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup90(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!4"; - char *value2_str = ">10"; - int value2 = 10; - char *value3_str = "<35"; - int value3 = 35; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xF8) { - goto end; - } - for (i = (value2 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0x07) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0x0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup91(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!4"; - char *value2_str = ">10"; - int value2 = 10; - char *value3_str = "<35"; - int value3 = 35; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xF8) { - goto end; - } - for (i = (value2 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0x07) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0x0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup92(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!4"; - char *value2_str = ">10"; - int value2 = 10; - char *value3_str = "<35"; - int value3 = 35; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xF8) { - goto end; - } - for (i = (value2 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0x07) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0x0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup93(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!9"; - char *value2_str = ">12"; - int value2 = 12; - char *value3_str = "<35"; - int value3 = 35; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xE0) { - goto end; - } - for (i = (value2 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup94(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!9"; - char *value2_str = ">12"; - int value2 = 12; - char *value3_str = "<35"; - int value3 = 35; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xE0) { - goto end; - } - for (i = (value2 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup95(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!9"; - char *value2_str = ">12"; - int value2 = 12; - char *value3_str = "<35"; - int value3 = 35; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xE0) { - goto end; - } - for (i = (value2 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup96(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!9"; - char *value2_str = ">12"; - int value2 = 12; - char *value3_str = "<35"; - int value3 = 35; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xE0) { - goto end; - } - for (i = (value2 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup97(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!9"; - char *value2_str = ">12"; - int value2 = 12; - char *value3_str = "<35"; - int value3 = 35; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xE0) { - goto end; - } - for (i = (value2 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup98(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!9"; - char *value2_str = ">12"; - int value2 = 12; - char *value3_str = "<35"; - int value3 = 35; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xE0) { - goto end; - } - for (i = (value2 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup99(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "!13"; - int value2 = 13; - char *value3_str = "<35"; - int value3 = 35; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xD8) { - goto end; - } - for (i = (value2 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup100(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "!13"; - int value2 = 13; - char *value3_str = "<35"; - int value3 = 35; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xD8) { - goto end; - } - for (i = (value2 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup101(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "!13"; - int value2 = 13; - char *value3_str = "<35"; - int value3 = 35; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xD8) { - goto end; - } - for (i = (value2 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup102(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "!13"; - int value2 = 13; - char *value3_str = "<35"; - int value3 = 35; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xD8) { - goto end; - } - for (i = (value2 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup103(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "!13"; - int value2 = 13; - char *value3_str = "<35"; - int value3 = 35; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xD8) { - goto end; - } - for (i = (value2 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup104(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "!13"; - int value2 = 13; - char *value3_str = "<35"; - int value3 = 35; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xD8) { - goto end; - } - for (i = (value2 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup105(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "!18"; - int value2 = 18; - char *value3_str = "<35"; - int value3 = 35; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xF8) { - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xFB) { - goto end; - } - for (i = (value2 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup106(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "!18"; - int value2 = 18; - char *value3_str = "<35"; - int value3 = 35; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xF8) { - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xFB) { - goto end; - } - for (i = (value2 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup107(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "!18"; - int value2 = 18; - char *value3_str = "<35"; - int value3 = 35; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xF8) { - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xFB) { - goto end; - } - for (i = (value2 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup108(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "!18"; - int value2 = 18; - char *value3_str = "<35"; - int value3 = 35; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xF8) { - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xFB) { - goto end; - } - for (i = (value2 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup109(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "!18"; - int value2 = 18; - char *value3_str = "<35"; - int value3 = 35; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xF8) { - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xFB) { - goto end; - } - for (i = (value2 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup110(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "!18"; - int value2 = 18; - char *value3_str = "<35"; - int value3 = 35; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xF8) { - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xFB) { - goto end; - } - for (i = (value2 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup111(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "!33"; - char *value3_str = "<35"; - int value3 = 35; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xF8) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0x05) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup112(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "!33"; - char *value3_str = "<35"; - int value3 = 35; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xF8) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0x05) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup113(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "!33"; - char *value3_str = "<35"; - int value3 = 35; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xF8) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0x05) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup114(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "!33"; - char *value3_str = "<35"; - int value3 = 35; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xF8) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0x05) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup115(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "!33"; - char *value3_str = "<35"; - int value3 = 35; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xF8) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0x05) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup116(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "!33"; - char *value3_str = "<35"; - int value3 = 35; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xF8) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value3 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value3 / 8] != 0x05) { - goto end; - } - for (i = (value3 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup117(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "<34"; - int value2 = 34; - char *value3_str = "!38"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xF8) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0x03) { - goto end; - } - for (i = (value2 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0x0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup118(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "<34"; - int value2 = 34; - char *value3_str = "!38"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xF8) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0x03) { - goto end; - } - for (i = (value2 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0x0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup119(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "<34"; - int value2 = 34; - char *value3_str = "!38"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xF8) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0x03) { - goto end; - } - for (i = (value2 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0x0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup120(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "<34"; - int value2 = 34; - char *value3_str = "!38"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xF8) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0x03) { - goto end; - } - for (i = (value2 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0x0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup121(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "<34"; - int value2 = 34; - char *value3_str = "!38"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xF8) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0x03) { - goto end; - } - for (i = (value2 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0x0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup122(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "<34"; - int value2 = 34; - char *value3_str = "!38"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xF8) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0x03) { - goto end; - } - for (i = (value2 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0x0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup123(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "<34"; - int value2 = 34; - char *value3_str = "!45"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xF8) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0x03) { - goto end; - } - for (i = (value2 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0x0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup124(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "<34"; - int value2 = 34; - char *value3_str = "!45"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xF8) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0x03) { - goto end; - } - for (i = (value2 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0x0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup125(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "<34"; - int value2 = 34; - char *value3_str = "!45"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xF8) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0x03) { - goto end; - } - for (i = (value2 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0x0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup126(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "<34"; - int value2 = 34; - char *value3_str = "!45"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xF8) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0x03) { - goto end; - } - for (i = (value2 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0x0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup127(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "<34"; - int value2 = 34; - char *value3_str = "!45"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xF8) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0x03) { - goto end; - } - for (i = (value2 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0x0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup128(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "<34"; - int value2 = 34; - char *value3_str = "!45"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xF8) { - goto end; - } - for (i = (value1 / 8) + 1; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0x03) { - goto end; - } - for (i = (value2 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0x0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup129(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "<10"; - int value1 = 10; - char *value2_str = ">10"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x03) { - goto end; - } - for (i = (value1 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (DetectIPProtoSetup(NULL, sig, value2_str) == 0) - goto end; - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup130(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "<10"; - char *value2_str = ">10"; - int value2 = 10; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) == 0) - goto end; - for (i = 0; i < (value2 / 8); i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - if (sig->proto.proto[value2 / 8] != 0xF8) { - goto end; - } - for (i = (value2 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup131(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "<10"; - int value1 = 10; - char *value2_str = "!10"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x03) { - goto end; - } - for (i = (value1 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0x0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup132(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "<10"; - int value1 = 10; - char *value2_str = "!10"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0x03) { - goto end; - } - for (i = (value1 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0x0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup133(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "!10"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0x0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xF8) { - goto end; - } - for (i = (value1 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - - -static int DetectIPProtoTestSetup134(void) -{ - int result = 0; - Signature *sig; - char *value1_str = ">10"; - int value1 = 10; - char *value2_str = "!10"; - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - for (i = 0; i < (value1 / 8); i++) { - if (sig->proto.proto[i] != 0x0) - goto end; - } - if (sig->proto.proto[value1 / 8] != 0xF8) { - goto end; - } - for (i = (value1 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0xFF) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup135(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!4"; - char *value2_str = ">8"; - char *value3_str = "!27"; - char *value4_str = "!29"; - char *value5_str = "!30"; - char *value6_str = "!34"; - char *value7_str = "<36"; - char *value8_str = "!38"; - int value8 = 38; - - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value4_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value5_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value6_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value7_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value8_str) != 0) - goto end; - if (sig->proto.proto[0] != 0) { - goto end; - } - if (sig->proto.proto[1] != 0xFE) { - goto end; - } - if (sig->proto.proto[2] != 0xFF) { - goto end; - } - if (sig->proto.proto[3] != 0x97) { - goto end; - } - if (sig->proto.proto[4] != 0x0B) { - goto end; - } - for (i = (value8 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup136(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!4"; - char *value2_str = ">8"; - char *value3_str = "!27"; - char *value4_str = "!29"; - char *value5_str = "!30"; - char *value6_str = "!34"; - char *value7_str = "<36"; - char *value8_str = "!38"; - int value8 = 38; - - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value8_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value7_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value6_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value5_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value4_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (sig->proto.proto[0] != 0) { - goto end; - } - if (sig->proto.proto[1] != 0xFE) { - goto end; - } - if (sig->proto.proto[2] != 0xFF) { - goto end; - } - if (sig->proto.proto[3] != 0x97) { - goto end; - } - if (sig->proto.proto[4] != 0x0B) { - goto end; - } - for (i = (value8 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup137(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!4"; - char *value2_str = ">8"; - char *value3_str = "!27"; - char *value4_str = "!29"; - char *value5_str = "!30"; - char *value6_str = "!34"; - char *value7_str = "<36"; - char *value8_str = "!38"; - int value8 = 38; - - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value5_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value7_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value8_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value4_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value6_str) != 0) - goto end; - if (sig->proto.proto[0] != 0) { - goto end; - } - if (sig->proto.proto[1] != 0xFE) { - goto end; - } - if (sig->proto.proto[2] != 0xFF) { - goto end; - } - if (sig->proto.proto[3] != 0x97) { - goto end; - } - if (sig->proto.proto[4] != 0x0B) { - goto end; - } - for (i = (value8 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup138(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!4"; - char *value2_str = ">8"; - char *value3_str = "!27"; - char *value4_str = "!29"; - char *value5_str = "!30"; - char *value6_str = "!34"; - char *value7_str = "<36"; - char *value8_str = "!38"; - int value8 = 38; - - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value7_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value4_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value8_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value6_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value5_str) != 0) - goto end; - if (sig->proto.proto[0] != 0) { - goto end; - } - if (sig->proto.proto[1] != 0xFE) { - goto end; - } - if (sig->proto.proto[2] != 0xFF) { - goto end; - } - if (sig->proto.proto[3] != 0x97) { - goto end; - } - if (sig->proto.proto[4] != 0x0B) { - goto end; - } - for (i = (value8 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup139(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!4"; - char *value2_str = ">8"; - char *value3_str = "!27"; - char *value4_str = "!29"; - char *value5_str = "!30"; - char *value6_str = "!34"; - char *value7_str = "<36"; - char *value8_str = "!38"; - int value8 = 38; - - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value7_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value5_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value8_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value6_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value4_str) != 0) - goto end; - if (sig->proto.proto[0] != 0) { - goto end; - } - if (sig->proto.proto[1] != 0xFE) { - goto end; - } - if (sig->proto.proto[2] != 0xFF) { - goto end; - } - if (sig->proto.proto[3] != 0x97) { - goto end; - } - if (sig->proto.proto[4] != 0x0B) { - goto end; - } - for (i = (value8 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup140(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!4"; - char *value2_str = ">8"; - char *value3_str = "!27"; - char *value4_str = "!29"; - char *value5_str = "!30"; - char *value6_str = "!34"; - char *value7_str = "<36"; - char *value8_str = "!38"; - int value8 = 38; - - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value4_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value8_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value6_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value7_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value5_str) != 0) - goto end; - if (sig->proto.proto[0] != 0) { - goto end; - } - if (sig->proto.proto[1] != 0xFE) { - goto end; - } - if (sig->proto.proto[2] != 0xFF) { - goto end; - } - if (sig->proto.proto[3] != 0x97) { - goto end; - } - if (sig->proto.proto[4] != 0x0B) { - goto end; - } - for (i = (value8 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup141(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!4"; - char *value2_str = ">8"; - char *value3_str = "!27"; - char *value4_str = "!29"; - char *value5_str = "!30"; - char *value6_str = "!34"; - char *value7_str = "<36"; - char *value8_str = "!38"; - int value8 = 38; - - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value6_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value8_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value7_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value5_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value4_str) != 0) - goto end; - if (sig->proto.proto[0] != 0) { - goto end; - } - if (sig->proto.proto[1] != 0xFE) { - goto end; - } - if (sig->proto.proto[2] != 0xFF) { - goto end; - } - if (sig->proto.proto[3] != 0x97) { - goto end; - } - if (sig->proto.proto[4] != 0x0B) { - goto end; - } - for (i = (value8 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup142(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!4"; - char *value2_str = ">8"; - char *value3_str = "!27"; - char *value4_str = "!29"; - char *value5_str = "!30"; - char *value6_str = "!34"; - char *value7_str = "<36"; - char *value8_str = "!38"; - int value8 = 38; - - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value4_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value8_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value5_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value7_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value6_str) != 0) - goto end; - if (sig->proto.proto[0] != 0) { - goto end; - } - if (sig->proto.proto[1] != 0xFE) { - goto end; - } - if (sig->proto.proto[2] != 0xFF) { - goto end; - } - if (sig->proto.proto[3] != 0x97) { - goto end; - } - if (sig->proto.proto[4] != 0x0B) { - goto end; - } - for (i = (value8 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup143(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!4"; - char *value2_str = ">8"; - char *value3_str = "!10"; - char *value4_str = "!14"; - char *value5_str = "!27"; - char *value6_str = "!29"; - char *value7_str = "!30"; - char *value8_str = "!34"; - char *value9_str = "<36"; - char *value10_str = "!38"; - int value10 = 38; - - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value4_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value5_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value6_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value7_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value8_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value9_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value10_str) != 0) - goto end; - if (sig->proto.proto[0] != 0) { - goto end; - } - if (sig->proto.proto[1] != 0xBA) { - goto end; - } - if (sig->proto.proto[2] != 0xFF) { - goto end; - } - if (sig->proto.proto[3] != 0x97) { - goto end; - } - if (sig->proto.proto[4] != 0x0B) { - goto end; - } - for (i = (value10 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) - goto end; - } - - result = 1; - - end: - SigFree(sig); - return result; -} - -static int DetectIPProtoTestSetup144(void) -{ - int result = 0; - Signature *sig; - char *value1_str = "!4"; - char *value2_str = ">8"; - char *value3_str = "!10"; - char *value4_str = "!14"; - char *value5_str = "!27"; - char *value6_str = "!29"; - char *value7_str = "!30"; - char *value8_str = "!34"; - char *value9_str = "<36"; - char *value10_str = "!38"; - int value10 = 38; - - int i; - - if ((sig = SigAlloc()) == NULL) - goto end; - - sig->init_data->init_flags |= SIG_FLAG_INIT_FIRST_IPPROTO_SEEN; - sig->proto.flags |= DETECT_PROTO_ANY; - if (DetectIPProtoSetup(NULL, sig, value10_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value9_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value8_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value7_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value6_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value5_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value4_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value3_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value2_str) != 0) - goto end; - if (DetectIPProtoSetup(NULL, sig, value1_str) != 0) - goto end; - if (sig->proto.proto[0] != 0) { + if (sig->proto.proto[value1 / 8] != 0x03) { goto end; } - if (sig->proto.proto[1] != 0xBA) { - goto end; - } - if (sig->proto.proto[2] != 0xFF) { - goto end; - } - if (sig->proto.proto[3] != 0x97) { - goto end; - } - if (sig->proto.proto[4] != 0x0B) { - goto end; - } - for (i = (value10 / 8) + 1; i < 256 / 8; i++) { - if (sig->proto.proto[i] != 0) + for (i = (value1 / 8) + 1; i < 256 / 8; i++) { + if (sig->proto.proto[i] != 0x0) goto end; } @@ -9138,16 +1791,16 @@ static int DetectIPProtoTestSetup145(void) { int result = 0; Signature *sig; - char *value1_str = "!4"; - char *value2_str = ">8"; - char *value3_str = "!10"; - char *value4_str = "!14"; - char *value5_str = "!27"; - char *value6_str = "!29"; - char *value7_str = "!30"; - char *value8_str = "!34"; - char *value9_str = "<36"; - char *value10_str = "!38"; + const char *value1_str = "!4"; + const char *value2_str = ">8"; + const char *value3_str = "!10"; + const char *value4_str = "!14"; + const char *value5_str = "!27"; + const char *value6_str = "!29"; + const char *value7_str = "!30"; + const char *value8_str = "!34"; + const char *value9_str = "<36"; + const char *value10_str = "!38"; int value10 = 38; int i; @@ -9216,7 +1869,7 @@ static int DetectIPProtoTestSig1(void) if (p == NULL) return 0; - char *sigs[4]; + const char *sigs[4]; sigs[0] = "alert ip any any -> any any " "(msg:\"Not tcp\"; ip_proto:!tcp; content:\"GET \"; sid:1;)"; sigs[1] = "alert ip any any -> any any " @@ -9450,126 +2103,19 @@ static void DetectIPProtoRegisterTests(void) UtRegisterTest("DetectIPProtoTestSetup22", DetectIPProtoTestSetup22); UtRegisterTest("DetectIPProtoTestSetup23", DetectIPProtoTestSetup23); UtRegisterTest("DetectIPProtoTestSetup24", DetectIPProtoTestSetup24); - UtRegisterTest("DetectIPProtoTestSetup25", DetectIPProtoTestSetup25); - UtRegisterTest("DetectIPProtoTestSetup26", DetectIPProtoTestSetup26); - UtRegisterTest("DetectIPProtoTestSetup27", DetectIPProtoTestSetup27); - UtRegisterTest("DetectIPProtoTestSetup28", DetectIPProtoTestSetup28); - UtRegisterTest("DetectIPProtoTestSetup29", DetectIPProtoTestSetup29); - UtRegisterTest("DetectIPProtoTestSetup30", DetectIPProtoTestSetup30); - UtRegisterTest("DetectIPProtoTestSetup31", DetectIPProtoTestSetup31); - UtRegisterTest("DetectIPProtoTestSetup32", DetectIPProtoTestSetup32); UtRegisterTest("DetectIPProtoTestSetup33", DetectIPProtoTestSetup33); UtRegisterTest("DetectIPProtoTestSetup34", DetectIPProtoTestSetup34); - UtRegisterTest("DetectIPProtoTestSetup35", DetectIPProtoTestSetup35); UtRegisterTest("DetectIPProtoTestSetup36", DetectIPProtoTestSetup36); - UtRegisterTest("DetectIPProtoTestSetup37", DetectIPProtoTestSetup37); - UtRegisterTest("DetectIPProtoTestSetup38", DetectIPProtoTestSetup38); - UtRegisterTest("DetectIPProtoTestSetup39", DetectIPProtoTestSetup39); - UtRegisterTest("DetectIPProtoTestSetup40", DetectIPProtoTestSetup40); - UtRegisterTest("DetectIPProtoTestSetup41", DetectIPProtoTestSetup41); - UtRegisterTest("DetectIPProtoTestSetup42", DetectIPProtoTestSetup42); UtRegisterTest("DetectIPProtoTestSetup43", DetectIPProtoTestSetup43); UtRegisterTest("DetectIPProtoTestSetup44", DetectIPProtoTestSetup44); UtRegisterTest("DetectIPProtoTestSetup45", DetectIPProtoTestSetup45); - UtRegisterTest("DetectIPProtoTestSetup46", DetectIPProtoTestSetup46); - UtRegisterTest("DetectIPProtoTestSetup47", DetectIPProtoTestSetup47); - UtRegisterTest("DetectIPProtoTestSetup48", DetectIPProtoTestSetup48); - UtRegisterTest("DetectIPProtoTestSetup49", DetectIPProtoTestSetup49); - UtRegisterTest("DetectIPProtoTestSetup50", DetectIPProtoTestSetup50); - UtRegisterTest("DetectIPProtoTestSetup51", DetectIPProtoTestSetup51); - UtRegisterTest("DetectIPProtoTestSetup52", DetectIPProtoTestSetup52); - UtRegisterTest("DetectIPProtoTestSetup53", DetectIPProtoTestSetup53); - UtRegisterTest("DetectIPProtoTestSetup54", DetectIPProtoTestSetup54); - UtRegisterTest("DetectIPProtoTestSetup55", DetectIPProtoTestSetup55); UtRegisterTest("DetectIPProtoTestSetup56", DetectIPProtoTestSetup56); - UtRegisterTest("DetectIPProtoTestSetup57", DetectIPProtoTestSetup57); - UtRegisterTest("DetectIPProtoTestSetup58", DetectIPProtoTestSetup58); - UtRegisterTest("DetectIPProtoTestSetup59", DetectIPProtoTestSetup59); - UtRegisterTest("DetectIPProtoTestSetup60", DetectIPProtoTestSetup60); - UtRegisterTest("DetectIPProtoTestSetup61", DetectIPProtoTestSetup61); - UtRegisterTest("DetectIPProtoTestSetup62", DetectIPProtoTestSetup62); - UtRegisterTest("DetectIPProtoTestSetup63", DetectIPProtoTestSetup63); - UtRegisterTest("DetectIPProtoTestSetup64", DetectIPProtoTestSetup64); - UtRegisterTest("DetectIPProtoTestSetup65", DetectIPProtoTestSetup65); - UtRegisterTest("DetectIPProtoTestSetup66", DetectIPProtoTestSetup66); - UtRegisterTest("DetectIPProtoTestSetup67", DetectIPProtoTestSetup67); - UtRegisterTest("DetectIPProtoTestSetup68", DetectIPProtoTestSetup68); - UtRegisterTest("DetectIPProtoTestSetup69", DetectIPProtoTestSetup69); - UtRegisterTest("DetectIPProtoTestSetup70", DetectIPProtoTestSetup70); - UtRegisterTest("DetectIPProtoTestSetup71", DetectIPProtoTestSetup71); - UtRegisterTest("DetectIPProtoTestSetup72", DetectIPProtoTestSetup72); - UtRegisterTest("DetectIPProtoTestSetup73", DetectIPProtoTestSetup73); - UtRegisterTest("DetectIPProtoTestSetup74", DetectIPProtoTestSetup74); UtRegisterTest("DetectIPProtoTestSetup75", DetectIPProtoTestSetup75); UtRegisterTest("DetectIPProtoTestSetup76", DetectIPProtoTestSetup76); - UtRegisterTest("DetectIPProtoTestSetup77", DetectIPProtoTestSetup77); - UtRegisterTest("DetectIPProtoTestSetup78", DetectIPProtoTestSetup78); - UtRegisterTest("DetectIPProtoTestSetup79", DetectIPProtoTestSetup79); - UtRegisterTest("DetectIPProtoTestSetup80", DetectIPProtoTestSetup80); - UtRegisterTest("DetectIPProtoTestSetup81", DetectIPProtoTestSetup81); - UtRegisterTest("DetectIPProtoTestSetup82", DetectIPProtoTestSetup82); - UtRegisterTest("DetectIPProtoTestSetup83", DetectIPProtoTestSetup83); - UtRegisterTest("DetectIPProtoTestSetup84", DetectIPProtoTestSetup84); - UtRegisterTest("DetectIPProtoTestSetup85", DetectIPProtoTestSetup85); - UtRegisterTest("DetectIPProtoTestSetup86", DetectIPProtoTestSetup86); - UtRegisterTest("DetectIPProtoTestSetup87", DetectIPProtoTestSetup87); - UtRegisterTest("DetectIPProtoTestSetup88", DetectIPProtoTestSetup88); - UtRegisterTest("DetectIPProtoTestSetup89", DetectIPProtoTestSetup89); - UtRegisterTest("DetectIPProtoTestSetup90", DetectIPProtoTestSetup90); - UtRegisterTest("DetectIPProtoTestSetup91", DetectIPProtoTestSetup91); - UtRegisterTest("DetectIPProtoTestSetup92", DetectIPProtoTestSetup92); - UtRegisterTest("DetectIPProtoTestSetup93", DetectIPProtoTestSetup93); - UtRegisterTest("DetectIPProtoTestSetup94", DetectIPProtoTestSetup94); - UtRegisterTest("DetectIPProtoTestSetup95", DetectIPProtoTestSetup95); - UtRegisterTest("DetectIPProtoTestSetup96", DetectIPProtoTestSetup96); - UtRegisterTest("DetectIPProtoTestSetup97", DetectIPProtoTestSetup97); - UtRegisterTest("DetectIPProtoTestSetup98", DetectIPProtoTestSetup98); - UtRegisterTest("DetectIPProtoTestSetup99", DetectIPProtoTestSetup99); - UtRegisterTest("DetectIPProtoTestSetup100", DetectIPProtoTestSetup100); - UtRegisterTest("DetectIPProtoTestSetup101", DetectIPProtoTestSetup101); - UtRegisterTest("DetectIPProtoTestSetup102", DetectIPProtoTestSetup102); - UtRegisterTest("DetectIPProtoTestSetup103", DetectIPProtoTestSetup103); - UtRegisterTest("DetectIPProtoTestSetup104", DetectIPProtoTestSetup104); - UtRegisterTest("DetectIPProtoTestSetup105", DetectIPProtoTestSetup105); - UtRegisterTest("DetectIPProtoTestSetup106", DetectIPProtoTestSetup106); - UtRegisterTest("DetectIPProtoTestSetup107", DetectIPProtoTestSetup107); - UtRegisterTest("DetectIPProtoTestSetup108", DetectIPProtoTestSetup108); - UtRegisterTest("DetectIPProtoTestSetup109", DetectIPProtoTestSetup109); - UtRegisterTest("DetectIPProtoTestSetup110", DetectIPProtoTestSetup110); - UtRegisterTest("DetectIPProtoTestSetup111", DetectIPProtoTestSetup111); - UtRegisterTest("DetectIPProtoTestSetup112", DetectIPProtoTestSetup112); - UtRegisterTest("DetectIPProtoTestSetup113", DetectIPProtoTestSetup113); - UtRegisterTest("DetectIPProtoTestSetup114", DetectIPProtoTestSetup114); - UtRegisterTest("DetectIPProtoTestSetup115", DetectIPProtoTestSetup115); - UtRegisterTest("DetectIPProtoTestSetup116", DetectIPProtoTestSetup116); - UtRegisterTest("DetectIPProtoTestSetup117", DetectIPProtoTestSetup117); - UtRegisterTest("DetectIPProtoTestSetup118", DetectIPProtoTestSetup118); - UtRegisterTest("DetectIPProtoTestSetup119", DetectIPProtoTestSetup119); - UtRegisterTest("DetectIPProtoTestSetup120", DetectIPProtoTestSetup120); - UtRegisterTest("DetectIPProtoTestSetup121", DetectIPProtoTestSetup121); - UtRegisterTest("DetectIPProtoTestSetup122", DetectIPProtoTestSetup122); - UtRegisterTest("DetectIPProtoTestSetup123", DetectIPProtoTestSetup123); - UtRegisterTest("DetectIPProtoTestSetup124", DetectIPProtoTestSetup124); - UtRegisterTest("DetectIPProtoTestSetup125", DetectIPProtoTestSetup125); - UtRegisterTest("DetectIPProtoTestSetup126", DetectIPProtoTestSetup126); - UtRegisterTest("DetectIPProtoTestSetup127", DetectIPProtoTestSetup127); - UtRegisterTest("DetectIPProtoTestSetup128", DetectIPProtoTestSetup128); UtRegisterTest("DetectIPProtoTestSetup129", DetectIPProtoTestSetup129); UtRegisterTest("DetectIPProtoTestSetup130", DetectIPProtoTestSetup130); UtRegisterTest("DetectIPProtoTestSetup131", DetectIPProtoTestSetup131); UtRegisterTest("DetectIPProtoTestSetup132", DetectIPProtoTestSetup132); - UtRegisterTest("DetectIPProtoTestSetup133", DetectIPProtoTestSetup133); - UtRegisterTest("DetectIPProtoTestSetup134", DetectIPProtoTestSetup134); - UtRegisterTest("DetectIPProtoTestSetup135", DetectIPProtoTestSetup135); - UtRegisterTest("DetectIPProtoTestSetup136", DetectIPProtoTestSetup136); - UtRegisterTest("DetectIPProtoTestSetup137", DetectIPProtoTestSetup137); - UtRegisterTest("DetectIPProtoTestSetup138", DetectIPProtoTestSetup138); - UtRegisterTest("DetectIPProtoTestSetup139", DetectIPProtoTestSetup139); - UtRegisterTest("DetectIPProtoTestSetup140", DetectIPProtoTestSetup140); - UtRegisterTest("DetectIPProtoTestSetup141", DetectIPProtoTestSetup141); - UtRegisterTest("DetectIPProtoTestSetup142", DetectIPProtoTestSetup142); - UtRegisterTest("DetectIPProtoTestSetup143", DetectIPProtoTestSetup143); - UtRegisterTest("DetectIPProtoTestSetup144", DetectIPProtoTestSetup144); UtRegisterTest("DetectIPProtoTestSetup145", DetectIPProtoTestSetup145); UtRegisterTest("DetectIPProtoTestSig1", DetectIPProtoTestSig1); diff --git a/src/detect-iprep.c b/src/detect-iprep.c index 7b0dfb78b6..e3cfe1b032 100644 --- a/src/detect-iprep.c +++ b/src/detect-iprep.c @@ -54,7 +54,7 @@ static pcre_extra *parse_regex_study; static int DetectIPRepMatch (ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectIPRepSetup (DetectEngineCtx *, Signature *, char *); +static int DetectIPRepSetup (DetectEngineCtx *, Signature *, const char *); void DetectIPRepFree (void *); void IPRepRegisterTests(void); @@ -233,7 +233,7 @@ static int DetectIPRepMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Pack return 0; } -int DetectIPRepSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr) +int DetectIPRepSetup (DetectEngineCtx *de_ctx, Signature *s, const char *rawstr) { DetectIPRepData *cd = NULL; SigMatch *sm = NULL; @@ -378,7 +378,7 @@ void DetectIPRepFree (void *ptr) } #ifdef UNITTESTS -FILE *DetectIPRepGenerateCategoriesDummy() +static FILE *DetectIPRepGenerateCategoriesDummy(void) { FILE *fd = NULL; const char *buffer = "1,BadHosts,Know bad hosts"; @@ -390,7 +390,7 @@ FILE *DetectIPRepGenerateCategoriesDummy() return fd; } -FILE *DetectIPRepGenerateCategoriesDummy2() +static FILE *DetectIPRepGenerateCategoriesDummy2(void) { FILE *fd = NULL; const char *buffer = @@ -404,7 +404,7 @@ FILE *DetectIPRepGenerateCategoriesDummy2() return fd; } -FILE *DetectIPRepGenerateNetworksDummy() +static FILE *DetectIPRepGenerateNetworksDummy(void) { FILE *fd = NULL; const char *buffer = "10.0.0.0/24,1,20"; @@ -416,7 +416,7 @@ FILE *DetectIPRepGenerateNetworksDummy() return fd; } -FILE *DetectIPRepGenerateNetworksDummy2() +static FILE *DetectIPRepGenerateNetworksDummy2(void) { FILE *fd = NULL; const char *buffer = diff --git a/src/detect-isdataat.c b/src/detect-isdataat.c index 56cdbb3f62..3dcddb826d 100644 --- a/src/detect-isdataat.c +++ b/src/detect-isdataat.c @@ -55,7 +55,7 @@ static pcre *parse_regex; static pcre_extra *parse_regex_study; -int DetectIsdataatSetup (DetectEngineCtx *, Signature *, char *); +int DetectIsdataatSetup (DetectEngineCtx *, Signature *, const char *); void DetectIsdataatRegisterTests(void); void DetectIsdataatFree(void *); @@ -84,7 +84,7 @@ void DetectIsdataatRegister(void) * \retval idad pointer to DetectIsdataatData on success * \retval NULL on failure */ -DetectIsdataatData *DetectIsdataatParse (char *isdataatstr, char **offset) +static DetectIsdataatData *DetectIsdataatParse (const char *isdataatstr, char **offset) { DetectIsdataatData *idad = NULL; char *args[3] = {NULL,NULL,NULL}; @@ -195,7 +195,7 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -int DetectIsdataatSetup (DetectEngineCtx *de_ctx, Signature *s, char *isdataatstr) +int DetectIsdataatSetup (DetectEngineCtx *de_ctx, Signature *s, const char *isdataatstr) { SigMatch *sm = NULL; SigMatch *prev_pm = NULL; @@ -305,7 +305,7 @@ static int g_dce_stub_data_buffer_id = 0; * \test DetectIsdataatTestParse01 is a test to make sure that we return a correct IsdataatData structure * when given valid isdataat opt */ -int DetectIsdataatTestParse01 (void) +static int DetectIsdataatTestParse01 (void) { int result = 0; DetectIsdataatData *idad = NULL; @@ -322,7 +322,7 @@ int DetectIsdataatTestParse01 (void) * \test DetectIsdataatTestParse02 is a test to make sure that we return a correct IsdataatData structure * when given valid isdataat opt */ -int DetectIsdataatTestParse02 (void) +static int DetectIsdataatTestParse02 (void) { int result = 0; DetectIsdataatData *idad = NULL; @@ -339,7 +339,7 @@ int DetectIsdataatTestParse02 (void) * \test DetectIsdataatTestParse03 is a test to make sure that we return a correct IsdataatData structure * when given valid isdataat opt */ -int DetectIsdataatTestParse03 (void) +static int DetectIsdataatTestParse03 (void) { int result = 0; DetectIsdataatData *idad = NULL; @@ -355,7 +355,7 @@ int DetectIsdataatTestParse03 (void) /** * \test Test isdataat option for dce sig. */ -int DetectIsdataatTestParse04(void) +static int DetectIsdataatTestParse04(void) { Signature *s = SigAlloc(); int result = 1; @@ -380,7 +380,7 @@ int DetectIsdataatTestParse04(void) /** * \test Test isdataat option for dce sig. */ -int DetectIsdataatTestParse05(void) +static int DetectIsdataatTestParse05(void) { DetectEngineCtx *de_ctx = NULL; int result = 1; @@ -482,7 +482,7 @@ int DetectIsdataatTestParse05(void) return result; } -int DetectIsdataatTestParse06(void) +static int DetectIsdataatTestParse06(void) { DetectEngineCtx *de_ctx = NULL; int result = 0; @@ -530,7 +530,7 @@ int DetectIsdataatTestParse06(void) * \test DetectIsdataatTestPacket01 is a test to check matches of * isdataat, and isdataat relative */ -int DetectIsdataatTestPacket01 (void) +static int DetectIsdataatTestPacket01 (void) { int result = 0; uint8_t *buf = (uint8_t *)"Hi all!"; @@ -543,7 +543,7 @@ int DetectIsdataatTestPacket01 (void) if (p[0] == NULL || p[1] == NULL ||p[2] == NULL) goto end; - char *sigs[5]; + const char *sigs[5]; sigs[0]= "alert ip any any -> any any (msg:\"Testing window 1\"; isdataat:6; sid:1;)"; sigs[1]= "alert ip any any -> any any (msg:\"Testing window 2\"; content:\"all\"; isdataat:1, relative; isdataat:6; sid:2;)"; sigs[2]= "alert ip any any -> any any (msg:\"Testing window 3\"; isdataat:8; sid:3;)"; @@ -572,7 +572,7 @@ end: * isdataat, and isdataat relative works if the previous keyword is pcre * (bug 144) */ -int DetectIsdataatTestPacket02 (void) +static int DetectIsdataatTestPacket02 (void) { int result = 0; uint8_t *buf = (uint8_t *)"GET /AllWorkAndNoPlayMakesWillADullBoy HTTP/1.0" @@ -604,7 +604,7 @@ end: * isdataat, and isdataat relative works if the previous keyword is byte_jump * (bug 146) */ -int DetectIsdataatTestPacket03 (void) +static int DetectIsdataatTestPacket03 (void) { int result = 0; uint8_t *buf = (uint8_t *)"GET /AllWorkAndNoPlayMakesWillADullBoy HTTP/1.0" diff --git a/src/detect-itype.c b/src/detect-itype.c index 0931972b80..638c07877a 100644 --- a/src/detect-itype.c +++ b/src/detect-itype.c @@ -48,7 +48,7 @@ static pcre_extra *parse_regex_study; static int DetectITypeMatch(ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectITypeSetup(DetectEngineCtx *, Signature *, char *); +static int DetectITypeSetup(DetectEngineCtx *, Signature *, const char *); void DetectITypeRegisterTests(void); void DetectITypeFree(void *); @@ -144,7 +144,7 @@ static int DetectITypeMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Pack * \retval itd pointer to DetectITypeData on success * \retval NULL on failure */ -DetectITypeData *DetectITypeParse(char *itypestr) +static DetectITypeData *DetectITypeParse(const char *itypestr) { DetectITypeData *itd = NULL; char *args[3] = {NULL, NULL, NULL}; @@ -248,7 +248,7 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -static int DetectITypeSetup(DetectEngineCtx *de_ctx, Signature *s, char *itypestr) +static int DetectITypeSetup(DetectEngineCtx *de_ctx, Signature *s, const char *itypestr) { DetectITypeData *itd = NULL; @@ -363,7 +363,7 @@ static _Bool PrefilterITypeIsPrefilterable(const Signature *s) /** * \test DetectITypeParseTest01 is a test for setting a valid itype value */ -int DetectITypeParseTest01(void) +static int DetectITypeParseTest01(void) { DetectITypeData *itd = NULL; int result = 0; @@ -380,7 +380,7 @@ int DetectITypeParseTest01(void) * \test DetectITypeParseTest02 is a test for setting a valid itype value * with ">" operator */ -int DetectITypeParseTest02(void) +static int DetectITypeParseTest02(void) { DetectITypeData *itd = NULL; int result = 0; @@ -397,7 +397,7 @@ DetectITypeData *itd = NULL; * \test DetectITypeParseTest03 is a test for setting a valid itype value * with "<" operator */ -int DetectITypeParseTest03(void) +static int DetectITypeParseTest03(void) { DetectITypeData *itd = NULL; int result = 0; @@ -414,7 +414,7 @@ int DetectITypeParseTest03(void) * \test DetectITypeParseTest04 is a test for setting a valid itype value * with "<>" operator */ -int DetectITypeParseTest04(void) +static int DetectITypeParseTest04(void) { DetectITypeData *itd = NULL; int result = 0; @@ -431,7 +431,7 @@ DetectITypeData *itd = NULL; * \test DetectITypeParseTest05 is a test for setting a valid itype value * with spaces all around */ -int DetectITypeParseTest05(void) +static int DetectITypeParseTest05(void) { DetectITypeData *itd = NULL; int result = 0; @@ -448,7 +448,7 @@ DetectITypeData *itd = NULL; * \test DetectITypeParseTest06 is a test for setting a valid itype value * with ">" operator and spaces all around */ -int DetectITypeParseTest06(void) +static int DetectITypeParseTest06(void) { DetectITypeData *itd = NULL; int result = 0; @@ -465,7 +465,7 @@ DetectITypeData *itd = NULL; * \test DetectITypeParseTest07 is a test for setting a valid itype value * with "<>" operator and spaces all around */ -int DetectITypeParseTest07(void) +static int DetectITypeParseTest07(void) { DetectITypeData *itd = NULL; int result = 0; @@ -481,7 +481,7 @@ DetectITypeData *itd = NULL; /** * \test DetectITypeParseTest08 is a test for setting an invalid itype value */ -int DetectITypeParseTest08(void) +static int DetectITypeParseTest08(void) { DetectITypeData *itd = NULL; itd = DetectITypeParse("> 8 <> 20"); @@ -496,7 +496,7 @@ int DetectITypeParseTest08(void) * keyword by creating 5 rules and matching a crafted packet against * them. 4 out of 5 rules shall trigger. */ -int DetectITypeMatchTest01(void) +static int DetectITypeMatchTest01(void) { Packet *p = NULL; diff --git a/src/detect-l3proto.c b/src/detect-l3proto.c index fb94a9a0f6..7766231fd9 100644 --- a/src/detect-l3proto.c +++ b/src/detect-l3proto.c @@ -38,13 +38,15 @@ #include "detect-engine-siggroup.h" #include "detect-engine-address.h" +#include "detect-l3proto.h" + #include "util-byte.h" #include "util-unittest.h" #include "util-unittest-helper.h" #include "util-debug.h" -static int DetectL3ProtoSetup(DetectEngineCtx *, Signature *, char *); +static int DetectL3ProtoSetup(DetectEngineCtx *, Signature *, const char *); void DetectL3protoRegisterTests(void); @@ -68,21 +70,9 @@ void DetectL3ProtoRegister(void) * * \return Non-zero on error */ -static int DetectL3ProtoSetup(DetectEngineCtx *de_ctx, Signature *s, char *optstr) +static int DetectL3ProtoSetup(DetectEngineCtx *de_ctx, Signature *s, const char *optstr) { - char *str = optstr; - char dubbed = 0; - - /* Strip leading and trailing "s. */ - if (optstr[0] == '\"') { - str = SCStrdup(optstr + 1); - if (unlikely(str == NULL)) - goto error; - if (strlen(str) && str[strlen(str) - 1] == '\"') { - str[strlen(str) - 1] = '\0'; - } - dubbed = 1; - } + const char *str = optstr; /* reset possible any value */ if (s->proto.flags & DETECT_PROTO_ANY) { @@ -111,12 +101,8 @@ static int DetectL3ProtoSetup(DetectEngineCtx *de_ctx, Signature *s, char *optst goto error; } - if (dubbed) - SCFree(str); return 0; error: - if (dubbed) - SCFree(str); return -1; } diff --git a/src/detect-lua-extensions.c b/src/detect-lua-extensions.c index 91d1f071e4..c731b92cec 100644 --- a/src/detect-lua-extensions.c +++ b/src/detect-lua-extensions.c @@ -70,6 +70,7 @@ #include "util-lua-ssh.h" #include "util-lua-smtp.h" #include "util-lua-dnp3.h" +#include "detect-lua-extensions.h" static const char luaext_key_ld[] = "suricata:luadata"; diff --git a/src/detect-lua.c b/src/detect-lua.c index 5eb9f0eca9..b5603c5d5b 100644 --- a/src/detect-lua.c +++ b/src/detect-lua.c @@ -61,7 +61,7 @@ #ifndef HAVE_LUA -static int DetectLuaSetupNoSupport (DetectEngineCtx *a, Signature *b, char *c) +static int DetectLuaSetupNoSupport (DetectEngineCtx *a, Signature *b, const char *c) { SCLogError(SC_ERR_NO_LUA_SUPPORT, "no Lua support built in, needed for lua/luajit keyword"); return -1; @@ -93,7 +93,7 @@ static int DetectLuaAppTxMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Flow *f, uint8_t flags, void *state, void *txv, const Signature *s, const SigMatchCtx *ctx); -static int DetectLuaSetup (DetectEngineCtx *, Signature *, char *); +static int DetectLuaSetup (DetectEngineCtx *, Signature *, const char *); static void DetectLuaRegisterTests(void); static void DetectLuaFree(void *); static int g_smtp_generic_list_id = 0; @@ -173,6 +173,7 @@ static int InspectSmtpGeneric(ThreadVars *tv, #define DATATYPE_DNP3 (1<<20) +#if 0 /** \brief dump stack from lua state to screen */ void LuaDumpStack(lua_State *state) { @@ -207,6 +208,7 @@ void LuaDumpStack(lua_State *state) printf("\n"); } } +#endif int DetectLuaMatchBuffer(DetectEngineThreadCtx *det_ctx, const Signature *s, const SigMatchData *smd, @@ -658,7 +660,7 @@ static void DetectLuaThreadFree(void *ctx) * \retval lua pointer to DetectLuaData on success * \retval NULL on failure */ -static DetectLuaData *DetectLuaParse (const DetectEngineCtx *de_ctx, char *str) +static DetectLuaData *DetectLuaParse (const DetectEngineCtx *de_ctx, const char *str) { DetectLuaData *lua = NULL; @@ -955,7 +957,7 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -static int DetectLuaSetup (DetectEngineCtx *de_ctx, Signature *s, char *str) +static int DetectLuaSetup (DetectEngineCtx *de_ctx, Signature *s, const char *str) { DetectLuaData *lua = NULL; SigMatch *sm = NULL; diff --git a/src/detect-mark.c b/src/detect-mark.c index de04203ce8..1dc41f9b2f 100644 --- a/src/detect-mark.c +++ b/src/detect-mark.c @@ -42,7 +42,7 @@ static pcre *parse_regex; static pcre_extra *parse_regex_study; -static int DetectMarkSetup (DetectEngineCtx *, Signature *, char *); +static int DetectMarkSetup (DetectEngineCtx *, Signature *, const char *); static int DetectMarkPacket(ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p, const Signature *s, const SigMatchCtx *ctx); void DetectMarkDataFree(void *ptr); @@ -72,7 +72,7 @@ void DetectMarkRegister (void) * \retval 0 on success * \retval < 0 on failure */ -static void * DetectMarkParse (char *rawstr) +static void * DetectMarkParse (const char *rawstr) { int ret = 0, res = 0; #define MAX_SUBSTRINGS 30 @@ -182,7 +182,7 @@ static void * DetectMarkParse (char *rawstr) * \retval 0 on Success * \retval -1 on Failure */ -static int DetectMarkSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr) +static int DetectMarkSetup (DetectEngineCtx *de_ctx, Signature *s, const char *rawstr) { #ifdef NFQ DetectMarkData *data = NULL; diff --git a/src/detect-metadata.c b/src/detect-metadata.c index d5b46949d9..87d4d745f7 100644 --- a/src/detect-metadata.c +++ b/src/detect-metadata.c @@ -28,8 +28,9 @@ #include "suricata-common.h" #include "detect.h" +#include "detect-metadata.h" -static int DetectMetadataSetup (DetectEngineCtx *, Signature *, char *); +static int DetectMetadataSetup (DetectEngineCtx *, Signature *, const char *); void DetectMetadataRegister (void) { @@ -42,7 +43,7 @@ void DetectMetadataRegister (void) sigmatch_table[DETECT_METADATA].RegisterTests = NULL; } -static int DetectMetadataSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr) +static int DetectMetadataSetup (DetectEngineCtx *de_ctx, Signature *s, const char *rawstr) { return 0; } diff --git a/src/detect-modbus.c b/src/detect-modbus.c index e0ab9c88c3..7724695d72 100644 --- a/src/detect-modbus.c +++ b/src/detect-modbus.c @@ -108,7 +108,7 @@ static void DetectModbusFree(void *ptr) { * * \retval Pointer to DetectModbusData on success or NULL on failure */ -static DetectModbus *DetectModbusAccessParse(char *str) +static DetectModbus *DetectModbusAccessParse(const char *str) { SCEnter(); DetectModbus *modbus = NULL; @@ -272,7 +272,7 @@ error: * \retval id_d pointer to DetectModbusData on success * \retval NULL on failure */ -static DetectModbus *DetectModbusFunctionParse(char *str) +static DetectModbus *DetectModbusFunctionParse(const char *str) { SCEnter(); DetectModbus *modbus = NULL; @@ -360,7 +360,7 @@ error: * * \retval 0 on Success or -1 on Failure */ -static int DetectModbusSetup(DetectEngineCtx *de_ctx, Signature *s, char *str) +static int DetectModbusSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str) { SCEnter(); DetectModbus *modbus = NULL; diff --git a/src/detect-msg.c b/src/detect-msg.c index fb3d241107..6195f00a47 100644 --- a/src/detect-msg.c +++ b/src/detect-msg.c @@ -32,8 +32,9 @@ #include "detect-parse.h" #include "detect-engine.h" #include "detect-engine-mpm.h" +#include "detect-msg.h" -static int DetectMsgSetup (DetectEngineCtx *, Signature *, char *); +static int DetectMsgSetup (DetectEngineCtx *, Signature *, const char *); void DetectMsgRegisterTests(void); void DetectMsgRegister (void) @@ -48,7 +49,7 @@ void DetectMsgRegister (void) sigmatch_table[DETECT_MSG].flags = SIGMATCH_QUOTES_MANDATORY; } -static int DetectMsgSetup (DetectEngineCtx *de_ctx, Signature *s, char *msgstr) +static int DetectMsgSetup (DetectEngineCtx *de_ctx, Signature *s, const char *msgstr) { size_t slen = strlen(msgstr); if (slen == 0) @@ -118,7 +119,7 @@ static int DetectMsgParseTest01(void) { int result = 0; Signature *sig = NULL; - char *teststringparsed = "flow stateless to_server"; + const char *teststringparsed = "flow stateless to_server"; DetectEngineCtx *de_ctx = DetectEngineCtxInit(); if (de_ctx == NULL) goto end; @@ -148,7 +149,7 @@ static int DetectMsgParseTest02(void) { int result = 0; Signature *sig = NULL; - char *teststringparsed = "msg escape tests wxy'\"\\;:"; + const char *teststringparsed = "msg escape tests wxy'\"\\;:"; DetectEngineCtx *de_ctx = DetectEngineCtxInit(); if (de_ctx == NULL) goto end; @@ -175,7 +176,7 @@ static int DetectMsgParseTest03(void) { int result = 0; Signature *sig = NULL; - char *teststringparsed = "flow stateless to_server"; + const char *teststringparsed = "flow stateless to_server"; DetectEngineCtx *de_ctx = DetectEngineCtxInit(); if (de_ctx == NULL) goto end; diff --git a/src/detect-noalert.c b/src/detect-noalert.c index b4f69af42f..3c68758beb 100644 --- a/src/detect-noalert.c +++ b/src/detect-noalert.c @@ -25,9 +25,10 @@ #include "suricata-common.h" #include "detect.h" +#include "detect-noalert.h" #include "util-debug.h" -static int DetectNoalertSetup (DetectEngineCtx *, Signature *, char *); +static int DetectNoalertSetup (DetectEngineCtx *, Signature *, const char *); void DetectNoalertRegister (void) { @@ -40,7 +41,7 @@ void DetectNoalertRegister (void) sigmatch_table[DETECT_NOALERT].flags |= SIGMATCH_NOOPT; } -static int DetectNoalertSetup (DetectEngineCtx *de_ctx, Signature *s, char *nullstr) +static int DetectNoalertSetup (DetectEngineCtx *de_ctx, Signature *s, const char *nullstr) { if (nullstr != NULL) { SCLogError(SC_ERR_INVALID_VALUE, "nocase has no value"); diff --git a/src/detect-nocase.c b/src/detect-nocase.c index ee0d5bdea0..6e2eec9a0e 100644 --- a/src/detect-nocase.c +++ b/src/detect-nocase.c @@ -28,21 +28,12 @@ #include "detect.h" #include "detect-parse.h" - -#include "flow-var.h" - #include "detect-content.h" -#include "detect-uricontent.h" -#include "detect-pcre.h" -#include "detect-http-client-body.h" -#include "detect-http-cookie.h" -#include "detect-http-header.h" -#include "detect-http-method.h" -#include "detect-http-uri.h" +#include "detect-nocase.h" #include "util-debug.h" -static int DetectNocaseSetup (DetectEngineCtx *, Signature *, char *); +static int DetectNocaseSetup (DetectEngineCtx *, Signature *, const char *); void DetectNocaseRegister(void) { @@ -66,7 +57,7 @@ void DetectNocaseRegister(void) * \retval 0 ok * \retval -1 failure */ -static int DetectNocaseSetup (DetectEngineCtx *de_ctx, Signature *s, char *nullstr) +static int DetectNocaseSetup (DetectEngineCtx *de_ctx, Signature *s, const char *nullstr) { SCEnter(); diff --git a/src/detect-offset.c b/src/detect-offset.c index f0c84ee838..31a835adf0 100644 --- a/src/detect-offset.c +++ b/src/detect-offset.c @@ -33,13 +33,13 @@ #include "detect-content.h" #include "detect-uricontent.h" #include "detect-byte-extract.h" -#include "app-layer.h" +#include "detect-offset.h" #include "flow-var.h" #include "util-debug.h" -static int DetectOffsetSetup(DetectEngineCtx *, Signature *, char *); +static int DetectOffsetSetup(DetectEngineCtx *, Signature *, const char *); void DetectOffsetRegister (void) { @@ -52,24 +52,12 @@ void DetectOffsetRegister (void) sigmatch_table[DETECT_OFFSET].RegisterTests = NULL; } -int DetectOffsetSetup (DetectEngineCtx *de_ctx, Signature *s, char *offsetstr) +int DetectOffsetSetup (DetectEngineCtx *de_ctx, Signature *s, const char *offsetstr) { - char *str = offsetstr; - char dubbed = 0; + const char *str = offsetstr; SigMatch *pm = NULL; int ret = -1; - /* Strip leading and trailing "s. */ - if (offsetstr[0] == '\"') { - str = SCStrdup(offsetstr+1); - if (unlikely(str == NULL)) - goto end; - if (strlen(str) && str[strlen(str) - 1] == '\"') { - str[strlen(str) - 1] = '\0'; - } - dubbed = 1; - } - /* retrive the sm to apply the offset against */ pm = DetectGetLastSMFromLists(s, DETECT_CONTENT, -1); if (pm == NULL) { @@ -128,8 +116,6 @@ int DetectOffsetSetup (DetectEngineCtx *de_ctx, Signature *s, char *offsetstr) ret = 0; end: - if (dubbed) - SCFree(str); return ret; } diff --git a/src/detect-parse.c b/src/detect-parse.c index 6239d5d92c..c7c60cf626 100644 --- a/src/detect-parse.c +++ b/src/detect-parse.c @@ -280,7 +280,7 @@ void SigMatchFree(SigMatch *sm) } /* Get the detection module by name */ -SigTableElmt *SigTableGet(char *name) +static SigTableElmt *SigTableGet(char *name) { SigTableElmt *st = NULL; int i = 0; @@ -583,7 +583,7 @@ int SigMatchListSMBelongsTo(const Signature *s, const SigMatch *key_sm) void SigParsePrepare(void) { - char *regexstr = CONFIG_PCRE; + const char *regexstr = CONFIG_PCRE; const char *eb; int eo; int opts = 0; @@ -828,7 +828,7 @@ error: * \retval 0 On successfully parsing the protocl sent as the argument. * \retval -1 On failure */ -int SigParseProto(Signature *s, const char *protostr) +static int SigParseProto(Signature *s, const char *protostr) { SCEnter(); @@ -936,7 +936,7 @@ static int SigParseActionRejectValidate(const char *action) * Signature. * \retval -1 On failure. */ -int SigParseAction(Signature *s, const char *action) +static int SigParseAction(Signature *s, const char *action) { if (strcasecmp(action, "alert") == 0) { s->action = ACTION_ALERT; @@ -1064,7 +1064,7 @@ error: * \param -1 parse error * \param 0 ok */ -int SigParse(DetectEngineCtx *de_ctx, Signature *s, char *sigstr, uint8_t addrs_direction) +int SigParse(DetectEngineCtx *de_ctx, Signature *s, const char *sigstr, uint8_t addrs_direction) { SCEnter(); @@ -1431,7 +1431,7 @@ SigMatchData* SigMatchList2DataArray(SigMatch *head) * \retval 0 invalid * \retval 1 valid */ -int SigValidate(DetectEngineCtx *de_ctx, Signature *s) +static int SigValidate(DetectEngineCtx *de_ctx, Signature *s) { uint32_t sig_flags = 0; SigMatch *sm, *pm; @@ -1622,7 +1622,7 @@ int SigValidate(DetectEngineCtx *de_ctx, Signature *s) * \internal * \brief Helper function for SigInit(). */ -static Signature *SigInitHelper(DetectEngineCtx *de_ctx, char *sigstr, +static Signature *SigInitHelper(DetectEngineCtx *de_ctx, const char *sigstr, uint8_t dir) { Signature *sig = SigAlloc(); @@ -1718,7 +1718,7 @@ error: * * \retval Pointer to the Signature instance on success; NULL on failure. */ -Signature *SigInit(DetectEngineCtx *de_ctx, char *sigstr) +Signature *SigInit(DetectEngineCtx *de_ctx, const char *sigstr) { SCEnter(); @@ -1756,7 +1756,7 @@ error: * * \param data Pointer to the data, in our case SigDuplWrapper to be freed. */ -void DetectParseDupSigFreeFunc(void *data) +static void DetectParseDupSigFreeFunc(void *data) { if (data != NULL) SCFree(data); @@ -1774,7 +1774,7 @@ void DetectParseDupSigFreeFunc(void *data) * * \retval sw->s->id The generated hash value. */ -uint32_t DetectParseDupSigHashFunc(HashListTable *ht, void *data, uint16_t datalen) +static uint32_t DetectParseDupSigHashFunc(HashListTable *ht, void *data, uint16_t datalen) { SigDuplWrapper *sw = (SigDuplWrapper *)data; @@ -1793,7 +1793,7 @@ uint32_t DetectParseDupSigHashFunc(HashListTable *ht, void *data, uint16_t datal * \retval 1 If the 2 SigDuplWrappers sent as args match. * \retval 0 If the 2 SigDuplWrappers sent as args do not match. */ -char DetectParseDupSigCompareFunc(void *data1, uint16_t len1, void *data2, +static char DetectParseDupSigCompareFunc(void *data1, uint16_t len1, void *data2, uint16_t len2) { SigDuplWrapper *sw1 = (SigDuplWrapper *)data1; @@ -1991,7 +1991,7 @@ end: * \retval Pointer to the head Signature in the detection engine ctx sig_list * on success; NULL on failure. */ -Signature *DetectEngineAppendSig(DetectEngineCtx *de_ctx, char *sigstr) +Signature *DetectEngineAppendSig(DetectEngineCtx *de_ctx, const char *sigstr) { Signature *sig = SigInit(de_ctx, sigstr); if (sig == NULL) { @@ -2150,7 +2150,7 @@ int RuleParseDataFromFile(char *filename) */ #ifdef UNITTESTS -int SigParseTest01 (void) +static int SigParseTest01 (void) { int result = 1; Signature *sig = NULL; @@ -2169,7 +2169,7 @@ end: return result; } -int SigParseTest02 (void) +static int SigParseTest02 (void) { int result = 0; Signature *sig = NULL; @@ -2208,7 +2208,7 @@ end: /** * \test SigParseTest03 test for invalid direction operator in rule */ -int SigParseTest03 (void) +static int SigParseTest03 (void) { int result = 1; Signature *sig = NULL; @@ -2229,7 +2229,7 @@ end: return result; } -int SigParseTest04 (void) +static int SigParseTest04 (void) { int result = 1; Signature *sig = NULL; @@ -2249,7 +2249,7 @@ end: } /** \test Port validation */ -int SigParseTest05 (void) +static int SigParseTest05 (void) { int result = 0; Signature *sig = NULL; @@ -2272,7 +2272,7 @@ end: } /** \test Parsing bug debugging at 2010-03-18 */ -int SigParseTest06 (void) +static int SigParseTest06 (void) { int result = 0; Signature *sig = NULL; @@ -2299,7 +2299,7 @@ end: /** * \test Parsing duplicate sigs. */ -int SigParseTest07(void) +static int SigParseTest07(void) { int result = 0; @@ -2321,7 +2321,7 @@ end: /** * \test Parsing duplicate sigs. */ -int SigParseTest08(void) +static int SigParseTest08(void) { int result = 0; @@ -2344,7 +2344,7 @@ end: /** * \test Parsing duplicate sigs. */ -int SigParseTest09(void) +static int SigParseTest09(void) { int result = 1; @@ -2395,7 +2395,7 @@ end: /** * \test Parsing duplicate sigs. */ -int SigParseTest10(void) +static int SigParseTest10(void) { int result = 1; @@ -2427,7 +2427,7 @@ end: * \test Parsing sig with trailing space(s) as reported by * Morgan Cox on oisf-users. */ -int SigParseTest11(void) +static int SigParseTest11(void) { int result = 0; @@ -2763,7 +2763,7 @@ end: } /** \test Direction operator validation (invalid) */ -int SigParseBidirecTest06 (void) +static int SigParseBidirecTest06 (void) { int result = 1; Signature *sig = NULL; @@ -2783,7 +2783,7 @@ end: } /** \test Direction operator validation (invalid) */ -int SigParseBidirecTest07 (void) +static int SigParseBidirecTest07 (void) { int result = 1; Signature *sig = NULL; @@ -2803,7 +2803,7 @@ end: } /** \test Direction operator validation (invalid) */ -int SigParseBidirecTest08 (void) +static int SigParseBidirecTest08 (void) { int result = 1; Signature *sig = NULL; @@ -2823,7 +2823,7 @@ end: } /** \test Direction operator validation (invalid) */ -int SigParseBidirecTest09 (void) +static int SigParseBidirecTest09 (void) { int result = 1; Signature *sig = NULL; @@ -2843,7 +2843,7 @@ end: } /** \test Direction operator validation (invalid) */ -int SigParseBidirecTest10 (void) +static int SigParseBidirecTest10 (void) { int result = 1; Signature *sig = NULL; @@ -2863,7 +2863,7 @@ end: } /** \test Direction operator validation (invalid) */ -int SigParseBidirecTest11 (void) +static int SigParseBidirecTest11 (void) { int result = 1; Signature *sig = NULL; @@ -2883,7 +2883,7 @@ end: } /** \test Direction operator validation (invalid) */ -int SigParseBidirecTest12 (void) +static int SigParseBidirecTest12 (void) { int result = 1; Signature *sig = NULL; @@ -2903,7 +2903,7 @@ end: } /** \test Direction operator validation (valid) */ -int SigParseBidirecTest13 (void) +static int SigParseBidirecTest13 (void) { int result = 1; Signature *sig = NULL; @@ -2922,7 +2922,7 @@ end: } /** \test Direction operator validation (valid) */ -int SigParseBidirecTest14 (void) +static int SigParseBidirecTest14 (void) { int result = 1; Signature *sig = NULL; @@ -2943,7 +2943,7 @@ end: /** \test Ensure that we don't set bidirectional in a * normal (one direction) Signature */ -int SigTestBidirec01 (void) +static int SigTestBidirec01 (void) { Signature *sig = NULL; int result = 0; @@ -2974,7 +2974,7 @@ end: } /** \test Ensure that we set a bidirectional Signature correctly */ -int SigTestBidirec02 (void) +static int SigTestBidirec02 (void) { int result = 0; Signature *sig = NULL; @@ -3019,7 +3019,7 @@ end: * and we install it with the rest of the signatures, checking * also that it match with the correct addr directions */ -int SigTestBidirec03 (void) +static int SigTestBidirec03 (void) { int result = 0; Signature *sig = NULL; @@ -3031,7 +3031,7 @@ int SigTestBidirec03 (void) de_ctx->flags |= DE_QUIET; - char *sigs[3]; + const char *sigs[3]; sigs[0] = "alert tcp any any -> 192.168.1.1 any (msg:\"SigTestBidirec03 sid 1\"; sid:1;)"; sigs[1] = "alert tcp any any <> 192.168.1.1 any (msg:\"SigTestBidirec03 sid 2 bidirectional\"; sid:2;)"; sigs[2] = "alert tcp any any -> 192.168.1.1 any (msg:\"SigTestBidirec03 sid 3\"; sid:3;)"; @@ -3140,7 +3140,7 @@ end: * and we install it with the rest of the signatures, checking * also that it match with the correct addr directions */ -int SigTestBidirec04 (void) +static int SigTestBidirec04 (void) { int result = 0; Signature *sig = NULL; @@ -3498,7 +3498,7 @@ end: /** * \test mpm */ -int SigParseTestMpm01 (void) +static int SigParseTestMpm01 (void) { int result = 0; Signature *sig = NULL; @@ -3529,7 +3529,7 @@ end: /** * \test mpm */ -int SigParseTestMpm02 (void) +static int SigParseTestMpm02 (void) { int result = 0; Signature *sig = NULL; diff --git a/src/detect-parse.h b/src/detect-parse.h index 456ef66a03..9af561abab 100644 --- a/src/detect-parse.h +++ b/src/detect-parse.h @@ -40,15 +40,15 @@ enum { }; /* prototypes */ -int SigParse(DetectEngineCtx *,Signature *, char *, uint8_t); +int SigParse(DetectEngineCtx *, Signature *, const char *, uint8_t); Signature *SigAlloc(void); void SigFree(Signature *s); -Signature *SigInit(DetectEngineCtx *,char *sigstr); -Signature *SigInitReal(DetectEngineCtx *, char *); +Signature *SigInit(DetectEngineCtx *, const char *sigstr); +Signature *SigInitReal(DetectEngineCtx *, const char *); SigMatchData* SigMatchList2DataArray(SigMatch *head); void SigParsePrepare(void); void SigParseRegisterTests(void); -Signature *DetectEngineAppendSig(DetectEngineCtx *, char *); +Signature *DetectEngineAppendSig(DetectEngineCtx *, const char *); void SigMatchAppendSMToList(Signature *, SigMatch *, int); void SigMatchRemoveSMFromList(Signature *, SigMatch *, int); diff --git a/src/detect-pcre.c b/src/detect-pcre.c index 95fce0e8e6..68b4eedbe5 100644 --- a/src/detect-pcre.c +++ b/src/detect-pcre.c @@ -79,7 +79,7 @@ static pcre_extra *parse_capture_regex_study; static int pcre_use_jit = 1; #endif -static int DetectPcreSetup (DetectEngineCtx *, Signature *, char *); +static int DetectPcreSetup (DetectEngineCtx *, Signature *, const char *); static void DetectPcreFree(void *); static void DetectPcreRegisterTests(void); @@ -792,7 +792,7 @@ error: return -1; } -static int DetectPcreSetup (DetectEngineCtx *de_ctx, Signature *s, char *regexstr) +static int DetectPcreSetup (DetectEngineCtx *de_ctx, Signature *s, const char *regexstr) { SCEnter(); DetectPcreData *pd = NULL; @@ -916,7 +916,7 @@ static int DetectPcreParseTest02 (void) { int result = 1; DetectPcreData *pd = NULL; - char *teststring = "/blah/Ui$"; + const char *teststring = "/blah/Ui$"; int list = DETECT_SM_LIST_NOTSET; DetectEngineCtx *de_ctx = DetectEngineCtxInit(); FAIL_IF_NULL(de_ctx); @@ -935,7 +935,7 @@ static int DetectPcreParseTest03 (void) { int result = 1; DetectPcreData *pd = NULL; - char *teststring = "/blah/UNi"; + const char *teststring = "/blah/UNi"; int list = DETECT_SM_LIST_NOTSET; DetectEngineCtx *de_ctx = DetectEngineCtxInit(); FAIL_IF_NULL(de_ctx); @@ -954,7 +954,7 @@ static int DetectPcreParseTest04 (void) { int result = 1; DetectPcreData *pd = NULL; - char *teststring = "/b\\\"lah/i"; + const char *teststring = "/b\\\"lah/i"; int list = DETECT_SM_LIST_NOTSET; DetectEngineCtx *de_ctx = DetectEngineCtxInit(); FAIL_IF_NULL(de_ctx); @@ -974,7 +974,7 @@ static int DetectPcreParseTest05 (void) { int result = 1; DetectPcreData *pd = NULL; - char *teststring = "/b(l|a)h/"; + const char *teststring = "/b(l|a)h/"; int list = DETECT_SM_LIST_NOTSET; DetectEngineCtx *de_ctx = DetectEngineCtxInit(); FAIL_IF_NULL(de_ctx); @@ -994,7 +994,7 @@ static int DetectPcreParseTest06 (void) { int result = 1; DetectPcreData *pd = NULL; - char *teststring = "/b(l|a)h/smi"; + const char *teststring = "/b(l|a)h/smi"; int list = DETECT_SM_LIST_NOTSET; DetectEngineCtx *de_ctx = DetectEngineCtxInit(); FAIL_IF_NULL(de_ctx); @@ -1014,7 +1014,7 @@ static int DetectPcreParseTest07 (void) { int result = 1; DetectPcreData *pd = NULL; - char *teststring = "/blah/Ui"; + const char *teststring = "/blah/Ui"; int list = DETECT_SM_LIST_NOTSET; DetectEngineCtx *de_ctx = DetectEngineCtxInit(); FAIL_IF_NULL(de_ctx); @@ -1034,7 +1034,7 @@ static int DetectPcreParseTest08 (void) { int result = 1; DetectPcreData *pd = NULL; - char *teststring = "/b(l|a)h/O"; + const char *teststring = "/b(l|a)h/O"; int list = DETECT_SM_LIST_NOTSET; DetectEngineCtx *de_ctx = DetectEngineCtxInit(); FAIL_IF_NULL(de_ctx); @@ -1054,7 +1054,7 @@ static int DetectPcreParseTest08 (void) static int DetectPcreParseTest09 (void) { DetectPcreData *pd = NULL; - char *teststring = "/lala\\\\/"; + const char *teststring = "/lala\\\\/"; int list = DETECT_SM_LIST_NOTSET; DetectEngineCtx *de_ctx = DetectEngineCtxInit(); FAIL_IF_NULL(de_ctx); @@ -1070,7 +1070,7 @@ static int DetectPcreParseTest09 (void) /** * \test Test pcre option for dce sig(yeah I'm bored of writing test titles). */ -int DetectPcreParseTest10(void) +static int DetectPcreParseTest10(void) { Signature *s = SigAlloc(); DetectEngineCtx *de_ctx = DetectEngineCtxInit(); @@ -1099,7 +1099,7 @@ int DetectPcreParseTest10(void) /** * \test Test pcre option for dce sig. */ -int DetectPcreParseTest11(void) +static int DetectPcreParseTest11(void) { DetectEngineCtx *de_ctx = NULL; Signature *s = NULL; @@ -1263,7 +1263,7 @@ static int DetectPcreParseTest14(void) } /** \test Check a signature with pcre relative method */ -int DetectPcreParseTest15(void) +static int DetectPcreParseTest15(void) { DetectEngineCtx *de_ctx = NULL; @@ -1286,7 +1286,7 @@ int DetectPcreParseTest15(void) /** \test Check a signature with pcre relative cookie */ -int DetectPcreParseTest16(void) +static int DetectPcreParseTest16(void) { DetectEngineCtx *de_ctx = NULL; @@ -1308,7 +1308,7 @@ int DetectPcreParseTest16(void) } /** \test Check a signature with pcre relative raw header */ -int DetectPcreParseTest17(void) +static int DetectPcreParseTest17(void) { DetectEngineCtx *de_ctx = NULL; @@ -1330,7 +1330,7 @@ int DetectPcreParseTest17(void) } /** \test Check a signature with pcre relative header */ -int DetectPcreParseTest18(void) +static int DetectPcreParseTest18(void) { DetectEngineCtx *de_ctx = NULL; @@ -1352,7 +1352,7 @@ int DetectPcreParseTest18(void) } /** \test Check a signature with pcre relative client-body */ -int DetectPcreParseTest19(void) +static int DetectPcreParseTest19(void) { DetectEngineCtx *de_ctx = NULL; @@ -1374,7 +1374,7 @@ int DetectPcreParseTest19(void) } /** \test Check a signature with pcre relative raw uri */ -int DetectPcreParseTest20(void) +static int DetectPcreParseTest20(void) { DetectEngineCtx *de_ctx = NULL; @@ -1396,7 +1396,7 @@ int DetectPcreParseTest20(void) } /** \test Check a signature with pcre relative uricontent */ -int DetectPcreParseTest21(void) +static int DetectPcreParseTest21(void) { DetectEngineCtx *de_ctx = NULL; @@ -1418,7 +1418,7 @@ int DetectPcreParseTest21(void) } /** \test Check a signature with pcre relative http_uri */ -int DetectPcreParseTest22(void) +static int DetectPcreParseTest22(void) { DetectEngineCtx *de_ctx = NULL; @@ -1440,7 +1440,7 @@ int DetectPcreParseTest22(void) } /** \test Check a signature with inconsistent pcre relative */ -int DetectPcreParseTest23(void) +static int DetectPcreParseTest23(void) { DetectEngineCtx *de_ctx = NULL; @@ -1462,7 +1462,7 @@ int DetectPcreParseTest23(void) } /** \test Check a signature with inconsistent pcre modifiers */ -int DetectPcreParseTest24(void) +static int DetectPcreParseTest24(void) { DetectEngineCtx *de_ctx = NULL; @@ -1483,7 +1483,7 @@ int DetectPcreParseTest24(void) } /** \test Check a signature with inconsistent pcre modifiers */ -int DetectPcreParseTest25(void) +static int DetectPcreParseTest25(void) { DetectEngineCtx *de_ctx = NULL; @@ -1934,7 +1934,7 @@ static int DetectPcreModifPTest05(void) PASS; } -int DetectPcreTestSig06() +static int DetectPcreTestSig06(void) { uint8_t *buf = (uint8_t *) "lalala lalala\\ lala\n"; @@ -1955,7 +1955,7 @@ end: } /** \test anchored pcre */ -int DetectPcreTestSig07() +static int DetectPcreTestSig07(void) { uint8_t *buf = (uint8_t *) "lalala\n"; @@ -1971,7 +1971,7 @@ int DetectPcreTestSig07() } /** \test anchored pcre */ -int DetectPcreTestSig08() +static int DetectPcreTestSig08(void) { /* test it also without ending in a newline "\n" */ uint8_t *buf = (uint8_t *) diff --git a/src/detect-pkt-data.c b/src/detect-pkt-data.c index 4bdc3b3315..7443dfa053 100644 --- a/src/detect-pkt-data.c +++ b/src/detect-pkt-data.c @@ -29,7 +29,7 @@ #include "detect.h" #include "detect-parse.h" - +#include "detect-pkt-data.h" #include "detect-engine.h" #include "detect-engine-mpm.h" #include "detect-engine-state.h" @@ -43,7 +43,7 @@ #include "util-unittest.h" #include "util-unittest-helper.h" -static int DetectPktDataSetup (DetectEngineCtx *, Signature *, char *); +static int DetectPktDataSetup (DetectEngineCtx *, Signature *, const char *); static void DetectPktDataTestRegister(void); /** @@ -70,7 +70,7 @@ void DetectPktDataRegister(void) * \retval 0 on Success * \retval -1 on Failure */ -static int DetectPktDataSetup (DetectEngineCtx *de_ctx, Signature *s, char *str) +static int DetectPktDataSetup (DetectEngineCtx *de_ctx, Signature *s, const char *str) { SCEnter(); s->init_data->list = DETECT_SM_LIST_NOTSET; diff --git a/src/detect-pktvar.c b/src/detect-pktvar.c index 7a720839d7..9a2291ec15 100644 --- a/src/detect-pktvar.c +++ b/src/detect-pktvar.c @@ -41,7 +41,7 @@ static pcre_extra *parse_regex_study; static int DetectPktvarMatch (ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectPktvarSetup (DetectEngineCtx *, Signature *, char *); +static int DetectPktvarSetup (DetectEngineCtx *, Signature *, const char *); void DetectPktvarRegister (void) { @@ -76,12 +76,12 @@ static int DetectPktvarMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Pac return ret; } -static int DetectPktvarSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr) +static int DetectPktvarSetup (DetectEngineCtx *de_ctx, Signature *s, const char *rawstr) { DetectPktvarData *cd = NULL; SigMatch *sm = NULL; - char *str = rawstr; - char dubbed = 0; + char *str; + int dubbed = 0; uint16_t len; char *varname = NULL, *varcontent = NULL; #define MAX_SUBSTRINGS 30 @@ -102,14 +102,12 @@ static int DetectPktvarSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawst } varname = (char *)str_ptr; - if (ret > 2) { - res = pcre_get_substring((char *)rawstr, ov, MAX_SUBSTRINGS, 2, &str_ptr); - if (res < 0) { - SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre_get_substring failed"); - return -1; - } - varcontent = (char *)str_ptr; + res = pcre_get_substring((char *)rawstr, ov, MAX_SUBSTRINGS, 2, &str_ptr); + if (res < 0) { + SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre_get_substring failed"); + return -1; } + varcontent = (char *)str_ptr; SCLogDebug("varname %s, varcontent %s", varname, varcontent); @@ -120,6 +118,8 @@ static int DetectPktvarSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawst } str[strlen(varcontent)-2] = '\0'; dubbed = 1; + } else { + str = varcontent; } len = strlen(str); diff --git a/src/detect-prefilter.c b/src/detect-prefilter.c index fe50e39ac0..f2beac3d32 100644 --- a/src/detect-prefilter.c +++ b/src/detect-prefilter.c @@ -29,10 +29,10 @@ #include "detect.h" #include "detect-parse.h" #include "detect-content.h" - +#include "detect-prefilter.h" #include "util-debug.h" -static int DetectPrefilterSetup (DetectEngineCtx *, Signature *, char *); +static int DetectPrefilterSetup (DetectEngineCtx *, Signature *, const char *); void DetectPrefilterRegister(void) { @@ -55,7 +55,7 @@ void DetectPrefilterRegister(void) * \retval 0 ok * \retval -1 failure */ -static int DetectPrefilterSetup (DetectEngineCtx *de_ctx, Signature *s, char *nullstr) +static int DetectPrefilterSetup (DetectEngineCtx *de_ctx, Signature *s, const char *nullstr) { SCEnter(); diff --git a/src/detect-priority.c b/src/detect-priority.c index e4b10740ec..e848cec3ad 100644 --- a/src/detect-priority.c +++ b/src/detect-priority.c @@ -27,6 +27,7 @@ #include "suricata-common.h" #include "detect.h" #include "detect-parse.h" +#include "detect-priority.h" #include "detect-engine.h" #include "detect-engine-mpm.h" #include "util-error.h" @@ -38,7 +39,7 @@ static pcre *regex = NULL; static pcre_extra *regex_study = NULL; -static int DetectPrioritySetup (DetectEngineCtx *, Signature *, char *); +static int DetectPrioritySetup (DetectEngineCtx *, Signature *, const char *); void SCPriorityRegisterTests(void); /** @@ -57,7 +58,7 @@ void DetectPriorityRegister (void) DetectSetupParseRegexes(PARSE_REGEX, ®ex, ®ex_study); } -static int DetectPrioritySetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr) +static int DetectPrioritySetup (DetectEngineCtx *de_ctx, Signature *s, const char *rawstr) { char copy_str[128] = ""; @@ -96,7 +97,7 @@ static int DetectPrioritySetup (DetectEngineCtx *de_ctx, Signature *s, char *raw #ifdef UNITTESTS -int DetectPriorityTest01() +static int DetectPriorityTest01(void) { int result = 0; @@ -116,7 +117,7 @@ end: return result; } -int DetectPriorityTest02() +static int DetectPriorityTest02(void) { int result = 0; Signature *last = NULL; diff --git a/src/detect-rawbytes.c b/src/detect-rawbytes.c index 52c53b7f6a..ba8d9dff71 100644 --- a/src/detect-rawbytes.c +++ b/src/detect-rawbytes.c @@ -30,14 +30,14 @@ #include "decode.h" #include "detect.h" #include "detect-parse.h" -#include "flow-var.h" +#include "detect-rawbytes.h" #include "detect-content.h" #include "detect-pcre.h" #include "util-debug.h" -static int DetectRawbytesSetup (DetectEngineCtx *, Signature *, char *); +static int DetectRawbytesSetup (DetectEngineCtx *, Signature *, const char *); void DetectRawbytesRegister (void) { @@ -50,7 +50,7 @@ void DetectRawbytesRegister (void) sigmatch_table[DETECT_RAWBYTES].flags |= SIGMATCH_NOOPT; } -static int DetectRawbytesSetup (DetectEngineCtx *de_ctx, Signature *s, char *nullstr) +static int DetectRawbytesSetup (DetectEngineCtx *de_ctx, Signature *s, const char *nullstr) { SCEnter(); diff --git a/src/detect-reference.c b/src/detect-reference.c index d1a82dfed5..a53517465b 100644 --- a/src/detect-reference.c +++ b/src/detect-reference.c @@ -48,7 +48,7 @@ static pcre *parse_regex; static pcre_extra *parse_regex_study; -static int DetectReferenceSetup(DetectEngineCtx *, Signature *s, char *str); +static int DetectReferenceSetup(DetectEngineCtx *, Signature *s, const char *str); /** * \brief Registration function for the reference: keyword @@ -90,7 +90,7 @@ void DetectReferenceFree(DetectReference *ref) * \retval ref Pointer to signature reference on success. * \retval NULL On failure. */ -static DetectReference *DetectReferenceParse(char *rawstr, DetectEngineCtx *de_ctx) +static DetectReference *DetectReferenceParse(const char *rawstr, DetectEngineCtx *de_ctx) { SCEnter(); @@ -170,7 +170,7 @@ error: * \retval -1 On Failure. */ static int DetectReferenceSetup(DetectEngineCtx *de_ctx, Signature *s, - char *rawstr) + const char *rawstr) { SCEnter(); diff --git a/src/detect-replace.c b/src/detect-replace.c index e4392f3d64..cfc4f1556a 100644 --- a/src/detect-replace.c +++ b/src/detect-replace.c @@ -59,7 +59,7 @@ extern int run_mode; #include "host.h" #include "util-profiling.h" -static int DetectReplaceSetup(DetectEngineCtx *, Signature *, char *); +static int DetectReplaceSetup(DetectEngineCtx *, Signature *, const char *); void DetectReplaceRegisterTests(void); void DetectReplaceRegister (void) @@ -72,7 +72,7 @@ void DetectReplaceRegister (void) sigmatch_table[DETECT_REPLACE].flags = (SIGMATCH_QUOTES_MANDATORY|SIGMATCH_HANDLE_NEGATION); } -int DetectReplaceSetup(DetectEngineCtx *de_ctx, Signature *s, char *replacestr) +int DetectReplaceSetup(DetectEngineCtx *de_ctx, Signature *s, const char *replacestr) { uint8_t *content = NULL; uint16_t len = 0; @@ -220,7 +220,7 @@ void DetectReplaceFreeInternal(DetectReplaceList *replist) */ static int DetectReplaceLongPatternMatchTest(uint8_t *raw_eth_pkt, uint16_t pktsize, - char *sig, uint32_t sid, uint8_t *pp, + const char *sig, uint32_t sid, uint8_t *pp, uint16_t *len) { int result = 0; @@ -305,7 +305,7 @@ end: /** * \brief Wrapper for DetectContentLongPatternMatchTest */ -int DetectReplaceLongPatternMatchTestWrp(char *sig, uint32_t sid, char *sig_rep, uint32_t sid_rep) +static int DetectReplaceLongPatternMatchTestWrp(const char *sig, uint32_t sid, const char *sig_rep, uint32_t sid_rep) { int ret; /** Real packet with the following tcp data: @@ -353,7 +353,7 @@ int DetectReplaceLongPatternMatchTestWrp(char *sig, uint32_t sid, char *sig_rep, /** * \brief Wrapper for DetectContentLongPatternMatchTest */ -int DetectReplaceLongPatternMatchTestUDPWrp(char *sig, uint32_t sid, char *sig_rep, uint32_t sid_rep) +static int DetectReplaceLongPatternMatchTestUDPWrp(const char *sig, uint32_t sid, const char *sig_rep, uint32_t sid_rep) { int ret; /** Real UDP DNS packet with a request A to a1.twimg.com @@ -389,9 +389,9 @@ int DetectReplaceLongPatternMatchTestUDPWrp(char *sig, uint32_t sid, char *sig_r */ static int DetectReplaceMatchTest01(void) { - char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";" + const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";" " content:\"big\"; replace:\"pig\"; sid:1;)"; - char *sig_rep = "alert tcp any any -> any any (msg:\"replace worked\";" + const char *sig_rep = "alert tcp any any -> any any (msg:\"replace worked\";" " content:\"this is a pig test\"; sid:2;)"; return DetectReplaceLongPatternMatchTestWrp(sig, 1, sig_rep, 2); } @@ -401,9 +401,9 @@ static int DetectReplaceMatchTest01(void) */ static int DetectReplaceMatchTest02(void) { - char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";" + const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";" " content:\"th\"; offset: 4; replace:\"TH\"; sid:1;)"; - char *sig_rep = "alert tcp any any -> any any (msg:\"replace worked\";" + const char *sig_rep = "alert tcp any any -> any any (msg:\"replace worked\";" " content:\"THis\"; offset:4; sid:2;)"; return DetectReplaceLongPatternMatchTestWrp(sig, 1, sig_rep, 2); } @@ -413,9 +413,9 @@ static int DetectReplaceMatchTest02(void) */ static int DetectReplaceMatchTest03(void) { - char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";" + const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";" " content:\"th\"; replace:\"TH\"; offset: 4; sid:1;)"; - char *sig_rep = "alert tcp any any -> any any (msg:\"replace worked\";" + const char *sig_rep = "alert tcp any any -> any any (msg:\"replace worked\";" " content:\"THis\"; offset:4; sid:2;)"; return DetectReplaceLongPatternMatchTestWrp(sig, 1, sig_rep, 2); } @@ -425,9 +425,9 @@ static int DetectReplaceMatchTest03(void) */ static int DetectReplaceMatchTest04(void) { - char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";" + const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";" " content:\"th\"; replace:\"TH\"; content:\"patter\"; replace:\"matter\"; sid:1;)"; - char *sig_rep = "alert tcp any any -> any any (msg:\"replace worked\";" + const char *sig_rep = "alert tcp any any -> any any (msg:\"replace worked\";" " content:\"THis\"; content:\"matterns\"; sid:2;)"; return DetectReplaceLongPatternMatchTestWrp(sig, 1, sig_rep, 2); } @@ -437,9 +437,9 @@ static int DetectReplaceMatchTest04(void) */ static int DetectReplaceMatchTest05(void) { - char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";" + const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";" " content:\"th\"; replace:\"TH\"; content:\"nutella\"; sid:1;)"; - char *sig_rep = "alert tcp any any -> any any (msg:\"replace worked\";" + const char *sig_rep = "alert tcp any any -> any any (msg:\"replace worked\";" " content:\"TH\"; sid:2;)"; return !DetectReplaceLongPatternMatchTestWrp(sig, 1, sig_rep, 2); } @@ -450,9 +450,9 @@ static int DetectReplaceMatchTest05(void) */ static int DetectReplaceMatchTest06(void) { - char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";" + const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";" " content:\"nutella\"; replace:\"commode\"; content:\"this is\"; sid:1;)"; - char *sig_rep = "alert tcp any any -> any any (msg:\"replace worked\";" + const char *sig_rep = "alert tcp any any -> any any (msg:\"replace worked\";" " content:\"commode\"; sid:2;)"; return !DetectReplaceLongPatternMatchTestWrp(sig, 1, sig_rep, 2); } @@ -462,9 +462,9 @@ static int DetectReplaceMatchTest06(void) */ static int DetectReplaceMatchTest07(void) { - char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";" + const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";" " content:\"BiG\"; nocase; replace:\"pig\"; sid:1;)"; - char *sig_rep = "alert tcp any any -> any any (msg:\"replace worked\";" + const char *sig_rep = "alert tcp any any -> any any (msg:\"replace worked\";" " content:\"this is a pig test\"; sid:2;)"; return DetectReplaceLongPatternMatchTestWrp(sig, 1, sig_rep, 2); } @@ -474,9 +474,9 @@ static int DetectReplaceMatchTest07(void) */ static int DetectReplaceMatchTest08(void) { - char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";" + const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";" " content:\"big\"; depth:17; replace:\"pig\"; sid:1;)"; - char *sig_rep = "alert tcp any any -> any any (msg:\"replace worked\";" + const char *sig_rep = "alert tcp any any -> any any (msg:\"replace worked\";" " content:\"this is a pig test\"; sid:2;)"; return DetectReplaceLongPatternMatchTestWrp(sig, 1, sig_rep, 2); } @@ -486,9 +486,9 @@ static int DetectReplaceMatchTest08(void) */ static int DetectReplaceMatchTest09(void) { - char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";" + const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";" " content:\"big\"; depth:16; replace:\"pig\"; sid:1;)"; - char *sig_rep = "alert tcp any any -> any any (msg:\"replace worked\";" + const char *sig_rep = "alert tcp any any -> any any (msg:\"replace worked\";" " content:\"this is a pig test\"; sid:2;)"; return !DetectReplaceLongPatternMatchTestWrp(sig, 1, sig_rep, 2); } @@ -498,9 +498,9 @@ static int DetectReplaceMatchTest09(void) */ static int DetectReplaceMatchTest10(void) { - char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";" + const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";" " content:\"big\"; depth:17; replace:\"pig\"; offset: 14; sid:1;)"; - char *sig_rep = "alert tcp any any -> any any (msg:\"replace worked\";" + const char *sig_rep = "alert tcp any any -> any any (msg:\"replace worked\";" " content:\"pig\"; depth:17; offset:14; sid:2;)"; return DetectReplaceLongPatternMatchTestWrp(sig, 1, sig_rep, 2); } @@ -510,9 +510,9 @@ static int DetectReplaceMatchTest10(void) */ static int DetectReplaceMatchTest11(void) { - char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";" + const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";" " content:\"big\"; replace:\"pig\"; content:\"to\"; within: 11; sid:1;)"; - char *sig_rep = "alert tcp any any -> any any (msg:\"replace worked\";" + const char *sig_rep = "alert tcp any any -> any any (msg:\"replace worked\";" " content:\"pig\"; depth:17; offset:14; sid:2;)"; return DetectReplaceLongPatternMatchTestWrp(sig, 1, sig_rep, 2); } @@ -522,9 +522,9 @@ static int DetectReplaceMatchTest11(void) */ static int DetectReplaceMatchTest12(void) { - char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";" + const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";" " content:\"big\"; replace:\"pig\"; content:\"to\"; within: 4; sid:1;)"; - char *sig_rep = "alert tcp any any -> any any (msg:\"replace worked\";" + const char *sig_rep = "alert tcp any any -> any any (msg:\"replace worked\";" " content:\"pig\"; depth:17; offset:14; sid:2;)"; return !DetectReplaceLongPatternMatchTestWrp(sig, 1, sig_rep, 2); } @@ -534,9 +534,9 @@ static int DetectReplaceMatchTest12(void) */ static int DetectReplaceMatchTest13(void) { - char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";" + const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";" " content:\"big\"; replace:\"pig\"; content:\"test\"; distance: 1; sid:1;)"; - char *sig_rep = "alert tcp any any -> any any (msg:\"replace worked\";" + const char *sig_rep = "alert tcp any any -> any any (msg:\"replace worked\";" " content:\"pig\"; depth:17; offset:14; sid:2;)"; return DetectReplaceLongPatternMatchTestWrp(sig, 1, sig_rep, 2); } @@ -546,9 +546,9 @@ static int DetectReplaceMatchTest13(void) */ static int DetectReplaceMatchTest14(void) { - char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";" + const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";" " content:\"big\"; replace:\"pig\"; content:\"test\"; distance: 2; sid:1;)"; - char *sig_rep = "alert tcp any any -> any any (msg:\"replace worked\";" + const char *sig_rep = "alert tcp any any -> any any (msg:\"replace worked\";" " content:\"pig\"; depth:17; offset:14; sid:2;)"; return !DetectReplaceLongPatternMatchTestWrp(sig, 1, sig_rep, 2); } @@ -558,9 +558,9 @@ static int DetectReplaceMatchTest14(void) */ static int DetectReplaceMatchTest15(void) { - char *sig = "alert udp any any -> any any (msg:\"Nothing..\";" + const char *sig = "alert udp any any -> any any (msg:\"Nothing..\";" " content:\"com\"; replace:\"org\"; sid:1;)"; - char *sig_rep = "alert udp any any -> any any (msg:\"replace worked\";" + const char *sig_rep = "alert udp any any -> any any (msg:\"replace worked\";" " content:\"twimg|03|org\"; sid:2;)"; return DetectReplaceLongPatternMatchTestUDPWrp(sig, 1, sig_rep, 2); } diff --git a/src/detect-rev.c b/src/detect-rev.c index 1c1bc401da..d558e75477 100644 --- a/src/detect-rev.c +++ b/src/detect-rev.c @@ -25,10 +25,11 @@ #include "suricata-common.h" #include "detect.h" +#include "detect-rev.h" #include "util-debug.h" #include "util-error.h" -static int DetectRevSetup (DetectEngineCtx *, Signature *, char *); +static int DetectRevSetup (DetectEngineCtx *, Signature *, const char *); void DetectRevRegister (void) { @@ -41,22 +42,8 @@ void DetectRevRegister (void) sigmatch_table[DETECT_REV].RegisterTests = NULL; } -static int DetectRevSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr) +static int DetectRevSetup (DetectEngineCtx *de_ctx, Signature *s, const char *rawstr) { - char *str = rawstr; - char dubbed = 0; - - /* Strip leading and trailing "s. */ - if (rawstr[0] == '\"') { - str = SCStrdup(rawstr+1); - if (unlikely(str == NULL)) - return -1; - if (strlen(str) && str[strlen(str) - 1] == '\"') { - str[strlen(rawstr)-1] = '\0'; - } - dubbed = 1; - } - unsigned long rev = 0; char *endptr = NULL; rev = strtoul(rawstr, &endptr, 10); @@ -72,13 +59,9 @@ static int DetectRevSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr) s->rev = (uint32_t)rev; - if (dubbed) - SCFree(str); return 0; error: - if (dubbed) - SCFree(str); return -1; } diff --git a/src/detect-rpc.c b/src/detect-rpc.c index b559ad6f07..d7e41f07e0 100644 --- a/src/detect-rpc.c +++ b/src/detect-rpc.c @@ -50,7 +50,7 @@ static pcre_extra *parse_regex_study; static int DetectRpcMatch (ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectRpcSetup (DetectEngineCtx *, Signature *, char *); +static int DetectRpcSetup (DetectEngineCtx *, Signature *, const char *); void DetectRpcRegisterTests(void); void DetectRpcFree(void *); @@ -142,7 +142,7 @@ static int DetectRpcMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet * \retval rd pointer to DetectRpcData on success * \retval NULL on failure */ -DetectRpcData *DetectRpcParse (char *rpcstr) +static DetectRpcData *DetectRpcParse (const char *rpcstr) { DetectRpcData *rd = NULL; char *args[3] = {NULL,NULL,NULL}; @@ -254,7 +254,7 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -int DetectRpcSetup (DetectEngineCtx *de_ctx, Signature *s, char *rpcstr) +int DetectRpcSetup (DetectEngineCtx *de_ctx, Signature *s, const char *rpcstr) { DetectRpcData *rd = NULL; SigMatch *sm = NULL; @@ -305,7 +305,7 @@ void DetectRpcFree(void *ptr) * \test DetectRpcTestParse01 is a test to make sure that we return "something" * when given valid rpc opt */ -int DetectRpcTestParse01 (void) +static int DetectRpcTestParse01 (void) { int result = 0; DetectRpcData *rd = NULL; @@ -321,7 +321,7 @@ int DetectRpcTestParse01 (void) /** * \test DetectRpcTestParse02 is a test for setting the established rpc opt */ -int DetectRpcTestParse02 (void) +static int DetectRpcTestParse02 (void) { int result = 0; DetectRpcData *rd = NULL; @@ -346,7 +346,7 @@ int DetectRpcTestParse02 (void) * \test DetectRpcTestParse03 is a test for checking the wildcards * and not specified fields */ -int DetectRpcTestParse03 (void) +static int DetectRpcTestParse03 (void) { int result = 1; DetectRpcData *rd = NULL; @@ -425,7 +425,7 @@ int DetectRpcTestParse03 (void) /** * \test DetectRpcTestParse04 is a test for check the discarding of empty options */ -int DetectRpcTestParse04 (void) +static int DetectRpcTestParse04 (void) { int result = 0; DetectRpcData *rd = NULL; @@ -443,7 +443,7 @@ int DetectRpcTestParse04 (void) /** * \test DetectRpcTestParse05 is a test for check invalid values */ -int DetectRpcTestParse05 (void) +static int DetectRpcTestParse05 (void) { int result = 0; DetectRpcData *rd = NULL; diff --git a/src/detect-sameip.c b/src/detect-sameip.c index 780832b8fe..828157461b 100644 --- a/src/detect-sameip.c +++ b/src/detect-sameip.c @@ -39,7 +39,7 @@ static int DetectSameipMatch(ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectSameipSetup(DetectEngineCtx *, Signature *, char *); +static int DetectSameipSetup(DetectEngineCtx *, Signature *, const char *); static void DetectSameipRegisterTests(void); /** @@ -87,7 +87,7 @@ static int DetectSameipMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx, * \retval 0 on Success * \retval -1 on Failure */ -static int DetectSameipSetup(DetectEngineCtx *de_ctx, Signature *s, char *optstr) +static int DetectSameipSetup(DetectEngineCtx *de_ctx, Signature *s, const char *optstr) { SigMatch *sm = NULL; diff --git a/src/detect-seq.c b/src/detect-seq.c index 6c3bd90531..e2f185ad1a 100644 --- a/src/detect-seq.c +++ b/src/detect-seq.c @@ -40,7 +40,7 @@ #include "util-unittest-helper.h" #include "util-debug.h" -static int DetectSeqSetup(DetectEngineCtx *, Signature *, char *); +static int DetectSeqSetup(DetectEngineCtx *, Signature *, const char *); static int DetectSeqMatch(ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); static void DetectSeqRegisterTests(void); @@ -98,7 +98,7 @@ static int DetectSeqMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx, * \retval 0 on Success * \retval -1 on Failure */ -static int DetectSeqSetup (DetectEngineCtx *de_ctx, Signature *s, char *optstr) +static int DetectSeqSetup (DetectEngineCtx *de_ctx, Signature *s, const char *optstr) { DetectSeqData *data = NULL; SigMatch *sm = NULL; @@ -266,7 +266,7 @@ static int DetectSeqSigTest02(void) /* TCP w/seq=100 */ p[1]->tcph->th_seq = htonl(100); - char *sigs[2]; + const char *sigs[2]; sigs[0]= "alert tcp any any -> any any (msg:\"Testing seq\"; seq:41; sid:1;)"; sigs[1]= "alert tcp any any -> any any (msg:\"Testing seq\"; seq:42; sid:2;)"; diff --git a/src/detect-sid.c b/src/detect-sid.c index d148a3dd07..a356f23fdc 100644 --- a/src/detect-sid.c +++ b/src/detect-sid.c @@ -27,11 +27,12 @@ #include "detect.h" #include "detect-engine.h" #include "detect-parse.h" +#include "detect-sid.h" #include "util-debug.h" #include "util-error.h" #include "util-unittest.h" -static int DetectSidSetup (DetectEngineCtx *, Signature *, char *); +static int DetectSidSetup (DetectEngineCtx *, Signature *, const char *); static void DetectSidRegisterTests(void); void DetectSidRegister (void) @@ -45,23 +46,8 @@ void DetectSidRegister (void) sigmatch_table[DETECT_SID].RegisterTests = DetectSidRegisterTests; } -static int DetectSidSetup (DetectEngineCtx *de_ctx, Signature *s, char *sidstr) +static int DetectSidSetup (DetectEngineCtx *de_ctx, Signature *s, const char *sidstr) { - char *str = sidstr; - char duped = 0; - - /* Strip leading and trailing "s. */ - if (sidstr[0] == '\"') { - str = SCStrdup(sidstr + 1); - if (unlikely(str == NULL)) { - return -1; - } - if (strlen(str) && str[strlen(str) - 1] == '\"') { - str[strlen(str) - 1] = '\0'; - } - duped = 1; - } - unsigned long id = 0; char *endptr = NULL; id = strtoul(sidstr, &endptr, 10); @@ -76,14 +62,9 @@ static int DetectSidSetup (DetectEngineCtx *de_ctx, Signature *s, char *sidstr) } s->id = (uint32_t)id; - - if (duped) - SCFree(str); return 0; error: - if (duped) - SCFree(str); return -1; } diff --git a/src/detect-ssh-proto-version.c b/src/detect-ssh-proto-version.c index 26ec15113a..13a6b69111 100644 --- a/src/detect-ssh-proto-version.c +++ b/src/detect-ssh-proto-version.c @@ -65,7 +65,7 @@ static pcre_extra *parse_regex_study; static int DetectSshVersionMatch (ThreadVars *, DetectEngineThreadCtx *, Flow *, uint8_t, void *, void *, const Signature *, const SigMatchCtx *); -static int DetectSshVersionSetup (DetectEngineCtx *, Signature *, char *); +static int DetectSshVersionSetup (DetectEngineCtx *, Signature *, const char *); static void DetectSshVersionRegisterTests(void); static void DetectSshVersionFree(void *); static int g_ssh_banner_list_id = 0; @@ -148,7 +148,7 @@ static int DetectSshVersionMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, * \retval id_d pointer to DetectSshVersionData on success * \retval NULL on failure */ -DetectSshVersionData *DetectSshVersionParse (char *str) +static DetectSshVersionData *DetectSshVersionParse (const char *str) { DetectSshVersionData *ssh = NULL; #define MAX_SUBSTRINGS 30 @@ -215,7 +215,7 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -static int DetectSshVersionSetup (DetectEngineCtx *de_ctx, Signature *s, char *str) +static int DetectSshVersionSetup (DetectEngineCtx *de_ctx, Signature *s, const char *str) { DetectSshVersionData *ssh = NULL; SigMatch *sm = NULL; @@ -265,7 +265,7 @@ void DetectSshVersionFree(void *ptr) * \test DetectSshVersionTestParse01 is a test to make sure that we parse * a proto version correctly */ -int DetectSshVersionTestParse01 (void) +static int DetectSshVersionTestParse01 (void) { DetectSshVersionData *ssh = NULL; ssh = DetectSshVersionParse("1.0"); @@ -281,7 +281,7 @@ int DetectSshVersionTestParse01 (void) * \test DetectSshVersionTestParse02 is a test to make sure that we parse * the proto version (compatible with proto version 2) correctly */ -int DetectSshVersionTestParse02 (void) +static int DetectSshVersionTestParse02 (void) { DetectSshVersionData *ssh = NULL; ssh = DetectSshVersionParse("2_compat"); @@ -297,7 +297,7 @@ int DetectSshVersionTestParse02 (void) * \test DetectSshVersionTestParse03 is a test to make sure that we * don't return a ssh_data with an invalid value specified */ -int DetectSshVersionTestParse03 (void) +static int DetectSshVersionTestParse03 (void) { DetectSshVersionData *ssh = NULL; ssh = DetectSshVersionParse("2_com"); diff --git a/src/detect-ssh-proto.c b/src/detect-ssh-proto.c index 794290b7a2..75688a6b3a 100644 --- a/src/detect-ssh-proto.c +++ b/src/detect-ssh-proto.c @@ -45,6 +45,7 @@ #include "app-layer.h" #include "app-layer-parser.h" #include "app-layer-ssh.h" +#include "detect-ssh-proto.h" #define KEYWORD_NAME "ssh_proto" #define KEYWORD_DOC "ssh-keywords#ssh-protocol" @@ -169,7 +170,7 @@ static int InspectEngineSshProtocol(ThreadVars *tv, return DETECT_ENGINE_INSPECT_SIG_NO_MATCH; } -static int DetectSshProtocolSetup(DetectEngineCtx *de_ctx, Signature *s, char *arg) +static int DetectSshProtocolSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg) { s->init_data->list = g_buffer_id; return 0; diff --git a/src/detect-ssh-software-version.c b/src/detect-ssh-software-version.c index cd1dbfe5dc..08fcc82669 100644 --- a/src/detect-ssh-software-version.c +++ b/src/detect-ssh-software-version.c @@ -69,7 +69,7 @@ static pcre_extra *parse_regex_study; static int DetectSshSoftwareVersionMatch (ThreadVars *, DetectEngineThreadCtx *, Flow *, uint8_t, void *, void *, const Signature *, const SigMatchCtx *); -static int DetectSshSoftwareVersionSetup (DetectEngineCtx *, Signature *, char *); +static int DetectSshSoftwareVersionSetup (DetectEngineCtx *, Signature *, const char *); static void DetectSshSoftwareVersionRegisterTests(void); static void DetectSshSoftwareVersionFree(void *); static int g_ssh_banner_list_id = 0; @@ -151,7 +151,7 @@ static int DetectSshSoftwareVersionMatch (ThreadVars *t, DetectEngineThreadCtx * * \retval id_d pointer to DetectSshSoftwareVersionData on success * \retval NULL on failure */ -DetectSshSoftwareVersionData *DetectSshSoftwareVersionParse (char *str) +static DetectSshSoftwareVersionData *DetectSshSoftwareVersionParse (const char *str) { DetectSshSoftwareVersionData *ssh = NULL; #define MAX_SUBSTRINGS 30 @@ -210,7 +210,7 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -static int DetectSshSoftwareVersionSetup (DetectEngineCtx *de_ctx, Signature *s, char *str) +static int DetectSshSoftwareVersionSetup (DetectEngineCtx *de_ctx, Signature *s, const char *str) { DetectSshSoftwareVersionData *ssh = NULL; SigMatch *sm = NULL; diff --git a/src/detect-ssh-software.c b/src/detect-ssh-software.c index c93579f69e..abeccc06e6 100644 --- a/src/detect-ssh-software.c +++ b/src/detect-ssh-software.c @@ -45,6 +45,7 @@ #include "app-layer.h" #include "app-layer-parser.h" #include "app-layer-ssh.h" +#include "detect-ssh-software.h" #define KEYWORD_NAME "ssh_software" #define KEYWORD_DOC "ssh-keywords#ssh-software" @@ -169,7 +170,7 @@ static int InspectEngineSshSoftware(ThreadVars *tv, return DETECT_ENGINE_INSPECT_SIG_NO_MATCH; } -static int DetectSshSoftwareSetup(DetectEngineCtx *de_ctx, Signature *s, char *arg) +static int DetectSshSoftwareSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg) { s->init_data->list = g_buffer_id; return 0; diff --git a/src/detect-ssl-state.c b/src/detect-ssl-state.c index 3e7dda0213..e55f4711c3 100644 --- a/src/detect-ssl-state.c +++ b/src/detect-ssl-state.c @@ -51,7 +51,7 @@ #include "stream-tcp.h" #include "app-layer-ssl.h" -#define PARSE_REGEX1 "^\\s*(!?)([_a-zA-Z0-9]+)(.*)$" +#define PARSE_REGEX1 "^(!?)([_a-zA-Z0-9]+)(.*)$" static pcre *parse_regex1; static pcre_extra *parse_regex1_study; @@ -62,7 +62,7 @@ static pcre_extra *parse_regex2_study; static int DetectSslStateMatch(ThreadVars *, DetectEngineThreadCtx *, Flow *, uint8_t, void *, void *, const Signature *, const SigMatchCtx *); -static int DetectSslStateSetup(DetectEngineCtx *, Signature *, char *); +static int DetectSslStateSetup(DetectEngineCtx *, Signature *, const char *); static void DetectSslStateRegisterTests(void); static void DetectSslStateFree(void *); @@ -154,7 +154,7 @@ static int DetectSslStateMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx, * \retval ssd Pointer to DetectSslStateData on succese. * \retval NULL On failure. */ -static DetectSslStateData *DetectSslStateParse(char *arg) +static DetectSslStateData *DetectSslStateParse(const char *arg) { #define MAX_SUBSTRINGS 30 int ret = 0, res = 0; @@ -303,7 +303,7 @@ error: * \retval 0 On success. * \retval -1 On failure. */ -static int DetectSslStateSetup(DetectEngineCtx *de_ctx, Signature *s, char *arg) +static int DetectSslStateSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg) { DetectSslStateData *ssd = NULL; SigMatch *sm = NULL; diff --git a/src/detect-ssl-version.c b/src/detect-ssl-version.c index b6d9c39701..8a429f04ae 100644 --- a/src/detect-ssl-version.c +++ b/src/detect-ssl-version.c @@ -63,7 +63,7 @@ static pcre_extra *parse_regex_study; static int DetectSslVersionMatch(ThreadVars *, DetectEngineThreadCtx *, Flow *, uint8_t, void *, void *, const Signature *, const SigMatchCtx *); -static int DetectSslVersionSetup(DetectEngineCtx *, Signature *, char *); +static int DetectSslVersionSetup(DetectEngineCtx *, Signature *, const char *); static void DetectSslVersionRegisterTests(void); static void DetectSslVersionFree(void *); static int g_tls_generic_list_id = 0; @@ -165,7 +165,7 @@ static int DetectSslVersionMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx, * \retval ssl pointer to DetectSslVersionData on success * \retval NULL on failure */ -static DetectSslVersionData *DetectSslVersionParse(char *str) +static DetectSslVersionData *DetectSslVersionParse(const char *str) { DetectSslVersionData *ssl = NULL; #define MAX_SUBSTRINGS 30 @@ -277,7 +277,7 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -static int DetectSslVersionSetup (DetectEngineCtx *de_ctx, Signature *s, char *str) +static int DetectSslVersionSetup (DetectEngineCtx *de_ctx, Signature *s, const char *str) { DetectSslVersionData *ssl = NULL; SigMatch *sm = NULL; diff --git a/src/detect-stream_size.c b/src/detect-stream_size.c index 529139d5c8..dce2e659a8 100644 --- a/src/detect-stream_size.c +++ b/src/detect-stream_size.c @@ -46,7 +46,7 @@ static pcre_extra *parse_regex_study; /*prototypes*/ static int DetectStreamSizeMatch (ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectStreamSizeSetup (DetectEngineCtx *, Signature *, char *); +static int DetectStreamSizeSetup (DetectEngineCtx *, Signature *, const char *); void DetectStreamSizeFree(void *); void DetectStreamSizeRegisterTests(void); @@ -176,8 +176,7 @@ static int DetectStreamSizeMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, * \retval sd pointer to DetectStreamSizeData on success * \retval NULL on failure */ - -DetectStreamSizeData *DetectStreamSizeParse (char *streamstr) +static DetectStreamSizeData *DetectStreamSizeParse (const char *streamstr) { DetectStreamSizeData *sd = NULL; @@ -287,7 +286,7 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -static int DetectStreamSizeSetup (DetectEngineCtx *de_ctx, Signature *s, char *streamstr) +static int DetectStreamSizeSetup (DetectEngineCtx *de_ctx, Signature *s, const char *streamstr) { DetectStreamSizeData *sd = NULL; diff --git a/src/detect-tag.c b/src/detect-tag.c index b844deb7ee..28c39498b4 100644 --- a/src/detect-tag.c +++ b/src/detect-tag.c @@ -59,7 +59,7 @@ static pcre_extra *parse_regex_study; static int DetectTagMatch(ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectTagSetup(DetectEngineCtx *, Signature *, char *); +static int DetectTagSetup(DetectEngineCtx *, Signature *, const char *); void DetectTagRegisterTests(void); void DetectTagDataFree(void *); @@ -151,7 +151,7 @@ static int DetectTagMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet * \retval td pointer to DetectTagData on success * \retval NULL on failure */ -DetectTagData *DetectTagParse(char *tagstr) +static DetectTagData *DetectTagParse(const char *tagstr) { DetectTagData td; #define MAX_SUBSTRINGS 30 @@ -281,7 +281,7 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -int DetectTagSetup(DetectEngineCtx *de_ctx, Signature *s, char *tagstr) +int DetectTagSetup(DetectEngineCtx *de_ctx, Signature *s, const char *tagstr) { DetectTagData *td = NULL; SigMatch *sm = NULL; diff --git a/src/detect-template-buffer.c b/src/detect-template-buffer.c index 1e7fcceea2..46f824503c 100644 --- a/src/detect-template-buffer.c +++ b/src/detect-template-buffer.c @@ -36,8 +36,9 @@ #include "detect-engine.h" #include "app-layer-template.h" #include "detect-engine-template.h" +#include "detect-template-buffer.h" -static int DetectTemplateBufferSetup(DetectEngineCtx *, Signature *, char *); +static int DetectTemplateBufferSetup(DetectEngineCtx *, Signature *, const char *); static void DetectTemplateBufferRegisterTests(void); static int g_template_buffer_id = 0; @@ -71,7 +72,7 @@ void DetectTemplateBufferRegister(void) } static int DetectTemplateBufferSetup(DetectEngineCtx *de_ctx, Signature *s, - char *str) + const char *str) { s->init_data->list = g_template_buffer_id; s->alproto = ALPROTO_TEMPLATE; diff --git a/src/detect-template.c b/src/detect-template.c index b3aff67bde..f9c7aad468 100644 --- a/src/detect-template.c +++ b/src/detect-template.c @@ -41,7 +41,7 @@ static pcre_extra *parse_regex_study; /* Prototypes of functions registered in DetectTemplateRegister below */ static int DetectTemplateMatch (ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectTemplateSetup (DetectEngineCtx *, Signature *, char *); +static int DetectTemplateSetup (DetectEngineCtx *, Signature *, const char *); static void DetectTemplateFree (void *); static void DetectTemplateRegisterTests (void); @@ -181,7 +181,7 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -static int DetectTemplateSetup (DetectEngineCtx *de_ctx, Signature *s, char *templatestr) +static int DetectTemplateSetup (DetectEngineCtx *de_ctx, Signature *s, const char *templatestr) { DetectTemplateData *templated = NULL; SigMatch *sm = NULL; diff --git a/src/detect-threshold.c b/src/detect-threshold.c index 3632d4d4d1..88949b56b1 100644 --- a/src/detect-threshold.c +++ b/src/detect-threshold.c @@ -66,7 +66,7 @@ static pcre_extra *parse_regex_study; static int DetectThresholdMatch(ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectThresholdSetup(DetectEngineCtx *, Signature *, char *); +static int DetectThresholdSetup(DetectEngineCtx *, Signature *, const char *); static void DetectThresholdFree(void *); /** @@ -103,7 +103,7 @@ static int DetectThresholdMatch(ThreadVars *thv, DetectEngineThreadCtx *det_ctx, * \retval de pointer to DetectThresholdData on success * \retval NULL on failure */ -static DetectThresholdData *DetectThresholdParse(char *rawstr) +static DetectThresholdData *DetectThresholdParse(const char *rawstr) { DetectThresholdData *de = NULL; #define MAX_SUBSTRINGS 30 @@ -222,7 +222,7 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -static int DetectThresholdSetup(DetectEngineCtx *de_ctx, Signature *s, char *rawstr) +static int DetectThresholdSetup(DetectEngineCtx *de_ctx, Signature *s, const char *rawstr) { DetectThresholdData *de = NULL; SigMatch *sm = NULL; diff --git a/src/detect-tls-cert-issuer.c b/src/detect-tls-cert-issuer.c index c88a533439..8b7f57494c 100644 --- a/src/detect-tls-cert-issuer.c +++ b/src/detect-tls-cert-issuer.c @@ -49,11 +49,12 @@ #include "app-layer.h" #include "app-layer-ssl.h" +#include "detect-tls-cert-issuer.h" #include "util-unittest.h" #include "util-unittest-helper.h" -static int DetectTlsIssuerSetup(DetectEngineCtx *, Signature *, char *); +static int DetectTlsIssuerSetup(DetectEngineCtx *, Signature *, const char *); static void DetectTlsIssuerRegisterTests(void); static int g_tls_cert_issuer_buffer_id = 0; @@ -92,7 +93,7 @@ void DetectTlsIssuerRegister(void) * * \retval 0 On success */ -static int DetectTlsIssuerSetup(DetectEngineCtx *de_ctx, Signature *s, char *str) +static int DetectTlsIssuerSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str) { s->init_data->list = g_tls_cert_issuer_buffer_id; s->alproto = ALPROTO_TLS; diff --git a/src/detect-tls-cert-serial.c b/src/detect-tls-cert-serial.c index 5463fccaca..c275b96faf 100644 --- a/src/detect-tls-cert-serial.c +++ b/src/detect-tls-cert-serial.c @@ -49,11 +49,12 @@ #include "app-layer.h" #include "app-layer-ssl.h" +#include "detect-tls-cert-serial.h" #include "util-unittest.h" #include "util-unittest-helper.h" -static int DetectTlsSerialSetup(DetectEngineCtx *, Signature *, char *); +static int DetectTlsSerialSetup(DetectEngineCtx *, Signature *, const char *); static void DetectTlsSerialRegisterTests(void); static int g_tls_cert_serial_buffer_id = 0; @@ -91,7 +92,7 @@ void DetectTlsSerialRegister(void) * * \retval 0 On success */ -static int DetectTlsSerialSetup(DetectEngineCtx *de_ctx, Signature *s, char *str) +static int DetectTlsSerialSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str) { s->init_data->list = g_tls_cert_serial_buffer_id; diff --git a/src/detect-tls-cert-subject.c b/src/detect-tls-cert-subject.c index 271e8f2230..806f080870 100644 --- a/src/detect-tls-cert-subject.c +++ b/src/detect-tls-cert-subject.c @@ -35,6 +35,7 @@ #include "detect-engine-tls.h" #include "detect-content.h" #include "detect-pcre.h" +#include "detect-tls-cert-subject.h" #include "flow.h" #include "flow-util.h" @@ -53,12 +54,12 @@ #include "util-unittest.h" #include "util-unittest-helper.h" -static int DetectTlsSubjectSetup(DetectEngineCtx *, Signature *, char *); +static int DetectTlsSubjectSetup(DetectEngineCtx *, Signature *, const char *); static void DetectTlsSubjectRegisterTests(void); static int g_tls_cert_subject_buffer_id = 0; /** - * \brief Registration function for keyword: tls_cert_issuer + * \brief Registration function for keyword: tls_cert_subject */ void DetectTlsSubjectRegister(void) { @@ -91,7 +92,7 @@ void DetectTlsSubjectRegister(void) * * \retval 0 On success */ -static int DetectTlsSubjectSetup(DetectEngineCtx *de_ctx, Signature *s, char *str) +static int DetectTlsSubjectSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str) { s->init_data->list = g_tls_cert_subject_buffer_id; s->alproto = ALPROTO_TLS; diff --git a/src/detect-tls-cert-validity.c b/src/detect-tls-cert-validity.c index 99a12b6b7e..638b5dcb59 100644 --- a/src/detect-tls-cert-validity.c +++ b/src/detect-tls-cert-validity.c @@ -62,12 +62,12 @@ static int DetectTlsValidityMatch (ThreadVars *, DetectEngineThreadCtx *, Flow * const SigMatchCtx *); static time_t DateStringToEpoch (char *); -static DetectTlsValidityData *DetectTlsValidityParse (char *); -static int DetectTlsExpiredSetup (DetectEngineCtx *, Signature *s, char *str); -static int DetectTlsValidSetup (DetectEngineCtx *, Signature *s, char *str); -static int DetectTlsNotBeforeSetup (DetectEngineCtx *, Signature *s, char *str); -static int DetectTlsNotAfterSetup (DetectEngineCtx *, Signature *s, char *str); -static int DetectTlsValiditySetup (DetectEngineCtx *, Signature *s, char *str, uint8_t); +static DetectTlsValidityData *DetectTlsValidityParse (const char *); +static int DetectTlsExpiredSetup (DetectEngineCtx *, Signature *s, const char *str); +static int DetectTlsValidSetup (DetectEngineCtx *, Signature *s, const char *str); +static int DetectTlsNotBeforeSetup (DetectEngineCtx *, Signature *s, const char *str); +static int DetectTlsNotAfterSetup (DetectEngineCtx *, Signature *s, const char *str); +static int DetectTlsValiditySetup (DetectEngineCtx *, Signature *s, const char *str, uint8_t); static void TlsNotBeforeRegisterTests(void); static void TlsNotAfterRegisterTests(void); static void TlsExpiredRegisterTests(void); @@ -232,7 +232,7 @@ static time_t DateStringToEpoch (char *string) { int r = 0; struct tm tm; - char *patterns[] = { + const char *patterns[] = { /* ISO 8601 */ "%Y-%m", "%Y-%m-%d", @@ -287,7 +287,7 @@ static time_t DateStringToEpoch (char *string) * \retval dd pointer to DetectTlsValidityData on success. * \retval NULL on failure. */ -static DetectTlsValidityData *DetectTlsValidityParse (char *rawstr) +static DetectTlsValidityData *DetectTlsValidityParse (const char *rawstr) { DetectTlsValidityData *dd = NULL; #define MAX_SUBSTRINGS 30 @@ -414,7 +414,7 @@ error: * \retval -1 on Failure. */ static int DetectTlsExpiredSetup (DetectEngineCtx *de_ctx, Signature *s, - char *rawstr) + const char *rawstr) { DetectTlsValidityData *dd = NULL; SigMatch *sm = NULL; @@ -465,7 +465,7 @@ error: * \retval -1 on Failure. */ static int DetectTlsValidSetup (DetectEngineCtx *de_ctx, Signature *s, - char *rawstr) + const char *rawstr) { DetectTlsValidityData *dd = NULL; SigMatch *sm = NULL; @@ -516,7 +516,7 @@ error: * \retval -1 on Failure. */ static int DetectTlsNotBeforeSetup (DetectEngineCtx *de_ctx, Signature *s, - char *rawstr) + const char *rawstr) { uint8_t type = DETECT_TLS_TYPE_NOTBEFORE; int r = DetectTlsValiditySetup(de_ctx, s, rawstr, type); @@ -535,7 +535,7 @@ static int DetectTlsNotBeforeSetup (DetectEngineCtx *de_ctx, Signature *s, * \retval -1 on Failure. */ static int DetectTlsNotAfterSetup (DetectEngineCtx *de_ctx, Signature *s, - char *rawstr) + const char *rawstr) { uint8_t type = DETECT_TLS_TYPE_NOTAFTER; int r = DetectTlsValiditySetup(de_ctx, s, rawstr, type); @@ -555,7 +555,7 @@ static int DetectTlsNotAfterSetup (DetectEngineCtx *de_ctx, Signature *s, * \retval -1 on Failure. */ static int DetectTlsValiditySetup (DetectEngineCtx *de_ctx, Signature *s, - char *rawstr, uint8_t type) + const char *rawstr, uint8_t type) { DetectTlsValidityData *dd = NULL; SigMatch *sm = NULL; @@ -622,7 +622,7 @@ void DetectTlsValidityFree(void *de_ptr) * \retval 1 on success. * \retval 0 on failure. */ -int ValidityTestParse01 (void) +static int ValidityTestParse01 (void) { DetectTlsValidityData *dd = NULL; dd = DetectTlsValidityParse("1430000000"); @@ -638,7 +638,7 @@ int ValidityTestParse01 (void) * \retval 1 on success. * \retval 0 on failure. */ -int ValidityTestParse02 (void) +static int ValidityTestParse02 (void) { DetectTlsValidityData *dd = NULL; dd = DetectTlsValidityParse(">1430000000"); @@ -654,7 +654,7 @@ int ValidityTestParse02 (void) * \retval 1 on success. * \retval 0 on failure. */ -int ValidityTestParse03 (void) +static int ValidityTestParse03 (void) { DetectTlsValidityData *dd = NULL; dd = DetectTlsValidityParse("<1430000000"); @@ -670,7 +670,7 @@ int ValidityTestParse03 (void) * \retval 1 on success. * \retval 0 on failure. */ -int ValidityTestParse04 (void) +static int ValidityTestParse04 (void) { DetectTlsValidityData *dd = NULL; dd = DetectTlsValidityParse("1430000000<>1470000000"); @@ -687,7 +687,7 @@ int ValidityTestParse04 (void) * \retval 1 on success. * \retval 0 on failure. */ -int ValidityTestParse05 (void) +static int ValidityTestParse05 (void) { DetectTlsValidityData *dd = NULL; dd = DetectTlsValidityParse("A"); @@ -701,7 +701,7 @@ int ValidityTestParse05 (void) * \retval 1 on success. * \retval 0 on failure. */ -int ValidityTestParse06 (void) +static int ValidityTestParse06 (void) { DetectTlsValidityData *dd = NULL; dd = DetectTlsValidityParse(">1430000000<>1470000000"); @@ -715,7 +715,7 @@ int ValidityTestParse06 (void) * \retval 1 on success. * \retval 0 on failure. */ -int ValidityTestParse07 (void) +static int ValidityTestParse07 (void) { DetectTlsValidityData *dd = NULL; dd = DetectTlsValidityParse("1430000000<>"); @@ -729,7 +729,7 @@ int ValidityTestParse07 (void) * \retval 1 on success. * \retval 0 on failure. */ -int ValidityTestParse08 (void) +static int ValidityTestParse08 (void) { DetectTlsValidityData *dd = NULL; dd = DetectTlsValidityParse("<>1430000000"); @@ -743,7 +743,7 @@ int ValidityTestParse08 (void) * \retval 1 on success. * \retval 0 on failure. */ -int ValidityTestParse09 (void) +static int ValidityTestParse09 (void) { DetectTlsValidityData *dd = NULL; dd = DetectTlsValidityParse(""); @@ -757,7 +757,7 @@ int ValidityTestParse09 (void) * \retval 1 on success. * \retval 0 on failure. */ -int ValidityTestParse10 (void) +static int ValidityTestParse10 (void) { DetectTlsValidityData *dd = NULL; dd = DetectTlsValidityParse(" "); @@ -771,7 +771,7 @@ int ValidityTestParse10 (void) * \retval 1 on success. * \retval 0 on failure. */ -int ValidityTestParse11 (void) +static int ValidityTestParse11 (void) { DetectTlsValidityData *dd = NULL; dd = DetectTlsValidityParse("1490000000<>1430000000"); @@ -785,7 +785,7 @@ int ValidityTestParse11 (void) * \retval 1 on success. * \retval 0 on failure. */ -int ValidityTestParse12 (void) +static int ValidityTestParse12 (void) { DetectTlsValidityData *dd = NULL; dd = DetectTlsValidityParse("1430000000 <> 1490000000"); @@ -802,7 +802,7 @@ int ValidityTestParse12 (void) * \retval 1 on success. * \retval 0 on failure. */ -int ValidityTestParse13 (void) +static int ValidityTestParse13 (void) { DetectTlsValidityData *dd = NULL; dd = DetectTlsValidityParse("> 1430000000 "); @@ -818,7 +818,7 @@ int ValidityTestParse13 (void) * \retval 1 on success. * \retval 0 on failure. */ -int ValidityTestParse14 (void) +static int ValidityTestParse14 (void) { DetectTlsValidityData *dd = NULL; dd = DetectTlsValidityParse("< 1490000000 "); @@ -834,7 +834,7 @@ int ValidityTestParse14 (void) * \retval 1 on success. * \retval 0 on failure. */ -int ValidityTestParse15 (void) +static int ValidityTestParse15 (void) { DetectTlsValidityData *dd = NULL; dd = DetectTlsValidityParse(" 1490000000 "); @@ -850,7 +850,7 @@ int ValidityTestParse15 (void) * \retval 1 on success. * \retval 0 on failure. */ -int ValidityTestParse16 (void) +static int ValidityTestParse16 (void) { DetectTlsValidityData *dd = NULL; dd = DetectTlsValidityParse("2015-10"); @@ -866,7 +866,7 @@ int ValidityTestParse16 (void) * \retval 1 on success. * \retval 0 on failure. */ -int ValidityTestParse17 (void) +static int ValidityTestParse17 (void) { DetectTlsValidityData *dd = NULL; dd = DetectTlsValidityParse(">2015-10-22"); @@ -882,7 +882,7 @@ int ValidityTestParse17 (void) * \retval 1 on success. * \retval 0 on failure. */ -int ValidityTestParse18 (void) +static int ValidityTestParse18 (void) { DetectTlsValidityData *dd = NULL; dd = DetectTlsValidityParse("<2015-10-22 23"); @@ -898,7 +898,7 @@ int ValidityTestParse18 (void) * \retval 1 on success. * \retval 0 on failure. */ -int ValidityTestParse19 (void) +static int ValidityTestParse19 (void) { DetectTlsValidityData *dd = NULL; dd = DetectTlsValidityParse("2015-10-22 23:59"); @@ -914,7 +914,7 @@ int ValidityTestParse19 (void) * \retval 1 on success. * \retval 0 on failure. */ -int ValidityTestParse20 (void) +static int ValidityTestParse20 (void) { DetectTlsValidityData *dd = NULL; dd = DetectTlsValidityParse("2015-10-22 23:59:59"); @@ -930,7 +930,7 @@ int ValidityTestParse20 (void) * \retval 1 on success. * \retval 0 on failure. */ -int ValidityTestParse21 (void) +static int ValidityTestParse21 (void) { DetectTlsValidityData *dd = NULL; dd = DetectTlsValidityParse("2015-10-22T23"); @@ -946,7 +946,7 @@ int ValidityTestParse21 (void) * \retval 1 on success. * \retval 0 on failure. */ -int ValidityTestParse22 (void) +static int ValidityTestParse22 (void) { DetectTlsValidityData *dd = NULL; dd = DetectTlsValidityParse("2015-10-22T23:59"); @@ -962,7 +962,7 @@ int ValidityTestParse22 (void) * \retval 1 on success. * \retval 0 on failure. */ -int ValidityTestParse23 (void) +static int ValidityTestParse23 (void) { DetectTlsValidityData *dd = NULL; dd = DetectTlsValidityParse("2015-10-22T23:59:59"); @@ -978,7 +978,7 @@ int ValidityTestParse23 (void) * \retval 1 on success. * \retval 0 on failure. */ -int ValidityTestDetect01(void) +static int ValidityTestDetect01(void) { /* client hello */ uint8_t client_hello[] = { @@ -1296,7 +1296,7 @@ int ValidityTestDetect01(void) * \retval 1 on success. * \retval 0 on failure. */ -int ExpiredTestDetect01(void) +static int ExpiredTestDetect01(void) { /* client hello */ uint8_t client_hello[] = { @@ -1618,7 +1618,7 @@ int ExpiredTestDetect01(void) * \retval 1 on success. * \retval 0 on failure. */ -int ValidTestDetect01(void) +static int ValidTestDetect01(void) { /* client hello */ uint8_t client_hello[] = { diff --git a/src/detect-tls-sni.c b/src/detect-tls-sni.c index 5b5350c643..9b490092ad 100644 --- a/src/detect-tls-sni.c +++ b/src/detect-tls-sni.c @@ -49,11 +49,12 @@ #include "app-layer.h" #include "app-layer-ssl.h" #include "detect-engine-tls.h" +#include "detect-tls-sni.h" #include "util-unittest.h" #include "util-unittest-helper.h" -static int DetectTlsSniSetup(DetectEngineCtx *, Signature *, char *); +static int DetectTlsSniSetup(DetectEngineCtx *, Signature *, const char *); static void DetectTlsSniRegisterTests(void); static int g_tls_sni_buffer_id = 0; @@ -92,7 +93,7 @@ void DetectTlsSniRegister(void) * * \retval 0 On success */ -static int DetectTlsSniSetup(DetectEngineCtx *de_ctx, Signature *s, char *str) +static int DetectTlsSniSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str) { s->init_data->list = g_tls_sni_buffer_id; s->alproto = ALPROTO_TLS; diff --git a/src/detect-tls-version.c b/src/detect-tls-version.c index 8895e4483e..8925308710 100644 --- a/src/detect-tls-version.c +++ b/src/detect-tls-version.c @@ -62,7 +62,7 @@ static pcre_extra *parse_regex_study; static int DetectTlsVersionMatch (ThreadVars *, DetectEngineThreadCtx *, Flow *, uint8_t, void *, void *, const Signature *, const SigMatchCtx *); -static int DetectTlsVersionSetup (DetectEngineCtx *, Signature *, char *); +static int DetectTlsVersionSetup (DetectEngineCtx *, Signature *, const char *); static void DetectTlsVersionRegisterTests(void); static void DetectTlsVersionFree(void *); static int g_tls_generic_list_id = 0; @@ -133,7 +133,7 @@ static int DetectTlsVersionMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, * \retval id_d pointer to DetectTlsVersionData on success * \retval NULL on failure */ -static DetectTlsVersionData *DetectTlsVersionParse (char *str) +static DetectTlsVersionData *DetectTlsVersionParse (const char *str) { uint16_t temp; DetectTlsVersionData *tls = NULL; @@ -216,7 +216,7 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -static int DetectTlsVersionSetup (DetectEngineCtx *de_ctx, Signature *s, char *str) +static int DetectTlsVersionSetup (DetectEngineCtx *de_ctx, Signature *s, const char *str) { DetectTlsVersionData *tls = NULL; SigMatch *sm = NULL; diff --git a/src/detect-tls.c b/src/detect-tls.c index 7e2b2a46bf..2b60e43117 100644 --- a/src/detect-tls.c +++ b/src/detect-tls.c @@ -77,24 +77,24 @@ static pcre_extra *fingerprint_parse_regex_study; static int DetectTlsSubjectMatch (ThreadVars *, DetectEngineThreadCtx *, Flow *, uint8_t, void *, void *, const Signature *, const SigMatchCtx *); -static int DetectTlsSubjectSetup (DetectEngineCtx *, Signature *, char *); +static int DetectTlsSubjectSetup (DetectEngineCtx *, Signature *, const char *); static void DetectTlsSubjectRegisterTests(void); static void DetectTlsSubjectFree(void *); static int DetectTlsIssuerDNMatch (ThreadVars *, DetectEngineThreadCtx *, Flow *, uint8_t, void *, void *, const Signature *, const SigMatchCtx *); -static int DetectTlsIssuerDNSetup (DetectEngineCtx *, Signature *, char *); +static int DetectTlsIssuerDNSetup (DetectEngineCtx *, Signature *, const char *); static void DetectTlsIssuerDNRegisterTests(void); static void DetectTlsIssuerDNFree(void *); static int DetectTlsFingerprintMatch (ThreadVars *, DetectEngineThreadCtx *, Flow *, uint8_t, void *, void *, const Signature *, const SigMatchCtx *); -static int DetectTlsFingerprintSetup (DetectEngineCtx *, Signature *, char *); +static int DetectTlsFingerprintSetup (DetectEngineCtx *, Signature *, const char *); static void DetectTlsFingerprintFree(void *); -static int DetectTlsStoreSetup (DetectEngineCtx *, Signature *, char *); +static int DetectTlsStoreSetup (DetectEngineCtx *, Signature *, const char *); static int DetectTlsStorePostMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *, const Signature *s, const SigMatchCtx *unused); @@ -311,7 +311,7 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -static int DetectTlsSubjectSetup (DetectEngineCtx *de_ctx, Signature *s, char *str) +static int DetectTlsSubjectSetup (DetectEngineCtx *de_ctx, Signature *s, const char *str) { DetectTlsData *tls = NULL; SigMatch *sm = NULL; @@ -511,7 +511,7 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -static int DetectTlsIssuerDNSetup (DetectEngineCtx *de_ctx, Signature *s, char *str) +static int DetectTlsIssuerDNSetup (DetectEngineCtx *de_ctx, Signature *s, const char *str) { DetectTlsData *tls = NULL; SigMatch *sm = NULL; @@ -701,7 +701,7 @@ static int DetectTlsFingerprintMatch (ThreadVars *t, DetectEngineThreadCtx *det_ * \retval 0 on Success * \retval -1 on Failure */ -static int DetectTlsFingerprintSetup (DetectEngineCtx *de_ctx, Signature *s, char *str) +static int DetectTlsFingerprintSetup (DetectEngineCtx *de_ctx, Signature *s, const char *str) { DetectTlsData *tls = NULL; SigMatch *sm = NULL; @@ -758,7 +758,7 @@ static void DetectTlsFingerprintFree(void *ptr) * \retval 0 on Success * \retval -1 on Failure */ -static int DetectTlsStoreSetup (DetectEngineCtx *de_ctx, Signature *s, char *str) +static int DetectTlsStoreSetup (DetectEngineCtx *de_ctx, Signature *s, const char *str) { SigMatch *sm = NULL; diff --git a/src/detect-tos.c b/src/detect-tos.c index 699d2474b1..1675374355 100644 --- a/src/detect-tos.c +++ b/src/detect-tos.c @@ -48,7 +48,7 @@ static pcre *parse_regex; static pcre_extra *parse_regex_study; -static int DetectTosSetup(DetectEngineCtx *, Signature *, char *); +static int DetectTosSetup(DetectEngineCtx *, Signature *, const char *); static int DetectTosMatch(ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); static void DetectTosRegisterTests(void); @@ -67,6 +67,8 @@ void DetectTosRegister(void) sigmatch_table[DETECT_TOS].Setup = DetectTosSetup; sigmatch_table[DETECT_TOS].Free = DetectTosFree; sigmatch_table[DETECT_TOS].RegisterTests = DetectTosRegisterTests; + sigmatch_table[DETECT_TOS].flags = + (SIGMATCH_QUOTES_OPTIONAL|SIGMATCH_HANDLE_NEGATION); DetectSetupParseRegexes(PARSE_REGEX, &parse_regex, &parse_regex_study); } @@ -100,7 +102,7 @@ static int DetectTosMatch(ThreadVars *tv, DetectEngineThreadCtx *det_ctx, Packet return (tosd->negated ^ result); } -DetectTosData *DetectTosParse(char *arg) +static DetectTosData *DetectTosParse(const char *arg, bool negate) { DetectTosData *tosd = NULL; #define MAX_SUBSTRINGS 30 @@ -126,15 +128,6 @@ DetectTosData *DetectTosParse(char *arg) } int64_t tos = 0; - int negated = 0; - - if (*str_ptr == '!') { - str_ptr++; - negated = 1; - } - - while (isspace((unsigned char)*str_ptr)) - str_ptr++; if (*str_ptr == 'x' || *str_ptr == 'X') { int r = ByteExtractStringSigned(&tos, 16, 0, str_ptr + 1); @@ -158,7 +151,7 @@ DetectTosData *DetectTosParse(char *arg) if (unlikely(tosd == NULL)) goto error; tosd->tos = (uint8_t)tos; - tosd->negated = negated; + tosd->negated = negate; return tosd; @@ -177,12 +170,12 @@ error: * \retval 0 on Success. * \retval -1 on Failure. */ -int DetectTosSetup(DetectEngineCtx *de_ctx, Signature *s, char *arg) +int DetectTosSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg) { DetectTosData *tosd; SigMatch *sm; - tosd = DetectTosParse(arg); + tosd = DetectTosParse(arg, s->init_data->negated); if (tosd == NULL) goto error; @@ -218,10 +211,10 @@ void DetectTosFree(void *tosd) #ifdef UNITTESTS -int DetectTosTest01(void) +static int DetectTosTest01(void) { DetectTosData *tosd = NULL; - tosd = DetectTosParse("12"); + tosd = DetectTosParse("12", false); if (tosd != NULL && tosd->tos == 12 && !tosd->negated) { DetectTosFree(tosd); return 1; @@ -230,10 +223,10 @@ int DetectTosTest01(void) return 0; } -int DetectTosTest02(void) +static int DetectTosTest02(void) { DetectTosData *tosd = NULL; - tosd = DetectTosParse("123"); + tosd = DetectTosParse("123", false); if (tosd != NULL && tosd->tos == 123 && !tosd->negated) { DetectTosFree(tosd); return 1; @@ -242,22 +235,10 @@ int DetectTosTest02(void) return 0; } -int DetectTosTest03(void) -{ - DetectTosData *tosd = NULL; - tosd = DetectTosParse(" 12 "); - if (tosd != NULL && tosd->tos == 12 && !tosd->negated) { - DetectTosFree(tosd); - return 1; - } - - return 0; -} - -int DetectTosTest04(void) +static int DetectTosTest04(void) { DetectTosData *tosd = NULL; - tosd = DetectTosParse("256"); + tosd = DetectTosParse("256", false); if (tosd != NULL) { DetectTosFree(tosd); return 0; @@ -266,10 +247,10 @@ int DetectTosTest04(void) return 1; } -int DetectTosTest05(void) +static int DetectTosTest05(void) { DetectTosData *tosd = NULL; - tosd = DetectTosParse("boom"); + tosd = DetectTosParse("boom", false); if (tosd != NULL) { DetectTosFree(tosd); return 0; @@ -278,10 +259,10 @@ int DetectTosTest05(void) return 1; } -int DetectTosTest06(void) +static int DetectTosTest06(void) { DetectTosData *tosd = NULL; - tosd = DetectTosParse("x12"); + tosd = DetectTosParse("x12", false); if (tosd != NULL && tosd->tos == 0x12 && !tosd->negated) { DetectTosFree(tosd); return 1; @@ -290,10 +271,10 @@ int DetectTosTest06(void) return 0; } -int DetectTosTest07(void) +static int DetectTosTest07(void) { DetectTosData *tosd = NULL; - tosd = DetectTosParse("X12"); + tosd = DetectTosParse("X12", false); if (tosd != NULL && tosd->tos == 0x12 && !tosd->negated) { DetectTosFree(tosd); return 1; @@ -302,10 +283,10 @@ int DetectTosTest07(void) return 0; } -int DetectTosTest08(void) +static int DetectTosTest08(void) { DetectTosData *tosd = NULL; - tosd = DetectTosParse("x121"); + tosd = DetectTosParse("x121", false); if (tosd != NULL) { DetectTosFree(tosd); return 0; @@ -314,10 +295,10 @@ int DetectTosTest08(void) return 1; } -int DetectTosTest09(void) +static int DetectTosTest09(void) { DetectTosData *tosd = NULL; - tosd = DetectTosParse("!12"); + tosd = DetectTosParse("12", true); if (tosd != NULL && tosd->tos == 12 && tosd->negated) { DetectTosFree(tosd); return 1; @@ -326,10 +307,10 @@ int DetectTosTest09(void) return 0; } -int DetectTosTest10(void) +static int DetectTosTest10(void) { DetectTosData *tosd = NULL; - tosd = DetectTosParse("!x12"); + tosd = DetectTosParse("x12", true); if (tosd != NULL && tosd->tos == 0x12 && tosd->negated) { DetectTosFree(tosd); return 1; @@ -338,19 +319,7 @@ int DetectTosTest10(void) return 0; } -int DetectTosTest11(void) -{ - DetectTosData *tosd = NULL; - tosd = DetectTosParse(" ! 12"); - if (tosd != NULL && tosd->tos == 12 && tosd->negated) { - DetectTosFree(tosd); - return 1; - } - - return 0; -} - -int DetectTosTest12(void) +static int DetectTosTest12(void) { int result = 0; uint8_t *buf = (uint8_t *)"Hi all!"; @@ -364,11 +333,11 @@ int DetectTosTest12(void) IPV4_SET_RAW_IPTOS(p->ip4h, 10); - char *sigs[4]; - sigs[0]= "alert ip any any -> any any (msg:\"Testing id 1\"; tos:10; sid:1;)"; - sigs[1]= "alert ip any any -> any any (msg:\"Testing id 2\"; tos:!10; sid:2;)"; - sigs[2]= "alert ip any any -> any any (msg:\"Testing id 3\"; tos:20; sid:3;)"; - sigs[3]= "alert ip any any -> any any (msg:\"Testing id 3\"; tos:!20; sid:4;)"; + const char *sigs[4]; + sigs[0]= "alert ip any any -> any any (msg:\"Testing id 1\"; tos: 10 ; sid:1;)"; + sigs[1]= "alert ip any any -> any any (msg:\"Testing id 2\"; tos: ! 10; sid:2;)"; + sigs[2]= "alert ip any any -> any any (msg:\"Testing id 3\"; tos:20 ; sid:3;)"; + sigs[3]= "alert ip any any -> any any (msg:\"Testing id 3\"; tos:! 20; sid:4;)"; uint32_t sid[4] = {1, 2, 3, 4}; @@ -392,7 +361,6 @@ void DetectTosRegisterTests(void) #ifdef UNITTESTS UtRegisterTest("DetectTosTest01", DetectTosTest01); UtRegisterTest("DetectTosTest02", DetectTosTest02); - UtRegisterTest("DetectTosTest03", DetectTosTest03); UtRegisterTest("DetectTosTest04", DetectTosTest04); UtRegisterTest("DetectTosTest05", DetectTosTest05); UtRegisterTest("DetectTosTest06", DetectTosTest06); @@ -400,9 +368,7 @@ void DetectTosRegisterTests(void) UtRegisterTest("DetectTosTest08", DetectTosTest08); UtRegisterTest("DetectTosTest09", DetectTosTest09); UtRegisterTest("DetectTosTest10", DetectTosTest10); - UtRegisterTest("DetectTosTest11", DetectTosTest11); UtRegisterTest("DetectTosTest12", DetectTosTest12); #endif - return; } diff --git a/src/detect-ttl.c b/src/detect-ttl.c index b70312e47e..488e14c415 100644 --- a/src/detect-ttl.c +++ b/src/detect-ttl.c @@ -45,7 +45,7 @@ static pcre_extra *parse_regex_study; /*prototypes*/ static int DetectTtlMatch (ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectTtlSetup (DetectEngineCtx *, Signature *, char *); +static int DetectTtlSetup (DetectEngineCtx *, Signature *, const char *); void DetectTtlFree (void *); void DetectTtlRegisterTests (void); @@ -130,9 +130,8 @@ static int DetectTtlMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet * \retval NULL on failure */ -DetectTtlData *DetectTtlParse (char *ttlstr) +static DetectTtlData *DetectTtlParse (const char *ttlstr) { - DetectTtlData *ttld = NULL; char *arg1 = NULL; char *arg2 = NULL; @@ -273,9 +272,8 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -static int DetectTtlSetup (DetectEngineCtx *de_ctx, Signature *s, char *ttlstr) +static int DetectTtlSetup (DetectEngineCtx *de_ctx, Signature *s, const char *ttlstr) { - DetectTtlData *ttld = NULL; SigMatch *sm = NULL; @@ -392,7 +390,7 @@ static _Bool PrefilterTtlIsPrefilterable(const Signature *s) * */ -static int DetectTtlInitTest(DetectEngineCtx **de_ctx, Signature **sig, DetectTtlData **ttld, char *str) +static int DetectTtlInitTest(DetectEngineCtx **de_ctx, Signature **sig, DetectTtlData **ttld, const char *str) { char fullstr[1024]; int result = 0; diff --git a/src/detect-uricontent.c b/src/detect-uricontent.c index 6da1b6a565..0aa10c7941 100644 --- a/src/detect-uricontent.c +++ b/src/detect-uricontent.c @@ -57,7 +57,7 @@ #include "conf.h" /* prototypes */ -static int DetectUricontentSetup (DetectEngineCtx *, Signature *, char *); +static int DetectUricontentSetup (DetectEngineCtx *, Signature *, const char *); static void DetectUricontentRegisterTests(void); static void DetectUricontentFree(void *); @@ -152,11 +152,11 @@ void DetectUricontentPrint(DetectContentData *cd) * * \retval 0 on success, -1 on failure */ -int DetectUricontentSetup(DetectEngineCtx *de_ctx, Signature *s, char *contentstr) +int DetectUricontentSetup(DetectEngineCtx *de_ctx, Signature *s, const char *contentstr) { SCEnter(); - char *legacy = NULL; + const char *legacy = NULL; if (ConfGet("legacy.uricontent", &legacy) == 1) { if (strcasecmp("disabled", legacy) == 0) { SCLogError(SC_ERR_INVALID_SIGNATURE, "uriconent deprecated. To " @@ -483,7 +483,7 @@ end: /** * \test Checks if a uricontent is registered in a Signature */ -int DetectUriSigTest01(void) +static int DetectUriSigTest01(void) { ThreadVars th_v; Signature *s = NULL; @@ -1220,7 +1220,7 @@ static int DetectUriSigTest07(void) /** * \test Test content for dce sig. */ -int DetectUriSigTest08(void) +static int DetectUriSigTest08(void) { DetectEngineCtx *de_ctx = NULL; int result = 1; @@ -1249,7 +1249,7 @@ int DetectUriSigTest08(void) /** * \test Test content for dce sig. */ -int DetectUriSigTest09(void) +static int DetectUriSigTest09(void) { DetectEngineCtx *de_ctx = NULL; int result = 1; @@ -1278,7 +1278,7 @@ int DetectUriSigTest09(void) /** * \test Test content for dce sig. */ -int DetectUriSigTest10(void) +static int DetectUriSigTest10(void) { DetectEngineCtx *de_ctx = NULL; int result = 1; @@ -1307,7 +1307,7 @@ int DetectUriSigTest10(void) /** * \test Test content for dce sig. */ -int DetectUriSigTest11(void) +static int DetectUriSigTest11(void) { DetectEngineCtx *de_ctx = NULL; int result = 1; @@ -1336,7 +1336,7 @@ int DetectUriSigTest11(void) /** * \test Parsing test */ -int DetectUriSigTest12(void) +static int DetectUriSigTest12(void) { DetectEngineCtx *de_ctx = NULL; DetectContentData *ud = 0; @@ -1376,7 +1376,7 @@ end: /** * \test Parsing test */ -int DetectUriContentParseTest13(void) +static int DetectUriContentParseTest13(void) { DetectEngineCtx *de_ctx = NULL; int result = 1; @@ -1405,7 +1405,7 @@ int DetectUriContentParseTest13(void) /** * \test Parsing test */ -int DetectUriContentParseTest14(void) +static int DetectUriContentParseTest14(void) { DetectEngineCtx *de_ctx = NULL; int result = 1; @@ -1434,7 +1434,7 @@ int DetectUriContentParseTest14(void) /** * \test Parsing test */ -int DetectUriContentParseTest15(void) +static int DetectUriContentParseTest15(void) { DetectEngineCtx *de_ctx = NULL; int result = 1; @@ -1463,7 +1463,7 @@ int DetectUriContentParseTest15(void) /** * \test Parsing test */ -int DetectUriContentParseTest16(void) +static int DetectUriContentParseTest16(void) { DetectEngineCtx *de_ctx = NULL; int result = 1; @@ -1492,7 +1492,7 @@ int DetectUriContentParseTest16(void) /** * \test Parsing test */ -int DetectUriContentParseTest17(void) +static int DetectUriContentParseTest17(void) { DetectEngineCtx *de_ctx = NULL; int result = 1; @@ -1521,7 +1521,7 @@ int DetectUriContentParseTest17(void) /** * \test Parsing test */ -int DetectUriContentParseTest18(void) +static int DetectUriContentParseTest18(void) { DetectEngineCtx *de_ctx = NULL; int result = 1; @@ -1550,7 +1550,7 @@ int DetectUriContentParseTest18(void) /** * \test Parsing test */ -int DetectUriContentParseTest19(void) +static int DetectUriContentParseTest19(void) { DetectEngineCtx *de_ctx = NULL; int result = 1; @@ -1579,7 +1579,7 @@ int DetectUriContentParseTest19(void) /** * \test Parsing test */ -int DetectUriContentParseTest20(void) +static int DetectUriContentParseTest20(void) { DetectEngineCtx *de_ctx = NULL; int result = 1; @@ -1608,7 +1608,7 @@ int DetectUriContentParseTest20(void) /** * \test Parsing test */ -int DetectUriContentParseTest21(void) +static int DetectUriContentParseTest21(void) { DetectEngineCtx *de_ctx = NULL; int result = 1; @@ -1637,7 +1637,7 @@ int DetectUriContentParseTest21(void) /** * \test Parsing test */ -int DetectUriContentParseTest22(void) +static int DetectUriContentParseTest22(void) { DetectEngineCtx *de_ctx = NULL; int result = 1; @@ -1666,7 +1666,7 @@ int DetectUriContentParseTest22(void) /** * \test Parsing test */ -int DetectUriContentParseTest23(void) +static int DetectUriContentParseTest23(void) { DetectEngineCtx *de_ctx = NULL; int result = 1; @@ -1695,7 +1695,7 @@ int DetectUriContentParseTest23(void) /** * \test Parsing test */ -int DetectUriContentParseTest24(void) +static int DetectUriContentParseTest24(void) { DetectEngineCtx *de_ctx = NULL; int result = 1; diff --git a/src/detect-urilen.c b/src/detect-urilen.c index 65f4b0b24b..7959b9c644 100644 --- a/src/detect-urilen.c +++ b/src/detect-urilen.c @@ -50,7 +50,7 @@ static pcre *parse_regex; static pcre_extra *parse_regex_study; /*prototypes*/ -static int DetectUrilenSetup (DetectEngineCtx *, Signature *, char *); +static int DetectUrilenSetup (DetectEngineCtx *, Signature *, const char *); void DetectUrilenFree (void *); void DetectUrilenRegisterTests (void); @@ -86,7 +86,7 @@ void DetectUrilenRegister(void) * \retval NULL on failure */ -DetectUrilenData *DetectUrilenParse (char *urilenstr) +static DetectUrilenData *DetectUrilenParse (const char *urilenstr) { DetectUrilenData *urilend = NULL; @@ -241,7 +241,7 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -static int DetectUrilenSetup (DetectEngineCtx *de_ctx, Signature *s, char *urilenstr) +static int DetectUrilenSetup (DetectEngineCtx *de_ctx, Signature *s, const char *urilenstr) { SCEnter(); DetectUrilenData *urilend = NULL; @@ -474,7 +474,7 @@ static int DetectUrilenParseTest10(void) */ static int DetectUrilenInitTest(DetectEngineCtx **de_ctx, Signature **sig, - DetectUrilenData **urilend, char *str) + DetectUrilenData **urilend, const char *str) { char fullstr[1024]; int result = 0; diff --git a/src/detect-window.c b/src/detect-window.c index 4c44682544..bd1b2f28f6 100644 --- a/src/detect-window.c +++ b/src/detect-window.c @@ -49,7 +49,7 @@ static pcre_extra *parse_regex_study; static int DetectWindowMatch(ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectWindowSetup(DetectEngineCtx *, Signature *, char *); +static int DetectWindowSetup(DetectEngineCtx *, Signature *, const char *); void DetectWindowRegisterTests(void); void DetectWindowFree(void *); @@ -104,7 +104,7 @@ static int DetectWindowMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx, Pack * \retval wd pointer to DetectWindowData on success * \retval NULL on failure */ -static DetectWindowData *DetectWindowParse(char *windowstr) +static DetectWindowData *DetectWindowParse(const char *windowstr) { DetectWindowData *wd = NULL; #define MAX_SUBSTRINGS 30 @@ -171,7 +171,7 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -static int DetectWindowSetup (DetectEngineCtx *de_ctx, Signature *s, char *windowstr) +static int DetectWindowSetup (DetectEngineCtx *de_ctx, Signature *s, const char *windowstr) { DetectWindowData *wd = NULL; SigMatch *sm = NULL; @@ -217,7 +217,7 @@ void DetectWindowFree(void *ptr) * \test DetectWindowTestParse01 is a test to make sure that we set the size correctly * when given valid window opt */ -int DetectWindowTestParse01 (void) +static int DetectWindowTestParse01 (void) { int result = 0; DetectWindowData *wd = NULL; @@ -233,7 +233,7 @@ int DetectWindowTestParse01 (void) /** * \test DetectWindowTestParse02 is a test for setting the window opt negated */ -int DetectWindowTestParse02 (void) +static int DetectWindowTestParse02 (void) { int result = 0; DetectWindowData *wd = NULL; @@ -253,7 +253,7 @@ int DetectWindowTestParse02 (void) /** * \test DetectWindowTestParse03 is a test to check for an empty value */ -int DetectWindowTestParse03 (void) +static int DetectWindowTestParse03 (void) { int result = 0; DetectWindowData *wd = NULL; @@ -271,7 +271,7 @@ int DetectWindowTestParse03 (void) /** * \test DetectWindowTestParse03 is a test to check for a big value */ -int DetectWindowTestParse04 (void) +static int DetectWindowTestParse04 (void) { int result = 0; DetectWindowData *wd = NULL; @@ -288,7 +288,7 @@ int DetectWindowTestParse04 (void) /** * \test DetectWindowTestPacket01 is a test to check window with constructed packets */ -int DetectWindowTestPacket01 (void) +static int DetectWindowTestPacket01 (void) { int result = 0; uint8_t *buf = (uint8_t *)"Hi all!"; @@ -307,7 +307,7 @@ int DetectWindowTestPacket01 (void) /* TCP window = 41 */ p[1]->tcph->th_win = htons(41); - char *sigs[2]; + const char *sigs[2]; sigs[0]= "alert tcp any any -> any any (msg:\"Testing window 1\"; window:40; sid:1;)"; sigs[1]= "alert tcp any any -> any any (msg:\"Testing window 2\"; window:41; sid:2;)"; diff --git a/src/detect-within.c b/src/detect-within.c index 772fb039d7..24db6250be 100644 --- a/src/detect-within.c +++ b/src/detect-within.c @@ -41,9 +41,10 @@ #include "util-debug.h" #include "detect-pcre.h" +#include "detect-within.h" #include "util-unittest.h" -static int DetectWithinSetup(DetectEngineCtx *, Signature *, char *); +static int DetectWithinSetup(DetectEngineCtx *, Signature *, const char *); void DetectWithinRegisterTests(void); void DetectWithinRegister(void) @@ -64,24 +65,12 @@ void DetectWithinRegister(void) * \retval 0 ok * \retval -1 error, sig needs to be invalidated */ -static int DetectWithinSetup(DetectEngineCtx *de_ctx, Signature *s, char *withinstr) +static int DetectWithinSetup(DetectEngineCtx *de_ctx, Signature *s, const char *withinstr) { - char *str = withinstr; - char dubbed = 0; + const char *str = withinstr; SigMatch *pm = NULL; int ret = -1; - /* Strip leading and trailing "s. */ - if (withinstr[0] == '\"') { - str = SCStrdup(withinstr+1); - if (unlikely(str == NULL)) - goto end; - if (strlen(str) && str[strlen(str) - 1] == '\"') { - str[strlen(str) - 1] = '\0'; - } - dubbed = 1; - } - /* retrieve the sm to apply the within against */ pm = DetectGetLastSMFromLists(s, DETECT_CONTENT, -1); if (pm == NULL) { @@ -160,8 +149,6 @@ static int DetectWithinSetup(DetectEngineCtx *de_ctx, Signature *s, char *within ret = 0; end: - if (dubbed) - SCFree(str); return ret; } @@ -173,7 +160,7 @@ static int DetectWithinSetup(DetectEngineCtx *de_ctx, Signature *s, char *within * \test DetectWithinTestPacket01 is a test to check matches of * within, if the previous keyword is pcre (bug 145) */ -int DetectWithinTestPacket01 (void) +static int DetectWithinTestPacket01 (void) { int result = 0; uint8_t *buf = (uint8_t *)"GET /AllWorkAndNoPlayMakesWillADullBoy HTTP/1.0" @@ -201,7 +188,7 @@ end: } -int DetectWithinTestPacket02 (void) +static int DetectWithinTestPacket02 (void) { int result = 0; uint8_t *buf = (uint8_t *)"Zero Five Ten Fourteen"; diff --git a/src/detect-xbits.c b/src/detect-xbits.c index a6264ea267..c521076e30 100644 --- a/src/detect-xbits.c +++ b/src/detect-xbits.c @@ -58,7 +58,7 @@ static pcre *parse_regex; static pcre_extra *parse_regex_study; static int DetectXbitMatch (ThreadVars *, DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); -static int DetectXbitSetup (DetectEngineCtx *, Signature *, char *); +static int DetectXbitSetup (DetectEngineCtx *, Signature *, const char *); void DetectXbitFree (void *); void XBitsRegisterTests(void); @@ -317,7 +317,7 @@ static int DetectXbitParse(DetectEngineCtx *de_ctx, return 0; } -int DetectXbitSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr) +int DetectXbitSetup (DetectEngineCtx *de_ctx, Signature *s, const char *rawstr) { SigMatch *sm = NULL; DetectXbitsData *cd = NULL; diff --git a/src/detect.c b/src/detect.c index 947d88a331..458aef4c9d 100644 --- a/src/detect.c +++ b/src/detect.c @@ -245,9 +245,9 @@ static void PacketCreateMask(Packet *, SignatureMask *, AppProto, bool, int); * \param sig_file The name of the file * \retval str Pointer to the string path + sig_file */ -char *DetectLoadCompleteSigPath(const DetectEngineCtx *de_ctx, char *sig_file) +char *DetectLoadCompleteSigPath(const DetectEngineCtx *de_ctx, const char *sig_file) { - char *defaultpath = NULL; + const char *defaultpath = NULL; char *path = NULL; char varname[128]; @@ -1617,15 +1617,6 @@ Signature *SigFindSignatureBySidGid(DetectEngineCtx *de_ctx, uint32_t sid, uint3 return NULL; } - -int SignatureIsAppLayer(DetectEngineCtx *de_ctx, const Signature *s) -{ - if (s->alproto != 0) - return 1; - - return 0; -} - /** * \brief Check if a signature contains the filestore keyword. * @@ -2308,14 +2299,14 @@ static void SigParseApplyDsizeToContent(Signature *s) } /** \brief Pure-PCRE or bytetest rule */ -int RuleInspectsPayloadHasNoMpm(const Signature *s) +static int RuleInspectsPayloadHasNoMpm(const Signature *s) { if (s->init_data->mpm_sm == NULL && s->init_data->smlists[DETECT_SM_LIST_PMATCH] != NULL) return 1; return 0; } -int RuleGetMpmPatternSize(const Signature *s) +static int RuleGetMpmPatternSize(const Signature *s) { if (s->init_data->mpm_sm == NULL) return -1; @@ -2328,7 +2319,7 @@ int RuleGetMpmPatternSize(const Signature *s) return (int)cd->content_len; } -int RuleMpmIsNegated(const Signature *s) +static int RuleMpmIsNegated(const Signature *s) { if (s->init_data->mpm_sm == NULL) return 0; @@ -2342,7 +2333,7 @@ int RuleMpmIsNegated(const Signature *s) } #ifdef HAVE_LIBJANSSON -json_t *RulesGroupPrintSghStats(const SigGroupHead *sgh, +static json_t *RulesGroupPrintSghStats(const SigGroupHead *sgh, const int add_rules, const int add_mpm_stats) { uint32_t mpm_cnt = 0; @@ -2576,7 +2567,7 @@ json_t *RulesGroupPrintSghStats(const SigGroupHead *sgh, } #endif /* HAVE_LIBJANSSON */ -void RulesDumpGrouping(const DetectEngineCtx *de_ctx, +static void RulesDumpGrouping(const DetectEngineCtx *de_ctx, const int add_rules, const int add_mpm_stats) { #ifdef HAVE_LIBJANSSON @@ -2658,7 +2649,7 @@ void RulesDumpGrouping(const DetectEngineCtx *de_ctx, return; } -int RulesGroupByProto(DetectEngineCtx *de_ctx) +static int RulesGroupByProto(DetectEngineCtx *de_ctx) { Signature *s = de_ctx->sig_list; @@ -3481,29 +3472,6 @@ void DbgPrintSigs2(DetectEngineCtx *de_ctx, SigGroupHead *sgh) printf("\n"); } -void DbgSghContainsSig(DetectEngineCtx *de_ctx, SigGroupHead *sgh, uint32_t sid) -{ - if (sgh == NULL || sgh->init == NULL) { - printf("\n"); - return; - } - - uint32_t sig; - for (sig = 0; sig < DetectEngineGetMaxSigId(de_ctx); sig++) { - if (!(sgh->init->sig_array[(sig/8)] & (1<<(sig%8)))) - continue; - - Signature *s = de_ctx->sig_array[sig]; - if (s == NULL) - continue; - - if (sid == s->id) { - printf("%" PRIu32 " ", de_ctx->sig_array[sig]->id); - } - } - printf("\n"); -} - /** \brief finalize preparing sgh's */ int SigAddressPrepareStage4(DetectEngineCtx *de_ctx) { @@ -3749,7 +3717,7 @@ static void PrintFeatureList(const SigTableElmt *e, char sep) } } -static void SigMultilinePrint(int i, char *prefix) +static void SigMultilinePrint(int i, const char *prefix) { if (sigmatch_table[i].desc) { printf("%sDescription: %s\n", prefix, sigmatch_table[i].desc); @@ -5494,7 +5462,7 @@ end: return result; } -int SigTest24IPV4Keyword(void) +static int SigTest24IPV4Keyword(void) { uint8_t valid_raw_ipv4[] = { 0x45, 0x00, 0x00, 0x54, 0x00, 0x00, 0x40, 0x00, @@ -5598,7 +5566,7 @@ end: return result; } -int SigTest25NegativeIPV4Keyword(void) +static int SigTest25NegativeIPV4Keyword(void) { uint8_t valid_raw_ipv4[] = { 0x45, 0x00, 0x00, 0x54, 0x00, 0x00, 0x40, 0x00, @@ -5699,7 +5667,7 @@ end: return result; } -int SigTest26TCPV4Keyword(void) +static int SigTest26TCPV4Keyword(void) { uint8_t raw_ipv4[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -6151,7 +6119,7 @@ end: return result; } -int SigTest28TCPV6Keyword(void) +static int SigTest28TCPV6Keyword(void) { static uint8_t valid_raw_ipv6[] = { 0x00, 0x60, 0x97, 0x07, 0x69, 0xea, 0x00, 0x00, @@ -6279,7 +6247,7 @@ end: return result; } -int SigTest29NegativeTCPV6Keyword(void) +static int SigTest29NegativeTCPV6Keyword(void) { static uint8_t valid_raw_ipv6[] = { 0x00, 0x60, 0x97, 0x07, 0x69, 0xea, 0x00, 0x00, @@ -6405,7 +6373,7 @@ end: return result; } -int SigTest30UDPV4Keyword(void) +static int SigTest30UDPV4Keyword(void) { uint8_t raw_ipv4[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -6509,7 +6477,7 @@ int SigTest30UDPV4Keyword(void) PASS; } -int SigTest31NegativeUDPV4Keyword(void) +static int SigTest31NegativeUDPV4Keyword(void) { uint8_t raw_ipv4[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -6633,7 +6601,7 @@ end: } -int SigTest32UDPV6Keyword(void) +static int SigTest32UDPV6Keyword(void) { static uint8_t valid_raw_ipv6[] = { 0x00, 0x60, 0x97, 0x07, 0x69, 0xea, 0x00, 0x00, @@ -6730,7 +6698,7 @@ int SigTest32UDPV6Keyword(void) PASS; } -int SigTest33NegativeUDPV6Keyword(void) +static int SigTest33NegativeUDPV6Keyword(void) { static uint8_t valid_raw_ipv6[] = { 0x00, 0x60, 0x97, 0x07, 0x69, 0xea, 0x00, 0x00, @@ -6845,7 +6813,7 @@ end: return result; } -int SigTest34ICMPV4Keyword(void) +static int SigTest34ICMPV4Keyword(void) { uint8_t valid_raw_ipv4[] = { 0x45, 0x00, 0x00, 0x54, 0x00, 0x00, 0x40, 0x00, @@ -6965,7 +6933,7 @@ end: return result; } -int SigTest35NegativeICMPV4Keyword(void) +static int SigTest35NegativeICMPV4Keyword(void) { uint8_t valid_raw_ipv4[] = { 0x45, 0x00, 0x00, 0x54, 0x00, 0x00, 0x40, 0x00, @@ -7086,262 +7054,6 @@ end: return result; } -int SigTest36ICMPV6Keyword(void) -{ - uint8_t valid_raw_ipv6[] = { - 0x00, 0x00, 0x86, 0x05, 0x80, 0xda, 0x00, 0x60, - 0x97, 0x07, 0x69, 0xea, 0x86, 0xdd, 0x60, 0x00, - 0x00, 0x00, 0x00, 0x44, 0x3a, 0x40, 0x3f, 0xfe, - 0x05, 0x07, 0x00, 0x00, 0x00, 0x01, 0x02, 0x60, - 0x97, 0xff, 0xfe, 0x07, 0x69, 0xea, 0x3f, 0xfe, - 0x05, 0x07, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, - 0x86, 0xff, 0xfe, 0x05, 0x80, 0xda, 0x03, 0x00, - 0xf7, 0x52, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, - 0x00, 0x00, 0x00, 0x14, 0x11, 0x01, 0x3f, 0xfe, - 0x05, 0x07, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, - 0x86, 0xff, 0xfe, 0x05, 0x80, 0xda, 0x3f, 0xfe, - 0x05, 0x01, 0x04, 0x10, 0x00, 0x00, 0x02, 0xc0, - 0xdf, 0xff, 0xfe, 0x47, 0x03, 0x3e, 0xa0, 0x75, - 0x82, 0x9b, 0x00, 0x14, 0x82, 0x8b, 0x01, 0x01, - 0x00, 0x00, 0xf9, 0xc8, 0xe7, 0x36, 0xf5, 0xed, - 0x08, 0x00}; - - uint8_t invalid_raw_ipv6[] = { - 0x00, 0x00, 0x86, 0x05, 0x80, 0xda, 0x00, 0x60, - 0x97, 0x07, 0x69, 0xea, 0x86, 0xdd, 0x60, 0x00, - 0x00, 0x00, 0x00, 0x44, 0x3a, 0x40, 0x3f, 0xfe, - 0x05, 0x07, 0x00, 0x00, 0x00, 0x01, 0x02, 0x60, - 0x97, 0xff, 0xfe, 0x07, 0x69, 0xea, 0x3f, 0xfe, - 0x05, 0x07, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, - 0x86, 0xff, 0xfe, 0x05, 0x80, 0xda, 0x03, 0x00, - 0xf7, 0x52, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, - 0x00, 0x00, 0x00, 0x14, 0x11, 0x01, 0x3f, 0xfe, - 0x05, 0x07, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, - 0x86, 0xff, 0xfe, 0x05, 0x80, 0xda, 0x3f, 0xfe, - 0x05, 0x01, 0x04, 0x10, 0x00, 0x00, 0x02, 0xc0, - 0xdf, 0xff, 0xfe, 0x47, 0x03, 0x3e, 0xa0, 0x75, - 0x82, 0x9b, 0x00, 0x14, 0x82, 0x8b, 0x01, 0x01, - 0x00, 0x00, 0xf9, 0xc8, 0xe7, 0x36, 0xf5, 0xed, - 0x08, 0x01}; - - Packet *p1 = SCMalloc(SIZE_OF_PACKET); - if (unlikely(p1 == NULL)) - return 0; - Packet *p2 = SCMalloc(SIZE_OF_PACKET); - if (unlikely(p2 == NULL)) { - SCFree(p1); - return 0; - } - ThreadVars th_v; - DetectEngineThreadCtx *det_ctx = NULL; - int result = 1; - - uint8_t *buf = (uint8_t *)"GET /one/ HTTP/1.0\r\n" - "\r\n\r\n"; - uint16_t buflen = strlen((char *)buf); - - memset(&th_v, 0, sizeof(ThreadVars)); - memset(p1, 0, SIZE_OF_PACKET); - memset(p2, 0, SIZE_OF_PACKET); - - PACKET_RESET_CHECKSUMS(p1); - p1->ip6h = (IPV6Hdr *)(valid_raw_ipv6 + 14); - p1->icmpv6h = (ICMPV6Hdr *) (valid_raw_ipv6 + 54); - p1->src.family = AF_INET; - p1->dst.family = AF_INET; - p1->payload = buf; - p1->payload_len = buflen; - p1->proto = IPPROTO_ICMPV6; - - PACKET_RESET_CHECKSUMS(p2); - p2->ip6h = (IPV6Hdr *)(invalid_raw_ipv6 + 14); - p2->icmpv6h = (ICMPV6Hdr *) (invalid_raw_ipv6 + 54); - p2->src.family = AF_INET; - p2->dst.family = AF_INET; - p2->payload = buf; - p2->payload_len = buflen; - p2->proto = IPPROTO_ICMPV6; - - DetectEngineCtx *de_ctx = DetectEngineCtxInit(); - if (de_ctx == NULL) { - goto end; - } - - de_ctx->flags |= DE_QUIET; - - de_ctx->sig_list = SigInit(de_ctx, - "alert icmpv6 any any -> any any " - "(content:\"/one/\"; icmpv6-csum:valid; " - "msg:\"icmpv6-csum keyword check(1)\"; sid:1;)"); - if (de_ctx->sig_list == NULL) { - result &= 0; - goto end; - } - - de_ctx->sig_list->next = SigInit(de_ctx, - "alert icmpv6 any any -> any any " - "(content:\"/one/\"; icmpv6-csum:invalid; " - "msg:\"icmpv6-csum keyword check(1)\"; " - "sid:2;)"); - if (de_ctx->sig_list->next == NULL) { - result &= 0; - goto end; - } - - SigGroupBuild(de_ctx); - DetectEngineThreadCtxInit(&th_v, (void *)de_ctx,(void *)&det_ctx); - - SigMatchSignatures(&th_v, de_ctx, det_ctx, p1); - if (PacketAlertCheck(p1, 1)) - result &= 1; - else - result &= 0; - - SigMatchSignatures(&th_v, de_ctx, det_ctx, p2); - if (PacketAlertCheck(p2, 2)) - result &= 1; - else - result &= 0; - - SigGroupCleanup(de_ctx); - SigCleanSignatures(de_ctx); - if (det_ctx != NULL) - DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - DetectEngineCtxFree(de_ctx); -end: - SCFree(p1); - SCFree(p2); - return result; -} - -int SigTest37NegativeICMPV6Keyword(void) -{ - uint8_t valid_raw_ipv6[] = { - 0x00, 0x00, 0x86, 0x05, 0x80, 0xda, 0x00, 0x60, - 0x97, 0x07, 0x69, 0xea, 0x86, 0xdd, 0x60, 0x00, - 0x00, 0x00, 0x00, 0x44, 0x3a, 0x40, 0x3f, 0xfe, - 0x05, 0x07, 0x00, 0x00, 0x00, 0x01, 0x02, 0x60, - 0x97, 0xff, 0xfe, 0x07, 0x69, 0xea, 0x3f, 0xfe, - 0x05, 0x07, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, - 0x86, 0xff, 0xfe, 0x05, 0x80, 0xda, 0x03, 0x00, - 0xf7, 0x52, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, - 0x00, 0x00, 0x00, 0x14, 0x11, 0x01, 0x3f, 0xfe, - 0x05, 0x07, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, - 0x86, 0xff, 0xfe, 0x05, 0x80, 0xda, 0x3f, 0xfe, - 0x05, 0x01, 0x04, 0x10, 0x00, 0x00, 0x02, 0xc0, - 0xdf, 0xff, 0xfe, 0x47, 0x03, 0x3e, 0xa0, 0x75, - 0x82, 0x9b, 0x00, 0x14, 0x82, 0x8b, 0x01, 0x01, - 0x00, 0x00, 0xf9, 0xc8, 0xe7, 0x36, 0xf5, 0xed, - 0x08, 0x00}; - - uint8_t invalid_raw_ipv6[] = { - 0x00, 0x00, 0x86, 0x05, 0x80, 0xda, 0x00, 0x60, - 0x97, 0x07, 0x69, 0xea, 0x86, 0xdd, 0x60, 0x00, - 0x00, 0x00, 0x00, 0x44, 0x3a, 0x40, 0x3f, 0xfe, - 0x05, 0x07, 0x00, 0x00, 0x00, 0x01, 0x02, 0x60, - 0x97, 0xff, 0xfe, 0x07, 0x69, 0xea, 0x3f, 0xfe, - 0x05, 0x07, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, - 0x86, 0xff, 0xfe, 0x05, 0x80, 0xda, 0x03, 0x00, - 0xf7, 0x52, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, - 0x00, 0x00, 0x00, 0x14, 0x11, 0x01, 0x3f, 0xfe, - 0x05, 0x07, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, - 0x86, 0xff, 0xfe, 0x05, 0x80, 0xda, 0x3f, 0xfe, - 0x05, 0x01, 0x04, 0x10, 0x00, 0x00, 0x02, 0xc0, - 0xdf, 0xff, 0xfe, 0x47, 0x03, 0x3e, 0xa0, 0x75, - 0x82, 0x9b, 0x00, 0x14, 0x82, 0x8b, 0x01, 0x01, - 0x00, 0x00, 0xf9, 0xc8, 0xe7, 0x36, 0xf5, 0xed, - 0x08, 0x01}; - - Packet *p1 = SCMalloc(SIZE_OF_PACKET); - if (unlikely(p1 == NULL)) - return 0; - Packet *p2 = SCMalloc(SIZE_OF_PACKET); - if (unlikely(p2 == NULL)) { - SCFree(p1); - return 0; - } - ThreadVars th_v; - DetectEngineThreadCtx *det_ctx = NULL; - int result = 1; - - uint8_t *buf = (uint8_t *)"GET /one/ HTTP/1.0\r\n" - "\r\n\r\n"; - uint16_t buflen = strlen((char *)buf); - - memset(&th_v, 0, sizeof(ThreadVars)); - memset(p1, 0, SIZE_OF_PACKET); - memset(p2, 0, SIZE_OF_PACKET); - - PACKET_RESET_CHECKSUMS(p1); - p1->ip6h = (IPV6Hdr *)(valid_raw_ipv6 + 14); - p1->icmpv6h = (ICMPV6Hdr *) (valid_raw_ipv6 + 54); - p1->src.family = AF_INET; - p1->dst.family = AF_INET; - p1->payload = buf; - p1->payload_len = buflen; - p1->proto = IPPROTO_ICMPV6; - - PACKET_RESET_CHECKSUMS(p2); - p2->ip6h = (IPV6Hdr *)(invalid_raw_ipv6 + 14); - p2->icmpv6h = (ICMPV6Hdr *) (invalid_raw_ipv6 + 54); - p2->src.family = AF_INET; - p2->dst.family = AF_INET; - p2->payload = buf; - p2->payload_len = buflen; - p2->proto = IPPROTO_ICMPV6; - - DetectEngineCtx *de_ctx = DetectEngineCtxInit(); - if (de_ctx == NULL) { - goto end; - } - - de_ctx->flags |= DE_QUIET; - - de_ctx->sig_list = SigInit(de_ctx, - "alert icmpv6 any any -> any any " - "(content:\"/one/\"; icmpv6-csum:invalid; " - "msg:\"icmpv6-csum keyword check(1)\"; sid:1;)"); - if (de_ctx->sig_list == NULL) { - result &= 0; - goto end; - } - - de_ctx->sig_list->next = SigInit(de_ctx, - "alert icmpv6 any any -> any any " - "(content:\"/one/\"; icmpv6-csum:valid; " - "msg:\"icmpv6-csum keyword check(1)\"; " - "sid:2;)"); - if (de_ctx->sig_list->next == NULL) { - result &= 0; - goto end; - } - - SigGroupBuild(de_ctx); - DetectEngineThreadCtxInit(&th_v, (void *)de_ctx,(void *)&det_ctx); - - SigMatchSignatures(&th_v, de_ctx, det_ctx, p1); - if (PacketAlertCheck(p1, 1)) - result &= 0; - else - result &= 1; - - SigMatchSignatures(&th_v, de_ctx, det_ctx, p2); - if (PacketAlertCheck(p2, 2)) - result &= 0; - else - result &= 1; - - SigGroupCleanup(de_ctx); - SigCleanSignatures(de_ctx); - if (det_ctx != NULL) - DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - DetectEngineCtxFree(de_ctx); -end: - SCFree(p1); - SCFree(p2); - return result; -} - static int SigTest38(void) { Packet *p1 = SCMalloc(SIZE_OF_PACKET); @@ -7931,7 +7643,7 @@ end: * flasg is set, we don't need to inspect the packet contents. */ -int SigTest40NoPayloadInspection02(void) +static int SigTest40NoPayloadInspection02(void) { uint8_t *buf = (uint8_t *) @@ -9632,18 +9344,11 @@ void SigRegisterTests(void) UtRegisterTest("SigTest34ICMPV4Keyword", SigTest34ICMPV4Keyword); UtRegisterTest("SigTest35NegativeICMPV4Keyword", SigTest35NegativeICMPV4Keyword); - UtRegisterTest("SigTest36ContentAndIsdataatKeywords01", SigTest36ContentAndIsdataatKeywords01); UtRegisterTest("SigTest37ContentAndIsdataatKeywords02", SigTest37ContentAndIsdataatKeywords02); - /* We need to enable these tests, as soon as we add the ICMPv6 protocol - support in our rules engine */ - //UtRegisterTest("SigTest36ICMPV6Keyword", SigTest36ICMPV6Keyword, 1); - //UtRegisterTest("SigTest37NegativeICMPV6Keyword", - // SigTest37NegativeICMPV6Keyword, 1); - UtRegisterTest("SigTest38 -- byte_test test (1)", SigTest38); UtRegisterTest("SigTest39 -- byte_jump test (2)", SigTest39); diff --git a/src/detect.h b/src/detect.h index 8f68e22b07..28d703a03b 100644 --- a/src/detect.h +++ b/src/detect.h @@ -462,7 +462,7 @@ typedef struct Signature_ { /* Be careful, this pointer is only valid while parsing the sig, * to warn the user about any possible problem */ - char *sig_str; + const char *sig_str; SignatureInitData *init_data; @@ -948,7 +948,7 @@ typedef struct SigTableElmt_ { uint8_t flags, File *, const Signature *, const SigMatchCtx *); /** keyword setup function pointer */ - int (*Setup)(DetectEngineCtx *, Signature *, char *); + int (*Setup)(DetectEngineCtx *, Signature *, const char *); _Bool (*SupportsPrefilter)(const Signature *s); int (*SetupPrefilter)(struct SigGroupHead_ *sgh); @@ -1355,6 +1355,13 @@ enum { SigTableElmt sigmatch_table[DETECT_TBLSIZE]; /* detection api */ +int SigAddressPrepareStage1(DetectEngineCtx *de_ctx); +int SigAddressPrepareStage2(DetectEngineCtx *de_ctx); +int SigAddressPrepareStage3(DetectEngineCtx *de_ctx); +int SigAddressPrepareStage4(DetectEngineCtx *de_ctx); +int SigAddressCleanupStage1(DetectEngineCtx *de_ctx); +TmEcode Detect(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, PacketQueue *postpq); + SigMatch *SigMatchAlloc(void); Signature *SigFindSignatureBySidGid(DetectEngineCtx *, uint32_t, uint32_t); void SigMatchSignaturesBuildMatchArray(DetectEngineThreadCtx *, @@ -1373,7 +1380,7 @@ int SigGroupCleanup (DetectEngineCtx *de_ctx); void SigAddressPrepareBidirectionals (DetectEngineCtx *); void DisableDetectFlowFileFlags(Flow *f); -char *DetectLoadCompleteSigPath(const DetectEngineCtx *, char *sig_file); +char *DetectLoadCompleteSigPath(const DetectEngineCtx *, const char *sig_file); int SigLoadSignatures (DetectEngineCtx *, char *, int); void SigTableList(const char *keyword); void SigTableSetup(void); diff --git a/src/flow-manager.c b/src/flow-manager.c index 2d0323707b..b0c9f95faf 100644 --- a/src/flow-manager.c +++ b/src/flow-manager.c @@ -589,7 +589,7 @@ typedef struct FlowManagerThreadData_ { } FlowManagerThreadData; -static TmEcode FlowManagerThreadInit(ThreadVars *t, void *initdata, void **data) +static TmEcode FlowManagerThreadInit(ThreadVars *t, const void *initdata, void **data) { FlowManagerThreadData *ftd = SCCalloc(1, sizeof(FlowManagerThreadData)); if (ftd == NULL) @@ -859,7 +859,7 @@ typedef struct FlowRecyclerThreadData_ { void *output_thread_data; } FlowRecyclerThreadData; -static TmEcode FlowRecyclerThreadInit(ThreadVars *t, void *initdata, void **data) +static TmEcode FlowRecyclerThreadInit(ThreadVars *t, const void *initdata, void **data) { FlowRecyclerThreadData *ftd = SCCalloc(1, sizeof(FlowRecyclerThreadData)); if (ftd == NULL) @@ -963,7 +963,7 @@ static TmEcode FlowRecycler(ThreadVars *th_v, void *thread_data) return TM_ECODE_OK; } -int FlowRecyclerReadyToShutdown(void) +static int FlowRecyclerReadyToShutdown(void) { uint32_t len = 0; FQLOCK_LOCK(&flow_recycle_q); diff --git a/src/flow-queue.h b/src/flow-queue.h index b370cd2226..fd7a3b0ea8 100644 --- a/src/flow-queue.h +++ b/src/flow-queue.h @@ -72,7 +72,7 @@ typedef struct FlowQueue_ #endif /* prototypes */ -FlowQueue *FlowQueueNew(); +FlowQueue *FlowQueueNew(void); FlowQueue *FlowQueueInit(FlowQueue *); void FlowQueueDestroy (FlowQueue *); diff --git a/src/flow-storage.c b/src/flow-storage.c index 155b3fc10d..f63052f91d 100644 --- a/src/flow-storage.c +++ b/src/flow-storage.c @@ -26,7 +26,7 @@ */ #include "suricata-common.h" -#include "host-storage.h" +#include "flow-storage.h" #include "flow-hash.h" #include "flow-util.h" #include "util-unittest.h" diff --git a/src/flow-timeout.c b/src/flow-timeout.c index eb277295f4..9547b617ec 100644 --- a/src/flow-timeout.c +++ b/src/flow-timeout.c @@ -39,6 +39,7 @@ #include "flow-var.h" #include "flow-private.h" #include "flow-manager.h" +#include "flow-timeout.h" #include "pkt-var.h" #include "host.h" diff --git a/src/flow-worker.c b/src/flow-worker.c index e0935cc35e..184d4e5d1f 100644 --- a/src/flow-worker.c +++ b/src/flow-worker.c @@ -82,7 +82,7 @@ static inline TmEcode FlowUpdate(Packet *p) static TmEcode FlowWorkerThreadDeinit(ThreadVars *tv, void *data); -static TmEcode FlowWorkerThreadInit(ThreadVars *tv, void *initdata, void **data) +static TmEcode FlowWorkerThreadInit(ThreadVars *tv, const void *initdata, void **data) { FlowWorkerThreadData *fw = SCCalloc(1, sizeof(*fw)); if (fw == NULL) @@ -160,7 +160,7 @@ static TmEcode FlowWorkerThreadDeinit(ThreadVars *tv, void *data) TmEcode Detect(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, PacketQueue *postpq); TmEcode StreamTcp (ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *); -TmEcode FlowWorker(ThreadVars *tv, Packet *p, void *data, PacketQueue *preq, PacketQueue *unused) +static TmEcode FlowWorker(ThreadVars *tv, Packet *p, void *data, PacketQueue *preq, PacketQueue *unused) { FlowWorkerThreadData *fw = data; void *detect_thread = SC_ATOMIC_GET(fw->detect_thread); diff --git a/src/flow.c b/src/flow.c index 6d199f7764..589f733ee9 100644 --- a/src/flow.c +++ b/src/flow.c @@ -83,7 +83,7 @@ SC_ATOMIC_DECLARE(unsigned int, flow_prune_idx); SC_ATOMIC_DECLARE(unsigned int, flow_flags); void FlowRegisterTests(void); -void FlowInitFlowProto(); +void FlowInitFlowProto(void); int FlowSetProtoFreeFunc(uint8_t, void (*Free)(void *)); /* Run mode selected at suricata.c */ @@ -371,7 +371,7 @@ void FlowInitConfig(char quiet) } /* Check if we have memcap and hash_size defined at config */ - char *conf_val; + const char *conf_val; uint32_t configval = 0; /** set config values for memcap, prealloc and hash_size */ diff --git a/src/host-bit.c b/src/host-bit.c index 6710caebf1..7eeeaab2af 100644 --- a/src/host-bit.c +++ b/src/host-bit.c @@ -40,7 +40,8 @@ static int host_bit_id = -1; /**< Host storage id for bits */ -void HostBitFreeAll(void *store) { +static void HostBitFreeAll(void *store) +{ GenericVar *gv = store; GenericVarFree(gv); } diff --git a/src/host-queue.h b/src/host-queue.h index 386d0f6e7e..2edd169d22 100644 --- a/src/host-queue.h +++ b/src/host-queue.h @@ -72,7 +72,7 @@ typedef struct HostQueue_ #endif /* prototypes */ -HostQueue *HostQueueNew(); +HostQueue *HostQueueNew(void); HostQueue *HostQueueInit(HostQueue *); void HostQueueDestroy (HostQueue *); diff --git a/src/host-timeout.c b/src/host-timeout.c index c8be4e05a7..48efb5ab74 100644 --- a/src/host-timeout.c +++ b/src/host-timeout.c @@ -28,6 +28,7 @@ #include "detect-engine-threshold.h" #include "host-bit.h" +#include "host-timeout.h" #include "reputation.h" diff --git a/src/host.c b/src/host.c index 11a4ca8d4d..84b4d5eaae 100644 --- a/src/host.c +++ b/src/host.c @@ -96,7 +96,7 @@ void HostFree(Host *h) } } -Host *HostNew(Address *a) +static Host *HostNew(Address *a) { Host *h = HostAlloc(); if (h == NULL) @@ -148,7 +148,7 @@ void HostInitConfig(char quiet) host_config.prealloc = HOST_DEFAULT_PREALLOC; /* Check if we have memcap and hash_size defined at config */ - char *conf_val; + const char *conf_val; uint32_t configval = 0; /** set config values for memcap, prealloc and hash_size */ @@ -345,7 +345,7 @@ void HostCleanup(void) * hash_rand -- set at init time * source address */ -uint32_t HostGetKey(Address *a) +static inline uint32_t HostGetKey(Address *a) { uint32_t key; @@ -424,7 +424,7 @@ static Host *HostGetNew(Address *a) return h; } -void HostInit(Host *h, Address *a) +static void HostInit(Host *h, Address *a) { COPY_ADDRESS(a, &h->a); (void) HostIncrUsecnt(h); diff --git a/src/host.h b/src/host.h index d22f6f32f0..e3acb709e3 100644 --- a/src/host.h +++ b/src/host.h @@ -148,8 +148,8 @@ void HostPrintStats (void); void HostRegisterUnittests(void); -Host *HostAlloc(); -void HostFree(); +Host *HostAlloc(void); +void HostFree(Host *); void HostUnlock(Host *h); diff --git a/src/ippair-bit.c b/src/ippair-bit.c index 8ea1bc4d6b..0564217cc8 100644 --- a/src/ippair-bit.c +++ b/src/ippair-bit.c @@ -40,7 +40,8 @@ static int ippair_bit_id = -1; /**< IPPair storage id for bits */ -void XBitFreeAll(void *store) { +static void XBitFreeAll(void *store) +{ GenericVar *gv = store; GenericVarFree(gv); } diff --git a/src/ippair-queue.h b/src/ippair-queue.h index 5c80cf3917..cc3814b34f 100644 --- a/src/ippair-queue.h +++ b/src/ippair-queue.h @@ -72,7 +72,7 @@ typedef struct IPPairQueue_ #endif /* prototypes */ -IPPairQueue *IPPairQueueNew(); +IPPairQueue *IPPairQueueNew(void); IPPairQueue *IPPairQueueInit(IPPairQueue *); void IPPairQueueDestroy (IPPairQueue *); diff --git a/src/ippair-timeout.c b/src/ippair-timeout.c index 1225f82511..074200c878 100644 --- a/src/ippair-timeout.c +++ b/src/ippair-timeout.c @@ -24,6 +24,7 @@ #include "suricata-common.h" #include "ippair.h" #include "ippair-bit.h" +#include "ippair-timeout.h" uint32_t IPPairGetSpareCount(void) { diff --git a/src/ippair.c b/src/ippair.c index 5c35efa475..fa56b7c982 100644 --- a/src/ippair.c +++ b/src/ippair.c @@ -96,7 +96,7 @@ void IPPairFree(IPPair *h) } } -IPPair *IPPairNew(Address *a, Address *b) +static IPPair *IPPairNew(Address *a, Address *b) { IPPair *p = IPPairAlloc(); if (p == NULL) @@ -144,7 +144,7 @@ void IPPairInitConfig(char quiet) ippair_config.prealloc = IPPAIR_DEFAULT_PREALLOC; /* Check if we have memcap and hash_size defined at config */ - char *conf_val; + const char *conf_val; uint32_t configval = 0; /** set config values for memcap, prealloc and hash_size */ @@ -468,7 +468,7 @@ static IPPair *IPPairGetNew(Address *a, Address *b) return h; } -void IPPairInit(IPPair *h, Address *a, Address *b) +static void IPPairInit(IPPair *h, Address *a, Address *b) { COPY_ADDRESS(a, &h->a[0]); COPY_ADDRESS(b, &h->a[1]); diff --git a/src/log-cf-common.c b/src/log-cf-common.c index 9a4efb3219..35a3168eaf 100644 --- a/src/log-cf-common.c +++ b/src/log-cf-common.c @@ -260,7 +260,7 @@ static int LogCustomFormatTest01(void) return 1; } -void LogCustomFormatRegisterTests(void) +static void LogCustomFormatRegisterTests(void) { UtRegisterTest("LogCustomFormatTest01", LogCustomFormatTest01); } diff --git a/src/log-dnslog.c b/src/log-dnslog.c index 2b3658d2e7..df3e19c39d 100644 --- a/src/log-dnslog.c +++ b/src/log-dnslog.c @@ -249,7 +249,7 @@ static int LogDnsResponseLogger(ThreadVars *tv, void *data, const Packet *p, return LogDnsLogger(tv, data, p, f, state, tx, tx_id, STREAM_TOCLIENT); } -static TmEcode LogDnsLogThreadInit(ThreadVars *t, void *initdata, void **data) +static TmEcode LogDnsLogThreadInit(ThreadVars *t, const void *initdata, void **data) { LogDnsLogThread *aft = SCMalloc(sizeof(LogDnsLogThread)); if (unlikely(aft == NULL)) diff --git a/src/log-droplog.c b/src/log-droplog.c index 027425754d..d418711115 100644 --- a/src/log-droplog.c +++ b/src/log-droplog.c @@ -72,7 +72,7 @@ typedef struct LogDropLogThread_ { * * \return TM_ECODE_OK on success */ -static TmEcode LogDropLogThreadInit(ThreadVars *t, void *initdata, void **data) +static TmEcode LogDropLogThreadInit(ThreadVars *t, const void *initdata, void **data) { if(initdata == NULL) { SCLogDebug("Error getting context for LogDropLog. \"initdata\" argument NULL"); @@ -348,7 +348,7 @@ static void LogDropLogExitPrintStats(ThreadVars *tv, void *data) #ifdef UNITTESTS /** \brief test if the action is drop then packet should be logged */ -int LogDropLogTest01() +static int LogDropLogTest01(void) { int result = 0; EngineModeSetIPS(); @@ -413,7 +413,7 @@ int LogDropLogTest01() } /** \brief test if the action is alert then packet shouldn't be logged */ -int LogDropLogTest02() +static int LogDropLogTest02(void) { int result = 0; EngineModeSetIPS(); diff --git a/src/log-file.c b/src/log-file.c index 3ddf8643b1..0c04ff4125 100644 --- a/src/log-file.c +++ b/src/log-file.c @@ -349,7 +349,7 @@ static int LogFileLogger(ThreadVars *tv, void *thread_data, const Packet *p, con return 0; } -static TmEcode LogFileLogThreadInit(ThreadVars *t, void *initdata, void **data) +static TmEcode LogFileLogThreadInit(ThreadVars *t, const void *initdata, void **data) { LogFileLogThread *aft = SCMalloc(sizeof(LogFileLogThread)); if (unlikely(aft == NULL)) @@ -370,7 +370,7 @@ static TmEcode LogFileLogThreadInit(ThreadVars *t, void *initdata, void **data) return TM_ECODE_OK; } -TmEcode LogFileLogThreadDeinit(ThreadVars *t, void *data) +static TmEcode LogFileLogThreadDeinit(ThreadVars *t, void *data) { LogFileLogThread *aft = (LogFileLogThread *)data; if (aft == NULL) { @@ -384,7 +384,7 @@ TmEcode LogFileLogThreadDeinit(ThreadVars *t, void *data) return TM_ECODE_OK; } -void LogFileLogExitPrintStats(ThreadVars *tv, void *data) +static void LogFileLogExitPrintStats(ThreadVars *tv, void *data) { LogFileLogThread *aft = (LogFileLogThread *)data; if (aft == NULL) { @@ -449,17 +449,6 @@ static OutputCtx *LogFileLogInitCtx(ConfNode *conf) SCReturnPtr(output_ctx, "OutputCtx"); } -/** \brief Read the config set the file pointer, open the file - * \param file_ctx pointer to a created LogFileCtx using LogFileNewCtx() - * \param config_file for loading separate configs - * \return -1 if failure, 0 if succesful - * */ -int LogFileLogOpenFileCtx(LogFileCtx *file_ctx, const char *filename, const - char *mode) -{ - return 0; -} - void LogFileLogRegister (void) { OutputRegisterFileModule(LOGGER_FILE, MODULE_NAME, "file-log", diff --git a/src/log-filestore.c b/src/log-filestore.c index 5fca12d203..0bc6c1f676 100644 --- a/src/log-filestore.c +++ b/src/log-filestore.c @@ -51,6 +51,7 @@ #include "output.h" #include "log-file.h" +#include "log-filestore.h" #include "util-logopenfile.h" #include "app-layer-htp.h" @@ -361,7 +362,7 @@ static int LogFilestoreLogger(ThreadVars *tv, void *thread_data, const Packet *p return 0; } -static TmEcode LogFilestoreLogThreadInit(ThreadVars *t, void *initdata, void **data) +static TmEcode LogFilestoreLogThreadInit(ThreadVars *t, const void *initdata, void **data) { LogFilestoreLogThread *aft = SCMalloc(sizeof(LogFilestoreLogThread)); if (unlikely(aft == NULL)) @@ -453,7 +454,7 @@ static OutputCtx *LogFilestoreLogInitCtx(ConfNode *conf) output_ctx->data = NULL; output_ctx->DeInit = LogFilestoreLogDeInitCtx; - char *s_default_log_dir = NULL; + const char *s_default_log_dir = NULL; s_default_log_dir = ConfigGetLogDirectory(); const char *s_base_dir = NULL; diff --git a/src/log-httplog.c b/src/log-httplog.c index a26a2f6730..9888cee028 100644 --- a/src/log-httplog.c +++ b/src/log-httplog.c @@ -57,7 +57,7 @@ #define OUTPUT_BUFFER_SIZE 65535 -TmEcode LogHttpLogThreadInit(ThreadVars *, void *, void **); +TmEcode LogHttpLogThreadInit(ThreadVars *, const void *, void **); TmEcode LogHttpLogThreadDeinit(ThreadVars *, void *); static void LogHttpLogDeInitCtx(OutputCtx *); @@ -503,7 +503,7 @@ int LogHttpLogger(ThreadVars *tv, void *thread_data, const Packet *p, Flow *f, v SCReturnInt(r); } -TmEcode LogHttpLogThreadInit(ThreadVars *t, void *initdata, void **data) +TmEcode LogHttpLogThreadInit(ThreadVars *t, const void *initdata, void **data) { LogHttpLogThread *aft = SCMalloc(sizeof(LogHttpLogThread)); if (unlikely(aft == NULL)) diff --git a/src/log-pcap.c b/src/log-pcap.c index 0d1a2f776a..523adb3812 100644 --- a/src/log-pcap.c +++ b/src/log-pcap.c @@ -166,7 +166,7 @@ static PcapLogData *g_pcap_data = NULL; static int PcapLogOpenFileCtx(PcapLogData *); static int PcapLog(ThreadVars *, void *, const Packet *); -static TmEcode PcapLogDataInit(ThreadVars *, void *, void **); +static TmEcode PcapLogDataInit(ThreadVars *, const void *, void **); static TmEcode PcapLogDataDeinit(ThreadVars *, void *); static void PcapLogFileDeInitCtx(OutputCtx *); static OutputCtx *PcapLogInitCtx(ConfNode *); @@ -686,7 +686,7 @@ static TmEcode PcapLogInitRingBuffer(PcapLogData *pl) } #endif /* INIT_RING_BUFFER */ -static TmEcode PcapLogDataInit(ThreadVars *t, void *initdata, void **data) +static TmEcode PcapLogDataInit(ThreadVars *t, const void *initdata, void **data) { if (initdata == NULL) { SCLogDebug("Error getting context for LogPcap. \"initdata\" argument NULL"); @@ -1039,7 +1039,7 @@ static OutputCtx *PcapLogInitCtx(ConfNode *conf) "option to be set."); exit(EXIT_FAILURE); } else { - char *log_dir = NULL; + const char *log_dir = NULL; log_dir = ConfigGetLogDirectory(); strlcpy(pl->dir, @@ -1051,7 +1051,7 @@ static OutputCtx *PcapLogInitCtx(ConfNode *conf) strlcpy(pl->dir, s_dir, sizeof(pl->dir)); } else { - char *log_dir = NULL; + const char *log_dir = NULL; log_dir = ConfigGetLogDirectory(); snprintf(pl->dir, sizeof(pl->dir), "%s/%s", @@ -1324,7 +1324,7 @@ error: static int profiling_pcaplog_enabled = 0; static int profiling_pcaplog_output_to_file = 0; static char *profiling_pcaplog_file_name = NULL; -static char *profiling_pcaplog_file_mode = "a"; +static const char *profiling_pcaplog_file_mode = "a"; static void FormatNumber(uint64_t num, char *str, size_t size) { @@ -1445,7 +1445,7 @@ void PcapLogProfileSetup(void) const char *filename = ConfNodeLookupChildValue(conf, "filename"); if (filename != NULL) { - char *log_dir; + const char *log_dir; log_dir = ConfigGetLogDirectory(); profiling_pcaplog_file_name = SCMalloc(PATH_MAX); diff --git a/src/log-stats.c b/src/log-stats.c index 69fe82d205..138eef0027 100644 --- a/src/log-stats.c +++ b/src/log-stats.c @@ -53,7 +53,7 @@ #define LOG_STATS_THREADS (1<<1) #define LOG_STATS_NULLS (1<<2) -TmEcode LogStatsLogThreadInit(ThreadVars *, void *, void **); +TmEcode LogStatsLogThreadInit(ThreadVars *, const void *, void **); TmEcode LogStatsLogThreadDeinit(ThreadVars *, void *); static void LogStatsLogDeInitCtx(OutputCtx *); @@ -67,7 +67,7 @@ typedef struct LogStatsLogThread_ { MemBuffer *buffer; } LogStatsLogThread; -int LogStatsLogger(ThreadVars *tv, void *thread_data, const StatsTable *st) +static int LogStatsLogger(ThreadVars *tv, void *thread_data, const StatsTable *st) { SCEnter(); LogStatsLogThread *aft = (LogStatsLogThread *)thread_data; @@ -80,7 +80,8 @@ int LogStatsLogger(ThreadVars *tv, void *thread_data, const StatsTable *st) tms = SCLocalTime(tval.tv_sec, &local_tm); /* Calculate the Engine uptime */ - int up_time = (int)difftime(tval.tv_sec, st->start_time); + double up_time_d = difftime(tval.tv_sec, st->start_time); + int up_time = (int)up_time_d; // ignoring risk of overflow here int sec = up_time % 60; // Seconds in a minute int in_min = up_time / 60; int min = in_min % 60; // Minutes in a hour @@ -163,7 +164,7 @@ int LogStatsLogger(ThreadVars *tv, void *thread_data, const StatsTable *st) SCReturnInt(0); } -TmEcode LogStatsLogThreadInit(ThreadVars *t, void *initdata, void **data) +TmEcode LogStatsLogThreadInit(ThreadVars *t, const void *initdata, void **data) { LogStatsLogThread *aft = SCMalloc(sizeof(LogStatsLogThread)); if (unlikely(aft == NULL)) @@ -209,7 +210,7 @@ TmEcode LogStatsLogThreadDeinit(ThreadVars *t, void *data) * \param conf Pointer to ConfNode containing this loggers configuration. * \return NULL if failure, LogFileCtx* to the file_ctx if succesful * */ -OutputCtx *LogStatsLogInitCtx(ConfNode *conf) +static OutputCtx *LogStatsLogInitCtx(ConfNode *conf) { LogFileCtx *file_ctx = LogFileNewCtx(); if (file_ctx == NULL) { diff --git a/src/log-tcp-data.c b/src/log-tcp-data.c index c2faa046ee..068e738eb0 100644 --- a/src/log-tcp-data.c +++ b/src/log-tcp-data.c @@ -53,7 +53,7 @@ #define OUTPUT_BUFFER_SIZE 65535 -TmEcode LogTcpDataLogThreadInit(ThreadVars *, void *, void **); +TmEcode LogTcpDataLogThreadInit(ThreadVars *, const void *, void **); TmEcode LogTcpDataLogThreadDeinit(ThreadVars *, void *); static void LogTcpDataLogDeInitCtx(OutputCtx *); @@ -88,7 +88,7 @@ static int LogTcpDataLoggerDir(ThreadVars *tv, void *thread_data, const Flow *f, SCEnter(); LogTcpDataLogThread *aft = thread_data; LogTcpDataFileCtx *td = aft->tcpdatalog_ctx; - char *mode = "a"; + const char *mode = "a"; if (flags & OUTPUT_STREAMING_FLAG_OPEN) mode = "w"; @@ -179,7 +179,7 @@ int LogTcpDataLogger(ThreadVars *tv, void *thread_data, const Flow *f, SCReturnInt(TM_ECODE_OK); } -TmEcode LogTcpDataLogThreadInit(ThreadVars *t, void *initdata, void **data) +TmEcode LogTcpDataLogThreadInit(ThreadVars *t, const void *initdata, void **data) { LogTcpDataLogThread *aft = SCMalloc(sizeof(LogTcpDataLogThread)); if (unlikely(aft == NULL)) diff --git a/src/log-tlslog.c b/src/log-tlslog.c index fb76d705cf..b45802d63c 100644 --- a/src/log-tlslog.c +++ b/src/log-tlslog.c @@ -200,7 +200,7 @@ int TLSGetIPInformations(const Packet *p, char* srcip, size_t srcip_len, return 1; } -static TmEcode LogTlsLogThreadInit(ThreadVars *t, void *initdata, void **data) +static TmEcode LogTlsLogThreadInit(ThreadVars *t, const void *initdata, void **data) { LogTlsLogThread *aft = SCMalloc(sizeof(LogTlsLogThread)); if (unlikely(aft == NULL)) diff --git a/src/log-tlsstore.c b/src/log-tlsstore.c index 861a2da69a..74d0ec1d27 100644 --- a/src/log-tlsstore.c +++ b/src/log-tlsstore.c @@ -43,6 +43,7 @@ #include "output.h" #include "log-tlslog.h" +#include "log-tlsstore.h" #include "app-layer-ssl.h" #include "app-layer.h" #include "app-layer-parser.h" @@ -291,7 +292,7 @@ static int LogTlsStoreLogger(ThreadVars *tv, void *thread_data, const Packet *p, return 0; } -static TmEcode LogTlsStoreLogThreadInit(ThreadVars *t, void *initdata, void **data) +static TmEcode LogTlsStoreLogThreadInit(ThreadVars *t, const void *initdata, void **data) { LogTlsStoreLogThread *aft = SCMalloc(sizeof(LogTlsStoreLogThread)); if (unlikely(aft == NULL)) @@ -383,7 +384,7 @@ static OutputCtx *LogTlsStoreLogInitCtx(ConfNode *conf) output_ctx->DeInit = LogTlsStoreLogDeInitCtx; /* FIXME we need to implement backward compability here */ - char *s_default_log_dir = NULL; + const char *s_default_log_dir = NULL; s_default_log_dir = ConfigGetLogDirectory(); const char *s_base_dir = NULL; diff --git a/src/output-file.c b/src/output-file.c index 020be8e282..d05ffd4d40 100644 --- a/src/output-file.c +++ b/src/output-file.c @@ -185,7 +185,7 @@ static TmEcode OutputFileLog(ThreadVars *tv, Packet *p, void *thread_data) /** \brief thread init for the tx logger * This will run the thread init functions for the individual registered * loggers */ -static TmEcode OutputFileLogThreadInit(ThreadVars *tv, void *initdata, void **data) +static TmEcode OutputFileLogThreadInit(ThreadVars *tv, const void *initdata, void **data) { OutputLoggerThreadData *td = SCMalloc(sizeof(*td)); if (td == NULL) diff --git a/src/output-filedata.c b/src/output-filedata.c index 7beca04aca..6a5345eaaa 100644 --- a/src/output-filedata.c +++ b/src/output-filedata.c @@ -294,7 +294,7 @@ static void LogFiledataLogStoreWaldo(const char *path) /** \brief thread init for the tx logger * This will run the thread init functions for the individual registered * loggers */ -static TmEcode OutputFiledataLogThreadInit(ThreadVars *tv, void *initdata, void **data) +static TmEcode OutputFiledataLogThreadInit(ThreadVars *tv, const void *initdata, void **data) { OutputLoggerThreadData *td = SCMalloc(sizeof(*td)); if (td == NULL) @@ -363,7 +363,7 @@ static TmEcode OutputFiledataLogThreadInit(ThreadVars *tv, void *initdata, void } } if (node != NULL) { - char *s_default_log_dir = NULL; + const char *s_default_log_dir = NULL; s_default_log_dir = ConfigGetLogDirectory(); const char *waldo = node->val; diff --git a/src/output-flow.c b/src/output-flow.c index 235c6578e6..9552a86075 100644 --- a/src/output-flow.c +++ b/src/output-flow.c @@ -47,7 +47,7 @@ typedef struct OutputFlowLogger_ { OutputCtx *output_ctx; struct OutputFlowLogger_ *next; const char *name; - TmEcode (*ThreadInit)(ThreadVars *, void *, void **); + TmEcode (*ThreadInit)(ThreadVars *, const void *, void **); TmEcode (*ThreadDeinit)(ThreadVars *, void *); void (*ThreadExitPrintStats)(ThreadVars *, void *); } OutputFlowLogger; diff --git a/src/output-json-alert.c b/src/output-json-alert.c index 89a582cf50..2a5a752e41 100644 --- a/src/output-json-alert.c +++ b/src/output-json-alert.c @@ -53,6 +53,7 @@ #include "output.h" #include "output-json.h" +#include "output-json-alert.h" #include "output-json-dnp3.h" #include "output-json-http.h" #include "output-json-tls.h" @@ -175,7 +176,7 @@ static void AlertJsonDnp3(const Flow *f, json_t *js) void AlertJsonHeader(const Packet *p, const PacketAlert *pa, json_t *js) { - char *action = "allowed"; + const char *action = "allowed"; /* use packet action if rate_filter modified the action */ if (unlikely(pa->flags & PACKET_ALERT_RATE_FILTER_MODIFIED)) { if (PACKET_TEST_ACTION(p, (ACTION_DROP|ACTION_REJECT| @@ -488,7 +489,7 @@ static int AlertJsonDecoderEvent(ThreadVars *tv, JsonAlertLogThread *aft, const continue; } - char *action = "allowed"; + const char *action = "allowed"; if (pa->action & (ACTION_REJECT|ACTION_REJECT_DST|ACTION_REJECT_BOTH)) { action = "blocked"; } else if ((pa->action & ACTION_DROP) && EngineModeIsIPS()) { @@ -562,7 +563,7 @@ static int JsonAlertLogCondition(ThreadVars *tv, const Packet *p) } #define OUTPUT_BUFFER_SIZE 65535 -static TmEcode JsonAlertLogThreadInit(ThreadVars *t, void *initdata, void **data) +static TmEcode JsonAlertLogThreadInit(ThreadVars *t, const void *initdata, void **data) { JsonAlertLogThread *aft = SCMalloc(sizeof(JsonAlertLogThread)); if (unlikely(aft == NULL)) diff --git a/src/output-json-dnp3-objects.c b/src/output-json-dnp3-objects.c index 8fc7e760c0..ff57dfcf65 100644 --- a/src/output-json-dnp3-objects.c +++ b/src/output-json-dnp3-objects.c @@ -28,6 +28,7 @@ #include "app-layer-dnp3.h" #include "app-layer-dnp3-objects.h" +#include "output-json-dnp3-objects.h" #ifdef HAVE_LIBJANSSON diff --git a/src/output-json-dnp3.c b/src/output-json-dnp3.c index e726959d48..e8730a6855 100644 --- a/src/output-json-dnp3.c +++ b/src/output-json-dnp3.c @@ -40,6 +40,7 @@ #include "output.h" #include "output-json.h" +#include "output-json-dnp3.h" #include "output-json-dnp3-objects.h" #ifdef HAVE_LIBJANSSON @@ -389,7 +390,7 @@ static OutputCtx *OutputDNP3LogInitSub(ConfNode *conf, OutputCtx *parent_ctx) #define OUTPUT_BUFFER_SIZE 65535 -static TmEcode JsonDNP3LogThreadInit(ThreadVars *t, void *initdata, void **data) +static TmEcode JsonDNP3LogThreadInit(ThreadVars *t, const void *initdata, void **data) { LogDNP3LogThread *thread = SCCalloc(1, sizeof(*thread)); if (unlikely(thread == NULL)) { diff --git a/src/output-json-dns.c b/src/output-json-dns.c index 96689777ec..dc78a996cc 100644 --- a/src/output-json-dns.c +++ b/src/output-json-dns.c @@ -49,6 +49,7 @@ #include "util-time.h" #include "output-json.h" +#include "output-json-dns.h" #ifdef HAVE_LIBJANSSON @@ -182,7 +183,7 @@ typedef enum { } DnsRRTypes; static struct { - char *config_rrtype; + const char *config_rrtype; uint64_t flags; } dns_rrtype_fields[] = { { "a", LOG_A }, @@ -665,7 +666,7 @@ static int JsonDnsLoggerToClient(ThreadVars *tv, void *thread_data, } #define OUTPUT_BUFFER_SIZE 65536 -static TmEcode LogDnsLogThreadInit(ThreadVars *t, void *initdata, void **data) +static TmEcode LogDnsLogThreadInit(ThreadVars *t, const void *initdata, void **data) { LogDnsLogThread *aft = SCMalloc(sizeof(LogDnsLogThread)); if (unlikely(aft == NULL)) diff --git a/src/output-json-drop.c b/src/output-json-drop.c index e26fd6dcb6..471a2c5de8 100644 --- a/src/output-json-drop.c +++ b/src/output-json-drop.c @@ -44,6 +44,7 @@ #include "output.h" #include "output-json.h" #include "output-json-alert.h" +#include "output-json-drop.h" #include "util-unittest.h" #include "util-unittest-helper.h" @@ -177,7 +178,7 @@ static int DropLogJSON (JsonDropLogThread *aft, const Packet *p) } #define OUTPUT_BUFFER_SIZE 65535 -static TmEcode JsonDropLogThreadInit(ThreadVars *t, void *initdata, void **data) +static TmEcode JsonDropLogThreadInit(ThreadVars *t, const void *initdata, void **data) { JsonDropLogThread *aft = SCMalloc(sizeof(JsonDropLogThread)); if (unlikely(aft == NULL)) diff --git a/src/output-json-email-common.c b/src/output-json-email-common.c index a802b4a121..e4055061be 100644 --- a/src/output-json-email-common.c +++ b/src/output-json-email-common.c @@ -63,8 +63,8 @@ #define LOG_EMAIL_SUBJECT_MD5 (1<<4) struct { - char *config_field; - char *email_field; + const char *config_field; + const char *email_field; uint32_t flags; } email_fields[] = { { "reply_to", "reply-to", LOG_EMAIL_DEFAULT }, @@ -235,7 +235,7 @@ static void JsonEmailLogJSONCustom(OutputJsonEmailCtx *email_ctx, json_t *js, SM } /* JSON format logging */ -json_t *JsonEmailLogJsonData(const Flow *f, void *state, void *vtx, uint64_t tx_id) +static json_t *JsonEmailLogJsonData(const Flow *f, void *state, void *vtx, uint64_t tx_id) { SMTPState *smtp_state; MimeDecParseState *mime_state; diff --git a/src/output-json-file.c b/src/output-json-file.c index e840b669c8..02b834b923 100644 --- a/src/output-json-file.c +++ b/src/output-json-file.c @@ -56,6 +56,7 @@ #include "output.h" #include "output-json.h" +#include "output-json-file.h" #include "output-json-http.h" #include "output-json-smtp.h" #include "output-json-email-common.h" @@ -208,7 +209,7 @@ static int JsonFileLogger(ThreadVars *tv, void *thread_data, const Packet *p, co #define OUTPUT_BUFFER_SIZE 65535 -static TmEcode JsonFileLogThreadInit(ThreadVars *t, void *initdata, void **data) +static TmEcode JsonFileLogThreadInit(ThreadVars *t, const void *initdata, void **data) { JsonFileLogThread *aft = SCMalloc(sizeof(JsonFileLogThread)); if (unlikely(aft == NULL)) @@ -261,7 +262,7 @@ static void OutputFileLogDeinitSub(OutputCtx *output_ctx) * \param conf Pointer to ConfNode containing this loggers configuration. * \return NULL if failure, LogFileCtx* to the file_ctx if succesful * */ -OutputCtx *OutputFileLogInitSub(ConfNode *conf, OutputCtx *parent_ctx) +static OutputCtx *OutputFileLogInitSub(ConfNode *conf, OutputCtx *parent_ctx) { OutputJsonCtx *ojc = parent_ctx->data; diff --git a/src/output-json-flow.c b/src/output-json-flow.c index e2d7c1b5c2..5df87d842f 100644 --- a/src/output-json-flow.c +++ b/src/output-json-flow.c @@ -45,6 +45,7 @@ #include "util-logopenfile.h" #include "util-time.h" #include "output-json.h" +#include "output-json-flow.h" #include "stream-tcp-private.h" @@ -68,7 +69,7 @@ typedef struct JsonFlowLogThread_ { #define LOG_HTTP_EXTENDED 1 #define LOG_HTTP_CUSTOM 2 -static json_t *CreateJSONHeaderFromFlow(Flow *f, char *event_type) +static json_t *CreateJSONHeaderFromFlow(Flow *f, const char *event_type) { char timebuf[64]; char srcip[46], dstip[46]; @@ -291,7 +292,7 @@ static void JsonFlowLogJSON(JsonFlowLogThread *aft, json_t *js, Flow *f) JsonTcpFlags(ssn ? ssn->tcp_packet_flags : 0, tjs); if (ssn) { - char *tcp_state = NULL; + const char *tcp_state = NULL; switch (ssn->state) { case TCP_NONE: tcp_state = "none"; @@ -370,7 +371,7 @@ static void OutputFlowLogDeinit(OutputCtx *output_ctx) } #define DEFAULT_LOG_FILENAME "flow.json" -OutputCtx *OutputFlowLogInit(ConfNode *conf) +static OutputCtx *OutputFlowLogInit(ConfNode *conf) { SCLogInfo("hi"); LogFileCtx *file_ctx = LogFileNewCtx(); @@ -411,7 +412,7 @@ static void OutputFlowLogDeinitSub(OutputCtx *output_ctx) SCFree(output_ctx); } -OutputCtx *OutputFlowLogInitSub(ConfNode *conf, OutputCtx *parent_ctx) +static OutputCtx *OutputFlowLogInitSub(ConfNode *conf, OutputCtx *parent_ctx) { OutputJsonCtx *ojc = parent_ctx->data; @@ -435,7 +436,7 @@ OutputCtx *OutputFlowLogInitSub(ConfNode *conf, OutputCtx *parent_ctx) } #define OUTPUT_BUFFER_SIZE 65535 -static TmEcode JsonFlowLogThreadInit(ThreadVars *t, void *initdata, void **data) +static TmEcode JsonFlowLogThreadInit(ThreadVars *t, const void *initdata, void **data) { JsonFlowLogThread *aft = SCMalloc(sizeof(JsonFlowLogThread)); if (unlikely(aft == NULL)) diff --git a/src/output-json-http.c b/src/output-json-http.c index a220252780..a23308388c 100644 --- a/src/output-json-http.c +++ b/src/output-json-http.c @@ -48,6 +48,7 @@ #include "util-logopenfile.h" #include "util-time.h" #include "output-json.h" +#include "output-json-http.h" #ifdef HAVE_LIBJANSSON @@ -125,8 +126,8 @@ typedef enum { } HttpField; struct { - char *config_field; - char *htp_field; + const char *config_field; + const char *htp_field; uint32_t flags; } http_fields[] = { { "accept", "accept", LOG_HTTP_REQUEST }, @@ -181,7 +182,7 @@ struct { { "www_authenticate", "www-authenticate", 0 }, }; -void JsonHttpLogJSONBasic(json_t *js, htp_tx_t *tx) +static void JsonHttpLogJSONBasic(json_t *js, htp_tx_t *tx) { char *c; @@ -291,7 +292,7 @@ static void JsonHttpLogJSONCustom(LogHttpFileCtx *http_ctx, json_t *js, htp_tx_t } } -void JsonHttpLogJSONExtended(json_t *js, htp_tx_t *tx) +static void JsonHttpLogJSONExtended(json_t *js, htp_tx_t *tx) { char *c; @@ -426,7 +427,7 @@ static void OutputHttpLogDeinit(OutputCtx *output_ctx) } #define DEFAULT_LOG_FILENAME "http.json" -OutputCtx *OutputHttpLogInit(ConfNode *conf) +static OutputCtx *OutputHttpLogInit(ConfNode *conf) { LogFileCtx *file_ctx = LogFileNewCtx(); if(file_ctx == NULL) { @@ -480,7 +481,7 @@ static void OutputHttpLogDeinitSub(OutputCtx *output_ctx) SCFree(output_ctx); } -OutputCtx *OutputHttpLogInitSub(ConfNode *conf, OutputCtx *parent_ctx) +static OutputCtx *OutputHttpLogInitSub(ConfNode *conf, OutputCtx *parent_ctx) { OutputJsonCtx *ojc = parent_ctx->data; @@ -540,7 +541,7 @@ OutputCtx *OutputHttpLogInitSub(ConfNode *conf, OutputCtx *parent_ctx) } #define OUTPUT_BUFFER_SIZE 65535 -static TmEcode JsonHttpLogThreadInit(ThreadVars *t, void *initdata, void **data) +static TmEcode JsonHttpLogThreadInit(ThreadVars *t, const void *initdata, void **data) { JsonHttpLogThread *aft = SCMalloc(sizeof(JsonHttpLogThread)); if (unlikely(aft == NULL)) diff --git a/src/output-json-http.h b/src/output-json-http.h index eda68c2acc..a82e928009 100644 --- a/src/output-json-http.h +++ b/src/output-json-http.h @@ -27,8 +27,6 @@ void JsonHttpLogRegister(void); #ifdef HAVE_LIBJANSSON -void JsonHttpLogJSONBasic(json_t *js, htp_tx_t *tx); -void JsonHttpLogJSONExtended(json_t *js, htp_tx_t *tx); json_t *JsonHttpAddMetadata(const Flow *f, uint64_t tx_id); #endif /* HAVE_LIBJANSSON */ diff --git a/src/output-json-netflow.c b/src/output-json-netflow.c index 4733a7dcb7..9464a15a3f 100644 --- a/src/output-json-netflow.c +++ b/src/output-json-netflow.c @@ -45,6 +45,7 @@ #include "util-logopenfile.h" #include "util-time.h" #include "output-json.h" +#include "output-json-netflow.h" #include "stream-tcp-private.h" @@ -62,7 +63,7 @@ typedef struct JsonNetFlowLogThread_ { } JsonNetFlowLogThread; -static json_t *CreateJSONHeaderFromFlow(Flow *f, char *event_type, int dir) +static json_t *CreateJSONHeaderFromFlow(Flow *f, const char *event_type, int dir) { char timebuf[64]; char srcip[46], dstip[46]; @@ -324,7 +325,7 @@ static void OutputNetFlowLogDeinit(OutputCtx *output_ctx) } #define DEFAULT_LOG_FILENAME "netflow.json" -OutputCtx *OutputNetFlowLogInit(ConfNode *conf) +static OutputCtx *OutputNetFlowLogInit(ConfNode *conf) { SCLogInfo("hi"); LogFileCtx *file_ctx = LogFileNewCtx(); @@ -365,7 +366,7 @@ static void OutputNetFlowLogDeinitSub(OutputCtx *output_ctx) SCFree(output_ctx); } -OutputCtx *OutputNetFlowLogInitSub(ConfNode *conf, OutputCtx *parent_ctx) +static OutputCtx *OutputNetFlowLogInitSub(ConfNode *conf, OutputCtx *parent_ctx) { OutputJsonCtx *ojc = parent_ctx->data; @@ -388,7 +389,7 @@ OutputCtx *OutputNetFlowLogInitSub(ConfNode *conf, OutputCtx *parent_ctx) } #define OUTPUT_BUFFER_SIZE 65535 -static TmEcode JsonNetFlowLogThreadInit(ThreadVars *t, void *initdata, void **data) +static TmEcode JsonNetFlowLogThreadInit(ThreadVars *t, const void *initdata, void **data) { JsonNetFlowLogThread *aft = SCMalloc(sizeof(JsonNetFlowLogThread)); if (unlikely(aft == NULL)) diff --git a/src/output-json-smtp.c b/src/output-json-smtp.c index 6bec700e16..e736014b20 100644 --- a/src/output-json-smtp.c +++ b/src/output-json-smtp.c @@ -49,6 +49,7 @@ #include "util-time.h" #include "output-json.h" +#include "output-json-smtp.h" #include "output-json-email-common.h" #ifdef HAVE_LIBJANSSON @@ -150,7 +151,7 @@ static void OutputSmtpLogDeInitCtxSub(OutputCtx *output_ctx) } #define DEFAULT_LOG_FILENAME "smtp.json" -OutputCtx *OutputSmtpLogInit(ConfNode *conf) +static OutputCtx *OutputSmtpLogInit(ConfNode *conf) { LogFileCtx *file_ctx = LogFileNewCtx(); if(file_ctx == NULL) { @@ -215,7 +216,7 @@ static OutputCtx *OutputSmtpLogInitSub(ConfNode *conf, OutputCtx *parent_ctx) } #define OUTPUT_BUFFER_SIZE 65535 -static TmEcode JsonSmtpLogThreadInit(ThreadVars *t, void *initdata, void **data) +static TmEcode JsonSmtpLogThreadInit(ThreadVars *t, const void *initdata, void **data) { JsonEmailLogThread *aft = SCMalloc(sizeof(JsonEmailLogThread)); if (unlikely(aft == NULL)) diff --git a/src/output-json-ssh.c b/src/output-json-ssh.c index db3c8ed028..17c0e72b3a 100644 --- a/src/output-json-ssh.c +++ b/src/output-json-ssh.c @@ -48,6 +48,7 @@ #include "util-crypt.h" #include "output-json.h" +#include "output-json-ssh.h" #ifdef HAVE_LIBJANSSON @@ -129,7 +130,7 @@ static int JsonSshLogger(ThreadVars *tv, void *thread_data, const Packet *p, } #define OUTPUT_BUFFER_SIZE 65535 -static TmEcode JsonSshLogThreadInit(ThreadVars *t, void *initdata, void **data) +static TmEcode JsonSshLogThreadInit(ThreadVars *t, const void *initdata, void **data) { JsonSshLogThread *aft = SCMalloc(sizeof(JsonSshLogThread)); if (unlikely(aft == NULL)) @@ -181,7 +182,7 @@ static void OutputSshLogDeinit(OutputCtx *output_ctx) } #define DEFAULT_LOG_FILENAME "ssh.json" -OutputCtx *OutputSshLogInit(ConfNode *conf) +static OutputCtx *OutputSshLogInit(ConfNode *conf) { LogFileCtx *file_ctx = LogFileNewCtx(); if(file_ctx == NULL) { @@ -223,7 +224,7 @@ static void OutputSshLogDeinitSub(OutputCtx *output_ctx) SCFree(output_ctx); } -OutputCtx *OutputSshLogInitSub(ConfNode *conf, OutputCtx *parent_ctx) +static OutputCtx *OutputSshLogInitSub(ConfNode *conf, OutputCtx *parent_ctx) { OutputJsonCtx *ojc = parent_ctx->data; diff --git a/src/output-json-stats.c b/src/output-json-stats.c index 16bf629c91..436d621ac4 100644 --- a/src/output-json-stats.c +++ b/src/output-json-stats.c @@ -102,8 +102,9 @@ json_t *StatsToJSON(const StatsTable *st, uint8_t flags) } /* Uptime, in seconds. */ + double up_time_d = difftime(tval.tv_sec, st->start_time); json_object_set_new(js_stats, "uptime", - json_integer((int)difftime(tval.tv_sec, st->start_time))); + json_integer((int)up_time_d)); uint32_t u = 0; if (flags & JSON_STATS_TOTALS) { @@ -207,7 +208,7 @@ static int JsonStatsLogger(ThreadVars *tv, void *thread_data, const StatsTable * } #define OUTPUT_BUFFER_SIZE 65535 -static TmEcode JsonStatsLogThreadInit(ThreadVars *t, void *initdata, void **data) +static TmEcode JsonStatsLogThreadInit(ThreadVars *t, const void *initdata, void **data) { JsonStatsLogThread *aft = SCMalloc(sizeof(JsonStatsLogThread)); if (unlikely(aft == NULL)) @@ -261,7 +262,7 @@ static void OutputStatsLogDeinit(OutputCtx *output_ctx) } #define DEFAULT_LOG_FILENAME "stats.json" -OutputCtx *OutputStatsLogInit(ConfNode *conf) +static OutputCtx *OutputStatsLogInit(ConfNode *conf) { LogFileCtx *file_ctx = LogFileNewCtx(); if(file_ctx == NULL) { @@ -321,7 +322,7 @@ static void OutputStatsLogDeinitSub(OutputCtx *output_ctx) SCFree(output_ctx); } -OutputCtx *OutputStatsLogInitSub(ConfNode *conf, OutputCtx *parent_ctx) +static OutputCtx *OutputStatsLogInitSub(ConfNode *conf, OutputCtx *parent_ctx) { AlertJsonThread *ajt = parent_ctx->data; diff --git a/src/output-json-template.c b/src/output-json-template.c index 3747121f58..6ff28f1a08 100644 --- a/src/output-json-template.c +++ b/src/output-json-template.c @@ -51,6 +51,7 @@ #include "app-layer-parser.h" #include "app-layer-template.h" +#include "output-json-template.h" #ifdef HAVE_LIBJANSSON @@ -149,7 +150,7 @@ static OutputCtx *OutputTemplateLogInitSub(ConfNode *conf, #define OUTPUT_BUFFER_SIZE 65535 -static TmEcode JsonTemplateLogThreadInit(ThreadVars *t, void *initdata, void **data) +static TmEcode JsonTemplateLogThreadInit(ThreadVars *t, const void *initdata, void **data) { LogTemplateLogThread *thread = SCCalloc(1, sizeof(*thread)); if (unlikely(thread == NULL)) { diff --git a/src/output-json-tls.c b/src/output-json-tls.c index fe7ee36843..5184373d65 100644 --- a/src/output-json-tls.c +++ b/src/output-json-tls.c @@ -48,6 +48,7 @@ #include "util-crypt.h" #include "output-json.h" +#include "output-json-tls.h" #ifdef HAVE_LIBJANSSON @@ -78,7 +79,7 @@ SC_ATOMIC_DECLARE(unsigned int, cert_id); #define LOG_TLS_FIELD_SESSION_RESUMED (1 << 10) typedef struct { - char *name; + const char *name; uint64_t flag; } TlsFields; @@ -391,7 +392,7 @@ static int JsonTlsLogger(ThreadVars *tv, void *thread_data, const Packet *p, return 0; } -static TmEcode JsonTlsLogThreadInit(ThreadVars *t, void *initdata, void **data) +static TmEcode JsonTlsLogThreadInit(ThreadVars *t, const void *initdata, void **data) { JsonTlsLogThread *aft = SCMalloc(sizeof(JsonTlsLogThread)); if (unlikely(aft == NULL)) { @@ -495,7 +496,7 @@ static OutputTlsCtx *OutputTlsInitCtx(ConfNode *conf) return tls_ctx; } -OutputCtx *OutputTlsLogInit(ConfNode *conf) +static OutputCtx *OutputTlsLogInit(ConfNode *conf) { LogFileCtx *file_ctx = LogFileNewCtx(); if (file_ctx == NULL) { @@ -538,7 +539,7 @@ static void OutputTlsLogDeinitSub(OutputCtx *output_ctx) SCFree(output_ctx); } -OutputCtx *OutputTlsLogInitSub(ConfNode *conf, OutputCtx *parent_ctx) +static OutputCtx *OutputTlsLogInitSub(ConfNode *conf, OutputCtx *parent_ctx) { OutputJsonCtx *ojc = parent_ctx->data; diff --git a/src/output-json-vars.c b/src/output-json-vars.c index c0747ca9ff..14961d23e4 100644 --- a/src/output-json-vars.c +++ b/src/output-json-vars.c @@ -53,6 +53,7 @@ #include "output.h" #include "output-json.h" +#include "output-json-vars.h" #include "util-byte.h" #include "util-privs.h" @@ -110,7 +111,7 @@ static int JsonVarsLogCondition(ThreadVars *tv, const Packet *p) } #define OUTPUT_BUFFER_SIZE 65535 -static TmEcode JsonVarsLogThreadInit(ThreadVars *t, void *initdata, void **data) +static TmEcode JsonVarsLogThreadInit(ThreadVars *t, const void *initdata, void **data) { JsonVarsLogThread *aft = SCMalloc(sizeof(JsonVarsLogThread)); if (unlikely(aft == NULL)) diff --git a/src/output-json.c b/src/output-json.c index 7df5660a2c..a20b0df6af 100644 --- a/src/output-json.c +++ b/src/output-json.c @@ -540,7 +540,7 @@ OutputCtx *OutputJsonInitCtx(ConfNode *conf) "Please set sensor-name globally."); } else { - (void)ConfGet("sensor-name", (char **)&sensor_name); + (void)ConfGet("sensor-name", &sensor_name); } if (unlikely(json_ctx == NULL)) { diff --git a/src/output-lua.c b/src/output-lua.c index 081a0bd441..bd9e6f2d46 100644 --- a/src/output-lua.c +++ b/src/output-lua.c @@ -49,6 +49,8 @@ #include "util-logopenfile.h" #include "util-time.h" +#include "output-lua.h" + #ifdef HAVE_LUA #include @@ -84,7 +86,7 @@ typedef struct LogLuaThreadCtx_ { LogLuaCtx *lua_ctx; } LogLuaThreadCtx; -static TmEcode LuaLogThreadInit(ThreadVars *t, void *initdata, void **data); +static TmEcode LuaLogThreadInit(ThreadVars *t, const void *initdata, void **data); static TmEcode LuaLogThreadDeinit(ThreadVars *t, void *data); /** \internal @@ -876,7 +878,7 @@ static void OutputLuaLogDoDeinit(LogLuaCtx *lua_ctx) * * Currently only stores a pointer to the global LogLuaCtx */ -static TmEcode LuaLogThreadInit(ThreadVars *t, void *initdata, void **data) +static TmEcode LuaLogThreadInit(ThreadVars *t, const void *initdata, void **data) { LogLuaThreadCtx *td = SCMalloc(sizeof(*td)); if (unlikely(td == NULL)) diff --git a/src/output-packet.c b/src/output-packet.c index fe4cc2fee8..2d5d302786 100644 --- a/src/output-packet.c +++ b/src/output-packet.c @@ -129,7 +129,7 @@ static TmEcode OutputPacketLog(ThreadVars *tv, Packet *p, void *thread_data) /** \brief thread init for the packet logger * This will run the thread init functions for the individual registered * loggers */ -static TmEcode OutputPacketLogThreadInit(ThreadVars *tv, void *initdata, void **data) +static TmEcode OutputPacketLogThreadInit(ThreadVars *tv, const void *initdata, void **data) { OutputLoggerThreadData *td = SCMalloc(sizeof(*td)); if (td == NULL) diff --git a/src/output-stats.c b/src/output-stats.c index 2eb9c9323f..58c4570978 100644 --- a/src/output-stats.c +++ b/src/output-stats.c @@ -116,7 +116,7 @@ TmEcode OutputStatsLog(ThreadVars *tv, void *thread_data, StatsTable *st) /** \brief thread init for the tx logger * This will run the thread init functions for the individual registered * loggers */ -static TmEcode OutputStatsLogThreadInit(ThreadVars *tv, void *initdata, void **data) +static TmEcode OutputStatsLogThreadInit(ThreadVars *tv, const void *initdata, void **data) { OutputLoggerThreadData *td = SCMalloc(sizeof(*td)); if (td == NULL) diff --git a/src/output-streaming.c b/src/output-streaming.c index c32b113d2e..bab641098a 100644 --- a/src/output-streaming.c +++ b/src/output-streaming.c @@ -104,7 +104,7 @@ typedef struct StreamerCallbackData_ { enum OutputStreamingType type; } StreamerCallbackData; -int Streamer(void *cbdata, Flow *f, const uint8_t *data, uint32_t data_len, uint64_t tx_id, uint8_t flags) +static int Streamer(void *cbdata, Flow *f, const uint8_t *data, uint32_t data_len, uint64_t tx_id, uint8_t flags) { StreamerCallbackData *streamer_cbdata = (StreamerCallbackData *)cbdata; BUG_ON(streamer_cbdata == NULL); @@ -146,7 +146,7 @@ int Streamer(void *cbdata, Flow *f, const uint8_t *data, uint32_t data_len, uint * - Invoke Streamer */ -int HttpBodyIterator(Flow *f, int close, void *cbdata, uint8_t iflags) +static int HttpBodyIterator(Flow *f, int close, void *cbdata, uint8_t iflags) { SCLogDebug("called with %p, %d, %p, %02x", f, close, cbdata, iflags); @@ -247,7 +247,7 @@ int HttpBodyIterator(Flow *f, int close, void *cbdata, uint8_t iflags) return 0; } -int StreamIterator(Flow *f, TcpStream *stream, int close, void *cbdata, uint8_t iflags) +static int StreamIterator(Flow *f, TcpStream *stream, int close, void *cbdata, uint8_t iflags) { SCLogDebug("called with %p, %d, %p, %02x", f, close, cbdata, iflags); int logged = 0; @@ -367,7 +367,7 @@ static TmEcode OutputStreamingLog(ThreadVars *tv, Packet *p, void *thread_data) /** \brief thread init for the tx logger * This will run the thread init functions for the individual registered * loggers */ -static TmEcode OutputStreamingLogThreadInit(ThreadVars *tv, void *initdata, void **data) { +static TmEcode OutputStreamingLogThreadInit(ThreadVars *tv, const void *initdata, void **data) { OutputLoggerThreadData *td = SCMalloc(sizeof(*td)); if (td == NULL) return TM_ECODE_FAILED; diff --git a/src/output-tx.c b/src/output-tx.c index 482fa087d9..74afe11c10 100644 --- a/src/output-tx.c +++ b/src/output-tx.c @@ -56,7 +56,7 @@ typedef struct OutputTxLogger_ { uint32_t id; int tc_log_progress; int ts_log_progress; - TmEcode (*ThreadInit)(ThreadVars *, void *, void **); + TmEcode (*ThreadInit)(ThreadVars *, const void *, void **); TmEcode (*ThreadDeinit)(ThreadVars *, void *); void (*ThreadExitPrintStats)(ThreadVars *, void *); } OutputTxLogger; @@ -279,7 +279,7 @@ end: /** \brief thread init for the tx logger * This will run the thread init functions for the individual registered * loggers */ -static TmEcode OutputTxLogThreadInit(ThreadVars *tv, void *initdata, void **data) +static TmEcode OutputTxLogThreadInit(ThreadVars *tv, const void *initdata, void **data) { OutputLoggerThreadData *td = SCMalloc(sizeof(*td)); if (td == NULL) diff --git a/src/output.c b/src/output.c index 6ee3dc15cb..8a22b0ed0f 100644 --- a/src/output.c +++ b/src/output.c @@ -232,7 +232,7 @@ error: * * \retval Returns 0 on success, -1 on failure. */ -void OutputRegisterTxModuleWrapper(LoggerId id, const char *name, +static void OutputRegisterTxModuleWrapper(LoggerId id, const char *name, const char *conf_name, OutputInitFunc InitFunc, AppProto alproto, TxLogger TxLogFunc, int tc_log_progress, int ts_log_progress, TxLoggerCondition TxLogCondition, ThreadInitFunc ThreadInit, @@ -269,7 +269,7 @@ error: exit(EXIT_FAILURE); } -void OutputRegisterTxSubModuleWrapper(LoggerId id, const char *parent_name, +static void OutputRegisterTxSubModuleWrapper(LoggerId id, const char *parent_name, const char *name, const char *conf_name, OutputInitSubFunc InitFunc, AppProto alproto, TxLogger TxLogFunc, int tc_log_progress, int ts_log_progress, TxLoggerCondition TxLogCondition, @@ -919,7 +919,7 @@ TmEcode OutputLoggerLog(ThreadVars *tv, Packet *p, void *thread_data) return TM_ECODE_OK; } -TmEcode OutputLoggerThreadInit(ThreadVars *tv, void *initdata, void **data) +TmEcode OutputLoggerThreadInit(ThreadVars *tv, const void *initdata, void **data) { LoggerThreadStore *thread_store = SCCalloc(1, sizeof(*thread_store)); if (thread_store == NULL) { diff --git a/src/output.h b/src/output.h index 59469f4ae6..4c5a770fe7 100644 --- a/src/output.h +++ b/src/output.h @@ -195,7 +195,7 @@ void OutputRegisterRootLogger(ThreadInitFunc ThreadInit, void TmModuleLoggerRegister(void); TmEcode OutputLoggerLog(ThreadVars *, Packet *, void *); -TmEcode OutputLoggerThreadInit(ThreadVars *, void *, void **); +TmEcode OutputLoggerThreadInit(ThreadVars *, const void *, void **); TmEcode OutputLoggerThreadDeinit(ThreadVars *, void *); void OutputLoggerExitPrintStats(ThreadVars *, void *); diff --git a/src/packet-queue.c b/src/packet-queue.c index cb766ff1b6..9f5bf43090 100644 --- a/src/packet-queue.c +++ b/src/packet-queue.c @@ -32,6 +32,9 @@ #include "pkt-var.h" #ifdef DEBUG +void PacketQueueValidateDebug(PacketQueue *q); +void PacketQueueValidate(PacketQueue *q); + void PacketQueueValidateDebug(PacketQueue *q) { SCLogDebug("q->len %u, q->top %p, q->bot %p", q->len, q->top, q->bot); diff --git a/src/reputation.c b/src/reputation.c index 232871817c..a364c7c01f 100644 --- a/src/reputation.c +++ b/src/reputation.c @@ -177,7 +177,7 @@ void SRepReloadComplete(void) /** \brief Set effective reputation version after * reputation initialization is complete. */ -void SRepInitComplete(void) +static void SRepInitComplete(void) { (void) SC_ATOMIC_SET(srep_eversion, 1); SCLogDebug("effective Reputation version %u", SRepGetEffectiveVersion()); @@ -337,17 +337,6 @@ static int SRepSplitLine(SRepCIDRTree *cidr_ctx, char *line, Address *ip, uint8_ #define SREP_SHORTNAME_LEN 32 static char srep_cat_table[SREP_MAX_CATS][SREP_SHORTNAME_LEN]; -int SRepCatValid(uint8_t cat) -{ - if (cat >= SREP_MAX_CATS) - return 0; - - if (strlen(srep_cat_table[cat]) == 0) - return 0; - - return 1; -} - uint8_t SRepCatGetByShortname(char *shortname) { uint8_t cat; @@ -359,7 +348,7 @@ uint8_t SRepCatGetByShortname(char *shortname) return 0; } -static int SRepLoadCatFile(char *filename) +static int SRepLoadCatFile(const char *filename) { int r = 0; FILE *fp = fopen(filename, "r"); @@ -543,7 +532,7 @@ int SRepLoadFileFromFD(SRepCIDRTree *cidr_ctx, FILE *fp) */ static char *SRepCompleteFilePath(char *file) { - char *defaultpath = NULL; + const char *defaultpath = NULL; char *path = NULL; /* Path not specified */ @@ -593,7 +582,7 @@ int SRepInit(DetectEngineCtx *de_ctx) ConfNode *file = NULL; int r = 0; char *sfile = NULL; - char *filename = NULL; + const char *filename = NULL; int init = 0; int i = 0; @@ -911,6 +900,7 @@ end: } #endif +#if 0 /** Global trees that hold host reputation for IPV4 and IPV6 hosts */ IPReputationCtx *rep_ctx; @@ -2317,11 +2307,13 @@ error: } #endif /* UNITTESTS */ +#endif /** Register the following unittests for the Reputation module */ void SCReputationRegisterTests(void) { #ifdef UNITTESTS +#if 0 UtRegisterTest("SCReputationTestIPV4AddRemoveHost01", SCReputationTestIPV4AddRemoveHost01); UtRegisterTest("SCReputationTestIPV6AddRemoveHost01", @@ -2339,7 +2331,7 @@ void SCReputationRegisterTests(void) SCReputationTestIPV4Update01); UtRegisterTest("SCReputationTestIPV6Update01", SCReputationTestIPV6Update01); - +#endif UtRegisterTest("SRepTest01", SRepTest01); UtRegisterTest("SRepTest02", SRepTest02); UtRegisterTest("SRepTest03", SRepTest03); diff --git a/src/reputation.h b/src/reputation.h index 347731fe7b..2602459754 100644 --- a/src/reputation.h +++ b/src/reputation.h @@ -84,10 +84,11 @@ typedef struct IPReputationCtx_ { uint8_t SRepCIDRGetIPRepSrc(SRepCIDRTree *cidr_ctx, Packet *p, uint8_t cat, uint32_t version); uint8_t SRepCIDRGetIPRepDst(SRepCIDRTree *cidr_ctx, Packet *p, uint8_t cat, uint32_t version); -void SRepResetVersion(); +void SRepResetVersion(void); int SRepLoadCatFileFromFD(FILE *fp); int SRepLoadFileFromFD(SRepCIDRTree *cidr_ctx, FILE *fp); +#if 0 /** Reputation Data */ //TODO: Add a timestamp here to know the last update of this reputation. typedef struct Reputation_ { @@ -118,6 +119,7 @@ IPReputationCtx *SCReputationInitCtx(void); void SCReputationFreeCtx(IPReputationCtx *); void SCReputationPrint(Reputation *); +#endif void SCReputationRegisterTests(void); #endif /* __REPUTATION_H__ */ diff --git a/src/runmode-af-packet.c b/src/runmode-af-packet.c index 959617889b..cbd27c9378 100644 --- a/src/runmode-af-packet.c +++ b/src/runmode-af-packet.c @@ -86,7 +86,7 @@ void RunModeIdsAFPRegister(void) #ifdef HAVE_AF_PACKET -void AFPDerefConfig(void *conf) +static void AFPDerefConfig(void *conf) { AFPIfaceConfig *pfp = (AFPIfaceConfig *)conf; /* Pcap config is used only once but cost of this low. */ @@ -109,19 +109,19 @@ static int cluster_id_auto = 1; * * \return a AFPIfaceConfig corresponding to the interface name */ -void *ParseAFPConfig(const char *iface) +static void *ParseAFPConfig(const char *iface) { - char *threadsstr = NULL; + const char *threadsstr = NULL; ConfNode *if_root; ConfNode *if_default = NULL; ConfNode *af_packet_node; - char *tmpclusterid; - char *tmpctype; - char *copymodestr; + const char *tmpclusterid; + const char *tmpctype; + const char *copymodestr; intmax_t value; int boolval; - char *bpf_filter = NULL; - char *out_iface = NULL; + const char *bpf_filter = NULL; + const char *out_iface = NULL; int cluster_type = PACKET_FANOUT_HASH; if (iface == NULL) { @@ -488,7 +488,7 @@ finalize: return aconf; } -int AFPConfigGeThreadsCount(void *conf) +static int AFPConfigGeThreadsCount(void *conf) { AFPIfaceConfig *afp = (AFPIfaceConfig *)conf; return afp->threads; @@ -518,7 +518,7 @@ int AFPRunModeIsIPS() SCLogError(SC_ERR_INVALID_VALUE, "Problem with config file"); return 0; } - char *copymodestr = NULL; + const char *copymodestr = NULL; if_root = ConfFindDeviceConfig(af_packet_node, live_dev); if (if_root == NULL) { @@ -549,7 +549,7 @@ int AFPRunModeIsIPS() return 0; } if_root = ConfNodeLookupKeyValue(af_packet_node, "interface", live_dev); - char *copymodestr = NULL; + const char *copymodestr = NULL; if (if_root == NULL) { if (if_default == NULL) { @@ -582,7 +582,7 @@ int RunModeIdsAFPAutoFp(void) /* We include only if AF_PACKET is enabled */ #ifdef HAVE_AF_PACKET int ret; - char *live_dev = NULL; + const char *live_dev = NULL; RunModeInitialize(); @@ -627,7 +627,7 @@ int RunModeIdsAFPSingle(void) SCEnter(); #ifdef HAVE_AF_PACKET int ret; - char *live_dev = NULL; + const char *live_dev = NULL; RunModeInitialize(); TimeModeSetLive(); @@ -672,7 +672,7 @@ int RunModeIdsAFPWorkers(void) SCEnter(); #ifdef HAVE_AF_PACKET int ret; - char *live_dev = NULL; + const char *live_dev = NULL; RunModeInitialize(); TimeModeSetLive(); diff --git a/src/runmode-af-packet.h b/src/runmode-af-packet.h index 79fe436a69..ab190a9ecd 100644 --- a/src/runmode-af-packet.h +++ b/src/runmode-af-packet.h @@ -28,6 +28,6 @@ int RunModeIdsAFPAutoFp(void); int RunModeIdsAFPWorkers(void); void RunModeIdsAFPRegister(void); const char *RunModeAFPGetDefaultMode(void); -int AFPRunModeIsIPS(); +int AFPRunModeIsIPS(void); #endif /* __RUNMODE_AF_PACKET_H__ */ diff --git a/src/runmode-erf-file.c b/src/runmode-erf-file.c index 76bc492147..a5354bb422 100644 --- a/src/runmode-erf-file.c +++ b/src/runmode-erf-file.c @@ -56,7 +56,7 @@ void RunModeErfFileRegister(void) int RunModeErfFileSingle(void) { - char *file; + const char *file; SCEnter(); @@ -122,7 +122,7 @@ int RunModeErfFileAutoFp(void) RunModeInitialize(); - char *file = NULL; + const char *file = NULL; if (ConfGet("erf-file.file", &file) == 0) { SCLogError(SC_ERR_RUNMODE, "Failed retrieving erf-file.file from config"); diff --git a/src/runmode-netmap.c b/src/runmode-netmap.c index 3ea6c7a55c..5a95d7e350 100644 --- a/src/runmode-netmap.c +++ b/src/runmode-netmap.c @@ -110,7 +110,7 @@ static int ParseNetmapSettings(NetmapIfaceSettings *ns, const char *iface, } } - char *bpf_filter = NULL; + const char *bpf_filter = NULL; if (ConfGet("bpf-filter", &bpf_filter) == 1) { if (strlen(bpf_filter) > 0) { ns->bpf_filter = bpf_filter; @@ -131,7 +131,7 @@ static int ParseNetmapSettings(NetmapIfaceSettings *ns, const char *iface, if_default = NULL; } - char *threadsstr = NULL; + const char *threadsstr = NULL; if (ConfGetChildValueWithDefault(if_root, if_default, "threads", &threadsstr) != 1) { ns->threads = 0; } else { @@ -160,7 +160,7 @@ static int ParseNetmapSettings(NetmapIfaceSettings *ns, const char *iface, ns->promisc = 0; } - char *tmpctype; + const char *tmpctype; if (ConfGetChildValueWithDefault(if_root, if_default, "checksum-checks", &tmpctype) == 1) { @@ -176,7 +176,7 @@ static int ParseNetmapSettings(NetmapIfaceSettings *ns, const char *iface, } } - char *copymodestr; + const char *copymodestr; if (ConfGetChildValueWithDefault(if_root, if_default, "copy-mode", ©modestr) == 1) { @@ -232,7 +232,7 @@ static void *ParseNetmapConfig(const char *iface_name) ConfNode *if_root = NULL; ConfNode *if_default = NULL; ConfNode *netmap_node; - char *out_iface = NULL; + const char *out_iface = NULL; if (iface_name == NULL) { return NULL; @@ -309,7 +309,7 @@ int NetmapRunModeIsIPS() SCLogError(SC_ERR_INVALID_VALUE, "Problem with config file"); return 0; } - char *copymodestr = NULL; + const char *copymodestr = NULL; if_root = ConfNodeLookupKeyValue(netmap_node, "interface", live_dev); if (if_root == NULL) { @@ -340,7 +340,7 @@ int NetmapRunModeIsIPS() return 0; } if_root = ConfNodeLookupKeyValue(netmap_node, "interface", live_dev); - char *copymodestr = NULL; + const char *copymodestr = NULL; if (if_root == NULL) { if (if_default == NULL) { @@ -371,7 +371,7 @@ int RunModeIdsNetmapAutoFp(void) #ifdef HAVE_NETMAP int ret; - char *live_dev = NULL; + const char *live_dev = NULL; RunModeInitialize(); @@ -407,7 +407,7 @@ int RunModeIdsNetmapSingle(void) #ifdef HAVE_NETMAP int ret; - char *live_dev = NULL; + const char *live_dev = NULL; RunModeInitialize(); TimeModeSetLive(); @@ -443,7 +443,7 @@ int RunModeIdsNetmapWorkers(void) #ifdef HAVE_NETMAP int ret; - char *live_dev = NULL; + const char *live_dev = NULL; RunModeInitialize(); TimeModeSetLive(); diff --git a/src/runmode-netmap.h b/src/runmode-netmap.h index 988c349ab5..80e3a7ac5c 100644 --- a/src/runmode-netmap.h +++ b/src/runmode-netmap.h @@ -28,6 +28,6 @@ int RunModeIdsNetmapAutoFp(void); int RunModeIdsNetmapWorkers(void); void RunModeIdsNetmapRegister(void); const char *RunModeNetmapGetDefaultMode(void); -int NetmapRunModeIsIPS(); +int NetmapRunModeIsIPS(void); #endif /* __RUNMODE_NETMAP_H__ */ diff --git a/src/runmode-nflog.c b/src/runmode-nflog.c index f312ad6420..578eb715d5 100644 --- a/src/runmode-nflog.c +++ b/src/runmode-nflog.c @@ -56,14 +56,14 @@ void RunModeIdsNflogRegister(void) return; } - +#ifdef HAVE_NFLOG static void NflogDerefConfig(void *data) { NflogGroupConfig *nflogconf = (NflogGroupConfig *)data; SCFree(nflogconf); } -void *ParseNflogConfig(const char *group) +static void *ParseNflogConfig(const char *group) { ConfNode *group_root; ConfNode *group_default = NULL; @@ -163,11 +163,12 @@ void *ParseNflogConfig(const char *group) return nflogconf; } -int NflogConfigGeThreadsCount(void *conf) +static int NflogConfigGeThreadsCount(void *conf) { /* for each nflog group there is no reason to use more than 1 thread */ return 1; } +#endif int RunModeIdsNflogAutoFp(void) { diff --git a/src/runmode-pcap-file.c b/src/runmode-pcap-file.c index 6bf44ae7d5..29de79dc8f 100644 --- a/src/runmode-pcap-file.c +++ b/src/runmode-pcap-file.c @@ -61,7 +61,7 @@ void RunModeFilePcapRegister(void) */ int RunModeFilePcapSingle(void) { - char *file = NULL; + const char *file = NULL; char tname[TM_THREAD_NAME_MAX]; if (ConfGet("pcap-file.file", &file) == 0) { @@ -155,7 +155,7 @@ int RunModeFilePcapAutoFp(void) RunModeInitialize(); - char *file = NULL; + const char *file = NULL; if (ConfGet("pcap-file.file", &file) == 0) { SCLogError(SC_ERR_RUNMODE, "Failed retrieving pcap-file from Conf"); exit(EXIT_FAILURE); diff --git a/src/runmode-pcap.c b/src/runmode-pcap.c index bcd8358ece..823af3b334 100644 --- a/src/runmode-pcap.c +++ b/src/runmode-pcap.c @@ -62,7 +62,7 @@ void RunModeIdsPcapRegister(void) return; } -void PcapDerefConfig(void *conf) +static void PcapDerefConfig(void *conf) { PcapIfaceConfig *pfp = (PcapIfaceConfig *)conf; /* Pcap config is used only once but cost of this low. */ @@ -71,16 +71,15 @@ void PcapDerefConfig(void *conf) } } - -void *ParsePcapConfig(const char *iface) +static void *ParsePcapConfig(const char *iface) { - char *threadsstr = NULL; + const char *threadsstr = NULL; ConfNode *if_root; ConfNode *if_default = NULL; ConfNode *pcap_node; PcapIfaceConfig *aconf = SCMalloc(sizeof(*aconf)); - char *tmpbpf; - char *tmpctype; + const char *tmpbpf; + const char *tmpctype; intmax_t value; int promisc = 0; intmax_t snaplen = 0; @@ -151,7 +150,7 @@ void *ParsePcapConfig(const char *iface) (void) SC_ATOMIC_ADD(aconf->ref, aconf->threads); if (aconf->buffer_size == 0) { - char *s_limit = NULL; + const char *s_limit = NULL; int ret; ret = ConfGetChildValueWithDefault(if_root, if_default, "buffer-size", &s_limit); if (ret == 1 && s_limit) { @@ -218,7 +217,7 @@ void *ParsePcapConfig(const char *iface) return aconf; } -int PcapConfigGeThreadsCount(void *conf) +static int PcapConfigGeThreadsCount(void *conf) { PcapIfaceConfig *pfp = (PcapIfaceConfig *)conf; return pfp->threads; @@ -230,7 +229,7 @@ int PcapConfigGeThreadsCount(void *conf) int RunModeIdsPcapSingle(void) { int ret; - char *live_dev = NULL; + const char *live_dev = NULL; SCEnter(); @@ -272,7 +271,7 @@ int RunModeIdsPcapSingle(void) int RunModeIdsPcapAutoFp(void) { int ret; - char *live_dev = NULL; + const char *live_dev = NULL; SCEnter(); RunModeInitialize(); @@ -304,7 +303,7 @@ int RunModeIdsPcapAutoFp(void) int RunModeIdsPcapWorkers(void) { int ret; - char *live_dev = NULL; + const char *live_dev = NULL; SCEnter(); RunModeInitialize(); diff --git a/src/runmode-pfring.c b/src/runmode-pfring.c index 5332252570..dcfe322a6c 100644 --- a/src/runmode-pfring.c +++ b/src/runmode-pfring.c @@ -65,7 +65,8 @@ void RunModeIdsPfringRegister(void) return; } -void PfringDerefConfig(void *conf) +#ifdef HAVE_PFRING +static void PfringDerefConfig(void *conf) { PfringIfaceConfig *pfp = (PfringIfaceConfig *)conf; if (SC_ATOMIC_SUB(pfp->ref, 1) == 0) { @@ -89,15 +90,13 @@ void PfringDerefConfig(void *conf) * * \return a PfringIfaceConfig corresponding to the interface name */ -void *OldParsePfringConfig(const char *iface) +static void *OldParsePfringConfig(const char *iface) { char *threadsstr = NULL; PfringIfaceConfig *pfconf = SCMalloc(sizeof(*pfconf)); char *tmpclusterid; -#ifdef HAVE_PFRING char *tmpctype = NULL; cluster_type default_ctype = CLUSTER_ROUND_ROBIN; -#endif if (unlikely(pfconf == NULL)) { return NULL; @@ -112,9 +111,7 @@ void *OldParsePfringConfig(const char *iface) pfconf->flags = 0; pfconf->threads = 1; pfconf->cluster_id = 1; -#ifdef HAVE_PFRING pfconf->ctype = default_ctype; -#endif pfconf->DerefFunc = PfringDerefConfig; pfconf->checksum_mode = CHECKSUM_VALIDATION_AUTO; SC_ATOMIC_INIT(pfconf->ref); @@ -148,7 +145,6 @@ void *OldParsePfringConfig(const char *iface) SCLogDebug("Going to use cluster-id %" PRId32, pfconf->cluster_id); } -#ifdef HAVE_PFRING if (strncmp(pfconf->iface, "zc", 2) == 0) { SCLogInfo("ZC interface detected, not setting cluster type for PF_RING (iface %s)", pfconf->iface); @@ -170,7 +166,6 @@ void *OldParsePfringConfig(const char *iface) SCFree(pfconf); return NULL; } -#endif /* HAVE_PFRING */ return pfconf; } @@ -188,7 +183,7 @@ void *OldParsePfringConfig(const char *iface) * * \return a PfringIfaceConfig corresponding to the interface name */ -void *ParsePfringConfig(const char *iface) +static void *ParsePfringConfig(const char *iface) { char *threadsstr = NULL; ConfNode *if_root; @@ -197,10 +192,8 @@ void *ParsePfringConfig(const char *iface) PfringIfaceConfig *pfconf = SCMalloc(sizeof(*pfconf)); char *tmpclusterid; char *tmpctype = NULL; -#ifdef HAVE_PFRING cluster_type default_ctype = CLUSTER_ROUND_ROBIN; int getctype = 0; -#endif char *bpf_filter = NULL; if (unlikely(pfconf == NULL)) { @@ -216,9 +209,7 @@ void *ParsePfringConfig(const char *iface) strlcpy(pfconf->iface, iface, sizeof(pfconf->iface)); pfconf->threads = 1; pfconf->cluster_id = 1; -#ifdef HAVE_PFRING pfconf->ctype = (cluster_type)default_ctype; -#endif pfconf->DerefFunc = PfringDerefConfig; SC_ATOMIC_INIT(pfconf->ref); (void) SC_ATOMIC_ADD(pfconf->ref, 1); @@ -314,7 +305,6 @@ void *ParsePfringConfig(const char *iface) } } -#ifdef HAVE_PFRING if (ConfGet("pfring.cluster-type", &tmpctype) == 1) { SCLogDebug("Going to use command-line provided cluster-type"); getctype = 1; @@ -350,7 +340,6 @@ void *ParsePfringConfig(const char *iface) return NULL; } } -#endif /* HAVE_PFRING */ if (ConfGetChildValueWithDefault(if_root, if_default, "checksum-checks", &tmpctype) == 1) { if (strcmp(tmpctype, "auto") == 0) { pfconf->checksum_mode = CHECKSUM_VALIDATION_AUTO; @@ -368,13 +357,13 @@ void *ParsePfringConfig(const char *iface) return pfconf; } -int PfringConfigGeThreadsCount(void *conf) +static int PfringConfigGeThreadsCount(void *conf) { PfringIfaceConfig *pfp = (PfringIfaceConfig *)conf; return pfp->threads; } -int PfringConfLevel() +static int PfringConfLevel() { char *def_dev; /* 1.0 config should return a string */ @@ -386,7 +375,6 @@ int PfringConfLevel() return PFRING_CONF_V2; } -#ifdef HAVE_PFRING static int GetDevAndParser(char **live_dev, ConfigIfaceParserFunc *parser) { ConfGet("pfring.live-interface", live_dev); diff --git a/src/runmode-unittests.c b/src/runmode-unittests.c index 6bbad32cc1..daceaf12ea 100644 --- a/src/runmode-unittests.c +++ b/src/runmode-unittests.c @@ -23,6 +23,7 @@ #include "suricata-common.h" #include "config.h" #include "util-unittest.h" +#include "runmode-unittests.h" #ifdef UNITTESTS @@ -123,7 +124,6 @@ #endif /* UNITTESTS */ -void RegisterAllModules(); void TmqhSetup (void); #ifdef UNITTESTS @@ -146,6 +146,7 @@ static void RegisterUnittests(void) HostBitRegisterTests(); IPPairBitRegisterTests(); StatsRegisterTests(); + DecodeEthernetRegisterTests(); DecodePPPRegisterTests(); DecodeVLANRegisterTests(); DecodeRawRegisterTests(); @@ -230,7 +231,7 @@ static void RegisterUnittests(void) * This function is terminal and will call exit after being called. */ -void RunUnittests(int list_unittests, char *regex_arg) +void RunUnittests(int list_unittests, const char *regex_arg) { #ifdef UNITTESTS /* Initializations for global vars, queues, etc (memsets, mutex init..) */ @@ -263,7 +264,6 @@ void RunUnittests(int list_unittests, char *regex_arg) #ifdef DBG_MEM_ALLOC SCLogInfo("Memory used at startup: %"PRIdMAX, (intmax_t)global_mem); #endif - SCReputationInitCtx(); SCProtoNameInit(); TagInitCtx(); @@ -278,7 +278,7 @@ void RunUnittests(int list_unittests, char *regex_arg) StorageFinalize(); /* test and initialize the unittesting subsystem */ - if(regex_arg == NULL){ + if (regex_arg == NULL){ regex_arg = ".*"; UtRunSelftest(regex_arg); /* inits and cleans up again */ } diff --git a/src/runmode-unittests.h b/src/runmode-unittests.h index 8ccd296d58..0c5d142e91 100644 --- a/src/runmode-unittests.h +++ b/src/runmode-unittests.h @@ -24,6 +24,6 @@ #ifndef __UTIL_RUNMODE_UNITTESTS_H__ #define __UTIL_RUNMODE_UNITTESTS_H__ -int RunUnittests(int list_unittests, char *regex_arg); +void RunUnittests(int list_unittests, const char *regex_arg); #endif /* __UTIL_RUNMODE_UNITTESTS_H__ */ diff --git a/src/runmode-unix-socket.c b/src/runmode-unix-socket.c index 7d9ef8ed26..8b7276cd4f 100644 --- a/src/runmode-unix-socket.c +++ b/src/runmode-unix-socket.c @@ -196,7 +196,7 @@ static TmEcode UnixListAddFile(PcapCommand *this, * \param answer the json_t object that has to be used to answer * \param data pointer to data defining the context here a PcapCommand:: */ -TmEcode UnixSocketAddPcapFile(json_t *cmd, json_t* answer, void *data) +static TmEcode UnixSocketAddPcapFile(json_t *cmd, json_t* answer, void *data) { PcapCommand *this = (PcapCommand *) data; int ret; @@ -283,7 +283,7 @@ TmEcode UnixSocketAddPcapFile(json_t *cmd, json_t* answer, void *data) * \param this a UnixCommand:: structure * \retval 0 in case of error, 1 in case of success */ -TmEcode UnixSocketPcapFilesCheck(void *data) +static TmEcode UnixSocketPcapFilesCheck(void *data) { PcapCommand *this = (PcapCommand *) data; if (unix_manager_file_task_running == 1) { diff --git a/src/runmodes.c b/src/runmodes.c index fdedea8f18..b99d3e95e9 100644 --- a/src/runmodes.c +++ b/src/runmodes.c @@ -280,7 +280,7 @@ void RunModeDispatch(int runmode, const char *custom_mode) char *local_custom_mode = NULL; if (custom_mode == NULL) { - char *val = NULL; + const char *val = NULL; if (ConfGet("runmode", &val) != 1) { custom_mode = NULL; } else { diff --git a/src/source-af-packet.c b/src/source-af-packet.c index 2f31916208..5b13ae34c4 100644 --- a/src/source-af-packet.c +++ b/src/source-af-packet.c @@ -104,7 +104,7 @@ extern int max_pending_packets; #ifndef HAVE_AF_PACKET -TmEcode NoAFPSupportExit(ThreadVars *, void *, void **); +TmEcode NoAFPSupportExit(ThreadVars *, const void *, void **); void TmModuleReceiveAFPRegister (void) { @@ -137,7 +137,7 @@ void TmModuleDecodeAFPRegister (void) /** * \brief this function prints an error message and exits. */ -TmEcode NoAFPSupportExit(ThreadVars *tv, void *initdata, void **data) +TmEcode NoAFPSupportExit(ThreadVars *tv, const void *initdata, void **data) { SCLogError(SC_ERR_NO_AF_PACKET,"Error creating thread %s: you do not have " "support for AF_PACKET enabled, on Linux host please recompile " @@ -242,7 +242,7 @@ typedef struct AFPThreadVars_ /* socket buffer size */ int buffer_size; /* Filter */ - char *bpf_filter; + const char *bpf_filter; int promisc; @@ -267,12 +267,12 @@ typedef struct AFPThreadVars_ } AFPThreadVars; TmEcode ReceiveAFP(ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *); -TmEcode ReceiveAFPThreadInit(ThreadVars *, void *, void **); +TmEcode ReceiveAFPThreadInit(ThreadVars *, const void *, void **); void ReceiveAFPThreadExitStats(ThreadVars *, void *); TmEcode ReceiveAFPThreadDeinit(ThreadVars *, void *); TmEcode ReceiveAFPLoop(ThreadVars *tv, void *data, void *slot); -TmEcode DecodeAFPThreadInit(ThreadVars *, void *, void **); +TmEcode DecodeAFPThreadInit(ThreadVars *, const void *, void **); TmEcode DecodeAFPThreadDeinit(ThreadVars *tv, void *data); TmEcode DecodeAFP(ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *); @@ -329,7 +329,7 @@ typedef struct AFPPeersList_ { * or iface index. * */ -void AFPPeerUpdate(AFPThreadVars *ptv) +static void AFPPeerUpdate(AFPThreadVars *ptv) { if (ptv->mpeer == NULL) { return; @@ -342,7 +342,7 @@ void AFPPeerUpdate(AFPThreadVars *ptv) /** * \brief Clean and free ressource used by an ::AFPPeer */ -void AFPPeerClean(AFPPeer *peer) +static void AFPPeerClean(AFPPeer *peer) { if (peer->flags & AFP_SOCK_PROTECT) SCMutexDestroy(&peer->sock_protect); @@ -396,7 +396,7 @@ TmEcode AFPPeersListCheck() /** * \brief Declare a new AFP thread to AFP peers list. */ -TmEcode AFPPeersListAdd(AFPThreadVars *ptv) +static TmEcode AFPPeersListAdd(AFPThreadVars *ptv) { SCEnter(); AFPPeer *peer = SCMalloc(sizeof(AFPPeer)); @@ -456,7 +456,7 @@ TmEcode AFPPeersListAdd(AFPThreadVars *ptv) SCReturnInt(TM_ECODE_OK); } -int AFPPeersListWaitTurn(AFPPeer *peer) +static int AFPPeersListWaitTurn(AFPPeer *peer) { /* If turn is zero, we already have started threads once */ if (peerslist.turn == 0) @@ -467,7 +467,7 @@ int AFPPeersListWaitTurn(AFPPeer *peer) return 1; } -void AFPPeersListReachedInc() +static void AFPPeersListReachedInc(void) { if (peerslist.turn == 0) return; @@ -482,7 +482,7 @@ void AFPPeersListReachedInc() } } -static int AFPPeersListStarted() +static int AFPPeersListStarted(void) { return !peerslist.turn; } @@ -550,7 +550,7 @@ static inline void AFPDumpCounters(AFPThreadVars *ptv) * \param user pointer to AFPThreadVars * \retval TM_ECODE_FAILED on failure and TM_ECODE_OK on success */ -int AFPRead(AFPThreadVars *ptv) +static int AFPRead(AFPThreadVars *ptv) { Packet *p = NULL; /* XXX should try to use read that get directly to packet */ @@ -756,7 +756,7 @@ static TmEcode AFPWritePacket(Packet *p, int version) return TM_ECODE_OK; } -void AFPReleaseDataFromRing(Packet *p) +static void AFPReleaseDataFromRing(Packet *p) { /* Need to be in copy mode and need to detect early release where Ethernet header could not be set (and pseudo packet) */ @@ -778,7 +778,7 @@ cleanup: } #ifdef HAVE_TPACKET_V3 -void AFPReleasePacketV3(Packet *p) +static void AFPReleasePacketV3(Packet *p) { /* Need to be in copy mode and need to detect early release where Ethernet header could not be set (and pseudo packet) */ @@ -789,7 +789,7 @@ void AFPReleasePacketV3(Packet *p) } #endif -void AFPReleasePacket(Packet *p) +static void AFPReleasePacket(Packet *p) { AFPReleaseDataFromRing(p); PacketFreeOrRelease(p); @@ -804,7 +804,7 @@ void AFPReleasePacket(Packet *p) * \param user pointer to AFPThreadVars * \retval TM_ECODE_FAILED on failure and TM_ECODE_OK on success */ -int AFPReadFromRing(AFPThreadVars *ptv) +static int AFPReadFromRing(AFPThreadVars *ptv) { Packet *p = NULL; union thdr h; @@ -1068,7 +1068,7 @@ static inline int AFPWalkBlock(AFPThreadVars *ptv, struct tpacket_block_desc *pb * \param user pointer to AFPThreadVars * \retval TM_ECODE_FAILED on failure and TM_ECODE_OK on success */ -int AFPReadFromRingV3(AFPThreadVars *ptv) +static int AFPReadFromRingV3(AFPThreadVars *ptv) { #ifdef HAVE_TPACKET_V3 struct tpacket_block_desc *pbd; @@ -1138,7 +1138,7 @@ static int AFPDerefSocket(AFPPeer* peer) return 1; } -void AFPSwitchState(AFPThreadVars *ptv, int state) +static void AFPSwitchState(AFPThreadVars *ptv, int state) { ptv->afp_state = state; ptv->down_count = 0; @@ -2122,10 +2122,10 @@ TmEcode AFPSetBPFFilter(AFPThreadVars *ptv) * * \todo Create a general AFP setup function. */ -TmEcode ReceiveAFPThreadInit(ThreadVars *tv, void *initdata, void **data) +TmEcode ReceiveAFPThreadInit(ThreadVars *tv, const void *initdata, void **data) { SCEnter(); - AFPIfaceConfig *afpconfig = initdata; + AFPIfaceConfig *afpconfig = (AFPIfaceConfig *)initdata; if (initdata == NULL) { SCLogError(SC_ERR_INVALID_ARGUMENT, "initdata == NULL"); @@ -2331,7 +2331,7 @@ TmEcode DecodeAFP(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, Packet SCReturnInt(TM_ECODE_OK); } -TmEcode DecodeAFPThreadInit(ThreadVars *tv, void *initdata, void **data) +TmEcode DecodeAFPThreadInit(ThreadVars *tv, const void *initdata, void **data) { SCEnter(); DecodeThreadVars *dtv = NULL; diff --git a/src/source-af-packet.h b/src/source-af-packet.h index 513fdc9b37..d49528076c 100644 --- a/src/source-af-packet.h +++ b/src/source-af-packet.h @@ -87,8 +87,8 @@ typedef struct AFPIfaceConfig_ int flags; int copy_mode; ChecksumValidationMode checksum_mode; - char *bpf_filter; - char *out_iface; + const char *bpf_filter; + const char *out_iface; SC_ATOMIC_DECLARE(unsigned int, ref); void (*DerefFunc)(void *); } AFPIfaceConfig; @@ -142,9 +142,9 @@ typedef struct AFPPacketVars_ void TmModuleReceiveAFPRegister (void); void TmModuleDecodeAFPRegister (void); -TmEcode AFPPeersListInit(); -TmEcode AFPPeersListCheck(); -void AFPPeersListClean(); +TmEcode AFPPeersListInit(void); +TmEcode AFPPeersListCheck(void); +void AFPPeersListClean(void); int AFPGetLinkType(const char *ifname); int AFPIsFanoutSupported(void); diff --git a/src/source-erf-dag.c b/src/source-erf-dag.c index db6b3d9f64..35816386cf 100644 --- a/src/source-erf-dag.c +++ b/src/source-erf-dag.c @@ -33,10 +33,11 @@ #include "util-privs.h" #include "util-device.h" #include "tmqh-packetpool.h" +#include "source-erf-dag.h" #ifndef HAVE_DAG -TmEcode NoErfDagSupportExit(ThreadVars *, void *, void **); +TmEcode NoErfDagSupportExit(ThreadVars *, const void *, void **); void TmModuleReceiveErfDagRegister(void) @@ -65,7 +66,7 @@ TmModuleDecodeErfDagRegister(void) } TmEcode -NoErfDagSupportExit(ThreadVars *tv, void *initdata, void **data) +NoErfDagSupportExit(ThreadVars *tv, const void *initdata, void **data) { SCLogError(SC_ERR_DAG_NOSUPPORT, "Error creating thread %s: you do not have support for DAG cards " @@ -75,7 +76,6 @@ NoErfDagSupportExit(ThreadVars *tv, void *initdata, void **data) #else /* Implied we do have DAG support */ -#include "source-erf-dag.h" #include /* Minimum amount of data to read from the DAG at a time. */ diff --git a/src/source-erf-file.c b/src/source-erf-file.c index 29e59358c8..7031dfb1d0 100644 --- a/src/source-erf-file.c +++ b/src/source-erf-file.c @@ -28,6 +28,7 @@ #include "suricata-common.h" #include "suricata.h" #include "tm-threads.h" +#include "source-erf-file.h" #define DAG_TYPE_ETH 2 @@ -63,11 +64,11 @@ typedef struct ErfFileThreadVars_ { static inline TmEcode ReadErfRecord(ThreadVars *, Packet *, void *); TmEcode ReceiveErfFileLoop(ThreadVars *, void *, void *); -TmEcode ReceiveErfFileThreadInit(ThreadVars *, void *, void **); +TmEcode ReceiveErfFileThreadInit(ThreadVars *, const void *, void **); void ReceiveErfFileThreadExitStats(ThreadVars *, void *); TmEcode ReceiveErfFileThreadDeinit(ThreadVars *, void *); -TmEcode DecodeErfFileThreadInit(ThreadVars *, void *, void **); +TmEcode DecodeErfFileThreadInit(ThreadVars *, const void *, void **); TmEcode DecodeErfFileThreadDeinit(ThreadVars *tv, void *data); TmEcode DecodeErfFile(ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *); @@ -208,7 +209,7 @@ static inline TmEcode ReadErfRecord(ThreadVars *tv, Packet *p, void *data) * \brief Initialize the ERF receiver thread. */ TmEcode -ReceiveErfFileThreadInit(ThreadVars *tv, void *initdata, void **data) +ReceiveErfFileThreadInit(ThreadVars *tv, const void *initdata, void **data) { SCEnter(); @@ -244,7 +245,7 @@ ReceiveErfFileThreadInit(ThreadVars *tv, void *initdata, void **data) * \brief Initialize the ERF decoder thread. */ TmEcode -DecodeErfFileThreadInit(ThreadVars *tv, void *initdata, void **data) +DecodeErfFileThreadInit(ThreadVars *tv, const void *initdata, void **data) { SCEnter(); DecodeThreadVars *dtv = NULL; diff --git a/src/source-ipfw.c b/src/source-ipfw.c index 05392828b3..40742afc55 100644 --- a/src/source-ipfw.c +++ b/src/source-ipfw.c @@ -54,7 +54,7 @@ * */ -TmEcode NoIPFWSupportExit(ThreadVars *, void *, void **); +TmEcode NoIPFWSupportExit(ThreadVars *, const void *, void **); void TmModuleReceiveIPFWRegister (void) { @@ -90,7 +90,7 @@ void TmModuleDecodeIPFWRegister (void) tmm_modules[TMM_DECODEIPFW].flags = TM_FLAG_DECODE_TM; } -TmEcode NoIPFWSupportExit(ThreadVars *tv, void *initdata, void **data) +TmEcode NoIPFWSupportExit(ThreadVars *tv, const void *initdata, void **data) { SCLogError(SC_ERR_IPFW_NOSUPPORT,"Error creating thread %s: you do not have support for ipfw " @@ -130,7 +130,7 @@ static SCMutex ipfw_init_lock; /* IPFW Prototypes */ void *IPFWGetQueue(int number); -TmEcode ReceiveIPFWThreadInit(ThreadVars *, void *, void **); +TmEcode ReceiveIPFWThreadInit(ThreadVars *, const void *, void **); TmEcode ReceiveIPFW(ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *); TmEcode ReceiveIPFWLoop(ThreadVars *tv, void *data, void *slot); void ReceiveIPFWThreadExitStats(ThreadVars *, void *); @@ -138,11 +138,11 @@ TmEcode ReceiveIPFWThreadDeinit(ThreadVars *, void *); TmEcode IPFWSetVerdict(ThreadVars *, IPFWThreadVars *, Packet *); TmEcode VerdictIPFW(ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *); -TmEcode VerdictIPFWThreadInit(ThreadVars *, void *, void **); +TmEcode VerdictIPFWThreadInit(ThreadVars *, const void *, void **); void VerdictIPFWThreadExitStats(ThreadVars *, void *); TmEcode VerdictIPFWThreadDeinit(ThreadVars *, void *); -TmEcode DecodeIPFWThreadInit(ThreadVars *, void *, void **); +TmEcode DecodeIPFWThreadInit(ThreadVars *, const void *, void **); TmEcode DecodeIPFWThreadDeinit(ThreadVars *tv, void *data); TmEcode DecodeIPFW(ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *); @@ -326,7 +326,7 @@ TmEcode ReceiveIPFWLoop(ThreadVars *tv, void *data, void *slot) * \param data pointer gets populated with IPFWThreadVars * */ -TmEcode ReceiveIPFWThreadInit(ThreadVars *tv, void *initdata, void **data) +TmEcode ReceiveIPFWThreadInit(ThreadVars *tv, const void *initdata, void **data) { struct timeval timev; int flag; @@ -483,7 +483,7 @@ TmEcode DecodeIPFW(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, Packe * \param initdata pointer for passing in args * \param data pointer that gets cast into IPFWThreadVars for ptv */ -TmEcode DecodeIPFWThreadInit(ThreadVars *tv, void *initdata, void **data) +TmEcode DecodeIPFWThreadInit(ThreadVars *tv, const void *initdata, void **data) { DecodeThreadVars *dtv = NULL; dtv = DecodeThreadVarsAlloc(tv); @@ -665,7 +665,7 @@ TmEcode VerdictIPFW(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, Pack * \param initdata pointer for passing in args * \param data pointer that gets cast into IPFWThreadVars for ptv */ -TmEcode VerdictIPFWThreadInit(ThreadVars *tv, void *initdata, void **data) +TmEcode VerdictIPFWThreadInit(ThreadVars *tv, const void *initdata, void **data) { IPFWThreadVars *ptv = NULL; diff --git a/src/source-napatech.c b/src/source-napatech.c index 1348eaf99e..941d626094 100644 --- a/src/source-napatech.c +++ b/src/source-napatech.c @@ -36,10 +36,11 @@ #include "util-privs.h" #include "tmqh-packetpool.h" +#include "source-napatech.h" #ifndef HAVE_NAPATECH -TmEcode NoNapatechSupportExit(ThreadVars *, void *, void **); +TmEcode NoNapatechSupportExit(ThreadVars *, const void *, void **); void TmModuleNapatechStreamRegister (void) @@ -65,7 +66,7 @@ void TmModuleNapatechDecodeRegister (void) tmm_modules[TMM_DECODENAPATECH].flags = TM_FLAG_DECODE_TM; } -TmEcode NoNapatechSupportExit(ThreadVars *tv, void *initdata, void **data) +TmEcode NoNapatechSupportExit(ThreadVars *tv, const void *initdata, void **data) { SCLogError(SC_ERR_NAPATECH_NOSUPPORT, "Error creating thread %s: you do not have support for Napatech adapter " @@ -75,7 +76,6 @@ TmEcode NoNapatechSupportExit(ThreadVars *tv, void *initdata, void **data) #else /* Implied we do have NAPATECH support */ -#include "source-napatech.h" #include extern int max_pending_packets; @@ -93,11 +93,11 @@ typedef struct NapatechThreadVars_ { } NapatechThreadVars; -TmEcode NapatechStreamThreadInit(ThreadVars *, void *, void **); +TmEcode NapatechStreamThreadInit(ThreadVars *, const void *, void **); void NapatechStreamThreadExitStats(ThreadVars *, void *); TmEcode NapatechStreamLoop(ThreadVars *tv, void *data, void *slot); -TmEcode NapatechDecodeThreadInit(ThreadVars *, void *, void **); +TmEcode NapatechDecodeThreadInit(ThreadVars *, const void *, void **); TmEcode NapatechDecodeThreadDeinit(ThreadVars *tv, void *data); TmEcode NapatechDecode(ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *); @@ -149,7 +149,7 @@ void TmModuleNapatechDecodeRegister(void) * \param data data pointer gets populated with * */ -TmEcode NapatechStreamThreadInit(ThreadVars *tv, void *initdata, void **data) +TmEcode NapatechStreamThreadInit(ThreadVars *tv, const void *initdata, void **data) { SCEnter(); struct NapatechStreamDevConf *conf = (struct NapatechStreamDevConf *)initdata; @@ -376,7 +376,7 @@ TmEcode NapatechDecode(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, SCReturnInt(TM_ECODE_OK); } -TmEcode NapatechDecodeThreadInit(ThreadVars *tv, void *initdata, void **data) +TmEcode NapatechDecodeThreadInit(ThreadVars *tv, const void *initdata, void **data) { SCEnter(); DecodeThreadVars *dtv = NULL; diff --git a/src/source-netmap.c b/src/source-netmap.c index 5f81f1a694..cf0b443183 100644 --- a/src/source-netmap.c +++ b/src/source-netmap.c @@ -86,7 +86,7 @@ extern intmax_t max_pending_packets; #ifndef HAVE_NETMAP -TmEcode NoNetmapSupportExit(ThreadVars *, void *, void **); +TmEcode NoNetmapSupportExit(ThreadVars *, const void *, void **); void TmModuleReceiveNetmapRegister (void) { @@ -119,7 +119,7 @@ void TmModuleDecodeNetmapRegister (void) /** * \brief this function prints an error message and exits. */ -TmEcode NoNetmapSupportExit(ThreadVars *tv, void *initdata, void **data) +TmEcode NoNetmapSupportExit(ThreadVars *tv, const void *initdata, void **data) { SCLogError(SC_ERR_NO_NETMAP,"Error creating thread %s: you do not have " "support for netmap enabled, please recompile " @@ -491,10 +491,10 @@ static inline void NetmapDumpCounters(NetmapThreadVars *ntv) * \param initdata pointer to the interface passed from the user * \param data pointer gets populated with NetmapThreadVars */ -static TmEcode ReceiveNetmapThreadInit(ThreadVars *tv, void *initdata, void **data) +static TmEcode ReceiveNetmapThreadInit(ThreadVars *tv, const void *initdata, void **data) { SCEnter(); - NetmapIfaceConfig *aconf = initdata; + NetmapIfaceConfig *aconf = (NetmapIfaceConfig *)initdata; if (initdata == NULL) { SCLogError(SC_ERR_INVALID_ARGUMENT, "initdata == NULL"); @@ -976,7 +976,7 @@ static TmEcode ReceiveNetmapThreadDeinit(ThreadVars *tv, void *data) * \param initdata Thread config. * \param data Pointer to DecodeThreadVars placed here. */ -static TmEcode DecodeNetmapThreadInit(ThreadVars *tv, void *initdata, void **data) +static TmEcode DecodeNetmapThreadInit(ThreadVars *tv, const void *initdata, void **data) { SCEnter(); DecodeThreadVars *dtv = NULL; diff --git a/src/source-netmap.h b/src/source-netmap.h index 00b0b44274..caa59eefd0 100644 --- a/src/source-netmap.h +++ b/src/source-netmap.h @@ -46,7 +46,7 @@ typedef struct NetmapIfaceSettings_ int promisc; int copy_mode; ChecksumValidationMode checksum_mode; - char *bpf_filter; + const char *bpf_filter; } NetmapIfaceSettings; typedef struct NetmapIfaceConfig_ diff --git a/src/source-nflog.c b/src/source-nflog.c index 858ad76c79..0e399be00e 100644 --- a/src/source-nflog.c +++ b/src/source-nflog.c @@ -43,7 +43,7 @@ * */ -TmEcode NoNFLOGSupportExit(ThreadVars *, void *, void **); +TmEcode NoNFLOGSupportExit(ThreadVars *, const void *, void **); void TmModuleReceiveNFLOGRegister (void) { @@ -57,7 +57,7 @@ void TmModuleDecodeNFLOGRegister (void) tmm_modules[TMM_DECODENFLOG].ThreadInit = NoNFLOGSupportExit; } -TmEcode NoNFLOGSupportExit(ThreadVars *tv, void *initdata, void **data) +TmEcode NoNFLOGSupportExit(ThreadVars *tv, const void *initdata, void **data) { SCLogError(SC_ERR_NFLOG_NOSUPPORT,"Error creating thread %s: you do not have support for nflog " "enabled please recompile with --enable-nflog", tv->name); @@ -68,12 +68,12 @@ TmEcode NoNFLOGSupportExit(ThreadVars *tv, void *initdata, void **data) #include "source-nflog.h" -TmEcode ReceiveNFLOGThreadInit(ThreadVars *, void *, void **); +TmEcode ReceiveNFLOGThreadInit(ThreadVars *, const void *, void **); TmEcode ReceiveNFLOGThreadDeinit(ThreadVars *, void *); TmEcode ReceiveNFLOGLoop(ThreadVars *, void *, void *); void ReceiveNFLOGThreadExitStats(ThreadVars *, void *); -TmEcode DecodeNFLOGThreadInit(ThreadVars *, void *, void **); +TmEcode DecodeNFLOGThreadInit(ThreadVars *, const void *, void **); TmEcode DecodeNFLOGThreadDeinit(ThreadVars *tv, void *data); TmEcode DecodeNFLOG(ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *); diff --git a/src/source-nfq.c b/src/source-nfq.c index a53d080c36..7c163bd9ef 100644 --- a/src/source-nfq.c +++ b/src/source-nfq.c @@ -60,7 +60,7 @@ * */ -TmEcode NoNFQSupportExit(ThreadVars *, void *, void **); +TmEcode NoNFQSupportExit(ThreadVars *, const void *, void **); void TmModuleReceiveNFQRegister (void) { @@ -97,7 +97,7 @@ void TmModuleDecodeNFQRegister (void) tmm_modules[TMM_DECODENFQ].flags = TM_FLAG_DECODE_TM; } -TmEcode NoNFQSupportExit(ThreadVars *tv, void *initdata, void **data) +TmEcode NoNFQSupportExit(ThreadVars *tv, const void *initdata, void **data) { SCLogError(SC_ERR_NFQ_NOSUPPORT,"Error creating thread %s: you do not have support for nfqueue " "enabled please recompile with --enable-nfqueue", tv->name); @@ -142,16 +142,16 @@ static uint16_t receive_queue_num = 0; static SCMutex nfq_init_lock; TmEcode ReceiveNFQLoop(ThreadVars *tv, void *data, void *slot); -TmEcode ReceiveNFQThreadInit(ThreadVars *, void *, void **); +TmEcode ReceiveNFQThreadInit(ThreadVars *, const void *, void **); TmEcode ReceiveNFQThreadDeinit(ThreadVars *, void *); void ReceiveNFQThreadExitStats(ThreadVars *, void *); TmEcode VerdictNFQ(ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *); -TmEcode VerdictNFQThreadInit(ThreadVars *, void *, void **); +TmEcode VerdictNFQThreadInit(ThreadVars *, const void *, void **); TmEcode VerdictNFQThreadDeinit(ThreadVars *, void *); TmEcode DecodeNFQ(ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *); -TmEcode DecodeNFQThreadInit(ThreadVars *, void *, void **); +TmEcode DecodeNFQThreadInit(ThreadVars *, const void *, void **); TmEcode DecodeNFQThreadDeinit(ThreadVars *tv, void *data); TmEcode NFQSetVerdict(Packet *p); @@ -223,7 +223,7 @@ void TmModuleDecodeNFQRegister (void) void NFQInitConfig(char quiet) { intmax_t value = 0; - char* nfq_mode = NULL; + const char *nfq_mode = NULL; int boolval; SCLogDebug("Initializing NFQ"); @@ -420,7 +420,7 @@ static inline void NFQMutexInit(NFQQueueVars *nq) * In case of error, this function verdict the packet * to avoid skb to get stuck in kernel. */ -int NFQSetupPkt (Packet *p, struct nfq_q_handle *qh, void *data) +static int NFQSetupPkt (Packet *p, struct nfq_q_handle *qh, void *data) { struct nfq_data *tb = (struct nfq_data *)data; int ret; @@ -587,7 +587,7 @@ static int NFQCallBack(struct nfq_q_handle *qh, struct nfgenmsg *nfmsg, return 0; } -TmEcode NFQInitThread(NFQThreadVars *t, uint32_t queue_maxlen) +static TmEcode NFQInitThread(NFQThreadVars *t, uint32_t queue_maxlen) { #ifndef OS_WIN32 struct timeval tv; @@ -738,7 +738,7 @@ TmEcode NFQInitThread(NFQThreadVars *t, uint32_t queue_maxlen) return TM_ECODE_OK; } -TmEcode ReceiveNFQThreadInit(ThreadVars *tv, void *initdata, void **data) +TmEcode ReceiveNFQThreadInit(ThreadVars *tv, const void *initdata, void **data) { SCMutexLock(&nfq_init_lock); @@ -800,7 +800,7 @@ TmEcode ReceiveNFQThreadDeinit(ThreadVars *t, void *data) } -TmEcode VerdictNFQThreadInit(ThreadVars *tv, void *initdata, void **data) +TmEcode VerdictNFQThreadInit(ThreadVars *tv, const void *initdata, void **data) { NFQThreadVars *ntv = (NFQThreadVars *) initdata; @@ -915,7 +915,7 @@ void *NFQGetThread(int number) * \note separate functions for Linux and Win32 for readability. */ #ifndef OS_WIN32 -void NFQRecvPkt(NFQQueueVars *t, NFQThreadVars *tv) +static void NFQRecvPkt(NFQQueueVars *t, NFQThreadVars *tv) { int rv, ret; int flag = NFQVerdictCacheLen(t) ? MSG_DONTWAIT : 0; @@ -1296,7 +1296,7 @@ TmEcode DecodeNFQ(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, Packet /** * \brief Initialize the NFQ Decode threadvars */ -TmEcode DecodeNFQThreadInit(ThreadVars *tv, void *initdata, void **data) +TmEcode DecodeNFQThreadInit(ThreadVars *tv, const void *initdata, void **data) { DecodeThreadVars *dtv = NULL; dtv = DecodeThreadVarsAlloc(tv); diff --git a/src/source-pcap-file.c b/src/source-pcap-file.c index c6b1c3bbf3..db1ec63fec 100644 --- a/src/source-pcap-file.c +++ b/src/source-pcap-file.c @@ -93,12 +93,12 @@ static PcapFileGlobalVars pcap_g; TmEcode ReceivePcapFileLoop(ThreadVars *, void *, void *); -TmEcode ReceivePcapFileThreadInit(ThreadVars *, void *, void **); +TmEcode ReceivePcapFileThreadInit(ThreadVars *, const void *, void **); void ReceivePcapFileThreadExitStats(ThreadVars *, void *); TmEcode ReceivePcapFileThreadDeinit(ThreadVars *, void *); TmEcode DecodePcapFile(ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *); -TmEcode DecodePcapFileThreadInit(ThreadVars *, void *, void **); +TmEcode DecodePcapFileThreadInit(ThreadVars *, const void *, void **); TmEcode DecodePcapFileThreadDeinit(ThreadVars *tv, void *data); void TmModuleReceivePcapFileRegister (void) @@ -133,7 +133,7 @@ void PcapFileGlobalInit() SC_ATOMIC_INIT(pcap_g.invalid_checksums); } -void PcapFileCallbackLoop(char *user, struct pcap_pkthdr *h, u_char *pkt) +static void PcapFileCallbackLoop(char *user, struct pcap_pkthdr *h, u_char *pkt) { SCEnter(); @@ -252,12 +252,12 @@ TmEcode ReceivePcapFileLoop(ThreadVars *tv, void *data, void *slot) SCReturnInt(TM_ECODE_OK); } -TmEcode ReceivePcapFileThreadInit(ThreadVars *tv, void *initdata, void **data) +TmEcode ReceivePcapFileThreadInit(ThreadVars *tv, const void *initdata, void **data) { SCEnter(); - char *tmpbpfstring = NULL; - char *tmpstring = NULL; + const char *tmpbpfstring = NULL; + const char *tmpstring = NULL; if (initdata == NULL) { SCLogError(SC_ERR_INVALID_ARGUMENT, "error: initdata == NULL"); @@ -299,7 +299,7 @@ TmEcode ReceivePcapFileThreadInit(ThreadVars *tv, void *initdata, void **data) } else { SCLogInfo("using bpf-filter \"%s\"", tmpbpfstring); - if (pcap_compile(pcap_g.pcap_handle, &pcap_g.filter, tmpbpfstring, 1, 0) < 0) { + if (pcap_compile(pcap_g.pcap_handle, &pcap_g.filter, (char *)tmpbpfstring, 1, 0) < 0) { SCLogError(SC_ERR_BPF,"bpf compilation error %s", pcap_geterr(pcap_g.pcap_handle)); SCFree(ptv); @@ -432,7 +432,7 @@ TmEcode DecodePcapFile(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, P SCReturnInt(TM_ECODE_OK); } -TmEcode DecodePcapFileThreadInit(ThreadVars *tv, void *initdata, void **data) +TmEcode DecodePcapFileThreadInit(ThreadVars *tv, const void *initdata, void **data) { SCEnter(); DecodeThreadVars *dtv = NULL; diff --git a/src/source-pcap-file.h b/src/source-pcap-file.h index fa76a1a8f8..30a3c2ec69 100644 --- a/src/source-pcap-file.h +++ b/src/source-pcap-file.h @@ -27,9 +27,9 @@ void TmModuleReceivePcapFileRegister (void); void TmModuleDecodePcapFileRegister (void); -void PcapIncreaseInvalidChecksum(); +void PcapIncreaseInvalidChecksum(void); -void PcapFileGlobalInit(); +void PcapFileGlobalInit(void); #endif /* __SOURCE_PCAP_FILE_H__ */ diff --git a/src/source-pcap.c b/src/source-pcap.c index 08a2ab505b..84e9456735 100644 --- a/src/source-pcap.c +++ b/src/source-pcap.c @@ -71,7 +71,7 @@ typedef struct PcapThreadVars_ /* thread specific bpf */ struct bpf_program filter; /* ptr to string from config */ - char *bpf_filter; + const char *bpf_filter; time_t last_stats_dump; @@ -102,12 +102,12 @@ typedef struct PcapThreadVars_ LiveDevice *livedev; } PcapThreadVars; -TmEcode ReceivePcapThreadInit(ThreadVars *, void *, void **); +TmEcode ReceivePcapThreadInit(ThreadVars *, const void *, void **); void ReceivePcapThreadExitStats(ThreadVars *, void *); TmEcode ReceivePcapThreadDeinit(ThreadVars *, void *); TmEcode ReceivePcapLoop(ThreadVars *tv, void *data, void *slot); -TmEcode DecodePcapThreadInit(ThreadVars *, void *, void **); +TmEcode DecodePcapThreadInit(ThreadVars *, const void *, void **); TmEcode DecodePcapThreadDeinit(ThreadVars *tv, void *data); TmEcode DecodePcap(ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *); @@ -171,7 +171,7 @@ static int PcapTryReopen(PcapThreadVars *ptv) } /* set bpf filter if we have one */ if (ptv->bpf_filter != NULL) { - if(pcap_compile(ptv->pcap_handle,&ptv->filter,ptv->bpf_filter,1,0) < 0) { + if(pcap_compile(ptv->pcap_handle,&ptv->filter,(char *)ptv->bpf_filter,1,0) < 0) { SCLogError(SC_ERR_BPF,"bpf compilation error %s",pcap_geterr(ptv->pcap_handle)); return -1; } @@ -187,7 +187,7 @@ static int PcapTryReopen(PcapThreadVars *ptv) return 0; } -void PcapCallbackLoop(char *user, struct pcap_pkthdr *h, u_char *pkt) +static void PcapCallbackLoop(char *user, struct pcap_pkthdr *h, u_char *pkt) { SCEnter(); @@ -325,10 +325,10 @@ TmEcode ReceivePcapLoop(ThreadVars *tv, void *data, void *slot) * * \todo Create a general pcap setup function. */ -TmEcode ReceivePcapThreadInit(ThreadVars *tv, void *initdata, void **data) +TmEcode ReceivePcapThreadInit(ThreadVars *tv, const void *initdata, void **data) { SCEnter(); - PcapIfaceConfig *pcapconfig = initdata; + PcapIfaceConfig *pcapconfig = (PcapIfaceConfig *)initdata; if (initdata == NULL) { SCLogError(SC_ERR_INVALID_ARGUMENT, "initdata == NULL"); @@ -453,7 +453,7 @@ TmEcode ReceivePcapThreadInit(ThreadVars *tv, void *initdata, void **data) ptv->bpf_filter = pcapconfig->bpf_filter; - if (pcap_compile(ptv->pcap_handle,&ptv->filter,ptv->bpf_filter,1,0) < 0) { + if (pcap_compile(ptv->pcap_handle,&ptv->filter,(char *)ptv->bpf_filter,1,0) < 0) { SCLogError(SC_ERR_BPF, "bpf compilation error %s", pcap_geterr(ptv->pcap_handle)); SCMutexUnlock(&pcap_bpf_compile_lock); @@ -590,7 +590,7 @@ TmEcode DecodePcap(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, Packe SCReturnInt(TM_ECODE_OK); } -TmEcode DecodePcapThreadInit(ThreadVars *tv, void *initdata, void **data) +TmEcode DecodePcapThreadInit(ThreadVars *tv, const void *initdata, void **data) { SCEnter(); DecodeThreadVars *dtv = NULL; diff --git a/src/source-pcap.h b/src/source-pcap.h index ac6d331ddb..4128983a4b 100644 --- a/src/source-pcap.h +++ b/src/source-pcap.h @@ -58,7 +58,7 @@ typedef struct PcapIfaceConfig_ /* promiscuous value */ int promisc; /* BPF filter */ - char *bpf_filter; + const char *bpf_filter; ChecksumValidationMode checksum_mode; SC_ATOMIC_DECLARE(unsigned int, ref); void (*DerefFunc)(void *); diff --git a/src/source-pfring.c b/src/source-pfring.c index d8583f5f18..b721dd6caf 100644 --- a/src/source-pfring.c +++ b/src/source-pfring.c @@ -64,11 +64,11 @@ TmEcode ReceivePfringLoop(ThreadVars *tv, void *data, void *slot); TmEcode PfringBreakLoop(ThreadVars *tv, void *data); -TmEcode ReceivePfringThreadInit(ThreadVars *, void *, void **); +TmEcode ReceivePfringThreadInit(ThreadVars *, const void *, void **); void ReceivePfringThreadExitStats(ThreadVars *, void *); TmEcode ReceivePfringThreadDeinit(ThreadVars *, void *); -TmEcode DecodePfringThreadInit(ThreadVars *, void *, void **); +TmEcode DecodePfringThreadInit(ThreadVars *, const void *, void **); TmEcode DecodePfring(ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *); TmEcode DecodePfringThreadDeinit(ThreadVars *tv, void *data); @@ -77,7 +77,7 @@ extern int max_pending_packets; #ifndef HAVE_PFRING /*Handle cases where we don't have PF_RING support built-in*/ -TmEcode NoPfringSupportExit(ThreadVars *, void *, void **); +TmEcode NoPfringSupportExit(ThreadVars *, const void *, void **); void TmModuleReceivePfringRegister (void) { @@ -110,7 +110,7 @@ void TmModuleDecodePfringRegister (void) * \param initdata pointer to the interface passed from the user * \param data pointer gets populated with PfringThreadVars */ -TmEcode NoPfringSupportExit(ThreadVars *tv, void *initdata, void **data) +TmEcode NoPfringSupportExit(ThreadVars *tv, const void *initdata, void **data) { SCLogError(SC_ERR_NO_PF_RING,"Error creating thread %s: you do not have support for pfring " "enabled please recompile with --enable-pfring", tv->name); @@ -431,7 +431,7 @@ TmEcode PfringBreakLoop(ThreadVars *tv, void *data) * \retval TM_ECODE_OK on success * \retval TM_ECODE_FAILED on error */ -TmEcode ReceivePfringThreadInit(ThreadVars *tv, void *initdata, void **data) +TmEcode ReceivePfringThreadInit(ThreadVars *tv, const void *initdata, void **data) { int rc; u_int32_t version = 0; @@ -687,7 +687,7 @@ TmEcode DecodePfring(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, Pac * \retval TM_ECODE_OK is returned on success * \retval TM_ECODE_FAILED is returned on error */ -TmEcode DecodePfringThreadInit(ThreadVars *tv, void *initdata, void **data) +TmEcode DecodePfringThreadInit(ThreadVars *tv, const void *initdata, void **data) { DecodeThreadVars *dtv = NULL; diff --git a/src/stream-tcp-list.c b/src/stream-tcp-list.c index abcd4fea56..4302c04e22 100644 --- a/src/stream-tcp-list.c +++ b/src/stream-tcp-list.c @@ -925,6 +925,7 @@ void PrintList(TcpSegment *seg) } } +#if 0 void ValidateList(const TcpStream *stream) { TcpSegment *seg = stream->seg_list; @@ -942,6 +943,7 @@ void ValidateList(const TcpStream *stream) BUG_ON(seg && SEQ_LT(seg->seq, prev_seg->seq)); } } +#endif /* * unittests diff --git a/src/stream-tcp-reassemble.c b/src/stream-tcp-reassemble.c index 1fef7b233e..6072383132 100644 --- a/src/stream-tcp-reassemble.c +++ b/src/stream-tcp-reassemble.c @@ -212,7 +212,7 @@ static void ReassembleFree(void *ptr, size_t size) } /** \brief alloc a tcp segment pool entry */ -void *TcpSegmentPoolAlloc() +static void *TcpSegmentPoolAlloc(void) { if (StreamTcpReassembleCheckMemcap((uint32_t)sizeof(TcpSegment)) == 0) { return NULL; @@ -226,7 +226,7 @@ void *TcpSegmentPoolAlloc() return seg; } -int TcpSegmentPoolInit(void *data, void *initdata) +static int TcpSegmentPoolInit(void *data, void *initdata) { TcpSegment *seg = (TcpSegment *) data; @@ -251,7 +251,7 @@ int TcpSegmentPoolInit(void *data, void *initdata) } /** \brief clean up a tcp segment pool entry */ -void TcpSegmentPoolCleanup(void *ptr) +static void TcpSegmentPoolCleanup(void *ptr) { if (ptr == NULL) return; @@ -336,7 +336,7 @@ int StreamTcpAppLayerIsDisabled(Flow *f) return (ssn->flags & STREAMTCP_FLAG_APP_LAYER_DISABLED); } -int StreamTcpReassemblyConfig(char quiet) +static int StreamTcpReassemblyConfig(char quiet) { uint32_t segment_prealloc = 2048; ConfNode *seg = ConfGetNode("stream.reassembly.segment-prealloc"); @@ -766,7 +766,7 @@ int StreamNeedsReassembly(const TcpSession *ssn, uint8_t direction) { const TcpStream *stream = NULL; #ifdef DEBUG - char *dirstr = NULL; + const char *dirstr = NULL; #endif if (direction == STREAM_TOSERVER) { stream = &ssn->client; diff --git a/src/stream-tcp-sack.c b/src/stream-tcp-sack.c index ab0ad57faa..0d01e5353a 100644 --- a/src/stream-tcp-sack.c +++ b/src/stream-tcp-sack.c @@ -30,7 +30,7 @@ #include "util-unittest.h" #ifdef DEBUG -void StreamTcpSackPrintList(TcpStream *stream) +static void StreamTcpSackPrintList(TcpStream *stream) { StreamTcpSackRecord *rec = stream->sack_head; for (; rec != NULL; rec = rec->next) { diff --git a/src/stream-tcp-util.c b/src/stream-tcp-util.c index 825e51b098..a41a5d415e 100644 --- a/src/stream-tcp-util.c +++ b/src/stream-tcp-util.c @@ -159,7 +159,7 @@ int StreamTcpUTAddSegmentWithByte(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx /* tests */ -int StreamTcpUtilTest01(void) +static int StreamTcpUtilTest01(void) { int ret = 0; TcpReassemblyThreadCtx *ra_ctx = NULL; @@ -178,7 +178,7 @@ end: } -int StreamTcpUtilStreamTest01(void) +static int StreamTcpUtilStreamTest01(void) { int ret = 0; TcpReassemblyThreadCtx *ra_ctx = NULL; @@ -228,7 +228,7 @@ end: return ret; } -int StreamTcpUtilStreamTest02(void) +static int StreamTcpUtilStreamTest02(void) { int ret = 0; TcpReassemblyThreadCtx *ra_ctx = NULL; diff --git a/src/stream-tcp.c b/src/stream-tcp.c index 0db8f496e3..07378ee86a 100644 --- a/src/stream-tcp.c +++ b/src/stream-tcp.c @@ -112,7 +112,6 @@ static SCMutex ssn_pool_mutex = SCMUTEX_INITIALIZER; /**< init only, protect ini static uint64_t ssn_pool_cnt = 0; /** counts ssns, protected by ssn_pool_mutex */ #endif -uint64_t StreamTcpMemuseCounter(void); uint64_t StreamTcpReassembleMemuseGlobalCounter(void); SC_ATOMIC_DECLARE(uint64_t, st_memuse); @@ -269,7 +268,7 @@ void StreamTcpSessionPktFree (Packet *p) /** \brief Stream alloc function for the Pool * \retval ptr void ptr to TcpSession structure with all vars set to 0/NULL */ -static void *StreamTcpSessionPoolAlloc() +static void *StreamTcpSessionPoolAlloc(void) { void *ptr = NULL; @@ -342,7 +341,7 @@ void StreamTcpInitConfig(char quiet) stream_config.prealloc_sessions); } - char *temp_stream_memcap_str; + const char *temp_stream_memcap_str; if (ConfGet("stream.memcap", &temp_stream_memcap_str) == 1) { if (ParseSizeStringU64(temp_stream_memcap_str, &stream_config.memcap) < 0) { SCLogError(SC_ERR_SIZE_PARSE, "Error parsing stream.memcap " @@ -387,7 +386,7 @@ void StreamTcpInitConfig(char quiet) "enabled" : "disabled"); } - char *temp_stream_inline_str; + const char *temp_stream_inline_str; if (ConfGet("stream.inline", &temp_stream_inline_str) == 1) { int inl = 0; @@ -443,7 +442,7 @@ void StreamTcpInitConfig(char quiet) SCLogConfig("stream \"max-synack-queued\": %"PRIu8, stream_config.max_synack_queued); } - char *temp_stream_reassembly_memcap_str; + const char *temp_stream_reassembly_memcap_str; if (ConfGet("stream.reassembly.memcap", &temp_stream_reassembly_memcap_str) == 1) { if (ParseSizeStringU64(temp_stream_reassembly_memcap_str, &stream_config.reassembly_memcap) < 0) { @@ -461,7 +460,7 @@ void StreamTcpInitConfig(char quiet) SCLogConfig("stream.reassembly \"memcap\": %"PRIu64"", stream_config.reassembly_memcap); } - char *temp_stream_reassembly_depth_str; + const char *temp_stream_reassembly_depth_str; if (ConfGet("stream.reassembly.depth", &temp_stream_reassembly_depth_str) == 1) { if (ParseSizeStringU32(temp_stream_reassembly_depth_str, &stream_config.reassembly_depth) < 0) { @@ -488,7 +487,7 @@ void StreamTcpInitConfig(char quiet) } if (randomize) { - char *temp_rdrange; + const char *temp_rdrange; if (ConfGet("stream.reassembly.randomize-chunk-range", &temp_rdrange) == 1) { if (ParseSizeStringU16(temp_rdrange, &rdrange) < 0) { @@ -506,7 +505,7 @@ void StreamTcpInitConfig(char quiet) } } - char *temp_stream_reassembly_toserver_chunk_size_str; + const char *temp_stream_reassembly_toserver_chunk_size_str; if (ConfGet("stream.reassembly.toserver-chunk-size", &temp_stream_reassembly_toserver_chunk_size_str) == 1) { if (ParseSizeStringU16(temp_stream_reassembly_toserver_chunk_size_str, @@ -528,7 +527,7 @@ void StreamTcpInitConfig(char quiet) (int) (stream_config.reassembly_toserver_chunk_size * (r * 1.0 / RAND_MAX - 0.5) * rdrange / 100); } - char *temp_stream_reassembly_toclient_chunk_size_str; + const char *temp_stream_reassembly_toclient_chunk_size_str; if (ConfGet("stream.reassembly.toclient-chunk-size", &temp_stream_reassembly_toclient_chunk_size_str) == 1) { if (ParseSizeStringU16(temp_stream_reassembly_toclient_chunk_size_str, @@ -1066,7 +1065,7 @@ static inline void StreamTcp3whsSynAckToStateQueue(Packet *p, TcpStateQueue *q) /** \internal * \brief Find the Queued SYN/ACK that is the same as this SYN/ACK * \retval q or NULL */ -TcpStateQueue *StreamTcp3whsFindSynAckBySynAck(TcpSession *ssn, Packet *p) +static TcpStateQueue *StreamTcp3whsFindSynAckBySynAck(TcpSession *ssn, Packet *p) { TcpStateQueue *q = ssn->queue; TcpStateQueue search; @@ -1089,7 +1088,7 @@ TcpStateQueue *StreamTcp3whsFindSynAckBySynAck(TcpSession *ssn, Packet *p) return q; } -int StreamTcp3whsQueueSynAck(TcpSession *ssn, Packet *p) +static int StreamTcp3whsQueueSynAck(TcpSession *ssn, Packet *p) { /* first see if this is already in our list */ if (StreamTcp3whsFindSynAckBySynAck(ssn, p) != NULL) @@ -1126,7 +1125,7 @@ int StreamTcp3whsQueueSynAck(TcpSession *ssn, Packet *p) /** \internal * \brief Find the Queued SYN/ACK that goes with this ACK * \retval q or NULL */ -TcpStateQueue *StreamTcp3whsFindSynAckByAck(TcpSession *ssn, Packet *p) +static TcpStateQueue *StreamTcp3whsFindSynAckByAck(TcpSession *ssn, Packet *p) { uint32_t ack = TCP_GET_SEQ(p); uint32_t seq = TCP_GET_ACK(p) - 1; @@ -4816,7 +4815,7 @@ static int TcpSessionReuseDoneEnoughSynAck(const Packet *p, const Flow *f, const * Reuse means a new TCP session reuses the tuple (flow in suri) * * \retval bool true if ssn can be reused, false if not */ -int TcpSessionReuseDoneEnough(const Packet *p, const Flow *f, const TcpSession *ssn) +static int TcpSessionReuseDoneEnough(const Packet *p, const Flow *f, const TcpSession *ssn) { if (p->tcph->th_flags == TH_SYN) { return TcpSessionReuseDoneEnoughSyn(p, f, ssn); @@ -6847,12 +6846,12 @@ static const char *dummy_conf_string1 = * \param conf_val_name Name of the OS policy type * \retval returns IP address as string on success and NULL on failure */ -char *StreamTcpParseOSPolicy (char *conf_var_name) +static const char *StreamTcpParseOSPolicy (char *conf_var_name) { SCEnter(); char conf_var_type_name[15] = "host-os-policy"; char *conf_var_full_name = NULL; - char *conf_var_value = NULL; + const char *conf_var_value = NULL; if (conf_var_name == NULL) goto end; @@ -6906,7 +6905,7 @@ static int StreamTcpTest14 (void) struct in_addr addr; IPV4Hdr ipv4h; char os_policy_name[10] = "windows"; - char *ip_addr; + const char *ip_addr; PacketQueue pq; memset(&pq,0,sizeof(PacketQueue)); @@ -7308,7 +7307,7 @@ static int StreamTcpTest15 (void) struct in_addr addr; IPV4Hdr ipv4h; char os_policy_name[10] = "windows"; - char *ip_addr; + const char *ip_addr; PacketQueue pq; memset(&pq,0,sizeof(PacketQueue)); @@ -7475,7 +7474,7 @@ static int StreamTcpTest16 (void) struct in_addr addr; IPV4Hdr ipv4h; char os_policy_name[10] = "windows"; - char *ip_addr; + const char *ip_addr; PacketQueue pq; memset(&pq,0,sizeof(PacketQueue)); @@ -7645,7 +7644,7 @@ static int StreamTcpTest17 (void) struct in_addr addr; IPV4Hdr ipv4h; char os_policy_name[10] = "windows"; - char *ip_addr; + const char *ip_addr; PacketQueue pq; memset(&pq,0,sizeof(PacketQueue)); @@ -7801,7 +7800,7 @@ static int StreamTcpTest18 (void) StreamTcpThread stt; struct in_addr addr; char os_policy_name[10] = "windows"; - char *ip_addr; + const char *ip_addr; TcpStream stream; Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) @@ -7850,7 +7849,7 @@ static int StreamTcpTest19 (void) StreamTcpThread stt; struct in_addr addr; char os_policy_name[10] = "windows"; - char *ip_addr; + const char *ip_addr; TcpStream stream; Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) @@ -7902,7 +7901,7 @@ static int StreamTcpTest20 (void) StreamTcpThread stt; struct in_addr addr; char os_policy_name[10] = "linux"; - char *ip_addr; + const char *ip_addr; TcpStream stream; Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) @@ -7954,7 +7953,7 @@ static int StreamTcpTest21 (void) StreamTcpThread stt; struct in_addr addr; char os_policy_name[10] = "linux"; - char *ip_addr; + const char *ip_addr; TcpStream stream; Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) @@ -8006,7 +8005,7 @@ static int StreamTcpTest22 (void) StreamTcpThread stt; struct in_addr addr; char os_policy_name[10] = "windows"; - char *ip_addr; + const char *ip_addr; TcpStream stream; Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) diff --git a/src/stream-tcp.h b/src/stream-tcp.h index 17ce9c9a01..dfe8f44a74 100644 --- a/src/stream-tcp.h +++ b/src/stream-tcp.h @@ -203,5 +203,7 @@ void StreamTcpStreamCleanup(TcpStream *stream); /* check if bypass is enabled */ int StreamTcpBypassEnabled(void); +int TcpSessionPacketSsnReuse(const Packet *p, const Flow *f, const void *tcp_ssn); + #endif /* __STREAM_TCP_H__ */ diff --git a/src/suricata-common.h b/src/suricata-common.h index 063e904a1f..940e3e06f9 100644 --- a/src/suricata-common.h +++ b/src/suricata-common.h @@ -164,6 +164,10 @@ #include #endif +#if HAVE_SYS_MMAN_H +#include +#endif + #if HAVE_NETINET_IN_H #include #endif diff --git a/src/suricata.c b/src/suricata.c index f974950659..62a2cd9dde 100644 --- a/src/suricata.c +++ b/src/suricata.c @@ -312,7 +312,7 @@ uint8_t print_mem_flag = 1; #endif #endif -void CreateLowercaseTable() +static void CreateLowercaseTable(void) { /* create table for O(1) lowercase conversion lookup. It was removed, but * we still need it for cuda. So resintalling it back into the codebase */ @@ -326,7 +326,7 @@ void CreateLowercaseTable() } } -void GlobalsInitPreConfig() +void GlobalsInitPreConfig(void) { #ifdef __SC_CUDA_SUPPORT__ /* Init the CUDA environment */ @@ -359,7 +359,7 @@ void GlobalsInitPreConfig() SupportFastPatternForSigMatchTypes(); } -void GlobalsDestroy(SCInstance *suri) +static void GlobalsDestroy(SCInstance *suri) { HostShutdown(); HTPFreeConfig(); @@ -587,7 +587,7 @@ static void SetBpfStringFromFile(char *filename) SCFree(bpf_filter); } -void usage(const char *progname) +static void PrintUsage(const char *progname) { #ifdef REVISION printf("%s %s (rev %s)\n", PROG_NAME, PROG_VER, xstr(REVISION)); @@ -685,12 +685,12 @@ void usage(const char *progname) progname); } -void SCPrintBuildInfo(void) +static void PrintBuildInfo(void) { - char *bits = "-bits"; - char *endian = "-endian"; + const char *bits = "-bits"; + const char *endian = "-endian"; char features[2048] = ""; - char *tls = "pthread key"; + const char *tls = "pthread key"; #ifdef REVISION printf("This is %s version %s (rev %s)\n", PROG_NAME, PROG_VER, xstr(REVISION)); @@ -878,7 +878,7 @@ int coverage_unittests; int g_ut_modules; int g_ut_covered; -void RegisterAllModules() +void RegisterAllModules(void) { /* commanders */ TmModuleUnixManagerRegister(); @@ -1082,7 +1082,7 @@ static void SCInstanceInit(SCInstance *suri, const char *progname) #endif } -static TmEcode PrintVersion() +static TmEcode PrintVersion(void) { #ifdef REVISION printf("This is %s version %s (rev %s)\n", PROG_NAME, PROG_VER, xstr(REVISION)); @@ -1094,7 +1094,7 @@ static TmEcode PrintVersion() return TM_ECODE_OK; } -static TmEcode SCPrintVersion() +static TmEcode LogVersion(void) { #ifdef REVISION SCLogNotice("This is %s version %s (rev %s)", PROG_NAME, PROG_VER, xstr(REVISION)); @@ -1145,7 +1145,7 @@ static int ParseCommandLineAfpacket(SCInstance *suri, const char *in_arg) } else { SCLogError(SC_ERR_MULTIPLE_RUN_MODE, "more than one run mode " "has been specified"); - usage(suri->progname); + PrintUsage(suri->progname); return TM_ECODE_FAILED; } return TM_ECODE_OK; @@ -1197,7 +1197,7 @@ static int ParseCommandLinePcapLive(SCInstance *suri, const char *in_arg) } else { SCLogError(SC_ERR_MULTIPLE_RUN_MODE, "more than one run mode " "has been specified"); - usage(suri->progname); + PrintUsage(suri->progname); return TM_ECODE_FAILED; } return TM_ECODE_OK; @@ -1621,7 +1621,7 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri) } else { SCLogError(SC_ERR_MULTIPLE_RUN_MODE, "more than one run mode " "has been specified"); - usage(argv[0]); + PrintUsage(argv[0]); return TM_ECODE_FAILED; } #else @@ -1666,7 +1666,7 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri) } else { SCLogError(SC_ERR_MULTIPLE_RUN_MODE, "more than one run mode " "has been specified"); - usage(argv[0]); + PrintUsage(argv[0]); return TM_ECODE_FAILED; } #endif @@ -1765,7 +1765,7 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri) else if (suri->run_mode != RUNMODE_DAG) { SCLogError(SC_ERR_MULTIPLE_RUN_MODE, "more than one run mode has been specified"); - usage(argv[0]); + PrintUsage(argv[0]); return TM_ECODE_FAILED; } LiveRegisterDevice(optarg); @@ -1813,7 +1813,7 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri) } else { SCLogError(SC_ERR_MULTIPLE_RUN_MODE, "more than one run mode has been specified"); - usage(argv[0]); + PrintUsage(argv[0]); exit(EXIT_FAILURE); } } @@ -1929,7 +1929,7 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri) } else { SCLogError(SC_ERR_MULTIPLE_RUN_MODE, "more than one run mode " "has been specified"); - usage(argv[0]); + PrintUsage(argv[0]); return TM_ECODE_FAILED; } #else @@ -1950,7 +1950,7 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri) } else { SCLogError(SC_ERR_MULTIPLE_RUN_MODE, "more than one run mode " "has been specified"); - usage(argv[0]); + PrintUsage(argv[0]); return TM_ECODE_FAILED; } #else @@ -1964,7 +1964,7 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri) } else { SCLogError(SC_ERR_MULTIPLE_RUN_MODE, "more than one run mode " "has been specified"); - usage(argv[0]); + PrintUsage(argv[0]); return TM_ECODE_FAILED; } if (ConfSetFinal("pcap-file.file", optarg) != 1) { @@ -1994,7 +1994,7 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri) } else { SCLogError(SC_ERR_MULTIPLE_RUN_MODE, "more than one run mode has" " been specified"); - usage(argv[0]); + PrintUsage(argv[0]); return TM_ECODE_FAILED; } #else @@ -2039,7 +2039,7 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri) } break; default: - usage(argv[0]); + PrintUsage(argv[0]); return TM_ECODE_FAILED; } } @@ -2161,7 +2161,7 @@ static int InitSignalHandler(SCInstance *suri) /* Try to get user/group to run suricata as if command line as not decide of that */ if (suri->do_setuid == FALSE && suri->do_setgid == FALSE) { - char *id; + const char *id; if (ConfGet("run-as.user", &id) == 1) { suri->do_setuid = TRUE; suri->user_name = id; @@ -2278,7 +2278,7 @@ void PostRunDeinit(const int runmode, struct timeval *start_time) } -int StartInternalRunMode(SCInstance *suri, int argc, char **argv) +static int StartInternalRunMode(SCInstance *suri, int argc, char **argv) { /* Treat internal running mode */ switch(suri->run_mode) { @@ -2292,10 +2292,10 @@ int StartInternalRunMode(SCInstance *suri, int argc, char **argv) PrintVersion(); return TM_ECODE_DONE; case RUNMODE_PRINT_BUILDINFO: - SCPrintBuildInfo(); + PrintBuildInfo(); return TM_ECODE_DONE; case RUNMODE_PRINT_USAGE: - usage(argv[0]); + PrintUsage(argv[0]); return TM_ECODE_DONE; #ifdef __SC_CUDA_SUPPORT__ case RUNMODE_LIST_CUDA_CARDS: @@ -2344,7 +2344,7 @@ static int FinalizeRunMode(SCInstance *suri, char **argv) suri->offline = 1; break; case RUNMODE_UNKNOWN: - usage(argv[0]); + PrintUsage(argv[0]); return TM_ECODE_FAILED; default: break; @@ -2414,7 +2414,7 @@ static int ConfigGetCaptureValue(SCInstance *suri) /* Pull the default packet size from the config, if not found fall * back on a sane default. */ - char *temp_default_packet_size; + const char *temp_default_packet_size; if ((ConfGet("default-packet-size", &temp_default_packet_size)) != 1) { int lthread; int nlive; @@ -2540,7 +2540,7 @@ static void PostConfLoadedDetectSetup(SCInstance *suri) */ static int PostConfLoadedSetup(SCInstance *suri) { - char *hostmode = NULL; + const char *hostmode = NULL; /* do this as early as possible #1577 #1955 */ #ifdef HAVE_LUAJIT @@ -2566,7 +2566,7 @@ static int PostConfLoadedSetup(SCInstance *suri) } if (suri->checksum_validation == -1) { - char *cv = NULL; + const char *cv = NULL; if (ConfGet("capture.checksum-validation", &cv) == 1) { if (strcmp(cv, "none") == 0) { suri->checksum_validation = 0; @@ -2638,7 +2638,7 @@ static int PostConfLoadedSetup(SCInstance *suri) if (suri->run_mode == RUNMODE_ENGINE_ANALYSIS) { SCLogInfo("== Carrying out Engine Analysis =="); - char *temp = NULL; + const char *temp = NULL; if (ConfGet("engine-analysis", &temp) == 0) { SCLogInfo("no engine-analysis parameter(s) defined in conf file. " "Please define/enable them in the conf to use this " @@ -2654,7 +2654,6 @@ static int PostConfLoadedSetup(SCInstance *suri) StorageInit(); CIDRInit(); SigParsePrepare(); - SCReputationInitCtx(); SCProtoNameInit(); TagInitCtx(); @@ -2823,7 +2822,7 @@ int main(int argc, char **argv) * logging module. */ SCLogLoadConfig(suri.daemon, suri.verbose); - SCPrintVersion(); + LogVersion(); UtilCpuPrintSummary(); if (ParseInterfacesList(suri.run_mode, suri.pcap_dev) != TM_ECODE_OK) { diff --git a/src/suricata.h b/src/suricata.h index c93036a234..3192fb82f5 100644 --- a/src/suricata.h +++ b/src/suricata.h @@ -139,14 +139,14 @@ typedef struct SCInstance_ { char pcap_dev[128]; char *sig_file; int sig_file_exclusive; - char *pid_filename; + const char *pid_filename; char *regex_arg; char *keyword_info; char *runmode_custom_mode; #ifndef OS_WIN32 - char *user_name; - char *group_name; + const char *user_name; + const char *group_name; uint8_t do_setuid; uint8_t do_setgid; uint32_t userid; @@ -161,14 +161,14 @@ typedef struct SCInstance_ { struct timeval start_time; - char *log_dir; + const char *log_dir; const char *progname; /**< pointer to argv[0] */ const char *conf_filename; } SCInstance; /* memset to zeros, and mutex init! */ -void GlobalsInitPreConfig(); +void GlobalsInitPreConfig(void); extern volatile uint8_t suricata_ctl_flags; extern int g_disable_randomness; @@ -199,6 +199,7 @@ extern int run_mode_offline; void PreRunInit(const int runmode); void PreRunPostPrivsDropInit(const int runmode); void PostRunDeinit(const int runmode, struct timeval *start_time); +void RegisterAllModules(void); #endif /* __SURICATA_H__ */ diff --git a/src/threads.c b/src/threads.c index 29b924f4a7..1eb4dcb44c 100644 --- a/src/threads.c +++ b/src/threads.c @@ -35,7 +35,7 @@ /** * \brief Test Mutex macros */ -int ThreadMacrosTest01Mutex(void) +static int ThreadMacrosTest01Mutex(void) { SCMutex mut; int r = 0; @@ -63,7 +63,7 @@ int ThreadMacrosTest01Mutex(void) * if a spinlock is actually locked. * */ -int ThreadMacrosTest02Spinlocks(void) +static int ThreadMacrosTest02Spinlocks(void) { SCSpinlock mut; int r = 0; @@ -83,7 +83,7 @@ int ThreadMacrosTest02Spinlocks(void) /** * \brief Test RWLock macros */ -int ThreadMacrosTest03RWLocks(void) +static int ThreadMacrosTest03RWLocks(void) { SCRWLock rwl_write; int r = 0; @@ -105,7 +105,7 @@ int ThreadMacrosTest03RWLocks(void) /** * \brief Test RWLock macros */ -int ThreadMacrosTest04RWLocks(void) +static int ThreadMacrosTest04RWLocks(void) { SCRWLock rwl_read; int r = 0; @@ -118,10 +118,11 @@ int ThreadMacrosTest04RWLocks(void) return (r == 0)? 1 : 0; } +#if 0 // broken on OSX /** * \brief Test RWLock macros */ -int ThreadMacrosTest05RWLocks(void) +static int ThreadMacrosTest05RWLocks(void) { SCRWLock rwl_read; int r = 0; @@ -133,6 +134,7 @@ int ThreadMacrosTest05RWLocks(void) return (r == 0)? 1 : 0; } +#endif #endif /* UNIT TESTS */ @@ -146,5 +148,6 @@ void ThreadMacrosRegisterTests(void) UtRegisterTest("ThreadMacrosTest02Spinlocks", ThreadMacrosTest02Spinlocks); UtRegisterTest("ThreadMacrosTest03RWLocks", ThreadMacrosTest03RWLocks); UtRegisterTest("ThreadMacrosTest04RWLocks", ThreadMacrosTest04RWLocks); +// UtRegisterTest("ThreadMacrosTest05RWLocks", ThreadMacrosTest05RWLocks); #endif /* UNIT TESTS */ } diff --git a/src/threadvars.h b/src/threadvars.h index 82de83bcd8..14aee90e6c 100644 --- a/src/threadvars.h +++ b/src/threadvars.h @@ -71,7 +71,7 @@ typedef struct ThreadVars_ { Tmq *inq; Tmq *outq; void *outctx; - char *outqh_name; + const char *outqh_name; /** queue handlers */ struct Packet_ * (*tmqh_in)(struct ThreadVars_ *); diff --git a/src/tm-modules.h b/src/tm-modules.h index 4e29aa3556..5d41de617b 100644 --- a/src/tm-modules.h +++ b/src/tm-modules.h @@ -36,15 +36,15 @@ #define TM_FLAG_MANAGEMENT_TM 0x20 #define TM_FLAG_COMMAND_TM 0x40 -typedef TmEcode (*ThreadInitFunc)(ThreadVars *, void *, void **); +typedef TmEcode (*ThreadInitFunc)(ThreadVars *, const void *, void **); typedef TmEcode (*ThreadDeinitFunc)(ThreadVars *, void *); typedef void (*ThreadExitPrintStatsFunc)(ThreadVars *, void *); typedef struct TmModule_ { - char *name; + const char *name; /** thread handling */ - TmEcode (*ThreadInit)(ThreadVars *, void *, void **); + TmEcode (*ThreadInit)(ThreadVars *, const void *, void **); void (*ThreadExitPrintStats)(ThreadVars *, void *); TmEcode (*ThreadDeinit)(ThreadVars *, void *); diff --git a/src/tm-queuehandlers.c b/src/tm-queuehandlers.c index 48d06aac61..adf793b595 100644 --- a/src/tm-queuehandlers.c +++ b/src/tm-queuehandlers.c @@ -50,7 +50,7 @@ void TmqhCleanup(void) { } -Tmqh* TmqhGetQueueHandlerByName(char *name) +Tmqh* TmqhGetQueueHandlerByName(const char *name) { int i; diff --git a/src/tm-queuehandlers.h b/src/tm-queuehandlers.h index 28e0ffc14b..592f1811ac 100644 --- a/src/tm-queuehandlers.h +++ b/src/tm-queuehandlers.h @@ -34,11 +34,11 @@ enum { }; typedef struct Tmqh_ { - char *name; + const char *name; Packet *(*InHandler)(ThreadVars *); void (*InShutdownHandler)(ThreadVars *); void (*OutHandler)(ThreadVars *, Packet *); - void *(*OutHandlerCtxSetup)(char *); + void *(*OutHandlerCtxSetup)(const char *); void (*OutHandlerCtxFree)(void *); void (*RegisterTests)(void); } Tmqh; @@ -47,7 +47,7 @@ Tmqh tmqh_table[TMQH_SIZE]; void TmqhSetup (void); void TmqhCleanup(void); -Tmqh* TmqhGetQueueHandlerByName(char *name); +Tmqh* TmqhGetQueueHandlerByName(const char *name); #endif /* __TM_QUEUEHANDLERS_H__ */ diff --git a/src/tm-queues.c b/src/tm-queues.c index b956c71498..bb8c045476 100644 --- a/src/tm-queues.c +++ b/src/tm-queues.c @@ -33,20 +33,7 @@ static uint16_t tmq_id = 0; static Tmq tmqs[TMQ_MAX_QUEUES]; -Tmq* TmqAlloc(void) -{ - Tmq *q = SCMalloc(sizeof(Tmq)); - if (unlikely(q == NULL)) - goto error; - - memset(q, 0, sizeof(Tmq)); - return q; - -error: - return NULL; -} - -Tmq* TmqCreateQueue(char *name) +Tmq *TmqCreateQueue(const char *name) { if (tmq_id >= TMQ_MAX_QUEUES) goto error; @@ -68,7 +55,7 @@ error: return NULL; } -Tmq* TmqGetQueueByName(char *name) +Tmq* TmqGetQueueByName(const char *name) { uint16_t i; diff --git a/src/tm-queues.h b/src/tm-queues.h index 01dbb6e704..32e1e5203c 100644 --- a/src/tm-queues.h +++ b/src/tm-queues.h @@ -33,8 +33,8 @@ typedef struct Tmq_ { uint8_t q_type; } Tmq; -Tmq* TmqCreateQueue(char *name); -Tmq* TmqGetQueueByName(char *name); +Tmq* TmqCreateQueue(const char *name); +Tmq* TmqGetQueueByName(const char *name); void TmqDebugList(void); void TmqResetQueues(void); diff --git a/src/tm-threads.c b/src/tm-threads.c index bede1e05a6..81de56c342 100644 --- a/src/tm-threads.c +++ b/src/tm-threads.c @@ -253,7 +253,7 @@ static int TmThreadTimeoutLoop(ThreadVars *tv, TmSlot *s) */ -void *TmThreadsSlotPktAcqLoop(void *td) +static void *TmThreadsSlotPktAcqLoop(void *td) { /* block usr2. usr2 to be handled by the main thread only */ UtilSignalBlock(SIGUSR2); @@ -390,7 +390,7 @@ error: * * The loop runs in the caller's thread. No separate thread. */ -void *TmThreadsSlotPktAcqLoopAFL(void *td) +static void *TmThreadsSlotPktAcqLoopAFL(void *td) { SCLogNotice("AFL mode starting"); @@ -504,7 +504,7 @@ error: * \todo Only the first "slot" currently makes the "post_pq" available * to the thread module. */ -void *TmThreadsSlotVar(void *td) +static void *TmThreadsSlotVar(void *td) { /* block usr2. usr2 to be handled by the main thread only */ UtilSignalBlock(SIGUSR2); @@ -747,7 +747,7 @@ static void *TmThreadsManagement(void *td) * * \retval TmEcode TM_ECODE_OK on success; TM_ECODE_FAILED on failure. */ -TmEcode TmThreadSetSlots(ThreadVars *tv, char *name, void *(*fn_p)(void *)) +static TmEcode TmThreadSetSlots(ThreadVars *tv, const char *name, void *(*fn_p)(void *)) { if (name == NULL) { if (fn_p == NULL) { @@ -823,11 +823,11 @@ ThreadVars *TmThreadsGetTVContainingSlot(TmSlot *tm_slot) * * \retval The allocated TmSlot or NULL if there is an error */ -static inline TmSlot * _TmSlotSetFuncAppend(ThreadVars *tv, TmModule *tm, void *data) +void TmSlotSetFuncAppend(ThreadVars *tv, TmModule *tm, const void *data) { TmSlot *slot = SCMalloc(sizeof(TmSlot)); if (unlikely(slot == NULL)) - return NULL; + return; memset(slot, 0, sizeof(TmSlot)); SC_ATOMIC_INIT(slot->slot_data); slot->tv = tv; @@ -862,26 +862,7 @@ static inline TmSlot * _TmSlotSetFuncAppend(ThreadVars *tv, TmModule *tm, void * slot->id = b->id + 1; } } - - return slot; -} - -void TmSlotFree(TmSlot *tms) -{ - SC_ATOMIC_DESTROY(tms->slot_data); - SCFree(tms); -} - -/** - * \brief Appends a new entry to the slots. - * - * \param tv TV the slot is attached to. - * \param tm TM to append. - * \param data Data to be passed on to the slot init function. - */ -void TmSlotSetFuncAppend(ThreadVars *tv, TmModule *tm, void *data) -{ - _TmSlotSetFuncAppend(tv, tm, data); + return; } /** @@ -1137,8 +1118,8 @@ TmEcode TmThreadSetupOptions(ThreadVars *tv) * * \retval the newly created TV instance, or NULL on error */ -ThreadVars *TmThreadCreate(const char *name, char *inq_name, char *inqh_name, - char *outq_name, char *outqh_name, char *slots, +ThreadVars *TmThreadCreate(const char *name, const char *inq_name, const char *inqh_name, + const char *outq_name, const char *outqh_name, const char *slots, void * (*fn_p)(void *), int mucond) { ThreadVars *tv = NULL; @@ -1258,9 +1239,9 @@ error: * * \retval the newly created TV instance, or NULL on error */ -ThreadVars *TmThreadCreatePacketHandler(const char *name, char *inq_name, - char *inqh_name, char *outq_name, - char *outqh_name, char *slots) +ThreadVars *TmThreadCreatePacketHandler(const char *name, const char *inq_name, + const char *inqh_name, const char *outq_name, + const char *outqh_name, const char *slots) { ThreadVars *tv = NULL; @@ -1316,7 +1297,7 @@ ThreadVars *TmThreadCreateMgmtThread(const char *name, void *(fn_p)(void *), * * \retval the newly created TV instance, or NULL on error */ -ThreadVars *TmThreadCreateMgmtThreadByName(const char *name, char *module, +ThreadVars *TmThreadCreateMgmtThreadByName(const char *name, const char *module, int mucond) { ThreadVars *tv = NULL; @@ -1349,7 +1330,7 @@ ThreadVars *TmThreadCreateMgmtThreadByName(const char *name, char *module, * * \retval the newly created TV instance, or NULL on error */ -ThreadVars *TmThreadCreateCmdThreadByName(const char *name, char *module, +ThreadVars *TmThreadCreateCmdThreadByName(const char *name, const char *module, int mucond) { ThreadVars *tv = NULL; @@ -1835,7 +1816,7 @@ void TmThreadKillThreads(void) return; } -void TmThreadFree(ThreadVars *tv) +static void TmThreadFree(ThreadVars *tv) { TmSlot *s; TmSlot *ps; diff --git a/src/tm-threads.h b/src/tm-threads.h index ff6fd35fd8..1395db39de 100644 --- a/src/tm-threads.h +++ b/src/tm-threads.h @@ -44,12 +44,12 @@ typedef struct TmSlot_ { TmEcode (*PktAcqLoop)(ThreadVars *, void *, void *); - TmEcode (*SlotThreadInit)(ThreadVars *, void *, void **); + TmEcode (*SlotThreadInit)(ThreadVars *, const void *, void **); void (*SlotThreadExitPrintStats)(ThreadVars *, void *); TmEcode (*SlotThreadDeinit)(ThreadVars *, void *); /* data storage */ - void *slot_initdata; + const void *slot_initdata; SC_ATOMIC_DECLARE(void *, slot_data); /* queue filled by the SlotFunc with packets that will @@ -80,18 +80,17 @@ extern ThreadVars *tv_root[TVT_MAX]; extern SCMutex tv_root_lock; -void TmSlotSetFuncAppend(ThreadVars *, TmModule *, void *); -void TmSlotSetFuncAppendDelayed(ThreadVars *, TmModule *, void *, int delayed); +void TmSlotSetFuncAppend(ThreadVars *, TmModule *, const void *); TmSlot *TmSlotGetSlotForTM(int); -ThreadVars *TmThreadCreate(const char *, char *, char *, char *, char *, char *, +ThreadVars *TmThreadCreate(const char *, const char *, const char *, const char *, const char *, const char *, void *(fn_p)(void *), int); -ThreadVars *TmThreadCreatePacketHandler(const char *, char *, char *, char *, char *, - char *); +ThreadVars *TmThreadCreatePacketHandler(const char *, const char *, const char *, const char *, const char *, + const char *); ThreadVars *TmThreadCreateMgmtThread(const char *name, void *(fn_p)(void *), int); -ThreadVars *TmThreadCreateMgmtThreadByName(const char *name, char *module, +ThreadVars *TmThreadCreateMgmtThreadByName(const char *name, const char *module, int mucond); -ThreadVars *TmThreadCreateCmdThreadByName(const char *name, char *module, +ThreadVars *TmThreadCreateCmdThreadByName(const char *name, const char *module, int mucond); TmEcode TmThreadSpawn(ThreadVars *); void TmThreadSetFlags(ThreadVars *, uint8_t); diff --git a/src/tmqh-flow.c b/src/tmqh-flow.c index cdcfd670a3..6b5f323ed5 100644 --- a/src/tmqh-flow.c +++ b/src/tmqh-flow.c @@ -42,7 +42,7 @@ Packet *TmqhInputFlow(ThreadVars *t); void TmqhOutputFlowHash(ThreadVars *t, Packet *p); void TmqhOutputFlowIPPair(ThreadVars *t, Packet *p); -void *TmqhOutputFlowSetupCtx(char *queue_str); +void *TmqhOutputFlowSetupCtx(const char *queue_str); void TmqhOutputFlowFreeCtx(void *ctx); void TmqhFlowRegisterTests(void); @@ -54,7 +54,7 @@ void TmqhFlowRegister(void) tmqh_table[TMQH_FLOW].OutHandlerCtxFree = TmqhOutputFlowFreeCtx; tmqh_table[TMQH_FLOW].RegisterTests = TmqhFlowRegisterTests; - char *scheduler = NULL; + const char *scheduler = NULL; if (ConfGet("autofp-scheduler", &scheduler) == 1) { if (strcasecmp(scheduler, "round-robin") == 0) { SCLogNotice("using flow hash instead of round robin"); @@ -162,7 +162,7 @@ static int StoreQueueId(TmqhFlowCtx *ctx, char *name) * * \retval ctx queues handlers ctx or NULL in error */ -void *TmqhOutputFlowSetupCtx(char *queue_str) +void *TmqhOutputFlowSetupCtx(const char *queue_str) { if (queue_str == NULL || strlen(queue_str) == 0) return NULL; @@ -303,7 +303,7 @@ static int TmqhOutputFlowSetupCtxTest01(void) if (tmq == NULL) goto end; - char *str = "queue1,queue2,another,yetanother"; + const char *str = "queue1,queue2,another,yetanother"; void *ctx = TmqhOutputFlowSetupCtx(str); if (ctx == NULL) @@ -355,7 +355,7 @@ static int TmqhOutputFlowSetupCtxTest02(void) if (tmq == NULL) goto end; - char *str = "queue1"; + const char *str = "queue1"; void *ctx = TmqhOutputFlowSetupCtx(str); if (ctx == NULL) @@ -387,7 +387,7 @@ static int TmqhOutputFlowSetupCtxTest03(void) TmqResetQueues(); - char *str = "queue1,queue2,another,yetanother"; + const char *str = "queue1,queue2,another,yetanother"; void *ctx = TmqhOutputFlowSetupCtx(str); if (ctx == NULL) diff --git a/src/tmqh-nfq.c b/src/tmqh-nfq.c index 90b9e77a2f..599dc1d255 100644 --- a/src/tmqh-nfq.c +++ b/src/tmqh-nfq.c @@ -30,6 +30,7 @@ #include "threadvars.h" #include "tm-queuehandlers.h" +#include "tmqh-nfq.h" void TmqhOutputVerdictNfq(ThreadVars *t, Packet *p); diff --git a/src/tmqh-simple.c b/src/tmqh-simple.c index bc09dff340..3228aaf1b5 100644 --- a/src/tmqh-simple.c +++ b/src/tmqh-simple.c @@ -30,6 +30,7 @@ #include "threadvars.h" #include "tm-queuehandlers.h" +#include "tmqh-simple.h" Packet *TmqhInputSimple(ThreadVars *t); void TmqhOutputSimple(ThreadVars *t, Packet *p); diff --git a/src/unix-manager.c b/src/unix-manager.c index 5f9a0e49fb..2f942d895c 100644 --- a/src/unix-manager.c +++ b/src/unix-manager.c @@ -91,14 +91,14 @@ typedef struct UnixCommand_ { * * \retval 0 in case of error, 1 in case of success */ -int UnixNew(UnixCommand * this) +static int UnixNew(UnixCommand * this) { struct sockaddr_un addr; int len; int ret; int on = 1; char sockettarget[PATH_MAX]; - char *socketname; + const char *socketname; this->start_timestamp = time(NULL); this->socket = -1; @@ -203,7 +203,7 @@ int UnixNew(UnixCommand * this) return 1; } -void UnixCommandSetMaxFD(UnixCommand *this) +static void UnixCommandSetMaxFD(UnixCommand *this) { UnixClient *item; @@ -247,7 +247,7 @@ static void UnixClientFree(UnixClient *c) /** * \brief Close the unix socket */ -void UnixCommandClose(UnixCommand *this, int fd) +static void UnixCommandClose(UnixCommand *this, int fd) { UnixClient *item; int found = 0; @@ -274,7 +274,7 @@ void UnixCommandClose(UnixCommand *this, int fd) #define UNIX_PROTO_VERSION_LENGTH 200 #define UNIX_PROTO_VERSION "0.1" -int UnixCommandSendJSONToClient(UnixClient *client, json_t *js) +static int UnixCommandSendJSONToClient(UnixClient *client, json_t *js) { MemBufferReset(client->mbuf); @@ -314,7 +314,7 @@ int UnixCommandSendJSONToClient(UnixClient *client, json_t *js) * * \retval 0 in case of error, 1 in case of success */ -int UnixCommandAccept(UnixCommand *this) +static int UnixCommandAccept(UnixCommand *this) { char buffer[UNIX_PROTO_VERSION_LENGTH + 1]; json_t *client_msg; @@ -416,7 +416,7 @@ int UnixCommandAccept(UnixCommand *this) return 1; } -int UnixCommandBackgroundTasks(UnixCommand* this) +static int UnixCommandBackgroundTasks(UnixCommand* this) { int ret = 1; Task *ltask; @@ -439,7 +439,7 @@ int UnixCommandBackgroundTasks(UnixCommand* this) * * \retval 0 in case of error, 1 in case of success */ -int UnixCommandExecute(UnixCommand * this, char *command, UnixClient *client) +static int UnixCommandExecute(UnixCommand * this, char *command, UnixClient *client) { int ret = 1; json_error_t error; @@ -516,7 +516,7 @@ error: return 0; } -void UnixCommandRun(UnixCommand * this, UnixClient *client) +static void UnixCommandRun(UnixCommand * this, UnixClient *client) { char buffer[4096]; int ret; @@ -545,7 +545,7 @@ void UnixCommandRun(UnixCommand * this, UnixClient *client) * * \retval 0 in case of error, 1 in case of success */ -int UnixMain(UnixCommand * this) +static int UnixMain(UnixCommand * this) { struct timeval tv; int ret; @@ -599,52 +599,7 @@ int UnixMain(UnixCommand * this) return 1; } -/** - * \brief Used to kill unix manager thread(s). - * - * \todo Kinda hackish since it uses the tv name to identify unix manager - * thread. We need an all weather identification scheme. - */ -void UnixKillUnixManagerThread(void) -{ - ThreadVars *tv = NULL; - int cnt = 0; - -again: - SCCtrlCondSignal(&unix_manager_ctrl_cond); - SCMutexLock(&tv_root_lock); - - /* flow manager thread(s) is/are a part of mgmt threads */ - tv = tv_root[TVT_CMD]; - - while (tv != NULL) { - if (strcasecmp(tv->name, "UnixManagerThread") == 0) { - TmThreadsSetFlag(tv, THV_KILL); - TmThreadsSetFlag(tv, THV_DEINIT); - - /* be sure it has shut down */ - if(!(TmThreadsCheckFlag(tv, THV_CLOSED))) { - SCMutexUnlock(&tv_root_lock); - usleep(100); - goto again; - } - cnt++; - } - tv = tv->next; - } - - /* not possible, unless someone decides to rename UnixManagerThread */ - if (cnt == 0) { - SCMutexUnlock(&tv_root_lock); - abort(); - } - - SCMutexUnlock(&tv_root_lock); - return; -} - - -TmEcode UnixManagerShutdownCommand(json_t *cmd, +static TmEcode UnixManagerShutdownCommand(json_t *cmd, json_t *server_msg, void *data) { SCEnter(); @@ -653,7 +608,7 @@ TmEcode UnixManagerShutdownCommand(json_t *cmd, SCReturnInt(TM_ECODE_OK); } -TmEcode UnixManagerVersionCommand(json_t *cmd, +static TmEcode UnixManagerVersionCommand(json_t *cmd, json_t *server_msg, void *data) { SCEnter(); @@ -669,7 +624,7 @@ TmEcode UnixManagerVersionCommand(json_t *cmd, SCReturnInt(TM_ECODE_OK); } -TmEcode UnixManagerUptimeCommand(json_t *cmd, +static TmEcode UnixManagerUptimeCommand(json_t *cmd, json_t *server_msg, void *data) { SCEnter(); @@ -681,7 +636,7 @@ TmEcode UnixManagerUptimeCommand(json_t *cmd, SCReturnInt(TM_ECODE_OK); } -TmEcode UnixManagerRunningModeCommand(json_t *cmd, +static TmEcode UnixManagerRunningModeCommand(json_t *cmd, json_t *server_msg, void *data) { SCEnter(); @@ -689,7 +644,7 @@ TmEcode UnixManagerRunningModeCommand(json_t *cmd, SCReturnInt(TM_ECODE_OK); } -TmEcode UnixManagerCaptureModeCommand(json_t *cmd, +static TmEcode UnixManagerCaptureModeCommand(json_t *cmd, json_t *server_msg, void *data) { SCEnter(); @@ -697,7 +652,7 @@ TmEcode UnixManagerCaptureModeCommand(json_t *cmd, SCReturnInt(TM_ECODE_OK); } -TmEcode UnixManagerReloadRules(json_t *cmd, json_t *server_msg, void *data) +static TmEcode UnixManagerReloadRules(json_t *cmd, json_t *server_msg, void *data) { SCEnter(); DetectEngineReloadStart(); @@ -709,12 +664,12 @@ TmEcode UnixManagerReloadRules(json_t *cmd, json_t *server_msg, void *data) SCReturnInt(TM_ECODE_OK); } -TmEcode UnixManagerConfGetCommand(json_t *cmd, +static TmEcode UnixManagerConfGetCommand(json_t *cmd, json_t *server_msg, void *data) { SCEnter(); - char *confval = NULL; + const char *confval = NULL; char *variable = NULL; json_t *jarg = json_object_get(cmd, "variable"); @@ -739,7 +694,7 @@ TmEcode UnixManagerConfGetCommand(json_t *cmd, SCReturnInt(TM_ECODE_FAILED); } -TmEcode UnixManagerListCommand(json_t *cmd, +static TmEcode UnixManagerListCommand(json_t *cmd, json_t *answer, void *data) { SCEnter(); @@ -895,7 +850,7 @@ typedef struct UnixManagerThreadData_ { int padding; } UnixManagerThreadData; -static TmEcode UnixManagerThreadInit(ThreadVars *t, void *initdata, void **data) +static TmEcode UnixManagerThreadInit(ThreadVars *t, const void *initdata, void **data) { UnixManagerThreadData *utd = SCCalloc(1, sizeof(*utd)); if (utd == NULL) diff --git a/src/util-action.c b/src/util-action.c index a47e79dfca..769135a027 100644 --- a/src/util-action.c +++ b/src/util-action.c @@ -74,7 +74,7 @@ uint8_t ActionOrderVal(uint8_t action) * \retval uint8_t can be one of ACTION_PASS, ACTION_DROP, * ACTION_REJECT or ACTION_ALERT */ -uint8_t ActionAsciiToFlag(char *action) +static uint8_t ActionAsciiToFlag(const char *action) { if (strcmp(action,"pass") == 0) return ACTION_PASS; @@ -168,7 +168,7 @@ int ActionInitConfig() * \test Check that we invalidate duplicated actions * (It should default to pass, drop, reject, alert) */ -int UtilActionTest01(void) +static int UtilActionTest01(void) { int res = 1; char config[] = "\ @@ -206,7 +206,7 @@ action-order:\n\ * \test Check that we invalidate with unknown keywords * (It should default to pass, drop, reject, alert) */ -int UtilActionTest02(void) +static int UtilActionTest02(void) { int res = 1; char config[] = "\ @@ -244,7 +244,7 @@ action-order:\n\ * \test Check that we invalidate if any action is missing * (It should default to pass, drop, reject, alert) */ -int UtilActionTest03(void) +static int UtilActionTest03(void) { int res = 1; char config[] = "\ @@ -281,7 +281,7 @@ action-order:\n\ * \test Check that we invalidate if any action is missing * (It should default to pass, drop, reject, alert) */ -int UtilActionTest04(void) +static int UtilActionTest04(void) { int res = 1; char config[] = "\ @@ -316,7 +316,7 @@ action-order:\n"; * and/or more than the expected * (It should default to pass, drop, reject, alert) */ -int UtilActionTest05(void) +static int UtilActionTest05(void) { int res = 1; char config[] = "\ @@ -354,7 +354,7 @@ action-order:\n\ /** * \test Check that we load a valid config */ -int UtilActionTest06(void) +static int UtilActionTest06(void) { int res = 1; char config[] = "\ @@ -391,7 +391,7 @@ action-order:\n\ /** * \test Check that we load a valid config */ -int UtilActionTest07(void) +static int UtilActionTest07(void) { int res = 1; char config[] = "\ @@ -429,7 +429,7 @@ action-order:\n\ * \test Check that we handle the "pass" action * correctly at the IP Only engine in the default case */ -int UtilActionTest08(void) +static int UtilActionTest08(void) { int res = 0; uint8_t *buf = (uint8_t *)"Hi all!"; @@ -448,7 +448,7 @@ int UtilActionTest08(void) if (p[0] == NULL || p[1] == NULL ||p[2] == NULL) goto end; - char *sigs[3]; + const char *sigs[3]; sigs[0]= "alert ip any any -> any any (msg:\"sig 1\"; sid:1;)"; sigs[1]= "pass ip 192.168.1.1 80 -> any any (msg:\"sig 2\"; sid:2;)"; sigs[2]= "alert ip any any -> any any (msg:\"sig 3\"; sid:3;)"; @@ -494,7 +494,7 @@ end: * correctly at the IP Only engine with more * prio to drop */ -int UtilActionTest09(void) +static int UtilActionTest09(void) { int res = 1; uint8_t *buf = (uint8_t *)"Hi all!"; @@ -519,7 +519,7 @@ int UtilActionTest09(void) if (p[0] == NULL || p[1] == NULL ||p[2] == NULL) goto end; - char *sigs[3]; + const char *sigs[3]; sigs[0]= "alert ip any any -> any any (msg:\"sig 1\"; sid:1;)"; sigs[1]= "pass ip 192.168.1.1 80 -> any any (msg:\"sig 2\"; sid:2;)"; sigs[2]= "drop ip any any -> any any (msg:\"sig 3\"; sid:3;)"; @@ -570,7 +570,7 @@ end: * \test Check that we handle the "pass" action * correctly at the detection engine in the default case */ -int UtilActionTest10(void) +static int UtilActionTest10(void) { int res = 0; uint8_t *buf = (uint8_t *)"Hi all!"; @@ -591,7 +591,7 @@ int UtilActionTest10(void) if (p[0] == NULL || p[1] == NULL ||p[2] == NULL) goto end; - char *sigs[3]; + const char *sigs[3]; sigs[0]= "alert ip any any -> any any (msg:\"sig 1\"; content:\"Hi all\"; sid:1;)"; sigs[1]= "pass ip any any -> any any (msg:\"sig 2\"; content:\"wo\"; sid:2;)"; sigs[2]= "alert ip any any -> any any (msg:\"sig 3\"; content:\"Hi all\"; sid:3;)"; @@ -637,7 +637,7 @@ end: * correctly at the detection engine with more * prio to drop */ -int UtilActionTest11(void) +static int UtilActionTest11(void) { int res = 1; uint8_t *buf = (uint8_t *)"Hi all!"; @@ -664,7 +664,7 @@ int UtilActionTest11(void) if (p[0] == NULL || p[1] == NULL ||p[2] == NULL) goto end; - char *sigs[3]; + const char *sigs[3]; sigs[0]= "alert tcp any any -> any any (msg:\"sig 1\"; content:\"Hi all\"; sid:1;)"; sigs[1]= "pass tcp any any -> any any (msg:\"sig 2\"; content:\"wo\"; sid:2;)"; sigs[2]= "drop tcp any any -> any any (msg:\"sig 3\"; content:\"Hi all\"; sid:3;)"; @@ -715,7 +715,7 @@ end: * \test Check that we handle the "pass" action * correctly at the detection engine in the default case */ -int UtilActionTest12(void) +static int UtilActionTest12(void) { int res = 0; uint8_t *buf = (uint8_t *)"Hi all!"; @@ -734,7 +734,7 @@ int UtilActionTest12(void) if (p[0] == NULL || p[1] == NULL ||p[2] == NULL) goto end; - char *sigs[3]; + const char *sigs[3]; sigs[0]= "alert ip any any -> any any (msg:\"sig 1\"; sid:1;)"; sigs[1]= "pass ip any any -> any any (msg:\"Testing normal 2\"; sid:2;)"; sigs[2]= "alert ip any any -> any any (msg:\"sig 3\"; sid:3;)"; @@ -778,7 +778,7 @@ end: * correctly at the detection engine with more * prio to drop */ -int UtilActionTest13(void) +static int UtilActionTest13(void) { int res = 1; uint8_t *buf = (uint8_t *)"Hi all!"; @@ -803,7 +803,7 @@ int UtilActionTest13(void) if (p[0] == NULL || p[1] == NULL ||p[2] == NULL) goto end; - char *sigs[3]; + const char *sigs[3]; sigs[0]= "alert tcp any any -> any any (msg:\"sig 1\"; content:\"Hi all\"; sid:1;)"; sigs[1]= "pass tcp any any -> any any (msg:\"sig 2\"; content:\"Hi all\"; sid:2;)"; sigs[2]= "drop tcp any any -> any any (msg:\"sig 3\"; content:\"Hi all\"; sid:3;)"; @@ -853,7 +853,7 @@ end: * correctly at the detection engine with more * prio to drop and alert */ -int UtilActionTest14(void) +static int UtilActionTest14(void) { int res = 1; uint8_t *buf = (uint8_t *)"Hi all!"; @@ -878,7 +878,7 @@ int UtilActionTest14(void) if (p[0] == NULL || p[1] == NULL ||p[2] == NULL) goto end; - char *sigs[3]; + const char *sigs[3]; sigs[0]= "alert tcp any any -> any any (msg:\"sig 1\"; content:\"Hi all\"; sid:1;)"; sigs[1]= "pass tcp any any -> any any (msg:\"sig 2\"; content:\"Hi all\"; sid:2;)"; sigs[2]= "drop tcp any any -> any any (msg:\"sig 3\"; content:\"Hi all\"; sid:3;)"; @@ -927,7 +927,7 @@ end: /** * \test Check mixed sigs (iponly and normal) */ -int UtilActionTest15(void) +static int UtilActionTest15(void) { int res = 1; uint8_t *buf = (uint8_t *)"Hi all!"; @@ -947,7 +947,7 @@ int UtilActionTest15(void) if (p[0] == NULL || p[1] == NULL ||p[2] == NULL) goto end; - char *sigs[3]; + const char *sigs[3]; sigs[0]= "alert tcp any any -> any any (msg:\"sig 1\"; sid:1;)"; sigs[1]= "pass tcp any any -> any any (msg:\"sig 2\"; content:\"Hi all\"; sid:2;)"; sigs[2]= "drop tcp any any -> any any (msg:\"sig 3\"; sid:3;)"; @@ -991,7 +991,7 @@ end: /** * \test Check mixed sigs (iponly and normal) */ -int UtilActionTest16(void) +static int UtilActionTest16(void) { int res = 1; uint8_t *buf = (uint8_t *)"Hi all!"; @@ -1011,7 +1011,7 @@ int UtilActionTest16(void) if (p[0] == NULL || p[1] == NULL ||p[2] == NULL) goto end; - char *sigs[3]; + const char *sigs[3]; sigs[0]= "drop tcp any any -> any any (msg:\"sig 1\"; sid:1;)"; sigs[1]= "alert tcp any any -> any any (msg:\"sig 2\"; content:\"Hi all\"; sid:2;)"; sigs[2]= "pass tcp any any -> any any (msg:\"sig 3\"; sid:3;)"; @@ -1055,7 +1055,7 @@ end: /** * \test Check mixed sigs (iponly and normal) */ -int UtilActionTest17(void) +static int UtilActionTest17(void) { int res = 1; uint8_t *buf = (uint8_t *)"Hi all!"; @@ -1075,7 +1075,7 @@ int UtilActionTest17(void) if (p[0] == NULL || p[1] == NULL ||p[2] == NULL) goto end; - char *sigs[3]; + const char *sigs[3]; sigs[0]= "pass tcp any any -> any any (msg:\"sig 1\"; sid:1;)"; sigs[1]= "drop tcp any any -> any any (msg:\"sig 2\"; content:\"Hi all\"; sid:2;)"; sigs[2]= "alert tcp any any -> any any (msg:\"sig 3\"; sid:3;)"; @@ -1119,7 +1119,7 @@ end: /** * \test Check mixed sigs (iponly and normal) with more prio for drop */ -int UtilActionTest18(void) +static int UtilActionTest18(void) { int res = 1; uint8_t *buf = (uint8_t *)"Hi all!"; @@ -1144,7 +1144,7 @@ int UtilActionTest18(void) if (p[0] == NULL || p[1] == NULL ||p[2] == NULL) goto end; - char *sigs[3]; + const char *sigs[3]; sigs[0]= "alert tcp any any -> any any (msg:\"sig 1\"; sid:1;)"; sigs[1]= "pass tcp any any -> any any (msg:\"sig 2\"; content:\"Hi all\"; sid:2;)"; sigs[2]= "drop tcp any any -> any any (msg:\"sig 3\"; sid:3;)"; @@ -1194,7 +1194,7 @@ end: /** * \test Check mixed sigs (iponly and normal) with more prio for drop */ -int UtilActionTest19(void) +static int UtilActionTest19(void) { int res = 1; uint8_t *buf = (uint8_t *)"Hi all!"; @@ -1219,7 +1219,7 @@ int UtilActionTest19(void) if (p[0] == NULL || p[1] == NULL ||p[2] == NULL) goto end; - char *sigs[3]; + const char *sigs[3]; sigs[0]= "drop tcp any any -> any any (msg:\"sig 1\"; sid:1;)"; sigs[1]= "alert tcp any any -> any any (msg:\"sig 2\"; content:\"Hi all\"; sid:2;)"; sigs[2]= "pass tcp any any -> any any (msg:\"sig 3\"; sid:3;)"; @@ -1269,7 +1269,7 @@ end: /** * \test Check mixed sigs (iponly and normal) with more prio for drop */ -int UtilActionTest20(void) +static int UtilActionTest20(void) { int res = 1; uint8_t *buf = (uint8_t *)"Hi all!"; @@ -1294,7 +1294,7 @@ int UtilActionTest20(void) if (p[0] == NULL || p[1] == NULL ||p[2] == NULL) goto end; - char *sigs[3]; + const char *sigs[3]; sigs[0]= "pass tcp any any -> any any (msg:\"sig 1\"; sid:1;)"; sigs[1]= "drop tcp any any -> any any (msg:\"sig 2\"; content:\"Hi all\"; sid:2;)"; sigs[2]= "alert tcp any any -> any any (msg:\"sig 3\"; sid:3;)"; @@ -1338,7 +1338,7 @@ end: /** * \test Check mixed sigs (iponly and normal) with more prio for alert and drop */ -int UtilActionTest21(void) +static int UtilActionTest21(void) { int res = 1; uint8_t *buf = (uint8_t *)"Hi all!"; @@ -1363,7 +1363,7 @@ int UtilActionTest21(void) if (p[0] == NULL || p[1] == NULL ||p[2] == NULL) goto end; - char *sigs[3]; + const char *sigs[3]; sigs[0]= "alert tcp any any -> any any (msg:\"sig 1\"; sid:1;)"; sigs[1]= "pass tcp any any -> any any (msg:\"sig 2\"; content:\"Hi all\"; sid:2;)"; sigs[2]= "drop tcp any any -> any any (msg:\"sig 3\"; sid:3;)"; @@ -1413,7 +1413,7 @@ end: /** * \test Check mixed sigs (iponly and normal) with more prio for alert and drop */ -int UtilActionTest22(void) +static int UtilActionTest22(void) { int res = 1; uint8_t *buf = (uint8_t *)"Hi all!"; @@ -1438,7 +1438,7 @@ int UtilActionTest22(void) if (p[0] == NULL || p[1] == NULL ||p[2] == NULL) goto end; - char *sigs[3]; + const char *sigs[3]; sigs[0]= "drop tcp any any -> any any (msg:\"sig 1\"; sid:1;)"; sigs[1]= "alert tcp any any -> any any (msg:\"sig 2\"; content:\"Hi all\"; sid:2;)"; sigs[2]= "pass tcp any any -> any any (msg:\"sig 3\"; sid:3;)"; @@ -1488,7 +1488,7 @@ end: /** * \test Check mixed sigs (iponly and normal) with more prio for alert and drop */ -int UtilActionTest23(void) +static int UtilActionTest23(void) { int res = 1; uint8_t *buf = (uint8_t *)"Hi all!"; @@ -1513,7 +1513,7 @@ int UtilActionTest23(void) if (p[0] == NULL || p[1] == NULL ||p[2] == NULL) goto end; - char *sigs[3]; + const char *sigs[3]; sigs[0]= "pass tcp any any -> any any (msg:\"sig 1\"; sid:1;)"; sigs[1]= "drop tcp any any -> any any (msg:\"sig 2\"; content:\"Hi all\"; sid:2;)"; sigs[2]= "alert tcp any any -> any any (msg:\"sig 3\"; sid:3;)"; @@ -1564,7 +1564,7 @@ end: * \test Check that the expected defaults are loaded if the * action-order configuration is not present. */ -int UtilActionTest24(void) +static int UtilActionTest24(void) { int res = 1; char config[] = "%YAML 1.1\n" diff --git a/src/util-action.h b/src/util-action.h index bc71131443..0413067609 100644 --- a/src/util-action.h +++ b/src/util-action.h @@ -23,8 +23,10 @@ #ifndef __ACTION_ORDER_H__ #define __ACTION_ORDER_H__ + #include "suricata-common.h" -int ActionInitConfig(); + +int ActionInitConfig(void); uint8_t ActionOrderVal(uint8_t); void UtilActionRegisterTests(void); diff --git a/src/util-affinity.c b/src/util-affinity.c index 37539aef66..88614a3f70 100644 --- a/src/util-affinity.c +++ b/src/util-affinity.c @@ -77,7 +77,7 @@ ThreadsAffinityType * GetAffinityTypeFromName(const char *name) } #if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined sun -static void AffinitySetupInit() +static void AffinitySetupInit(void) { int i, j; int ncpu = UtilCpuGetNumProcessorsConfigured(); diff --git a/src/util-affinity.h b/src/util-affinity.h index bd9e1626ea..7e846f4a2d 100644 --- a/src/util-affinity.h +++ b/src/util-affinity.h @@ -81,7 +81,7 @@ typedef struct ThreadsAffinityType_ { extern ThreadsAffinityType thread_affinity[MAX_CPU_SET]; #endif -void AffinitySetupLoadFromConfig(); +void AffinitySetupLoadFromConfig(void); ThreadsAffinityType * GetAffinityTypeFromName(const char *name); int AffinityGetNextCPU(ThreadsAffinityType *taf); diff --git a/src/util-bloomfilter-counting.c b/src/util-bloomfilter-counting.c index 66dac54d77..cbf99e5bae 100644 --- a/src/util-bloomfilter-counting.c +++ b/src/util-bloomfilter-counting.c @@ -31,7 +31,7 @@ /* type: 1, 2 or 4 for 8, 16, or 32 bit counters * */ -BloomFilterCounting *BloomFilterCountingInit(uint32_t size, uint8_t type, uint8_t iter, uint32_t (*Hash)(void *, uint16_t, uint8_t, uint32_t)) { +BloomFilterCounting *BloomFilterCountingInit(uint32_t size, uint8_t type, uint8_t iter, uint32_t (*Hash)(const void *, uint16_t, uint8_t, uint32_t)) { BloomFilterCounting *bf = NULL; if (iter == 0) @@ -96,7 +96,7 @@ void BloomFilterCountingPrint(BloomFilterCounting *bf) printf("-----------------------------------------\n"); } -int BloomFilterCountingAdd(BloomFilterCounting *bf, void *data, uint16_t datalen) +int BloomFilterCountingAdd(BloomFilterCounting *bf, const void *data, uint16_t datalen) { uint8_t iter = 0; uint32_t hash = 0; @@ -124,7 +124,7 @@ int BloomFilterCountingAdd(BloomFilterCounting *bf, void *data, uint16_t datalen return 0; } -int BloomFilterCountingRemove(BloomFilterCounting *bf, void *data, uint16_t datalen) +int BloomFilterCountingRemove(BloomFilterCounting *bf, const void *data, uint16_t datalen) { uint8_t iter = 0; uint32_t hash = 0; @@ -180,7 +180,7 @@ int BloomFilterCountingRemove(BloomFilterCounting *bf, void *data, uint16_t data * returns 0: for no match * 1: match */ -int BloomFilterCountingTest(BloomFilterCounting *bf, void *data, uint16_t datalen) +int BloomFilterCountingTest(BloomFilterCounting *bf, const void *data, uint16_t datalen) { uint8_t iter = 0; uint32_t hash = 0; @@ -218,7 +218,7 @@ int BloomFilterCountingTest(BloomFilterCounting *bf, void *data, uint16_t datale */ #ifdef UNITTESTS -static uint32_t BloomHash(void *data, uint16_t datalen, uint8_t iter, uint32_t hash_size) +static uint32_t BloomHash(const void *data, uint16_t datalen, uint8_t iter, uint32_t hash_size) { uint8_t *d = (uint8_t *)data; uint32_t i; diff --git a/src/util-bloomfilter-counting.h b/src/util-bloomfilter-counting.h index 80d790bec7..bdb0cfa09c 100644 --- a/src/util-bloomfilter-counting.h +++ b/src/util-bloomfilter-counting.h @@ -30,16 +30,16 @@ typedef struct BloomFilterCounting_ { uint32_t array_size; /* size in buckets */ uint8_t type; /* 1, 2 or 4 byte counters */ uint8_t hash_iterations; - uint32_t (*Hash)(void *, uint16_t, uint8_t, uint32_t); + uint32_t (*Hash)(const void *, uint16_t, uint8_t, uint32_t); } BloomFilterCounting; /* prototypes */ -BloomFilterCounting *BloomFilterCountingInit(uint32_t, uint8_t, uint8_t, uint32_t (*Hash)(void *, uint16_t, uint8_t, uint32_t)); +BloomFilterCounting *BloomFilterCountingInit(uint32_t, uint8_t, uint8_t, uint32_t (*Hash)(const void *, uint16_t, uint8_t, uint32_t)); void BloomFilterCountingFree(BloomFilterCounting *); void BloomFilterCountingPrint(BloomFilterCounting *); -int BloomFilterCountingAdd(BloomFilterCounting *, void *, uint16_t); -int BloomFilterCountingRemove(BloomFilterCounting *, void *, uint16_t); -int BloomFilterCountingTest(BloomFilterCounting *, void *, uint16_t); +int BloomFilterCountingAdd(BloomFilterCounting *, const void *, uint16_t); +int BloomFilterCountingRemove(BloomFilterCounting *, const void *, uint16_t); +int BloomFilterCountingTest(BloomFilterCounting *, const void *, uint16_t); void BloomFilterCountingRegisterTests(void); diff --git a/src/util-bloomfilter.c b/src/util-bloomfilter.c index 7403f5f762..ae0b045322 100644 --- a/src/util-bloomfilter.c +++ b/src/util-bloomfilter.c @@ -86,7 +86,7 @@ void BloomFilterPrint(BloomFilter *bf) printf("-----------------------------------------\n"); } -int BloomFilterAdd(BloomFilter *bf, void *data, uint16_t datalen) +int BloomFilterAdd(BloomFilter *bf, const void *data, uint16_t datalen) { uint8_t iter = 0; uint32_t hash = 0; diff --git a/src/util-bloomfilter.h b/src/util-bloomfilter.h index 59b5dcdca5..b6dee868a5 100644 --- a/src/util-bloomfilter.h +++ b/src/util-bloomfilter.h @@ -36,7 +36,7 @@ typedef struct BloomFilter_ { BloomFilter *BloomFilterInit(uint32_t, uint8_t, uint32_t (*Hash)(const void *, uint16_t, uint8_t, uint32_t)); void BloomFilterFree(BloomFilter *); void BloomFilterPrint(BloomFilter *); -int BloomFilterAdd(BloomFilter *, void *, uint16_t); +int BloomFilterAdd(BloomFilter *, const void *, uint16_t); uint32_t BloomFilterMemoryCnt(BloomFilter *); uint32_t BloomFilterMemorySize(BloomFilter *); diff --git a/src/util-byte.c b/src/util-byte.c index f0d0a1332c..30a5fdbbbc 100644 --- a/src/util-byte.c +++ b/src/util-byte.c @@ -602,11 +602,9 @@ static int ByteTest16 (void) return 0; } -#endif /* UNITTESTS */ void ByteRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("ByteTest01", ByteTest01); UtRegisterTest("ByteTest02", ByteTest02); UtRegisterTest("ByteTest03", ByteTest03); @@ -623,7 +621,6 @@ void ByteRegisterTests(void) UtRegisterTest("ByteTest14", ByteTest14); UtRegisterTest("ByteTest15", ByteTest15); UtRegisterTest("ByteTest16", ByteTest16); -#endif /* UNITTESTS */ } - +#endif /* UNITTESTS */ diff --git a/src/util-cidr.c b/src/util-cidr.c index 300a44551b..7889a5ecf4 100644 --- a/src/util-cidr.c +++ b/src/util-cidr.c @@ -24,6 +24,7 @@ */ #include "suricata-common.h" +#include "util-cidr.h" static uint32_t cidrs[33]; diff --git a/src/util-classification-config.c b/src/util-classification-config.c index a5d4bdbe99..b4dbf37ead 100644 --- a/src/util-classification-config.c +++ b/src/util-classification-config.c @@ -54,7 +54,7 @@ uint32_t SCClassConfClasstypeHashFunc(HashTable *ht, void *data, uint16_t datale char SCClassConfClasstypeHashCompareFunc(void *data1, uint16_t datalen1, void *data2, uint16_t datalen2); void SCClassConfClasstypeHashFree(void *ch); -static char *SCClassConfGetConfFilename(const DetectEngineCtx *de_ctx); +static const char *SCClassConfGetConfFilename(const DetectEngineCtx *de_ctx); void SCClassConfInit(void) { @@ -105,9 +105,9 @@ void SCClassConfDeinit(void) * * \retval fp NULL on error */ -FILE *SCClassConfInitContextAndLocalResources(DetectEngineCtx *de_ctx, FILE *fd) +static FILE *SCClassConfInitContextAndLocalResources(DetectEngineCtx *de_ctx, FILE *fd) { - char *filename = NULL; + const char *filename = NULL; /* init the hash table to be used by the classification config Classtypes */ de_ctx->class_conf_ht = HashTableInit(128, SCClassConfClasstypeHashFunc, @@ -160,9 +160,9 @@ FILE *SCClassConfInitContextAndLocalResources(DetectEngineCtx *de_ctx, FILE *fd) * \retval log_filename Pointer to a string containing the path for the * Classification Config file. */ -static char *SCClassConfGetConfFilename(const DetectEngineCtx *de_ctx) +static const char *SCClassConfGetConfFilename(const DetectEngineCtx *de_ctx) { - char *log_filename = NULL; + const char *log_filename = NULL; if (de_ctx != NULL && strlen(de_ctx->config_prefix) > 0) { char config_value[256]; @@ -244,7 +244,7 @@ static char *SCClassConfStringToLowercase(const char *str) * \retval 0 On success. * \retval -1 On failure. */ -int SCClassConfAddClasstype(char *rawstr, uint8_t index, DetectEngineCtx *de_ctx) +static int SCClassConfAddClasstype(char *rawstr, uint8_t index, DetectEngineCtx *de_ctx) { char ct_name[64]; char ct_desc[512]; @@ -352,7 +352,7 @@ static int SCClassConfIsLineBlankOrComment(char *line) * * \param de_ctx Pointer to the Detection Engine Context. */ -void SCClassConfParseFile(DetectEngineCtx *de_ctx, FILE *fd) +static void SCClassConfParseFile(DetectEngineCtx *de_ctx, FILE *fd) { char line[1024]; uint8_t i = 1; @@ -648,7 +648,7 @@ FILE *SCClassConfGenerateInValidDummyClassConfigFD03(void) * \test Check that the classification file is loaded and the detection engine * content class_conf_hash_table loaded with the classtype data. */ -int SCClassConfTest01(void) +static int SCClassConfTest01(void) { DetectEngineCtx *de_ctx = DetectEngineCtxInit(); int result = 0; @@ -674,7 +674,7 @@ int SCClassConfTest01(void) * \test Check that invalid classtypes present in the classification config file * aren't loaded. */ -int SCClassConfTest02(void) +static int SCClassConfTest02(void) { DetectEngineCtx *de_ctx = DetectEngineCtxInit(); int result = 0; @@ -699,7 +699,7 @@ int SCClassConfTest02(void) * \test Check that only valid classtypes are loaded into the hash table from * the classfication.config file. */ -int SCClassConfTest03(void) +static int SCClassConfTest03(void) { DetectEngineCtx *de_ctx = DetectEngineCtxInit(); int result = 0; @@ -724,7 +724,7 @@ int SCClassConfTest03(void) * \test Check if the classtype info from the classification.config file have * been loaded into the hash table. */ -int SCClassConfTest04(void) +static int SCClassConfTest04(void) { DetectEngineCtx *de_ctx = DetectEngineCtxInit(); int result = 1; @@ -757,7 +757,7 @@ int SCClassConfTest04(void) * have not been loaded into the hash table, and cross verify to check * that the hash table contains no classtype data. */ -int SCClassConfTest05(void) +static int SCClassConfTest05(void) { DetectEngineCtx *de_ctx = DetectEngineCtxInit(); int result = 1; @@ -789,7 +789,7 @@ int SCClassConfTest05(void) * \test Check if the classtype info from the classification.config file have * been loaded into the hash table. */ -int SCClassConfTest06(void) +static int SCClassConfTest06(void) { DetectEngineCtx *de_ctx = DetectEngineCtxInit(); int result = 1; diff --git a/src/util-conf.c b/src/util-conf.c index 0c81178ec5..388a1541d8 100644 --- a/src/util-conf.c +++ b/src/util-conf.c @@ -32,9 +32,9 @@ TmEcode ConfigSetLogDirectory(char *name) return ConfSetFinal("default-log-dir", name) ? TM_ECODE_OK : TM_ECODE_FAILED; } -char *ConfigGetLogDirectory() +const char *ConfigGetLogDirectory() { - char *log_dir = NULL; + const char *log_dir = NULL; if (ConfGet("default-log-dir", &log_dir) != 1) { #ifdef OS_WIN32 @@ -50,7 +50,7 @@ char *ConfigGetLogDirectory() return log_dir; } -TmEcode ConfigCheckLogDirectory(char *log_dir) +TmEcode ConfigCheckLogDirectory(const char *log_dir) { SCEnter(); #ifdef OS_WIN32 @@ -94,7 +94,7 @@ ConfNode *ConfFindDeviceConfig(ConfNode *node, const char *iface) int ConfUnixSocketIsEnable(void) { - char *value; + const char *value; if (ConfGet("unix-command.enabled", &value) != 1) { return 0; diff --git a/src/util-conf.h b/src/util-conf.h index 08727567f5..6be51d6845 100644 --- a/src/util-conf.h +++ b/src/util-conf.h @@ -28,8 +28,8 @@ #include "conf.h" TmEcode ConfigSetLogDirectory(char *name); -char *ConfigGetLogDirectory(); -TmEcode ConfigCheckLogDirectory(char *log_dir); +const char *ConfigGetLogDirectory(void); +TmEcode ConfigCheckLogDirectory(const char *log_dir); ConfNode *ConfFindDeviceConfig(ConfNode *node, const char *iface); diff --git a/src/util-coredump-config.c b/src/util-coredump-config.c index 8677211b60..a88b3f32be 100644 --- a/src/util-coredump-config.c +++ b/src/util-coredump-config.c @@ -40,7 +40,7 @@ int32_t CoredumpLoadConfig (void) { #ifdef HAVE_SYS_RESOURCE_H /* get core dump configuration settings for suricata */ - char* dump_size_config = NULL; + const char *dump_size_config = NULL; rlim_t max_dump = 0; uint32_t unlimited = 0; size_t rlim_size = sizeof(rlim_t); diff --git a/src/util-cpu.c b/src/util-cpu.c index 655bffbd55..8a4eb4c3b7 100644 --- a/src/util-cpu.c +++ b/src/util-cpu.c @@ -26,6 +26,7 @@ #include "suricata-common.h" #include "util-error.h" #include "util-debug.h" +#include "util-cpu.h" /** * Ok, if they should use sysconf, check that they have the macro's @@ -54,7 +55,7 @@ * \retval 0 if the syscall is not available or we have an error; * otherwise it will return the number of cpus configured */ -uint16_t UtilCpuGetNumProcessorsConfigured() +uint16_t UtilCpuGetNumProcessorsConfigured(void) { #ifdef SYSCONF_NPROCESSORS_CONF_COMPAT long nprocs = -1; @@ -95,7 +96,7 @@ uint16_t UtilCpuGetNumProcessorsConfigured() * \retval 0 if the syscall is not available or we have an error; * otherwise it will return the number of cpus online */ -uint16_t UtilCpuGetNumProcessorsOnline() +uint16_t UtilCpuGetNumProcessorsOnline(void) { #ifdef SYSCONF_NPROCESSORS_ONLN_COMPAT long nprocs = -1; @@ -130,7 +131,7 @@ uint16_t UtilCpuGetNumProcessorsOnline() * \retval 0 if the syscall is not available or we have an error; * otherwise it will return the number of cpus allowed */ -uint16_t UtilCpuGetNumProcessorsMax() +uint16_t UtilCpuGetNumProcessorsMax(void) { #ifdef SYSCONF_NPROCESSORS_MAX_COMPAT long nprocs = -1; @@ -158,7 +159,7 @@ uint16_t UtilCpuGetNumProcessorsMax() /** * \brief Print a summary of CPUs detected (configured and online) */ -void UtilCpuPrintSummary() +void UtilCpuPrintSummary(void) { uint16_t cpus_conf = UtilCpuGetNumProcessorsConfigured(); uint16_t cpus_online = UtilCpuGetNumProcessorsOnline(); diff --git a/src/util-cpu.h b/src/util-cpu.h index c7af03594e..e0b651f329 100644 --- a/src/util-cpu.h +++ b/src/util-cpu.h @@ -25,14 +25,14 @@ #define __UTIL_CPU_H__ /* Processors configured: */ -uint16_t UtilCpuGetNumProcessorsConfigured(); +uint16_t UtilCpuGetNumProcessorsConfigured(void); /* Processors online: */ -uint16_t UtilCpuGetNumProcessorsOnline(); +uint16_t UtilCpuGetNumProcessorsOnline(void); /* Only on Solaris */ -uint16_t UtilCpuGetNumProcessorsMax(); +uint16_t UtilCpuGetNumProcessorsMax(void); -void UtilCpuPrintSummary(); +void UtilCpuPrintSummary(void); uint64_t UtilCpuGetTicks(void); diff --git a/src/util-daemon.c b/src/util-daemon.c index 5aab8509e2..5eba5a6cdf 100644 --- a/src/util-daemon.c +++ b/src/util-daemon.c @@ -119,7 +119,7 @@ void Daemonize (void) exit(EXIT_FAILURE); } else if (pid == 0) { /* Child continues here */ - char *daemondir; + const char *daemondir; umask(027); diff --git a/src/util-debug-filters.c b/src/util-debug-filters.c index 6c06b0af2d..bba36559a3 100644 --- a/src/util-debug-filters.c +++ b/src/util-debug-filters.c @@ -78,7 +78,7 @@ static SCMutex sc_log_fd_filters_tl_m = SCMUTEX_INITIALIZER; * \retval 0 on successfully adding the filter; * \retval -1 on failure */ -int SCLogAddFGFilter(const char *file, const char *function, +static int SCLogAddFGFilter(const char *file, const char *function, int line, int listtype) { SCLogFGFilterFile *fgf_file = NULL; diff --git a/src/util-debug.c b/src/util-debug.c index 1a0f19341e..7af9d89b7a 100644 --- a/src/util-debug.c +++ b/src/util-debug.c @@ -85,7 +85,7 @@ static SCLogConfig *sc_log_config = NULL; /** * \brief Returns the full path given a file and configured log dir */ -static char *SCLogGetLogFilename(char *); +static char *SCLogGetLogFilename(const char *); /** * \brief Holds the global log level. Is the same as sc_log_config->log_level @@ -200,7 +200,7 @@ static inline void SCLogPrintToSyslog(int syslog_log_level, const char *msg) #include /** */ -int SCLogMessageJSON(struct timeval *tval, char *buffer, size_t buffer_size, +static int SCLogMessageJSON(struct timeval *tval, char *buffer, size_t buffer_size, SCLogLevel log_level, const char *file, unsigned line, const char *function, SCError error_code, const char *message) @@ -284,13 +284,13 @@ static SCError SCLogMessageGetBuffer( const char *s = NULL; struct tm *tms = NULL; - char *redb = ""; - char *red = ""; - char *yellowb = ""; - char *yellow = ""; - char *green = ""; - char *blue = ""; - char *reset = ""; + const char *redb = ""; + const char *red = ""; + const char *yellowb = ""; + const char *yellow = ""; + const char *green = ""; + const char *blue = ""; + const char *reset = ""; if (color) { redb = "\x1b[1;31m"; red = "\x1b[31m"; @@ -471,7 +471,7 @@ static SCError SCLogMessageGetBuffer( } } - char *hi = ""; + const char *hi = ""; if (error_code > SC_OK) hi = red; else if (log_level <= SC_LOG_NOTICE) @@ -654,7 +654,7 @@ SCLogOPBuffer *SCLogAllocLogOPBuffer(void) * \retval iface_ctx Pointer to a newly allocated output_interface_context * \initonly */ -static inline SCLogOPIfaceCtx *SCLogAllocLogOPIfaceCtx() +static inline SCLogOPIfaceCtx *SCLogAllocLogOPIfaceCtx(void) { SCLogOPIfaceCtx *iface_ctx = NULL; @@ -920,7 +920,7 @@ static inline void SCLogSetLogLevel(SCLogInitData *sc_lid, SCLogConfig *sc_lc) */ static inline void SCLogSetLogFormat(SCLogInitData *sc_lid, SCLogConfig *sc_lc) { - char *format = NULL; + const char *format = NULL; /* envvar overrides config */ format = getenv(SC_LOG_ENV_LOG_FORMAT); @@ -1092,12 +1092,13 @@ SCLogInitData *SCLogAllocLogInitData(void) return sc_lid; } +#if 0 /** * \brief Frees a SCLogInitData * * \param sc_lid Pointer to the SCLogInitData to be freed */ -void SCLogFreeLogInitData(SCLogInitData *sc_lid) +static void SCLogFreeLogInitData(SCLogInitData *sc_lid) { if (sc_lid != NULL) { if (sc_lid->startup_message != NULL) @@ -1112,6 +1113,7 @@ void SCLogFreeLogInitData(SCLogInitData *sc_lid) return; } +#endif /** * \brief Frees the logging module context @@ -1276,7 +1278,7 @@ void SCLogLoadConfig(int daemon, int verbose) } /* Get default log level and format. */ - char *default_log_level_s = NULL; + const char *default_log_level_s = NULL; if (ConfGet("logging.default-log-level", &default_log_level_s) == 1) { sc_lid->global_log_level = SCMapEnumNameToValue(default_log_level_s, sc_log_level_map); @@ -1417,9 +1419,9 @@ void SCLogLoadConfig(int daemon, int verbose) * * \retval log_filename The fullpath of the logfile to open */ -static char *SCLogGetLogFilename(char *filearg) +static char *SCLogGetLogFilename(const char *filearg) { - char *log_dir; + const char *log_dir; char *log_filename; log_dir = ConfigGetLogDirectory(); @@ -1471,7 +1473,7 @@ void SCLogDeInitLogModule(void) #ifdef UNITTESTS -int SCLogTestInit01() +static int SCLogTestInit01(void) { int result = 1; @@ -1514,7 +1516,7 @@ int SCLogTestInit01() return result; } -int SCLogTestInit02() +static int SCLogTestInit02(void) { SCLogInitData *sc_lid = NULL; SCLogOPIfaceCtx *sc_iface_ctx = NULL; @@ -1585,7 +1587,7 @@ int SCLogTestInit02() return result; } -int SCLogTestInit03() +static int SCLogTestInit03(void) { int result = 1; @@ -1607,7 +1609,7 @@ int SCLogTestInit03() return result; } -int SCLogTestInit04() +static int SCLogTestInit04(void) { int result = 1; @@ -1637,7 +1639,7 @@ int SCLogTestInit04() return result; } -int SCLogTestInit05() +static int SCLogTestInit05(void) { int result = 1; diff --git a/src/util-debug.h b/src/util-debug.h index 46157763e1..5148fe19f6 100644 --- a/src/util-debug.h +++ b/src/util-debug.h @@ -148,16 +148,16 @@ typedef struct SCLogOPIfaceCtx_ { */ typedef struct SCLogInitData_ { /* startup message */ - char *startup_message; + const char *startup_message; /* the log level */ SCLogLevel global_log_level; /* the log format */ - char *global_log_format; + const char *global_log_format; /* output filter */ - char *op_filter; + const char *op_filter; /* list of output interfaces to be used */ SCLogOPIfaceCtx *op_ifaces; diff --git a/src/util-decode-asn1.c b/src/util-decode-asn1.c index 2404c3d843..f99f33eba8 100644 --- a/src/util-decode-asn1.c +++ b/src/util-decode-asn1.c @@ -55,7 +55,7 @@ void SCAsn1LoadConfig() * * \retval byte of the status of the parser */ -uint8_t SCAsn1GetHighTagNumber(Asn1Ctx *ac) +static uint8_t SCAsn1GetHighTagNumber(Asn1Ctx *ac) { uint8_t ret = 0; uint32_t tag_num = 0; @@ -119,7 +119,7 @@ uint8_t SCAsn1GetHighTagNumber(Asn1Ctx *ac) * * \retval byte of the status of the parser */ -uint32_t SCAsn1GetLengthLongForm(Asn1Ctx *ac) +static uint32_t SCAsn1GetLengthLongForm(Asn1Ctx *ac) { uint8_t raw_len = *ac->iter; uint8_t ret = 0; @@ -394,7 +394,7 @@ void SCAsn1CtxDestroy(Asn1Ctx *ac) * * \retval Asn1Node pointer to the new node allocated */ -Asn1Node *SCAsn1CtxNewFrame(Asn1Ctx *ac, uint16_t node) +static Asn1Node *SCAsn1CtxNewFrame(Asn1Ctx *ac, uint16_t node) { if (node >= asn1_max_frames_config) { return NULL; @@ -542,7 +542,7 @@ uint8_t SCAsn1Decode(Asn1Ctx *ac, uint16_t node_id) /** * \test Check we handle extended identifiers correctly */ -int DecodeAsn1Test01(void) +static int DecodeAsn1Test01(void) { uint8_t *str = (uint8_t *) "\x3F\x84\x06"; @@ -571,7 +571,7 @@ end: /** * \test Check we handle extended identifiers correctly */ -int DecodeAsn1Test02(void) +static int DecodeAsn1Test02(void) { uint8_t *str = (uint8_t *) "\x3F\x81\x81\x81\x81\x06"; @@ -600,7 +600,7 @@ end: /** * \test Check we handle short identifiers correctly */ -int DecodeAsn1Test03(void) +static int DecodeAsn1Test03(void) { uint8_t *str = (uint8_t *) "\x28"; @@ -629,7 +629,7 @@ end: /** * \test Check we handle extended lengths correctly with indefinite form */ -int DecodeAsn1Test04(void) +static int DecodeAsn1Test04(void) { uint8_t *str = (uint8_t *) "\x3F\x84\x06\x80\x12\x12\x12\x00\x00"; @@ -659,7 +659,7 @@ end: * \test Check we handle extended lengths correctly * in the definite form */ -int DecodeAsn1Test05(void) +static int DecodeAsn1Test05(void) { uint8_t *str = (uint8_t *) "\x3F\x84\x06\x82\x10\x10"; @@ -688,7 +688,7 @@ end: /** * \test Check we handle short lengths correctly */ -int DecodeAsn1Test06(void) +static int DecodeAsn1Test06(void) { uint8_t *str = (uint8_t *) "\x3F\x84\x06\x26"; @@ -717,7 +717,7 @@ end: /** * \test Check we handle events correctly */ -int DecodeAsn1Test07(void) +static int DecodeAsn1Test07(void) { uint8_t *str = (uint8_t *) "\x3F\x00\x84\x06"; @@ -748,7 +748,7 @@ end: /** * \test Check we handle events correctly */ -int DecodeAsn1Test08(void) +static int DecodeAsn1Test08(void) { uint8_t *str = (uint8_t *) "\x3F\x84\x06\x81\xFF"; @@ -779,7 +779,7 @@ end: /** * \test Check we handle events correctly */ -int DecodeAsn1Test09(void) +static int DecodeAsn1Test09(void) { uint8_t *str = (uint8_t *) "\x3F\x84\x06\x80\xAB\xCD\xEF"; @@ -810,7 +810,7 @@ end: /** * \test Decode a big chunk of data */ -int DecodeAsn1Test10(void) +static int DecodeAsn1Test10(void) { // Example from the specification X.690-0207 Appendix A.3 uint8_t *str = (uint8_t *) "\x60\x81\x85\x61\x10\x1A\x04""John""\x1A\x01" diff --git a/src/util-decode-asn1.h b/src/util-decode-asn1.h index ed0fc79709..a27de1025c 100644 --- a/src/util-decode-asn1.h +++ b/src/util-decode-asn1.h @@ -214,7 +214,7 @@ uint8_t SCAsn1DecodeContent(Asn1Ctx *); uint8_t SCAsn1CheckBounds(Asn1Ctx *); void DecodeAsn1RegisterTests(void); -void SCAsn1LoadConfig(); +void SCAsn1LoadConfig(void); #endif /* __DECODE_ASN1_H__ */ diff --git a/src/util-decode-mime.c b/src/util-decode-mime.c index fcda28c055..5ec00918a8 100644 --- a/src/util-decode-mime.c +++ b/src/util-decode-mime.c @@ -113,7 +113,7 @@ static const char *UrlExeExts[] = { ".exe", * * \return none */ -static void PrintChars(int log_level, char *label, const uint8_t *src, uint32_t len) +static void PrintChars(int log_level, const char *label, const uint8_t *src, uint32_t len) { #ifdef DEBUG if (log_level <= sc_log_global_log_level) { @@ -1828,8 +1828,8 @@ static int FindMimeHeader(const uint8_t *buf, uint32_t blen, * * \return A pointer to the token if found, otherwise NULL if not found */ -static uint8_t * FindMimeHeaderToken(MimeDecField *field, char *search_start, - char *search_end, uint32_t *tlen) +static uint8_t * FindMimeHeaderToken(MimeDecField *field, const char *search_start, + const char *search_end, uint32_t *tlen) { uint8_t *fptr, *tptr = NULL, *tok = NULL; @@ -2731,7 +2731,7 @@ static int MimeDecParseLineTest01(void) MimeDecParseState *state = MimeDecInitParser(&line_count, TestDataChunkCallback); - char *str = "From: Sender1"; + const char *str = "From: Sender1"; ret |= MimeDecParseLine((uint8_t *)str, strlen(str), 1, state); str = "To: Recipient1"; @@ -2799,7 +2799,7 @@ static int MimeDecParseLineTest02(void) MimeDecParseState *state = MimeDecInitParser(&line_count, TestDataChunkCallback); - char *str = "From: Sender1"; + const char *str = "From: Sender1"; ret |= MimeDecParseLine((uint8_t *)str, strlen(str), 1, state); str = "To: Recipient1"; @@ -2937,9 +2937,9 @@ static int MimeBase64DecodeTest01(void) { int ret = 0; - char *msg = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890@" + const char *msg = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890@" "#$%^&*()-=_+,./;'[]<>?:"; - char *base64msg = "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNERUZHSElKS0xNTk9QU" + const char *base64msg = "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNERUZHSElKS0xNTk9QU" "VJTVFVWV1hZWjEyMzQ1Njc4OTBAIyQlXiYqKCktPV8rLC4vOydbXTw+Pzo="; uint8_t *dst = SCMalloc(strlen(msg) + 1); @@ -2960,8 +2960,8 @@ static int MimeBase64DecodeTest01(void) static int MimeIsExeURLTest01(void) { int ret = 0; - char *url1 = "http://www.google.com/"; - char *url2 = "http://www.google.com/test.exe"; + const char *url1 = "http://www.google.com/"; + const char *url2 = "http://www.google.com/test.exe"; if(IsExeUrl((const uint8_t *)url1, strlen(url1)) != 0){ SCLogDebug("Debug: URL1 error"); diff --git a/src/util-enum.h b/src/util-enum.h index ee555e99f7..ea88fc4b44 100644 --- a/src/util-enum.h +++ b/src/util-enum.h @@ -25,7 +25,7 @@ #define __UTIL_ENUM_H__ typedef struct SCEnumCharMap_ { - char *enum_name; + const char *enum_name; int enum_value; } SCEnumCharMap; diff --git a/src/util-file.c b/src/util-file.c index f868222a85..fbe149a3a9 100644 --- a/src/util-file.c +++ b/src/util-file.c @@ -260,7 +260,7 @@ uint16_t FileFlowToFlags(const Flow *flow, uint8_t direction) return flags; } -int FileMagicSize(void) +static int FileMagicSize(void) { /** \todo make this size configurable */ return 512; @@ -1037,7 +1037,7 @@ void FileDisableFilesize(Flow *f, uint8_t direction) * * \param ff file */ -void FileDisableStoringForFile(File *ff) +static void FileDisableStoringForFile(File *ff) { SCEnter(); diff --git a/src/util-file.h b/src/util-file.h index 8c3828d9b9..ddf212cfbc 100644 --- a/src/util-file.h +++ b/src/util-file.h @@ -90,7 +90,7 @@ typedef struct FileContainer_ { File *tail; } FileContainer; -FileContainer *FileContainerAlloc(); +FileContainer *FileContainerAlloc(void); void FileContainerFree(FileContainer *); void FileContainerRecycle(FileContainer *); diff --git a/src/util-fix_checksum.c b/src/util-fix_checksum.c index f2bf881e70..ec2280789f 100644 --- a/src/util-fix_checksum.c +++ b/src/util-fix_checksum.c @@ -36,6 +36,8 @@ #include +#include "util-fix_checksum.h" + /** * \brief Fix-up an IP checksum. * diff --git a/src/util-hash-lookup3.c b/src/util-hash-lookup3.c index d13fa16af2..0c72f9a05f 100644 --- a/src/util-hash-lookup3.c +++ b/src/util-hash-lookup3.c @@ -42,6 +42,7 @@ on 1 byte), but shoehorning those bytes into integers efficiently is messy. #ifdef linux # include /* attempt to define endianness */ #endif +#include "util-hash-lookup3.h" /* * My best guess at if you are big-endian or little-endian. This may diff --git a/src/util-hash.c b/src/util-hash.c index 9dbe36983c..ae72cd8a9f 100644 --- a/src/util-hash.c +++ b/src/util-hash.c @@ -330,7 +330,7 @@ static int HashTableTestAdd01 (void) if (ht == NULL) goto end; - int r = HashTableAdd(ht, "test", 0); + int r = HashTableAdd(ht, (char *)"test", 0); if (r != 0) goto end; @@ -366,15 +366,15 @@ static int HashTableTestFull01 (void) if (ht == NULL) goto end; - int r = HashTableAdd(ht, "test", 4); + int r = HashTableAdd(ht, (char *)"test", 4); if (r != 0) goto end; - char *rp = HashTableLookup(ht, "test", 4); + char *rp = HashTableLookup(ht, (char *)"test", 4); if (rp == NULL) goto end; - r = HashTableRemove(ht, "test", 4); + r = HashTableRemove(ht, (char *)"test", 4); if (r != 0) goto end; @@ -392,15 +392,15 @@ static int HashTableTestFull02 (void) if (ht == NULL) goto end; - int r = HashTableAdd(ht, "test", 4); + int r = HashTableAdd(ht, (char *)"test", 4); if (r != 0) goto end; - char *rp = HashTableLookup(ht, "test", 4); + char *rp = HashTableLookup(ht, (char *)"test", 4); if (rp == NULL) goto end; - r = HashTableRemove(ht, "test2", 5); + r = HashTableRemove(ht, (char *)"test2", 5); if (r == 0) goto end; diff --git a/src/util-hashlist.c b/src/util-hashlist.c index 52ad1b1350..6866261736 100644 --- a/src/util-hashlist.c +++ b/src/util-hashlist.c @@ -349,7 +349,7 @@ static int HashListTableTestAdd01 (void) if (ht == NULL) goto end; - int r = HashListTableAdd(ht, "test", 0); + int r = HashListTableAdd(ht, (char *)"test", 0); if (r != 0) goto end; @@ -385,7 +385,7 @@ static int HashListTableTestAdd03 (void) if (ht == NULL) goto end; - int r = HashListTableAdd(ht, "test", 0); + int r = HashListTableAdd(ht, (char *)"test", 0); if (r != 0) goto end; @@ -413,11 +413,11 @@ static int HashListTableTestAdd04 (void) if (ht == NULL) goto end; - int r = HashListTableAdd(ht, "test", 4); + int r = HashListTableAdd(ht, (char *)"test", 4); if (r != 0) goto end; - char *rp = HashListTableLookup(ht, "test", 4); + char *rp = HashListTableLookup(ht, (char *)"test", 4); if (rp == NULL) goto end; @@ -452,15 +452,15 @@ static int HashListTableTestFull01 (void) if (ht == NULL) goto end; - int r = HashListTableAdd(ht, "test", 4); + int r = HashListTableAdd(ht, (char *)"test", 4); if (r != 0) goto end; - char *rp = HashListTableLookup(ht, "test", 4); + char *rp = HashListTableLookup(ht, (char *)"test", 4); if (rp == NULL) goto end; - r = HashListTableRemove(ht, "test", 4); + r = HashListTableRemove(ht, (char *)"test", 4); if (r != 0) goto end; @@ -478,15 +478,15 @@ static int HashListTableTestFull02 (void) if (ht == NULL) goto end; - int r = HashListTableAdd(ht, "test", 4); + int r = HashListTableAdd(ht, (char *)"test", 4); if (r != 0) goto end; - char *rp = HashListTableLookup(ht, "test", 4); + char *rp = HashListTableLookup(ht, (char *)"test", 4); if (rp == NULL) goto end; - r = HashListTableRemove(ht, "test2", 5); + r = HashListTableRemove(ht, (char *)"test2", 5); if (r == 0) goto end; diff --git a/src/util-host-info.c b/src/util-host-info.c index 2e06c636de..dba9fad1c0 100644 --- a/src/util-host-info.c +++ b/src/util-host-info.c @@ -26,6 +26,7 @@ #include "suricata-common.h" #include "config.h" +#include "util-host-info.h" #ifndef OS_WIN32 #include diff --git a/src/util-host-os-info.c b/src/util-host-os-info.c index eaea28432c..93e73a82d0 100644 --- a/src/util-host-os-info.c +++ b/src/util-host-os-info.c @@ -119,7 +119,7 @@ static void SCHInfoFreeUserDataOSPolicy(void *data) * \retval -1 On failure * \initonly (only specified from config, at the startup) */ -int SCHInfoAddHostOSInfo(char *host_os, char *host_os_ip_range, int is_ipv4) +int SCHInfoAddHostOSInfo(const char *host_os, const char *host_os_ip_range, int is_ipv4) { char *ip_str = NULL; char *ip_str_rem = NULL; @@ -245,7 +245,7 @@ int SCHInfoAddHostOSInfo(char *host_os, char *host_os_ip_range, int is_ipv4) * * \retval The OS flavour on success; -1 on failure, or on not finding the key */ -int SCHInfoGetHostOSFlavour(char *ip_addr_str) +int SCHInfoGetHostOSFlavour(const char *ip_addr_str) { struct in_addr *ipv4_addr = NULL; struct in6_addr *ipv6_addr = NULL; @@ -378,7 +378,7 @@ static void SCHInfoRestoreContextBackup(void) * \test Check if we the IPs with the right OS flavours are added to the host OS * radix tree, and the IPS with invalid flavours returns an error(-1) */ -int SCHInfoTestInvalidOSFlavour01(void) +static int SCHInfoTestInvalidOSFlavour01(void) { SCHInfoCreateContextBackup(); @@ -445,7 +445,7 @@ int SCHInfoTestInvalidOSFlavour01(void) * \test Check that invalid ipv4 addresses and ipv4 netblocks are rejected by * the host os info API */ -int SCHInfoTestInvalidIPV4Address02(void) +static int SCHInfoTestInvalidIPV4Address02(void) { SCHInfoCreateContextBackup(); @@ -483,7 +483,7 @@ int SCHInfoTestInvalidIPV4Address02(void) * \test Check that invalid ipv4 addresses and ipv4 netblocks are rejected by * the host os info API */ -int SCHInfoTestInvalidIPV6Address03(void) +static int SCHInfoTestInvalidIPV6Address03(void) { SCHInfoCreateContextBackup(); @@ -525,7 +525,7 @@ int SCHInfoTestInvalidIPV6Address03(void) * flavour, on supplying as arg an ipv4 addresses that has been added to * the host os radix tree. */ -int SCHInfoTestValidIPV4Address04(void) +static int SCHInfoTestValidIPV4Address04(void) { SCHInfoCreateContextBackup(); @@ -637,7 +637,7 @@ int SCHInfoTestValidIPV4Address04(void) * os flavour, on supplying as arg an ipv4 addresses that has been added * to the host os radix tree. */ -int SCHInfoTestValidIPV4Address05(void) +static int SCHInfoTestValidIPV4Address05(void) { SCHInfoCreateContextBackup(); @@ -778,7 +778,7 @@ int SCHInfoTestValidIPV4Address05(void) * flavour, on supplying as arg an ipv6 address that has been added to * the host os radix tree. */ -int SCHInfoTestValidIPV6Address06(void) +static int SCHInfoTestValidIPV6Address06(void) { SCHInfoCreateContextBackup(); @@ -914,7 +914,7 @@ int SCHInfoTestValidIPV6Address06(void) * os flavour, on supplying as arg an ipv6 address that has been added to * the host os radix tree. */ -int SCHInfoTestValidIPV6Address07(void) +static int SCHInfoTestValidIPV6Address07(void) { SCHInfoCreateContextBackup(); @@ -1070,7 +1070,7 @@ int SCHInfoTestValidIPV6Address07(void) * os flavour, on supplying as arg an ipv6 address that has been added to * the host os radix tree. */ -int SCHInfoTestValidIPV6Address08(void) +static int SCHInfoTestValidIPV6Address08(void) { SCHInfoCreateContextBackup(); @@ -1243,7 +1243,7 @@ int SCHInfoTestValidIPV6Address08(void) * flavour, on supplying as arg an ipv4 addresses that has been added to * the host os radix tree. */ -int SCHInfoTestValidIPV4Address09(void) +static int SCHInfoTestValidIPV4Address09(void) { SCHInfoCreateContextBackup(); @@ -1360,7 +1360,7 @@ int SCHInfoTestValidIPV4Address09(void) /** * \test Check the loading of host info from a configuration file. */ -int SCHInfoTestLoadFromConfig01(void) +static int SCHInfoTestLoadFromConfig01(void) { char config[] = "\ %YAML 1.1\n\ @@ -1403,7 +1403,7 @@ host-os-policy:\n\ /** * \test Check the loading of host info from a configuration file. */ -int SCHInfoTestLoadFromConfig02(void) +static int SCHInfoTestLoadFromConfig02(void) { char config[] = "\ %YAML 1.1\n\ @@ -1471,7 +1471,7 @@ host-os-policy:\n\ /** * \test Check the loading of host info from a configuration file. */ -int SCHInfoTestLoadFromConfig03(void) +static int SCHInfoTestLoadFromConfig03(void) { char config[] = "\ %YAML 1.1\n\ @@ -1517,7 +1517,7 @@ host-os-policy:\n\ /** * \test Check the loading of host info from a configuration file. */ -int SCHInfoTestLoadFromConfig04(void) +static int SCHInfoTestLoadFromConfig04(void) { char config[] = "\ %YAML 1.1\n\ @@ -1563,7 +1563,7 @@ host-os-policy:\n\ /** * \test Check the loading of host info from a configuration file. */ -int SCHInfoTestLoadFromConfig05(void) +static int SCHInfoTestLoadFromConfig05(void) { char config[] = "\ %YAML 1.1\n\ @@ -1576,48 +1576,25 @@ host-os-policy:\n\ linux: [0.0.0.5]\n\ \n"; - int result = 0; - SCHInfoCreateContextBackup(); ConfCreateContextBackup(); ConfInit(); ConfYamlLoadString(config, strlen(config)); - SCHInfoLoadFromConfig(); - if (SCHInfoGetHostOSFlavour("0.0.0.1") != OS_POLICY_BSD_RIGHT) { - goto end; - } - if (SCHInfoGetHostOSFlavour("0.0.0.2") != OS_POLICY_OLD_LINUX) { - goto end; - } - if (SCHInfoGetHostOSFlavour("0.0.0.3") != OS_POLICY_OLD_SOLARIS) { - goto end; - } - if (SCHInfoGetHostOSFlavour("0.0.0.4") != OS_POLICY_WINDOWS) { - goto end; - } - if (SCHInfoGetHostOSFlavour("0.0.0.5") != OS_POLICY_VISTA) { - goto end; - } - if (SCHInfoGetHostOSFlavour("0.0.0.0") != -1) { - goto end; - } - if (SCHInfoGetHostOSFlavour("0.0.0.6") != -1) { - goto end; - } - + FAIL_IF (SCHInfoGetHostOSFlavour("0.0.0.1") != OS_POLICY_BSD_RIGHT); + FAIL_IF (SCHInfoGetHostOSFlavour("0.0.0.2") != OS_POLICY_OLD_LINUX); + FAIL_IF (SCHInfoGetHostOSFlavour("0.0.0.3") != OS_POLICY_OLD_SOLARIS); + FAIL_IF (SCHInfoGetHostOSFlavour("0.0.0.4") != OS_POLICY_WINDOWS); + FAIL_IF (SCHInfoGetHostOSFlavour("0.0.0.5") != OS_POLICY_LINUX); + FAIL_IF (SCHInfoGetHostOSFlavour("0.0.0.0") != -1); + FAIL_IF (SCHInfoGetHostOSFlavour("0.0.0.6") != -1); - result = 1; - - end: ConfDeInit(); ConfRestoreContextBackup(); - SCHInfoRestoreContextBackup(); - - return result; + PASS; } #endif /* UNITTESTS */ @@ -1650,6 +1627,7 @@ void SCHInfoRegisterTests(void) UtRegisterTest("SCHInfoTestLoadFromConfig02", SCHInfoTestLoadFromConfig02); UtRegisterTest("SCHInfoTestLoadFromConfig03", SCHInfoTestLoadFromConfig03); UtRegisterTest("SCHInfoTestLoadFromConfig04", SCHInfoTestLoadFromConfig04); + UtRegisterTest("SCHInfoTestLoadFromConfig05", SCHInfoTestLoadFromConfig05); #endif /* UNITTESTS */ } diff --git a/src/util-host-os-info.h b/src/util-host-os-info.h index 2dbcbc206e..e83f470e95 100644 --- a/src/util-host-os-info.h +++ b/src/util-host-os-info.h @@ -27,8 +27,8 @@ #define SC_HINFO_IS_IPV6 0 #define SC_HINFO_IS_IPV4 1 -int SCHInfoAddHostOSInfo(char *, char *, int); -int SCHInfoGetHostOSFlavour(char *); +int SCHInfoAddHostOSInfo(const char *, const char *, int); +int SCHInfoGetHostOSFlavour(const char *); int SCHInfoGetIPv4HostOSFlavour(uint8_t *); int SCHInfoGetIPv6HostOSFlavour(uint8_t *); void SCHInfoCleanResources(void); diff --git a/src/util-hyperscan.c b/src/util-hyperscan.c index edcf73f665..c5886d6691 100644 --- a/src/util-hyperscan.c +++ b/src/util-hyperscan.c @@ -27,6 +27,7 @@ #include "suricata.h" #ifdef BUILD_HYPERSCAN +#include "util-hyperscan.h" /** * \internal diff --git a/src/util-ioctl.c b/src/util-ioctl.c index 1ec0700c86..1e54cbc757 100644 --- a/src/util-ioctl.c +++ b/src/util-ioctl.c @@ -44,12 +44,14 @@ #include #endif +#include "util-ioctl.h" + /** * \brief output a majorant of hardware header length * * \param Name of a network interface */ -int GetIfaceMaxHWHeaderLength(const char *pcap_dev) +static int GetIfaceMaxHWHeaderLength(const char *pcap_dev) { if ((!strcmp("eth", pcap_dev)) || @@ -327,7 +329,7 @@ static int GetIfaceOffloadingLinux(const char *dev, int csum, int other) uint32_t value = 0; if (csum) { - char *rx = "unset", *tx = "unset"; + const char *rx = "unset", *tx = "unset"; int csum_ret = 0; #ifdef ETHTOOL_GRXCSUM if (GetEthtoolValue(dev, ETHTOOL_GRXCSUM, &value) == 0 && value != 0) { @@ -352,8 +354,8 @@ static int GetIfaceOffloadingLinux(const char *dev, int csum, int other) } if (other) { - char *lro = "unset", *gro = "unset", *tso = "unset", *gso = "unset"; - char *sg = "unset"; + const char *lro = "unset", *gro = "unset", *tso = "unset", *gso = "unset"; + const char *sg = "unset"; int other_ret = 0; #ifdef ETHTOOL_GGRO if (GetEthtoolValue(dev, ETHTOOL_GGRO, &value) == 0 && value != 0) { diff --git a/src/util-ioctl.h b/src/util-ioctl.h index 54020e4c7c..2d0c74740d 100644 --- a/src/util-ioctl.h +++ b/src/util-ioctl.h @@ -21,6 +21,7 @@ * \author Eric Leblond */ +#include "suricata-common.h" #include "util-device.h" int GetIfaceMTU(const char *pcap_dev); @@ -36,5 +37,8 @@ int SetIfaceFlags(const char *ifname, int flags); #ifdef SIOCGIFCAP int GetIfaceCaps(const char *ifname); #endif +#ifdef SIOCSIFCAP +int SetIfaceCaps(const char *ifname, int caps); +#endif int DisableIfaceOffloading(LiveDevice *dev, int csum, int other); void RestoreIfaceOffloading(LiveDevice *dev); diff --git a/src/util-ip.c b/src/util-ip.c index 91c3baab99..b206197a4a 100644 --- a/src/util-ip.c +++ b/src/util-ip.c @@ -25,6 +25,7 @@ */ #include "suricata-common.h" +#include "util-ip.h" /** * \brief Validates an IPV4 address and returns the network endian arranged @@ -91,7 +92,7 @@ struct in6_addr *ValidateIPV6Address(const char *addr_str) * \param netmask The netmask value (cidr) to which the IP address has to be culled * \param key_bitlen The bitlen of the stream */ -void MaskIPNetblock(uint8_t *stream, uint8_t netmask, uint16_t key_bitlen) +void MaskIPNetblock(uint8_t *stream, int netmask, int key_bitlen) { uint32_t mask = 0; int i = 0; diff --git a/src/util-log-redis.c b/src/util-log-redis.c index 07a4b74e76..51eaaf4f42 100644 --- a/src/util-log-redis.c +++ b/src/util-log-redis.c @@ -53,7 +53,7 @@ void SCLogRedisInit() /** \brief SCLogRedisContextAlloc() - Allocates and initalizes redis context */ -static SCLogRedisContext * SCLogRedisContextAlloc() +static SCLogRedisContext *SCLogRedisContextAlloc(void) { SCLogRedisContext* ctx = (SCLogRedisContext*) SCCalloc(1, sizeof(SCLogRedisContext)); if (ctx == NULL) { @@ -78,7 +78,7 @@ static int SCConfLogReopenAsyncRedis(LogFileCtx *log_ctx); /** \brief SCLogRedisAsyncContextAlloc() - Allocates and initalizes redis context with async */ -static SCLogRedisContext * SCLogRedisContextAsyncAlloc() +static SCLogRedisContext *SCLogRedisContextAsyncAlloc(void) { SCLogRedisContext* ctx = (SCLogRedisContext*) SCCalloc(1, sizeof(SCLogRedisContext)); if (unlikely(ctx == NULL)) { diff --git a/src/util-log-redis.h b/src/util-log-redis.h index ff8bfc46f7..0153151eba 100644 --- a/src/util-log-redis.h +++ b/src/util-log-redis.h @@ -57,7 +57,7 @@ typedef struct SCLogRedisContext_ { int batch_count; } SCLogRedisContext; -void SCLogRedisInit(); +void SCLogRedisInit(void); int SCConfLogOpenRedis(ConfNode *, void *); int LogFileWriteRedis(void *, const char *, size_t); diff --git a/src/util-logopenfile.c b/src/util-logopenfile.c index b5863f84ea..89b7bdcf02 100644 --- a/src/util-logopenfile.c +++ b/src/util-logopenfile.c @@ -353,7 +353,7 @@ SCConfLogOpenGeneric(ConfNode *conf, int rotate) { char log_path[PATH_MAX]; - char *log_dir; + const char *log_dir; const char *filename, *filetype; // Arg check diff --git a/src/util-lua-common.c b/src/util-lua-common.c index 8cf564274d..2037ef7bbf 100644 --- a/src/util-lua-common.c +++ b/src/util-lua-common.c @@ -55,6 +55,7 @@ #include #include "util-lua.h" +#include "util-lua-common.h" int LuaCallbackError(lua_State *luastate, const char *msg) { diff --git a/src/util-lua-dnp3-objects.c b/src/util-lua-dnp3-objects.c index 6c3dcc51ab..27bbc53519 100644 --- a/src/util-lua-dnp3-objects.c +++ b/src/util-lua-dnp3-objects.c @@ -34,6 +34,7 @@ #include #include "util-lua.h" +#include "util-lua-dnp3-objects.h" /** * \brief Push an object point item onto the stack. diff --git a/src/util-lua-dnp3.c b/src/util-lua-dnp3.c index 96b7a5ea6b..7a791a0db0 100644 --- a/src/util-lua-dnp3.c +++ b/src/util-lua-dnp3.c @@ -28,6 +28,7 @@ #include "util-lua.h" #include "util-lua-common.h" +#include "util-lua-dnp3.h" #include "util-lua-dnp3-objects.h" /** diff --git a/src/util-lua-dns.c b/src/util-lua-dns.c index b43413f377..da5c99deb3 100644 --- a/src/util-lua-dns.c +++ b/src/util-lua-dns.c @@ -56,6 +56,7 @@ #include "util-lua.h" #include "util-lua-common.h" +#include "util-lua-dns.h" static int DnsGetDnsRrname(lua_State *luastate) { diff --git a/src/util-lua-http.c b/src/util-lua-http.c index 1207f7f9ef..bf612020f5 100644 --- a/src/util-lua-http.c +++ b/src/util-lua-http.c @@ -55,6 +55,7 @@ #include "util-lua.h" #include "util-lua-common.h" +#include "util-lua-http.h" static int HttpGetRequestHost(lua_State *luastate) { diff --git a/src/util-lua-smtp.c b/src/util-lua-smtp.c index 8fca9131a1..25bb0eb191 100644 --- a/src/util-lua-smtp.c +++ b/src/util-lua-smtp.c @@ -44,6 +44,7 @@ #include "util-lua.h" #include "util-lua-common.h" +#include "util-lua-smtp.h" #include "util-file.h" /* diff --git a/src/util-lua-ssh.c b/src/util-lua-ssh.c index 892190080f..9370798a8a 100644 --- a/src/util-lua-ssh.c +++ b/src/util-lua-ssh.c @@ -56,6 +56,7 @@ #include "util-lua.h" #include "util-lua-common.h" +#include "util-lua-ssh.h" static int GetServerProtoVersion(lua_State *luastate, const Flow *f) { diff --git a/src/util-lua-tls.c b/src/util-lua-tls.c index 8472c0f6db..2a3de1b597 100644 --- a/src/util-lua-tls.c +++ b/src/util-lua-tls.c @@ -56,6 +56,7 @@ #include "util-lua.h" #include "util-lua-common.h" +#include "util-lua-tls.h" static int GetCertNotBefore(lua_State *luastate, const Flow *f, int direction) { diff --git a/src/util-magic.c b/src/util-magic.c index 96af56e171..a25e13bc47 100644 --- a/src/util-magic.c +++ b/src/util-magic.c @@ -33,6 +33,7 @@ #include "conf.h" #include "util-unittest.h" +#include "util-magic.h" static magic_t g_magic_ctx = NULL; static SCMutex g_magic_lock; @@ -46,7 +47,7 @@ int MagicInit(void) SCEnter(); - char *filename = NULL; + const char *filename = NULL; FILE *fd = NULL; SCMutexInit(&g_magic_lock, NULL); @@ -175,7 +176,7 @@ void MagicDeinit(void) #endif /** \test magic lib calls -- init */ -int MagicInitTest01(void) +static int MagicInitTest01(void) { int result = 0; magic_t magic_ctx; @@ -198,7 +199,7 @@ int MagicInitTest01(void) } /** \test magic init through api */ -int MagicInitTest02(void) +static int MagicInitTest02(void) { if (g_magic_ctx != NULL) { printf("g_magic_ctx != NULL at start of the test: "); @@ -226,7 +227,7 @@ int MagicInitTest02(void) } /** \test magic lib calls -- lookup */ -int MagicDetectTest01(void) +static int MagicDetectTest01(void) { magic_t magic_ctx; char *result = NULL; @@ -258,7 +259,7 @@ end: } #if 0 /** \test magic lib calls -- lookup */ -int MagicDetectTest02(void) +static int MagicDetectTest02(void) { magic_t magic_ctx; char *result = NULL; @@ -306,7 +307,7 @@ end: } #endif /** \test magic lib calls -- lookup */ -int MagicDetectTest03(void) +static int MagicDetectTest03(void) { char buffer[] = { 0x50, 0x4b, 0x03, 0x04, 0x14, 0x00, 0x00, 0x00, @@ -353,7 +354,7 @@ int MagicDetectTest03(void) } /** \test magic lib calls -- lookup */ -int MagicDetectTest04(void) +static int MagicDetectTest04(void) { magic_t magic_ctx; char *result = NULL; @@ -415,7 +416,7 @@ end: } /** \test magic api calls -- lookup */ -int MagicDetectTest05(void) +static int MagicDetectTest05(void) { const char *result = NULL; uint8_t buffer[] = { 0x25, 'P', 'D', 'F', '-', '1', '.', '3', 0x0d, 0x0a}; @@ -440,7 +441,7 @@ end: } #if 0 /** \test magic api calls -- lookup */ -int MagicDetectTest06(void) +static int MagicDetectTest06(void) { const char *result = NULL; uint8_t buffer[] = { @@ -481,7 +482,7 @@ end: } #endif /** \test magic api calls -- lookup */ -int MagicDetectTest07(void) +static int MagicDetectTest07(void) { const char *result = NULL; uint8_t buffer[] = { @@ -526,7 +527,7 @@ int MagicDetectTest07(void) } /** \test magic api calls -- lookup */ -int MagicDetectTest08(void) +static int MagicDetectTest08(void) { const char *result = NULL; uint8_t buffer[] = { @@ -578,9 +579,9 @@ end: MagicDeinit(); return retval; } - +#if 0 /** \test magic api calls -- make sure memory is shared */ -int MagicDetectTest09(void) +static int MagicDetectTest09(void) { const char *result1 = NULL; const char *result2 = NULL; @@ -615,7 +616,7 @@ end: MagicDeinit(); return retval; } - +#endif /** \test results in valgrind warning about invalid read, tested with * file 5.09 and 5.11 */ static int MagicDetectTest10ValgrindError(void) diff --git a/src/util-memcmp.c b/src/util-memcmp.c index 2dd06ecc7f..4342ac1f6c 100644 --- a/src/util-memcmp.c +++ b/src/util-memcmp.c @@ -188,8 +188,8 @@ static int MemcmpTest14 (void) #ifdef PROFILING uint64_t ticks_start = 0; uint64_t ticks_end = 0; - char *a[] = { "0123456789012345", "abc", "abcdefghij", "suricata", "test", "xyz", "rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr", "abcdefghijklmnopqrstuvwxyz", NULL }; - char *b[] = { "1234567890123456", "abc", "abcdefghik", "suricatb", "test", "xyz", "rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr", "abcdefghijklmnopqrstuvwxyz", NULL }; + const char *a[] = { "0123456789012345", "abc", "abcdefghij", "suricata", "test", "xyz", "rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr", "abcdefghijklmnopqrstuvwxyz", NULL }; + const char *b[] = { "1234567890123456", "abc", "abcdefghik", "suricatb", "test", "xyz", "rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr", "abcdefghijklmnopqrstuvwxyz", NULL }; int t = 0; int i, j; @@ -227,8 +227,8 @@ static int MemcmpTest15 (void) #ifdef PROFILING uint64_t ticks_start = 0; uint64_t ticks_end = 0; - char *a[] = { "0123456789012345", "abc", "abcdefghij", "suricata", "test", "xyz", "rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr", "abcdefghijklmnopqrstuvwxyz", NULL }; - char *b[] = { "1234567890123456", "abc", "abcdefghik", "suricatb", "test", "xyz", "rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr", "abcdefghijklmnopqrstuvwxyz", NULL }; + const char *a[] = { "0123456789012345", "abc", "abcdefghij", "suricata", "test", "xyz", "rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr", "abcdefghijklmnopqrstuvwxyz", NULL }; + const char *b[] = { "1234567890123456", "abc", "abcdefghik", "suricatb", "test", "xyz", "rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr", "abcdefghijklmnopqrstuvwxyz", NULL }; int t = 0; int i, j; @@ -266,8 +266,8 @@ static int MemcmpTest16 (void) #ifdef PROFILING uint64_t ticks_start = 0; uint64_t ticks_end = 0; - char *a[] = { "0123456789012345", "abc", "abcdefghij", "suricata", "test", "xyz", "rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr", "abcdefghijklmnopqrstuvwxyz", NULL }; - char *b[] = { "1234567890123456", "abc", "abcdefghik", "suricatb", "test", "xyz", "rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr", "abcdefghijklmnopqrstuvwxyz", NULL }; + const char *a[] = { "0123456789012345", "abc", "abcdefghij", "suricata", "test", "xyz", "rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr", "abcdefghijklmnopqrstuvwxyz", NULL }; + const char *b[] = { "1234567890123456", "abc", "abcdefghik", "suricatb", "test", "xyz", "rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr", "abcdefghijklmnopqrstuvwxyz", NULL }; int t = 0; int i, j; @@ -305,8 +305,8 @@ static int MemcmpTest17 (void) #ifdef PROFILING uint64_t ticks_start = 0; uint64_t ticks_end = 0; - char *a[] = { "0123456789012345", "abc", "abcdefghij", "suricata", "test", "xyz", "rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr", "abcdefghijklmnopqrstuvwxyz", NULL }; - char *b[] = { "1234567890123456", "abc", "abcdefghik", "suricatb", "test", "xyz", "rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr", "abcdefghijklmnopqrstuvwxyz", NULL }; + const char *a[] = { "0123456789012345", "abc", "abcdefghij", "suricata", "test", "xyz", "rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr", "abcdefghijklmnopqrstuvwxyz", NULL }; + const char *b[] = { "1234567890123456", "abc", "abcdefghik", "suricatb", "test", "xyz", "rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr", "abcdefghijklmnopqrstuvwxyz", NULL }; int t = 0; int i, j; @@ -340,8 +340,8 @@ static int MemcmpTest17 (void) } struct MemcmpTest18Tests { - char *a; - char *b; + const char *a; + const char *b; int result; } memcmp_tests18_tests[] = { { "abcdefgh", "!bcdefgh", 1, }, diff --git a/src/util-memrchr.c b/src/util-memrchr.c index 6e49fc86f4..e531f845c7 100644 --- a/src/util-memrchr.c +++ b/src/util-memrchr.c @@ -24,6 +24,7 @@ #include "suricata-common.h" #include "util-unittest.h" +#include "util-memrchr.h" #ifndef HAVE_MEMRCHR void *memrchr (const void *s, int c, size_t n) @@ -42,7 +43,7 @@ void *memrchr (const void *s, int c, size_t n) #ifdef UNITTESTS static int MemrchrTest01 (void) { - char *haystack = "abcabc"; + const char *haystack = "abcabc"; char needle = 'b'; char *ptr = memrchr(haystack, needle, strlen(haystack)); diff --git a/src/util-misc.c b/src/util-misc.c index 53ee0d3dc8..7e7f03d135 100644 --- a/src/util-misc.c +++ b/src/util-misc.c @@ -27,6 +27,7 @@ #include "util-byte.h" #include "util-debug.h" #include "util-unittest.h" +#include "util-misc.h" #define PARSE_REGEX "^\\s*(\\d+(?:.\\d+)?)\\s*([a-zA-Z]{2})?\\s*$" static pcre *parse_regex = NULL; @@ -208,7 +209,7 @@ int ParseSizeStringU64(const char *size, uint64_t *res) #ifdef UNITTESTS -int UtilMiscParseSizeStringTest01(void) +static int UtilMiscParseSizeStringTest01(void) { const char *str; double result; diff --git a/src/util-mpm-ac-bs.c b/src/util-mpm-ac-bs.c index 56ccbc8cf8..16fb9ba795 100644 --- a/src/util-mpm-ac-bs.c +++ b/src/util-mpm-ac-bs.c @@ -116,7 +116,7 @@ void MpmACBSRegister(void) * aren't retrieving anything for AC conf now, but we will certainly * need it, when we customize AC. */ -static void SCACBSGetConfig() +static void SCACBSGetConfig(void) { //ConfNode *ac_conf; //const char *hash_val = NULL; @@ -1435,7 +1435,7 @@ static int SCACBSTest01(void) SCACBSPreparePatterns(&mpm_ctx); - char *buf = "abcdefghjiklmnopqrstuvwxyz"; + const char *buf = "abcdefghjiklmnopqrstuvwxyz"; uint32_t cnt = SCACBSSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -1469,7 +1469,7 @@ static int SCACBSTest02(void) SCACBSPreparePatterns(&mpm_ctx); - char *buf = "abcdefghjiklmnopqrstuvwxyz"; + const char *buf = "abcdefghjiklmnopqrstuvwxyz"; uint32_t cnt = SCACBSSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -1506,7 +1506,7 @@ static int SCACBSTest03(void) SCACBSPreparePatterns(&mpm_ctx); - char *buf = "abcdefghjiklmnopqrstuvwxyz"; + const char *buf = "abcdefghjiklmnopqrstuvwxyz"; uint32_t cnt = SCACBSSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -1540,7 +1540,7 @@ static int SCACBSTest04(void) SCACBSPreparePatterns(&mpm_ctx); - char *buf = "abcdefghjiklmnopqrstuvwxyz"; + const char *buf = "abcdefghjiklmnopqrstuvwxyz"; uint32_t cnt = SCACBSSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -1574,7 +1574,7 @@ static int SCACBSTest05(void) SCACBSPreparePatterns(&mpm_ctx); - char *buf = "abcdefghjiklmnopqrstuvwxyz"; + const char *buf = "abcdefghjiklmnopqrstuvwxyz"; uint32_t cnt = SCACBSSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -1606,7 +1606,7 @@ static int SCACBSTest06(void) SCACBSPreparePatterns(&mpm_ctx); - char *buf = "abcd"; + const char *buf = "abcd"; uint32_t cnt = SCACBSSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -1651,7 +1651,7 @@ static int SCACBSTest07(void) SCACBSPreparePatterns(&mpm_ctx); - char *buf = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + const char *buf = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; uint32_t cnt = SCACBSSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -1748,7 +1748,7 @@ static int SCACBSTest10(void) SCACBSPreparePatterns(&mpm_ctx); - char *buf = "01234567890123456789012345678901234567890123456789" + const char *buf = "01234567890123456789012345678901234567890123456789" "01234567890123456789012345678901234567890123456789" "abcdefgh" "01234567890123456789012345678901234567890123456789" @@ -1794,7 +1794,7 @@ static int SCACBSTest11(void) result = 1; - char *buf = "he"; + const char *buf = "he"; result &= (SCACBSSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)) == 1); buf = "she"; @@ -1834,7 +1834,7 @@ static int SCACBSTest12(void) SCACBSPreparePatterns(&mpm_ctx); - char *buf = "abcdefghijklmnopqrstuvwxyz"; + const char *buf = "abcdefghijklmnopqrstuvwxyz"; uint32_t cnt = SCACBSSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -1862,13 +1862,13 @@ static int SCACBSTest13(void) SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx); /* 1 match */ - char *pat = "abcdefghijklmnopqrstuvwxyzABCD"; + const char *pat = "abcdefghijklmnopqrstuvwxyzABCD"; MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0); PmqSetup(&pmq); SCACBSPreparePatterns(&mpm_ctx); - char *buf = "abcdefghijklmnopqrstuvwxyzABCD"; + const char *buf = "abcdefghijklmnopqrstuvwxyzABCD"; uint32_t cnt = SCACBSSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -1896,13 +1896,13 @@ static int SCACBSTest14(void) SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx); /* 1 match */ - char *pat = "abcdefghijklmnopqrstuvwxyzABCDE"; + const char *pat = "abcdefghijklmnopqrstuvwxyzABCDE"; MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0); PmqSetup(&pmq); SCACBSPreparePatterns(&mpm_ctx); - char *buf = "abcdefghijklmnopqrstuvwxyzABCDE"; + const char *buf = "abcdefghijklmnopqrstuvwxyzABCDE"; uint32_t cnt = SCACBSSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -1930,13 +1930,13 @@ static int SCACBSTest15(void) SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx); /* 1 match */ - char *pat = "abcdefghijklmnopqrstuvwxyzABCDEF"; + const char *pat = "abcdefghijklmnopqrstuvwxyzABCDEF"; MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0); PmqSetup(&pmq); SCACBSPreparePatterns(&mpm_ctx); - char *buf = "abcdefghijklmnopqrstuvwxyzABCDEF"; + const char *buf = "abcdefghijklmnopqrstuvwxyzABCDEF"; uint32_t cnt = SCACBSSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -1964,13 +1964,13 @@ static int SCACBSTest16(void) SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx); /* 1 match */ - char *pat = "abcdefghijklmnopqrstuvwxyzABC"; + const char *pat = "abcdefghijklmnopqrstuvwxyzABC"; MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0); PmqSetup(&pmq); SCACBSPreparePatterns(&mpm_ctx); - char *buf = "abcdefghijklmnopqrstuvwxyzABC"; + const char *buf = "abcdefghijklmnopqrstuvwxyzABC"; uint32_t cnt = SCACBSSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -1998,13 +1998,13 @@ static int SCACBSTest17(void) SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx); /* 1 match */ - char *pat = "abcdefghijklmnopqrstuvwxyzAB"; + const char *pat = "abcdefghijklmnopqrstuvwxyzAB"; MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0); PmqSetup(&pmq); SCACBSPreparePatterns(&mpm_ctx); - char *buf = "abcdefghijklmnopqrstuvwxyzAB"; + const char *buf = "abcdefghijklmnopqrstuvwxyzAB"; uint32_t cnt = SCACBSSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2032,13 +2032,13 @@ static int SCACBSTest18(void) SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx); /* 1 match */ - char *pat = "abcde""fghij""klmno""pqrst""uvwxy""z"; + const char *pat = "abcde""fghij""klmno""pqrst""uvwxy""z"; MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0); PmqSetup(&pmq); SCACBSPreparePatterns(&mpm_ctx); - char *buf = "abcde""fghij""klmno""pqrst""uvwxy""z"; + const char *buf = "abcde""fghij""klmno""pqrst""uvwxy""z"; uint32_t cnt = SCACBSSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2066,13 +2066,13 @@ static int SCACBSTest19(void) SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx); /* 1 */ - char *pat = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + const char *pat = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0); PmqSetup(&pmq); SCACBSPreparePatterns(&mpm_ctx); - char *buf = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + const char *buf = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; uint32_t cnt = SCACBSSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2099,13 +2099,13 @@ static int SCACBSTest20(void) SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx); /* 1 */ - char *pat = "AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AA"; + const char *pat = "AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AA"; MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0); PmqSetup(&pmq); SCACBSPreparePatterns(&mpm_ctx); - char *buf = "AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AA"; + const char *buf = "AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AA"; uint32_t cnt = SCACBSSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2172,7 +2172,7 @@ static int SCACBSTest22(void) SCACBSPreparePatterns(&mpm_ctx); - char *buf = "abcdefghijklmnopqrstuvwxyz"; + const char *buf = "abcdefghijklmnopqrstuvwxyz"; uint32_t cnt = SCACBSSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2270,7 +2270,7 @@ static int SCACBSTest25(void) SCACBSPreparePatterns(&mpm_ctx); - char *buf = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + const char *buf = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; uint32_t cnt = SCACBSSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2303,7 +2303,7 @@ static int SCACBSTest26(void) SCACBSPreparePatterns(&mpm_ctx); - char *buf = "works"; + const char *buf = "works"; uint32_t cnt = SCACBSSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2336,7 +2336,7 @@ static int SCACBSTest27(void) SCACBSPreparePatterns(&mpm_ctx); - char *buf = "tone"; + const char *buf = "tone"; uint32_t cnt = SCACBSSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2369,7 +2369,7 @@ static int SCACBSTest28(void) SCACBSPreparePatterns(&mpm_ctx); - char *buf = "tONE"; + const char *buf = "tONE"; uint32_t cnt = SCACBSSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2404,7 +2404,7 @@ static int SCACBSTest29(void) SCACBSPreparePatterns(&mpm_ctx); - char *buf = "abcdefgh"; + const char *buf = "abcdefgh"; uint32_t cnt = SCACBSSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); diff --git a/src/util-mpm-ac-tile.c b/src/util-mpm-ac-tile.c index e6b3d1ed53..d01397a28f 100644 --- a/src/util-mpm-ac-tile.c +++ b/src/util-mpm-ac-tile.c @@ -68,8 +68,6 @@ #include "suricata-common.h" #include "suricata.h" -#if __BYTE_ORDER == __LITTLE_ENDIAN - #include "detect.h" #include "detect-parse.h" #include "detect-engine.h" @@ -82,6 +80,8 @@ #include "util-memcpy.h" #include "util-mpm-ac-tile.h" +#if __BYTE_ORDER == __LITTLE_ENDIAN + void SCACTileInitCtx(MpmCtx *); void SCACTileInitThreadCtx(MpmCtx *, MpmThreadCtx *); void SCACTileDestroyCtx(MpmCtx *); @@ -163,7 +163,7 @@ typedef struct StateQueue_ { * aren't retrieving anything for AC conf now, but we will certainly * need it, when we customize AC. */ -static void SCACTileGetConfig() +static void SCACTileGetConfig(void) { } @@ -1172,7 +1172,7 @@ void SCACTileDestroyCtx(MpmCtx *mpm_ctx) #define EXTRA 4 // need 4 extra bytes to avoid OOB reads #endif -int CheckMatch(const SCACTileSearchCtx *ctx, PrefilterRuleStore *pmq, +static int CheckMatch(const SCACTileSearchCtx *ctx, PrefilterRuleStore *pmq, const uint8_t *buf, uint16_t buflen, uint16_t state, int i, int matches, uint8_t *mpm_bitarray) @@ -1528,7 +1528,7 @@ static int SCACTileTest01(void) SCACTilePreparePatterns(&mpm_ctx); - char *buf = "abcdefghjiklmnopqrstuvwxyz"; + const char *buf = "abcdefghjiklmnopqrstuvwxyz"; uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -1562,7 +1562,7 @@ static int SCACTileTest02(void) SCACTilePreparePatterns(&mpm_ctx); - char *buf = "abcdefghjiklmnopqrstuvwxyz"; + const char *buf = "abcdefghjiklmnopqrstuvwxyz"; uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -1599,7 +1599,7 @@ static int SCACTileTest03(void) SCACTilePreparePatterns(&mpm_ctx); - char *buf = "abcdefghjiklmnopqrstuvwxyz"; + const char *buf = "abcdefghjiklmnopqrstuvwxyz"; uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -1633,7 +1633,7 @@ static int SCACTileTest04(void) SCACTilePreparePatterns(&mpm_ctx); - char *buf = "abcdefghjiklmnopqrstuvwxyz"; + const char *buf = "abcdefghjiklmnopqrstuvwxyz"; uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -1667,7 +1667,7 @@ static int SCACTileTest05(void) SCACTilePreparePatterns(&mpm_ctx); - char *buf = "abcdefghjiklmnopqrstuvwxyz"; + const char *buf = "abcdefghjiklmnopqrstuvwxyz"; uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -1699,7 +1699,7 @@ static int SCACTileTest06(void) SCACTilePreparePatterns(&mpm_ctx); - char *buf = "abcd"; + const char *buf = "abcd"; uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -1744,7 +1744,7 @@ static int SCACTileTest07(void) SCACTilePreparePatterns(&mpm_ctx); - char *buf = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + const char *buf = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -1841,7 +1841,7 @@ static int SCACTileTest10(void) SCACTilePreparePatterns(&mpm_ctx); - char *buf = "01234567890123456789012345678901234567890123456789" + const char *buf = "01234567890123456789012345678901234567890123456789" "01234567890123456789012345678901234567890123456789" "abcdefgh" "01234567890123456789012345678901234567890123456789" @@ -1887,7 +1887,7 @@ static int SCACTileTest11(void) result = 1; - char *buf = "he"; + const char *buf = "he"; result &= (SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)) == 1); buf = "she"; @@ -1927,7 +1927,7 @@ static int SCACTileTest12(void) SCACTilePreparePatterns(&mpm_ctx); - char *buf = "abcdefghijklmnopqrstuvwxyz"; + const char *buf = "abcdefghijklmnopqrstuvwxyz"; uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -1955,13 +1955,13 @@ static int SCACTileTest13(void) SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx); /* 1 match */ - char *pat = "abcdefghijklmnopqrstuvwxyzABCD"; + const char *pat = "abcdefghijklmnopqrstuvwxyzABCD"; MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0); PmqSetup(&pmq); SCACTilePreparePatterns(&mpm_ctx); - char *buf = "abcdefghijklmnopqrstuvwxyzABCD"; + const char *buf = "abcdefghijklmnopqrstuvwxyzABCD"; uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -1989,13 +1989,13 @@ static int SCACTileTest14(void) SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx); /* 1 match */ - char *pat = "abcdefghijklmnopqrstuvwxyzABCDE"; + const char *pat = "abcdefghijklmnopqrstuvwxyzABCDE"; MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0); PmqSetup(&pmq); SCACTilePreparePatterns(&mpm_ctx); - char *buf = "abcdefghijklmnopqrstuvwxyzABCDE"; + const char *buf = "abcdefghijklmnopqrstuvwxyzABCDE"; uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2023,13 +2023,13 @@ static int SCACTileTest15(void) SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx); /* 1 match */ - char *pat = "abcdefghijklmnopqrstuvwxyzABCDEF"; + const char *pat = "abcdefghijklmnopqrstuvwxyzABCDEF"; MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0); PmqSetup(&pmq); SCACTilePreparePatterns(&mpm_ctx); - char *buf = "abcdefghijklmnopqrstuvwxyzABCDEF"; + const char *buf = "abcdefghijklmnopqrstuvwxyzABCDEF"; uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2057,13 +2057,13 @@ static int SCACTileTest16(void) SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx); /* 1 match */ - char *pat = "abcdefghijklmnopqrstuvwxyzABC"; + const char *pat = "abcdefghijklmnopqrstuvwxyzABC"; MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0); PmqSetup(&pmq); SCACTilePreparePatterns(&mpm_ctx); - char *buf = "abcdefghijklmnopqrstuvwxyzABC"; + const char *buf = "abcdefghijklmnopqrstuvwxyzABC"; uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2091,13 +2091,13 @@ static int SCACTileTest17(void) SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx); /* 1 match */ - char *pat = "abcdefghijklmnopqrstuvwxyzAB"; + const char *pat = "abcdefghijklmnopqrstuvwxyzAB"; MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0); PmqSetup(&pmq); SCACTilePreparePatterns(&mpm_ctx); - char *buf = "abcdefghijklmnopqrstuvwxyzAB"; + const char *buf = "abcdefghijklmnopqrstuvwxyzAB"; uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2125,13 +2125,13 @@ static int SCACTileTest18(void) SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx); /* 1 match */ - char *pat = "abcde""fghij""klmno""pqrst""uvwxy""z"; + const char *pat = "abcde""fghij""klmno""pqrst""uvwxy""z"; MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0); PmqSetup(&pmq); SCACTilePreparePatterns(&mpm_ctx); - char *buf = "abcde""fghij""klmno""pqrst""uvwxy""z"; + const char *buf = "abcde""fghij""klmno""pqrst""uvwxy""z"; uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2159,13 +2159,13 @@ static int SCACTileTest19(void) SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx); /* 1 */ - char *pat = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + const char *pat = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0); PmqSetup(&pmq); SCACTilePreparePatterns(&mpm_ctx); - char *buf = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + const char *buf = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2193,13 +2193,13 @@ static int SCACTileTest20(void) SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx); /* 1 */ - char *pat = "AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AA"; + const char *pat = "AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AA"; MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0); PmqSetup(&pmq); SCACTilePreparePatterns(&mpm_ctx); - char *buf = "AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AA"; + const char *buf = "AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AA"; uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2266,7 +2266,7 @@ static int SCACTileTest22(void) SCACTilePreparePatterns(&mpm_ctx); - char *buf = "abcdefghijklmnopqrstuvwxyz"; + const char *buf = "abcdefghijklmnopqrstuvwxyz"; uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2364,7 +2364,7 @@ static int SCACTileTest25(void) SCACTilePreparePatterns(&mpm_ctx); - char *buf = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + const char *buf = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2397,7 +2397,7 @@ static int SCACTileTest26(void) SCACTilePreparePatterns(&mpm_ctx); - char *buf = "works"; + const char *buf = "works"; uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2430,7 +2430,7 @@ static int SCACTileTest27(void) SCACTilePreparePatterns(&mpm_ctx); - char *buf = "tone"; + const char *buf = "tone"; uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2463,7 +2463,7 @@ static int SCACTileTest28(void) SCACTilePreparePatterns(&mpm_ctx); - char *buf = "tONE"; + const char *buf = "tONE"; uint32_t cnt = SCACTileSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); diff --git a/src/util-mpm-ac.c b/src/util-mpm-ac.c index ff2728911b..a271dc0774 100644 --- a/src/util-mpm-ac.c +++ b/src/util-mpm-ac.c @@ -110,7 +110,7 @@ typedef struct StateQueue_ { * aren't retrieving anything for AC conf now, but we will certainly * need it, when we customize AC. */ -static void SCACGetConfig() +static void SCACGetConfig(void) { //ConfNode *ac_conf; //const char *hash_val = NULL; @@ -1852,7 +1852,7 @@ static int SCACTest01(void) SCACPreparePatterns(&mpm_ctx); - char *buf = "abcdefghjiklmnopqrstuvwxyz"; + const char *buf = "abcdefghjiklmnopqrstuvwxyz"; uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -1886,7 +1886,7 @@ static int SCACTest02(void) SCACPreparePatterns(&mpm_ctx); - char *buf = "abcdefghjiklmnopqrstuvwxyz"; + const char *buf = "abcdefghjiklmnopqrstuvwxyz"; uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -1923,7 +1923,7 @@ static int SCACTest03(void) SCACPreparePatterns(&mpm_ctx); - char *buf = "abcdefghjiklmnopqrstuvwxyz"; + const char *buf = "abcdefghjiklmnopqrstuvwxyz"; uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -1957,7 +1957,7 @@ static int SCACTest04(void) SCACPreparePatterns(&mpm_ctx); - char *buf = "abcdefghjiklmnopqrstuvwxyz"; + const char *buf = "abcdefghjiklmnopqrstuvwxyz"; uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -1991,7 +1991,7 @@ static int SCACTest05(void) SCACPreparePatterns(&mpm_ctx); - char *buf = "abcdefghjiklmnopqrstuvwxyz"; + const char *buf = "abcdefghjiklmnopqrstuvwxyz"; uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2023,7 +2023,7 @@ static int SCACTest06(void) SCACPreparePatterns(&mpm_ctx); - char *buf = "abcd"; + const char *buf = "abcd"; uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2068,7 +2068,7 @@ static int SCACTest07(void) SCACPreparePatterns(&mpm_ctx); - char *buf = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + const char *buf = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2165,7 +2165,7 @@ static int SCACTest10(void) SCACPreparePatterns(&mpm_ctx); - char *buf = "01234567890123456789012345678901234567890123456789" + const char *buf = "01234567890123456789012345678901234567890123456789" "01234567890123456789012345678901234567890123456789" "abcdefgh" "01234567890123456789012345678901234567890123456789" @@ -2211,7 +2211,7 @@ static int SCACTest11(void) result = 1; - char *buf = "he"; + const char *buf = "he"; result &= (SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)) == 1); buf = "she"; @@ -2251,7 +2251,7 @@ static int SCACTest12(void) SCACPreparePatterns(&mpm_ctx); - char *buf = "abcdefghijklmnopqrstuvwxyz"; + const char *buf = "abcdefghijklmnopqrstuvwxyz"; uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2279,13 +2279,13 @@ static int SCACTest13(void) SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx); /* 1 match */ - char *pat = "abcdefghijklmnopqrstuvwxyzABCD"; + const char *pat = "abcdefghijklmnopqrstuvwxyzABCD"; MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0); PmqSetup(&pmq); SCACPreparePatterns(&mpm_ctx); - char *buf = "abcdefghijklmnopqrstuvwxyzABCD"; + const char *buf = "abcdefghijklmnopqrstuvwxyzABCD"; uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2313,13 +2313,13 @@ static int SCACTest14(void) SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx); /* 1 match */ - char *pat = "abcdefghijklmnopqrstuvwxyzABCDE"; + const char *pat = "abcdefghijklmnopqrstuvwxyzABCDE"; MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0); PmqSetup(&pmq); SCACPreparePatterns(&mpm_ctx); - char *buf = "abcdefghijklmnopqrstuvwxyzABCDE"; + const char *buf = "abcdefghijklmnopqrstuvwxyzABCDE"; uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2347,13 +2347,13 @@ static int SCACTest15(void) SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx); /* 1 match */ - char *pat = "abcdefghijklmnopqrstuvwxyzABCDEF"; + const char *pat = "abcdefghijklmnopqrstuvwxyzABCDEF"; MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0); PmqSetup(&pmq); SCACPreparePatterns(&mpm_ctx); - char *buf = "abcdefghijklmnopqrstuvwxyzABCDEF"; + const char *buf = "abcdefghijklmnopqrstuvwxyzABCDEF"; uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2381,13 +2381,13 @@ static int SCACTest16(void) SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx); /* 1 match */ - char *pat = "abcdefghijklmnopqrstuvwxyzABC"; + const char *pat = "abcdefghijklmnopqrstuvwxyzABC"; MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0); PmqSetup(&pmq); SCACPreparePatterns(&mpm_ctx); - char *buf = "abcdefghijklmnopqrstuvwxyzABC"; + const char *buf = "abcdefghijklmnopqrstuvwxyzABC"; uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2415,13 +2415,13 @@ static int SCACTest17(void) SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx); /* 1 match */ - char *pat = "abcdefghijklmnopqrstuvwxyzAB"; + const char *pat = "abcdefghijklmnopqrstuvwxyzAB"; MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0); PmqSetup(&pmq); SCACPreparePatterns(&mpm_ctx); - char *buf = "abcdefghijklmnopqrstuvwxyzAB"; + const char *buf = "abcdefghijklmnopqrstuvwxyzAB"; uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2449,13 +2449,13 @@ static int SCACTest18(void) SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx); /* 1 match */ - char *pat = "abcde""fghij""klmno""pqrst""uvwxy""z"; + const char *pat = "abcde""fghij""klmno""pqrst""uvwxy""z"; MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0); PmqSetup(&pmq); SCACPreparePatterns(&mpm_ctx); - char *buf = "abcde""fghij""klmno""pqrst""uvwxy""z"; + const char *buf = "abcde""fghij""klmno""pqrst""uvwxy""z"; uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2483,13 +2483,13 @@ static int SCACTest19(void) SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx); /* 1 */ - char *pat = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + const char *pat = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0); PmqSetup(&pmq); SCACPreparePatterns(&mpm_ctx); - char *buf = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + const char *buf = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2517,13 +2517,13 @@ static int SCACTest20(void) SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx); /* 1 */ - char *pat = "AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AA"; + const char *pat = "AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AA"; MpmAddPatternCS(&mpm_ctx, (uint8_t *)pat, strlen(pat), 0, 0, 0, 0, 0); PmqSetup(&pmq); SCACPreparePatterns(&mpm_ctx); - char *buf = "AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AA"; + const char *buf = "AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AA"; uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2590,7 +2590,7 @@ static int SCACTest22(void) SCACPreparePatterns(&mpm_ctx); - char *buf = "abcdefghijklmnopqrstuvwxyz"; + const char *buf = "abcdefghijklmnopqrstuvwxyz"; uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2688,7 +2688,7 @@ static int SCACTest25(void) SCACPreparePatterns(&mpm_ctx); - char *buf = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + const char *buf = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2721,7 +2721,7 @@ static int SCACTest26(void) SCACPreparePatterns(&mpm_ctx); - char *buf = "works"; + const char *buf = "works"; uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2754,7 +2754,7 @@ static int SCACTest27(void) SCACPreparePatterns(&mpm_ctx); - char *buf = "tone"; + const char *buf = "tone"; uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); @@ -2787,7 +2787,7 @@ static int SCACTest28(void) SCACPreparePatterns(&mpm_ctx); - char *buf = "tONE"; + const char *buf = "tONE"; uint32_t cnt = SCACSearch(&mpm_ctx, &mpm_thread_ctx, &pmq, (uint8_t *)buf, strlen(buf)); diff --git a/src/util-pages.c b/src/util-pages.c index 900c063be9..afd9cb0495 100644 --- a/src/util-pages.c +++ b/src/util-pages.c @@ -24,10 +24,9 @@ */ #include "suricata-common.h" -#ifndef HAVE_SYS_MMAN_H -#define PageSupportsRWX 1 -#else -#include +#include "util-pages.h" + +#ifndef HAVE_PAGESUPPORTSRWX_AS_MACRO /** \brief check if OS allows for RWX pages * @@ -54,5 +53,5 @@ int PageSupportsRWX(void) } return retval; } -#endif /* HAVE_SYS_MMAN_H */ +#endif /* HAVE_PAGESUPPORTSRWX_AS_MACRO */ diff --git a/src/util-pages.h b/src/util-pages.h index dd096734a1..0376391477 100644 --- a/src/util-pages.h +++ b/src/util-pages.h @@ -31,9 +31,11 @@ /* OpenBSD won't allow for this test: * "suricata(...): mprotect W^X violation" */ #define PageSupportsRWX() 0 + #define HAVE_PAGESUPPORTSRWX_AS_MACRO 1 #else #ifndef HAVE_SYS_MMAN_H #define PageSupportsRWX() 1 + #define HAVE_PAGESUPPORTSRWX_AS_MACRO 1 #else int PageSupportsRWX(void); #endif /* HAVE_SYS_MMAN_H */ diff --git a/src/util-pool-thread.c b/src/util-pool-thread.c index 2795ebcad0..c0d42bc7fe 100644 --- a/src/util-pool-thread.c +++ b/src/util-pool-thread.c @@ -35,7 +35,7 @@ #include "util-unittest.h" #include "util-debug.h" -PoolThread *PoolThreadInit(int threads, uint32_t size, uint32_t prealloc_size, uint32_t elt_size, void *(*Alloc)(), int (*Init)(void *, void *), void *InitData, void (*Cleanup)(void *), void (*Free)(void *)) +PoolThread *PoolThreadInit(int threads, uint32_t size, uint32_t prealloc_size, uint32_t elt_size, void *(*Alloc)(void), int (*Init)(void *, void *), void *InitData, void (*Cleanup)(void *), void (*Free)(void *)) { PoolThread *pt = NULL; int i; @@ -85,7 +85,7 @@ error: /** * */ -int PoolThreadGrow(PoolThread *pt, uint32_t size, uint32_t prealloc_size, uint32_t elt_size, void *(*Alloc)(), int (*Init)(void *, void *), void *InitData, void (*Cleanup)(void *), void (*Free)(void *)) { +int PoolThreadGrow(PoolThread *pt, uint32_t size, uint32_t prealloc_size, uint32_t elt_size, void *(*Alloc)(void), int (*Init)(void *, void *), void *InitData, void (*Cleanup)(void *), void (*Free)(void *)) { void *ptmp; size_t newsize; PoolThreadElement *e = NULL; diff --git a/src/util-pool-thread.h b/src/util-pool-thread.h index 1d2bbd47ff..d43d4e8c9f 100644 --- a/src/util-pool-thread.h +++ b/src/util-pool-thread.h @@ -62,13 +62,13 @@ void PoolThreadRegisterTests(void); * \note same as PoolInit() except for "threads" * \param threads number of threads to use this * \retval pt thread pool or NULL on error */ -PoolThread *PoolThreadInit(int threads, uint32_t size, uint32_t prealloc_size, uint32_t elt_size, void *(*Alloc)(), int (*Init)(void *, void *), void *InitData, void (*Cleanup)(void *), void (*Free)(void *)); +PoolThread *PoolThreadInit(int threads, uint32_t size, uint32_t prealloc_size, uint32_t elt_size, void *(*Alloc)(void), int (*Init)(void *, void *), void *InitData, void (*Cleanup)(void *), void (*Free)(void *)); /** \brief grow a thread pool by one * \note calls PoolInit so all args but 'pt' are the same * \param pt thread pool to grow * \retval r id of new entry on succes, -1 on error */ -int PoolThreadGrow(PoolThread *pt, uint32_t size, uint32_t prealloc_size, uint32_t elt_size, void *(*Alloc)(), int (*Init)(void *, void *), void *InitData, void (*Cleanup)(void *), void (*Free)(void *)); +int PoolThreadGrow(PoolThread *pt, uint32_t size, uint32_t prealloc_size, uint32_t elt_size, void *(*Alloc)(void), int (*Init)(void *, void *), void *InitData, void (*Cleanup)(void *), void (*Free)(void *)); /** \brief destroy the thread pool * \note wrapper around PoolFree() diff --git a/src/util-pool.c b/src/util-pool.c index 4706222d8d..3d411298b8 100644 --- a/src/util-pool.c +++ b/src/util-pool.c @@ -81,7 +81,7 @@ static int PoolDataPreAllocated(Pool *p, void *data) * \param Free free func * \retval the allocated Pool */ -Pool *PoolInit(uint32_t size, uint32_t prealloc_size, uint32_t elt_size, void *(*Alloc)(), int (*Init)(void *, void *), void *InitData, void (*Cleanup)(void *), void (*Free)(void *)) +Pool *PoolInit(uint32_t size, uint32_t prealloc_size, uint32_t elt_size, void *(*Alloc)(void), int (*Init)(void *, void *), void *InitData, void (*Cleanup)(void *), void (*Free)(void *)) { Pool *p = NULL; @@ -383,14 +383,15 @@ void PoolPrintSaturation(Pool *p) * ONLY TESTS BELOW THIS COMMENT */ -void *PoolTestAlloc() +#ifdef UNITTESTS +static void *PoolTestAlloc(void) { void *ptr = SCMalloc(10); if (unlikely(ptr == NULL)) return NULL; return ptr; } -int PoolTestInitArg(void *data, void *allocdata) +static int PoolTestInitArg(void *data, void *allocdata) { size_t len = strlen((char *)allocdata) + 1; char *str = data; @@ -399,12 +400,11 @@ int PoolTestInitArg(void *data, void *allocdata) return 1; } -void PoolTestFree(void *ptr) +static void PoolTestFree(void *ptr) { return; } -#ifdef UNITTESTS static int PoolTestInit01 (void) { Pool *p = PoolInit(10,5,10,PoolTestAlloc,NULL,NULL,PoolTestFree, NULL); diff --git a/src/util-pool.h b/src/util-pool.h index 266d1f4d4c..5e566893c8 100644 --- a/src/util-pool.h +++ b/src/util-pool.h @@ -57,7 +57,7 @@ typedef struct Pool_ { void *data_buffer; PoolBucket *pb_buffer; - void *(*Alloc)(); + void *(*Alloc)(void); int (*Init)(void *, void *); void *InitData; void (*Cleanup)(void *); @@ -70,7 +70,7 @@ typedef struct Pool_ { } Pool; /* prototypes */ -Pool* PoolInit(uint32_t, uint32_t, uint32_t, void *(*Alloc)(), int (*Init)(void *, void *), void *, void (*Cleanup)(void *), void (*Free)(void *)); +Pool* PoolInit(uint32_t, uint32_t, uint32_t, void *(*Alloc)(void), int (*Init)(void *, void *), void *, void (*Cleanup)(void *), void (*Free)(void *)); void PoolFree(Pool *); void PoolPrint(Pool *); void PoolPrintSaturation(Pool *p); diff --git a/src/util-privs.c b/src/util-privs.c index d44cbc7b39..1689272f16 100644 --- a/src/util-privs.c +++ b/src/util-privs.c @@ -32,6 +32,8 @@ #include "util-debug.h" #include "suricata.h" +#include "util-privs.h" + #ifdef HAVE_LIBCAP_NG #include @@ -40,7 +42,6 @@ #endif #include "threadvars.h" #include "util-cpu.h" -#include "util-privs.h" #include "runmodes.h" /** flag indicating if we'll be using caps */ @@ -49,18 +50,6 @@ extern int sc_set_caps; /** our current runmode */ extern int run_mode; -/** - * \brief Drop all the previliges of the given thread - */ -void SCDropAllCaps() -{ - capng_clear(CAPNG_SELECT_BOTH); - if (capng_apply(CAPNG_SELECT_BOTH) < 0) { - SCLogError(SC_ERR_CHANGING_CAPS_FAILED, "failed in dropping the caps"); - exit(EXIT_FAILURE); - } -} - /** * \brief Drop the previliges of the main thread */ @@ -158,7 +147,7 @@ void SCDropCaps(ThreadVars *tv) * * \retval upon success it return 0 */ -int SCGetUserID(char *user_name, char *group_name, uint32_t *uid, uint32_t *gid) +int SCGetUserID(const char *user_name, const char *group_name, uint32_t *uid, uint32_t *gid) { uint32_t userid = 0; uint32_t groupid = 0; @@ -221,7 +210,7 @@ int SCGetUserID(char *user_name, char *group_name, uint32_t *uid, uint32_t *gid) * * \retval upon success it return 0 */ -int SCGetGroupID(char *group_name, uint32_t *gid) +int SCGetGroupID(const char *group_name, uint32_t *gid) { uint32_t grpid = 0; struct group *gp; diff --git a/src/util-privs.h b/src/util-privs.h index aef33a4873..a60b755410 100644 --- a/src/util-privs.h +++ b/src/util-privs.h @@ -91,8 +91,8 @@ void SCDropMainThreadCaps(uint32_t , uint32_t ); #endif /* HAVE_LIBCAP_NG */ -int SCGetUserID(char *, char *, uint32_t *, uint32_t *); -int SCGetGroupID(char *, uint32_t *); +int SCGetUserID(const char *, const char *, uint32_t *, uint32_t *); +int SCGetGroupID(const char *, uint32_t *); #endif /* _UTIL_PRIVS_H */ diff --git a/src/util-profiling-keywords.c b/src/util-profiling-keywords.c index 23b31f9ea7..80ffc3b7d1 100644 --- a/src/util-profiling-keywords.c +++ b/src/util-profiling-keywords.c @@ -76,8 +76,7 @@ void SCProfilingKeywordsGlobalInit(void) profiling_keyword_enabled = 1; const char *filename = ConfNodeLookupChildValue(conf, "filename"); if (filename != NULL) { - - char *log_dir; + const char *log_dir; log_dir = ConfigGetLogDirectory(); snprintf(profiling_file_name, sizeof(profiling_file_name), "%s/%s", @@ -147,7 +146,7 @@ static void DoDump(SCProfileKeywordDetectCtx *rules_ctx, FILE *fp, const char *n } } -void +static void SCProfilingKeywordDump(DetectEngineCtx *de_ctx) { int i; @@ -250,7 +249,7 @@ SCProfilingKeywordUpdateCounter(DetectEngineThreadCtx *det_ctx, int id, uint64_t } } -SCProfileKeywordDetectCtx *SCProfilingKeywordInitCtx(void) +static SCProfileKeywordDetectCtx *SCProfilingKeywordInitCtx(void) { SCProfileKeywordDetectCtx *ctx = SCMalloc(sizeof(SCProfileKeywordDetectCtx)); if (ctx != NULL) { diff --git a/src/util-profiling-locks.h b/src/util-profiling-locks.h index 453928a0b0..0631681c62 100644 --- a/src/util-profiling-locks.h +++ b/src/util-profiling-locks.h @@ -37,8 +37,8 @@ enum { void SCProfilingAddPacketLocks(void *); -int LockRecordInitHash(); -void LockRecordFreeHash(); +int LockRecordInitHash(void); +void LockRecordFreeHash(void); #endif /* PROFILING */ #endif /* __UTIL_PROFILE_LOCKS_H__ */ diff --git a/src/util-profiling-rulegroups.c b/src/util-profiling-rulegroups.c index 8f69338a13..66831b5fe0 100644 --- a/src/util-profiling-rulegroups.c +++ b/src/util-profiling-rulegroups.c @@ -80,8 +80,7 @@ void SCProfilingSghsGlobalInit(void) profiling_sghs_enabled = 1; const char *filename = ConfNodeLookupChildValue(conf, "filename"); if (filename != NULL) { - - char *log_dir; + const char *log_dir; log_dir = ConfigGetLogDirectory(); snprintf(profiling_file_name, sizeof(profiling_file_name), @@ -231,7 +230,7 @@ static void DoDump(SCProfileSghDetectCtx *rules_ctx, FILE *fp, const char *name) fprintf(fp,"\n"); } -void +static void SCProfilingSghDump(DetectEngineCtx *de_ctx) { FILE *fp; @@ -297,7 +296,7 @@ SCProfilingSghUpdateCounter(DetectEngineThreadCtx *det_ctx, const SigGroupHead * } } -SCProfileSghDetectCtx *SCProfilingSghInitCtx(void) +static SCProfileSghDetectCtx *SCProfilingSghInitCtx(void) { SCProfileSghDetectCtx *ctx = SCCalloc(1, sizeof(SCProfileSghDetectCtx)); if (ctx != NULL) { diff --git a/src/util-profiling-rules.c b/src/util-profiling-rules.c index bab516cb87..74d8eff40f 100644 --- a/src/util-profiling-rules.c +++ b/src/util-profiling-rules.c @@ -169,7 +169,7 @@ void SCProfilingRulesGlobalInit(void) const char *filename = ConfNodeLookupChildValue(conf, "filename"); if (filename != NULL) { - char *log_dir; + const char *log_dir; log_dir = ConfigGetLogDirectory(); snprintf(profiling_file_name, sizeof(profiling_file_name), @@ -428,7 +428,7 @@ static void DumpText(FILE *fp, SCProfileSummary *summary, * * \param de_ctx The active DetectEngineCtx, used to get at the loaded rules. */ -void +static void SCProfilingRuleDump(SCProfileDetectCtx *rules_ctx) { uint32_t i; @@ -583,7 +583,7 @@ SCProfilingRuleUpdateCounter(DetectEngineThreadCtx *det_ctx, uint16_t id, uint64 } } -SCProfileDetectCtx *SCProfilingRuleInitCtx(void) +static SCProfileDetectCtx *SCProfilingRuleInitCtx(void) { SCProfileDetectCtx *ctx = SCMalloc(sizeof(SCProfileDetectCtx)); if (ctx != NULL) { diff --git a/src/util-profiling.c b/src/util-profiling.c index 24ef3aca46..d7ed401bea 100644 --- a/src/util-profiling.c +++ b/src/util-profiling.c @@ -183,8 +183,7 @@ SCProfilingInit(void) const char *filename = ConfNodeLookupChildValue(conf, "filename"); if (filename != NULL) { - - char *log_dir; + const char *log_dir; log_dir = ConfigGetLogDirectory(); snprintf(profiling_packets_file_name, sizeof(profiling_packets_file_name), @@ -210,7 +209,7 @@ SCProfilingInit(void) filename = "packet_profile.csv"; } - char *log_dir; + const char *log_dir; log_dir = ConfigGetLogDirectory(); profiling_csv_file_name = SCMalloc(PATH_MAX); @@ -959,7 +958,7 @@ static void SCProfilingUpdatePacketDetectRecord(PacketProfileDetectId id, uint8_ pd->cnt ++; } -void SCProfilingUpdatePacketDetectRecords(Packet *p) +static void SCProfilingUpdatePacketDetectRecords(Packet *p) { PacketProfileDetectId i; for (i = 0; i < PROF_DETECT_SIZE; i++) { @@ -1017,7 +1016,7 @@ static void SCProfilingUpdatePacketAppRecord(int alproto, uint8_t ipproto, PktPr pd->cnt ++; } -void SCProfilingUpdatePacketAppRecords(Packet *p) +static void SCProfilingUpdatePacketAppRecords(Packet *p) { int i; for (i = 0; i < ALPROTO_MAX; i++) { @@ -1041,7 +1040,7 @@ void SCProfilingUpdatePacketAppRecords(Packet *p) } } -void SCProfilingUpdatePacketTmmRecord(int module, uint8_t proto, PktProfilingTmmData *pdt, int ipver) +static void SCProfilingUpdatePacketTmmRecord(int module, uint8_t proto, PktProfilingTmmData *pdt, int ipver) { if (pdt == NULL) { return; @@ -1074,7 +1073,7 @@ void SCProfilingUpdatePacketTmmRecord(int module, uint8_t proto, PktProfilingTmm #endif } -void SCProfilingUpdatePacketTmmRecords(Packet *p) +static void SCProfilingUpdatePacketTmmRecords(Packet *p) { int i; for (i = 0; i < TMM_SIZE; i++) { diff --git a/src/util-radix-tree.c b/src/util-radix-tree.c index ba63e6432c..9d29dbc9d5 100644 --- a/src/util-radix-tree.c +++ b/src/util-radix-tree.c @@ -380,7 +380,7 @@ static void SCRadixReleasePrefix(SCRadixPrefix *prefix, SCRadixTree *tree) * * \retval node The newly created node for the radix tree */ -static inline SCRadixNode *SCRadixCreateNode() +static inline SCRadixNode *SCRadixCreateNode(void) { SCRadixNode *node = NULL; @@ -1661,46 +1661,7 @@ void SCRadixPrintTree(SCRadixTree *tree) #ifdef UNITTESTS -int SCRadixTestInsertion01(void) -{ - SCRadixTree *tree = NULL; - SCRadixNode *node[2]; - - int result = 1; - - tree = SCRadixCreateRadixTree(free, NULL); - - - node[0] = SCRadixAddKeyGeneric((uint8_t *)"abaa", 32, tree, NULL); - node[1] = SCRadixAddKeyGeneric((uint8_t *)"abab", 32, tree, NULL); - - result &= (tree->head->bit == 30); - result &= (tree->head->right == node[0]); - result &= (tree->head->left == node[1]); - - SCRadixReleaseRadixTree(tree); - - return result; -} - -int SCRadixTestInsertion02(void) -{ - SCRadixTree *tree = NULL; - int result = 1; - - tree = SCRadixCreateRadixTree(free, NULL); - - SCRadixAddKeyGeneric((uint8_t *)"aaaaaa", 48, tree, NULL); - SCRadixAddKeyGeneric((uint8_t *)"aaaaab", 48, tree, NULL); - SCRadixAddKeyGeneric((uint8_t *)"aaaaaba", 56, tree, NULL); - SCRadixAddKeyGeneric((uint8_t *)"abab", 32, tree, NULL); - SCRadixReleaseRadixTree(tree); - - /* If we don't have a segfault till here we have succeeded :) */ - return result; -} - -int SCRadixTestIPV4Insertion03(void) +static int SCRadixTestIPV4Insertion03(void) { SCRadixTree *tree = NULL; struct sockaddr_in servaddr; @@ -1811,7 +1772,7 @@ int SCRadixTestIPV4Insertion03(void) return result; } -int SCRadixTestIPV4Removal04(void) +static int SCRadixTestIPV4Removal04(void) { SCRadixTree *tree = NULL; struct sockaddr_in servaddr; @@ -1923,101 +1884,7 @@ int SCRadixTestIPV4Removal04(void) return result; } -int SCRadixTestCharacterInsertion05(void) -{ - SCRadixTree *tree = NULL; - int result = 1; - - tree = SCRadixCreateRadixTree(free, NULL); - - /* Let us have our team here ;-) */ - SCRadixAddKeyGeneric((uint8_t *)"Victor", 48, tree, NULL); - SCRadixAddKeyGeneric((uint8_t *)"Matt", 32, tree, NULL); - SCRadixAddKeyGeneric((uint8_t *)"Josh", 32, tree, NULL); - SCRadixAddKeyGeneric((uint8_t *)"Margaret", 64, tree, NULL); - SCRadixAddKeyGeneric((uint8_t *)"Pablo", 40, tree, NULL); - SCRadixAddKeyGeneric((uint8_t *)"Brian", 40, tree, NULL); - SCRadixAddKeyGeneric((uint8_t *)"Jasonish", 64, tree, NULL); - SCRadixAddKeyGeneric((uint8_t *)"Jasonmc", 56, tree, NULL); - SCRadixAddKeyGeneric((uint8_t *)"Nathan", 48, tree, NULL); - SCRadixAddKeyGeneric((uint8_t *)"Anoop", 40, tree, NULL); - - result &= (SCRadixFindKeyGeneric((uint8_t *)"Victor", 48, tree, NULL) != NULL); - result &= (SCRadixFindKeyGeneric((uint8_t *)"Matt", 32, tree, NULL) != NULL); - result &= (SCRadixFindKeyGeneric((uint8_t *)"Josh", 32, tree, NULL) != NULL); - result &= (SCRadixFindKeyGeneric((uint8_t *)"Margaret", 64, tree, NULL) != NULL); - result &= (SCRadixFindKeyGeneric((uint8_t *)"Pablo", 40, tree, NULL) != NULL); - result &= (SCRadixFindKeyGeneric((uint8_t *)"Brian", 40, tree, NULL) != NULL); - result &= (SCRadixFindKeyGeneric((uint8_t *)"Jasonish", 64, tree, NULL) != NULL); - result &= (SCRadixFindKeyGeneric((uint8_t *)"Jasonmc", 56, tree, NULL) != NULL); - result &= (SCRadixFindKeyGeneric((uint8_t *)"Nathan", 48, tree, NULL) != NULL); - result &= (SCRadixFindKeyGeneric((uint8_t *)"Anoop", 40, tree, NULL) != NULL); - - result &= (SCRadixFindKeyGeneric((uint8_t *)"bamboo", 48, tree, NULL) != NULL); - result &= (SCRadixFindKeyGeneric((uint8_t *)"bool", 32, tree, NULL) == NULL); - result &= (SCRadixFindKeyGeneric((uint8_t *)"meerkat", 56, tree, NULL) == NULL); - result &= (SCRadixFindKeyGeneric((uint8_t *)"Victor", 48, tree, NULL) == NULL); - - SCRadixReleaseRadixTree(tree); - - return result; -} - -int SCRadixTestCharacterRemoval06(void) -{ - SCRadixTree *tree = NULL; - int result = 1; - - tree = SCRadixCreateRadixTree(free, NULL); - - /* Let us have our team here ;-) */ - SCRadixAddKeyGeneric((uint8_t *)"Victor", 48, tree, NULL); - SCRadixAddKeyGeneric((uint8_t *)"Matt", 32, tree, NULL); - SCRadixAddKeyGeneric((uint8_t *)"Josh", 32, tree, NULL); - SCRadixAddKeyGeneric((uint8_t *)"Margaret", 64, tree, NULL); - SCRadixAddKeyGeneric((uint8_t *)"Pablo", 40, tree, NULL); - SCRadixAddKeyGeneric((uint8_t *)"Brian", 40, tree, NULL); - SCRadixAddKeyGeneric((uint8_t *)"Jasonish", 64, tree, NULL); - SCRadixAddKeyGeneric((uint8_t *)"Jasonmc", 56, tree, NULL); - SCRadixAddKeyGeneric((uint8_t *)"Nathan", 48, tree, NULL); - SCRadixAddKeyGeneric((uint8_t *)"Anoop", 40, tree, NULL); - - SCRadixRemoveKeyGeneric((uint8_t *)"Nathan", 48, tree); - SCRadixRemoveKeyGeneric((uint8_t *)"Brian", 40, tree); - SCRadixRemoveKeyGeneric((uint8_t *)"Margaret", 64, tree); - - result &= (SCRadixFindKeyGeneric((uint8_t *)"Victor", 48, tree, NULL) != NULL); - result &= (SCRadixFindKeyGeneric((uint8_t *)"Matt", 32, tree, NULL) != NULL); - result &= (SCRadixFindKeyGeneric((uint8_t *)"Josh", 32, tree, NULL) != NULL); - result &= (SCRadixFindKeyGeneric((uint8_t *)"Margaret", 64, tree, NULL) == NULL); - result &= (SCRadixFindKeyGeneric((uint8_t *)"Brian", 40, tree, NULL) == NULL); - result &= (SCRadixFindKeyGeneric((uint8_t *)"Nathan", 48, tree, NULL) == NULL); - - SCRadixRemoveKeyGeneric((uint8_t *)"Victor", 48, tree); - SCRadixRemoveKeyGeneric((uint8_t *)"Josh", 32, tree); - SCRadixRemoveKeyGeneric((uint8_t *)"Jasonmc", 56, tree); - SCRadixRemoveKeyGeneric((uint8_t *)"Matt", 32, tree); - - result &= (SCRadixFindKeyGeneric((uint8_t *)"Pablo", 40, tree, NULL) != NULL); - result &= (SCRadixFindKeyGeneric((uint8_t *)"Jasonish", 64, tree, NULL) != NULL); - result &= (SCRadixFindKeyGeneric((uint8_t *)"Anoop", 40, tree, NULL) != NULL); - - SCRadixRemoveKeyGeneric((uint8_t *)"Pablo", 40, tree); - SCRadixRemoveKeyGeneric((uint8_t *)"Jasonish", 64, tree); - SCRadixRemoveKeyGeneric((uint8_t *)"Anoop", 40, tree); - - result &= (SCRadixFindKeyGeneric((uint8_t *)"Pablo", 40, tree, NULL) == NULL); - result &= (SCRadixFindKeyGeneric((uint8_t *)"Jasonish", 64, tree, NULL) == NULL); - result &= (SCRadixFindKeyGeneric((uint8_t *)"Anoop", 40, tree, NULL) == NULL); - - result &= (tree->head == NULL); - - SCRadixReleaseRadixTree(tree); - - return result; -} - -int SCRadixTestIPV6Insertion07(void) +static int SCRadixTestIPV6Insertion07(void) { SCRadixTree *tree = NULL; struct sockaddr_in6 servaddr; @@ -2131,7 +1998,7 @@ int SCRadixTestIPV6Insertion07(void) return result; } -int SCRadixTestIPV6Removal08(void) +static int SCRadixTestIPV6Removal08(void) { SCRadixTree *tree = NULL; struct sockaddr_in6 servaddr; @@ -2370,7 +2237,7 @@ int SCRadixTestIPV6Removal08(void) return result; } -int SCRadixTestIPV4NetblockInsertion09(void) +static int SCRadixTestIPV4NetblockInsertion09(void) { SCRadixTree *tree = NULL; struct sockaddr_in servaddr; @@ -2479,7 +2346,7 @@ int SCRadixTestIPV4NetblockInsertion09(void) return result; } -int SCRadixTestIPV4NetblockInsertion10(void) +static int SCRadixTestIPV4NetblockInsertion10(void) { SCRadixTree *tree = NULL; SCRadixNode *node[2]; @@ -2586,7 +2453,7 @@ int SCRadixTestIPV4NetblockInsertion10(void) return result; } -int SCRadixTestIPV4NetblockInsertion11(void) +static int SCRadixTestIPV4NetblockInsertion11(void) { SCRadixTree *tree = NULL; SCRadixNode *node = NULL; @@ -2754,7 +2621,7 @@ int SCRadixTestIPV4NetblockInsertion11(void) return result; } -int SCRadixTestIPV4NetblockInsertion12(void) +static int SCRadixTestIPV4NetblockInsertion12(void) { SCRadixTree *tree = NULL; SCRadixNode *node[2]; @@ -2879,7 +2746,7 @@ int SCRadixTestIPV4NetblockInsertion12(void) return result; } -int SCRadixTestIPV6NetblockInsertion13(void) +static int SCRadixTestIPV6NetblockInsertion13(void) { SCRadixTree *tree = NULL; struct sockaddr_in6 servaddr; @@ -3009,7 +2876,7 @@ int SCRadixTestIPV6NetblockInsertion13(void) return result; } -int SCRadixTestIPV6NetblockInsertion14(void) +static int SCRadixTestIPV6NetblockInsertion14(void) { SCRadixTree *tree = NULL; SCRadixNode *node = NULL; @@ -3115,7 +2982,7 @@ int SCRadixTestIPV6NetblockInsertion14(void) * \test Check that the best match search works for all the * possible netblocks of a fixed address */ -int SCRadixTestIPV4NetBlocksAndBestSearch15(void) +static int SCRadixTestIPV4NetBlocksAndBestSearch15(void) { SCRadixTree *tree = NULL; struct sockaddr_in servaddr; @@ -3175,7 +3042,7 @@ end: * \test Check that the best match search works for all the * possible netblocks of a fixed address */ -int SCRadixTestIPV4NetBlocksAndBestSearch16(void) +static int SCRadixTestIPV4NetBlocksAndBestSearch16(void) { SCRadixTree *tree = NULL; struct sockaddr_in servaddr; @@ -3235,7 +3102,7 @@ end: * \test Check that the best match search works for all the * possible netblocks of a fixed address */ -int SCRadixTestIPV4NetBlocksAndBestSearch17(void) +static int SCRadixTestIPV4NetBlocksAndBestSearch17(void) { SCRadixTree *tree = NULL; struct sockaddr_in servaddr; @@ -3295,7 +3162,7 @@ end: * \test Check that the best match search works for all the * possible netblocks of a fixed address */ -int SCRadixTestIPV4NetBlocksAndBestSearch18(void) +static int SCRadixTestIPV4NetBlocksAndBestSearch18(void) { SCRadixTree *tree = NULL; struct sockaddr_in servaddr; @@ -3355,7 +3222,7 @@ end: * \test Check special combinations of netblocks and addresses * on best search checking the returned userdata */ -int SCRadixTestIPV4NetBlocksAndBestSearch19(void) +static int SCRadixTestIPV4NetBlocksAndBestSearch19(void) { SCRadixTree *tree = NULL; struct sockaddr_in servaddr; @@ -3601,7 +3468,7 @@ end: * \test Check that the best match search works for all the * possible netblocks of a fixed address */ -int SCRadixTestIPV6NetBlocksAndBestSearch20(void) +static int SCRadixTestIPV6NetBlocksAndBestSearch20(void) { SCRadixTree *tree = NULL; struct sockaddr_in6 servaddr; @@ -3661,7 +3528,7 @@ end: * \test Check that the best match search works for all the * possible netblocks of a fixed address */ -int SCRadixTestIPV6NetBlocksAndBestSearch21(void) +static int SCRadixTestIPV6NetBlocksAndBestSearch21(void) { SCRadixTree *tree = NULL; struct sockaddr_in6 servaddr; @@ -3721,7 +3588,7 @@ end: * \test Check that the best match search works for all the * possible netblocks of a fixed address */ -int SCRadixTestIPV6NetBlocksAndBestSearch22(void) +static int SCRadixTestIPV6NetBlocksAndBestSearch22(void) { SCRadixTree *tree = NULL; struct sockaddr_in6 servaddr; @@ -3781,7 +3648,7 @@ end: * \test Check that the best match search works for all the * possible netblocks of a fixed address */ -int SCRadixTestIPV6NetBlocksAndBestSearch23(void) +static int SCRadixTestIPV6NetBlocksAndBestSearch23(void) { SCRadixTree *tree = NULL; struct sockaddr_in6 servaddr; @@ -3841,7 +3708,7 @@ end: * \test Check special combinations of netblocks and addresses * on best search checking the returned userdata */ -int SCRadixTestIPV6NetBlocksAndBestSearch24(void) +static int SCRadixTestIPV6NetBlocksAndBestSearch24(void) { SCRadixTree *tree = NULL; struct sockaddr_in6 servaddr; @@ -4089,7 +3956,7 @@ end: * Should always return true but the purposse of the test is to monitor * the memory usage to detect memleaks (there was one on searching) */ -int SCRadixTestIPV4NetblockInsertion25(void) +static int SCRadixTestIPV4NetblockInsertion25(void) { SCRadixTree *tree = NULL; struct sockaddr_in servaddr; @@ -4119,7 +3986,7 @@ int SCRadixTestIPV4NetblockInsertion25(void) * Should always return true but the purposse of the test is to monitor * the memory usage to detect memleaks (there was one on searching) */ -int SCRadixTestIPV4NetblockInsertion26(void) +static int SCRadixTestIPV4NetblockInsertion26(void) { SCRadixNode *tmp = NULL; SCRadixTree *tree = NULL; @@ -4179,14 +4046,8 @@ void SCRadixRegisterTests(void) { #ifdef UNITTESTS - //UtRegisterTest("SCRadixTestInsertion01", SCRadixTestInsertion01, 1); - //UtRegisterTest("SCRadixTestInsertion02", SCRadixTestInsertion02, 1); UtRegisterTest("SCRadixTestIPV4Insertion03", SCRadixTestIPV4Insertion03); UtRegisterTest("SCRadixTestIPV4Removal04", SCRadixTestIPV4Removal04); - //UtRegisterTest("SCRadixTestCharacterInsertion05", - // SCRadixTestCharacterInsertion05, 1); - //UtRegisterTest("SCRadixTestCharacterRemoval06", - // SCRadixTestCharacterRemoval06, 1); UtRegisterTest("SCRadixTestIPV6Insertion07", SCRadixTestIPV6Insertion07); UtRegisterTest("SCRadixTestIPV6Removal08", SCRadixTestIPV6Removal08); UtRegisterTest("SCRadixTestIPV4NetblockInsertion09", diff --git a/src/util-random.c b/src/util-random.c index 08916ec494..63adb2d954 100644 --- a/src/util-random.c +++ b/src/util-random.c @@ -25,6 +25,7 @@ */ #include "suricata-common.h" +#include "util-random.h" #if defined(HAVE_WINCRYPT_H) && defined(OS_WIN32) #include diff --git a/src/util-reference-config.c b/src/util-reference-config.c index 3703353940..2cbfaf3c2f 100644 --- a/src/util-reference-config.c +++ b/src/util-reference-config.c @@ -51,7 +51,7 @@ char SCRConfReferenceHashCompareFunc(void *data1, uint16_t datalen1, void SCRConfReferenceHashFree(void *ch); /* used to get the reference.config file path */ -static char *SCRConfGetConfFilename(const DetectEngineCtx *de_ctx); +static const char *SCRConfGetConfFilename(const DetectEngineCtx *de_ctx); void SCReferenceConfInit(void) { @@ -105,7 +105,7 @@ void SCReferenceConfDeinit(void) */ static FILE *SCRConfInitContextAndLocalResources(DetectEngineCtx *de_ctx, FILE *fd) { - char *filename = NULL; + const char *filename = NULL; /* init the hash table to be used by the reference config references */ de_ctx->reference_conf_ht = HashTableInit(128, SCRConfReferenceHashFunc, @@ -159,9 +159,9 @@ static FILE *SCRConfInitContextAndLocalResources(DetectEngineCtx *de_ctx, FILE * * \retval log_filename Pointer to a string containing the path for the * reference.config file. */ -static char *SCRConfGetConfFilename(const DetectEngineCtx *de_ctx) +static const char *SCRConfGetConfFilename(const DetectEngineCtx *de_ctx) { - char *path = NULL; + const char *path = NULL; if (de_ctx != NULL && strlen(de_ctx->config_prefix) > 0) { char config_value[256]; @@ -614,7 +614,7 @@ FILE *SCRConfGenerateInValidDummyReferenceConfigFD03(void) * \test Check that the reference file is loaded and the detection engine * content reference_conf_ht loaded with the reference data. */ -int SCRConfTest01(void) +static int SCRConfTest01(void) { DetectEngineCtx *de_ctx = DetectEngineCtxInit(); int result = 0; @@ -642,7 +642,7 @@ int SCRConfTest01(void) * \test Check that invalid references present in the reference.config file * aren't loaded. */ -int SCRConfTest02(void) +static int SCRConfTest02(void) { DetectEngineCtx *de_ctx = DetectEngineCtxInit(); int result = 0; @@ -669,7 +669,7 @@ int SCRConfTest02(void) * \test Check that only valid references are loaded into the hash table from * the reference.config file. */ -int SCRConfTest03(void) +static int SCRConfTest03(void) { DetectEngineCtx *de_ctx = DetectEngineCtxInit(); int result = 0; @@ -695,7 +695,7 @@ int SCRConfTest03(void) * \test Check if the reference info from the reference.config file have * been loaded into the hash table. */ -int SCRConfTest04(void) +static int SCRConfTest04(void) { DetectEngineCtx *de_ctx = DetectEngineCtxInit(); int result = 1; @@ -727,7 +727,7 @@ int SCRConfTest04(void) * have not been loaded into the hash table, and cross verify to check * that the hash table contains no reference data. */ -int SCRConfTest05(void) +static int SCRConfTest05(void) { DetectEngineCtx *de_ctx = DetectEngineCtxInit(); int result = 1; @@ -759,7 +759,7 @@ int SCRConfTest05(void) * \test Check if the reference info from the reference.config file have * been loaded into the hash table. */ -int SCRConfTest06(void) +static int SCRConfTest06(void) { DetectEngineCtx *de_ctx = DetectEngineCtxInit(); int result = 1; diff --git a/src/util-rule-vars.c b/src/util-rule-vars.c index 12ced4d193..7c7e564fca 100644 --- a/src/util-rule-vars.c +++ b/src/util-rule-vars.c @@ -62,7 +62,7 @@ SCEnumCharMap sc_rule_vars_type_map[ ] = { * \retval conf_var_name_value Pointer to the string containing the conf value * on success; NULL on failure. */ -char *SCRuleVarsGetConfVar(const DetectEngineCtx *de_ctx, +const char *SCRuleVarsGetConfVar(const DetectEngineCtx *de_ctx, const char *conf_var_name, SCRuleVarsType conf_vars_type) { @@ -70,7 +70,7 @@ char *SCRuleVarsGetConfVar(const DetectEngineCtx *de_ctx, const char *conf_var_type_name = NULL; char conf_var_full_name[2048]; - char *conf_var_full_name_value = NULL; + const char *conf_var_full_name_value = NULL; if (conf_var_name == NULL) goto end; @@ -184,7 +184,7 @@ static const char *dummy_conf_string = * \test Check that valid address and port group vars are correctly retrieved * from the configuration. */ -int SCRuleVarsPositiveTest01(void) +static int SCRuleVarsPositiveTest01(void) { int result = 1; @@ -248,7 +248,7 @@ int SCRuleVarsPositiveTest01(void) * \test Check that invalid address and port groups are properly handled by the * API. */ -int SCRuleVarsNegativeTest02(void) +static int SCRuleVarsNegativeTest02(void) { int result = 1; @@ -272,7 +272,7 @@ int SCRuleVarsNegativeTest02(void) * \test Check that Signatures with valid address and port groups are parsed * without any errors by the Signature parsing API. */ -int SCRuleVarsPositiveTest03(void) +static int SCRuleVarsPositiveTest03(void) { int result = 0; Signature *s = NULL; @@ -396,7 +396,7 @@ end: * \test Check that Signatures with invalid address and port groups, are * are invalidated by the Singature parsing API. */ -int SCRuleVarsNegativeTest04(void) +static int SCRuleVarsNegativeTest04(void) { int result = 0; Signature *s = NULL; @@ -465,7 +465,7 @@ static const char *dummy_mt_conf_string = * \test Check that valid address and port group vars are correctly retrieved * from the configuration. */ -int SCRuleVarsMTest01(void) +static int SCRuleVarsMTest01(void) { int result = 0; DetectEngineCtx *de_ctx = NULL; diff --git a/src/util-rule-vars.h b/src/util-rule-vars.h index 57d161e9f1..a79e5c6c51 100644 --- a/src/util-rule-vars.h +++ b/src/util-rule-vars.h @@ -30,7 +30,7 @@ typedef enum { SC_RULE_VARS_PORT_GROUPS, } SCRuleVarsType; -char *SCRuleVarsGetConfVar(const DetectEngineCtx *, const char *, SCRuleVarsType); +const char *SCRuleVarsGetConfVar(const DetectEngineCtx *, const char *, SCRuleVarsType); void SCRuleVarsRegisterTests(void); #endif /* __UTIL_RULE_VARS_H__ */ diff --git a/src/util-running-modes.c b/src/util-running-modes.c index 30699c40c3..ebc44a3fb6 100644 --- a/src/util-running-modes.c +++ b/src/util-running-modes.c @@ -29,6 +29,7 @@ #include "util-unittest.h" #include "util-debug.h" #include "conf-yaml-loader.h" +#include "util-running-modes.h" int ListKeywords(const char *keyword_info) { diff --git a/src/util-running-modes.h b/src/util-running-modes.h index b373f5aafa..510a86f125 100644 --- a/src/util-running-modes.h +++ b/src/util-running-modes.h @@ -25,9 +25,9 @@ int ListKeywords(const char *keyword_info); -int ListAppLayerProtocols(); +int ListAppLayerProtocols(void); #ifdef __SC_CUDA_SUPPORT__ -int ListCudaCards(); +int ListCudaCards(void); #endif #endif /* __UTIL_RUNNING_MODES_H__ */ diff --git a/src/util-signal.c b/src/util-signal.c index 0ba1a2b819..4dc43e4a43 100644 --- a/src/util-signal.c +++ b/src/util-signal.c @@ -24,6 +24,7 @@ #include "suricata-common.h" #include "suricata.h" #include "util-debug.h" +#include "util-signal.h" int UtilSignalBlock(int signum) { @@ -38,7 +39,7 @@ int UtilSignalBlock(int signum) return 0; } -void UtilSignalHandlerSetup(int sig, void (*handler)()) +void UtilSignalHandlerSetup(int sig, void (*handler)(int)) { #if defined (OS_WIN32) signal(sig, handler); @@ -56,7 +57,7 @@ void UtilSignalHandlerSetup(int sig, void (*handler)()) return; } -int UtilSignalIsHandler(int sig, void (*handler)()) +int UtilSignalIsHandler(int sig, void (*handler)(int)) { struct sigaction action; memset(&action, 0x00, sizeof(struct sigaction)); diff --git a/src/util-signal.h b/src/util-signal.h index 7209b3da79..1c1c85ab27 100644 --- a/src/util-signal.h +++ b/src/util-signal.h @@ -25,7 +25,7 @@ #define __UTIL_SIGNAL_H__ int UtilSignalBlock(int); -void UtilSignalHandlerSetup(int, void (*handler)());; -int UtilSignalIsHandler(int sig, void (*handler)()); +void UtilSignalHandlerSetup(int, void (*handler)(int)); +int UtilSignalIsHandler(int sig, void (*handler)(int)); #endif /* __UTIL_SIGNAL_H__ */ diff --git a/src/util-spm.c b/src/util-spm.c index 52432b8adc..7cdbdf2964 100644 --- a/src/util-spm.c +++ b/src/util-spm.c @@ -65,7 +65,7 @@ */ uint16_t SinglePatternMatchDefaultMatcher(void) { - char *spm_algo; + const char *spm_algo; if ((ConfGet("spm-algo", &spm_algo)) == 1) { if (spm_algo != NULL) { if (strcmp("auto", spm_algo) == 0) { @@ -287,7 +287,7 @@ uint8_t *BoyerMooreNocaseSearch(const uint8_t *text, uint32_t textlen, * \param times If you are testing performance, se the numebr of times * that you want to repeat the search */ -uint8_t *BasicSearchWrapper(uint8_t *text, uint8_t *needle, int times) +static uint8_t *BasicSearchWrapper(uint8_t *text, uint8_t *needle, int times) { uint32_t textlen = strlen((char *)text); uint16_t needlelen = strlen((char *)needle); @@ -307,7 +307,7 @@ uint8_t *BasicSearchWrapper(uint8_t *text, uint8_t *needle, int times) return ret; } -uint8_t *BasicSearchNocaseWrapper(uint8_t *text, uint8_t *needle, int times) +static uint8_t *BasicSearchNocaseWrapper(uint8_t *text, uint8_t *needle, int times) { uint32_t textlen = strlen((char *)text); uint16_t needlelen = strlen((char *)needle); @@ -324,7 +324,7 @@ uint8_t *BasicSearchNocaseWrapper(uint8_t *text, uint8_t *needle, int times) return ret; } -uint8_t *Bs2bmWrapper(uint8_t *text, uint8_t *needle, int times) +static uint8_t *Bs2bmWrapper(uint8_t *text, uint8_t *needle, int times) { uint32_t textlen = strlen((char *)text); uint16_t needlelen = strlen((char *)needle); @@ -344,7 +344,7 @@ uint8_t *Bs2bmWrapper(uint8_t *text, uint8_t *needle, int times) return ret; } -uint8_t *Bs2bmNocaseWrapper(uint8_t *text, uint8_t *needle, int times) +static uint8_t *Bs2bmNocaseWrapper(uint8_t *text, uint8_t *needle, int times) { uint32_t textlen = strlen((char *)text); uint16_t needlelen = strlen((char *)needle); @@ -364,7 +364,7 @@ uint8_t *Bs2bmNocaseWrapper(uint8_t *text, uint8_t *needle, int times) return ret; } -uint8_t *BoyerMooreWrapper(uint8_t *text, uint8_t *needle, int times) +static uint8_t *BoyerMooreWrapper(uint8_t *text, uint8_t *needle, int times) { uint32_t textlen = strlen((char *)text); uint16_t needlelen = strlen((char *)needle); @@ -384,7 +384,7 @@ uint8_t *BoyerMooreWrapper(uint8_t *text, uint8_t *needle, int times) return ret; } -uint8_t *BoyerMooreNocaseWrapper(uint8_t *text, uint8_t *in_needle, int times) +static uint8_t *BoyerMooreNocaseWrapper(uint8_t *text, uint8_t *in_needle, int times) { uint32_t textlen = strlen((char *)text); uint16_t needlelen = strlen((char *)in_needle); @@ -412,6 +412,7 @@ uint8_t *BoyerMooreNocaseWrapper(uint8_t *text, uint8_t *in_needle, int times) } +#ifdef ENABLE_SEARCH_STATS /** * \brief Unittest helper function wrappers for the search algorithms * \param text pointer to the buffer to search in @@ -419,7 +420,7 @@ uint8_t *BoyerMooreNocaseWrapper(uint8_t *text, uint8_t *in_needle, int times) * \param times If you are testing performance, se the numebr of times * that you want to repeat the search */ -uint8_t *BasicSearchCtxWrapper(uint8_t *text, uint8_t *needle, int times) +static uint8_t *BasicSearchCtxWrapper(uint8_t *text, uint8_t *needle, int times) { uint32_t textlen = strlen((char *)text); uint16_t needlelen = strlen((char *)needle); @@ -437,7 +438,7 @@ uint8_t *BasicSearchCtxWrapper(uint8_t *text, uint8_t *needle, int times) return ret; } -uint8_t *BasicSearchNocaseCtxWrapper(uint8_t *text, uint8_t *needle, int times) +static uint8_t *BasicSearchNocaseCtxWrapper(uint8_t *text, uint8_t *needle, int times) { uint32_t textlen = strlen((char *)text); uint16_t needlelen = strlen((char *)needle); @@ -455,7 +456,7 @@ uint8_t *BasicSearchNocaseCtxWrapper(uint8_t *text, uint8_t *needle, int times) return ret; } -uint8_t *Bs2bmCtxWrapper(uint8_t *text, uint8_t *needle, int times) +static uint8_t *Bs2bmCtxWrapper(uint8_t *text, uint8_t *needle, int times) { uint32_t textlen = strlen((char *)text); uint16_t needlelen = strlen((char *)needle); @@ -476,7 +477,7 @@ uint8_t *Bs2bmCtxWrapper(uint8_t *text, uint8_t *needle, int times) return ret; } -uint8_t *Bs2bmNocaseCtxWrapper(uint8_t *text, uint8_t *needle, int times) +static uint8_t *Bs2bmNocaseCtxWrapper(uint8_t *text, uint8_t *needle, int times) { uint32_t textlen = strlen((char *)text); uint16_t needlelen = strlen((char *)needle); @@ -497,7 +498,7 @@ uint8_t *Bs2bmNocaseCtxWrapper(uint8_t *text, uint8_t *needle, int times) return ret; } -uint8_t *BoyerMooreCtxWrapper(uint8_t *text, uint8_t *needle, int times) +static uint8_t *BoyerMooreCtxWrapper(uint8_t *text, uint8_t *needle, int times) { uint32_t textlen = strlen((char *)text); uint16_t needlelen = strlen((char *)needle); @@ -519,7 +520,7 @@ uint8_t *BoyerMooreCtxWrapper(uint8_t *text, uint8_t *needle, int times) return ret; } -uint8_t *RawCtxWrapper(uint8_t *text, uint8_t *needle, int times) +static uint8_t *RawCtxWrapper(uint8_t *text, uint8_t *needle, int times) { uint32_t textlen = strlen((char *)text); uint16_t needlelen = strlen((char *)needle); @@ -536,7 +537,7 @@ uint8_t *RawCtxWrapper(uint8_t *text, uint8_t *needle, int times) return ret; } -uint8_t *BoyerMooreNocaseCtxWrapper(uint8_t *text, uint8_t *in_needle, int times) +static uint8_t *BoyerMooreNocaseCtxWrapper(uint8_t *text, uint8_t *in_needle, int times) { uint32_t textlen = strlen((char *)text); uint16_t needlelen = strlen((char *)in_needle); @@ -563,11 +564,12 @@ uint8_t *BoyerMooreNocaseCtxWrapper(uint8_t *text, uint8_t *in_needle, int times return ret; } +#endif /** * \test Generic test for BasicSearch matching */ -int UtilSpmBasicSearchTest01() +static int UtilSpmBasicSearchTest01(void) { uint8_t *needle = (uint8_t *)"oPqRsT"; uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ"; @@ -582,7 +584,7 @@ int UtilSpmBasicSearchTest01() /** * \test Generic test for BasicSearch nocase matching */ -int UtilSpmBasicSearchNocaseTest01() +static int UtilSpmBasicSearchNocaseTest01(void) { uint8_t *needle = (uint8_t *)"OpQrSt"; uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ"; @@ -597,7 +599,7 @@ int UtilSpmBasicSearchNocaseTest01() /** * \test Generic test for Bs2Bm matching */ -int UtilSpmBs2bmSearchTest01() +static int UtilSpmBs2bmSearchTest01(void) { uint8_t *needle = (uint8_t *)"oPqRsT"; uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ"; @@ -612,7 +614,7 @@ int UtilSpmBs2bmSearchTest01() /** * \test Generic test for Bs2Bm no case matching */ -int UtilSpmBs2bmSearchNocaseTest01() +static int UtilSpmBs2bmSearchNocaseTest01(void) { uint8_t *needle = (uint8_t *)"OpQrSt"; uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ"; @@ -627,7 +629,7 @@ int UtilSpmBs2bmSearchNocaseTest01() /** * \test Generic test for boyer moore matching */ -int UtilSpmBoyerMooreSearchTest01() +static int UtilSpmBoyerMooreSearchTest01(void) { uint8_t *needle = (uint8_t *)"oPqRsT"; uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ"; @@ -642,7 +644,7 @@ int UtilSpmBoyerMooreSearchTest01() /** * \test Generic test for boyer moore nocase matching */ -int UtilSpmBoyerMooreSearchNocaseTest01() +static int UtilSpmBoyerMooreSearchNocaseTest01(void) { uint8_t *needle = (uint8_t *)"OpQrSt"; uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ"; @@ -658,7 +660,7 @@ int UtilSpmBoyerMooreSearchNocaseTest01() * \test issue 130 (@redmine) check to ensure that the * problem is not the algorithm implementation */ -int UtilSpmBoyerMooreSearchNocaseTestIssue130() +static int UtilSpmBoyerMooreSearchNocaseTestIssue130(void) { uint8_t *needle = (uint8_t *)"WWW-Authenticate: "; uint8_t *text = (uint8_t *)"Date: Mon, 23 Feb 2009 13:31:49 GMT" @@ -679,7 +681,7 @@ int UtilSpmBoyerMooreSearchNocaseTestIssue130() } /* Generic tests that should not match */ -int UtilSpmBasicSearchTest02() +static int UtilSpmBasicSearchTest02(void) { uint8_t *needle = (uint8_t *)"oPQRsT"; uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ"; @@ -691,7 +693,7 @@ int UtilSpmBasicSearchTest02() return 1; } -int UtilSpmBasicSearchNocaseTest02() +static int UtilSpmBasicSearchNocaseTest02(void) { uint8_t *needle = (uint8_t *)"OpZrSt"; uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ"; @@ -703,7 +705,7 @@ int UtilSpmBasicSearchNocaseTest02() return 1; } -int UtilSpmBs2bmSearchTest02() +static int UtilSpmBs2bmSearchTest02(void) { uint8_t *needle = (uint8_t *)"oPQRsT"; uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ"; @@ -715,7 +717,7 @@ int UtilSpmBs2bmSearchTest02() return 1; } -int UtilSpmBs2bmSearchNocaseTest02() +static int UtilSpmBs2bmSearchNocaseTest02(void) { uint8_t *needle = (uint8_t *)"OpZrSt"; uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ"; @@ -727,7 +729,7 @@ int UtilSpmBs2bmSearchNocaseTest02() return 1; } -int UtilSpmBoyerMooreSearchTest02() +static int UtilSpmBoyerMooreSearchTest02(void) { uint8_t *needle = (uint8_t *)"oPQRsT"; uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ"; @@ -739,7 +741,7 @@ int UtilSpmBoyerMooreSearchTest02() return 1; } -int UtilSpmBoyerMooreSearchNocaseTest02() +static int UtilSpmBoyerMooreSearchNocaseTest02(void) { uint8_t *needle = (uint8_t *)"OpZrSt"; uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ"; @@ -754,9 +756,9 @@ int UtilSpmBoyerMooreSearchNocaseTest02() /** * \test Check that all the algorithms work at any offset and any pattern length */ -int UtilSpmSearchOffsetsTest01() +static int UtilSpmSearchOffsetsTest01(void) { - char *text[26][27]; + const char *text[26][27]; text[0][0]="azzzzzzzzzzzzzzzzzzzzzzzzzz"; text[0][1]="zazzzzzzzzzzzzzzzzzzzzzzzzz"; text[0][2]="zzazzzzzzzzzzzzzzzzzzzzzzzz"; @@ -1135,7 +1137,7 @@ int UtilSpmSearchOffsetsTest01() text[25][0]="aBcDeFgHiJkLmNoPqRsTuVwXyZz"; text[25][1]="zaBcDeFgHiJkLmNoPqRsTuVwXyZ"; - char *needle[26]; + const char *needle[26]; needle[0]="a"; needle[1]="aB"; needle[2]="aBc"; @@ -1190,9 +1192,9 @@ int UtilSpmSearchOffsetsTest01() /** * \test Check that all the algorithms (no case) work at any offset and any pattern length */ -int UtilSpmSearchOffsetsNocaseTest01() +static int UtilSpmSearchOffsetsNocaseTest01(void) { - char *text[26][27]; + const char *text[26][27]; text[0][0]="azzzzzzzzzzzzzzzzzzzzzzzzzz"; text[0][1]="zazzzzzzzzzzzzzzzzzzzzzzzzz"; text[0][2]="zzazzzzzzzzzzzzzzzzzzzzzzzz"; @@ -1571,7 +1573,7 @@ int UtilSpmSearchOffsetsNocaseTest01() text[25][0]="aBcDeFgHiJkLmNoPqRsTuVwXyZz"; text[25][1]="zaBcDeFgHiJkLmNoPqRsTuVwXyZ"; - char *needle[26]; + const char *needle[26]; needle[0]="A"; needle[1]="Ab"; needle[2]="AbC"; @@ -1623,10 +1625,11 @@ int UtilSpmSearchOffsetsNocaseTest01() return 1; } +#ifdef ENABLE_SEARCH_STATS /** * \test Give some stats */ -int UtilSpmSearchStatsTest01() +static int UtilSpmSearchStatsTest01(void) { char *text[16]; text[0]="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzza"; @@ -1694,7 +1697,7 @@ int UtilSpmSearchStatsTest01() /** * \test Give some stats for */ -int UtilSpmSearchStatsTest02() +static int UtilSpmSearchStatsTest02(void) { char *text[16]; text[0]="zzzzzzzzzzzzzzzzzza"; @@ -1760,7 +1763,7 @@ int UtilSpmSearchStatsTest02() } -int UtilSpmSearchStatsTest03() +static int UtilSpmSearchStatsTest03(void) { char *text[16]; text[0]="zzzzzza"; @@ -1828,7 +1831,7 @@ int UtilSpmSearchStatsTest03() /** * \test Give some stats */ -int UtilSpmSearchStatsTest04() +static int UtilSpmSearchStatsTest04(void) { char *text[16]; text[0]="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzza"; @@ -1903,7 +1906,7 @@ int UtilSpmSearchStatsTest04() /** * \test Give some stats for */ -int UtilSpmSearchStatsTest05() +static int UtilSpmSearchStatsTest05(void) { char *text[16]; text[0]="zzzzzzzzzzzzzzzzzza"; @@ -1969,7 +1972,7 @@ int UtilSpmSearchStatsTest05() } -int UtilSpmSearchStatsTest06() +static int UtilSpmSearchStatsTest06(void) { char *text[16]; text[0]="zzzzkzzzzzzzkzzzzzza"; @@ -2012,7 +2015,7 @@ int UtilSpmSearchStatsTest06() return 1; } -int UtilSpmSearchStatsTest07() +static int UtilSpmSearchStatsTest07(void) { char *text[16]; text[0]="zzzza"; @@ -2058,7 +2061,7 @@ int UtilSpmSearchStatsTest07() /** * \test Give some stats for no case algorithms */ -int UtilSpmNocaseSearchStatsTest01() +static int UtilSpmNocaseSearchStatsTest01(void) { char *text[16]; text[0]="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzza"; @@ -2123,7 +2126,7 @@ int UtilSpmNocaseSearchStatsTest01() return 1; } -int UtilSpmNocaseSearchStatsTest02() +static int UtilSpmNocaseSearchStatsTest02(void) { char *text[16]; text[0]="zzzzzzzzzzzzzzzzzza"; @@ -2189,7 +2192,7 @@ int UtilSpmNocaseSearchStatsTest02() } -int UtilSpmNocaseSearchStatsTest03() +static int UtilSpmNocaseSearchStatsTest03(void) { char *text[16]; text[0]="zzzzkzzzzzzzkzzzzzza"; @@ -2235,7 +2238,7 @@ int UtilSpmNocaseSearchStatsTest03() /** * \test Give some stats for no case algorithms */ -int UtilSpmNocaseSearchStatsTest04() +static int UtilSpmNocaseSearchStatsTest04(void) { char *text[16]; text[0]="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzza"; @@ -2300,7 +2303,7 @@ int UtilSpmNocaseSearchStatsTest04() return 1; } -int UtilSpmNocaseSearchStatsTest05() +static int UtilSpmNocaseSearchStatsTest05(void) { char *text[16]; text[0]="zzzzzzzzzzzzzzzzzza"; @@ -2366,7 +2369,7 @@ int UtilSpmNocaseSearchStatsTest05() } -int UtilSpmNocaseSearchStatsTest06() +static int UtilSpmNocaseSearchStatsTest06(void) { char *text[16]; text[0]="zzzzkzzzzzzzkzzzzzza"; @@ -2409,7 +2412,7 @@ int UtilSpmNocaseSearchStatsTest06() return 1; } -int UtilSpmNocaseSearchStatsTest07() +static int UtilSpmNocaseSearchStatsTest07(void) { char *text[16]; text[0]="zzzza"; @@ -2451,6 +2454,7 @@ int UtilSpmNocaseSearchStatsTest07() } return 1; } +#endif /* Unit tests for new SPM API. */ @@ -2519,7 +2523,7 @@ exit: return ret; } -int SpmSearchTest01() { +static int SpmSearchTest01(void) { SpmTableSetup(); printf("\n"); @@ -2583,7 +2587,7 @@ int SpmSearchTest01() { return ret; } -int SpmSearchTest02() { +static int SpmSearchTest02(void) { SpmTableSetup(); printf("\n"); diff --git a/src/util-storage.c b/src/util-storage.c index 5c4c0e05bb..21bbf4e061 100644 --- a/src/util-storage.c +++ b/src/util-storage.c @@ -47,7 +47,7 @@ static int storage_max_id[STORAGE_MAX]; static int storage_registraton_closed = 0; static StorageMapping **storage_map = NULL; -const char *StoragePrintType(StorageEnum type) +static const char *StoragePrintType(StorageEnum type) { switch(type) { case STORAGE_HOST: diff --git a/src/util-streaming-buffer.c b/src/util-streaming-buffer.c index 760fa775fb..4a84a556c6 100644 --- a/src/util-streaming-buffer.c +++ b/src/util-streaming-buffer.c @@ -953,12 +953,13 @@ int StreamingBufferCompareRawData(const StreamingBuffer *sb, return 0; } -void Dump(StreamingBuffer *sb) +#ifdef UNITTESTS +static void Dump(StreamingBuffer *sb) { PrintRawDataFp(stdout, sb->buf, sb->buf_offset); } -void DumpSegment(StreamingBuffer *sb, StreamingBufferSegment *seg) +static void DumpSegment(StreamingBuffer *sb, StreamingBufferSegment *seg) { const uint8_t *data = NULL; uint32_t data_len = 0; @@ -968,7 +969,6 @@ void DumpSegment(StreamingBuffer *sb, StreamingBufferSegment *seg) } } -#ifdef UNITTESTS static int StreamingBufferTest01(void) { StreamingBufferConfig cfg = { STREAMING_BUFFER_AUTOSLIDE, 8, 16, NULL, NULL, NULL, NULL }; diff --git a/src/util-strlcatu.c b/src/util-strlcatu.c index 2edb808050..03add8333e 100644 --- a/src/util-strlcatu.c +++ b/src/util-strlcatu.c @@ -27,9 +27,7 @@ /* $Id: strlcatu.c,v 1.4 2003/10/20 15:03:27 chrisgreen Exp $ */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif +#include "suricata-common.h" #ifndef HAVE_STRLCAT @@ -37,9 +35,6 @@ static char *rcsid = "$OpenBSD: strlcat.c,v 1.5 2001/01/13 16:17:24 millert Exp $"; #endif /* LIBC_SCCS and not lint */ -#include -#include - /* * Appends src to string dst of size siz (unlike strncat, siz is the * full size of dst, not space left). At most siz-1 characters diff --git a/src/util-strlcpyu.c b/src/util-strlcpyu.c index 80694580f5..5cb7bfa9c6 100644 --- a/src/util-strlcpyu.c +++ b/src/util-strlcpyu.c @@ -27,9 +27,7 @@ /* $Id: strlcpyu.c,v 1.4 2003/10/20 15:03:27 chrisgreen Exp $ */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif +#include "suricata-common.h" #ifndef HAVE_STRLCPY @@ -37,9 +35,6 @@ static char *rcsid = "$OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $"; #endif /* LIBC_SCCS and not lint */ -#include -#include - /* * Copy src to string dst of size siz. At most siz-1 characters * will be copied. Always NUL terminates (unless siz == 0). diff --git a/src/util-syslog.c b/src/util-syslog.c index 5b3f7da4a2..482f206789 100644 --- a/src/util-syslog.c +++ b/src/util-syslog.c @@ -25,6 +25,7 @@ */ #include "suricata-common.h" +#include "util-syslog.h" /* holds the string-enum mapping for the syslog facility in SCLogOPIfaceCtx */ SCEnumCharMap sc_syslog_facility_map[] = { @@ -53,7 +54,7 @@ SCEnumCharMap sc_syslog_facility_map[] = { }; /** \brief returns the syslog facility enum map */ -SCEnumCharMap *SCSyslogGetFacilityMap() +SCEnumCharMap *SCSyslogGetFacilityMap(void) { return sc_syslog_facility_map; } @@ -71,7 +72,7 @@ SCEnumCharMap sc_syslog_level_map[ ] = { }; /** \brief returns the syslog facility enum map */ -SCEnumCharMap *SCSyslogGetLogLevelMap() +SCEnumCharMap *SCSyslogGetLogLevelMap(void) { return sc_syslog_level_map; } diff --git a/src/util-threshold-config.c b/src/util-threshold-config.c index b431732814..29715a24bd 100644 --- a/src/util-threshold-config.c +++ b/src/util-threshold-config.c @@ -108,9 +108,9 @@ static void SCThresholdConfDeInitContext(DetectEngineCtx *de_ctx, FILE *fd); * \retval log_filename Pointer to a string containing the path for the * Threshold Config file. */ -static char *SCThresholdConfGetConfFilename(const DetectEngineCtx *de_ctx) +static const char *SCThresholdConfGetConfFilename(const DetectEngineCtx *de_ctx) { - char *log_filename = NULL; + const char *log_filename = NULL; if (de_ctx != NULL && strlen(de_ctx->config_prefix) > 0) { char config_value[256]; @@ -148,7 +148,7 @@ static char *SCThresholdConfGetConfFilename(const DetectEngineCtx *de_ctx) */ int SCThresholdConfInitContext(DetectEngineCtx *de_ctx) { - char *filename = NULL; + const char *filename = NULL; const char *eb = NULL; int eo; int opts = 0; @@ -996,7 +996,7 @@ error: * \retval 0 On success. * \retval -1 On failure. */ -int SCThresholdConfAddThresholdtype(char *rawstr, DetectEngineCtx *de_ctx) +static int SCThresholdConfAddThresholdtype(char *rawstr, DetectEngineCtx *de_ctx) { uint8_t parsed_type = 0; uint8_t parsed_track = 0; @@ -1046,7 +1046,7 @@ error: * \retval 1 On the argument string being a comment or blank line * \retval 0 Otherwise */ -int SCThresholdConfIsLineBlankOrComment(char *line) +static int SCThresholdConfIsLineBlankOrComment(char *line) { while (*line != '\0') { /* we have a comment */ @@ -1072,7 +1072,7 @@ int SCThresholdConfIsLineBlankOrComment(char *line) * \retval the position of the slash making it multiline * \retval 0 Otherwise */ -int SCThresholdConfLineIsMultiline(char *line) +static int SCThresholdConfLineIsMultiline(char *line) { int flag = 0; char *rline = line; @@ -1099,7 +1099,7 @@ int SCThresholdConfLineIsMultiline(char *line) * \param fd Pointer to file descriptor. * \retval int of the line length */ -int SCThresholdConfLineLength(FILE *fd) +static int SCThresholdConfLineLength(FILE *fd) { long pos = ftell(fd); int len = 0; @@ -1196,7 +1196,7 @@ void SCThresholdConfParseFile(DetectEngineCtx *de_ctx, FILE *fd) * * \retval fd Pointer to file descriptor. */ -FILE *SCThresholdConfGenerateValidDummyFD01() +static FILE *SCThresholdConfGenerateValidDummyFD01(void) { FILE *fd = NULL; const char *buffer = @@ -1217,7 +1217,7 @@ FILE *SCThresholdConfGenerateValidDummyFD01() * * \retval fd Pointer to file descriptor. */ -FILE *SCThresholdConfGenerateInValidDummyFD02() +static FILE *SCThresholdConfGenerateInValidDummyFD02(void) { FILE *fd; const char *buffer = @@ -1235,7 +1235,7 @@ FILE *SCThresholdConfGenerateInValidDummyFD02() * * \retval fd Pointer to file descriptor. */ -FILE *SCThresholdConfGenerateValidDummyFD03() +static FILE *SCThresholdConfGenerateValidDummyFD03(void) { FILE *fd; const char *buffer = @@ -1254,7 +1254,7 @@ FILE *SCThresholdConfGenerateValidDummyFD03() * * \retval fd Pointer to file descriptor. */ -FILE *SCThresholdConfGenerateValidDummyFD04() +static FILE *SCThresholdConfGenerateValidDummyFD04(void) { FILE *fd = NULL; const char *buffer = @@ -1274,7 +1274,7 @@ FILE *SCThresholdConfGenerateValidDummyFD04() * * \retval fd Pointer to file descriptor. */ -FILE *SCThresholdConfGenerateValidDummyFD05() +static FILE *SCThresholdConfGenerateValidDummyFD05(void) { FILE *fd = NULL; const char *buffer = @@ -1295,7 +1295,7 @@ FILE *SCThresholdConfGenerateValidDummyFD05() * * \retval fd Pointer to file descriptor. */ -FILE *SCThresholdConfGenerateValidDummyFD06() +static FILE *SCThresholdConfGenerateValidDummyFD06(void) { FILE *fd = NULL; const char *buffer = @@ -1316,7 +1316,7 @@ FILE *SCThresholdConfGenerateValidDummyFD06() * * \retval fd Pointer to file descriptor. */ -FILE *SCThresholdConfGenerateValidDummyFD07() +static FILE *SCThresholdConfGenerateValidDummyFD07(void) { FILE *fd = NULL; const char *buffer = @@ -1336,7 +1336,7 @@ FILE *SCThresholdConfGenerateValidDummyFD07() * * \retval fd Pointer to file descriptor. */ -FILE *SCThresholdConfGenerateValidDummyFD08() +static FILE *SCThresholdConfGenerateValidDummyFD08(void) { FILE *fd = NULL; const char *buffer = @@ -1356,7 +1356,7 @@ FILE *SCThresholdConfGenerateValidDummyFD08() * * \retval fd Pointer to file descriptor. */ -FILE *SCThresholdConfGenerateValidDummyFD09() +static FILE *SCThresholdConfGenerateValidDummyFD09(void) { FILE *fd = NULL; const char *buffer = @@ -1377,7 +1377,7 @@ FILE *SCThresholdConfGenerateValidDummyFD09() * * \retval fd Pointer to file descriptor. */ -FILE *SCThresholdConfGenerateValidDummyFD10() +static FILE *SCThresholdConfGenerateValidDummyFD10(void) { FILE *fd = NULL; const char *buffer = @@ -1397,7 +1397,7 @@ FILE *SCThresholdConfGenerateValidDummyFD10() * * \retval fd Pointer to file descriptor. */ -FILE *SCThresholdConfGenerateValidDummyFD11() +static FILE *SCThresholdConfGenerateValidDummyFD11(void) { FILE *fd = NULL; const char *buffer = @@ -1417,7 +1417,7 @@ FILE *SCThresholdConfGenerateValidDummyFD11() * \retval 1 on succces * \retval 0 on failure */ -int SCThresholdConfTest01(void) +static int SCThresholdConfTest01(void) { DetectEngineCtx *de_ctx = DetectEngineCtxInit(); FAIL_IF_NULL(de_ctx); @@ -1450,7 +1450,7 @@ int SCThresholdConfTest01(void) * \retval 1 on succces * \retval 0 on failure */ -int SCThresholdConfTest02(void) +static int SCThresholdConfTest02(void) { DetectEngineCtx *de_ctx = DetectEngineCtxInit(); FAIL_IF_NULL(de_ctx); @@ -1483,7 +1483,7 @@ int SCThresholdConfTest02(void) * \retval 1 on succces * \retval 0 on failure */ -int SCThresholdConfTest03(void) +static int SCThresholdConfTest03(void) { DetectEngineCtx *de_ctx = DetectEngineCtxInit(); FAIL_IF_NULL(de_ctx); @@ -1516,7 +1516,7 @@ int SCThresholdConfTest03(void) * \retval 1 on succces * \retval 0 on failure */ -int SCThresholdConfTest04(void) +static int SCThresholdConfTest04(void) { DetectEngineCtx *de_ctx = DetectEngineCtxInit(); FAIL_IF_NULL(de_ctx); @@ -1545,7 +1545,7 @@ int SCThresholdConfTest04(void) * \retval 1 on succces * \retval 0 on failure */ -int SCThresholdConfTest05(void) +static int SCThresholdConfTest05(void) { DetectEngineCtx *de_ctx = DetectEngineCtxInit(); FAIL_IF_NULL(de_ctx); @@ -1600,7 +1600,7 @@ int SCThresholdConfTest05(void) * \retval 1 on succces * \retval 0 on failure */ -int SCThresholdConfTest06(void) +static int SCThresholdConfTest06(void) { DetectEngineCtx *de_ctx = DetectEngineCtxInit(); FAIL_IF_NULL(de_ctx); @@ -1633,7 +1633,7 @@ int SCThresholdConfTest06(void) * \retval 1 on succces * \retval 0 on failure */ -int SCThresholdConfTest07(void) +static int SCThresholdConfTest07(void) { DetectEngineCtx *de_ctx = DetectEngineCtxInit(); FAIL_IF_NULL(de_ctx); @@ -1667,7 +1667,7 @@ int SCThresholdConfTest07(void) * \retval 1 on succces * \retval 0 on failure */ -int SCThresholdConfTest08(void) +static int SCThresholdConfTest08(void) { DetectEngineCtx *de_ctx = DetectEngineCtxInit(); FAIL_IF_NULL(de_ctx); @@ -1700,7 +1700,7 @@ int SCThresholdConfTest08(void) * \retval 1 on succces * \retval 0 on failure */ -int SCThresholdConfTest09(void) +static int SCThresholdConfTest09(void) { ThreadVars th_v; memset(&th_v, 0, sizeof(th_v)); @@ -1788,7 +1788,7 @@ int SCThresholdConfTest09(void) * \retval 1 on succces * \retval 0 on failure */ -int SCThresholdConfTest10(void) +static int SCThresholdConfTest10(void) { HostInitConfig(HOST_QUIET); @@ -1860,7 +1860,7 @@ int SCThresholdConfTest10(void) * \retval 1 on succces * \retval 0 on failure */ -int SCThresholdConfTest11(void) +static int SCThresholdConfTest11(void) { HostInitConfig(HOST_QUIET); @@ -1969,7 +1969,7 @@ int SCThresholdConfTest11(void) * \retval 1 on succces * \retval 0 on failure */ -int SCThresholdConfTest12(void) +static int SCThresholdConfTest12(void) { HostInitConfig(HOST_QUIET); @@ -2078,7 +2078,7 @@ int SCThresholdConfTest12(void) * \retval 1 on succces * \retval 0 on failure */ -int SCThresholdConfTest13(void) +static int SCThresholdConfTest13(void) { DetectEngineCtx *de_ctx = DetectEngineCtxInit(); FAIL_IF_NULL(de_ctx); @@ -2111,7 +2111,7 @@ int SCThresholdConfTest13(void) * \retval 1 on succces * \retval 0 on failure */ -int SCThresholdConfTest14(void) +static int SCThresholdConfTest14(void) { HostInitConfig(HOST_QUIET); @@ -2330,7 +2330,7 @@ static int SCThresholdConfTest17(void) * * \retval fd Pointer to file descriptor. */ -static FILE *SCThresholdConfGenerateInvalidDummyFD12() +static FILE *SCThresholdConfGenerateInvalidDummyFD12(void) { FILE *fd = NULL; const char *buffer = @@ -2382,7 +2382,7 @@ static int SCThresholdConfTest18(void) * * \retval fd Pointer to file descriptor. */ -static FILE *SCThresholdConfGenerateInvalidDummyFD13() +static FILE *SCThresholdConfGenerateInvalidDummyFD13(void) { FILE *fd = NULL; const char *buffer = @@ -2431,7 +2431,7 @@ static int SCThresholdConfTest19(void) * * \retval fd Pointer to file descriptor. */ -FILE *SCThresholdConfGenerateValidDummyFD20() +static FILE *SCThresholdConfGenerateValidDummyFD20(void) { FILE *fd = NULL; const char *buffer = diff --git a/src/util-threshold-config.h b/src/util-threshold-config.h index 459c956d07..e8a6024955 100644 --- a/src/util-threshold-config.h +++ b/src/util-threshold-config.h @@ -27,6 +27,6 @@ void SCThresholdConfParseFile(DetectEngineCtx *, FILE *); int SCThresholdConfInitContext(DetectEngineCtx *); -void SCThresholdConfRegisterTests(); +void SCThresholdConfRegisterTests(void); #endif /* __UTIL_THRESHOLD_CONFIG_H__ */ diff --git a/src/util-time.c b/src/util-time.c index 3e2b6058bb..d6ba2f7ccd 100644 --- a/src/util-time.c +++ b/src/util-time.c @@ -438,7 +438,7 @@ time_t SCMkTimeUtc (struct tm *tp) * \retval 0 on success. * \retval 1 on failure. */ -int SCStringPatternToTime (char *string, char **patterns, int num_patterns, +int SCStringPatternToTime (char *string, const char **patterns, int num_patterns, struct tm *tp) { char *result = NULL; diff --git a/src/util-time.h b/src/util-time.h index 4bf965e729..4b2c82e176 100644 --- a/src/util-time.h +++ b/src/util-time.h @@ -56,7 +56,7 @@ void CreateIsoTimeString(const struct timeval *ts, char *str, size_t size); void CreateUtcIsoTimeString(const struct timeval *ts, char *str, size_t size); void CreateFormattedTimeString(const struct tm *t, const char * fmt, char *str, size_t size); time_t SCMkTimeUtc(struct tm *tp); -int SCStringPatternToTime(char *string, char **patterns, +int SCStringPatternToTime(char *string, const char **patterns, int num_patterns, struct tm *time); int SCTimeToStringPattern (time_t epoch, const char *pattern, char *str, size_t size); diff --git a/src/util-unittest-helper.c b/src/util-unittest-helper.c index f678f129f1..2e7e2e0ac4 100644 --- a/src/util-unittest-helper.c +++ b/src/util-unittest-helper.c @@ -54,7 +54,7 @@ * * \retval uint the uin32_t representation */ -uint32_t UTHSetIPv4Address(char *str) +uint32_t UTHSetIPv4Address(const char *str) { struct in_addr in; if (inet_pton(AF_INET, str, &in) != 1) { @@ -79,7 +79,7 @@ uint32_t UTHSetIPv4Address(char *str) * \retval Packet pointer to the built in packet */ Packet *UTHBuildPacketIPV6Real(uint8_t *payload, uint16_t payload_len, - uint8_t ipproto, char *src, char *dst, + uint8_t ipproto, const char *src, const char *dst, uint16_t sport, uint16_t dport) { uint32_t in[4]; @@ -165,7 +165,7 @@ error: * \retval Packet pointer to the built in packet */ Packet *UTHBuildPacketReal(uint8_t *payload, uint16_t payload_len, - uint8_t ipproto, char *src, char *dst, + uint8_t ipproto, const char *src, const char *dst, uint16_t sport, uint16_t dport) { struct in_addr in; @@ -341,7 +341,7 @@ Packet *UTHBuildPacketFromEth(uint8_t *raw_eth, uint16_t pktsize) * \retval Packet pointer to the built in packet */ Packet *UTHBuildPacketSrcDst(uint8_t *payload, uint16_t payload_len, - uint8_t ipproto, char *src, char *dst) + uint8_t ipproto, const char *src, const char *dst) { return UTHBuildPacketReal(payload, payload_len, ipproto, src, dst, @@ -359,7 +359,7 @@ Packet *UTHBuildPacketSrcDst(uint8_t *payload, uint16_t payload_len, * \retval Packet pointer to the built in packet */ Packet *UTHBuildPacketIPV6SrcDst(uint8_t *payload, uint16_t payload_len, - uint8_t ipproto, char *src, char *dst) + uint8_t ipproto, const char *src, const char *dst) { return UTHBuildPacketIPV6Real(payload, payload_len, ipproto, src, dst, @@ -435,7 +435,7 @@ void UTHFreePacket(Packet *p) SCFree(p); } -Flow *UTHBuildFlow(int family, char *src, char *dst, Port sp, Port dp) +Flow *UTHBuildFlow(int family, const char *src, const char *dst, Port sp, Port dp) { struct in_addr in; @@ -564,7 +564,7 @@ int UTHRemoveSessionFromFlow(Flow *f) * \retval int 1 if the match of all the sids is the specified has the * specified results; 0 if not */ -int UTHGenericTest(Packet **pkt, int numpkts, char *sigs[], uint32_t sids[], uint32_t *results, int numsigs) +int UTHGenericTest(Packet **pkt, int numpkts, const char *sigs[], uint32_t sids[], uint32_t *results, int numsigs) { int result = 0; @@ -641,7 +641,7 @@ int UTHCheckPacketMatchResults(Packet *p, uint32_t sids[], * * \retval int 0 if we have errors; 1 if all the signatures loaded succesfuly */ -int UTHAppendSigs(DetectEngineCtx *de_ctx, char *sigs[], int numsigs) +int UTHAppendSigs(DetectEngineCtx *de_ctx, const char *sigs[], int numsigs) { if (de_ctx == NULL || numsigs <= 0 || sigs == NULL) { SCLogError(SC_ERR_INVALID_ARGUMENT, "Arguments invalid, check if sigs or de_ctx are NULL, and if the array contain sigs"); @@ -842,7 +842,7 @@ end: * \retval return 1 if match * \retval return 0 if not */ -int UTHPacketMatchSig(Packet *p, char *sig) +int UTHPacketMatchSig(Packet *p, const char *sig) { int result = 1; @@ -924,7 +924,7 @@ uint32_t UTHBuildPacketOfFlows(uint32_t start, uint32_t end, uint8_t dir) /** * \brief CheckUTHTestPacket wrapper to check packets for unittests */ -int CheckUTHTestPacket(Packet *p, uint8_t ipproto) +static int CheckUTHTestPacket(Packet *p, uint8_t ipproto) { uint16_t sport = 41424; uint16_t dport = 80; @@ -972,7 +972,7 @@ int CheckUTHTestPacket(Packet *p, uint8_t ipproto) /** * \brief UTHBuildPacketRealTest01 wrapper to check packets for unittests */ -int UTHBuildPacketRealTest01(void) +static int UTHBuildPacketRealTest01(void) { uint8_t payload[] = "Payload"; @@ -988,7 +988,7 @@ int UTHBuildPacketRealTest01(void) /** * \brief UTHBuildPacketRealTest02 wrapper to check packets for unittests */ -int UTHBuildPacketRealTest02(void) +static int UTHBuildPacketRealTest02(void) { uint8_t payload[] = "Payload"; @@ -1003,7 +1003,7 @@ int UTHBuildPacketRealTest02(void) /** * \brief UTHBuildPacketTest01 wrapper to check packets for unittests */ -int UTHBuildPacketTest01(void) +static int UTHBuildPacketTest01(void) { uint8_t payload[] = "Payload"; @@ -1018,7 +1018,7 @@ int UTHBuildPacketTest01(void) /** * \brief UTHBuildPacketTest02 wrapper to check packets for unittests */ -int UTHBuildPacketTest02(void) +static int UTHBuildPacketTest02(void) { uint8_t payload[] = "Payload"; @@ -1033,7 +1033,7 @@ int UTHBuildPacketTest02(void) /** * \brief UTHBuildPacketOfFlowsTest01 wrapper to check packets for unittests */ -int UTHBuildPacketOfFlowsTest01(void) +static int UTHBuildPacketOfFlowsTest01(void) { int result = 0; @@ -1055,7 +1055,7 @@ int UTHBuildPacketOfFlowsTest01(void) /** * \brief UTHBuildPacketSrcDstTest01 wrapper to check packets for unittests */ -int UTHBuildPacketSrcDstTest01(void) +static int UTHBuildPacketSrcDstTest01(void) { uint8_t payload[] = "Payload"; @@ -1071,7 +1071,7 @@ int UTHBuildPacketSrcDstTest01(void) /** * \brief UTHBuildPacketSrcDstTest02 wrapper to check packets for unittests */ -int UTHBuildPacketSrcDstTest02(void) +static int UTHBuildPacketSrcDstTest02(void) { uint8_t payload[] = "Payload"; @@ -1087,7 +1087,7 @@ int UTHBuildPacketSrcDstTest02(void) /** * \brief UTHBuildPacketSrcDstPortsTest01 wrapper to check packets for unittests */ -int UTHBuildPacketSrcDstPortsTest01(void) +static int UTHBuildPacketSrcDstPortsTest01(void) { uint8_t payload[] = "Payload"; @@ -1103,7 +1103,7 @@ int UTHBuildPacketSrcDstPortsTest01(void) /** * \brief UTHBuildPacketSrcDstPortsTest02 wrapper to check packets for unittests */ -int UTHBuildPacketSrcDstPortsTest02(void) +static int UTHBuildPacketSrcDstPortsTest02(void) { uint8_t payload[] = "Payload"; diff --git a/src/util-unittest-helper.h b/src/util-unittest-helper.h index 7555e7f36c..73dae60c60 100644 --- a/src/util-unittest-helper.h +++ b/src/util-unittest-helper.h @@ -25,14 +25,14 @@ #define __UTIL_UNITTEST_HELPER__ #ifdef UNITTESTS -uint32_t UTHSetIPv4Address(char *); +uint32_t UTHSetIPv4Address(const char *); -Packet *UTHBuildPacketReal(uint8_t *, uint16_t, uint8_t ipproto, char *, char *, uint16_t, uint16_t); +Packet *UTHBuildPacketReal(uint8_t *, uint16_t, uint8_t ipproto, const char *, const char *, uint16_t, uint16_t); Packet *UTHBuildPacket(uint8_t *, uint16_t, uint8_t ipproto); -Packet *UTHBuildPacketSrcDst(uint8_t *, uint16_t, uint8_t ipproto, char *, char *); +Packet *UTHBuildPacketSrcDst(uint8_t *, uint16_t, uint8_t ipproto, const char *, const char *); Packet *UTHBuildPacketSrcDstPorts(uint8_t *, uint16_t, uint8_t ipproto, uint16_t, uint16_t); -Packet *UTHBuildPacketIPV6SrcDst(uint8_t *, uint16_t, uint8_t ipproto, char *, char *); +Packet *UTHBuildPacketIPV6SrcDst(uint8_t *, uint16_t, uint8_t ipproto, const char *, const char *); int UTHPacketMatchSigMpm(Packet *, char *, uint16_t); Packet **UTHBuildPacketArrayFromEth(uint8_t **, int *, int); @@ -41,23 +41,23 @@ Packet *UTHBuildPacketFromEth(uint8_t *, uint16_t); void UTHFreePacket(Packet *); void UTHFreePackets(Packet **, int); -Flow *UTHBuildFlow(int family, char *src, char *dst, Port sp, Port dp); +Flow *UTHBuildFlow(int family, const char *src, const char *dst, Port sp, Port dp); void UTHFreeFlow(Flow *flow); int UTHAddStreamToFlow(Flow *f, int direction, uint8_t *data, uint32_t data_len); int UTHAddSessionToFlow(Flow *f, uint32_t ts_isn, uint32_t tc_isn); int UTHRemoveSessionFromFlow(Flow *f); -int UTHAppendSigs(DetectEngineCtx *, char **, int); +int UTHAppendSigs(DetectEngineCtx *, const char **, int); int UTHMatchPackets(DetectEngineCtx *, Packet **, int); -int UTHPacketMatchSig(Packet *p, char *); +int UTHPacketMatchSig(Packet *p, const char *); int UTHCheckPacketMatch(Packet *, uint32_t *, uint32_t *, int); int UTHCheckPacketMatchResults(Packet *, uint32_t *, uint32_t *, int); int UTHMatchPacketsWithResults(DetectEngineCtx *, Packet **, int, uint32_t *, uint32_t *, int); -int UTHGenericTest(Packet **, int, char **, uint32_t *, uint32_t *, int); +int UTHGenericTest(Packet **, int, const char **, uint32_t *, uint32_t *, int); uint32_t UTHBuildPacketOfFlows(uint32_t, uint32_t, uint8_t); -Packet *UTHBuildPacketIPV6Real(uint8_t *, uint16_t , uint8_t ipproto, char *, char *, +Packet *UTHBuildPacketIPV6Real(uint8_t *, uint16_t , uint8_t ipproto, const char *, const char *, uint16_t , uint16_t ); #endif diff --git a/src/util-unittest.c b/src/util-unittest.c index 9e2c6de619..bb12bfcda0 100644 --- a/src/util-unittest.c +++ b/src/util-unittest.c @@ -100,7 +100,7 @@ static int UtAppendTest(UtTest **list, UtTest *test) * \param TestFn Unit test function */ -void UtRegisterTest(char *name, int(*TestFn)(void)) +void UtRegisterTest(const char *name, int(*TestFn)(void)) { UtTest *ut = UtAllocTest(); if (ut == NULL) @@ -122,8 +122,7 @@ void UtRegisterTest(char *name, int(*TestFn)(void)) * \retval 1 Regex compiled * \retval -1 Regex error */ - -int UtRegex (char *regex_arg) +static int UtRegex (const char *regex_arg) { const char *eb; int eo; @@ -158,7 +157,7 @@ error: * * \param regex_arg Regular expression to limit listed tests. */ -void UtListTests(char *regex_arg) +void UtListTests(const char *regex_arg) { UtTest *ut; int ret = 0, rcomp = 0; @@ -188,7 +187,7 @@ void UtListTests(char *regex_arg) * \retval result number of tests that failed */ -uint32_t UtRunTests(char *regex_arg) +uint32_t UtRunTests(const char *regex_arg) { UtTest *ut; uint32_t good = 0, bad = 0, matchcnt = 0; @@ -296,8 +295,7 @@ void UtRunModeRegister(void) * \retval 1 True * \retval 0 False */ - -int UtSelftestTrue(void) +static int UtSelftestTrue(void) { if (1)return 1; else return 0; @@ -308,15 +306,12 @@ int UtSelftestTrue(void) * \retval 1 False * \retval 0 True */ - -int UtSelftestFalse(void) +static int UtSelftestFalse(void) { if (0)return 0; else return 1; } -#endif /* UNITTESTS */ - /** \brief Run self tests * * \param regex_arg The regular expression @@ -324,9 +319,8 @@ int UtSelftestFalse(void) * \retval 0 all successful */ -int UtRunSelftest (char *regex_arg) +int UtRunSelftest (const char *regex_arg) { -#ifdef UNITTESTS printf("* Running Unittesting subsystem selftests...\n"); UtInitialize(); @@ -341,9 +335,9 @@ int UtRunSelftest (char *regex_arg) printf("* ERROR running Unittesting subsystem selftests failed...\n"); UtCleanup(); -#endif /* UNITTESTS */ return 0; } +#endif /* UNITTESTS */ /** * @} diff --git a/src/util-unittest.h b/src/util-unittest.h index 7a0e110be9..4f3be006c8 100644 --- a/src/util-unittest.h +++ b/src/util-unittest.h @@ -35,21 +35,21 @@ #ifdef UNITTESTS -typedef struct UtTest_ { - - char *name; +typedef struct UtTest_ +{ + const char *name; int(*TestFn)(void); struct UtTest_ *next; } UtTest; -void UtRegisterTest(char *name, int(*TestFn)(void)); -uint32_t UtRunTests(char *regex_arg); +void UtRegisterTest(const char *name, int(*TestFn)(void)); +uint32_t UtRunTests(const char *regex_arg); void UtInitialize(void); void UtCleanup(void); -int UtRunSelftest (char *regex_arg); -void UtListTests(char *regex_arg); +int UtRunSelftest (const char *regex_arg); +void UtListTests(const char *regex_arg); void UtRunModeRegister(void); extern int unittests_fatal;