From: Ken Steele Date: Wed, 30 Jul 2014 18:19:35 +0000 (-0400) Subject: Enforce function coding standard X-Git-Tag: suricata-2.1beta1~27 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8f1d75039a1378aed62c3d27578a954c0a4ccce6;p=thirdparty%2Fsuricata.git Enforce function coding standard Functions should be defined as: int foo(void) { } Rather than: int food(void) { } All functions where changed by a script to match this standard. --- diff --git a/src/alert-debuglog.c b/src/alert-debuglog.c index c50a6becdf..361b070a3e 100644 --- a/src/alert-debuglog.c +++ b/src/alert-debuglog.c @@ -430,7 +430,8 @@ static TmEcode AlertDebugLogThreadDeinit(ThreadVars *t, void *data) return TM_ECODE_OK; } -static void AlertDebugLogExitPrintStats(ThreadVars *tv, void *data) { +static void AlertDebugLogExitPrintStats(ThreadVars *tv, void *data) +{ AlertDebugLogThread *aft = (AlertDebugLogThread *)data; if (aft == NULL) { return; @@ -492,11 +493,13 @@ error: return NULL; } -static int AlertDebugLogCondition(ThreadVars *tv, const Packet *p) { +static int AlertDebugLogCondition(ThreadVars *tv, const Packet *p) +{ return (p->alerts.cnt ? TRUE : FALSE); } -static int AlertDebugLogLogger(ThreadVars *tv, void *thread_data, const Packet *p) { +static int AlertDebugLogLogger(ThreadVars *tv, void *thread_data, const Packet *p) +{ if (PKT_IS_IPV4(p)) { return AlertDebugLogger(tv, p, thread_data); } else if (PKT_IS_IPV6(p)) { @@ -507,7 +510,8 @@ static int AlertDebugLogLogger(ThreadVars *tv, void *thread_data, const Packet * return TM_ECODE_OK; } -void TmModuleAlertDebugLogRegister (void) { +void TmModuleAlertDebugLogRegister (void) +{ tmm_modules[TMM_ALERTDEBUGLOG].name = MODULE_NAME; tmm_modules[TMM_ALERTDEBUGLOG].ThreadInit = AlertDebugLogThreadInit; tmm_modules[TMM_ALERTDEBUGLOG].Func = NULL; diff --git a/src/alert-fastlog.c b/src/alert-fastlog.c index 2a5f6d3a57..27fdbe4459 100644 --- a/src/alert-fastlog.c +++ b/src/alert-fastlog.c @@ -77,7 +77,8 @@ static void AlertFastLogDeInitCtx(OutputCtx *); int AlertFastLogCondition(ThreadVars *tv, const Packet *p); int AlertFastLogger(ThreadVars *tv, void *data, const Packet *p); -void TmModuleAlertFastLogRegister (void) { +void TmModuleAlertFastLogRegister (void) +{ tmm_modules[TMM_ALERTFASTLOG].name = MODULE_NAME; tmm_modules[TMM_ALERTFASTLOG].ThreadInit = AlertFastLogThreadInit; tmm_modules[TMM_ALERTFASTLOG].ThreadExitPrintStats = AlertFastLogExitPrintStats; @@ -95,7 +96,8 @@ typedef struct AlertFastLogThread_ { LogFileCtx* file_ctx; } AlertFastLogThread; -int AlertFastLogCondition(ThreadVars *tv, const Packet *p) { +int AlertFastLogCondition(ThreadVars *tv, const Packet *p) +{ return (p->alerts.cnt ? TRUE : FALSE); } diff --git a/src/alert-prelude.c b/src/alert-prelude.c index b20ae35b79..a8e41ac339 100644 --- a/src/alert-prelude.c +++ b/src/alert-prelude.c @@ -73,7 +73,8 @@ static TmEcode AlertPreludeThreadDeinit(ThreadVars *t, void *data) return TM_ECODE_FAILED; } -void TmModuleAlertPreludeRegister (void) { +void TmModuleAlertPreludeRegister (void) +{ tmm_modules[TMM_ALERTPRELUDE].name = "AlertPrelude"; tmm_modules[TMM_ALERTPRELUDE].ThreadInit = AlertPreludeThreadInit; tmm_modules[TMM_ALERTPRELUDE].ThreadDeinit = AlertPreludeThreadDeinit; @@ -740,7 +741,8 @@ static OutputCtx *AlertPreludeInitCtx(ConfNode *conf) SCReturnPtr((void*)output_ctx, "OutputCtx"); } -static int AlertPreludeCondition(ThreadVars *tv, const Packet *p) { +static int AlertPreludeCondition(ThreadVars *tv, const Packet *p) +{ if (p->alerts.cnt == 0) return FALSE; if (!IPH_IS_VALID(p)) @@ -764,7 +766,8 @@ static int AlertPreludeCondition(ThreadVars *tv, const Packet *p) { * * \return TM_ECODE_OK if ok, else TM_ECODE_FAILED */ -static int AlertPreludeLogger(ThreadVars *tv, void *thread_data, const Packet *p) { +static int AlertPreludeLogger(ThreadVars *tv, void *thread_data, const Packet *p) +{ AlertPreludeThread *apn = (AlertPreludeThread *)thread_data; int ret; idmef_time_t *time; @@ -866,7 +869,8 @@ err: SCReturnInt(TM_ECODE_FAILED); } -void TmModuleAlertPreludeRegister (void) { +void TmModuleAlertPreludeRegister (void) +{ tmm_modules[TMM_ALERTPRELUDE].name = "AlertPrelude"; tmm_modules[TMM_ALERTPRELUDE].ThreadInit = AlertPreludeThreadInit; tmm_modules[TMM_ALERTPRELUDE].Func = NULL; diff --git a/src/alert-syslog.c b/src/alert-syslog.c index a57712bf4c..13151dd990 100644 --- a/src/alert-syslog.c +++ b/src/alert-syslog.c @@ -377,7 +377,8 @@ static TmEcode AlertSyslogDecoderEvent(ThreadVars *tv, const Packet *p, void *da * \param tv Pointer to the output threadvars * \param data Pointer to the AlertSyslogThread data */ -static void AlertSyslogExitPrintStats(ThreadVars *tv, void *data) { +static void AlertSyslogExitPrintStats(ThreadVars *tv, void *data) +{ AlertSyslogThread *ast = (AlertSyslogThread *)data; if (ast == NULL) { return; @@ -386,11 +387,13 @@ static void AlertSyslogExitPrintStats(ThreadVars *tv, void *data) { SCLogInfo("(%s) Alerts %" PRIu64 "", tv->name, ast->file_ctx->alerts); } -static int AlertSyslogCondition(ThreadVars *tv, const Packet *p) { +static int AlertSyslogCondition(ThreadVars *tv, const Packet *p) +{ return (p->alerts.cnt > 0 ? TRUE : FALSE); } -static int AlertSyslogLogger(ThreadVars *tv, void *thread_data, const Packet *p) { +static int AlertSyslogLogger(ThreadVars *tv, void *thread_data, const Packet *p) +{ if (PKT_IS_IPV4(p)) { return AlertSyslogIPv4(tv, p, thread_data); } else if (PKT_IS_IPV6(p)) { @@ -405,7 +408,8 @@ static int AlertSyslogLogger(ThreadVars *tv, void *thread_data, const Packet *p) #endif /* !OS_WIN32 */ /** \brief Function to register the AlertSyslog module */ -void TmModuleAlertSyslogRegister (void) { +void TmModuleAlertSyslogRegister (void) +{ #ifndef OS_WIN32 tmm_modules[TMM_ALERTSYSLOG].name = MODULE_NAME; tmm_modules[TMM_ALERTSYSLOG].ThreadInit = AlertSyslogThreadInit; diff --git a/src/app-layer-dcerpc-udp.c b/src/app-layer-dcerpc-udp.c index d94e6ca4ab..c44bdbb370 100644 --- a/src/app-layer-dcerpc-udp.c +++ b/src/app-layer-dcerpc-udp.c @@ -767,7 +767,8 @@ static int DCERPCUDPParse(Flow *f, void *dcerpc_state, SCReturnInt(1); } -static void *DCERPCUDPStateAlloc(void) { +static void *DCERPCUDPStateAlloc(void) +{ void *s = SCMalloc(sizeof(DCERPCUDPState)); if (unlikely(s == NULL)) return NULL; @@ -776,7 +777,8 @@ static void *DCERPCUDPStateAlloc(void) { return s; } -static void DCERPCUDPStateFree(void *s) { +static void DCERPCUDPStateFree(void *s) +{ DCERPCUDPState *sstate = (DCERPCUDPState *) s; DCERPCUuidEntry *item; @@ -810,7 +812,8 @@ static int DCERPCUDPRegisterPatternsForProtocolDetection(void) return 0; } -void RegisterDCERPCUDPParsers(void) { +void RegisterDCERPCUDPParsers(void) +{ char *proto_name = "dcerpc"; if (AppLayerProtoDetectConfProtoDetectionEnabled("udp", proto_name)) { @@ -847,7 +850,8 @@ void RegisterDCERPCUDPParsers(void) { /** \test DCERPC UDP Header Parsing and UUID handling */ -int DCERPCUDPParserTest01(void) { +int DCERPCUDPParserTest01(void) +{ int result = 1; Flow f; uint8_t dcerpcrequest[] = { @@ -1097,7 +1101,8 @@ end: return result; } -void DCERPCUDPParserRegisterTests(void) { +void DCERPCUDPParserRegisterTests(void) +{ UtRegisterTest("DCERPCUDPParserTest01", DCERPCUDPParserTest01, 1); } #endif diff --git a/src/app-layer-dcerpc.c b/src/app-layer-dcerpc.c index 8f8af1ac22..900c326989 100644 --- a/src/app-layer-dcerpc.c +++ b/src/app-layer-dcerpc.c @@ -78,7 +78,8 @@ enum { }; /* \brief hexdump function from libdnet, used for debugging only */ -void hexdump(/*Flow *f,*/ const void *buf, size_t len) { +void hexdump(/*Flow *f,*/ const void *buf, size_t len) +{ /* dumps len bytes of *buf to stdout. Looks like: * [0000] 75 6E 6B 6E 6F 77 6E 20 * 30 FF 00 00 00 00 39 00 unknown 0.....9. @@ -140,7 +141,8 @@ 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(char *type, DCERPCUuidEntry *uuid) +{ uint8_t i = 0; if (uuid == NULL) { return; @@ -158,7 +160,8 @@ void printUUID(char *type, DCERPCUuidEntry *uuid) { * \brief DCERPCParseSecondaryAddr reads secondaryaddrlen bytes from the BIND_ACK * DCERPC call. */ -static uint32_t DCERPCParseSecondaryAddr(DCERPC *dcerpc, uint8_t *input, uint32_t input_len) { +static uint32_t DCERPCParseSecondaryAddr(DCERPC *dcerpc, uint8_t *input, uint32_t input_len) +{ SCEnter(); uint8_t *p = input; while (dcerpc->dcerpcbindbindack.secondaryaddrlenleft-- && input_len--) { @@ -169,7 +172,8 @@ static uint32_t DCERPCParseSecondaryAddr(DCERPC *dcerpc, uint8_t *input, uint32_ SCReturnUInt((uint32_t)(p - input)); } -static uint32_t PaddingParser(DCERPC *dcerpc, uint8_t *input, uint32_t input_len) { +static uint32_t PaddingParser(DCERPC *dcerpc, uint8_t *input, uint32_t input_len) +{ SCEnter(); uint8_t *p = input; while (dcerpc->padleft-- && input_len--) { @@ -180,7 +184,8 @@ static uint32_t PaddingParser(DCERPC *dcerpc, uint8_t *input, uint32_t input_len SCReturnUInt((uint32_t)(p - input)); } -static uint32_t DCERPCGetCTXItems(DCERPC *dcerpc, uint8_t *input, uint32_t input_len) { +static uint32_t DCERPCGetCTXItems(DCERPC *dcerpc, uint8_t *input, uint32_t input_len) +{ SCEnter(); uint8_t *p = input; if (input_len) { @@ -225,7 +230,8 @@ static uint32_t DCERPCGetCTXItems(DCERPC *dcerpc, uint8_t *input, uint32_t input * each UUID is added to a TAILQ. */ -static uint32_t DCERPCParseBINDCTXItem(DCERPC *dcerpc, uint8_t *input, uint32_t input_len) { +static uint32_t DCERPCParseBINDCTXItem(DCERPC *dcerpc, uint8_t *input, uint32_t input_len) +{ SCEnter(); uint8_t *p = input; @@ -656,7 +662,8 @@ static uint32_t DCERPCParseBINDCTXItem(DCERPC *dcerpc, uint8_t *input, uint32_t * the BIND_ACK call. The result (Accepted or Rejected) is added to the * correct UUID from the BIND call. */ -static uint32_t DCERPCParseBINDACKCTXItem(DCERPC *dcerpc, uint8_t *input, uint32_t input_len) { +static uint32_t DCERPCParseBINDACKCTXItem(DCERPC *dcerpc, uint8_t *input, uint32_t input_len) +{ SCEnter(); uint8_t *p = input; DCERPCUuidEntry *uuid_entry; @@ -871,7 +878,8 @@ static uint32_t DCERPCParseBINDACKCTXItem(DCERPC *dcerpc, uint8_t *input, uint32 SCReturnUInt((uint32_t)(p - input)); } -static uint32_t DCERPCParseBIND(DCERPC *dcerpc, uint8_t *input, uint32_t input_len) { +static uint32_t DCERPCParseBIND(DCERPC *dcerpc, uint8_t *input, uint32_t input_len) +{ SCEnter(); DCERPCUuidEntry *item; uint8_t *p = input; @@ -993,7 +1001,8 @@ static uint32_t DCERPCParseBIND(DCERPC *dcerpc, uint8_t *input, uint32_t input_l SCReturnUInt((uint32_t)(p - input)); } -static uint32_t DCERPCParseBINDACK(DCERPC *dcerpc, uint8_t *input, uint32_t input_len) { +static uint32_t DCERPCParseBINDACK(DCERPC *dcerpc, uint8_t *input, uint32_t input_len) +{ SCEnter(); uint8_t *p = input; @@ -1085,7 +1094,8 @@ static uint32_t DCERPCParseBINDACK(DCERPC *dcerpc, uint8_t *input, uint32_t inpu SCReturnUInt((uint32_t)(p - input)); } -static uint32_t DCERPCParseREQUEST(DCERPC *dcerpc, uint8_t *input, uint32_t input_len) { +static uint32_t DCERPCParseREQUEST(DCERPC *dcerpc, uint8_t *input, uint32_t input_len) +{ SCEnter(); uint8_t *p = input; @@ -1179,7 +1189,8 @@ static uint32_t DCERPCParseREQUEST(DCERPC *dcerpc, uint8_t *input, uint32_t inpu SCReturnUInt((uint32_t)(p - input)); } -static uint32_t StubDataParser(DCERPC *dcerpc, uint8_t *input, uint32_t input_len) { +static uint32_t StubDataParser(DCERPC *dcerpc, uint8_t *input, uint32_t input_len) +{ SCEnter(); uint8_t **stub_data_buffer = NULL; uint32_t *stub_data_buffer_len = NULL; @@ -1273,7 +1284,8 @@ end: * \retval -1 if DCERPC Header does not validate * \retval Number of bytes processed */ -static int DCERPCParseHeader(DCERPC *dcerpc, uint8_t *input, uint32_t input_len) { +static int DCERPCParseHeader(DCERPC *dcerpc, uint8_t *input, uint32_t input_len) +{ SCEnter(); uint8_t *p = input; @@ -1422,7 +1434,8 @@ static int DCERPCParseHeader(DCERPC *dcerpc, uint8_t *input, uint32_t input_len) SCReturnInt((p - input)); } -static inline void DCERPCResetParsingState(DCERPC *dcerpc) { +static inline void DCERPCResetParsingState(DCERPC *dcerpc) +{ dcerpc->bytesprocessed = 0; dcerpc->pdu_fragged = 0; dcerpc->dcerpcbindbindack.ctxbytesprocessed = 0; @@ -1430,7 +1443,8 @@ static inline void DCERPCResetParsingState(DCERPC *dcerpc) { return; } -static inline void DCERPCResetStub(DCERPC *dcerpc) { +static inline void DCERPCResetStub(DCERPC *dcerpc) +{ if (dcerpc->dcerpchdr.type == REQUEST) dcerpc->dcerpcrequest.stub_data_buffer_len = 0; else if (dcerpc->dcerpchdr.type == RESPONSE) @@ -1440,7 +1454,8 @@ static inline void DCERPCResetStub(DCERPC *dcerpc) { } static inline int DCERPCThrowOutExtraData(DCERPC *dcerpc, uint8_t *input, - uint16_t input_len) { + uint16_t input_len) +{ int parsed = 0; /* the function always assumes that * dcerpc->bytesprocessed < dcerpc->dcerpchdr.frag_length */ @@ -1463,7 +1478,8 @@ static inline int DCERPCThrowOutExtraData(DCERPC *dcerpc, uint8_t *input, * a condition where it has receives a segment with 2 pdus, while the * first pdu in the segment is corrupt. */ -int32_t DCERPCParser(DCERPC *dcerpc, uint8_t *input, uint32_t input_len) { +int32_t DCERPCParser(DCERPC *dcerpc, uint8_t *input, uint32_t input_len) +{ SCEnter(); uint32_t retval = 0; @@ -1893,7 +1909,8 @@ int32_t DCERPCParser(DCERPC *dcerpc, uint8_t *input, uint32_t input_len) { static int DCERPCParse(Flow *f, void *dcerpc_state, AppLayerParserState *pstate, uint8_t *input, uint32_t input_len, - void *local_data, int dir) { + void *local_data, int dir) +{ SCEnter(); int32_t retval = 0; @@ -1934,7 +1951,8 @@ static int DCERPCParseResponse(Flow *f, void *dcerpc_state, local_data, 1); } -static void *DCERPCStateAlloc(void) { +static void *DCERPCStateAlloc(void) +{ SCEnter(); DCERPCState *s = SCMalloc(sizeof(DCERPCState)); @@ -1948,7 +1966,8 @@ static void *DCERPCStateAlloc(void) { SCReturnPtr((void *)s, "void"); } -static void DCERPCStateFree(void *s) { +static void DCERPCStateFree(void *s) +{ DCERPCState *sstate = (DCERPCState *) s; DCERPCUuidEntry *item; @@ -1995,7 +2014,8 @@ static int DCERPCRegisterPatternsForProtocolDetection(void) return 0; } -void RegisterDCERPCParsers(void) { +void RegisterDCERPCParsers(void) +{ char *proto_name = "dcerpc"; if (AppLayerProtoDetectConfProtoDetectionEnabled("tcp", proto_name)) { @@ -2034,7 +2054,8 @@ void RegisterDCERPCParsers(void) { /* set this to 1 to see problem */ -int DCERPCParserTest01(void) { +int DCERPCParserTest01(void) +{ int result = 1; Flow f; uint8_t dcerpcbind[] = { @@ -2487,7 +2508,8 @@ end: /** \test DCERPC Request decoding and opnum parsing. */ -int DCERPCParserTest02(void) { +int DCERPCParserTest02(void) +{ int result = 1; Flow f; uint8_t dcerpcrequest[] = { @@ -2686,7 +2708,8 @@ end: /** \test Test endianness handling */ -int DCERPCParserTest03(void) { +int DCERPCParserTest03(void) +{ int result = 1; Flow f; uint8_t dcerpcrequest[] = { @@ -2879,7 +2902,8 @@ end: /** * \todo Needs to be rewritten */ -int DCERPCParserTest04(void) { +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 * as a part of dcerpc update/fixes */ @@ -4238,7 +4262,8 @@ end: /** * \test General test. */ -int DCERPCParserTest05(void) { +int DCERPCParserTest05(void) +{ int result = 1; Flow f; int r = 0; @@ -4339,7 +4364,8 @@ end: /** * \test DCERPC fragmented bind PDU(one PDU which is frag'ed) */ -int DCERPCParserTest06(void) { +int DCERPCParserTest06(void) +{ int result = 1; Flow f; int r = 0; @@ -4504,7 +4530,8 @@ end: /** * \test DCERPC fragmented bind PDU(one PDU which is frag'ed). */ -int DCERPCParserTest07(void) { +int DCERPCParserTest07(void) +{ int result = 1; Flow f; int r = 0; @@ -4605,7 +4632,8 @@ end: /** * \test DCERPC fragmented bind PDU(one PDU which is frag'ed). */ -int DCERPCParserTest08(void) { +int DCERPCParserTest08(void) +{ int result = 1; Flow f; int r = 0; @@ -4664,7 +4692,8 @@ end: /** * \test DCERPC fragmented bind PDU(one PDU which is frag'ed). */ -int DCERPCParserTest09(void) { +int DCERPCParserTest09(void) +{ int result = 1; Flow f; int r = 0; @@ -4723,7 +4752,8 @@ end: /** * \test DCERPC fragmented PDU. */ -int DCERPCParserTest10(void) { +int DCERPCParserTest10(void) +{ int result = 1; Flow f; int r = 0; @@ -4822,7 +4852,8 @@ end: /** * \test DCERPC fragmented PDU. */ -int DCERPCParserTest11(void) { +int DCERPCParserTest11(void) +{ int result = 1; Flow f; int r = 0; @@ -4926,7 +4957,8 @@ end: /** * \test DCERPC fragmented PDU. */ -int DCERPCParserTest12(void) { +int DCERPCParserTest12(void) +{ int result = 1; Flow f; int r = 0; @@ -5007,7 +5039,8 @@ end: * \test Check if the parser accepts bind pdus that have context ids starting * from a non-zero value. */ -int DCERPCParserTest13(void) { +int DCERPCParserTest13(void) +{ int result = 1; Flow f; int r = 0; @@ -5091,7 +5124,8 @@ end: /** * \test Check for another endless loop with bind pdus. */ -int DCERPCParserTest14(void) { +int DCERPCParserTest14(void) +{ int result = 1; Flow f; int r = 0; @@ -5156,7 +5190,8 @@ end: /** * \test Check for another endless loop for bind_ack pdus. */ -int DCERPCParserTest15(void) { +int DCERPCParserTest15(void) +{ int result = 1; Flow f; int r = 0; @@ -5217,7 +5252,8 @@ end: /** * \test Check for correct internal ids for bind_acks. */ -int DCERPCParserTest16(void) { +int DCERPCParserTest16(void) +{ int result = 1; Flow f; int r = 0; @@ -5815,7 +5851,8 @@ end: /** * \test Check for correct internal ids for bind_acks + alter_contexts */ -int DCERPCParserTest17(void) { +int DCERPCParserTest17(void) +{ int result = 1; Flow f; int r = 0; @@ -6007,7 +6044,8 @@ end: /** * \test DCERPC fragmented PDU. */ -int DCERPCParserTest18(void) { +int DCERPCParserTest18(void) +{ int result = 1; Flow f; int r = 0; @@ -6344,7 +6382,8 @@ end: #endif /* UNITTESTS */ -void DCERPCParserRegisterTests(void) { +void DCERPCParserRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("DCERPCParserTest01", DCERPCParserTest01, 1); UtRegisterTest("DCERPCParserTest02", DCERPCParserTest02, 1); diff --git a/src/app-layer-dns-common.c b/src/app-layer-dns-common.c index 164006ffc2..5f8e0be133 100644 --- a/src/app-layer-dns-common.c +++ b/src/app-layer-dns-common.c @@ -38,15 +38,18 @@ typedef struct DNSConfig_ { } DNSConfig; static DNSConfig dns_config; -void DNSConfigInit(void) { +void DNSConfigInit(void) +{ memset(&dns_config, 0x00, sizeof(dns_config)); } -void DNSConfigSetRequestFlood(uint32_t value) { +void DNSConfigSetRequestFlood(uint32_t value) +{ dns_config.request_flood = value; } -void DNSConfigSetStateMemcap(uint32_t value) { +void DNSConfigSetStateMemcap(uint32_t value) +{ dns_config.state_memcap = value; } @@ -54,7 +57,8 @@ SC_ATOMIC_DECLARE(uint64_t, dns_memuse); /**< byte counter of current memuse */ SC_ATOMIC_DECLARE(uint64_t, dns_memcap_state); /**< counts number of 'rejects' */ SC_ATOMIC_DECLARE(uint64_t, dns_memcap_global); /**< counts number of 'rejects' */ -void DNSConfigSetGlobalMemcap(uint64_t value) { +void DNSConfigSetGlobalMemcap(uint64_t value) +{ dns_config.global_memcap = value; SC_ATOMIC_INIT(dns_memuse); @@ -62,14 +66,16 @@ void DNSConfigSetGlobalMemcap(uint64_t value) { SC_ATOMIC_INIT(dns_memcap_global); } -void DNSIncrMemcap(uint32_t size, DNSState *state) { +void DNSIncrMemcap(uint32_t size, DNSState *state) +{ if (state != NULL) { state->memuse += size; } SC_ATOMIC_ADD(dns_memuse, size); } -void DNSDecrMemcap(uint32_t size, DNSState *state) { +void DNSDecrMemcap(uint32_t size, DNSState *state) +{ if (state != NULL) { BUG_ON(size > state->memuse); /**< TODO remove later */ state->memuse -= size; @@ -79,7 +85,8 @@ void DNSDecrMemcap(uint32_t size, DNSState *state) { (void)SC_ATOMIC_SUB(dns_memuse, size); } -int DNSCheckMemcap(uint32_t want, DNSState *state) { +int DNSCheckMemcap(uint32_t want, DNSState *state) +{ if (state != NULL) { if (state->memuse + want > dns_config.state_memcap) { SC_ATOMIC_ADD(dns_memcap_state, 1); @@ -139,7 +146,8 @@ void DNSAppLayerRegisterGetEventInfo(uint8_t ipproto, AppProto alproto) return; } -AppLayerDecoderEvents *DNSGetEvents(void *state, uint64_t id) { +AppLayerDecoderEvents *DNSGetEvents(void *state, uint64_t id) +{ DNSState *dns_state = (DNSState *)state; DNSTransaction *tx; @@ -154,12 +162,14 @@ AppLayerDecoderEvents *DNSGetEvents(void *state, uint64_t id) { return NULL; } -int DNSHasEvents(void *state) { +int DNSHasEvents(void *state) +{ DNSState *dns_state = (DNSState *)state; return (dns_state->events > 0); } -void *DNSGetTx(void *alstate, uint64_t tx_id) { +void *DNSGetTx(void *alstate, uint64_t tx_id) +{ DNSState *dns_state = (DNSState *)alstate; DNSTransaction *tx = NULL; @@ -178,12 +188,14 @@ void *DNSGetTx(void *alstate, uint64_t tx_id) { return NULL; } -uint64_t DNSGetTxCnt(void *alstate) { +uint64_t DNSGetTxCnt(void *alstate) +{ DNSState *dns_state = (DNSState *)alstate; return (uint64_t)dns_state->transaction_max; } -int DNSGetAlstateProgress(void *tx, uint8_t direction) { +int DNSGetAlstateProgress(void *tx, uint8_t direction) +{ DNSTransaction *dns_tx = (DNSTransaction *)tx; if (direction == 1) return dns_tx->replied|dns_tx->reply_lost; @@ -197,11 +209,13 @@ int DNSGetAlstateProgress(void *tx, uint8_t direction) { * * For DNS we use a simple bool. */ -int DNSGetAlstateProgressCompletionStatus(uint8_t direction) { +int DNSGetAlstateProgressCompletionStatus(uint8_t direction) +{ return 1; } -void DNSSetEvent(DNSState *s, uint8_t e) { +void DNSSetEvent(DNSState *s, uint8_t e) +{ if (s && s->curr) { SCLogDebug("s->curr->decoder_events %p", s->curr->decoder_events); AppLayerDecoderEventsSetEventRaw(&s->curr->decoder_events, e); @@ -215,7 +229,8 @@ void DNSSetEvent(DNSState *s, uint8_t e) { /** \internal * \brief Allocate a DNS TX * \retval tx or NULL */ -static DNSTransaction *DNSTransactionAlloc(DNSState *state, const uint16_t tx_id) { +static DNSTransaction *DNSTransactionAlloc(DNSState *state, const uint16_t tx_id) +{ if (DNSCheckMemcap(sizeof(DNSTransaction), state) < 0) return NULL; @@ -237,7 +252,8 @@ static DNSTransaction *DNSTransactionAlloc(DNSState *state, const uint16_t tx_id /** \internal * \brief Free a DNS TX * \param tx DNS TX to free */ -static void DNSTransactionFree(DNSTransaction *tx, DNSState *state) { +static void DNSTransactionFree(DNSTransaction *tx, DNSState *state) +{ SCEnter(); DNSQueryEntry *q = NULL; @@ -269,7 +285,8 @@ static void DNSTransactionFree(DNSTransaction *tx, DNSState *state) { /** * \brief dns transaction cleanup callback */ -void DNSStateTransactionFree(void *state, uint64_t tx_id) { +void DNSStateTransactionFree(void *state, uint64_t tx_id) +{ SCEnter(); DNSState *dns_state = state; @@ -305,7 +322,8 @@ void DNSStateTransactionFree(void *state, uint64_t tx_id) { * \brief Find the DNS Tx in the state * \param tx_id id of the tx * \retval tx or NULL if not found */ -DNSTransaction *DNSTransactionFindByTxId(const DNSState *dns_state, const uint16_t tx_id) { +DNSTransaction *DNSTransactionFindByTxId(const DNSState *dns_state, const uint16_t tx_id) +{ if (dns_state->curr == NULL) return NULL; @@ -326,7 +344,8 @@ DNSTransaction *DNSTransactionFindByTxId(const DNSState *dns_state, const uint16 return NULL; } -void *DNSStateAlloc(void) { +void *DNSStateAlloc(void) +{ void *s = SCMalloc(sizeof(DNSState)); if (unlikely(s == NULL)) return NULL; @@ -341,7 +360,8 @@ void *DNSStateAlloc(void) { return s; } -void DNSStateFree(void *s) { +void DNSStateFree(void *s) +{ SCEnter(); if (s) { DNSState *dns_state = (DNSState *) s; @@ -372,7 +392,8 @@ void DNSStateFree(void *s) { * \retval 0 ok * \retval -1 error */ -int DNSValidateRequestHeader(DNSState *dns_state, const DNSHeader *dns_header) { +int DNSValidateRequestHeader(DNSState *dns_state, const DNSHeader *dns_header) +{ uint16_t flags = ntohs(dns_header->flags); if ((flags & 0x8000) != 0) { @@ -399,7 +420,8 @@ bad_data: * \retval 0 ok * \retval -1 error */ -int DNSValidateResponseHeader(DNSState *dns_state, const DNSHeader *dns_header) { +int DNSValidateResponseHeader(DNSState *dns_state, const DNSHeader *dns_header) +{ uint16_t flags = ntohs(dns_header->flags); if ((flags & 0x8000) == 0) { @@ -424,7 +446,8 @@ bad_data: * \retval bool true or false */ static int QueryIsDuplicate(DNSTransaction *tx, const uint8_t *fqdn, const uint16_t fqdn_len, - const uint16_t type, const uint16_t class) { + const uint16_t type, const uint16_t class) +{ DNSQueryEntry *q = NULL; TAILQ_FOREACH(q, &tx->query_list, next) { @@ -960,7 +983,8 @@ insufficient_data: return NULL; } -void DNSCreateTypeString(uint16_t type, char *str, size_t str_size) { +void DNSCreateTypeString(uint16_t type, char *str, size_t str_size) +{ switch (type) { case DNS_RECORD_TYPE_A: snprintf(str, str_size, "A"); diff --git a/src/app-layer-dns-tcp.c b/src/app-layer-dns-tcp.c index cc6dec5b4d..6b46a5a1dc 100644 --- a/src/app-layer-dns-tcp.c +++ b/src/app-layer-dns-tcp.c @@ -148,7 +148,8 @@ bad_data: SCReturnInt(-1); } -static int BufferData(DNSState *dns_state, uint8_t *data, uint16_t len) { +static int BufferData(DNSState *dns_state, uint8_t *data, uint16_t len) +{ if (dns_state->buffer == NULL) { if (DNSCheckMemcap(0xffff, dns_state) < 0) return -1; @@ -175,12 +176,14 @@ static int BufferData(DNSState *dns_state, uint8_t *data, uint16_t len) { return 0; } -static void BufferReset(DNSState *dns_state) { +static void BufferReset(DNSState *dns_state) +{ dns_state->record_len = 0; dns_state->offset = 0; } -static int DNSRequestParseData(Flow *f, DNSState *dns_state, const uint8_t *input, const uint32_t input_len) { +static int DNSRequestParseData(Flow *f, DNSState *dns_state, const uint8_t *input, const uint32_t input_len) +{ DNSHeader *dns_header = (DNSHeader *)input; if (DNSValidateRequestHeader(dns_state, dns_header) < 0) @@ -355,7 +358,8 @@ bad_data: SCReturnInt(-1); } -static int DNSReponseParseData(Flow *f, DNSState *dns_state, const uint8_t *input, const uint32_t input_len) { +static int DNSReponseParseData(Flow *f, DNSState *dns_state, const uint8_t *input, const uint32_t input_len) +{ DNSHeader *dns_header = (DNSHeader *)input; if (DNSValidateResponseHeader(dns_state, dns_header) < 0) @@ -590,7 +594,8 @@ static uint16_t DNSTcpProbingParser(uint8_t *input, uint32_t ilen, uint32_t *off return ALPROTO_DNS; } -void RegisterDNSTCPParsers(void) { +void RegisterDNSTCPParsers(void) +{ char *proto_name = "dns"; /** DNS */ @@ -655,7 +660,8 @@ void RegisterDNSTCPParsers(void) { /* UNITTESTS */ #ifdef UNITTESTS -void DNSTCPParserRegisterTests(void) { +void DNSTCPParserRegisterTests(void) +{ // UtRegisterTest("DNSTCPParserTest01", DNSTCPParserTest01, 1); } #endif diff --git a/src/app-layer-dns-udp.c b/src/app-layer-dns-udp.c index 84e5c1480c..feeb7de1c7 100644 --- a/src/app-layer-dns-udp.c +++ b/src/app-layer-dns-udp.c @@ -307,7 +307,8 @@ static uint16_t DNSUdpProbingParser(uint8_t *input, uint32_t ilen, uint32_t *off return ALPROTO_DNS; } -static void DNSUDPConfigure(void) { +static void DNSUDPConfigure(void) +{ uint32_t request_flood = DNS_CONFIG_DEFAULT_REQUEST_FLOOD; uint32_t state_memcap = DNS_CONFIG_DEFAULT_STATE_MEMCAP; uint64_t global_memcap = DNS_CONFIG_DEFAULT_GLOBAL_MEMCAP; @@ -349,7 +350,8 @@ static void DNSUDPConfigure(void) { DNSConfigSetGlobalMemcap(global_memcap); } -void RegisterDNSUDPParsers(void) { +void RegisterDNSUDPParsers(void) +{ char *proto_name = "dns"; /** DNS */ @@ -422,7 +424,8 @@ void RegisterDNSUDPParsers(void) { #ifdef UNITTESTS #include "util-unittest-helper.h" -static int DNSUDPParserTest01 (void) { +static int DNSUDPParserTest01 (void) +{ int result = 0; /* query: abcdefghijk.com * TTL: 86400 @@ -459,7 +462,8 @@ end: return (result); } -static int DNSUDPParserTest02 (void) { +static int DNSUDPParserTest02 (void) +{ int result = 0; uint8_t buf[] = { 0x6D,0x08,0x84,0x80,0x00,0x01,0x00,0x08,0x00,0x00,0x00,0x01,0x03,0x57,0x57,0x57, @@ -493,7 +497,8 @@ end: return (result); } -static int DNSUDPParserTest03 (void) { +static int DNSUDPParserTest03 (void) +{ int result = 0; uint8_t buf[] = { 0x6F,0xB4,0x84,0x80,0x00,0x01,0x00,0x02,0x00,0x02,0x00,0x03,0x03,0x57,0x57,0x77, @@ -528,7 +533,8 @@ end: } /** \test TXT records in answer */ -static int DNSUDPParserTest04 (void) { +static int DNSUDPParserTest04 (void) +{ int result = 0; uint8_t buf[] = { 0xc2,0x2f,0x81,0x80,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x0a,0x41,0x41,0x41, @@ -565,7 +571,8 @@ end: } /** \test TXT records in answer, bad txtlen */ -static int DNSUDPParserTest05 (void) { +static int DNSUDPParserTest05 (void) +{ int result = 0; uint8_t buf[] = { 0xc2,0x2f,0x81,0x80,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x0a,0x41,0x41,0x41, @@ -602,7 +609,8 @@ end: } -void DNSUDPParserRegisterTests(void) { +void DNSUDPParserRegisterTests(void) +{ UtRegisterTest("DNSUDPParserTest01", DNSUDPParserTest01, 1); UtRegisterTest("DNSUDPParserTest02", DNSUDPParserTest02, 1); UtRegisterTest("DNSUDPParserTest03", DNSUDPParserTest03, 1); diff --git a/src/app-layer-ftp.c b/src/app-layer-ftp.c index 3e1cf30566..b4a4d6f8e8 100644 --- a/src/app-layer-ftp.c +++ b/src/app-layer-ftp.c @@ -180,7 +180,8 @@ static int FTPGetLine(FtpState *state) * \retval 1 when the command is parsed, 0 otherwise */ static int FTPParseRequestCommand(void *ftp_state, uint8_t *input, - uint32_t input_len) { + uint32_t input_len) +{ SCEnter(); FtpState *fstate = (FtpState *)ftp_state; fstate->command = FTP_COMMAND_UNKNOWN; @@ -270,7 +271,8 @@ static uint64_t ftp_state_memuse = 0; static uint64_t ftp_state_memcnt = 0; #endif -static void *FTPStateAlloc(void) { +static void *FTPStateAlloc(void) +{ void *s = SCMalloc(sizeof(FtpState)); if (unlikely(s == NULL)) return NULL; @@ -286,7 +288,8 @@ static void *FTPStateAlloc(void) { return s; } -static void FTPStateFree(void *s) { +static void FTPStateFree(void *s) +{ FtpState *fstate = (FtpState *) s; if (fstate->port_line != NULL) SCFree(fstate->port_line); @@ -324,7 +327,8 @@ static int FTPRegisterPatternsForProtocolDetection(void) return 0; } -void RegisterFTPParsers(void) { +void RegisterFTPParsers(void) +{ char *proto_name = "ftp"; /** FTP */ @@ -350,7 +354,8 @@ void RegisterFTPParsers(void) { #endif } -void FTPAtExitPrintStats(void) { +void FTPAtExitPrintStats(void) +{ #ifdef DEBUG SCMutexLock(&ftp_state_mem_lock); SCLogDebug("ftp_state_memcnt %"PRIu64", ftp_state_memuse %"PRIu64"", @@ -363,7 +368,8 @@ void FTPAtExitPrintStats(void) { #ifdef UNITTESTS /** \test Send a get request in one chunk. */ -int FTPParserTest01(void) { +int FTPParserTest01(void) +{ int result = 1; Flow f; uint8_t ftpbuf[] = "PORT 192,168,1,1,0,80\r\n"; @@ -412,7 +418,8 @@ end: } /** \test Send a splitted get request. */ -int FTPParserTest03(void) { +int FTPParserTest03(void) +{ int result = 1; Flow f; uint8_t ftpbuf1[] = "POR"; @@ -482,7 +489,8 @@ end: } /** \test See how it deals with an incomplete request. */ -int FTPParserTest06(void) { +int FTPParserTest06(void) +{ int result = 1; Flow f; uint8_t ftpbuf1[] = "PORT"; @@ -531,7 +539,8 @@ end: } /** \test See how it deals with an incomplete request in multiple chunks. */ -int FTPParserTest07(void) { +int FTPParserTest07(void) +{ int result = 1; Flow f; uint8_t ftpbuf1[] = "PO"; @@ -594,7 +603,8 @@ 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) { +int FTPParserTest10(void) +{ int result = 1; Flow f; uint8_t ftpbuf1[] = "PORT 1,2,3,4,5,6\r\n"; @@ -652,7 +662,8 @@ end: } #endif /* UNITTESTS */ -void FTPParserRegisterTests(void) { +void FTPParserRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("FTPParserTest01", FTPParserTest01, 1); UtRegisterTest("FTPParserTest03", FTPParserTest03, 1); diff --git a/src/app-layer-htp-file.c b/src/app-layer-htp-file.c index 7c70689a58..d8659f338e 100644 --- a/src/app-layer-htp-file.c +++ b/src/app-layer-htp-file.c @@ -292,7 +292,8 @@ end: } #ifdef UNITTESTS -static int HTPFileParserTest01(void) { +static int HTPFileParserTest01(void) +{ int result = 0; Flow *f = NULL; uint8_t httpbuf1[] = "POST /upload.cgi HTTP/1.1\r\n" @@ -374,7 +375,8 @@ end: return result; } -static int HTPFileParserTest02(void) { +static int HTPFileParserTest02(void) +{ int result = 0; Flow *f = NULL; uint8_t httpbuf1[] = "POST /upload.cgi HTTP/1.1\r\n" @@ -492,7 +494,8 @@ end: return result; } -static int HTPFileParserTest03(void) { +static int HTPFileParserTest03(void) +{ int result = 0; Flow *f = NULL; uint8_t httpbuf1[] = "POST /upload.cgi HTTP/1.1\r\n" @@ -642,7 +645,8 @@ end: return result; } -static int HTPFileParserTest04(void) { +static int HTPFileParserTest04(void) +{ int result = 0; Flow *f = NULL; uint8_t httpbuf1[] = "POST /upload.cgi HTTP/1.1\r\n" @@ -787,7 +791,8 @@ end: return result; } -static int HTPFileParserTest05(void) { +static int HTPFileParserTest05(void) +{ int result = 0; Flow *f = NULL; uint8_t httpbuf1[] = "POST /upload.cgi HTTP/1.1\r\n" @@ -911,7 +916,8 @@ end: } /** \test first multipart part contains file but doesn't end in first chunk */ -static int HTPFileParserTest06(void) { +static int HTPFileParserTest06(void) +{ int result = 0; Flow *f = NULL; uint8_t httpbuf1[] = "POST /upload.cgi HTTP/1.1\r\n" @@ -1035,7 +1041,8 @@ end: } /** \test POST, but not multipart */ -static int HTPFileParserTest07(void) { +static int HTPFileParserTest07(void) +{ int result = 0; Flow *f = NULL; uint8_t httpbuf1[] = "POST /filename HTTP/1.1\r\n" @@ -1130,7 +1137,8 @@ end: return result; } -static int HTPFileParserTest08(void) { +static int HTPFileParserTest08(void) +{ int result = 0; Flow *f = NULL; uint8_t httpbuf1[] = "POST /upload.cgi HTTP/1.1\r\n" @@ -1215,7 +1223,8 @@ end: } /** \test invalid header: Somereallylongheaderstr: has no value */ -static int HTPFileParserTest09(void) { +static int HTPFileParserTest09(void) +{ int result = 0; Flow *f = NULL; uint8_t httpbuf1[] = "POST /upload.cgi HTTP/1.1\r\n" @@ -1332,7 +1341,8 @@ end: } /** \test empty entries */ -static int HTPFileParserTest10(void) { +static int HTPFileParserTest10(void) +{ int result = 0; Flow *f = NULL; uint8_t httpbuf1[] = "POST /upload.cgi HTTP/1.1\r\n" @@ -1442,7 +1452,8 @@ end: } /** \test filedata cut in two pieces */ -static int HTPFileParserTest11(void) { +static int HTPFileParserTest11(void) +{ int result = 0; Flow *f = NULL; uint8_t httpbuf1[] = "POST /upload.cgi HTTP/1.1\r\n" @@ -1606,7 +1617,8 @@ end: #endif /* UNITTESTS */ -void HTPFileParserRegisterTests(void) { +void HTPFileParserRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("HTPFileParserTest01", HTPFileParserTest01, 1); UtRegisterTest("HTPFileParserTest02", HTPFileParserTest02, 1); diff --git a/src/app-layer-htp.c b/src/app-layer-htp.c index e18795b804..7514b374e3 100644 --- a/src/app-layer-htp.c +++ b/src/app-layer-htp.c @@ -251,7 +251,8 @@ void HTPSetEvent(HtpState *s, HtpTxUserData *htud, uint8_t e) SCLogDebug("couldn't set event %u", e); } -static int HTPHasEvents(void *state) { +static int HTPHasEvents(void *state) +{ HtpState *htp_state = (HtpState *)state; return (htp_state->events > 0); } @@ -303,7 +304,8 @@ error: SCReturnPtr(NULL, "void"); } -static void HtpTxUserDataFree(HtpTxUserData *htud) { +static void HtpTxUserDataFree(HtpTxUserData *htud) +{ if (htud) { HtpBodyFree(&htud->request_body); HtpBodyFree(&htud->response_body); @@ -377,7 +379,8 @@ void HTPStateFree(void *state) * \warning We cannot actually free the transactions here. It seems that * HTP only accepts freeing of transactions in the response callback. */ -static void HTPStateTransactionFree(void *state, uint64_t id) { +static void HTPStateTransactionFree(void *state, uint64_t id) +{ SCEnter(); HtpState *s = (HtpState *)state; @@ -429,7 +432,8 @@ void AppLayerHtpEnableResponseBodyCallback(void) * * \initonly */ -void AppLayerHtpNeedMultipartHeader(void) { +void AppLayerHtpNeedMultipartHeader(void) +{ SCEnter(); AppLayerHtpEnableRequestBodyCallback(); @@ -507,7 +511,8 @@ struct { * * \retval id the id or 0 in case of not found */ -static int HTPHandleWarningGetId(const char *msg) { +static int HTPHandleWarningGetId(const char *msg) +{ SCLogDebug("received warning \"%s\"", msg); size_t idx; for (idx = 0; idx < HTP_WARNING_MAX; idx++) { @@ -530,7 +535,8 @@ static int HTPHandleWarningGetId(const char *msg) { * * \retval id the id or 0 in case of not found */ -static int HTPHandleErrorGetId(const char *msg) { +static int HTPHandleErrorGetId(const char *msg) +{ SCLogDebug("received error \"%s\"", msg); size_t idx; @@ -552,7 +558,8 @@ static int HTPHandleErrorGetId(const char *msg) { * * \param s state */ -static void HTPHandleError(HtpState *s) { +static void HTPHandleError(HtpState *s) +{ if (s == NULL || s->conn == NULL || s->conn->messages == NULL) { return; @@ -1008,7 +1015,8 @@ static int HTTPParseContentTypeHeader(uint8_t *name, size_t name_len, * If the request contains a multipart message, this function will * set the HTP_BOUNDARY_SET in the transaction. */ -static int HtpRequestBodySetupMultipart(htp_tx_data_t *d, HtpTxUserData *htud) { +static int HtpRequestBodySetupMultipart(htp_tx_data_t *d, HtpTxUserData *htud) +{ htp_header_t *cl = htp_table_get_c(d->tx->request_headers, "content-length"); if (cl != NULL) htud->request_body.content_len = SC_htp_parse_content_length(cl->value); @@ -1531,7 +1539,8 @@ end: /** \brief setup things for put request * \todo really needed? */ -int HtpRequestBodySetupPUT(htp_tx_data_t *d, HtpTxUserData *htud) { +int HtpRequestBodySetupPUT(htp_tx_data_t *d, HtpTxUserData *htud) +{ // if (d->tx->parsed_uri == NULL || d->tx->parsed_uri->path == NULL) { // return -1; // } @@ -1955,7 +1964,8 @@ void HTPFreeConfig(void) * \param connp pointer to the current connection parser which has the htp * state in it as user data */ -static int HTPCallbackRequest(htp_tx_t *tx) { +static int HTPCallbackRequest(htp_tx_t *tx) +{ SCEnter(); if (tx == NULL) { @@ -1995,7 +2005,8 @@ static int HTPCallbackRequest(htp_tx_t *tx) { * \param connp pointer to the current connection parser which has the htp * state in it as user data */ -static int HTPCallbackResponse(htp_tx_t *tx) { +static int HTPCallbackResponse(htp_tx_t *tx) +{ SCEnter(); HtpState *hstate = htp_connp_get_user_data(tx->connp); @@ -2535,7 +2546,8 @@ void HTPConfigure(void) SCReturn; } -void AppLayerHtpPrintStats(void) { +void AppLayerHtpPrintStats(void) +{ #ifdef DEBUG SCMutexLock(&htp_state_mem_lock); SCLogInfo("htp memory %"PRIu64" (%"PRIu64")", htp_state_memuse, htp_state_memcnt); @@ -2549,7 +2561,8 @@ void AppLayerHtpPrintStats(void) { * \param direction flow direction * \retval files files ptr */ -static FileContainer *HTPStateGetFiles(void *state, uint8_t direction) { +static FileContainer *HTPStateGetFiles(void *state, uint8_t direction) +{ if (state == NULL) return NULL; @@ -2786,7 +2799,8 @@ 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) { +int HTPParserTest01(void) +{ int result = 1; Flow *f = NULL; uint8_t httpbuf1[] = "POST / HTTP/1.0\r\nUser-Agent: Victor/1.0\r\n\r\nPost" @@ -2863,7 +2877,8 @@ end: } /** \test See how it deals with an incomplete request. */ -int HTPParserTest02(void) { +int HTPParserTest02(void) +{ int result = 1; Flow *f = NULL; uint8_t httpbuf1[] = "POST"; @@ -2921,7 +2936,8 @@ 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) { +int HTPParserTest03(void) +{ int result = 1; Flow *f = NULL; uint8_t httpbuf1[] = "HELLO / HTTP/1.0\r\n"; @@ -2993,7 +3009,8 @@ end: /** \test Test case where invalid data is sent and check the response of the * parser from HTP library. */ -int HTPParserTest04(void) { +int HTPParserTest04(void) +{ int result = 1; Flow *f = NULL; HtpState *htp_state = NULL; @@ -3053,7 +3070,8 @@ 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) { +int HTPParserTest05(void) +{ int result = 1; Flow *f = NULL; HtpState *http_state = NULL; @@ -3176,7 +3194,8 @@ end: /** \test Test proper chunked encoded response body */ -int HTPParserTest06(void) { +int HTPParserTest06(void) +{ int result = 1; Flow *f = NULL; uint8_t httpbuf1[] = "GET /ld/index.php?id=412784631&cid=0064&version=4&" @@ -3296,7 +3315,8 @@ end: /** \test */ -int HTPParserTest07(void) { +int HTPParserTest07(void) +{ int result = 0; Flow *f = NULL; uint8_t httpbuf1[] = "GET /awstats.pl?/migratemigrate%20=%20| HTTP/1.0\r\n\r\n"; @@ -3386,7 +3406,8 @@ end: /** \test Abort */ -int HTPParserTest08(void) { +int HTPParserTest08(void) +{ int result = 0; Flow *f = NULL; uint8_t httpbuf1[] = "GET /secondhouse/image/js/\%ce\%de\%ce\%fd_RentCity.js?v=2011.05.02 HTTP/1.0\r\n\r\n"; @@ -3471,7 +3492,8 @@ end: /** \test Abort */ -int HTPParserTest09(void) { +int HTPParserTest09(void) +{ int result = 0; Flow *f = NULL; uint8_t httpbuf1[] = "GET /secondhouse/image/js/\%ce\%de\%ce\%fd_RentCity.js?v=2011.05.02 HTTP/1.0\r\n\r\n"; @@ -3557,7 +3579,8 @@ end: /** \test Host:www.google.com <- missing space between name:value (rfc violation) */ -int HTPParserTest10(void) { +int HTPParserTest10(void) +{ int result = 0; Flow *f = NULL; uint8_t httpbuf1[] = "GET / HTTP/1.0\r\nHost:www.google.com\r\n\r\n"; @@ -3648,7 +3671,8 @@ end: /** \test double encoding in path */ -static int HTPParserTest11(void) { +static int HTPParserTest11(void) +{ int result = 0; Flow *f = NULL; uint8_t httpbuf1[] = "GET /%2500 HTTP/1.0\r\n\r\n"; @@ -3732,7 +3756,8 @@ end: /** \test double encoding in query */ -static int HTPParserTest12(void) { +static int HTPParserTest12(void) +{ int result = 0; Flow *f = NULL; uint8_t httpbuf1[] = "GET /?a=%2500 HTTP/1.0\r\n\r\n"; @@ -3819,7 +3844,8 @@ static int HTPParserTest12(void) { /** \test Host:www.google.com0dName: Value0d0a <- missing space between name:value (rfc violation) */ -int HTPParserTest13(void) { +int HTPParserTest13(void) +{ int result = 0; Flow *f = NULL; uint8_t httpbuf1[] = "GET / HTTP/1.0\r\nHost:www.google.com\rName: Value\r\n\r\n"; @@ -5598,7 +5624,8 @@ end: } /** \test BG crash */ -static int HTPSegvTest01(void) { +static int HTPSegvTest01(void) +{ int result = 0; Flow *f = NULL; uint8_t httpbuf1[] = "POST /uri HTTP/1.1\r\nHost: hostname.com\r\nKeep-Alive: 115\r\nAccept-Charset: utf-8\r\nUser-Agent: Mozilla/5.0 (X11; Linux i686; rv:9.0.1) Gecko/20100101 Firefox/9.0.1\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nConnection: keep-alive\r\nContent-length: 68102\r\nReferer: http://otherhost.com\r\nAccept-Encoding: gzip\r\nContent-Type: multipart/form-data; boundary=e5a320f21416a02493a0a6f561b1c494\r\nCookie: blah\r\nAccept-Language: us\r\n\r\n--e5a320f21416a02493a0a6f561b1c494\r\nContent-Disposition: form-data; name=\"uploadfile\"; filename=\"D2GUef.jpg\"\r"; @@ -5688,7 +5715,8 @@ end: } /** \test Test really long request, this should result in HTTP_DECODER_EVENT_REQUEST_FIELD_TOO_LONG */ -int HTPParserTest14(void) { +int HTPParserTest14(void) +{ int result = 0; Flow *f = NULL; char *httpbuf = NULL; @@ -5830,7 +5858,8 @@ end: /** \test Test really long request (same as HTPParserTest14), now with config * update to allow it */ -int HTPParserTest15(void) { +int HTPParserTest15(void) +{ int result = 0; Flow *f = NULL; char *httpbuf = NULL; @@ -5956,7 +5985,8 @@ end: /** * \brief Register the Unit tests for the HTTP protocol */ -void HTPParserRegisterTests(void) { +void HTPParserRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("HTPParserTest01", HTPParserTest01, 1); UtRegisterTest("HTPParserTest02", HTPParserTest02, 1); diff --git a/src/app-layer-parser.c b/src/app-layer-parser.c index daa54bc514..e665cceed6 100644 --- a/src/app-layer-parser.c +++ b/src/app-layer-parser.c @@ -610,7 +610,8 @@ FileContainer *AppLayerParserGetFiles(uint8_t ipproto, AppProto alproto, /** \brief active TX retrieval for normal ops: so with detection and logging * * \retval tx_id lowest tx_id that still needs work */ -uint64_t AppLayerTransactionGetActiveDetectLog(Flow *f, uint8_t flags) { +uint64_t AppLayerTransactionGetActiveDetectLog(Flow *f, uint8_t flags) +{ AppLayerParserProtoCtx *p = &alp_ctx.ctxs[FlowGetProtoMapping(f->proto)][f->alproto]; uint64_t log_id = f->alparser->log_id; uint64_t inspect_id = f->alparser->inspect_id[flags & STREAM_TOSERVER ? 0 : 1]; @@ -629,7 +630,8 @@ uint64_t AppLayerTransactionGetActiveDetectLog(Flow *f, uint8_t flags) { * in running this function in that case though. With no detection * and no logging, why run a parser in the first place? **/ -uint64_t AppLayerTransactionGetActiveLogOnly(Flow *f, uint8_t flags) { +uint64_t AppLayerTransactionGetActiveLogOnly(Flow *f, uint8_t flags) +{ AppLayerParserProtoCtx *p = &alp_ctx.ctxs[f->protomap][f->alproto]; if (p->logger == TRUE) { @@ -660,7 +662,8 @@ uint64_t AppLayerTransactionGetActiveLogOnly(Flow *f, uint8_t flags) { return idx; } -void RegisterAppLayerGetActiveTxIdFunc(GetActiveTxIdFunc FuncPtr) { +void RegisterAppLayerGetActiveTxIdFunc(GetActiveTxIdFunc FuncPtr) +{ //BUG_ON(AppLayerGetActiveTxIdFuncPtr != NULL); AppLayerGetActiveTxIdFuncPtr = FuncPtr; SCLogDebug("AppLayerGetActiveTxIdFuncPtr is now %p", AppLayerGetActiveTxIdFuncPtr); @@ -671,7 +674,8 @@ void RegisterAppLayerGetActiveTxIdFunc(GetActiveTxIdFunc FuncPtr) { * * \retval id tx id */ -static uint64_t AppLayerTransactionGetActive(Flow *f, uint8_t flags) { +static uint64_t AppLayerTransactionGetActive(Flow *f, uint8_t flags) +{ BUG_ON(AppLayerGetActiveTxIdFuncPtr == NULL); return AppLayerGetActiveTxIdFuncPtr(f, flags); diff --git a/src/app-layer-smb.c b/src/app-layer-smb.c index c5818ae544..b7ae55d3d1 100644 --- a/src/app-layer-smb.c +++ b/src/app-layer-smb.c @@ -1393,7 +1393,8 @@ static int SMBParseResponse(Flow *f, void *smb_state, AppLayerParserState *pstat * \retval 0 if smb command is not an AndX command */ -int isAndX(SMBState *smb_state) { +int isAndX(SMBState *smb_state) +{ SCEnter(); switch (smb_state->smb.command) { @@ -1417,7 +1418,8 @@ int isAndX(SMBState *smb_state) { * \brief Allocate a SMBState * \retval s State, or NULL in case of error */ -static void *SMBStateAlloc(void) { +static void *SMBStateAlloc(void) +{ SCEnter(); void *s = SCMalloc(sizeof(SMBState)); @@ -1433,7 +1435,8 @@ static void *SMBStateAlloc(void) { /** \internal * \brief Free a SMBState */ -static void SMBStateFree(void *s) { +static void SMBStateFree(void *s) +{ SCEnter(); SMBState *sstate = (SMBState *) s; @@ -1519,7 +1522,8 @@ static int SMBRegisterPatternsForProtocolDetection(void) return 0; } -void RegisterSMBParsers(void) { +void RegisterSMBParsers(void) +{ char *proto_name = "smb"; if (AppLayerProtoDetectConfProtoDetectionEnabled("tcp", proto_name)) { @@ -1569,7 +1573,8 @@ void RegisterSMBParsers(void) { /** * \test SMBParserTest01 tests the NBSS and SMB header decoding */ -int SMBParserTest01(void) { +int SMBParserTest01(void) +{ int result = 0; Flow f; uint8_t smbbuf[] = "\x00\x00\x00\x85" // NBSS @@ -1637,7 +1642,8 @@ end: /** * \test SMBParserTest02 tests the NBSS, SMB, and DCERPC over SMB header decoding */ -int SMBParserTest02(void) { +int SMBParserTest02(void) +{ int result = 0; Flow f; uint8_t smbbuf[] = { @@ -1711,7 +1717,8 @@ end: return result; } -int SMBParserTest03(void) { +int SMBParserTest03(void) +{ int result = 0; Flow f; uint8_t smbbuf1[] = { @@ -2012,7 +2019,8 @@ end: return result; } -int SMBParserTest04(void) { +int SMBParserTest04(void) +{ int result = 0; Flow f; uint8_t smbbuf1[] = { @@ -2319,7 +2327,8 @@ int SMBParserTest06(void) return result; } -int SMBParserTest07(void) { +int SMBParserTest07(void) +{ int result = 0; Flow f; uint8_t smbbuf1[] = { @@ -2376,7 +2385,8 @@ end: return result; } -int SMBParserTest08(void) { +int SMBParserTest08(void) +{ int result = 0; Flow f; uint8_t smbbuf1[] = { @@ -2475,7 +2485,8 @@ end: return result; } -int SMBParserTest09(void) { +int SMBParserTest09(void) +{ int result = 0; Flow f; uint8_t smbbuf1[] = { @@ -2684,7 +2695,8 @@ end: #endif -void SMBParserRegisterTests(void) { +void SMBParserRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("SMBParserTest01", SMBParserTest01, 1); UtRegisterTest("SMBParserTest02", SMBParserTest02, 1); diff --git a/src/app-layer-smb2.c b/src/app-layer-smb2.c index bc26a455b2..6a49bd751c 100644 --- a/src/app-layer-smb2.c +++ b/src/app-layer-smb2.c @@ -570,7 +570,8 @@ static int SMB2Parse(Flow *f, void *smb2_state, AppLayerParserState *pstate, } -static void *SMB2StateAlloc(void) { +static void *SMB2StateAlloc(void) +{ void *s = SCMalloc(sizeof(SMB2State)); if (unlikely(s == NULL)) return NULL; @@ -579,14 +580,16 @@ static void *SMB2StateAlloc(void) { return s; } -static void SMB2StateFree(void *s) { +static void SMB2StateFree(void *s) +{ if (s) { SCFree(s); s = NULL; } } -void RegisterSMB2Parsers(void) { +void RegisterSMB2Parsers(void) +{ /** SMB2 */ char *proto_name = "smb2"; @@ -608,7 +611,8 @@ void RegisterSMB2Parsers(void) { /* UNITTESTS */ #ifdef UNITTESTS -int SMB2ParserTest01(void) { +int SMB2ParserTest01(void) +{ int result = 1; Flow f; uint8_t smb2buf[] = @@ -672,7 +676,8 @@ end: return result; } -void SMB2ParserRegisterTests(void) { +void SMB2ParserRegisterTests(void) +{ UtRegisterTest("SMB2ParserTest01", SMB2ParserTest01, 1); } #endif diff --git a/src/app-layer-ssh.c b/src/app-layer-ssh.c index 5c1106d4ba..3e417e2abc 100644 --- a/src/app-layer-ssh.c +++ b/src/app-layer-ssh.c @@ -525,7 +525,8 @@ void RegisterSSHParsers(void) #ifdef UNITTESTS /** \test Send a version string in one chunk (client version str). */ -static int SSHParserTest01(void) { +static int SSHParserTest01(void) +{ int result = 0; Flow f; uint8_t sshbuf[] = "SSH-2.0-MySSHClient-0.5.1\n"; @@ -590,7 +591,8 @@ end: /** \test Send a version string in one chunk but multiple lines and comments. * (client version str) */ -static int SSHParserTest02(void) { +static int SSHParserTest02(void) +{ int result = 0; Flow f; uint8_t sshbuf[] = "SSH-2.0-MySSHClient-0.5.1 some comments...\n"; @@ -655,7 +657,8 @@ end: /** \test Send a invalid version string in one chunk but multiple lines and comments. * (client version str) */ -static int SSHParserTest03(void) { +static int SSHParserTest03(void) +{ int result = 0; Flow f; uint8_t sshbuf[] = "SSH-2.0 some comments...\n"; @@ -706,7 +709,8 @@ end: } /** \test Send a version string in one chunk (server version str). */ -static int SSHParserTest04(void) { +static int SSHParserTest04(void) +{ int result = 0; Flow f; uint8_t sshbuf[] = "SSH-2.0-MySSHClient-0.5.1\n"; @@ -771,7 +775,8 @@ end: /** \test Send a version string in one chunk (server version str) */ -static int SSHParserTest05(void) { +static int SSHParserTest05(void) +{ int result = 0; Flow f; uint8_t sshbuf[] = "SSH-2.0-MySSHClient-0.5.1 some comments...\n"; @@ -835,7 +840,8 @@ end: /** \test Send a invalid version string in one chunk (server version str) */ -static int SSHParserTest06(void) { +static int SSHParserTest06(void) +{ int result = 0; Flow f; uint8_t sshbuf[] = "SSH-2.0 some comments...\n"; @@ -886,7 +892,8 @@ end: return result; } -static int SSHParserTest07(void) { +static int SSHParserTest07(void) +{ int result = 0; Flow f; uint8_t sshbuf1[] = "SSH-2."; @@ -961,7 +968,8 @@ end: } /** \test Send a version banner in three chunks. */ -static int SSHParserTest08(void) { +static int SSHParserTest08(void) +{ int result = 0; Flow f; uint8_t sshbuf1[] = "SSH-"; @@ -1045,7 +1053,8 @@ end: return result; } -static int SSHParserTest09(void) { +static int SSHParserTest09(void) +{ int result = 0; Flow f; uint8_t sshbuf1[] = "SSH-2."; @@ -1120,7 +1129,8 @@ end: } /** \test Send a version banner in three chunks. */ -static int SSHParserTest10(void) { +static int SSHParserTest10(void) +{ int result = 0; Flow f; uint8_t sshbuf1[] = "SSH-"; @@ -1205,7 +1215,8 @@ end: } /** \test Send a banner and record in three chunks. */ -static int SSHParserTest11(void) { +static int SSHParserTest11(void) +{ int result = 0; Flow f; uint8_t sshbuf1[] = "SSH-2.0-MySSHClient-0.5.1\r\n"; @@ -1284,7 +1295,8 @@ end: } /** \test Send a banner and 2 records record in four chunks. */ -static int SSHParserTest12(void) { +static int SSHParserTest12(void) +{ int result = 0; Flow f; uint8_t sshbuf1[] = "SSH-2.0-MySSHClient-0.5.1\r\n"; @@ -1374,7 +1386,8 @@ end: } /** \test Send a banner and 2 records record in four chunks. */ -static int SSHParserTest13(void) { +static int SSHParserTest13(void) +{ int result = 0; Flow f; uint8_t sshbuf1[] = "SSH-2.0-MySSHClient-0.5.1\r\n"; @@ -1466,7 +1479,8 @@ end: } /** \test Send a banner and 2 records record in four chunks. */ -static int SSHParserTest14(void) { +static int SSHParserTest14(void) +{ int result = 0; Flow f; uint8_t sshbuf1[] = "SSH-2.0-MySSHClient-0.5.1\r\n"; @@ -1577,7 +1591,8 @@ end: } /** \test Send a banner and 2 records record in four chunks. */ -static int SSHParserTest15(void) { +static int SSHParserTest15(void) +{ int result = 0; Flow f; uint8_t sshbuf1[] = "SSH-2.0-MySSHClient-0.5.1\r\n"; @@ -1688,7 +1703,8 @@ end: } /** \test Send toserver a banner and record in three chunks. */ -static int SSHParserTest16(void) { +static int SSHParserTest16(void) +{ int result = 0; Flow f; uint8_t sshbuf1[] = "SSH-"; @@ -1778,7 +1794,8 @@ end: } /** \test Send toserver a banner and 2 records record in four chunks. */ -static int SSHParserTest17(void) { +static int SSHParserTest17(void) +{ int result = 0; Flow f; uint8_t sshbuf1[] = "SSH-"; @@ -1879,7 +1896,8 @@ end: } /** \test 2 directional test */ -static int SSHParserTest18(void) { +static int SSHParserTest18(void) +{ int result = 0; Flow f; @@ -1982,7 +2000,8 @@ end: } /** \test Really long banner handling: bannel exactly 255 */ -static int SSHParserTest19(void) { +static int SSHParserTest19(void) +{ int result = 0; Flow f; uint8_t sshbuf1[] = "SSH-"; @@ -2100,7 +2119,8 @@ end: /** \test Really long banner handling: banner exactly 255, * followed by malformed record */ -static int SSHParserTest20(void) { +static int SSHParserTest20(void) +{ int result = 0; Flow f; uint8_t sshbuf1[] = "SSH-"; @@ -2208,7 +2228,8 @@ end: /** \test Fragmented banner handling: chunk has final part of bannel plus * a record. */ -static int SSHParserTest21(void) { +static int SSHParserTest21(void) +{ int result = 0; Flow f; uint8_t sshbuf1[] = "SSH-"; @@ -2315,7 +2336,8 @@ end: /** \test Fragmented banner handling: chunk has final part of bannel plus * a record. */ -static int SSHParserTest22(void) { +static int SSHParserTest22(void) +{ int result = 0; Flow f; uint8_t sshbuf1[] = "SSH-"; @@ -2449,7 +2471,8 @@ end: #endif /* UNITTESTS */ -void SSHParserRegisterTests(void) { +void SSHParserRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("SSHParserTest01 - ToServer", SSHParserTest01, 1); UtRegisterTest("SSHParserTest02 - ToServer", SSHParserTest02, 1); diff --git a/src/app-layer.c b/src/app-layer.c index e2f4d088f8..4c7770c1ac 100644 --- a/src/app-layer.c +++ b/src/app-layer.c @@ -658,13 +658,15 @@ void AppLayerDestroyCtxThread(AppLayerThreadCtx *app_tctx) /* profiling */ -void AppLayerProfilingReset(AppLayerThreadCtx *app_tctx) { +void AppLayerProfilingReset(AppLayerThreadCtx *app_tctx) +{ #ifdef PROFILING PACKET_PROFILING_APP_RESET(app_tctx); #endif } -void AppLayerProfilingStore(AppLayerThreadCtx *app_tctx, Packet *p) { +void AppLayerProfilingStore(AppLayerThreadCtx *app_tctx, Packet *p) +{ #ifdef PROFILING PACKET_PROFILING_APP_STORE(app_tctx, p); #endif diff --git a/src/decode-gre.c b/src/decode-gre.c index 8888e79004..cd9f47191b 100644 --- a/src/decode-gre.c +++ b/src/decode-gre.c @@ -261,7 +261,8 @@ int DecodeGRE(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, ui * \test DecodeGRETest01 is a test for small gre packet */ -static int DecodeGREtest01 (void) { +static int DecodeGREtest01 (void) +{ uint8_t raw_gre[] = { 0x00 ,0x6e ,0x62 }; Packet *p = PacketGetFromAlloc(); @@ -288,7 +289,8 @@ static int DecodeGREtest01 (void) { * \test DecodeGRETest02 is a test for wrong gre version */ -static int DecodeGREtest02 (void) { +static int DecodeGREtest02 (void) +{ uint8_t raw_gre[] = { 0x00, 0x6e, 0x62, 0xac, 0x40, 0x00, 0x40, 0x2f, 0xc2, 0xc7, 0x0a, 0x00, 0x00, 0x64, 0x0a, 0x00, @@ -329,7 +331,8 @@ static int DecodeGREtest02 (void) { * \test DecodeGRETest03 is a test for valid gre packet */ -static int DecodeGREtest03 (void) { +static int DecodeGREtest03 (void) +{ uint8_t raw_gre[] = { 0x00, 0x6e, 0x62, 0xac, 0x40, 0x00, 0x40, 0x2f, 0xc2, 0xc7, 0x0a, 0x00, 0x00, 0x64, 0x0a, 0x00, @@ -371,7 +374,8 @@ static int DecodeGREtest03 (void) { * \brief this function registers unit tests for GRE decoder */ -void DecodeGRERegisterTests(void) { +void DecodeGRERegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("DecodeGREtest01", DecodeGREtest01, 1); UtRegisterTest("DecodeGREtest02", DecodeGREtest02, 1); diff --git a/src/decode-icmpv4.c b/src/decode-icmpv4.c index 6493550d99..99ab99f231 100644 --- a/src/decode-icmpv4.c +++ b/src/decode-icmpv4.c @@ -310,7 +310,8 @@ int DecodeICMPV4(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, * \brief * \retval 1 Expected test value */ -static int DecodeICMPV4test01(void) { +static int DecodeICMPV4test01(void) +{ uint8_t raw_icmpv4[] = { 0x08, 0x00, 0x78, 0x47, 0xfc, 0x55, 0x00, 0x04, 0x52, 0xab, 0x86, 0x4a, 0x84, 0x50, 0x0e, 0x00, @@ -361,7 +362,8 @@ static int DecodeICMPV4test01(void) { * \brief * \retval 1 Expected test value */ -static int DecodeICMPV4test02(void) { +static int DecodeICMPV4test02(void) +{ uint8_t raw_icmpv4[] = { 0x00, 0x00, 0x57, 0x64, 0xfb, 0x55, 0x00, 0x03, 0x43, 0xab, 0x86, 0x4a, 0xf6, 0x49, 0x02, 0x00, @@ -411,7 +413,8 @@ static int DecodeICMPV4test02(void) { * \brief TTL exceeded * \retval Expected test value: 1 */ -static int DecodeICMPV4test03(void) { +static int DecodeICMPV4test03(void) +{ uint8_t raw_icmpv4[] = { 0x0b, 0x00, 0x6a, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x3c, 0x64, 0x15, 0x00, 0x00, @@ -488,7 +491,8 @@ end: * \brief dest. unreachable, administratively prohibited * \retval 1 Expected test value */ -static int DecodeICMPV4test04(void) { +static int DecodeICMPV4test04(void) +{ uint8_t raw_icmpv4[] = { 0x03, 0x0a, 0x36, 0xc3, 0x00, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x3c, 0x62, 0xee, 0x40, 0x00, @@ -559,7 +563,8 @@ end: * \brief dest. unreachable, administratively prohibited * \retval 1 Expected test value */ -static int DecodeICMPV4test05(void) { +static int DecodeICMPV4test05(void) +{ uint8_t raw_icmpv4[] = { 0x0b, 0x00, 0x5c, 0x46, 0x00, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x30, 0x02, 0x17, 0x40, 0x00, 0x01, 0x06, @@ -624,7 +629,8 @@ end: return ret; } -static int ICMPV4CalculateValidChecksumtest05(void) { +static int ICMPV4CalculateValidChecksumtest05(void) +{ uint16_t csum = 0; uint8_t raw_icmpv4[] = { @@ -641,7 +647,8 @@ static int ICMPV4CalculateValidChecksumtest05(void) { return (csum == ICMPV4CalculateChecksum((uint16_t *)raw_icmpv4, sizeof(raw_icmpv4))); } -static int ICMPV4CalculateInvalidChecksumtest06(void) { +static int ICMPV4CalculateInvalidChecksumtest06(void) +{ uint16_t csum = 0; uint8_t raw_icmpv4[] = { @@ -658,7 +665,8 @@ static int ICMPV4CalculateInvalidChecksumtest06(void) { return (csum == ICMPV4CalculateChecksum((uint16_t *)raw_icmpv4, sizeof(raw_icmpv4))); } -static int ICMPV4InvalidType07(void) { +static int ICMPV4InvalidType07(void) +{ uint8_t raw_icmpv4[] = { 0xff, 0x00, 0xab, 0x9b, 0x7f, 0x2b, 0x05, 0x2c, @@ -709,7 +717,8 @@ static int ICMPV4InvalidType07(void) { * \brief * \retval 1 Expected test value - what we really want is not to segfault */ -static int DecodeICMPV4test08(void) { +static int DecodeICMPV4test08(void) +{ uint8_t raw_icmpv4[] = { 0x08, 0x00, 0x78, 0x47, 0xfc, 0x55, 0x00, 0x00 }; @@ -754,7 +763,8 @@ static int DecodeICMPV4test08(void) { /** * \brief Registers ICMPV4 unit test */ -void DecodeICMPV4RegisterTests(void) { +void DecodeICMPV4RegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("DecodeICMPV4test01", DecodeICMPV4test01, 1); UtRegisterTest("DecodeICMPV4test02", DecodeICMPV4test02, 1); diff --git a/src/decode-icmpv6.c b/src/decode-icmpv6.c index 0a58db5488..71623ab040 100644 --- a/src/decode-icmpv6.c +++ b/src/decode-icmpv6.c @@ -344,7 +344,8 @@ int DecodeICMPV6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, #ifdef UNITTESTS -static int ICMPV6CalculateValidChecksumtest01(void) { +static int ICMPV6CalculateValidChecksumtest01(void) +{ uint16_t csum = 0; uint8_t raw_ipv6[] = { @@ -371,7 +372,8 @@ static int ICMPV6CalculateValidChecksumtest01(void) { (uint16_t *)(raw_ipv6 + 54), 68)); } -static int ICMPV6CalculateInvalidChecksumtest02(void) { +static int ICMPV6CalculateInvalidChecksumtest02(void) +{ uint16_t csum = 0; uint8_t raw_ipv6[] = { diff --git a/src/decode-ipv4.c b/src/decode-ipv4.c index 665f4acd49..7d7d3a246a 100644 --- a/src/decode-ipv4.c +++ b/src/decode-ipv4.c @@ -54,7 +54,8 @@ * * See: RFC 791 */ -static int IPV4OptValidateGeneric(Packet *p, const IPV4Opt *o) { +static int IPV4OptValidateGeneric(Packet *p, const IPV4Opt *o) +{ switch (o->type) { /* See: RFC 4782 */ case IPV4_OPT_QS: @@ -98,7 +99,8 @@ static int IPV4OptValidateGeneric(Packet *p, const IPV4Opt *o) { * * See: RFC 791 */ -static int IPV4OptValidateRoute(Packet *p, const IPV4Opt *o) { +static int IPV4OptValidateRoute(Packet *p, const IPV4Opt *o) +{ uint8_t ptr; /* Check length */ @@ -133,7 +135,8 @@ static int IPV4OptValidateRoute(Packet *p, const IPV4Opt *o) { * * See: RFC 781 */ -static int IPV4OptValidateTimestamp(Packet *p, const IPV4Opt *o) { +static int IPV4OptValidateTimestamp(Packet *p, const IPV4Opt *o) +{ uint8_t ptr; uint8_t flag; uint8_t rec_size; @@ -180,7 +183,8 @@ static int IPV4OptValidateTimestamp(Packet *p, const IPV4Opt *o) { * See: draft-ietf-cipso-ipsecurity-01.txt * See: FIPS 188 (tags 6 & 7) */ -static int IPV4OptValidateCIPSO(Packet *p, const IPV4Opt *o) { +static int IPV4OptValidateCIPSO(Packet *p, const IPV4Opt *o) +{ // uint32_t doi; uint8_t *tag; uint16_t len; @@ -605,7 +609,8 @@ int DecodeIPV4(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, u /* UNITTESTS */ #ifdef UNITTESTS -void DecodeIPV4OptionsPrint(Packet *p) { +void DecodeIPV4OptionsPrint(Packet *p) +{ IPV4Vars *pv = &p->ip4vars; printf("DecodeIPV4Options: cnt=%" PRIu8 @@ -632,7 +637,8 @@ void DecodeIPV4OptionsPrint(Packet *p) { } /** \test IPV4 with no options. */ -int DecodeIPV4OptionsNONETest01(void) { +int DecodeIPV4OptionsNONETest01(void) +{ uint8_t raw_opts[] = { }; Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) @@ -663,7 +669,8 @@ int DecodeIPV4OptionsNONETest01(void) { } /** \test IPV4 with EOL option. */ -int DecodeIPV4OptionsEOLTest01(void) { +int DecodeIPV4OptionsEOLTest01(void) +{ uint8_t raw_opts[] = { IPV4_OPT_EOL, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; @@ -696,7 +703,8 @@ int DecodeIPV4OptionsEOLTest01(void) { } /** \test IPV4 with NOP option. */ -int DecodeIPV4OptionsNOPTest01(void) { +int DecodeIPV4OptionsNOPTest01(void) +{ uint8_t raw_opts[] = { IPV4_OPT_NOP, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; @@ -729,7 +737,8 @@ int DecodeIPV4OptionsNOPTest01(void) { } /** \test IPV4 with RR option. */ -int DecodeIPV4OptionsRRTest01(void) { +int DecodeIPV4OptionsRRTest01(void) +{ uint8_t raw_opts[] = { IPV4_OPT_RR, 0x27, 0x08, 0xc0, 0xa8, 0x2a, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -760,7 +769,8 @@ int DecodeIPV4OptionsRRTest01(void) { } /** \test IPV4 with RR option (len too large). */ -int DecodeIPV4OptionsRRTest02(void) { +int DecodeIPV4OptionsRRTest02(void) +{ uint8_t raw_opts[] = { IPV4_OPT_RR, 0xff, 0x08, 0xc0, 0xa8, 0x2a, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -786,7 +796,8 @@ int DecodeIPV4OptionsRRTest02(void) { } /** \test IPV4 with RR option (ptr too large). */ -int DecodeIPV4OptionsRRTest03(void) { +int DecodeIPV4OptionsRRTest03(void) +{ uint8_t raw_opts[] = { IPV4_OPT_RR, 0x27, 0xff, 0xc0, 0xa8, 0x2a, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -812,7 +823,8 @@ int DecodeIPV4OptionsRRTest03(void) { } /** \test IPV4 with RR option (ptr not in 4 byte increment). */ -int DecodeIPV4OptionsRRTest04(void) { +int DecodeIPV4OptionsRRTest04(void) +{ uint8_t raw_opts[] = { IPV4_OPT_RR, 0x27, 0x05, 0xc0, 0xa8, 0x2a, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -838,7 +850,8 @@ int DecodeIPV4OptionsRRTest04(void) { } /** \test IPV4 with QS option. */ -int DecodeIPV4OptionsQSTest01(void) { +int DecodeIPV4OptionsQSTest01(void) +{ uint8_t raw_opts[] = { IPV4_OPT_QS, 0x08, 0x0d, 0x00, 0xbe, 0xef, 0x00, 0x00 }; @@ -865,7 +878,8 @@ int DecodeIPV4OptionsQSTest01(void) { } /** \test IPV4 with QS option (len too small) */ -int DecodeIPV4OptionsQSTest02(void) { +int DecodeIPV4OptionsQSTest02(void) +{ uint8_t raw_opts[] = { IPV4_OPT_QS, 0x07, 0x0d, 0x00, 0xbe, 0xef, 0x00, 0x00 }; @@ -887,7 +901,8 @@ int DecodeIPV4OptionsQSTest02(void) { } /** \test IPV4 with TS option. */ -int DecodeIPV4OptionsTSTest01(void) { +int DecodeIPV4OptionsTSTest01(void) +{ uint8_t raw_opts[] = { IPV4_OPT_TS, 0x24, 0x0d, 0x01, 0x0a, 0x0a, 0x0a, 0x69, 0x04, 0xce, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -918,7 +933,8 @@ int DecodeIPV4OptionsTSTest01(void) { } /** \test IPV4 with TS option (ptr too small). */ -int DecodeIPV4OptionsTSTest02(void) { +int DecodeIPV4OptionsTSTest02(void) +{ uint8_t raw_opts[] = { IPV4_OPT_TS, 0x24, 0x04, 0x01, 0x0a, 0x0a, 0x0a, 0x69, 0x04, 0xce, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -944,7 +960,8 @@ int DecodeIPV4OptionsTSTest02(void) { } /** \test IPV4 with TS option (ptr too large). */ -int DecodeIPV4OptionsTSTest03(void) { +int DecodeIPV4OptionsTSTest03(void) +{ uint8_t raw_opts[] = { IPV4_OPT_TS, 0x24, 0xff, 0x01, 0x0a, 0x0a, 0x0a, 0x69, 0x04, 0xce, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -970,7 +987,8 @@ int DecodeIPV4OptionsTSTest03(void) { } /** \test IPV4 with TS option (ptr not valid). */ -int DecodeIPV4OptionsTSTest04(void) { +int DecodeIPV4OptionsTSTest04(void) +{ uint8_t raw_opts[] = { IPV4_OPT_TS, 0x24, 0x0a, 0x01, 0x0a, 0x0a, 0x0a, 0x69, 0x04, 0xce, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -996,7 +1014,8 @@ int DecodeIPV4OptionsTSTest04(void) { } /** \test IPV4 with SEC option. */ -int DecodeIPV4OptionsSECTest01(void) { +int DecodeIPV4OptionsSECTest01(void) +{ uint8_t raw_opts[] = { IPV4_OPT_SEC, 0x0b, 0xf1, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 @@ -1024,7 +1043,8 @@ int DecodeIPV4OptionsSECTest01(void) { } /** \test IPV4 with SEC option (invalid length). */ -int DecodeIPV4OptionsSECTest02(void) { +int DecodeIPV4OptionsSECTest02(void) +{ uint8_t raw_opts[] = { IPV4_OPT_SEC, 0x0a, 0xf1, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 @@ -1047,7 +1067,8 @@ int DecodeIPV4OptionsSECTest02(void) { } /** \test IPV4 with LSRR option. */ -int DecodeIPV4OptionsLSRRTest01(void) { +int DecodeIPV4OptionsLSRRTest01(void) +{ uint8_t raw_opts[] = { IPV4_OPT_LSRR, 0x27, 0x08, 0xc0, 0xa8, 0x2a, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -1078,7 +1099,8 @@ int DecodeIPV4OptionsLSRRTest01(void) { } /** \test IPV4 with LSRR option (len too large). */ -int DecodeIPV4OptionsLSRRTest02(void) { +int DecodeIPV4OptionsLSRRTest02(void) +{ uint8_t raw_opts[] = { IPV4_OPT_LSRR, 0xff, 0x08, 0xc0, 0xa8, 0x2a, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -1104,7 +1126,8 @@ int DecodeIPV4OptionsLSRRTest02(void) { } /** \test IPV4 with LSRR option (ptr too large). */ -int DecodeIPV4OptionsLSRRTest03(void) { +int DecodeIPV4OptionsLSRRTest03(void) +{ uint8_t raw_opts[] = { IPV4_OPT_LSRR, 0x27, 0xff, 0xc0, 0xa8, 0x2a, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -1130,7 +1153,8 @@ int DecodeIPV4OptionsLSRRTest03(void) { } /** \test IPV4 with LSRR option (ptr not in 4 byte increment). */ -int DecodeIPV4OptionsLSRRTest04(void) { +int DecodeIPV4OptionsLSRRTest04(void) +{ uint8_t raw_opts[] = { IPV4_OPT_LSRR, 0x27, 0x05, 0xc0, 0xa8, 0x2a, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -1156,7 +1180,8 @@ int DecodeIPV4OptionsLSRRTest04(void) { } /** \test IPV4 with CIPSO option. */ -int DecodeIPV4OptionsCIPSOTest01(void) { +int DecodeIPV4OptionsCIPSOTest01(void) +{ uint8_t raw_opts[] = { IPV4_OPT_CIPSO, 0x18, 0x00, 0x00, 0x00, 0x05, 0x05, 0x12, 0x00, 0x03, 0x00, 0xef, 0x00, 0xef, 0x00, 0x06, @@ -1185,7 +1210,8 @@ int DecodeIPV4OptionsCIPSOTest01(void) { } /** \test IPV4 with SID option. */ -int DecodeIPV4OptionsSIDTest01(void) { +int DecodeIPV4OptionsSIDTest01(void) +{ uint8_t raw_opts[] = { IPV4_OPT_SID, 0x04, 0xbe, 0xef, 0x00, 0x00, 0x00, 0x00 }; @@ -1212,7 +1238,8 @@ int DecodeIPV4OptionsSIDTest01(void) { } /** \test IPV4 with SID option (len invalid. */ -int DecodeIPV4OptionsSIDTest02(void) { +int DecodeIPV4OptionsSIDTest02(void) +{ uint8_t raw_opts[] = { IPV4_OPT_SID, 0x05, 0xbe, 0xef, 0x00, 0x00, 0x00, 0x00 }; @@ -1234,7 +1261,8 @@ int DecodeIPV4OptionsSIDTest02(void) { } /** \test IPV4 with SSRR option. */ -int DecodeIPV4OptionsSSRRTest01(void) { +int DecodeIPV4OptionsSSRRTest01(void) +{ uint8_t raw_opts[] = { IPV4_OPT_SSRR, 0x27, 0x08, 0xc0, 0xa8, 0x2a, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -1265,7 +1293,8 @@ int DecodeIPV4OptionsSSRRTest01(void) { } /** \test IPV4 with SSRR option (len too large). */ -int DecodeIPV4OptionsSSRRTest02(void) { +int DecodeIPV4OptionsSSRRTest02(void) +{ uint8_t raw_opts[] = { IPV4_OPT_SSRR, 0xff, 0x08, 0xc0, 0xa8, 0x2a, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -1291,7 +1320,8 @@ int DecodeIPV4OptionsSSRRTest02(void) { } /** \test IPV4 with SSRR option (ptr too large). */ -int DecodeIPV4OptionsSSRRTest03(void) { +int DecodeIPV4OptionsSSRRTest03(void) +{ uint8_t raw_opts[] = { IPV4_OPT_SSRR, 0x27, 0xff, 0xc0, 0xa8, 0x2a, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -1317,7 +1347,8 @@ int DecodeIPV4OptionsSSRRTest03(void) { } /** \test IPV4 with SSRR option (ptr not in 4 byte increment). */ -int DecodeIPV4OptionsSSRRTest04(void) { +int DecodeIPV4OptionsSSRRTest04(void) +{ uint8_t raw_opts[] = { IPV4_OPT_SSRR, 0x27, 0x05, 0xc0, 0xa8, 0x2a, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -1343,7 +1374,8 @@ int DecodeIPV4OptionsSSRRTest04(void) { } /** \test IPV4 with RTRALT option. */ -int DecodeIPV4OptionsRTRALTTest01(void) { +int DecodeIPV4OptionsRTRALTTest01(void) +{ uint8_t raw_opts[] = { IPV4_OPT_RTRALT, 0x04, 0xbe, 0xef, 0x00, 0x00, 0x00, 0x00 }; @@ -1370,7 +1402,8 @@ int DecodeIPV4OptionsRTRALTTest01(void) { } /** \test IPV4 with RTRALT option (len invalid. */ -int DecodeIPV4OptionsRTRALTTest02(void) { +int DecodeIPV4OptionsRTRALTTest02(void) +{ uint8_t raw_opts[] = { IPV4_OPT_RTRALT, 0x05, 0xbe, 0xef, 0x00, 0x00, 0x00, 0x00 }; @@ -1835,7 +1868,8 @@ end: #endif /* UNITTESTS */ -void DecodeIPV4RegisterTests(void) { +void DecodeIPV4RegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("DecodeIPV4OptionsNONETest01", DecodeIPV4OptionsNONETest01, 1); UtRegisterTest("DecodeIPV4OptionsEOLTest01", DecodeIPV4OptionsEOLTest01, 1); diff --git a/src/decode-ipv6.c b/src/decode-ipv6.c index 1504ae2a8d..3c96f66d3e 100644 --- a/src/decode-ipv6.c +++ b/src/decode-ipv6.c @@ -640,7 +640,8 @@ int DecodeIPV6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, u /** * \test fragment decoding */ -static int DecodeIPV6FragTest01 (void) { +static int DecodeIPV6FragTest01 (void) +{ uint8_t raw_frag1[] = { 0x60, 0x0f, 0x1a, 0xcf, 0x05, 0xa8, 0x2c, 0x36, 0x20, 0x01, 0x04, 0x70, 0x00, 0x01, 0x00, 0x18, @@ -807,7 +808,8 @@ end: /** * \test routing header decode */ -static int DecodeIPV6RouteTest01 (void) { +static int DecodeIPV6RouteTest01 (void) +{ uint8_t raw_pkt1[] = { 0x60, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x2b, 0x40, @@ -916,7 +918,8 @@ end: * \brief this function registers unit tests for IPV6 decoder */ -void DecodeIPV6RegisterTests(void) { +void DecodeIPV6RegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("DecodeIPV6FragTest01", DecodeIPV6FragTest01, 1); UtRegisterTest("DecodeIPV6RouteTest01", DecodeIPV6RouteTest01, 1); diff --git a/src/decode-ppp.c b/src/decode-ppp.c index 4a4aad985e..0d15c0c450 100644 --- a/src/decode-ppp.c +++ b/src/decode-ppp.c @@ -136,7 +136,8 @@ int DecodePPP(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, ui * Decode malformed ip layer PPP packet * Expected test value: 1 */ -static int DecodePPPtest01 (void) { +static int DecodePPPtest01 (void) +{ uint8_t raw_ppp[] = { 0xff, 0x03, 0x00, 0x21, 0x45, 0xc0, 0x00 }; Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) @@ -164,7 +165,8 @@ static int DecodePPPtest01 (void) { * Decode malformed ppp layer packet * Expected test value: 1 */ -static int DecodePPPtest02 (void) { +static int DecodePPPtest02 (void) +{ uint8_t raw_ppp[] = { 0xff, 0x03, 0x00, 0xff, 0x45, 0xc0, 0x00, 0x2c, 0x4d, 0xed, 0x00, 0x00, 0xff, 0x06, 0xd5, 0x17, 0xbf, 0x01, 0x0d, 0x01, 0xbf, 0x01, 0x0d, 0x03, 0xea, 0x37, 0x00, @@ -198,7 +200,8 @@ static int DecodePPPtest02 (void) { * \retval 0 Test failed * \retval 1 Test succeeded */ -static int DecodePPPtest03 (void) { +static int DecodePPPtest03 (void) +{ uint8_t raw_ppp[] = { 0xff, 0x03, 0x00, 0x21, 0x45, 0xc0, 0x00, 0x2c, 0x4d, 0xed, 0x00, 0x00, 0xff, 0x06, 0xd5, 0x17, 0xbf, 0x01, 0x0d, 0x01, 0xbf, 0x01, 0x0d, 0x03, 0xea, 0x37, 0x00, @@ -255,7 +258,8 @@ static int DecodePPPtest03 (void) { * Expected test value: 1 */ -static int DecodePPPtest04 (void) { +static int DecodePPPtest04 (void) +{ uint8_t raw_ppp[] = { 0xff, 0x03, 0x00, 0x21, 0x45, 0xc0, 0x00, 0x2c, 0x4d, 0xed, 0x00, 0x00, 0xff, 0x06, 0xd5, 0x17, 0xbf, 0x01, 0x0d, 0x01, 0xbf, 0x01, 0x0d, 0x03, 0xea, 0x37, 0x00, @@ -293,7 +297,8 @@ static int DecodePPPtest04 (void) { } #endif /* UNITTESTS */ -void DecodePPPRegisterTests(void) { +void DecodePPPRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("DecodePPPtest01", DecodePPPtest01, 1); UtRegisterTest("DecodePPPtest02", DecodePPPtest02, 1); diff --git a/src/decode-pppoe.c b/src/decode-pppoe.c index 01785be4fa..57df28f5e5 100644 --- a/src/decode-pppoe.c +++ b/src/decode-pppoe.c @@ -225,7 +225,8 @@ int DecodePPPOESession(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t * \brief Decode malformed PPPOE packet (too short) * \retval 1 Expected test value */ -static int DecodePPPOEtest01 (void) { +static int DecodePPPOEtest01 (void) +{ uint8_t raw_pppoe[] = { 0x11, 0x00, 0x00, 0x00, 0x00 }; Packet *p = PacketGetFromAlloc(); @@ -252,7 +253,8 @@ static int DecodePPPOEtest01 (void) { * \brief Valid PPPOE packet - check the invalid ICMP type encapsulated is flagged * \retval 0 Expected test value */ -static int DecodePPPOEtest02 (void) { +static int DecodePPPOEtest02 (void) +{ uint8_t raw_pppoe[] = { 0x11, 0x00, 0x00, 0x01, 0x00, 0x40, 0x00, 0x21, @@ -301,7 +303,8 @@ end: * \brief Valid example PADO packet PPPOE packet taken from RFC2516 * \retval 0 Expected test value */ -static int DecodePPPOEtest03 (void) { +static int DecodePPPOEtest03 (void) +{ /* example PADO packet taken from RFC2516 */ uint8_t raw_pppoe[] = { @@ -335,7 +338,8 @@ static int DecodePPPOEtest03 (void) { * \brief Valid example PPPOE packet taken from RFC2516 - but with wrong PPPOE code * \retval 1 Expected test value */ -static int DecodePPPOEtest04 (void) { +static int DecodePPPOEtest04 (void) +{ /* example PADI packet taken from RFC2516, but with wrong code */ uint8_t raw_pppoe[] = { @@ -367,7 +371,8 @@ static int DecodePPPOEtest04 (void) { * \brief Valid exaple PADO PPPOE packet taken from RFC2516, but too short for given length * \retval 0 Expected test value */ -static int DecodePPPOEtest05 (void) { +static int DecodePPPOEtest05 (void) +{ /* example PADI packet taken from RFC2516 */ uint8_t raw_pppoe[] = { @@ -403,7 +408,8 @@ static int DecodePPPOEtest05 (void) { * should extract the first 4 bits for version and the second 4 bits for type * \retval 1 Expected test value */ -static int DecodePPPOEtest06 (void) { +static int DecodePPPOEtest06 (void) +{ PPPOESessionHdr pppoesh; PPPOEDiscoveryHdr pppoedh; @@ -437,7 +443,8 @@ static int DecodePPPOEtest06 (void) { * \brief Registers PPPOE unit tests * \todo More PPPOE tests */ -void DecodePPPOERegisterTests(void) { +void DecodePPPOERegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("DecodePPPOEtest01", DecodePPPOEtest01, 1); UtRegisterTest("DecodePPPOEtest02", DecodePPPOEtest02, 1); diff --git a/src/decode-raw.c b/src/decode-raw.c index 4998ad9bcf..caa8068738 100644 --- a/src/decode-raw.c +++ b/src/decode-raw.c @@ -74,7 +74,8 @@ int DecodeRaw(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, ui * \brief Valid Raw packet * \retval 0 Expected test value */ -static int DecodeRawTest01 (void) { +static int DecodeRawTest01 (void) +{ /* IPV6/TCP/no eth header */ uint8_t raw_ip[] = { @@ -122,7 +123,8 @@ static int DecodeRawTest01 (void) { * \brief Valid Raw packet * \retval 0 Expected test value */ -static int DecodeRawTest02 (void) { +static int DecodeRawTest02 (void) +{ /* IPV4/TCP/no eth header */ uint8_t raw_ip[] = { @@ -167,7 +169,8 @@ static int DecodeRawTest02 (void) { * \brief Valid Raw packet * \retval 0 Expected test value */ -static int DecodeRawTest03 (void) { +static int DecodeRawTest03 (void) +{ /* IPV13 */ uint8_t raw_ip[] = { @@ -216,7 +219,8 @@ static int DecodeRawTest03 (void) { * \brief Registers Raw unit tests * \todo More Raw tests */ -void DecodeRawRegisterTests(void) { +void DecodeRawRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("DecodeRawTest01", DecodeRawTest01, 0); UtRegisterTest("DecodeRawTest02", DecodeRawTest02, 0); diff --git a/src/decode-vlan.c b/src/decode-vlan.c index 6675918c87..d84262e606 100644 --- a/src/decode-vlan.c +++ b/src/decode-vlan.c @@ -150,7 +150,8 @@ uint16_t DecodeVLANGetId(const Packet *p, uint8_t layer) * \retval 1 on success * \retval 0 on failure */ -static int DecodeVLANtest01 (void) { +static int DecodeVLANtest01 (void) +{ uint8_t raw_vlan[] = { 0x00, 0x20, 0x08 }; Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) @@ -178,7 +179,8 @@ static int DecodeVLANtest01 (void) { * \retval 1 on success * \retval 0 on failure */ -static int DecodeVLANtest02 (void) { +static int DecodeVLANtest02 (void) +{ uint8_t raw_vlan[] = { 0x00, 0x20, 0x01, 0x00, 0x45, 0x00, 0x00, 0x34, 0x3b, 0x36, 0x40, 0x00, 0x40, 0x06, 0xb7, 0xc9, @@ -214,7 +216,8 @@ static int DecodeVLANtest02 (void) { * \retval 1 on success * \retval 0 on failure */ -static int DecodeVLANtest03 (void) { +static int DecodeVLANtest03 (void) +{ uint8_t raw_vlan[] = { 0x00, 0x20, 0x08, 0x00, 0x45, 0x00, 0x00, 0x34, 0x3b, 0x36, 0x40, 0x00, 0x40, 0x06, 0xb7, 0xc9, @@ -262,7 +265,8 @@ error: } #endif /* UNITTESTS */ -void DecodeVLANRegisterTests(void) { +void DecodeVLANRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("DecodeVLANtest01", DecodeVLANtest01, 1); UtRegisterTest("DecodeVLANtest02", DecodeVLANtest02, 1); diff --git a/src/defrag-hash.c b/src/defrag-hash.c index 202a16155b..9cb377e5b3 100644 --- a/src/defrag-hash.c +++ b/src/defrag-hash.c @@ -30,16 +30,19 @@ static DefragTracker *DefragTrackerGetUsedDefragTracker(void); /** queue with spare tracker */ static DefragTrackerQueue defragtracker_spare_q; -uint32_t DefragTrackerSpareQueueGetSize(void) { +uint32_t DefragTrackerSpareQueueGetSize(void) +{ return DefragTrackerQueueLen(&defragtracker_spare_q); } -void DefragTrackerMoveToSpare(DefragTracker *h) { +void DefragTrackerMoveToSpare(DefragTracker *h) +{ DefragTrackerEnqueue(&defragtracker_spare_q, h); (void) SC_ATOMIC_SUB(defragtracker_counter, 1); } -DefragTracker *DefragTrackerAlloc(void) { +DefragTracker *DefragTrackerAlloc(void) +{ if (!(DEFRAG_CHECK_MEMCAP(sizeof(DefragTracker)))) { return NULL; } @@ -60,7 +63,8 @@ error: return NULL; } -void DefragTrackerFree(DefragTracker *dt) { +void DefragTrackerFree(DefragTracker *dt) +{ if (dt != NULL) { DefragTrackerClearMemory(dt); @@ -75,7 +79,8 @@ void DefragTrackerFree(DefragTracker *dt) { #define DefragTrackerDecrUsecnt(dt) \ SC_ATOMIC_SUB((dt)->use_cnt, 1) -static void DefragTrackerInit(DefragTracker *dt, Packet *p) { +static void DefragTrackerInit(DefragTracker *dt, Packet *p) +{ /* copy address */ COPY_ADDRESS(&p->src, &dt->src_addr); COPY_ADDRESS(&p->dst, &dt->dst_addr); @@ -96,7 +101,8 @@ static void DefragTrackerInit(DefragTracker *dt, Packet *p) { (void) DefragTrackerIncrUsecnt(dt); } -static DefragTracker *DefragTrackerNew(Packet *p) { +static DefragTracker *DefragTrackerNew(Packet *p) +{ DefragTracker *dt = DefragTrackerAlloc(); if (dt == NULL) goto error; @@ -108,12 +114,14 @@ error: return NULL; } -void DefragTrackerRelease(DefragTracker *t) { +void DefragTrackerRelease(DefragTracker *t) +{ (void) DefragTrackerDecrUsecnt(t); SCMutexUnlock(&t->lock); } -void DefragTrackerClearMemory(DefragTracker *dt) { +void DefragTrackerClearMemory(DefragTracker *dt) +{ DefragTrackerFreeFrags(dt); SC_ATOMIC_DESTROY(dt->use_cnt); } @@ -349,7 +357,8 @@ typedef struct DefragHashKey6_ { * id * vlan_id */ -static inline uint32_t DefragHashGetKey(Packet *p) { +static inline uint32_t DefragHashGetKey(Packet *p) +{ uint32_t key; if (p->ip4h != NULL) { @@ -411,7 +420,8 @@ static inline uint32_t DefragHashGetKey(Packet *p) { (d1)->vlan_id[0] == (d2)->vlan_id[0] && \ (d1)->vlan_id[1] == (d2)->vlan_id[1]) -static inline int DefragTrackerCompare(DefragTracker *t, Packet *p) { +static inline int DefragTrackerCompare(DefragTracker *t, Packet *p) +{ uint32_t id; if (PKT_IS_IPV4(p)) { id = (uint32_t)IPV4_GET_IPID(p); @@ -430,7 +440,8 @@ static inline int DefragTrackerCompare(DefragTracker *t, Packet *p) { * * \retval dt *LOCKED* tracker on succes, NULL on error. */ -static DefragTracker *DefragTrackerGetNew(Packet *p) { +static DefragTracker *DefragTrackerGetNew(Packet *p) +{ DefragTracker *dt = NULL; /* get a tracker from the spare queue */ @@ -655,7 +666,8 @@ DefragTracker *DefragLookupTrackerFromHash (Packet *p) * * \retval dt tracker or NULL */ -static DefragTracker *DefragTrackerGetUsedDefragTracker(void) { +static DefragTracker *DefragTrackerGetUsedDefragTracker(void) +{ uint32_t idx = SC_ATOMIC_GET(defragtracker_prune_idx) % defrag_config.hash_size; uint32_t cnt = defrag_config.hash_size; diff --git a/src/defrag-queue.c b/src/defrag-queue.c index 9862e90889..71dcb9329e 100644 --- a/src/defrag-queue.c +++ b/src/defrag-queue.c @@ -31,7 +31,8 @@ #include "util-debug.h" #include "util-print.h" -DefragTrackerQueue *DefragTrackerQueueInit (DefragTrackerQueue *q) { +DefragTrackerQueue *DefragTrackerQueueInit (DefragTrackerQueue *q) +{ if (q != NULL) { memset(q, 0, sizeof(DefragTrackerQueue)); DQLOCK_INIT(q); @@ -39,7 +40,8 @@ DefragTrackerQueue *DefragTrackerQueueInit (DefragTrackerQueue *q) { return q; } -DefragTrackerQueue *DefragTrackerQueueNew() { +DefragTrackerQueue *DefragTrackerQueueNew() +{ DefragTrackerQueue *q = (DefragTrackerQueue *)SCMalloc(sizeof(DefragTrackerQueue)); if (q == NULL) { SCLogError(SC_ERR_FATAL, "Fatal error encountered in DefragTrackerQueueNew. Exiting..."); @@ -54,7 +56,8 @@ DefragTrackerQueue *DefragTrackerQueueNew() { * * \param q the tracker queue to destroy */ -void DefragTrackerQueueDestroy (DefragTrackerQueue *q) { +void DefragTrackerQueueDestroy (DefragTrackerQueue *q) +{ DQLOCK_DESTROY(q); } @@ -64,7 +67,8 @@ void DefragTrackerQueueDestroy (DefragTrackerQueue *q) { * \param q queue * \param dt tracker */ -void DefragTrackerEnqueue (DefragTrackerQueue *q, DefragTracker *dt) { +void DefragTrackerEnqueue (DefragTrackerQueue *q, DefragTracker *dt) +{ #ifdef DEBUG BUG_ON(q == NULL || dt == NULL); #endif @@ -96,7 +100,8 @@ void DefragTrackerEnqueue (DefragTrackerQueue *q, DefragTracker *dt) { * * \retval dt tracker or NULL if empty list. */ -DefragTracker *DefragTrackerDequeue (DefragTrackerQueue *q) { +DefragTracker *DefragTrackerDequeue (DefragTrackerQueue *q) +{ DQLOCK_LOCK(q); DefragTracker *dt = q->bot; @@ -128,7 +133,8 @@ DefragTracker *DefragTrackerDequeue (DefragTrackerQueue *q) { return dt; } -uint32_t DefragTrackerQueueLen(DefragTrackerQueue *q) { +uint32_t DefragTrackerQueueLen(DefragTrackerQueue *q) +{ uint32_t len; DQLOCK_LOCK(q); len = q->len; diff --git a/src/defrag-timeout.c b/src/defrag-timeout.c index 991a00c1c3..f77cc59cf9 100644 --- a/src/defrag-timeout.c +++ b/src/defrag-timeout.c @@ -25,11 +25,13 @@ #include "defrag.h" #include "defrag-hash.h" -uint32_t DefragTrackerGetSpareCount(void) { +uint32_t DefragTrackerGetSpareCount(void) +{ return DefragTrackerSpareQueueGetSize(); } -uint32_t DefragTrackerGetActiveCount(void) { +uint32_t DefragTrackerGetActiveCount(void) +{ return SC_ATOMIC_GET(defragtracker_counter); } @@ -42,7 +44,8 @@ uint32_t DefragTrackerGetActiveCount(void) { * \retval 0 not timed out just yet * \retval 1 fully timed out, lets kill it */ -static int DefragTrackerTimedOut(DefragTracker *dt, struct timeval *ts) { +static int DefragTrackerTimedOut(DefragTracker *dt, struct timeval *ts) +{ /** never prune a trackers that is used by a packet * we are currently processing in one of the threads */ if (SC_ATOMIC_GET(dt->use_cnt) > 0) { @@ -122,7 +125,8 @@ static uint32_t DefragTrackerHashRowTimeout(DefragTrackerHashRow *hb, DefragTrac * * \retval cnt number of timed out tracker */ -uint32_t DefragTimeoutHash(struct timeval *ts) { +uint32_t DefragTimeoutHash(struct timeval *ts) +{ uint32_t idx = 0; uint32_t cnt = 0; diff --git a/src/defrag.c b/src/defrag.c index f72435373b..7badf1664e 100644 --- a/src/defrag.c +++ b/src/defrag.c @@ -912,7 +912,8 @@ DefragInit(void) DefragInitConfig(FALSE); } -void DefragDestroy(void) { +void DefragDestroy(void) +{ DefragHashShutdown(); DefragContextDestroy(defrag_context); defrag_context = NULL; @@ -2184,7 +2185,8 @@ end: * fragments. */ static int -DefragVlanTest(void) { +DefragVlanTest(void) +{ Packet *p1 = NULL, *p2 = NULL, *r = NULL; int ret = 0; @@ -2229,7 +2231,8 @@ end: * Like DefragVlanTest, but for QinQ, testing the second level VLAN ID. */ static int -DefragVlanQinQTest(void) { +DefragVlanQinQTest(void) +{ Packet *p1 = NULL, *p2 = NULL, *r = NULL; int ret = 0; diff --git a/src/detect-ack.c b/src/detect-ack.c index 840a718ec9..89d87131af 100644 --- a/src/detect-ack.c +++ b/src/detect-ack.c @@ -46,7 +46,8 @@ static int DetectAckMatch(ThreadVars *, DetectEngineThreadCtx *, static void DetectAckRegisterTests(void); static void DetectAckFree(void *); -void DetectAckRegister(void) { +void DetectAckRegister(void) +{ sigmatch_table[DETECT_ACK].name = "ack"; sigmatch_table[DETECT_ACK].desc = "check for a specific TCP acknowledgement number"; sigmatch_table[DETECT_ACK].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/Header_keywords#ack"; diff --git a/src/detect-asn1.c b/src/detect-asn1.c index f9cb41e36b..b88885d78d 100644 --- a/src/detect-asn1.c +++ b/src/detect-asn1.c @@ -51,7 +51,8 @@ void DetectAsn1Free(void *); /** * \brief Registration function for asn1 */ -void DetectAsn1Register(void) { +void DetectAsn1Register(void) +{ sigmatch_table[DETECT_ASN1].name = "asn1"; sigmatch_table[DETECT_ASN1].Match = DetectAsn1Match; sigmatch_table[DETECT_ASN1].Setup = DetectAsn1Setup; @@ -75,7 +76,8 @@ void DetectAsn1Register(void) { * checks that we want to perform, and the lenght of oversize check * \retval 1 if any of the options match, 0 if not */ -static uint8_t DetectAsn1Checks(Asn1Node *node, DetectAsn1Data *ad) { +static uint8_t DetectAsn1Checks(Asn1Node *node, DetectAsn1Data *ad) +{ /* oversize_length will check if a node has a length greater than * the user supplied length */ @@ -195,7 +197,8 @@ int DetectAsn1Match(ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p, * \retval fd pointer to DetectAsn1Data on success * \retval NULL on failure */ -DetectAsn1Data *DetectAsn1Parse(char *asn1str) { +DetectAsn1Data *DetectAsn1Parse(char *asn1str) +{ DetectAsn1Data *fd = NULL; char *tok = NULL; uint32_t ov_len = 0; @@ -285,7 +288,8 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -int DetectAsn1Setup(DetectEngineCtx *de_ctx, Signature *s, char *asn1str) { +int DetectAsn1Setup(DetectEngineCtx *de_ctx, Signature *s, char *asn1str) +{ DetectAsn1Data *ad = NULL; SigMatch *sm = NULL; @@ -317,7 +321,8 @@ error: * * \param ad pointer to DetectAsn1Data */ -void DetectAsn1Free(void *ptr) { +void DetectAsn1Free(void *ptr) +{ DetectAsn1Data *ad = (DetectAsn1Data *)ptr; SCFree(ad); } @@ -327,7 +332,8 @@ void DetectAsn1Free(void *ptr) { /** * \test DetectAsn1TestParse01 check that we parse oversize_length correctly */ -int DetectAsn1TestParse01(void) { +int DetectAsn1TestParse01(void) +{ int result = 0; char str[] = "oversize_length 1024"; DetectAsn1Data *ad = NULL; @@ -346,7 +352,8 @@ int DetectAsn1TestParse01(void) { /** * \test DetectAsn1TestParse02 check that we parse absolute_offset correctly */ -int DetectAsn1TestParse02(void) { +int DetectAsn1TestParse02(void) +{ int result = 0; DetectAsn1Data *ad = NULL; char str[] = "absolute_offset 1024"; @@ -364,7 +371,8 @@ int DetectAsn1TestParse02(void) { /** * \test DetectAsn1TestParse03 check that we parse relative_offset correctly */ -int DetectAsn1TestParse03(void) { +int DetectAsn1TestParse03(void) +{ int result = 0; char str[] = "relative_offset 1024"; DetectAsn1Data *ad = NULL; @@ -382,7 +390,8 @@ int DetectAsn1TestParse03(void) { /** * \test DetectAsn1TestParse04 check that we parse bitstring_overflow correctly */ -int DetectAsn1TestParse04(void) { +int DetectAsn1TestParse04(void) +{ int result = 0; char str[] = "bitstring_overflow"; DetectAsn1Data *ad = NULL; @@ -399,7 +408,8 @@ int DetectAsn1TestParse04(void) { /** * \test DetectAsn1TestParse05 check that we parse double_overflow correctly */ -int DetectAsn1TestParse05(void) { +int DetectAsn1TestParse05(void) +{ int result = 0; char str[] = "double_overflow"; DetectAsn1Data *ad = NULL; @@ -416,7 +426,8 @@ int DetectAsn1TestParse05(void) { /** * \test DetectAsn1TestParse06 check that we fail if a needed arg is not given */ -int DetectAsn1TestParse06(void) { +int DetectAsn1TestParse06(void) +{ int result = 1; char str[] = "absolute_offset"; DetectAsn1Data *ad = NULL; @@ -433,7 +444,8 @@ int DetectAsn1TestParse06(void) { /** * \test DetectAsn1TestParse07 check that we fail if a needed arg is not given */ -int DetectAsn1TestParse07(void) { +int DetectAsn1TestParse07(void) +{ int result = 1; char str[] = "relative_offset"; DetectAsn1Data *ad = NULL; @@ -450,7 +462,8 @@ int DetectAsn1TestParse07(void) { /** * \test DetectAsn1TestParse08 check that we fail if a needed arg is not given */ -int DetectAsn1TestParse08(void) { +int DetectAsn1TestParse08(void) +{ int result = 1; char str[] = "oversize_length"; DetectAsn1Data *ad = NULL; @@ -469,7 +482,8 @@ int DetectAsn1TestParse08(void) { /** * \test DetectAsn1TestParse09 test that we break on invalid options */ -int DetectAsn1TestParse09(void) { +int DetectAsn1TestParse09(void) +{ int result = 1; DetectAsn1Data *fd = NULL; char str[] = "oversize_length 1024, lalala 360"; @@ -486,7 +500,8 @@ int DetectAsn1TestParse09(void) { /** * \test DetectAsn1TestParse10 test that we break with a empty string */ -int DetectAsn1TestParse10(void) { +int DetectAsn1TestParse10(void) +{ int result = 1; DetectAsn1Data *fd = NULL; char str[] = ""; @@ -503,7 +518,8 @@ int DetectAsn1TestParse10(void) { /** * \test DetectAsn1TestParse11 check for combinations of keywords */ -int DetectAsn1TestParse11(void) { +int DetectAsn1TestParse11(void) +{ int result = 0; char str[] = "oversize_length 1024, relative_offset 10"; DetectAsn1Data *ad = NULL; @@ -524,7 +540,8 @@ int DetectAsn1TestParse11(void) { /** * \test DetectAsn1TestParse12 check for combinations of keywords */ -int DetectAsn1TestParse12(void) { +int DetectAsn1TestParse12(void) +{ int result = 0; char str[] = "oversize_length 1024 absolute_offset 10"; DetectAsn1Data *ad = NULL; @@ -545,7 +562,8 @@ int DetectAsn1TestParse12(void) { /** * \test DetectAsn1TestParse13 check for combinations of keywords */ -int DetectAsn1TestParse13(void) { +int DetectAsn1TestParse13(void) +{ int result = 0; char str[] = "oversize_length 1024 absolute_offset 10, bitstring_overflow"; DetectAsn1Data *ad = NULL; @@ -567,7 +585,8 @@ int DetectAsn1TestParse13(void) { /** * \test DetectAsn1TestParse14 check for combinations of keywords */ -int DetectAsn1TestParse14(void) { +int DetectAsn1TestParse14(void) +{ int result = 0; char str[] = "double_overflow, oversize_length 1024 absolute_offset 10," " bitstring_overflow"; @@ -591,7 +610,8 @@ int DetectAsn1TestParse14(void) { /** * \test DetectAsn1TestParse15 check for combinations of keywords */ -int DetectAsn1TestParse15(void) { +int DetectAsn1TestParse15(void) +{ int result = 0; char str[] = "double_overflow, oversize_length 1024 relative_offset 10," " bitstring_overflow"; @@ -615,7 +635,8 @@ int DetectAsn1TestParse15(void) { /** * \test DetectAsn1Test01 Ensure that the checks work when they should */ -int DetectAsn1Test01(void) { +int DetectAsn1Test01(void) +{ int result = 0; /* Match if any of the nodes after offset 0 has greater length than 10 */ char str[] = "oversize_length 132 absolute_offset 0"; @@ -680,7 +701,8 @@ int DetectAsn1Test01(void) { /** * \test DetectAsn1Test02 Ensure that the checks work when they should */ -int DetectAsn1Test02(void) { +int DetectAsn1Test02(void) +{ int result = 0; /* Match if any of the nodes has the bitstring overflow condition */ char str[] = "oversize_length 133, absolute_offset 0"; @@ -747,7 +769,8 @@ int DetectAsn1Test02(void) { /** * \test DetectAsn1Test03 Ensure that the checks work when they should */ -int DetectAsn1Test03(void) { +int DetectAsn1Test03(void) +{ int result = 0; /* Match if any of the nodes after offset 0 has a bitstring overflow */ char str[] = "bitstring_overflow, absolute_offset 0"; @@ -805,7 +828,8 @@ int DetectAsn1Test03(void) { /** * \test DetectAsn1Test04 Ensure that the checks work when they should */ -int DetectAsn1Test04(void) { +int DetectAsn1Test04(void) +{ int result = 0; /* Match if any of the nodes after offset 0 has a bitstring overflow */ char str[] = "bitstring_overflow, absolute_offset 0"; @@ -866,7 +890,8 @@ int DetectAsn1Test04(void) { /** * \test DetectAsn1Test05 Ensure that the checks work when they should */ -int DetectAsn1Test05(void) { +int DetectAsn1Test05(void) +{ int result = 0; /* Match if any of the nodes after offset 0 has a double overflow */ char str[] = "double_overflow, absolute_offset 0"; @@ -935,7 +960,8 @@ int DetectAsn1Test05(void) { /** * \test DetectAsn1Test06 Ensure that the checks work when they should */ -int DetectAsn1Test06(void) { +int DetectAsn1Test06(void) +{ int result = 0; /* Match if any of the nodes after offset 0 has a double overflow */ char str[] = "double_overflow, absolute_offset 0"; @@ -1007,7 +1033,8 @@ int DetectAsn1Test06(void) { /** * \test DetectAsn1TestReal01 Ensure that all works together */ -int DetectAsn1TestReal01(void) { +int DetectAsn1TestReal01(void) +{ int result = 0; uint8_t *buf = (uint8_t *) "\x60\x81\x85\x61\x10\x1A\x04""John""\x1A\x01" "P""\x1A\x05""Smith""\xA0\x0A\x1A\x08""Director" @@ -1085,7 +1112,8 @@ end: /** * \test DetectAsn1TestReal02 Ensure that all works together */ -int DetectAsn1TestReal02(void) { +int DetectAsn1TestReal02(void) +{ int result = 0; uint8_t *buf = (uint8_t *) "\x60\x81\x85\x61\x10\x1A\x04""John""\x1A\x01" "P""\x1A\x05""Smith""\xA0\x0A\x1A\x08""Director" @@ -1161,7 +1189,8 @@ end: /** * \test DetectAsn1TestReal03 Ensure that all works together */ -int DetectAsn1TestReal03(void) { +int DetectAsn1TestReal03(void) +{ int result = 0; uint8_t buf[261] = ""; /* universal class, primitive type, tag_num = 9 (Data type Real) */ @@ -1221,7 +1250,8 @@ end: * relative offset to check negative offset values, in this case * start decoding from -7 bytes respect the content match "John" */ -int DetectAsn1TestReal04(void) { +int DetectAsn1TestReal04(void) +{ int result = 0; uint8_t *buf = (uint8_t *) "\x60\x81\x85\x61\x10\x1A\x04""John""\x1A\x01" "P""\x1A\x05""Smith""\xA0\x0A\x1A\x08""Director" @@ -1299,7 +1329,8 @@ end: /** * \brief this function registers unit tests for DetectAsn1 */ -void DetectAsn1RegisterTests(void) { +void DetectAsn1RegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("DetectAsn1TestParse01", DetectAsn1TestParse01, 1); UtRegisterTest("DetectAsn1TestParse02", DetectAsn1TestParse02, 1); diff --git a/src/detect-bytejump.c b/src/detect-bytejump.c index 004c4fdb24..f138f74ad0 100644 --- a/src/detect-bytejump.c +++ b/src/detect-bytejump.c @@ -62,7 +62,8 @@ static pcre_extra *parse_regex_study; void DetectBytejumpRegisterTests(void); -void DetectBytejumpRegister (void) { +void DetectBytejumpRegister (void) +{ const char *eb; int eo; int opts = 0; @@ -759,7 +760,8 @@ void DetectBytejumpFree(void *ptr) * \test DetectBytejumpTestParse01 is a test to make sure that we return * "something" when given valid bytejump opt */ -int DetectBytejumpTestParse01(void) { +int DetectBytejumpTestParse01(void) +{ int result = 0; DetectBytejumpData *data = NULL; data = DetectBytejumpParse("4,0", NULL); @@ -774,7 +776,8 @@ int DetectBytejumpTestParse01(void) { /** * \test DetectBytejumpTestParse02 is a test for setting the required opts */ -int DetectBytejumpTestParse02(void) { +int DetectBytejumpTestParse02(void) +{ int result = 0; DetectBytejumpData *data = NULL; data = DetectBytejumpParse("4, 0", NULL); @@ -797,7 +800,8 @@ int DetectBytejumpTestParse02(void) { /** * \test DetectBytejumpTestParse03 is a test for setting the optional flags */ -int DetectBytejumpTestParse03(void) { +int DetectBytejumpTestParse03(void) +{ int result = 0; DetectBytejumpData *data = NULL; data = DetectBytejumpParse(" 4,0 , relative , little, string, " @@ -828,7 +832,8 @@ int DetectBytejumpTestParse03(void) { * * \todo This fails becuase we can only have 9 captures and there are 10. */ -int DetectBytejumpTestParse04(void) { +int DetectBytejumpTestParse04(void) +{ int result = 0; DetectBytejumpData *data = NULL; data = DetectBytejumpParse(" 4,0 , relative , little, string, " @@ -857,7 +862,8 @@ int DetectBytejumpTestParse04(void) { /** * \test DetectBytejumpTestParse05 is a test for setting base without string */ -int DetectBytejumpTestParse05(void) { +int DetectBytejumpTestParse05(void) +{ int result = 0; DetectBytejumpData *data = NULL; data = DetectBytejumpParse(" 4,0 , relative , little, dec, " @@ -872,7 +878,8 @@ int DetectBytejumpTestParse05(void) { /** * \test DetectBytejumpTestParse06 is a test for too many bytes to extract */ -int DetectBytejumpTestParse06(void) { +int DetectBytejumpTestParse06(void) +{ int result = 0; DetectBytejumpData *data = NULL; data = DetectBytejumpParse("9, 0", NULL); @@ -886,7 +893,8 @@ int DetectBytejumpTestParse06(void) { /** * \test DetectBytejumpTestParse07 is a test for too many string bytes to extract */ -int DetectBytejumpTestParse07(void) { +int DetectBytejumpTestParse07(void) +{ int result = 0; DetectBytejumpData *data = NULL; data = DetectBytejumpParse("24, 0, string, dec", NULL); @@ -900,7 +908,8 @@ int DetectBytejumpTestParse07(void) { /** * \test DetectBytejumpTestParse08 is a test for offset too big */ -int DetectBytejumpTestParse08(void) { +int DetectBytejumpTestParse08(void) +{ int result = 0; DetectBytejumpData *data = NULL; data = DetectBytejumpParse("4, 0xffffffffffffffff", NULL); @@ -914,7 +923,8 @@ int DetectBytejumpTestParse08(void) { /** * \test Test dce option. */ -int DetectBytejumpTestParse09(void) { +int DetectBytejumpTestParse09(void) +{ Signature *s = SigAlloc(); if (s == NULL) return 0; @@ -1201,7 +1211,8 @@ static int DetectBytejumpTestParse12(void) * byte_jump and byte_jump relative works if the previous keyword is pcre * (bug 142) */ -int DetectByteJumpTestPacket01 (void) { +int DetectByteJumpTestPacket01 (void) +{ int result = 0; uint8_t *buf = (uint8_t *)"GET /AllWorkAndNoPlayMakesWillADullBoy HTTP/1.0" "User-Agent: Wget/1.11.4" @@ -1232,7 +1243,8 @@ end: * byte_jump and byte_jump relative works if the previous keyword is byte_jump * (bug 165) */ -int DetectByteJumpTestPacket02 (void) { +int DetectByteJumpTestPacket02 (void) +{ int result = 0; uint8_t buf[] = { 0x00, 0x00, 0x00, 0x77, 0xff, 0x53, 0x4d, 0x42, 0x2f, 0x00, 0x00, 0x00, 0x00, 0x18, @@ -1294,7 +1306,8 @@ end: /** * \test check matches of with from_beginning (bug 626/627) */ -int DetectByteJumpTestPacket04 (void) { +int DetectByteJumpTestPacket04 (void) +{ int result = 0; uint8_t *buf = (uint8_t *)"XYZ04abcdABCD"; uint16_t buflen = strlen((char *)buf); @@ -1316,7 +1329,8 @@ end: /** * \test check matches of with from_beginning (bug 626/627) */ -int DetectByteJumpTestPacket05 (void) { +int DetectByteJumpTestPacket05 (void) +{ int result = 0; uint8_t *buf = (uint8_t *)"XYZ04abcdABCD"; uint16_t buflen = strlen((char *)buf); @@ -1338,7 +1352,8 @@ end: /** * \test check matches of with from_beginning (bug 626/627) */ -int DetectByteJumpTestPacket06 (void) { +int DetectByteJumpTestPacket06 (void) +{ int result = 0; uint8_t *buf = (uint8_t *)"XX04abcdABCD"; uint16_t buflen = strlen((char *)buf); @@ -1360,7 +1375,8 @@ end: /** * \test check matches of with from_beginning (bug 626/627) */ -int DetectByteJumpTestPacket07 (void) { +int DetectByteJumpTestPacket07 (void) +{ int result = 0; uint8_t *buf = (uint8_t *)"XX04abcdABCD"; uint16_t buflen = strlen((char *)buf); @@ -1385,7 +1401,8 @@ end: /** * \brief this function registers unit tests for DetectBytejump */ -void DetectBytejumpRegisterTests(void) { +void DetectBytejumpRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("DetectBytejumpTestParse01", DetectBytejumpTestParse01, 1); UtRegisterTest("DetectBytejumpTestParse02", DetectBytejumpTestParse02, 1); diff --git a/src/detect-bytetest.c b/src/detect-bytetest.c index 25d731fb4d..718a84788e 100644 --- a/src/detect-bytetest.c +++ b/src/detect-bytetest.c @@ -64,7 +64,8 @@ static pcre_extra *parse_regex_study; void DetectBytetestRegisterTests(void); -void DetectBytetestRegister (void) { +void DetectBytetestRegister (void) +{ const char *eb; int eo; int opts = 0; @@ -111,7 +112,8 @@ error: * \retval 0 no match */ int DetectBytetestDoMatch(DetectEngineThreadCtx *det_ctx, Signature *s, SigMatch *m, uint8_t *payload, uint32_t payload_len, - uint8_t flags, int32_t offset, uint64_t value) { + uint8_t flags, int32_t offset, uint64_t value) +{ SCEnter(); DetectBytetestData *data = (DetectBytetestData *)m->ctx; @@ -694,7 +696,8 @@ void DetectBytetestFree(void *ptr) * \test DetectBytetestTestParse01 is a test to make sure that we return "something" * when given valid bytetest opt */ -int DetectBytetestTestParse01(void) { +int DetectBytetestTestParse01(void) +{ int result = 0; DetectBytetestData *data = NULL; data = DetectBytetestParse("4, =, 1 , 0", NULL, NULL); @@ -709,7 +712,8 @@ int DetectBytetestTestParse01(void) { /** * \test DetectBytetestTestParse02 is a test for setting the required opts */ -int DetectBytetestTestParse02(void) { +int DetectBytetestTestParse02(void) +{ int result = 0; DetectBytetestData *data = NULL; data = DetectBytetestParse("4, !=, 1, 0", NULL, NULL); @@ -732,7 +736,8 @@ int DetectBytetestTestParse02(void) { /** * \test DetectBytetestTestParse03 is a test for setting the relative flag */ -int DetectBytetestTestParse03(void) { +int DetectBytetestTestParse03(void) +{ int result = 0; DetectBytetestData *data = NULL; data = DetectBytetestParse("4, !=, 1, 0, relative", NULL, NULL); @@ -756,7 +761,8 @@ int DetectBytetestTestParse03(void) { /** * \test DetectBytetestTestParse04 is a test for setting the string/oct flags */ -int DetectBytetestTestParse04(void) { +int DetectBytetestTestParse04(void) +{ int result = 0; DetectBytetestData *data = NULL; data = DetectBytetestParse("4, !=, 1, 0, string, oct", NULL, NULL); @@ -780,7 +786,8 @@ int DetectBytetestTestParse04(void) { /** * \test DetectBytetestTestParse05 is a test for setting the string/dec flags */ -int DetectBytetestTestParse05(void) { +int DetectBytetestTestParse05(void) +{ int result = 0; DetectBytetestData *data = NULL; data = DetectBytetestParse("4, =, 1, 0, string, dec", NULL, NULL); @@ -803,7 +810,8 @@ int DetectBytetestTestParse05(void) { /** * \test DetectBytetestTestParse06 is a test for setting the string/hex flags */ -int DetectBytetestTestParse06(void) { +int DetectBytetestTestParse06(void) +{ int result = 0; DetectBytetestData *data = NULL; data = DetectBytetestParse("4, >, 1, 0, string, hex", NULL, NULL); @@ -826,7 +834,8 @@ int DetectBytetestTestParse06(void) { /** * \test DetectBytetestTestParse07 is a test for setting the big flag */ -int DetectBytetestTestParse07(void) { +int DetectBytetestTestParse07(void) +{ int result = 0; DetectBytetestData *data = NULL; data = DetectBytetestParse("4, <, 5, 0, big", NULL, NULL); @@ -849,7 +858,8 @@ int DetectBytetestTestParse07(void) { /** * \test DetectBytetestTestParse08 is a test for setting the little flag */ -int DetectBytetestTestParse08(void) { +int DetectBytetestTestParse08(void) +{ int result = 0; DetectBytetestData *data = NULL; data = DetectBytetestParse("4, <, 5, 0, little", NULL, NULL); @@ -872,7 +882,8 @@ int DetectBytetestTestParse08(void) { /** * \test DetectBytetestTestParse09 is a test for neg operator only */ -int DetectBytetestTestParse09(void) { +int DetectBytetestTestParse09(void) +{ int result = 0; DetectBytetestData *data = NULL; data = DetectBytetestParse("4, !, 5, 0", NULL, NULL); @@ -895,7 +906,8 @@ int DetectBytetestTestParse09(void) { /** * \test DetectBytetestTestParse10 is a test for whitespace */ -int DetectBytetestTestParse10(void) { +int DetectBytetestTestParse10(void) +{ int result = 0; DetectBytetestData *data = NULL; data = DetectBytetestParse(" 4 , ! &, 5 , 0 , little ", NULL, NULL); @@ -918,7 +930,8 @@ int DetectBytetestTestParse10(void) { /** * \test DetectBytetestTestParse11 is a test for whitespace */ -int DetectBytetestTestParse11(void) { +int DetectBytetestTestParse11(void) +{ int result = 0; DetectBytetestData *data = NULL; data = DetectBytetestParse("4,!^,5,0,little,string,relative,hex", NULL, NULL); @@ -944,7 +957,8 @@ int DetectBytetestTestParse11(void) { /** * \test DetectBytetestTestParse12 is a test for hex w/o string */ -int DetectBytetestTestParse12(void) { +int DetectBytetestTestParse12(void) +{ int result = 0; DetectBytetestData *data = NULL; data = DetectBytetestParse("4, =, 1, 0, hex", NULL, NULL); @@ -958,7 +972,8 @@ int DetectBytetestTestParse12(void) { /** * \test DetectBytetestTestParse13 is a test for too many bytes to extract */ -int DetectBytetestTestParse13(void) { +int DetectBytetestTestParse13(void) +{ int result = 0; DetectBytetestData *data = NULL; data = DetectBytetestParse("9, =, 1, 0", NULL, NULL); @@ -972,7 +987,8 @@ int DetectBytetestTestParse13(void) { /** * \test DetectBytetestTestParse14 is a test for large string extraction */ -int DetectBytetestTestParse14(void) { +int DetectBytetestTestParse14(void) +{ int result = 0; DetectBytetestData *data = NULL; data = DetectBytetestParse("23,=,0xffffffffffffffffULL,0,string,oct", NULL, NULL); @@ -995,7 +1011,8 @@ int DetectBytetestTestParse14(void) { /** * \test DetectBytetestTestParse15 is a test for too many bytes to extract (string) */ -int DetectBytetestTestParse15(void) { +int DetectBytetestTestParse15(void) +{ int result = 0; DetectBytetestData *data = NULL; data = DetectBytetestParse("24, =, 0xffffffffffffffffULL, 0, string", NULL, NULL); @@ -1009,7 +1026,8 @@ int DetectBytetestTestParse15(void) { /** * \test DetectBytetestTestParse16 is a test for offset too big */ -int DetectBytetestTestParse16(void) { +int DetectBytetestTestParse16(void) +{ int result = 0; DetectBytetestData *data = NULL; data = DetectBytetestParse("4,=,0,0xffffffffffffffffULL", NULL, NULL); @@ -1023,7 +1041,8 @@ int DetectBytetestTestParse16(void) { /** * \test Test dce option. */ -int DetectBytetestTestParse17(void) { +int DetectBytetestTestParse17(void) +{ int result = 0; DetectBytetestData *data = NULL; data = DetectBytetestParse("4, <, 5, 0, dce", NULL, NULL); @@ -1044,7 +1063,8 @@ int DetectBytetestTestParse17(void) { /** * \test Test dce option. */ -int DetectBytetestTestParse18(void) { +int DetectBytetestTestParse18(void) +{ int result = 0; DetectBytetestData *data = NULL; data = DetectBytetestParse("4, <, 5, 0", NULL, NULL); @@ -1065,7 +1085,8 @@ int DetectBytetestTestParse18(void) { /** * \test Test dce option. */ -int DetectBytetestTestParse19(void) { +int DetectBytetestTestParse19(void) +{ Signature *s = SigAlloc(); if (s == NULL) return 0; @@ -1369,7 +1390,8 @@ static int DetectBytetestTestParse22(void) * byte_test and byte_test relative works if the previous keyword is pcre * (bug 142) */ -int DetectByteTestTestPacket01 (void) { +int DetectByteTestTestPacket01 (void) +{ int result = 0; uint8_t *buf = (uint8_t *)"GET /AllWorkAndNoPlayMakesWillADullBoy HTTP/1.0" "User-Agent: Wget/1.11.4" @@ -1400,7 +1422,8 @@ end: * byte_test and byte_test relative works if the previous keyword is byte_jump * (bug 158) */ -int DetectByteTestTestPacket02 (void) { +int DetectByteTestTestPacket02 (void) +{ int result = 0; uint8_t *buf = (uint8_t *)"GET /AllWorkAndNoPlayMakesWillADullBoy HTTP/1.0" "User-Agent: Wget/1.11.4" @@ -1522,7 +1545,8 @@ end: /** * \brief this function registers unit tests for DetectBytetest */ -void DetectBytetestRegisterTests(void) { +void DetectBytetestRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("DetectBytetestTestParse01", DetectBytetestTestParse01, 1); UtRegisterTest("DetectBytetestTestParse02", DetectBytetestTestParse02, 1); diff --git a/src/detect-content.c b/src/detect-content.c index d42f22ccad..64500e391b 100644 --- a/src/detect-content.c +++ b/src/detect-content.c @@ -52,7 +52,8 @@ int DetectContentMatch (ThreadVars *, DetectEngineThreadCtx *, Packet *, Signatu int DetectContentSetup(DetectEngineCtx *, Signature *, char *); void DetectContentRegisterTests(void); -void DetectContentRegister (void) { +void DetectContentRegister (void) +{ sigmatch_table[DETECT_CONTENT].name = "content"; sigmatch_table[DETECT_CONTENT].desc = "match on payload content"; sigmatch_table[DETECT_CONTENT].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/Payload_keywords#Content"; @@ -65,7 +66,8 @@ void DetectContentRegister (void) { } /* pass on the content_max_id */ -uint32_t DetectContentMaxId(DetectEngineCtx *de_ctx) { +uint32_t DetectContentMaxId(DetectEngineCtx *de_ctx) +{ return MpmPatternIdStoreGetMaxId(de_ctx->mpm_pattern_id_store); } @@ -418,7 +420,8 @@ error: * * \param cd pointer to DetectCotentData */ -void DetectContentFree(void *ptr) { +void DetectContentFree(void *ptr) +{ SCEnter(); DetectContentData *cd = (DetectContentData *)ptr; @@ -436,7 +439,8 @@ void DetectContentFree(void *ptr) { /** * \test DetectCotentParseTest01 this is a test to make sure we can deal with escaped colons */ -int DetectContentParseTest01 (void) { +int DetectContentParseTest01 (void) +{ int result = 1; DetectContentData *cd = NULL; char *teststring = "\"abc\\:def\""; @@ -461,7 +465,8 @@ int DetectContentParseTest01 (void) { /** * \test DetectCotentParseTest02 this is a test to make sure we can deal with escaped semi-colons */ -int DetectContentParseTest02 (void) { +int DetectContentParseTest02 (void) +{ int result = 1; DetectContentData *cd = NULL; char *teststring = "\"abc\\;def\""; @@ -486,7 +491,8 @@ int DetectContentParseTest02 (void) { /** * \test DetectCotentParseTest03 this is a test to make sure we can deal with escaped double-quotes */ -int DetectContentParseTest03 (void) { +int DetectContentParseTest03 (void) +{ int result = 1; DetectContentData *cd = NULL; char *teststring = "\"abc\\\"def\""; @@ -511,7 +517,8 @@ int DetectContentParseTest03 (void) { /** * \test DetectCotentParseTest04 this is a test to make sure we can deal with escaped backslashes */ -int DetectContentParseTest04 (void) { +int DetectContentParseTest04 (void) +{ int result = 1; DetectContentData *cd = NULL; char *teststring = "\"abc\\\\def\""; @@ -537,7 +544,8 @@ int DetectContentParseTest04 (void) { /** * \test DetectCotentParseTest05 test illegal escape */ -int DetectContentParseTest05 (void) { +int DetectContentParseTest05 (void) +{ int result = 1; DetectContentData *cd = NULL; char *teststring = "\"abc\\def\""; @@ -556,7 +564,8 @@ int DetectContentParseTest05 (void) { /** * \test DetectCotentParseTest06 test a binary content */ -int DetectContentParseTest06 (void) { +int DetectContentParseTest06 (void) +{ int result = 1; DetectContentData *cd = NULL; char *teststring = "\"a|42|c|44|e|46|\""; @@ -582,7 +591,8 @@ int DetectContentParseTest06 (void) { /** * \test DetectCotentParseTest07 test an empty content */ -int DetectContentParseTest07 (void) { +int DetectContentParseTest07 (void) +{ int result = 1; DetectContentData *cd = NULL; char *teststring = "\"\""; @@ -599,7 +609,8 @@ int DetectContentParseTest07 (void) { /** * \test DetectCotentParseTest08 test an empty content */ -int DetectContentParseTest08 (void) { +int DetectContentParseTest08 (void) +{ int result = 1; DetectContentData *cd = NULL; char *teststring = "\"\""; @@ -694,7 +705,8 @@ end: /** * \brief Wrapper for DetectContentLongPatternMatchTest */ -int DetectContentLongPatternMatchTestWrp(char *sig, uint32_t sid) { +int DetectContentLongPatternMatchTestWrp(char *sig, uint32_t sid) +{ /** Real packet with the following tcp data: * "Hi, this is a big test to check content matches of splitted" * "patterns between multiple chunks!" @@ -882,7 +894,8 @@ int DetectContentLongPatternMatchTest11() return DetectContentLongPatternMatchTestWrp(sig, 1); } -int DetectContentParseTest09(void) { +int DetectContentParseTest09(void) +{ int result = 0; DetectContentData *cd = NULL; char *teststring = "!\"boo\""; @@ -898,7 +911,8 @@ int DetectContentParseTest09(void) { return result; } -int DetectContentParseTest10(void) { +int DetectContentParseTest10(void) +{ int result = 0; DetectContentData *cd = NULL; char *teststring = "!\"boo\""; @@ -913,7 +927,8 @@ int DetectContentParseTest10(void) { return result; } -int DetectContentParseNegTest11(void) { +int DetectContentParseNegTest11(void) +{ int result = 0; DetectContentData *cd = NULL; char *teststring = "\"boo\""; @@ -928,7 +943,8 @@ int DetectContentParseNegTest11(void) { return result; } -int DetectContentParseNegTest12(void) { +int DetectContentParseNegTest12(void) +{ int result = 0; DetectContentData *cd = NULL; char *teststring = "\"boo\""; @@ -943,7 +959,8 @@ int DetectContentParseNegTest12(void) { return result; } -int DetectContentParseNegTest13(void) { +int DetectContentParseNegTest13(void) +{ int result = 0; DetectContentData *cd = NULL; char *teststring = "!\"boo\""; @@ -958,7 +975,8 @@ int DetectContentParseNegTest13(void) { return result; } -int DetectContentParseNegTest14(void) { +int DetectContentParseNegTest14(void) +{ int result = 0; DetectContentData *cd = NULL; char *teststring = " \"!boo\""; @@ -973,7 +991,8 @@ int DetectContentParseNegTest14(void) { return result; } -int DetectContentParseNegTest15(void) { +int DetectContentParseNegTest15(void) +{ int result = 0; DetectContentData *cd = NULL; char *teststring = " !\"boo\""; @@ -988,7 +1007,8 @@ int DetectContentParseNegTest15(void) { return result; } -int DetectContentParseNegTest16(void) { +int DetectContentParseNegTest16(void) +{ int result = 0; DetectContentData *cd = NULL; char *teststring = " \"boo\""; diff --git a/src/detect-csum.c b/src/detect-csum.c index 5e0d5476c8..b6dc16c2a1 100644 --- a/src/detect-csum.c +++ b/src/detect-csum.c @@ -995,7 +995,8 @@ int DetectCsumICMPV4ValidArgsTestParse01(void) return result; } -int DetectCsumICMPV4InValidArgsTestParse02(void) { +int DetectCsumICMPV4InValidArgsTestParse02(void) +{ Signature s; int result = -1; SigMatch *temp = NULL; @@ -1018,7 +1019,8 @@ int DetectCsumICMPV4InValidArgsTestParse02(void) { return result; } -int DetectCsumICMPV4ValidArgsTestParse03(void) { +int DetectCsumICMPV4ValidArgsTestParse03(void) +{ Signature s; DetectCsumData *cd = NULL; int result = 0; @@ -1080,7 +1082,8 @@ int DetectCsumTCPV4ValidArgsTestParse01(void) return result; } -int DetectCsumTCPV4InValidArgsTestParse02(void) { +int DetectCsumTCPV4InValidArgsTestParse02(void) +{ Signature s; int result = -1; SigMatch *temp = NULL; @@ -1103,7 +1106,8 @@ int DetectCsumTCPV4InValidArgsTestParse02(void) { return result; } -int DetectCsumTCPV4ValidArgsTestParse03(void) { +int DetectCsumTCPV4ValidArgsTestParse03(void) +{ Signature s; DetectCsumData *cd = NULL; int result = 0; @@ -1165,7 +1169,8 @@ int DetectCsumUDPV4ValidArgsTestParse01(void) return result; } -int DetectCsumUDPV4InValidArgsTestParse02(void) { +int DetectCsumUDPV4InValidArgsTestParse02(void) +{ Signature s; int result = -1; SigMatch *temp = NULL; @@ -1188,7 +1193,8 @@ int DetectCsumUDPV4InValidArgsTestParse02(void) { return result; } -int DetectCsumUDPV4ValidArgsTestParse03(void) { +int DetectCsumUDPV4ValidArgsTestParse03(void) +{ Signature s; DetectCsumData *cd = NULL; int result = 0; @@ -1250,7 +1256,8 @@ int DetectCsumTCPV6ValidArgsTestParse01(void) return result; } -int DetectCsumTCPV6InValidArgsTestParse02(void) { +int DetectCsumTCPV6InValidArgsTestParse02(void) +{ Signature s; int result = -1; SigMatch *temp = NULL; @@ -1273,7 +1280,8 @@ int DetectCsumTCPV6InValidArgsTestParse02(void) { return result; } -int DetectCsumTCPV6ValidArgsTestParse03(void) { +int DetectCsumTCPV6ValidArgsTestParse03(void) +{ Signature s; DetectCsumData *cd = NULL; int result = 0; @@ -1335,7 +1343,8 @@ int DetectCsumUDPV6ValidArgsTestParse01(void) return result; } -int DetectCsumUDPV6InValidArgsTestParse02(void) { +int DetectCsumUDPV6InValidArgsTestParse02(void) +{ Signature s; int result = -1; SigMatch *temp = NULL; @@ -1358,7 +1367,8 @@ int DetectCsumUDPV6InValidArgsTestParse02(void) { return result; } -int DetectCsumUDPV6ValidArgsTestParse03(void) { +int DetectCsumUDPV6ValidArgsTestParse03(void) +{ Signature s; DetectCsumData *cd = NULL; int result = 0; @@ -1420,7 +1430,8 @@ int DetectCsumICMPV6ValidArgsTestParse01(void) return result; } -int DetectCsumICMPV6InValidArgsTestParse02(void) { +int DetectCsumICMPV6InValidArgsTestParse02(void) +{ Signature s; int result = -1; SigMatch *temp = NULL; @@ -1443,7 +1454,8 @@ int DetectCsumICMPV6InValidArgsTestParse02(void) { return result; } -int DetectCsumICMPV6ValidArgsTestParse03(void) { +int DetectCsumICMPV6ValidArgsTestParse03(void) +{ Signature s; DetectCsumData *cd = NULL; int result = 0; diff --git a/src/detect-depth.c b/src/detect-depth.c index b075f1656f..53adf46063 100644 --- a/src/detect-depth.c +++ b/src/detect-depth.c @@ -42,7 +42,8 @@ static int DetectDepthSetup (DetectEngineCtx *, Signature *, char *); -void DetectDepthRegister (void) { +void DetectDepthRegister (void) +{ sigmatch_table[DETECT_DEPTH].name = "depth"; sigmatch_table[DETECT_DEPTH].desc = "designate how many bytes from the beginning of the payload will be checked"; sigmatch_table[DETECT_DEPTH].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/Payload_keywords#Depth"; diff --git a/src/detect-detection-filter.c b/src/detect-detection-filter.c index 6d9e6c7ee5..40cf0b2781 100644 --- a/src/detect-detection-filter.c +++ b/src/detect-detection-filter.c @@ -59,7 +59,8 @@ void DetectDetectionFilterFree(void *); /** * \brief Registration function for detection_filter: keyword */ -void DetectDetectionFilterRegister (void) { +void DetectDetectionFilterRegister (void) +{ sigmatch_table[DETECT_DETECTION_FILTER].name = "detection_filter"; sigmatch_table[DETECT_DETECTION_FILTER].desc = "alert on every match after a threshold has been reached"; sigmatch_table[DETECT_DETECTION_FILTER].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/Rule-Thresholding#detection_filter"; @@ -93,7 +94,8 @@ error: return; } -int DetectDetectionFilterMatch (ThreadVars *thv, DetectEngineThreadCtx *det_ctx, Packet *p, Signature *s, SigMatch *sm) { +int DetectDetectionFilterMatch (ThreadVars *thv, DetectEngineThreadCtx *det_ctx, Packet *p, Signature *s, SigMatch *sm) +{ return 1; } @@ -106,7 +108,8 @@ int DetectDetectionFilterMatch (ThreadVars *thv, DetectEngineThreadCtx *det_ctx, * \retval df pointer to DetectThresholdData on success * \retval NULL on failure */ -DetectThresholdData *DetectDetectionFilterParse (char *rawstr) { +DetectThresholdData *DetectDetectionFilterParse (char *rawstr) +{ DetectThresholdData *df = NULL; #define MAX_SUBSTRINGS 30 int ret = 0, res = 0; @@ -219,7 +222,8 @@ error: * \retval 0 on Success * \retval -1 on Failure */ -int DetectDetectionFilterSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr) { +int DetectDetectionFilterSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr) +{ SCEnter(); DetectThresholdData *df = NULL; SigMatch *sm = NULL; @@ -267,7 +271,8 @@ error: * * \param df_ptr pointer to DetectDetectionFilterData */ -void DetectDetectionFilterFree(void *df_ptr) { +void DetectDetectionFilterFree(void *df_ptr) +{ DetectThresholdData *df = (DetectThresholdData *)df_ptr; if (df) SCFree(df); } @@ -290,7 +295,8 @@ void DetectDetectionFilterFree(void *df_ptr) { * \retval 1 on succces * \retval 0 on failure */ -int DetectDetectionFilterTestParse01 (void) { +int DetectDetectionFilterTestParse01 (void) +{ DetectThresholdData *df = NULL; df = DetectDetectionFilterParse("track by_dst,count 10,seconds 60"); if (df && (df->track == TRACK_DST) && (df->count == 10) && (df->seconds == 60)) { @@ -307,7 +313,8 @@ int DetectDetectionFilterTestParse01 (void) { * \retval 1 on succces * \retval 0 on failure */ -int DetectDetectionFilterTestParse02 (void) { +int DetectDetectionFilterTestParse02 (void) +{ DetectThresholdData *df = NULL; df = DetectDetectionFilterParse("track both,count 10,seconds 60"); if (df && (df->track == TRACK_DST || df->track == TRACK_SRC) && (df->count == 10) && (df->seconds == 60)) { @@ -324,7 +331,8 @@ int DetectDetectionFilterTestParse02 (void) { * \retval 1 on succces * \retval 0 on failure */ -int DetectDetectionFilterTestParse03 (void) { +int DetectDetectionFilterTestParse03 (void) +{ DetectThresholdData *df = NULL; df = DetectDetectionFilterParse("track by_dst, seconds 60, count 10"); if (df && (df->track == TRACK_DST) && (df->count == 10) && (df->seconds == 60)) { @@ -342,7 +350,8 @@ int DetectDetectionFilterTestParse03 (void) { * \retval 1 on succces * \retval 0 on failure */ -int DetectDetectionFilterTestParse04 (void) { +int DetectDetectionFilterTestParse04 (void) +{ DetectThresholdData *df = NULL; df = DetectDetectionFilterParse("count 10, track by_dst, seconds 60, count 10"); if (df && (df->track == TRACK_DST) && (df->count == 10) && (df->seconds == 60)) { @@ -359,7 +368,8 @@ int DetectDetectionFilterTestParse04 (void) { * \retval 1 on succces * \retval 0 on failure */ -int DetectDetectionFilterTestParse05 (void) { +int DetectDetectionFilterTestParse05 (void) +{ DetectThresholdData *df = NULL; df = DetectDetectionFilterParse("count 10, track by_dst, seconds 60"); if (df && (df->track == TRACK_DST) && (df->count == 10) && (df->seconds == 60)) { @@ -376,7 +386,8 @@ int DetectDetectionFilterTestParse05 (void) { * \retval 1 on succces * \retval 0 on failure */ -int DetectDetectionFilterTestParse06 (void) { +int DetectDetectionFilterTestParse06 (void) +{ DetectThresholdData *df = NULL; df = DetectDetectionFilterParse("count 10, track by_dst, seconds 0"); if (df && (df->track == TRACK_DST) && (df->count == 10) && (df->seconds == 0)) { @@ -395,7 +406,8 @@ int DetectDetectionFilterTestParse06 (void) { * \retval 1 on succces * \retval 0 on failure */ -static int DetectDetectionFilterTestSig1(void) { +static int DetectDetectionFilterTestSig1(void) +{ Packet *p = NULL; Signature *s = NULL; ThreadVars th_v; @@ -465,7 +477,8 @@ end: * \retval 0 on failure */ -static int DetectDetectionFilterTestSig2(void) { +static int DetectDetectionFilterTestSig2(void) +{ Packet *p = NULL; Signature *s = NULL; ThreadVars th_v; @@ -536,7 +549,8 @@ end: /** * \test drops */ -static int DetectDetectionFilterTestSig3(void) { +static int DetectDetectionFilterTestSig3(void) +{ Packet *p = NULL; Signature *s = NULL; ThreadVars th_v; @@ -631,7 +645,8 @@ end: } #endif /* UNITTESTS */ -void DetectDetectionFilterRegisterTests(void) { +void DetectDetectionFilterRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("DetectDetectionFilterTestParse01", DetectDetectionFilterTestParse01, 1); UtRegisterTest("DetectDetectionFilterTestParse02", DetectDetectionFilterTestParse02, 0); diff --git a/src/detect-distance.c b/src/detect-distance.c index d0ab9e96c6..2877deead8 100644 --- a/src/detect-distance.c +++ b/src/detect-distance.c @@ -236,7 +236,8 @@ end: * distance works, if the previous keyword is byte_jump and content * (bug 163) */ -int DetectDistanceTestPacket01 (void) { +int DetectDistanceTestPacket01 (void) +{ int result = 0; uint8_t buf[] = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 }; uint16_t buflen = sizeof(buf); @@ -259,7 +260,8 @@ end: } #endif /* UNITTESTS */ -void DetectDistanceRegisterTests(void) { +void DetectDistanceRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("DetectDistanceTest01 -- distance / within mix", DetectDistanceTest01, 1); UtRegisterTest("DetectDistanceTestPacket01", DetectDistanceTestPacket01, 1); diff --git a/src/detect-dns-query.c b/src/detect-dns-query.c index f1e739f658..8f06fa1948 100644 --- a/src/detect-dns-query.c +++ b/src/detect-dns-query.c @@ -64,7 +64,8 @@ static void DetectDnsQueryRegisterTests(void); /** * \brief Registration function for keyword: http_uri */ -void DetectDnsQueryRegister (void) { +void DetectDnsQueryRegister (void) +{ sigmatch_table[DETECT_AL_DNS_QUERY].name = "dns_query"; sigmatch_table[DETECT_AL_DNS_QUERY].desc = "content modifier to match specifically and only on the DNS query-buffer"; sigmatch_table[DETECT_AL_DNS_QUERY].Match = NULL; @@ -133,7 +134,8 @@ uint32_t DetectDnsQueryInspectMpm(DetectEngineThreadCtx *det_ctx, Flow *f, #ifdef UNITTESTS /** \test simple google.com query matching */ -static int DetectDnsQueryTest01(void) { +static int DetectDnsQueryTest01(void) +{ /* google.com */ uint8_t buf[] = { 0x10, 0x32, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -224,7 +226,8 @@ end: } /** \test multi tx google.(com|net) query matching */ -static int DetectDnsQueryTest02(void) { +static int DetectDnsQueryTest02(void) +{ /* google.com */ uint8_t buf1[] = { 0x10, 0x32, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -409,7 +412,8 @@ end: } /** \test simple google.com query matching (TCP) */ -static int DetectDnsQueryTest03(void) { +static int DetectDnsQueryTest03(void) +{ /* google.com */ uint8_t buf[] = { 0x00, 28, 0x10, 0x32, 0x01, 0x00, 0x00, 0x01, @@ -507,7 +511,8 @@ end: } /** \test simple google.com query matching (TCP splicing) */ -static int DetectDnsQueryTest04(void) { +static int DetectDnsQueryTest04(void) +{ /* google.com */ uint8_t buf1[] = { 0x00, 28, 0x10, 0x32, 0x01, 0x00, 0x00, 0x01, @@ -630,7 +635,8 @@ end: } /** \test simple google.com query matching (TCP splicing) */ -static int DetectDnsQueryTest05(void) { +static int DetectDnsQueryTest05(void) +{ /* google.com in 2 chunks (buf1 and buf2) */ uint8_t buf1[] = { 0x00, 28, /* len 28 */ 0x10, 0x32, 0x01, 0x00, 0x00, 0x01, @@ -851,7 +857,8 @@ end: } /** \test simple google.com query matching, pcre */ -static int DetectDnsQueryTest06(void) { +static int DetectDnsQueryTest06(void) +{ /* google.com */ uint8_t buf[] = { 0x10, 0x32, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -956,7 +963,8 @@ end: /** \test multi tx google.(com|net) query matching + * app layer event */ -static int DetectDnsQueryTest07(void) { +static int DetectDnsQueryTest07(void) +{ /* google.com */ uint8_t buf1[] = { 0x10, 0x32, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -1157,7 +1165,8 @@ end: #endif -static void DetectDnsQueryRegisterTests(void) { +static void DetectDnsQueryRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("DetectDnsQueryTest01", DetectDnsQueryTest01, 1); UtRegisterTest("DetectDnsQueryTest02", DetectDnsQueryTest02, 1); diff --git a/src/detect-dsize.c b/src/detect-dsize.c index fc007ac47d..3e971f5190 100644 --- a/src/detect-dsize.c +++ b/src/detect-dsize.c @@ -56,7 +56,8 @@ static void DetectDsizeFree(void *); /** * \brief Registration function for dsize: keyword */ -void DetectDsizeRegister (void) { +void DetectDsizeRegister (void) +{ sigmatch_table[DETECT_DSIZE].name = "dsize"; sigmatch_table[DETECT_DSIZE].desc = "match on the size of the packet payload"; sigmatch_table[DETECT_DSIZE].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/Payload_keywords#Dsize"; @@ -310,7 +311,8 @@ error: * * \param de pointer to DetectDsizeData */ -void DetectDsizeFree(void *de_ptr) { +void DetectDsizeFree(void *de_ptr) +{ DetectDsizeData *dd = (DetectDsizeData *)de_ptr; if(dd) SCFree(dd); } @@ -328,7 +330,8 @@ void DetectDsizeFree(void *de_ptr) { * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse01 (void) { +int DsizeTestParse01 (void) +{ DetectDsizeData *dd = NULL; dd = DetectDsizeParse("1"); if (dd) { @@ -345,7 +348,8 @@ int DsizeTestParse01 (void) { * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse02 (void) { +int DsizeTestParse02 (void) +{ DetectDsizeData *dd = NULL; dd = DetectDsizeParse(">10"); if (dd) { @@ -362,7 +366,8 @@ int DsizeTestParse02 (void) { * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse03 (void) { +int DsizeTestParse03 (void) +{ DetectDsizeData *dd = NULL; dd = DetectDsizeParse("<100"); if (dd) { @@ -379,7 +384,8 @@ int DsizeTestParse03 (void) { * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse04 (void) { +int DsizeTestParse04 (void) +{ DetectDsizeData *dd = NULL; dd = DetectDsizeParse("1<>2"); if (dd) { @@ -396,7 +402,8 @@ int DsizeTestParse04 (void) { * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse05 (void) { +int DsizeTestParse05 (void) +{ int result = 0; DetectDsizeData *dd = NULL; dd = DetectDsizeParse("1"); @@ -416,7 +423,8 @@ int DsizeTestParse05 (void) { * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse06 (void) { +int DsizeTestParse06 (void) +{ int result = 0; DetectDsizeData *dd = NULL; dd = DetectDsizeParse(">10"); @@ -436,7 +444,8 @@ int DsizeTestParse06 (void) { * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse07 (void) { +int DsizeTestParse07 (void) +{ int result = 0; DetectDsizeData *dd = NULL; dd = DetectDsizeParse("<100"); @@ -456,7 +465,8 @@ int DsizeTestParse07 (void) { * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse08 (void) { +int DsizeTestParse08 (void) +{ int result = 0; DetectDsizeData *dd = NULL; dd = DetectDsizeParse("1<>2"); @@ -476,7 +486,8 @@ int DsizeTestParse08 (void) { * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse09 (void) { +int DsizeTestParse09 (void) +{ DetectDsizeData *dd = NULL; dd = DetectDsizeParse("A"); if (dd) { @@ -493,7 +504,8 @@ int DsizeTestParse09 (void) { * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse10 (void) { +int DsizeTestParse10 (void) +{ DetectDsizeData *dd = NULL; dd = DetectDsizeParse(">10<>10"); if (dd) { @@ -510,7 +522,8 @@ int DsizeTestParse10 (void) { * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse11 (void) { +int DsizeTestParse11 (void) +{ DetectDsizeData *dd = NULL; dd = DetectDsizeParse("<>10"); if (dd) { @@ -527,7 +540,8 @@ int DsizeTestParse11 (void) { * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse12 (void) { +int DsizeTestParse12 (void) +{ DetectDsizeData *dd = NULL; dd = DetectDsizeParse("1<>"); if (dd) { @@ -544,7 +558,8 @@ int DsizeTestParse12 (void) { * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse13 (void) { +int DsizeTestParse13 (void) +{ int result = 0; DetectDsizeData *dd = NULL; dd = DetectDsizeParse("1"); @@ -564,7 +579,8 @@ int DsizeTestParse13 (void) { * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse14 (void) { +int DsizeTestParse14 (void) +{ DetectDsizeData *dd = NULL; dd = DetectDsizeParse(""); if (dd) { @@ -581,7 +597,8 @@ int DsizeTestParse14 (void) { * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse15 (void) { +int DsizeTestParse15 (void) +{ DetectDsizeData *dd = NULL; dd = DetectDsizeParse(" "); if (dd) { @@ -598,7 +615,8 @@ int DsizeTestParse15 (void) { * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse16 (void) { +int DsizeTestParse16 (void) +{ DetectDsizeData *dd = NULL; dd = DetectDsizeParse("2<>1"); if (dd) { @@ -615,7 +633,8 @@ int DsizeTestParse16 (void) { * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse17 (void) { +int DsizeTestParse17 (void) +{ int result = 0; DetectDsizeData *dd = NULL; dd = DetectDsizeParse(" 1 <> 2 "); @@ -635,7 +654,8 @@ int DsizeTestParse17 (void) { * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse18 (void) { +int DsizeTestParse18 (void) +{ int result = 0; DetectDsizeData *dd = NULL; dd = DetectDsizeParse("> 2 "); @@ -655,7 +675,8 @@ int DsizeTestParse18 (void) { * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse19 (void) { +int DsizeTestParse19 (void) +{ int result = 0; DetectDsizeData *dd = NULL; dd = DetectDsizeParse("< 12 "); @@ -675,7 +696,8 @@ int DsizeTestParse19 (void) { * \retval 1 on succces * \retval 0 on failure */ -int DsizeTestParse20 (void) { +int DsizeTestParse20 (void) +{ int result = 0; DetectDsizeData *dd = NULL; dd = DetectDsizeParse(" 12 "); @@ -694,7 +716,8 @@ 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) { +int DetectDsizeIcmpv6Test01 (void) +{ int result = 0; static uint8_t raw_icmpv6[] = { @@ -785,7 +808,8 @@ end: /** * \brief this function registers unit tests for dsize */ -void DsizeRegisterTests(void) { +void DsizeRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("DsizeTestParse01", DsizeTestParse01, 1); UtRegisterTest("DsizeTestParse02", DsizeTestParse02, 1); diff --git a/src/detect-engine-address-ipv6.c b/src/detect-engine-address-ipv6.c index 068e64b97f..84a04d5933 100644 --- a/src/detect-engine-address-ipv6.c +++ b/src/detect-engine-address-ipv6.c @@ -62,7 +62,8 @@ int AddressIPv6Lt(Address *a, Address *b) return 0; } -int AddressIPv6LtU32(uint32_t *a, uint32_t *b) { +int AddressIPv6LtU32(uint32_t *a, uint32_t *b) +{ int i = 0; for (i = 0; i < 4; i++) { diff --git a/src/detect-engine-address.c b/src/detect-engine-address.c index 1841dc190b..44a96a8e2a 100644 --- a/src/detect-engine-address.c +++ b/src/detect-engine-address.c @@ -1613,7 +1613,8 @@ int DetectAddressCmp(DetectAddress *a, DetectAddress *b) * * \todo array should be ordered, so we can break out of the loop */ -int DetectAddressMatchIPv4(DetectMatchAddressIPv4 *addrs, uint16_t addrs_cnt, Address *a) { +int DetectAddressMatchIPv4(DetectMatchAddressIPv4 *addrs, uint16_t addrs_cnt, Address *a) +{ SCEnter(); if (addrs == NULL || addrs_cnt == 0) { @@ -1646,7 +1647,8 @@ int DetectAddressMatchIPv4(DetectMatchAddressIPv4 *addrs, uint16_t addrs_cnt, Ad * * \todo array should be ordered, so we can break out of the loop */ -int DetectAddressMatchIPv6(DetectMatchAddressIPv6 *addrs, uint16_t addrs_cnt, Address *a) { +int DetectAddressMatchIPv6(DetectMatchAddressIPv6 *addrs, uint16_t addrs_cnt, Address *a) +{ SCEnter(); if (addrs == NULL || addrs_cnt == 0) { @@ -1871,7 +1873,8 @@ typedef struct UTHValidateDetectAddressHeadRange_ { const char *two; } UTHValidateDetectAddressHeadRange; -int UTHValidateDetectAddressHead(DetectAddressHead *gh, int nranges, UTHValidateDetectAddressHeadRange *expectations) { +int UTHValidateDetectAddressHead(DetectAddressHead *gh, int nranges, UTHValidateDetectAddressHeadRange *expectations) +{ int expect = nranges; int have = 0; @@ -4052,7 +4055,8 @@ int AddressTestAddressGroupSetup35(void) return result; } -int AddressTestAddressGroupSetup36 (void) { +int AddressTestAddressGroupSetup36 (void) +{ int result = 0; DetectAddressHead *gh = DetectAddressHeadInit(); @@ -4814,7 +4818,8 @@ int AddressConfVarsTest05(void) /** * \test Test sig distribution over address groups */ -static int AddressTestFunctions01(void) { +static int AddressTestFunctions01(void) +{ DetectAddress *a1 = NULL; DetectAddress *a2 = NULL; DetectAddressHead *h = NULL; @@ -4891,7 +4896,8 @@ end: /** * \test Test sig distribution over address groups */ -static int AddressTestFunctions02(void) { +static int AddressTestFunctions02(void) +{ DetectAddress *a1 = NULL; DetectAddress *a2 = NULL; DetectAddressHead *h = NULL; @@ -4968,7 +4974,8 @@ end: /** * \test Test sig distribution over address groups */ -static int AddressTestFunctions03(void) { +static int AddressTestFunctions03(void) +{ DetectAddress *a1 = NULL; DetectAddress *a2 = NULL; DetectAddressHead *h = NULL; @@ -5045,7 +5052,8 @@ end: /** * \test Test sig distribution over address groups */ -static int AddressTestFunctions04(void) { +static int AddressTestFunctions04(void) +{ DetectAddress *a1 = NULL; DetectAddress *a2 = NULL; DetectAddressHead *h = NULL; diff --git a/src/detect-engine-alert.c b/src/detect-engine-alert.c index 0f12f7d656..f59c030562 100644 --- a/src/detect-engine-alert.c +++ b/src/detect-engine-alert.c @@ -34,7 +34,8 @@ static Signature g_tag_signature; /** tag packet alert structure for tag alerts */ static PacketAlert g_tag_pa; -void PacketAlertTagInit(void) { +void PacketAlertTagInit(void) +{ memset(&g_tag_signature, 0x00, sizeof(g_tag_signature)); g_tag_signature.id = TAG_SIG_ID; @@ -50,7 +51,8 @@ void PacketAlertTagInit(void) { g_tag_pa.s = &g_tag_signature; } -PacketAlert *PacketAlertGetTag(void) { +PacketAlert *PacketAlertGetTag(void) +{ return &g_tag_pa; } @@ -234,7 +236,8 @@ int PacketAlertAppend(DetectEngineThreadCtx *det_ctx, Signature *s, Packet *p, u * \param det_ctx detection engine thread context * \param p pointer to the packet */ -void PacketAlertFinalize(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p) { +void PacketAlertFinalize(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p) +{ SCEnter(); int i = 0; Signature *s = NULL; diff --git a/src/detect-engine-analyzer.c b/src/detect-engine-analyzer.c index 436f0fb54c..3ac8d0802b 100644 --- a/src/detect-engine-analyzer.c +++ b/src/detect-engine-analyzer.c @@ -295,7 +295,8 @@ void CleanupFPAnalyzer(void) } -void CleanupRuleAnalyzer(void) { +void CleanupRuleAnalyzer(void) +{ if (rule_engine_analysis_FD != NULL) { SCLogInfo("Engine-Analyis for rules printed to file - %s", log_path); fclose(rule_engine_analysis_FD); diff --git a/src/detect-engine-event.c b/src/detect-engine-event.c index 0887dc2a33..d0badb5ece 100644 --- a/src/detect-engine-event.c +++ b/src/detect-engine-event.c @@ -59,7 +59,8 @@ void EngineEventRegisterTests(void); /** * \brief Registration function for decode-event: keyword */ -void DetectEngineEventRegister (void) { +void DetectEngineEventRegister (void) +{ sigmatch_table[DETECT_ENGINE_EVENT].name = "engine-event"; sigmatch_table[DETECT_ENGINE_EVENT].Match = DetectEngineEventMatch; sigmatch_table[DETECT_ENGINE_EVENT].Setup = DetectEngineEventSetup; @@ -235,7 +236,8 @@ static int DetectEngineEventSetup (DetectEngineCtx *de_ctx, Signature *s, char * * * \param de pointer to DetectEngineEventData */ -static void DetectEngineEventFree(void *ptr) { +static void DetectEngineEventFree(void *ptr) +{ DetectEngineEventData *de = (DetectEngineEventData *)ptr; if (de) SCFree(de); @@ -272,7 +274,8 @@ static int DetectStreamEventSetup (DetectEngineCtx *de_ctx, Signature *s, char * /** * \test EngineEventTestParse01 is a test for a valid decode-event value */ -int EngineEventTestParse01 (void) { +int EngineEventTestParse01 (void) +{ DetectEngineEventData *de = NULL; de = DetectEngineEventParse("ipv4.pkt_too_small"); if (de) { @@ -287,7 +290,8 @@ int EngineEventTestParse01 (void) { /** * \test EngineEventTestParse02 is a test for a valid upper + lower case decode-event value */ -int EngineEventTestParse02 (void) { +int EngineEventTestParse02 (void) +{ DetectEngineEventData *de = NULL; de = DetectEngineEventParse("PPP.pkt_too_small"); if (de) { @@ -301,7 +305,8 @@ int EngineEventTestParse02 (void) { /** * \test EngineEventTestParse03 is a test for a valid upper case decode-event value */ -int EngineEventTestParse03 (void) { +int EngineEventTestParse03 (void) +{ DetectEngineEventData *de = NULL; de = DetectEngineEventParse("IPV6.PKT_TOO_SMALL"); if (de) { @@ -315,7 +320,8 @@ int EngineEventTestParse03 (void) { /** * \test EngineEventTestParse04 is a test for an invalid upper case decode-event value */ -int EngineEventTestParse04 (void) { +int EngineEventTestParse04 (void) +{ DetectEngineEventData *de = NULL; de = DetectEngineEventParse("IPV6.INVALID_EVENT"); if (de) { @@ -329,7 +335,8 @@ int EngineEventTestParse04 (void) { /** * \test EngineEventTestParse05 is a test for an invalid char into the decode-event value */ -int EngineEventTestParse05 (void) { +int EngineEventTestParse05 (void) +{ DetectEngineEventData *de = NULL; de = DetectEngineEventParse("IPV-6,INVALID_CHAR"); if (de) { @@ -343,7 +350,8 @@ int EngineEventTestParse05 (void) { /** * \test EngineEventTestParse06 is a test for match function with valid decode-event value */ -int EngineEventTestParse06 (void) { +int EngineEventTestParse06 (void) +{ Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) return 0; @@ -389,7 +397,8 @@ error: /** * \brief this function registers unit tests for EngineEvent */ -void EngineEventRegisterTests(void) { +void EngineEventRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("EngineEventTestParse01", EngineEventTestParse01, 1); UtRegisterTest("EngineEventTestParse02", EngineEventTestParse02, 1); diff --git a/src/detect-engine-hhd.c b/src/detect-engine-hhd.c index 152d9cd67f..6672895b48 100644 --- a/src/detect-engine-hhd.c +++ b/src/detect-engine-hhd.c @@ -60,7 +60,8 @@ #define BUFFER_STEP 50 -static inline int HHDCreateSpace(DetectEngineThreadCtx *det_ctx, uint16_t size) { +static inline int HHDCreateSpace(DetectEngineThreadCtx *det_ctx, uint16_t size) +{ void *ptmp; if (size > det_ctx->hhd_buffers_size) { ptmp = SCRealloc(det_ctx->hhd_buffers, diff --git a/src/detect-engine-iponly.c b/src/detect-engine-iponly.c index c76707100c..a44c5bb8eb 100644 --- a/src/detect-engine-iponly.c +++ b/src/detect-engine-iponly.c @@ -66,7 +66,8 @@ * * \retval IPOnlyCIDRItem address of the new instance */ -static IPOnlyCIDRItem *IPOnlyCIDRItemNew() { +static IPOnlyCIDRItem *IPOnlyCIDRItemNew() +{ SCEnter(); IPOnlyCIDRItem *item = NULL; @@ -79,7 +80,8 @@ static IPOnlyCIDRItem *IPOnlyCIDRItemNew() { } static uint8_t IPOnlyCIDRItemCompare(IPOnlyCIDRItem *head, - IPOnlyCIDRItem *item) { + IPOnlyCIDRItem *item) +{ uint8_t i = 0; for (; i < head->netmask / 32 || i < 1; i++) { if (item->ip[i] < head->ip[i]) @@ -291,7 +293,8 @@ error: * \retval 0 On success. * \retval -1 On failure. */ -static int IPOnlyCIDRItemSetup(IPOnlyCIDRItem *gh, char *s) { +static int IPOnlyCIDRItemSetup(IPOnlyCIDRItem *gh, char *s) +{ SCLogDebug("gh %p, s %s", gh, s); /* parse the address */ @@ -402,7 +405,8 @@ static IPOnlyCIDRItem *IPOnlyCIDRItemInsert(IPOnlyCIDRItem *head, * \brief This function free a IPOnlyCIDRItem list * \param tmphead Pointer to the list */ -void IPOnlyCIDRListFree(IPOnlyCIDRItem *tmphead) { +void IPOnlyCIDRListFree(IPOnlyCIDRItem *tmphead) +{ SCEnter(); uint32_t i = 0; @@ -435,7 +439,8 @@ void IPOnlyCIDRListFree(IPOnlyCIDRItem *tmphead) { * \param tmphead Pointer to the list * \param i number of signature internal id */ -static void IPOnlyCIDRListSetSigNum(IPOnlyCIDRItem *tmphead, SigIntId i) { +static void IPOnlyCIDRListSetSigNum(IPOnlyCIDRItem *tmphead, SigIntId i) +{ while (tmphead != NULL) { tmphead->signum = i; tmphead = tmphead->next; @@ -447,7 +452,8 @@ static void IPOnlyCIDRListSetSigNum(IPOnlyCIDRItem *tmphead, SigIntId i) { * \brief This function print a IPOnlyCIDRItem list * \param tmphead Pointer to the head of IPOnlyCIDRItems list */ -static void IPOnlyCIDRListPrint(IPOnlyCIDRItem *tmphead) { +static void IPOnlyCIDRListPrint(IPOnlyCIDRItem *tmphead) +{ uint32_t i = 0; while (tmphead != NULL) { @@ -467,7 +473,8 @@ static void IPOnlyCIDRListPrint(IPOnlyCIDRItem *tmphead) { * radix tree print function to help debugging * \param tmp Pointer to the head of SigNumArray */ -static void SigNumArrayPrint(void *tmp) { +static void SigNumArrayPrint(void *tmp) +{ SigNumArray *sna = (SigNumArray *)tmp; uint32_t u; @@ -526,7 +533,8 @@ static SigNumArray *SigNumArrayNew(DetectEngineCtx *de_ctx, * * \retval SigNumArray address of the new instance */ -static SigNumArray *SigNumArrayCopy(SigNumArray *orig) { +static SigNumArray *SigNumArrayCopy(SigNumArray *orig) +{ SigNumArray *new = SCMalloc(sizeof(SigNumArray)); if (unlikely(new == NULL)) { @@ -550,7 +558,8 @@ static SigNumArray *SigNumArrayCopy(SigNumArray *orig) { * \brief This function free() a SigNumArray * \param orig Pointer to the original SigNumArray to copy */ -static void SigNumArrayFree(void *tmp) { +static void SigNumArrayFree(void *tmp) +{ SigNumArray *sna = (SigNumArray *)tmp; if (sna == NULL) @@ -828,7 +837,8 @@ error: * \param de_ctx Pointer to the current detection engine * \param io_ctx Pointer to the current ip only detection engine */ -void IPOnlyInit(DetectEngineCtx *de_ctx, DetectEngineIPOnlyCtx *io_ctx) { +void IPOnlyInit(DetectEngineCtx *de_ctx, DetectEngineIPOnlyCtx *io_ctx) +{ io_ctx->sig_init_size = DetectEngineGetMaxSigId(de_ctx) / 8 + 1; if ( (io_ctx->sig_init_array = SCMalloc(io_ctx->sig_init_size)) == NULL) { @@ -855,7 +865,8 @@ void IPOnlyInit(DetectEngineCtx *de_ctx, DetectEngineIPOnlyCtx *io_ctx) { * \param io_ctx Pointer to the current ip only thread detection engine */ void DetectEngineIPOnlyThreadInit(DetectEngineCtx *de_ctx, - DetectEngineIPOnlyThreadCtx *io_tctx) { + DetectEngineIPOnlyThreadCtx *io_tctx) +{ /* initialize the signature bitarray */ io_tctx->sig_match_size = de_ctx->io_ctx.max_idx / 8 + 1; io_tctx->sig_match_array = SCMalloc(io_tctx->sig_match_size); @@ -872,7 +883,8 @@ void DetectEngineIPOnlyThreadInit(DetectEngineCtx *de_ctx, * \param de_ctx Pointer to the current detection engine * \param io_ctx Pointer to the current ip only detection engine */ -void IPOnlyPrint(DetectEngineCtx *de_ctx, DetectEngineIPOnlyCtx *io_ctx) { +void IPOnlyPrint(DetectEngineCtx *de_ctx, DetectEngineIPOnlyCtx *io_ctx) +{ /* XXX: how are we going to print the stats now? */ } @@ -882,7 +894,8 @@ void IPOnlyPrint(DetectEngineCtx *de_ctx, DetectEngineIPOnlyCtx *io_ctx) { * \param de_ctx Pointer to the current detection engine * \param io_ctx Pointer to the current ip only detection engine */ -void IPOnlyDeinit(DetectEngineCtx *de_ctx, DetectEngineIPOnlyCtx *io_ctx) { +void IPOnlyDeinit(DetectEngineCtx *de_ctx, DetectEngineIPOnlyCtx *io_ctx) +{ if (io_ctx == NULL) return; @@ -914,7 +927,8 @@ void IPOnlyDeinit(DetectEngineCtx *de_ctx, DetectEngineIPOnlyCtx *io_ctx) { * \param de_ctx Pointer to the current detection engine * \param io_ctx Pointer to the current ip only detection engine */ -void DetectEngineIPOnlyThreadDeinit(DetectEngineIPOnlyThreadCtx *io_tctx) { +void DetectEngineIPOnlyThreadDeinit(DetectEngineIPOnlyThreadCtx *io_tctx) +{ SCFree(io_tctx->sig_match_array); } @@ -1083,7 +1097,8 @@ void IPOnlyMatchPacket(ThreadVars *tv, * * \param de_ctx Pointer to the current detection engine */ -void IPOnlyPrepare(DetectEngineCtx *de_ctx) { +void IPOnlyPrepare(DetectEngineCtx *de_ctx) +{ SCLogDebug("Preparing Final Lists"); /* @@ -1502,7 +1517,8 @@ void IPOnlyPrepare(DetectEngineCtx *de_ctx) { * \param s Pointer to the current signature */ void IPOnlyAddSignature(DetectEngineCtx *de_ctx, DetectEngineIPOnlyCtx *io_ctx, - Signature *s) { + Signature *s) +{ if (!(s->flags & SIG_FLAG_IPONLY)) return; @@ -1535,7 +1551,8 @@ void IPOnlyAddSignature(DetectEngineCtx *de_ctx, DetectEngineIPOnlyCtx *io_ctx, * option appending a SigMatch and no port is fixed */ -static int IPOnlyTestSig01(void) { +static int IPOnlyTestSig01(void) +{ int result = 0; DetectEngineCtx de_ctx; @@ -1562,7 +1579,8 @@ end: * option appending a SigMatch but a port is fixed */ -static int IPOnlyTestSig02 (void) { +static int IPOnlyTestSig02 (void) +{ int result = 0; DetectEngineCtx de_ctx; memset (&de_ctx, 0, sizeof(DetectEngineCtx)); @@ -1591,7 +1609,8 @@ end: * because it has rule options appending a SigMatch like content, and pcre */ -static int IPOnlyTestSig03 (void) { +static int IPOnlyTestSig03 (void) +{ int result = 1; DetectEngineCtx *de_ctx; Signature *s=NULL; @@ -1718,7 +1737,8 @@ end: /** * \test */ -static int IPOnlyTestSig04 (void) { +static int IPOnlyTestSig04 (void) +{ int result = 1; IPOnlyCIDRItem *head = NULL; @@ -1785,7 +1805,8 @@ end: * \test Test a set of ip only signatures making use a lot of * addresses for src and dst (all should match) */ -int IPOnlyTestSig05(void) { +int IPOnlyTestSig05(void) +{ int result = 0; uint8_t *buf = (uint8_t *)"Hi all!"; uint16_t buflen = strlen((char *)buf); @@ -1821,7 +1842,8 @@ int IPOnlyTestSig05(void) { * \test Test a set of ip only signatures making use a lot of * addresses for src and dst (none should match) */ -int IPOnlyTestSig06(void) { +int IPOnlyTestSig06(void) +{ int result = 0; uint8_t *buf = (uint8_t *)"Hi all!"; uint16_t buflen = strlen((char *)buf); @@ -1861,7 +1883,8 @@ int IPOnlyTestSig06(void) { * \test Test a set of ip only signatures making use a lot of * addresses for src and dst (all should match) */ -int IPOnlyTestSig07(void) { +int IPOnlyTestSig07(void) +{ int result = 0; uint8_t *buf = (uint8_t *)"Hi all!"; uint16_t buflen = strlen((char *)buf); @@ -1898,7 +1921,8 @@ int IPOnlyTestSig07(void) { * \test Test a set of ip only signatures making use a lot of * addresses for src and dst (none should match) */ -int IPOnlyTestSig08(void) { +int IPOnlyTestSig08(void) +{ int result = 0; uint8_t *buf = (uint8_t *)"Hi all!"; uint16_t buflen = strlen((char *)buf); @@ -1934,7 +1958,8 @@ int IPOnlyTestSig08(void) { * \test Test a set of ip only signatures making use a lot of * addresses for src and dst (all should match) */ -int IPOnlyTestSig09(void) { +int IPOnlyTestSig09(void) +{ int result = 0; uint8_t *buf = (uint8_t *)"Hi all!"; uint16_t buflen = strlen((char *)buf); @@ -1970,7 +1995,8 @@ int IPOnlyTestSig09(void) { * \test Test a set of ip only signatures making use a lot of * addresses for src and dst (none should match) */ -int IPOnlyTestSig10(void) { +int IPOnlyTestSig10(void) +{ int result = 0; uint8_t *buf = (uint8_t *)"Hi all!"; uint16_t buflen = strlen((char *)buf); @@ -2010,7 +2036,8 @@ int IPOnlyTestSig10(void) { * \test Test a set of ip only signatures making use a lot of * addresses for src and dst (all should match) with ipv4 and ipv6 mixed */ -int IPOnlyTestSig11(void) { +int IPOnlyTestSig11(void) +{ int result = 0; uint8_t *buf = (uint8_t *)"Hi all!"; uint16_t buflen = strlen((char *)buf); @@ -2048,7 +2075,8 @@ int IPOnlyTestSig11(void) { * \test Test a set of ip only signatures making use a lot of * addresses for src and dst (none should match) with ipv4 and ipv6 mixed */ -int IPOnlyTestSig12(void) { +int IPOnlyTestSig12(void) +{ int result = 0; uint8_t *buf = (uint8_t *)"Hi all!"; uint16_t buflen = strlen((char *)buf); @@ -2245,7 +2273,8 @@ int IPOnlyTestSig17(void) #endif /* UNITTESTS */ -void IPOnlyRegisterTests(void) { +void IPOnlyRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("IPOnlyTestSig01", IPOnlyTestSig01, 1); UtRegisterTest("IPOnlyTestSig02", IPOnlyTestSig02, 1); diff --git a/src/detect-engine-mpm.c b/src/detect-engine-mpm.c index 266a734a13..6a81fde277 100644 --- a/src/detect-engine-mpm.c +++ b/src/detect-engine-mpm.c @@ -75,7 +75,8 @@ * \retval 1 true * \retval 0 false */ -int SignatureHasPacketContent(Signature *s) { +int SignatureHasPacketContent(Signature *s) +{ SCEnter(); if (s == NULL) { @@ -108,7 +109,8 @@ int SignatureHasPacketContent(Signature *s) { * \retval 1 true * \retval 0 false */ -int SignatureHasStreamContent(Signature *s) { +int SignatureHasStreamContent(Signature *s) +{ SCEnter(); if (s == NULL) { @@ -139,7 +141,8 @@ int SignatureHasStreamContent(Signature *s) { * * \retval mpm algo value */ -uint16_t PatternMatchDefaultMatcher(void) { +uint16_t PatternMatchDefaultMatcher(void) +{ char *mpm_algo; uint16_t mpm_algo_val = DEFAULT_MPM; @@ -735,7 +738,8 @@ uint32_t StreamPatternSearch(DetectEngineThreadCtx *det_ctx, Packet *p, } /** \brief cleans up the mpm instance after a match */ -void PacketPatternCleanup(ThreadVars *t, DetectEngineThreadCtx *det_ctx) { +void PacketPatternCleanup(ThreadVars *t, DetectEngineThreadCtx *det_ctx) +{ PmqReset(&det_ctx->pmq); if (det_ctx->sgh == NULL) @@ -781,7 +785,8 @@ void PacketPatternCleanup(ThreadVars *t, DetectEngineThreadCtx *det_ctx) { return; } -void StreamPatternCleanup(ThreadVars *t, DetectEngineThreadCtx *det_ctx, StreamMsg *smsg) { +void StreamPatternCleanup(ThreadVars *t, DetectEngineThreadCtx *det_ctx, StreamMsg *smsg) +{ uint8_t cnt = 0; while (smsg != NULL) { @@ -792,32 +797,38 @@ void StreamPatternCleanup(ThreadVars *t, DetectEngineThreadCtx *det_ctx, StreamM } } -void PatternMatchDestroy(MpmCtx *mpm_ctx, uint16_t mpm_matcher) { +void PatternMatchDestroy(MpmCtx *mpm_ctx, uint16_t mpm_matcher) +{ SCLogDebug("mpm_ctx %p, mpm_matcher %"PRIu16"", mpm_ctx, mpm_matcher); mpm_table[mpm_matcher].DestroyCtx(mpm_ctx); } -void PatternMatchPrepare(MpmCtx *mpm_ctx, uint16_t mpm_matcher) { +void PatternMatchPrepare(MpmCtx *mpm_ctx, uint16_t mpm_matcher) +{ SCLogDebug("mpm_ctx %p, mpm_matcher %"PRIu16"", mpm_ctx, mpm_matcher); MpmInitCtx(mpm_ctx, mpm_matcher); } -void PatternMatchThreadPrint(MpmThreadCtx *mpm_thread_ctx, uint16_t mpm_matcher) { +void PatternMatchThreadPrint(MpmThreadCtx *mpm_thread_ctx, uint16_t mpm_matcher) +{ SCLogDebug("mpm_thread_ctx %p, mpm_matcher %"PRIu16" defunct", mpm_thread_ctx, mpm_matcher); //mpm_table[mpm_matcher].PrintThreadCtx(mpm_thread_ctx); } -void PatternMatchThreadDestroy(MpmThreadCtx *mpm_thread_ctx, uint16_t mpm_matcher) { +void PatternMatchThreadDestroy(MpmThreadCtx *mpm_thread_ctx, uint16_t mpm_matcher) +{ SCLogDebug("mpm_thread_ctx %p, mpm_matcher %"PRIu16"", mpm_thread_ctx, mpm_matcher); mpm_table[mpm_matcher].DestroyThreadCtx(NULL, mpm_thread_ctx); } -void PatternMatchThreadPrepare(MpmThreadCtx *mpm_thread_ctx, uint16_t mpm_matcher, uint32_t max_id) { +void PatternMatchThreadPrepare(MpmThreadCtx *mpm_thread_ctx, uint16_t mpm_matcher, uint32_t max_id) +{ SCLogDebug("mpm_thread_ctx %p, type %"PRIu16", max_id %"PRIu32"", mpm_thread_ctx, mpm_matcher, max_id); MpmInitThreadCtx(mpm_thread_ctx, mpm_matcher, max_id); } /* free the pattern matcher part of a SigGroupHead */ -void PatternMatchDestroyGroup(SigGroupHead *sh) { +void PatternMatchDestroyGroup(SigGroupHead *sh) +{ /* content */ if (!(sh->flags & SIG_GROUP_HEAD_MPM_COPY)) { SCLogDebug("destroying mpm_ctx %p (sh %p)", @@ -1059,7 +1070,8 @@ typedef struct UricontentHash_ { uint8_t use; /* use no matter what */ } UricontentHash; -uint32_t ContentHashFunc(HashTable *ht, void *data, uint16_t datalen) { +uint32_t ContentHashFunc(HashTable *ht, void *data, uint16_t datalen) +{ ContentHash *ch = (ContentHash *)data; DetectContentData *co = ch->ptr; uint32_t hash = 0; @@ -1072,7 +1084,8 @@ uint32_t ContentHashFunc(HashTable *ht, void *data, uint16_t datalen) { return hash; } -uint32_t UricontentHashFunc(HashTable *ht, void *data, uint16_t datalen) { +uint32_t UricontentHashFunc(HashTable *ht, void *data, uint16_t datalen) +{ UricontentHash *ch = (UricontentHash *)data; DetectContentData *ud = ch->ptr; uint32_t hash = 0; @@ -1085,7 +1098,8 @@ uint32_t UricontentHashFunc(HashTable *ht, void *data, uint16_t datalen) { return hash; } -char ContentHashCompareFunc(void *data1, uint16_t len1, void *data2, uint16_t len2) { +char ContentHashCompareFunc(void *data1, uint16_t len1, void *data2, uint16_t len2) +{ ContentHash *ch1 = (ContentHash *)data1; ContentHash *ch2 = (ContentHash *)data2; DetectContentData *co1 = ch1->ptr; @@ -1099,7 +1113,8 @@ char ContentHashCompareFunc(void *data1, uint16_t len1, void *data2, uint16_t le return 0; } -char UricontentHashCompareFunc(void *data1, uint16_t len1, void *data2, uint16_t len2) { +char UricontentHashCompareFunc(void *data1, uint16_t len1, void *data2, uint16_t len2) +{ UricontentHash *ch1 = (UricontentHash *)data1; UricontentHash *ch2 = (UricontentHash *)data2; DetectContentData *ud1 = ch1->ptr; @@ -1113,7 +1128,8 @@ char UricontentHashCompareFunc(void *data1, uint16_t len1, void *data2, uint16_t return 0; } -ContentHash *ContentHashAlloc(DetectContentData *ptr) { +ContentHash *ContentHashAlloc(DetectContentData *ptr) +{ ContentHash *ch = SCMalloc(sizeof(ContentHash)); if (unlikely(ch == NULL)) return NULL; @@ -1125,7 +1141,8 @@ ContentHash *ContentHashAlloc(DetectContentData *ptr) { return ch; } -UricontentHash *UricontentHashAlloc(DetectContentData *ptr) { +UricontentHash *UricontentHashAlloc(DetectContentData *ptr) +{ UricontentHash *ch = SCMalloc(sizeof(UricontentHash)); if (unlikely(ch == NULL)) return NULL; @@ -1137,11 +1154,13 @@ UricontentHash *UricontentHashAlloc(DetectContentData *ptr) { return ch; } -void ContentHashFree(void *ch) { +void ContentHashFree(void *ch) +{ SCFree(ch); } -void UricontentHashFree(void *ch) { +void UricontentHashFree(void *ch) +{ SCFree(ch); } @@ -1158,7 +1177,8 @@ void UricontentHashFree(void *ch) { * * \retval s pattern score */ -uint32_t PatternStrength(uint8_t *pat, uint16_t patlen) { +uint32_t PatternStrength(uint8_t *pat, uint16_t patlen) +{ uint8_t a[256]; memset(&a, 0 ,sizeof(a)); @@ -2288,7 +2308,8 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh) has_co_huad || has_co_hhhd || has_co_hrhhd || - has_co_dnsquery) { + has_co_dnsquery) +{ PatternMatchPreparePopulateMpm(de_ctx, sh); @@ -2656,7 +2677,8 @@ typedef struct MpmPatternIdTableElmt_ { * \retval 1 patterns are the same * \retval 0 patterns are not the same **/ -static char MpmPatternIdCompare(void *p1, uint16_t len1, void *p2, uint16_t len2) { +static char MpmPatternIdCompare(void *p1, uint16_t len1, void *p2, uint16_t len2) +{ SCEnter(); BUG_ON(len1 < sizeof(MpmPatternIdTableElmt)); BUG_ON(len2 < sizeof(MpmPatternIdTableElmt)); @@ -2679,7 +2701,8 @@ static char MpmPatternIdCompare(void *p1, uint16_t len1, void *p2, uint16_t len2 /** \brief Hash func for MpmPatternId api * \retval hash hash value */ -static uint32_t MpmPatternIdHashFunc(HashTable *ht, void *p, uint16_t len) { +static uint32_t MpmPatternIdHashFunc(HashTable *ht, void *p, uint16_t len) +{ SCEnter(); BUG_ON(len < sizeof(MpmPatternIdTableElmt)); @@ -2695,7 +2718,8 @@ static uint32_t MpmPatternIdHashFunc(HashTable *ht, void *p, uint16_t len) { } /** \brief free a MpmPatternIdTableElmt */ -static void MpmPatternIdTableElmtFree(void *e) { +static void MpmPatternIdTableElmtFree(void *e) +{ SCEnter(); MpmPatternIdTableElmt *c = (MpmPatternIdTableElmt *)e; SCFree(c->pattern); @@ -2704,7 +2728,8 @@ static void MpmPatternIdTableElmtFree(void *e) { } /** \brief alloc initialize the MpmPatternIdHash */ -MpmPatternIdStore *MpmPatternIdTableInitHash(void) { +MpmPatternIdStore *MpmPatternIdTableInitHash(void) +{ SCEnter(); MpmPatternIdStore *ht = SCMalloc(sizeof(MpmPatternIdStore)); @@ -2717,7 +2742,8 @@ MpmPatternIdStore *MpmPatternIdTableInitHash(void) { SCReturnPtr(ht, "MpmPatternIdStore"); } -void MpmPatternIdTableFreeHash(MpmPatternIdStore *ht) { +void MpmPatternIdTableFreeHash(MpmPatternIdStore *ht) +{ SCEnter(); if (ht == NULL) { @@ -2732,7 +2758,8 @@ void MpmPatternIdTableFreeHash(MpmPatternIdStore *ht) { SCReturn; } -uint32_t MpmPatternIdStoreGetMaxId(MpmPatternIdStore *ht) { +uint32_t MpmPatternIdStoreGetMaxId(MpmPatternIdStore *ht) +{ if (ht == NULL) { return 0; } @@ -2749,7 +2776,8 @@ uint32_t MpmPatternIdStoreGetMaxId(MpmPatternIdStore *ht) { * \retval id pattern id * \initonly */ -uint32_t DetectContentGetId(MpmPatternIdStore *ht, DetectContentData *co) { +uint32_t DetectContentGetId(MpmPatternIdStore *ht, DetectContentData *co) +{ SCEnter(); BUG_ON(ht == NULL || ht->hash == NULL); diff --git a/src/detect-engine-payload.c b/src/detect-engine-payload.c index b8168bf9ab..af0d9c3e3d 100644 --- a/src/detect-engine-payload.c +++ b/src/detect-engine-payload.c @@ -128,7 +128,8 @@ int DetectEngineInspectStreamPayload(DetectEngineCtx *de_ctx, /** \test Not the first but the second occurence of "abc" should be used * for the 2nd match */ -static int PayloadTestSig01 (void) { +static int PayloadTestSig01 (void) +{ uint8_t *buf = (uint8_t *) "abcabcd"; uint16_t buflen = strlen((char *)buf); @@ -149,7 +150,8 @@ end: } /** \test Nocase matching */ -static int PayloadTestSig02 (void) { +static int PayloadTestSig02 (void) +{ uint8_t *buf = (uint8_t *) "abcaBcd"; uint16_t buflen = strlen((char *)buf); @@ -170,7 +172,8 @@ end: } /** \test Negative distance matching */ -static int PayloadTestSig03 (void) { +static int PayloadTestSig03 (void) +{ uint8_t *buf = (uint8_t *) "abcaBcd"; uint16_t buflen = strlen((char *)buf); @@ -1065,7 +1068,8 @@ end: #endif /* UNITTESTS */ -void PayloadRegisterTests(void) { +void PayloadRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("PayloadTestSig01", PayloadTestSig01, 1); UtRegisterTest("PayloadTestSig02", PayloadTestSig02, 1); diff --git a/src/detect-engine-port.c b/src/detect-engine-port.c index e47267c36f..2583f018d5 100644 --- a/src/detect-engine-port.c +++ b/src/detect-engine-port.c @@ -69,7 +69,8 @@ static uint32_t detect_port_free_cnt = 0; * \retval sgh Pointer to the newly created DetectPort on success; or NULL in * case of error. */ -DetectPort *DetectPortInit(void) { +DetectPort *DetectPortInit(void) +{ DetectPort *dp = SCMalloc(sizeof(DetectPort)); if (unlikely(dp == NULL)) return NULL; @@ -86,7 +87,8 @@ DetectPort *DetectPortInit(void) { * * \param dp Pointer to the DetectPort that has to be freed. */ -void DetectPortFree(DetectPort *dp) { +void DetectPortFree(DetectPort *dp) +{ if (dp == NULL) return; @@ -111,7 +113,8 @@ void DetectPortFree(DetectPort *dp) { /** * \brief Prints Memory statistics of the counters at detect-engine-port.[c,h] */ -void DetectPortPrintMemory(void) { +void DetectPortPrintMemory(void) +{ SCLogDebug(" * Port memory stats (DetectPort %" PRIuMAX "):", (uintmax_t)sizeof(DetectPort)); SCLogDebug(" - detect_port_memory %" PRIu32 "", detect_port_memory); @@ -130,7 +133,8 @@ void DetectPortPrintMemory(void) { * * \retval returns a ptr to the match, or NULL if no match */ -DetectPort *DetectPortLookup(DetectPort *head, DetectPort *dp) { +DetectPort *DetectPortLookup(DetectPort *head, DetectPort *dp) +{ DetectPort *cur; if (head != NULL) { @@ -149,7 +153,8 @@ DetectPort *DetectPortLookup(DetectPort *head, DetectPort *dp) { * * \param head Pointer to the DetectPort list head */ -void DetectPortPrintList(DetectPort *head) { +void DetectPortPrintList(DetectPort *head) +{ DetectPort *cur; uint16_t cnt = 0; @@ -169,7 +174,8 @@ void DetectPortPrintList(DetectPort *head) { * * \param head Pointer to the DetectPort list head */ -void DetectPortCleanupList (DetectPort *head) { +void DetectPortCleanupList (DetectPort *head) +{ if (head == NULL) return; @@ -193,7 +199,8 @@ void DetectPortCleanupList (DetectPort *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) { +int DetectPortAdd(DetectPort **head, DetectPort *dp) +{ DetectPort *cur, *prev_cur = NULL; //SCLogDebug("DetectPortAdd: adding "); DetectPortPrint(ag); SCLogDebug(""); @@ -236,7 +243,8 @@ int DetectPortAdd(DetectPort **head, DetectPort *dp) { * \retval 0 if dp is added correctly */ int DetectPortInsertCopy(DetectEngineCtx *de_ctx, DetectPort **head, - DetectPort *new) { + DetectPort *new) +{ DetectPort *copy = DetectPortCopySingle(de_ctx,new); if (copy == NULL) return -1; @@ -257,7 +265,8 @@ int DetectPortInsertCopy(DetectEngineCtx *de_ctx, DetectPort **head, * \retval -1 error * */ int DetectPortInsert(DetectEngineCtx *de_ctx, DetectPort **head, - DetectPort *new) { + DetectPort *new) +{ if (new == NULL) return 0; @@ -363,7 +372,8 @@ error: * \retval -1 error * */ static int DetectPortCut(DetectEngineCtx *de_ctx, DetectPort *a, - DetectPort *b, DetectPort **c) { + DetectPort *b, DetectPort **c) +{ uint32_t a_port1 = a->port; uint32_t a_port2 = a->port2; uint32_t b_port1 = b->port; @@ -649,7 +659,8 @@ error: * \retval 0 ok * \retval -1 error * */ -static int DetectPortCutNot(DetectPort *a, DetectPort **b) { +static int DetectPortCutNot(DetectPort *a, DetectPort **b) +{ uint16_t a_port1 = a->port; uint16_t a_port2 = a->port2; @@ -696,7 +707,8 @@ error: * \retval PORT_XX (Port enum value, XX is EQ, ES, EB, LE, etc) * \retval PORT_ER on error * */ -int DetectPortCmp(DetectPort *a, DetectPort *b) { +int DetectPortCmp(DetectPort *a, DetectPort *b) +{ /* check any */ if ((a->flags & PORT_FLAG_ANY) && (b->flags & PORT_FLAG_ANY)) return PORT_EQ; @@ -751,7 +763,8 @@ int DetectPortCmp(DetectPort *a, DetectPort *b) { * \retval Pointer to a DetectPort instance (copy of src) * \retval NULL on error * */ -DetectPort *DetectPortCopy(DetectEngineCtx *de_ctx, DetectPort *src) { +DetectPort *DetectPortCopy(DetectEngineCtx *de_ctx, DetectPort *src) +{ if (src == NULL) return NULL; @@ -784,7 +797,8 @@ error: * \retval Pointer to a DetectPort instance (copy of src) * \retval NULL on error * */ -DetectPort *DetectPortCopySingle(DetectEngineCtx *de_ctx,DetectPort *src) { +DetectPort *DetectPortCopySingle(DetectEngineCtx *de_ctx,DetectPort *src) +{ if (src == NULL) return NULL; @@ -812,7 +826,8 @@ 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) { +int DetectPortMatch(DetectPort *dp, uint16_t port) +{ if (port >= dp->port && port <= dp->port2) { return 1; @@ -825,7 +840,8 @@ int DetectPortMatch(DetectPort *dp, uint16_t port) { * \brief Helper function that print the DetectPort info * \retval none */ -void DetectPortPrint(DetectPort *dp) { +void DetectPortPrint(DetectPort *dp) +{ if (dp == NULL) return; @@ -848,7 +864,8 @@ void DetectPortPrint(DetectPort *dp) { * \retval NULL if port is not in the list * */ DetectPort * -DetectPortLookupGroup(DetectPort *dp, uint16_t port) { +DetectPortLookupGroup(DetectPort *dp, uint16_t port) +{ DetectPort *p = dp; if (dp == NULL) @@ -876,7 +893,8 @@ DetectPortLookupGroup(DetectPort *dp, uint16_t port) { * \retval 0 on success * */ int DetectPortJoin(DetectEngineCtx *de_ctx, DetectPort *target, - DetectPort *source) { + DetectPort *source) +{ if (target == NULL || source == NULL) return -1; @@ -904,7 +922,8 @@ int DetectPortJoin(DetectEngineCtx *de_ctx, DetectPort *target, * \retval 0 not inserted, memory of new is freed * \retval -1 error */ -static int DetectPortParseInsert(DetectPort **head, DetectPort *new) { +static int DetectPortParseInsert(DetectPort **head, DetectPort *new) +{ return DetectPortInsert(NULL, head, new); } @@ -917,7 +936,8 @@ 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, char *s) +{ DetectPort *ad = NULL, *ad_any = NULL; int r = 0; char port_any = FALSE; @@ -1004,7 +1024,8 @@ error: * \retval -1 On failure. */ static int DetectPortParseDo(DetectPort **head, DetectPort **nhead, char *s, - int negate) { + int negate) +{ size_t u = 0; size_t x = 0; int o_set = 0, n_set = 0, d_set = 0; @@ -1183,7 +1204,8 @@ error: * \retval 0 no * \retval 1 yes */ -int DetectPortIsCompletePortSpace(DetectPort *p) { +int DetectPortIsCompletePortSpace(DetectPort *p) +{ uint16_t next_port = 0; if (p == NULL) @@ -1222,7 +1244,8 @@ int DetectPortIsCompletePortSpace(DetectPort *p) { * \retval 0 on success * \retval -1 on error */ -int DetectPortParseMergeNotPorts(DetectPort **head, DetectPort **nhead) { +int DetectPortParseMergeNotPorts(DetectPort **head, DetectPort **nhead) +{ DetectPort *ad = NULL; DetectPort *ag, *ag2; int r = 0; @@ -1375,7 +1398,8 @@ int DetectPortTestConfVars(void) * \retval 0 on success * \retval -1 on error */ -int DetectPortParse(DetectPort **head, char *str) { +int DetectPortParse(DetectPort **head, char *str) +{ int r; SCLogDebug("Port string to be parsed - str %s", str); @@ -1410,7 +1434,8 @@ error: * \retval DetectPort pointer of the parse string on success * \retval NULL on error */ -DetectPort *PortParse(char *str) { +DetectPort *PortParse(char *str) +{ char *port2 = NULL; DetectPort *dp = NULL; @@ -1483,7 +1508,8 @@ error: * \retval 1 if port is in the valid range * \retval 0 if invalid */ -int DetectPortIsValidRange(char *port){ +int DetectPortIsValidRange(char *port) +{ if(atoi(port) >= 0 && atoi(port) <= 65535) return 1; else @@ -1504,7 +1530,8 @@ int DetectPortIsValidRange(char *port){ * * \retval uint32_t the value of the generated hash */ -uint32_t DetectPortHashFunc(HashListTable *ht, void *data, uint16_t datalen) { +uint32_t DetectPortHashFunc(HashListTable *ht, void *data, uint16_t datalen) +{ DetectPort *p = (DetectPort *)data; uint32_t hash = p->port * p->port2; @@ -1523,7 +1550,8 @@ uint32_t DetectPortHashFunc(HashListTable *ht, void *data, uint16_t datalen) { * \retval 0 if not equal */ char DetectPortCompareFunc(void *data1, uint16_t len1, void *data2, - uint16_t len2) { + uint16_t len2) +{ DetectPort *p1 = (DetectPort *)data1; DetectPort *p2 = (DetectPort *)data2; @@ -1534,7 +1562,8 @@ char DetectPortCompareFunc(void *data1, uint16_t len1, void *data2, return 0; } -void DetectPortFreeFunc(void *p) { +void DetectPortFreeFunc(void *p) +{ DetectPort *dp = (DetectPort *)p; DetectPortFree(dp); } @@ -1547,7 +1576,8 @@ void DetectPortFreeFunc(void *p) { * \retval 0 HashListTable initialization succes * \retval -1 Error */ -int DetectPortDpHashInit(DetectEngineCtx *de_ctx) { +int DetectPortDpHashInit(DetectEngineCtx *de_ctx) +{ de_ctx->dport_hash_table = HashListTableInit(PORT_HASH_SIZE, DetectPortHashFunc, DetectPortCompareFunc, DetectPortFreeFunc); if (de_ctx->dport_hash_table == NULL) @@ -1563,7 +1593,8 @@ error: * * \param de_ctx Pointer to the current DetectionEngineCtx */ -void DetectPortDpHashFree(DetectEngineCtx *de_ctx) { +void DetectPortDpHashFree(DetectEngineCtx *de_ctx) +{ if (de_ctx->dport_hash_table == NULL) return; @@ -1577,7 +1608,8 @@ void DetectPortDpHashFree(DetectEngineCtx *de_ctx) { * * \param de_ctx Pointer to the current DetectionEngineCtx */ -void DetectPortDpHashReset(DetectEngineCtx *de_ctx) { +void DetectPortDpHashReset(DetectEngineCtx *de_ctx) +{ DetectPortDpHashFree(de_ctx); DetectPortDpHashInit(de_ctx); } @@ -1588,7 +1620,8 @@ void DetectPortDpHashReset(DetectEngineCtx *de_ctx) { * \param de_ctx Pointer to the current DetectionEngineCtx * \param p Pointer to the DetectPort to add */ -int DetectPortDpHashAdd(DetectEngineCtx *de_ctx, DetectPort *p) { +int DetectPortDpHashAdd(DetectEngineCtx *de_ctx, DetectPort *p) +{ return HashListTableAdd(de_ctx->dport_hash_table, (void *)p, 0); } @@ -1598,7 +1631,8 @@ int DetectPortDpHashAdd(DetectEngineCtx *de_ctx, DetectPort *p) { * \param de_ctx Pointer to the current DetectionEngineCtx * \param p Pointer to the DetectPort to search */ -DetectPort *DetectPortDpHashLookup(DetectEngineCtx *de_ctx, DetectPort *p) { +DetectPort *DetectPortDpHashLookup(DetectEngineCtx *de_ctx, DetectPort *p) +{ DetectPort *rp = HashListTableLookup(de_ctx->dport_hash_table, (void *)p, 0); return rp; @@ -1612,7 +1646,8 @@ DetectPort *DetectPortDpHashLookup(DetectEngineCtx *de_ctx, DetectPort *p) { * \retval 0 HashListTable initialization succes * \retval -1 Error */ -int DetectPortSpHashInit(DetectEngineCtx *de_ctx) { +int DetectPortSpHashInit(DetectEngineCtx *de_ctx) +{ de_ctx->sport_hash_table = HashListTableInit(PORT_HASH_SIZE, DetectPortHashFunc, DetectPortCompareFunc, DetectPortFreeFunc); if (de_ctx->sport_hash_table == NULL) @@ -1628,7 +1663,8 @@ error: * * \param de_ctx Pointer to the current DetectionEngineCtx */ -void DetectPortSpHashFree(DetectEngineCtx *de_ctx) { +void DetectPortSpHashFree(DetectEngineCtx *de_ctx) +{ if (de_ctx->sport_hash_table == NULL) return; @@ -1642,7 +1678,8 @@ void DetectPortSpHashFree(DetectEngineCtx *de_ctx) { * * \param de_ctx Pointer to the current DetectionEngineCtx */ -void DetectPortSpHashReset(DetectEngineCtx *de_ctx) { +void DetectPortSpHashReset(DetectEngineCtx *de_ctx) +{ DetectPortSpHashFree(de_ctx); DetectPortSpHashInit(de_ctx); } @@ -1653,7 +1690,8 @@ void DetectPortSpHashReset(DetectEngineCtx *de_ctx) { * \param de_ctx Pointer to the current DetectionEngineCtx * \param p Pointer to the DetectPort to add */ -int DetectPortSpHashAdd(DetectEngineCtx *de_ctx, DetectPort *p) { +int DetectPortSpHashAdd(DetectEngineCtx *de_ctx, DetectPort *p) +{ return HashListTableAdd(de_ctx->sport_hash_table, (void *)p, 0); } @@ -1663,7 +1701,8 @@ int DetectPortSpHashAdd(DetectEngineCtx *de_ctx, DetectPort *p) { * \param de_ctx Pointer to the current DetectionEngineCtx * \param p Pointer to the DetectPort to search */ -DetectPort *DetectPortSpHashLookup(DetectEngineCtx *de_ctx, DetectPort *p) { +DetectPort *DetectPortSpHashLookup(DetectEngineCtx *de_ctx, DetectPort *p) +{ DetectPort *rp = HashListTableLookup(de_ctx->sport_hash_table, (void *)p, 0); return rp; @@ -1676,7 +1715,8 @@ DetectPort *DetectPortSpHashLookup(DetectEngineCtx *de_ctx, DetectPort *p) { /** * \test Check if a DetectPort is properly allocated */ -int PortTestParse01 (void) { +int PortTestParse01 (void) +{ DetectPort *dd = NULL; int r = DetectPortParse(&dd,"80"); @@ -1691,7 +1731,8 @@ int PortTestParse01 (void) { /** * \test Check if two ports are properly allocated in the DetectPort group */ -int PortTestParse02 (void) { +int PortTestParse02 (void) +{ DetectPort *dd = NULL; int result = 0; @@ -1712,7 +1753,8 @@ int PortTestParse02 (void) { /** * \test Check if two port ranges are properly allocated in the DetectPort group */ -int PortTestParse03 (void) { +int PortTestParse03 (void) +{ DetectPort *dd = NULL; int result = 0; @@ -1734,7 +1776,8 @@ int PortTestParse03 (void) { /** * \test Check if a negated port range is properly allocated in the DetectPort */ -int PortTestParse04 (void) { +int PortTestParse04 (void) +{ DetectPort *dd = NULL; int r = DetectPortParse(&dd,"!80:81"); @@ -1750,7 +1793,8 @@ 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) { +int PortTestParse05 (void) +{ DetectPort *dd = NULL; int result = 0; @@ -1776,7 +1820,8 @@ end: /** * \test Check if we copy a DetectPort correctly */ -int PortTestParse06 (void) { +int PortTestParse06 (void) +{ DetectPort *dd = NULL, *copy = NULL; int result = 0; @@ -1829,7 +1874,8 @@ end: * \test Check if a negated port range is properly fragmented in the allowed * real groups */ -int PortTestParse07 (void) { +int PortTestParse07 (void) +{ DetectPort *dd = NULL; int result = 0; @@ -1855,7 +1901,8 @@ end: /** * \test Check if we dont allow invalid port range specification */ -int PortTestParse08 (void) { +int PortTestParse08 (void) +{ DetectPort *dd = NULL; int result = 0; @@ -1872,7 +1919,8 @@ end: /** * \test Check if we autocomplete correctly an open range */ -int PortTestParse09 (void) { +int PortTestParse09 (void) +{ DetectPort *dd = NULL; int result = 0; @@ -1895,7 +1943,8 @@ end: /** * \test Test we don't allow a port that is too big */ -int PortTestParse10 (void) { +int PortTestParse10 (void) +{ DetectPort *dd = NULL; int result = 0; @@ -1914,7 +1963,8 @@ end: /** * \test Test second port of range being too big */ -int PortTestParse11 (void) { +int PortTestParse11 (void) +{ DetectPort *dd = NULL; int result = 0; @@ -1933,7 +1983,8 @@ end: /** * \test Test second port of range being just right */ -int PortTestParse12 (void) { +int PortTestParse12 (void) +{ DetectPort *dd = NULL; int result = 0; @@ -1952,7 +2003,8 @@ end: /** * \test Test first port of range being too big */ -int PortTestParse13 (void) { +int PortTestParse13 (void) +{ DetectPort *dd = NULL; int result = 0; @@ -1971,7 +2023,8 @@ end: /** * \test Test merging port groups */ -int PortTestParse14 (void) { +int PortTestParse14 (void) +{ DetectPort *dd = NULL; int result = 0; @@ -1997,7 +2050,8 @@ end: /** * \test Test merging negated port groups */ -int PortTestParse15 (void) { +int PortTestParse15 (void) +{ DetectPort *dd = NULL; int result = 0; @@ -2020,7 +2074,8 @@ end: /** * \test Test parse, copy and cmp functions */ -int PortTestParse16 (void) { +int PortTestParse16 (void) +{ DetectPort *dd = NULL, *copy = NULL; int result = 0; @@ -2073,7 +2128,8 @@ end: /** * \test Test general functions */ -int PortTestFunctions01(void) { +int PortTestFunctions01(void) +{ DetectPort *head = NULL; DetectPort *dp1= NULL; int result = 0; @@ -2134,7 +2190,8 @@ end: /** * \test Test general functions */ -int PortTestFunctions02(void) { +int PortTestFunctions02(void) +{ DetectPort *head = NULL; DetectPort *dp1= NULL; DetectPort *dp2= NULL; @@ -2183,7 +2240,8 @@ end: /** * \test Test general functions */ -int PortTestFunctions03(void) { +int PortTestFunctions03(void) +{ DetectPort *dp1= NULL; DetectPort *dp2= NULL; DetectPort *dp3= NULL; @@ -2248,7 +2306,8 @@ end: /** * \test Test general functions */ -int PortTestFunctions04(void) { +int PortTestFunctions04(void) +{ DetectPort *dp1= NULL; DetectPort *dp2= NULL; int result = 0; @@ -2285,7 +2344,8 @@ end: /** * \test Test general functions */ -static int PortTestFunctions05(void) { +static int PortTestFunctions05(void) +{ DetectPort *dp1 = NULL; DetectPort *dp2 = NULL; DetectPort *dp3 = NULL; @@ -2362,7 +2422,8 @@ end: /** * \test Test general functions */ -static int PortTestFunctions06(void) { +static int PortTestFunctions06(void) +{ DetectPort *dp1 = NULL; DetectPort *dp2 = NULL; DetectPort *dp3 = NULL; @@ -2460,7 +2521,8 @@ int PortTestMatchReal(uint8_t *raw_eth_pkt, uint16_t pktsize, char *sig, /** * \brief Wrapper for PortTestMatchReal */ -int PortTestMatchRealWrp(char *sig, uint32_t sid) { +int PortTestMatchRealWrp(char *sig, uint32_t sid) +{ /* Real HTTP packeth doing a GET method * tcp.sport=47370 tcp.dport=80 * ip.src=192.168.28.131 ip.dst=192.168.1.1 @@ -2733,7 +2795,8 @@ static int PortTestMatchDoubleNegation(void) #endif /* UNITTESTS */ -void DetectPortTests(void) { +void DetectPortTests(void) +{ #ifdef UNITTESTS UtRegisterTest("PortTestParse01", PortTestParse01, 1); UtRegisterTest("PortTestParse02", PortTestParse02, 1); diff --git a/src/detect-engine-proto.c b/src/detect-engine-proto.c index e2ec8facc1..cacaeee3b7 100644 --- a/src/detect-engine-proto.c +++ b/src/detect-engine-proto.c @@ -162,7 +162,8 @@ error: * \param proto protocol (such as IPPROTO_TCP) to look for * \retval 0 protocol not in the set * \retval 1 protocol is in the set */ -int DetectProtoContainsProto(DetectProto *dp, int proto) { +int DetectProtoContainsProto(DetectProto *dp, int proto) +{ if (dp->flags & DETECT_PROTO_ANY) return 1; @@ -183,7 +184,8 @@ int DetectProtoContainsProto(DetectProto *dp, int proto) { * setup the signature with passed values. */ static int DetectProtoInitTest(DetectEngineCtx **de_ctx, Signature **sig, - DetectProto *dp, char *str) { + DetectProto *dp, char *str) +{ char fullstr[1024]; int result = 0; @@ -486,7 +488,8 @@ static int DetectProtoTestSetup02(void) * by matching the received packet against the sig. */ -static int DetectProtoTestSig01(void) { +static int DetectProtoTestSig01(void) +{ Packet *p = NULL; Signature *s = NULL; ThreadVars th_v; @@ -565,7 +568,8 @@ end: * \test signature parsing with tcp-pkt and tcp-stream */ -static int DetectProtoTestSig02(void) { +static int DetectProtoTestSig02(void) +{ Signature *s = NULL; int result = 0; diff --git a/src/detect-engine-siggroup.c b/src/detect-engine-siggroup.c index c0917789c3..1a6cdcb978 100644 --- a/src/detect-engine-siggroup.c +++ b/src/detect-engine-siggroup.c @@ -66,7 +66,8 @@ static uint32_t detect_siggroup_matcharray_memory = 0; static uint32_t detect_siggroup_matcharray_init_cnt = 0; static uint32_t detect_siggroup_matcharray_free_cnt = 0; -void SigGroupHeadInitDataFree(SigGroupHeadInitData *sghid) { +void SigGroupHeadInitDataFree(SigGroupHeadInitData *sghid) +{ if (sghid->content_array != NULL) { SCFree(sghid->content_array); sghid->content_array = NULL; @@ -90,7 +91,8 @@ void SigGroupHeadInitDataFree(SigGroupHeadInitData *sghid) { detect_siggroup_head_initdata_memory -= sizeof(SigGroupHeadInitData); } -static SigGroupHeadInitData *SigGroupHeadInitDataAlloc(uint32_t size) { +static SigGroupHeadInitData *SigGroupHeadInitDataAlloc(uint32_t size) +{ SigGroupHeadInitData *sghid = SCMalloc(sizeof(SigGroupHeadInitData)); if (unlikely(sghid == NULL)) return NULL; @@ -116,7 +118,8 @@ error: return NULL; } -void SigGroupHeadStore(DetectEngineCtx *de_ctx, SigGroupHead *sgh) { +void SigGroupHeadStore(DetectEngineCtx *de_ctx, SigGroupHead *sgh) +{ void *ptmp; //printf("de_ctx->sgh_array_cnt %u, de_ctx->sgh_array_size %u, de_ctx->sgh_array %p\n", de_ctx->sgh_array_cnt, de_ctx->sgh_array_size, de_ctx->sgh_array); if (de_ctx->sgh_array_cnt < de_ctx->sgh_array_size) { @@ -689,7 +692,8 @@ int SigGroupHeadHashAdd(DetectEngineCtx *de_ctx, SigGroupHead *sgh) return ret; } -int SigGroupHeadHashRemove(DetectEngineCtx *de_ctx, SigGroupHead *sgh) { +int SigGroupHeadHashRemove(DetectEngineCtx *de_ctx, SigGroupHead *sgh) +{ return HashListTableRemove(de_ctx->sgh_hash_table, (void *)sgh, 0); } @@ -849,7 +853,8 @@ int SigGroupHeadSPortHashAdd(DetectEngineCtx *de_ctx, SigGroupHead *sgh) return ret; } -int SigGroupHeadSPortHashRemove(DetectEngineCtx *de_ctx, SigGroupHead *sgh) { +int SigGroupHeadSPortHashRemove(DetectEngineCtx *de_ctx, SigGroupHead *sgh) +{ return HashListTableRemove(de_ctx->sgh_sport_hash_table, (void *)sgh, 0); } @@ -1584,7 +1589,8 @@ int SigGroupHeadBuildMatchArray(DetectEngineCtx *de_ctx, SigGroupHead *sgh, * \param de_ctx detection engine ctx for the signatures * \param sgh sig group head to set the flag in */ -void SigGroupHeadSetFilemagicFlag(DetectEngineCtx *de_ctx, SigGroupHead *sgh) { +void SigGroupHeadSetFilemagicFlag(DetectEngineCtx *de_ctx, SigGroupHead *sgh) +{ Signature *s = NULL; uint32_t sig = 0; @@ -1611,7 +1617,8 @@ void SigGroupHeadSetFilemagicFlag(DetectEngineCtx *de_ctx, SigGroupHead *sgh) { * \param de_ctx detection engine ctx for the signatures * \param sgh sig group head to set the flag in */ -void SigGroupHeadSetFilesizeFlag(DetectEngineCtx *de_ctx, SigGroupHead *sgh) { +void SigGroupHeadSetFilesizeFlag(DetectEngineCtx *de_ctx, SigGroupHead *sgh) +{ Signature *s = NULL; uint32_t sig = 0; @@ -1638,7 +1645,8 @@ void SigGroupHeadSetFilesizeFlag(DetectEngineCtx *de_ctx, SigGroupHead *sgh) { * \param de_ctx detection engine ctx for the signatures * \param sgh sig group head to set the flag in */ -void SigGroupHeadSetFileMd5Flag(DetectEngineCtx *de_ctx, SigGroupHead *sgh) { +void SigGroupHeadSetFileMd5Flag(DetectEngineCtx *de_ctx, SigGroupHead *sgh) +{ Signature *s = NULL; uint32_t sig = 0; @@ -1666,7 +1674,8 @@ void SigGroupHeadSetFileMd5Flag(DetectEngineCtx *de_ctx, SigGroupHead *sgh) { * \param de_ctx detection engine ctx for the signatures * \param sgh sig group head to set the counter in */ -void SigGroupHeadSetFilestoreCount(DetectEngineCtx *de_ctx, SigGroupHead *sgh) { +void SigGroupHeadSetFilestoreCount(DetectEngineCtx *de_ctx, SigGroupHead *sgh) +{ Signature *s = NULL; uint32_t sig = 0; diff --git a/src/detect-engine-state.c b/src/detect-engine-state.c index 74c8ee4e94..d6fe83450c 100644 --- a/src/detect-engine-state.c +++ b/src/detect-engine-state.c @@ -1101,7 +1101,8 @@ end: } /** \test multiple pipelined http transactions */ -static int DeStateSigTest02(void) { +static int DeStateSigTest02(void) +{ int result = 0; Signature *s = NULL; DetectEngineThreadCtx *det_ctx = NULL; @@ -1298,7 +1299,8 @@ end: return result; } -static int DeStateSigTest03(void) { +static int DeStateSigTest03(void) +{ uint8_t httpbuf1[] = "POST /upload.cgi HTTP/1.1\r\n" "Host: www.server.lan\r\n" "Content-Type: multipart/form-data; boundary=---------------------------277531038314945\r\n" @@ -1424,7 +1426,8 @@ end: return result; } -static int DeStateSigTest04(void) { +static int DeStateSigTest04(void) +{ uint8_t httpbuf1[] = "POST /upload.cgi HTTP/1.1\r\n" "Host: www.server.lan\r\n" "Content-Type: multipart/form-data; boundary=---------------------------277531038314945\r\n" @@ -1550,7 +1553,8 @@ end: return result; } -static int DeStateSigTest05(void) { +static int DeStateSigTest05(void) +{ uint8_t httpbuf1[] = "POST /upload.cgi HTTP/1.1\r\n" "Host: www.server.lan\r\n" "Content-Type: multipart/form-data; boundary=---------------------------277531038314945\r\n" @@ -1676,7 +1680,8 @@ end: return result; } -static int DeStateSigTest06(void) { +static int DeStateSigTest06(void) +{ uint8_t httpbuf1[] = "POST /upload.cgi HTTP/1.1\r\n" "Host: www.server.lan\r\n" "Content-Type: multipart/form-data; boundary=---------------------------277531038314945\r\n" @@ -1802,7 +1807,8 @@ end: return result; } -static int DeStateSigTest07(void) { +static int DeStateSigTest07(void) +{ uint8_t httpbuf1[] = "POST /upload.cgi HTTP/1.1\r\n" "Host: www.server.lan\r\n" "Content-Type: multipart/form-data; boundary=---------------------------277531038314945\r\n" diff --git a/src/detect-engine-tag.c b/src/detect-engine-tag.c index bbae8936f8..7c8caabba0 100644 --- a/src/detect-engine-tag.c +++ b/src/detect-engine-tag.c @@ -595,7 +595,8 @@ int TagTimeoutCheck(Host *host, struct timeval *tv) /** * \test host tagging: packets */ -int DetectTagTestPacket01 (void) { +int DetectTagTestPacket01 (void) +{ int result = 0; uint8_t *buf = (uint8_t *)"Hi all!"; uint8_t *buf2 = (uint8_t *)"lalala!"; @@ -691,7 +692,8 @@ int DetectTagTestPacket01 (void) { /** * \test host tagging: seconds */ -int DetectTagTestPacket02 (void) { +int DetectTagTestPacket02 (void) +{ int result = 0; uint8_t *buf = (uint8_t *)"Hi all!"; uint8_t *buf2 = (uint8_t *)"lalala!"; @@ -811,7 +813,8 @@ end: /** * \test host tagging: bytes */ -static int DetectTagTestPacket03 (void) { +static int DetectTagTestPacket03 (void) +{ int result = 0; uint8_t *buf = (uint8_t *)"Hi all!"; uint8_t *buf2 = (uint8_t *)"lalala!"; @@ -927,7 +930,8 @@ end: /** * \test session tagging: packets */ -static int DetectTagTestPacket04 (void) { +static int DetectTagTestPacket04 (void) +{ int result = 0; uint8_t *buf = (uint8_t *)"Hi all!"; uint8_t *buf2 = (uint8_t *)"lalala!"; @@ -1067,7 +1071,8 @@ end: /** * \test session tagging: seconds */ -static int DetectTagTestPacket05 (void) { +static int DetectTagTestPacket05 (void) +{ int result = 0; uint8_t *buf = (uint8_t *)"Hi all!"; uint8_t *buf2 = (uint8_t *)"lalala!"; @@ -1212,7 +1217,8 @@ end: /** * \test session tagging: bytes */ -static int DetectTagTestPacket06 (void) { +static int DetectTagTestPacket06 (void) +{ int result = 0; uint8_t *buf = (uint8_t *)"Hi all!"; uint8_t *buf2 = (uint8_t *)"lalala!"; @@ -1353,7 +1359,8 @@ end: /** * \test session tagging: bytes, where a 2nd match makes us tag more */ -static int DetectTagTestPacket07 (void) { +static int DetectTagTestPacket07 (void) +{ int result = 0; uint8_t *buf = (uint8_t *)"Hi all!"; uint8_t *buf2 = (uint8_t *)"lalala!"; @@ -1497,7 +1504,8 @@ end: /** * \brief this function registers unit tests for DetectTag */ -void DetectEngineTagRegisterTests(void) { +void DetectEngineTagRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("DetectTagTestPacket01", DetectTagTestPacket01, 1); UtRegisterTest("DetectTagTestPacket02", DetectTagTestPacket02, 1); diff --git a/src/detect-engine-threshold.c b/src/detect-engine-threshold.c index ca715a3ce5..1ebc3e4043 100644 --- a/src/detect-engine-threshold.c +++ b/src/detect-engine-threshold.c @@ -68,11 +68,13 @@ static int threshold_id = -1; /**< host storage id for thresholds */ -int ThresholdHostStorageId(void) { +int ThresholdHostStorageId(void) +{ return threshold_id; } -void ThresholdInit(void) { +void ThresholdInit(void) +{ threshold_id = HostStorageRegister("threshold", sizeof(void *), NULL, ThresholdListFree); if (threshold_id == -1) { SCLogError(SC_ERR_HOST_INIT, "Can't initiate host storage for thresholding"); @@ -80,7 +82,8 @@ void ThresholdInit(void) { } } -int ThresholdHostHasThreshold(Host *host) { +int ThresholdHostHasThreshold(Host *host) +{ return HostGetStorageById(host, threshold_id) ? 1 : 0; } @@ -175,7 +178,8 @@ int ThresholdTimeoutCheck(Host *host, struct timeval *tv) return retval; } -static inline DetectThresholdEntry *DetectThresholdEntryAlloc(DetectThresholdData *td, Packet *p, uint32_t sid, uint32_t gid) { +static inline DetectThresholdEntry *DetectThresholdEntryAlloc(DetectThresholdData *td, Packet *p, uint32_t sid, uint32_t gid) +{ SCEnter(); DetectThresholdEntry *ste = SCMalloc(sizeof(DetectThresholdEntry)); @@ -210,7 +214,8 @@ static DetectThresholdEntry *ThresholdHostLookupEntry(Host *h, uint32_t sid, uin * \retval 1 normal match * \retval 0 no match */ -int ThresholdHandlePacketHost(Host *h, Packet *p, DetectThresholdData *td, uint32_t sid, uint32_t gid) { +int ThresholdHandlePacketHost(Host *h, Packet *p, DetectThresholdData *td, uint32_t sid, uint32_t gid) +{ int ret = 0; DetectThresholdEntry *lookup_tsh = ThresholdHostLookupEntry(h, sid, gid); @@ -487,7 +492,8 @@ int ThresholdHandlePacketHost(Host *h, Packet *p, DetectThresholdData *td, uint3 return ret; } -static int ThresholdHandlePacketRule(DetectEngineCtx *de_ctx, Packet *p, DetectThresholdData *td, Signature *s) { +static int ThresholdHandlePacketRule(DetectEngineCtx *de_ctx, Packet *p, DetectThresholdData *td, Signature *s) +{ int ret = 0; if (td->type != TYPE_RATE) @@ -649,7 +655,8 @@ void ThresholdContextDestroy(DetectEngineCtx *de_ctx) * * \param td pointer to DetectTagDataEntryList */ -void ThresholdListFree(void *ptr) { +void ThresholdListFree(void *ptr) +{ if (ptr != NULL) { DetectThresholdEntry *entry = ptr; diff --git a/src/detect-engine.c b/src/detect-engine.c index b34c7aef57..b70c7125ec 100644 --- a/src/detect-engine.c +++ b/src/detect-engine.c @@ -767,7 +767,8 @@ DetectEngineCtx *DetectEngineGetGlobalDeCtx(void) return NULL; } -DetectEngineCtx *DetectEngineCtxInit(void) { +DetectEngineCtx *DetectEngineCtxInit(void) +{ DetectEngineCtx *de_ctx; ConfNode *seq_node = NULL; @@ -851,7 +852,8 @@ error: return NULL; } -static void DetectEngineCtxFreeThreadKeywordData(DetectEngineCtx *de_ctx) { +static void DetectEngineCtxFreeThreadKeywordData(DetectEngineCtx *de_ctx) +{ DetectEngineThreadKeywordCtxItem *item = de_ctx->keyword_list; while (item) { DetectEngineThreadKeywordCtxItem *next = item->next; @@ -866,7 +868,8 @@ static void DetectEngineCtxFreeThreadKeywordData(DetectEngineCtx *de_ctx) { * * \param de_ctx DetectEngineCtx:: to be freed */ -void DetectEngineCtxFree(DetectEngineCtx *de_ctx) { +void DetectEngineCtxFree(DetectEngineCtx *de_ctx) +{ if (de_ctx == NULL) return; @@ -924,7 +927,8 @@ void DetectEngineCtxFree(DetectEngineCtx *de_ctx) { * \retval 0 if no config provided, 1 if config was provided * and loaded successfuly */ -static uint8_t DetectEngineCtxLoadConf(DetectEngineCtx *de_ctx) { +static uint8_t DetectEngineCtxLoadConf(DetectEngineCtx *de_ctx) +{ uint8_t profile = ENGINE_PROFILE_UNKNOWN; char *de_ctx_profile = NULL; @@ -1186,15 +1190,18 @@ static uint8_t DetectEngineCtxLoadConf(DetectEngineCtx *de_ctx) { * getting & (re)setting the internal sig i */ -//inline uint32_t DetectEngineGetMaxSigId(DetectEngineCtx *de_ctx) { +//inline uint32_t DetectEngineGetMaxSigId(DetectEngineCtx *de_ctx) +{ // return de_ctx->signum; //} -void DetectEngineResetMaxSigId(DetectEngineCtx *de_ctx) { +void DetectEngineResetMaxSigId(DetectEngineCtx *de_ctx) +{ de_ctx->signum = 0; } -static int DetectEngineThreadCtxInitKeywords(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx) { +static int DetectEngineThreadCtxInitKeywords(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx) +{ if (de_ctx->keyword_id > 0) { det_ctx->keyword_ctxs_array = SCMalloc(de_ctx->keyword_id * sizeof(void *)); if (det_ctx->keyword_ctxs_array == NULL) { @@ -1220,7 +1227,8 @@ static int DetectEngineThreadCtxInitKeywords(DetectEngineCtx *de_ctx, DetectEngi return TM_ECODE_OK; } -static void DetectEngineThreadCtxDeinitKeywords(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx) { +static void DetectEngineThreadCtxDeinitKeywords(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx) +{ if (de_ctx->keyword_id > 0) { DetectEngineThreadKeywordCtxItem *item = de_ctx->keyword_list; while (item) { @@ -1238,7 +1246,8 @@ static void DetectEngineThreadCtxDeinitKeywords(DetectEngineCtx *de_ctx, DetectE /** \internal * \brief Helper for DetectThread setup functions */ -static TmEcode ThreadCtxDoInit (DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx) { +static TmEcode ThreadCtxDoInit (DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx) +{ int i; /** \todo we still depend on the global mpm_ctx here @@ -1384,7 +1393,8 @@ static TmEcode DetectEngineThreadCtxInitForLiveRuleSwap(ThreadVars *tv, void *in return TM_ECODE_OK; } -TmEcode DetectEngineThreadCtxDeinit(ThreadVars *tv, void *data) { +TmEcode DetectEngineThreadCtxDeinit(ThreadVars *tv, void *data) +{ DetectEngineThreadCtx *det_ctx = (DetectEngineThreadCtx *)data; if (det_ctx == NULL) { @@ -1457,7 +1467,8 @@ TmEcode DetectEngineThreadCtxDeinit(ThreadVars *tv, void *data) { return TM_ECODE_OK; } -void DetectEngineThreadCtxInfo(ThreadVars *t, DetectEngineThreadCtx *det_ctx) { +void DetectEngineThreadCtxInfo(ThreadVars *t, DetectEngineThreadCtx *det_ctx) +{ /* XXX */ PatternMatchThreadPrint(&det_ctx->mtc, det_ctx->de_ctx->mpm_matcher); PatternMatchThreadPrint(&det_ctx->mtcu, det_ctx->de_ctx->mpm_matcher); @@ -1479,7 +1490,8 @@ void DetectEngineThreadCtxInfo(ThreadVars *t, DetectEngineThreadCtx *det_ctx) { * recommended to store it in the keywords global ctx so that * it's freed when the de_ctx is freed. */ -int DetectRegisterThreadCtxFuncs(DetectEngineCtx *de_ctx, const char *name, void *(*InitFunc)(void *), void *data, void (*FreeFunc)(void *), int mode) { +int DetectRegisterThreadCtxFuncs(DetectEngineCtx *de_ctx, const char *name, void *(*InitFunc)(void *), void *data, void (*FreeFunc)(void *), int mode) +{ BUG_ON(de_ctx == NULL || InitFunc == NULL || FreeFunc == NULL || data == NULL); if (mode) { @@ -1518,14 +1530,16 @@ int DetectRegisterThreadCtxFuncs(DetectEngineCtx *de_ctx, const char *name, void * * \retval ctx or NULL on error */ -void *DetectThreadCtxGetKeywordThreadCtx(DetectEngineThreadCtx *det_ctx, int id) { +void *DetectThreadCtxGetKeywordThreadCtx(DetectEngineThreadCtx *det_ctx, int id) +{ if (id < 0 || id > det_ctx->keyword_ctxs_size || det_ctx->keyword_ctxs_array == NULL) return NULL; return det_ctx->keyword_ctxs_array[id]; } -const char *DetectSigmatchListEnumToString(enum DetectSigmatchListEnum type) { +const char *DetectSigmatchListEnumToString(enum DetectSigmatchListEnum type) +{ switch (type) { case DETECT_SM_LIST_MATCH: return "packet"; diff --git a/src/detect-file-data.c b/src/detect-file-data.c index f1b8057906..4e84a931b0 100644 --- a/src/detect-file-data.c +++ b/src/detect-file-data.c @@ -48,7 +48,8 @@ static int DetectFiledataSetup (DetectEngineCtx *, Signature *, char *); /** * \brief Registration function for keyword: file_data */ -void DetectFiledataRegister(void) { +void DetectFiledataRegister(void) +{ sigmatch_table[DETECT_FILE_DATA].name = "file_data"; sigmatch_table[DETECT_FILE_DATA].desc = "make content keywords match on HTTP response body"; sigmatch_table[DETECT_FILE_DATA].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/HTTP-keywords#file_data"; diff --git a/src/detect-fileext.c b/src/detect-fileext.c index 7120e49f53..98b8bcb90f 100644 --- a/src/detect-fileext.c +++ b/src/detect-fileext.c @@ -60,7 +60,8 @@ static void DetectFileextFree(void *); /** * \brief Registration function for keyword: fileext */ -void DetectFileextRegister(void) { +void DetectFileextRegister(void) +{ sigmatch_table[DETECT_FILEEXT].name = "fileext"; sigmatch_table[DETECT_FILEEXT].desc = "match on the extension of a file name"; sigmatch_table[DETECT_FILEEXT].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/File-keywords#fileext"; @@ -235,7 +236,8 @@ error: * * \param fileext pointer to DetectFileextData */ -static void DetectFileextFree(void *ptr) { +static void DetectFileextFree(void *ptr) +{ if (ptr != NULL) { DetectFileextData *fileext = (DetectFileextData *)ptr; if (fileext->ext != NULL) @@ -249,7 +251,8 @@ static void DetectFileextFree(void *ptr) { /** * \test DetectFileextTestParse01 */ -int DetectFileextTestParse01 (void) { +int DetectFileextTestParse01 (void) +{ DetectFileextData *dfd = DetectFileextParse("\"doc\""); if (dfd != NULL) { DetectFileextFree(dfd); @@ -261,7 +264,8 @@ int DetectFileextTestParse01 (void) { /** * \test DetectFileextTestParse02 */ -int DetectFileextTestParse02 (void) { +int DetectFileextTestParse02 (void) +{ int result = 0; DetectFileextData *dfd = DetectFileextParse("\"tar.gz\""); @@ -279,7 +283,8 @@ int DetectFileextTestParse02 (void) { /** * \test DetectFileextTestParse03 */ -int DetectFileextTestParse03 (void) { +int DetectFileextTestParse03 (void) +{ int result = 0; DetectFileextData *dfd = DetectFileextParse("\"pdf\""); @@ -299,7 +304,8 @@ int DetectFileextTestParse03 (void) { /** * \brief this function registers unit tests for DetectFileext */ -void DetectFileextRegisterTests(void) { +void DetectFileextRegisterTests(void) +{ #ifdef UNITTESTS /* UNITTESTS */ UtRegisterTest("DetectFileextTestParse01", DetectFileextTestParse01, 1); UtRegisterTest("DetectFileextTestParse02", DetectFileextTestParse02, 1); diff --git a/src/detect-filemagic.c b/src/detect-filemagic.c index 8593f5a7f8..a456525180 100644 --- a/src/detect-filemagic.c +++ b/src/detect-filemagic.c @@ -64,7 +64,8 @@ static void DetectFilemagicFree(void *); /** * \brief Registration function for keyword: filemagic */ -void DetectFilemagicRegister(void) { +void DetectFilemagicRegister(void) +{ sigmatch_table[DETECT_FILEMAGIC].name = "filemagic"; sigmatch_table[DETECT_FILEMAGIC].desc = "match on the information libmagic returns about a file"; sigmatch_table[DETECT_FILEMAGIC].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/File-keywords#filemagic"; @@ -88,7 +89,8 @@ void DetectFilemagicRegister(void) { * \retval -1 error * \retval 0 ok */ -int FilemagicGlobalLookup(File *file) { +int FilemagicGlobalLookup(File *file) +{ if (file == NULL || file->chunks_head == NULL) { SCReturnInt(-1); } @@ -137,7 +139,8 @@ int FilemagicGlobalLookup(File *file) { * \retval -1 error * \retval 0 ok */ -int FilemagicThreadLookup(magic_t *ctx, File *file) { +int FilemagicThreadLookup(magic_t *ctx, File *file) +{ if (ctx == NULL || file == NULL || file->chunks_head == NULL) { SCReturnInt(-1); } @@ -297,7 +300,8 @@ error: return NULL; } -static void *DetectFilemagicThreadInit(void *data) { +static void *DetectFilemagicThreadInit(void *data) +{ char *filename = NULL; FILE *fd = NULL; DetectFilemagicData *filemagic = (DetectFilemagicData *)data; @@ -341,7 +345,8 @@ error: return NULL; } -static void DetectFilemagicThreadFree(void *ctx) { +static void DetectFilemagicThreadFree(void *ctx) +{ if (ctx != NULL) { DetectFilemagicThreadData *t = (DetectFilemagicThreadData *)ctx; if (t->ctx) @@ -413,7 +418,8 @@ error: * * \param filemagic pointer to DetectFilemagicData */ -static void DetectFilemagicFree(void *ptr) { +static void DetectFilemagicFree(void *ptr) +{ if (ptr != NULL) { DetectFilemagicData *filemagic = (DetectFilemagicData *)ptr; if (filemagic->bm_ctx != NULL) { @@ -430,7 +436,8 @@ static void DetectFilemagicFree(void *ptr) { /** * \test DetectFilemagicTestParse01 */ -int DetectFilemagicTestParse01 (void) { +int DetectFilemagicTestParse01 (void) +{ DetectFilemagicData *dnd = DetectFilemagicParse("\"secret.pdf\""); if (dnd != NULL) { DetectFilemagicFree(dnd); @@ -442,7 +449,8 @@ int DetectFilemagicTestParse01 (void) { /** * \test DetectFilemagicTestParse02 */ -int DetectFilemagicTestParse02 (void) { +int DetectFilemagicTestParse02 (void) +{ int result = 0; DetectFilemagicData *dnd = DetectFilemagicParse("\"backup.tar.gz\""); @@ -460,7 +468,8 @@ int DetectFilemagicTestParse02 (void) { /** * \test DetectFilemagicTestParse03 */ -int DetectFilemagicTestParse03 (void) { +int DetectFilemagicTestParse03 (void) +{ int result = 0; DetectFilemagicData *dnd = DetectFilemagicParse("\"cmd.exe\""); @@ -480,7 +489,8 @@ int DetectFilemagicTestParse03 (void) { /** * \brief this function registers unit tests for DetectFilemagic */ -void DetectFilemagicRegisterTests(void) { +void DetectFilemagicRegisterTests(void) +{ #ifdef UNITTESTS /* UNITTESTS */ UtRegisterTest("DetectFilemagicTestParse01", DetectFilemagicTestParse01, 1); UtRegisterTest("DetectFilemagicTestParse02", DetectFilemagicTestParse02, 1); diff --git a/src/detect-filemd5.c b/src/detect-filemd5.c index b08846e77d..a81ba25d6d 100644 --- a/src/detect-filemd5.c +++ b/src/detect-filemd5.c @@ -56,7 +56,8 @@ #ifndef HAVE_NSS -static int DetectFileMd5SetupNoSupport (DetectEngineCtx *a, Signature *b, char *c) { +static int DetectFileMd5SetupNoSupport (DetectEngineCtx *a, Signature *b, char *c) +{ SCLogError(SC_ERR_NO_MD5_SUPPORT, "no MD5 calculation support built in, needed for filemd5 keyword"); return -1; } @@ -64,7 +65,8 @@ static int DetectFileMd5SetupNoSupport (DetectEngineCtx *a, Signature *b, char * /** * \brief Registration function for keyword: filemd5 */ -void DetectFileMd5Register(void) { +void DetectFileMd5Register(void) +{ sigmatch_table[DETECT_FILEMD5].name = "filemd5"; sigmatch_table[DETECT_FILEMD5].FileMatch = NULL; sigmatch_table[DETECT_FILEMD5].alproto = ALPROTO_HTTP; @@ -88,7 +90,8 @@ static void DetectFileMd5Free(void *); /** * \brief Registration function for keyword: filemd5 */ -void DetectFileMd5Register(void) { +void DetectFileMd5Register(void) +{ sigmatch_table[DETECT_FILEMD5].name = "filemd5"; sigmatch_table[DETECT_FILEMD5].desc = "match file MD5 against list of MD5 checksums"; sigmatch_table[DETECT_FILEMD5].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/File-keywords#filemd5"; @@ -102,7 +105,8 @@ void DetectFileMd5Register(void) { return; } -static int Md5ReadString(uint8_t *md5, char *str, char *filename, int line_no) { +static int Md5ReadString(uint8_t *md5, char *str, char *filename, int line_no) +{ if (strlen(str) != 32) { SCLogError(SC_ERR_INVALID_MD5, "%s:%d md5 string not 32 bytes", filename, line_no); @@ -128,7 +132,8 @@ static int Md5ReadString(uint8_t *md5, char *str, char *filename, int line_no) { return 1; } -static int MD5LoadHash(ROHashTable *hash, char *string, char *filename, int line_no) { +static int MD5LoadHash(ROHashTable *hash, char *string, char *filename, int line_no) +{ uint8_t md5[16]; if (Md5ReadString(md5, string, filename, line_no) == 1) { @@ -139,7 +144,8 @@ static int MD5LoadHash(ROHashTable *hash, char *string, char *filename, int line return 1; } -static int MD5MatchLookupBuffer(ROHashTable *hash, uint8_t *buf, size_t buflen) { +static int MD5MatchLookupBuffer(ROHashTable *hash, uint8_t *buf, size_t buflen) +{ void *ptr = ROHashLookup(hash, buf, (uint16_t)buflen); if (ptr == NULL) return 0; @@ -344,7 +350,8 @@ error: * * \param filemd5 pointer to DetectFileMd5Data */ -static void DetectFileMd5Free(void *ptr) { +static void DetectFileMd5Free(void *ptr) +{ if (ptr != NULL) { DetectFileMd5Data *filemd5 = (DetectFileMd5Data *)ptr; if (filemd5->hash != NULL) @@ -354,7 +361,8 @@ static void DetectFileMd5Free(void *ptr) { } #ifdef UNITTESTS -static int MD5MatchLookupString(ROHashTable *hash, char *string) { +static int MD5MatchLookupString(ROHashTable *hash, char *string) +{ uint8_t md5[16]; if (Md5ReadString(md5, string, "file", 88) == 1) { void *ptr = ROHashLookup(hash, &md5, (uint16_t)sizeof(md5)); @@ -366,7 +374,8 @@ static int MD5MatchLookupString(ROHashTable *hash, char *string) { return 0; } -static int MD5MatchTest01(void) { +static int MD5MatchTest01(void) +{ ROHashTable *hash = ROHashInit(4, 16); if (hash == NULL) { return 0; @@ -409,7 +418,8 @@ static int MD5MatchTest01(void) { } #endif -void DetectFileMd5RegisterTests(void) { +void DetectFileMd5RegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("MD5MatchTest01", MD5MatchTest01, 1); #endif diff --git a/src/detect-filename.c b/src/detect-filename.c index 17c049b740..c8cea7f359 100644 --- a/src/detect-filename.c +++ b/src/detect-filename.c @@ -59,7 +59,8 @@ static void DetectFilenameFree(void *); /** * \brief Registration function for keyword: filename */ -void DetectFilenameRegister(void) { +void DetectFilenameRegister(void) +{ sigmatch_table[DETECT_FILENAME].name = "filename"; sigmatch_table[DETECT_FILENAME].desc = "match on the file name"; sigmatch_table[DETECT_FILENAME].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/File-keywords#filename"; @@ -239,7 +240,8 @@ error: * * \param filename pointer to DetectFilenameData */ -static void DetectFilenameFree(void *ptr) { +static void DetectFilenameFree(void *ptr) +{ if (ptr != NULL) { DetectFilenameData *filename = (DetectFilenameData *)ptr; if (filename->bm_ctx != NULL) { @@ -256,7 +258,8 @@ static void DetectFilenameFree(void *ptr) { /** * \test DetectFilenameTestParse01 */ -int DetectFilenameTestParse01 (void) { +int DetectFilenameTestParse01 (void) +{ DetectFilenameData *dnd = DetectFilenameParse("\"secret.pdf\""); if (dnd != NULL) { DetectFilenameFree(dnd); @@ -268,7 +271,8 @@ int DetectFilenameTestParse01 (void) { /** * \test DetectFilenameTestParse02 */ -int DetectFilenameTestParse02 (void) { +int DetectFilenameTestParse02 (void) +{ int result = 0; DetectFilenameData *dnd = DetectFilenameParse("\"backup.tar.gz\""); @@ -286,7 +290,8 @@ int DetectFilenameTestParse02 (void) { /** * \test DetectFilenameTestParse03 */ -int DetectFilenameTestParse03 (void) { +int DetectFilenameTestParse03 (void) +{ int result = 0; DetectFilenameData *dnd = DetectFilenameParse("\"cmd.exe\""); @@ -306,7 +311,8 @@ int DetectFilenameTestParse03 (void) { /** * \brief this function registers unit tests for DetectFilename */ -void DetectFilenameRegisterTests(void) { +void DetectFilenameRegisterTests(void) +{ #ifdef UNITTESTS /* UNITTESTS */ UtRegisterTest("DetectFilenameTestParse01", DetectFilenameTestParse01, 1); UtRegisterTest("DetectFilenameTestParse02", DetectFilenameTestParse02, 1); diff --git a/src/detect-filesize.c b/src/detect-filesize.c index a807405c6b..d8c49bcf78 100644 --- a/src/detect-filesize.c +++ b/src/detect-filesize.c @@ -483,7 +483,8 @@ end: * context and setting up the signature itself. */ -static int DetectFilesizeSetpTest01(void) { +static int DetectFilesizeSetpTest01(void) +{ DetectFilesizeData *fsd = NULL; uint8_t res = 0; diff --git a/src/detect-filestore.c b/src/detect-filestore.c index f4b046ce95..39e4b9913f 100644 --- a/src/detect-filestore.c +++ b/src/detect-filestore.c @@ -67,7 +67,8 @@ static void DetectFilestoreFree(void *); /** * \brief Registration function for keyword: filestore */ -void DetectFilestoreRegister(void) { +void DetectFilestoreRegister(void) +{ sigmatch_table[DETECT_FILESTORE].name = "filestore"; sigmatch_table[DETECT_FILESTORE].desc = "stores files to disk if the rule matched"; sigmatch_table[DETECT_FILESTORE].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/File-keywords#filestore"; @@ -199,7 +200,8 @@ static int FilestorePostMatchWithOptions(Packet *p, Flow *f, DetectFilestoreData * When we are sure all parts of the signature matched, we run this function * to finalize the filestore. */ -int DetectFilestorePostMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p, Signature *s) { +int DetectFilestorePostMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p, Signature *s) +{ uint8_t flags = 0; SCEnter(); @@ -429,7 +431,8 @@ error: return -1; } -static void DetectFilestoreFree(void *ptr) { +static void DetectFilestoreFree(void *ptr) +{ if (ptr != NULL) { SCFree(ptr); } diff --git a/src/detect-flags.c b/src/detect-flags.c index 557de7d1ab..f06f0f444e 100644 --- a/src/detect-flags.c +++ b/src/detect-flags.c @@ -64,7 +64,8 @@ static void DetectFlagsFree(void *); * \brief Registration function for flags: keyword */ -void DetectFlagsRegister (void) { +void DetectFlagsRegister (void) +{ sigmatch_table[DETECT_FLAGS].name = "flags"; sigmatch_table[DETECT_FLAGS].Match = DetectFlagsMatch; sigmatch_table[DETECT_FLAGS].Setup = DetectFlagsSetup; @@ -515,7 +516,8 @@ error: * * \param de pointer to DetectFlagsData */ -static void DetectFlagsFree(void *de_ptr) { +static void DetectFlagsFree(void *de_ptr) +{ DetectFlagsData *de = (DetectFlagsData *)de_ptr; if(de) SCFree(de); } @@ -531,7 +533,8 @@ static void DetectFlagsFree(void *de_ptr) { * \retval 1 on succces * \retval 0 on failure */ -static int FlagsTestParse01 (void) { +static int FlagsTestParse01 (void) +{ DetectFlagsData *de = NULL; de = DetectFlagsParse("S"); if (de && (de->flags == TH_SYN) ) { @@ -548,7 +551,8 @@ static int FlagsTestParse01 (void) { * \retval 1 on succces * \retval 0 on failure */ -static int FlagsTestParse02 (void) { +static int FlagsTestParse02 (void) +{ DetectFlagsData *de = NULL; de = DetectFlagsParse("G"); if (de) { @@ -565,7 +569,8 @@ static int FlagsTestParse02 (void) { * \retval 1 on success * \retval 0 on failure */ -static int FlagsTestParse03 (void) { +static int FlagsTestParse03 (void) +{ Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) return 0; @@ -619,7 +624,8 @@ error: * \retval 1 on succces * \retval 0 on failure */ -static int FlagsTestParse04 (void) { +static int FlagsTestParse04 (void) +{ Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) return 0; @@ -673,7 +679,8 @@ error: * \retval 1 on success * \retval 0 on failure */ -static int FlagsTestParse05 (void) { +static int FlagsTestParse05 (void) +{ Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) return 0; @@ -727,7 +734,8 @@ error: * \retval 1 on success * \retval 0 on failure */ -static int FlagsTestParse06 (void) { +static int FlagsTestParse06 (void) +{ Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) return 0; @@ -781,7 +789,8 @@ error: * \retval 1 on success * \retval 0 on failure */ -static int FlagsTestParse07 (void) { +static int FlagsTestParse07 (void) +{ Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) return 0; @@ -835,7 +844,8 @@ error: * \retval 1 on success * \retval 0 on failure */ -static int FlagsTestParse08 (void) { +static int FlagsTestParse08 (void) +{ Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) return 0; @@ -889,7 +899,8 @@ error: * \retval 1 on success * \retval 0 on failure */ -static int FlagsTestParse09 (void) { +static int FlagsTestParse09 (void) +{ Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) return 0; @@ -943,7 +954,8 @@ error: * \retval 1 on success * \retval 0 on failure */ -static int FlagsTestParse10 (void) { +static int FlagsTestParse10 (void) +{ Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) return 0; @@ -997,7 +1009,8 @@ error: * \retval 1 on success * \retval 0 on failure */ -static int FlagsTestParse11 (void) { +static int FlagsTestParse11 (void) +{ Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) return 0; @@ -1051,7 +1064,8 @@ error: * \retval 1 on succces * \retval 0 on failure */ -static int FlagsTestParse12 (void) { +static int FlagsTestParse12 (void) +{ Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) return 0; @@ -1107,7 +1121,8 @@ error: * \retval 1 on succces * \retval 0 on failure */ -static int FlagsTestParse13 (void) { +static int FlagsTestParse13 (void) +{ DetectFlagsData *de = NULL; de = DetectFlagsParse("+S*"); if (de != NULL) { @@ -1302,7 +1317,8 @@ error: /** * \brief this function registers unit tests for Flags */ -void FlagsRegisterTests(void) { +void FlagsRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("FlagsTestParse01", FlagsTestParse01, 1); UtRegisterTest("FlagsTestParse02", FlagsTestParse02, 0); diff --git a/src/detect-flow.c b/src/detect-flow.c index 827c6e8d4b..8f908419ff 100644 --- a/src/detect-flow.c +++ b/src/detect-flow.c @@ -56,7 +56,8 @@ void DetectFlowFree(void *); /** * \brief Registration function for flow: keyword */ -void DetectFlowRegister (void) { +void DetectFlowRegister (void) +{ sigmatch_table[DETECT_FLOW].name = "flow"; sigmatch_table[DETECT_FLOW].desc = "match on direction and state of the flow"; sigmatch_table[DETECT_FLOW].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/Flow-keywords#Flow"; @@ -354,7 +355,8 @@ error: * * \param fd pointer to DetectFlowData */ -void DetectFlowFree(void *ptr) { +void DetectFlowFree(void *ptr) +{ DetectFlowData *fd = (DetectFlowData *)ptr; SCFree(fd); } @@ -365,7 +367,8 @@ void DetectFlowFree(void *ptr) { * \test DetectFlowTestParse01 is a test to make sure that we return "something" * when given valid flow opt */ -int DetectFlowTestParse01 (void) { +int DetectFlowTestParse01 (void) +{ int result = 0; DetectFlowData *fd = NULL; fd = DetectFlowParse("established"); @@ -380,7 +383,8 @@ int DetectFlowTestParse01 (void) { /** * \test DetectFlowTestParse02 is a test for setting the established flow opt */ -int DetectFlowTestParse02 (void) { +int DetectFlowTestParse02 (void) +{ int result = 0; DetectFlowData *fd = NULL; fd = DetectFlowParse("established"); @@ -399,7 +403,8 @@ int DetectFlowTestParse02 (void) { /** * \test DetectFlowTestParse03 is a test for setting the stateless flow opt */ -int DetectFlowTestParse03 (void) { +int DetectFlowTestParse03 (void) +{ int result = 0; DetectFlowData *fd = NULL; fd = DetectFlowParse("stateless"); @@ -418,7 +423,8 @@ int DetectFlowTestParse03 (void) { /** * \test DetectFlowTestParse04 is a test for setting the to_client flow opt */ -int DetectFlowTestParse04 (void) { +int DetectFlowTestParse04 (void) +{ int result = 0; DetectFlowData *fd = NULL; fd = DetectFlowParse("to_client"); @@ -437,7 +443,8 @@ int DetectFlowTestParse04 (void) { /** * \test DetectFlowTestParse05 is a test for setting the to_server flow opt */ -int DetectFlowTestParse05 (void) { +int DetectFlowTestParse05 (void) +{ int result = 0; DetectFlowData *fd = NULL; fd = DetectFlowParse("to_server"); @@ -456,7 +463,8 @@ int DetectFlowTestParse05 (void) { /** * \test DetectFlowTestParse06 is a test for setting the from_server flow opt */ -int DetectFlowTestParse06 (void) { +int DetectFlowTestParse06 (void) +{ int result = 0; DetectFlowData *fd = NULL; fd = DetectFlowParse("from_server"); @@ -475,7 +483,8 @@ int DetectFlowTestParse06 (void) { /** * \test DetectFlowTestParse07 is a test for setting the from_client flow opt */ -int DetectFlowTestParse07 (void) { +int DetectFlowTestParse07 (void) +{ int result = 0; DetectFlowData *fd = NULL; fd = DetectFlowParse("from_client"); @@ -494,7 +503,8 @@ int DetectFlowTestParse07 (void) { /** * \test DetectFlowTestParse08 is a test for setting the established,to_client flow opts */ -int DetectFlowTestParse08 (void) { +int DetectFlowTestParse08 (void) +{ int result = 0; DetectFlowData *fd = NULL; fd = DetectFlowParse("established,to_client"); @@ -513,7 +523,8 @@ int DetectFlowTestParse08 (void) { /** * \test DetectFlowTestParse09 is a test for setting the to_client,stateless flow opts (order of state,dir reversed) */ -int DetectFlowTestParse09 (void) { +int DetectFlowTestParse09 (void) +{ int result = 0; DetectFlowData *fd = NULL; fd = DetectFlowParse("to_client,stateless"); @@ -532,7 +543,8 @@ int DetectFlowTestParse09 (void) { /** * \test DetectFlowTestParse10 is a test for setting the from_server,stateless flow opts (order of state,dir reversed) */ -int DetectFlowTestParse10 (void) { +int DetectFlowTestParse10 (void) +{ int result = 0; DetectFlowData *fd = NULL; fd = DetectFlowParse("from_server,stateless"); @@ -551,7 +563,8 @@ int DetectFlowTestParse10 (void) { /** * \test DetectFlowTestParse11 is a test for setting the from_server,stateless flow opts with spaces all around */ -int DetectFlowTestParse11 (void) { +int DetectFlowTestParse11 (void) +{ int result = 0; DetectFlowData *fd = NULL; fd = DetectFlowParse(" from_server , stateless "); @@ -571,7 +584,8 @@ int DetectFlowTestParse11 (void) { * \test DetectFlowTestParseNocase01 is a test to make sure that we return "something" * when given valid flow opt */ -int DetectFlowTestParseNocase01 (void) { +int DetectFlowTestParseNocase01 (void) +{ int result = 0; DetectFlowData *fd = NULL; fd = DetectFlowParse("ESTABLISHED"); @@ -586,7 +600,8 @@ int DetectFlowTestParseNocase01 (void) { /** * \test DetectFlowTestParseNocase02 is a test for setting the established flow opt */ -int DetectFlowTestParseNocase02 (void) { +int DetectFlowTestParseNocase02 (void) +{ int result = 0; DetectFlowData *fd = NULL; fd = DetectFlowParse("ESTABLISHED"); @@ -605,7 +620,8 @@ int DetectFlowTestParseNocase02 (void) { /** * \test DetectFlowTestParseNocase03 is a test for setting the stateless flow opt */ -int DetectFlowTestParseNocase03 (void) { +int DetectFlowTestParseNocase03 (void) +{ int result = 0; DetectFlowData *fd = NULL; fd = DetectFlowParse("STATELESS"); @@ -624,7 +640,8 @@ int DetectFlowTestParseNocase03 (void) { /** * \test DetectFlowTestParseNocase04 is a test for setting the to_client flow opt */ -int DetectFlowTestParseNocase04 (void) { +int DetectFlowTestParseNocase04 (void) +{ int result = 0; DetectFlowData *fd = NULL; fd = DetectFlowParse("TO_CLIENT"); @@ -643,7 +660,8 @@ int DetectFlowTestParseNocase04 (void) { /** * \test DetectFlowTestParseNocase05 is a test for setting the to_server flow opt */ -int DetectFlowTestParseNocase05 (void) { +int DetectFlowTestParseNocase05 (void) +{ int result = 0; DetectFlowData *fd = NULL; fd = DetectFlowParse("TO_SERVER"); @@ -662,7 +680,8 @@ int DetectFlowTestParseNocase05 (void) { /** * \test DetectFlowTestParseNocase06 is a test for setting the from_server flow opt */ -int DetectFlowTestParseNocase06 (void) { +int DetectFlowTestParseNocase06 (void) +{ int result = 0; DetectFlowData *fd = NULL; fd = DetectFlowParse("FROM_SERVER"); @@ -681,7 +700,8 @@ int DetectFlowTestParseNocase06 (void) { /** * \test DetectFlowTestParseNocase07 is a test for setting the from_client flow opt */ -int DetectFlowTestParseNocase07 (void) { +int DetectFlowTestParseNocase07 (void) +{ int result = 0; DetectFlowData *fd = NULL; fd = DetectFlowParse("FROM_CLIENT"); @@ -700,7 +720,8 @@ int DetectFlowTestParseNocase07 (void) { /** * \test DetectFlowTestParseNocase08 is a test for setting the established,to_client flow opts */ -int DetectFlowTestParseNocase08 (void) { +int DetectFlowTestParseNocase08 (void) +{ int result = 0; DetectFlowData *fd = NULL; fd = DetectFlowParse("ESTABLISHED,TO_CLIENT"); @@ -719,7 +740,8 @@ int DetectFlowTestParseNocase08 (void) { /** * \test DetectFlowTestParseNocase09 is a test for setting the to_client,stateless flow opts (order of state,dir reversed) */ -int DetectFlowTestParseNocase09 (void) { +int DetectFlowTestParseNocase09 (void) +{ int result = 0; DetectFlowData *fd = NULL; fd = DetectFlowParse("TO_CLIENT,STATELESS"); @@ -738,7 +760,8 @@ int DetectFlowTestParseNocase09 (void) { /** * \test DetectFlowTestParseNocase10 is a test for setting the from_server,stateless flow opts (order of state,dir reversed) */ -int DetectFlowTestParseNocase10 (void) { +int DetectFlowTestParseNocase10 (void) +{ int result = 0; DetectFlowData *fd = NULL; fd = DetectFlowParse("FROM_SERVER,STATELESS"); @@ -757,7 +780,8 @@ int DetectFlowTestParseNocase10 (void) { /** * \test DetectFlowTestParseNocase11 is a test for setting the from_server,stateless flow opts with spaces all around */ -int DetectFlowTestParseNocase11 (void) { +int DetectFlowTestParseNocase11 (void) +{ int result = 0; DetectFlowData *fd = NULL; fd = DetectFlowParse(" FROM_SERVER , STATELESS "); @@ -777,7 +801,8 @@ int DetectFlowTestParseNocase11 (void) { /** * \test DetectFlowTestParse12 is a test for setting an invalid seperator : */ -int DetectFlowTestParse12 (void) { +int DetectFlowTestParse12 (void) +{ int result = 1; DetectFlowData *fd = NULL; fd = DetectFlowParse("from_server:stateless"); @@ -793,7 +818,8 @@ int DetectFlowTestParse12 (void) { /** * \test DetectFlowTestParse13 is a test for an invalid option */ -int DetectFlowTestParse13 (void) { +int DetectFlowTestParse13 (void) +{ int result = 1; DetectFlowData *fd = NULL; fd = DetectFlowParse("invalidoptiontest"); @@ -808,7 +834,8 @@ int DetectFlowTestParse13 (void) { /** * \test DetectFlowTestParse14 is a test for a empty option */ -int DetectFlowTestParse14 (void) { +int DetectFlowTestParse14 (void) +{ int result = 1; DetectFlowData *fd = NULL; fd = DetectFlowParse(""); @@ -824,7 +851,8 @@ int DetectFlowTestParse14 (void) { /** * \test DetectFlowTestParse15 is a test for an invalid combo of options established,stateless */ -int DetectFlowTestParse15 (void) { +int DetectFlowTestParse15 (void) +{ int result = 1; DetectFlowData *fd = NULL; fd = DetectFlowParse("established,stateless"); @@ -840,7 +868,8 @@ int DetectFlowTestParse15 (void) { /** * \test DetectFlowTestParse16 is a test for an invalid combo of options to_client,to_server */ -int DetectFlowTestParse16 (void) { +int DetectFlowTestParse16 (void) +{ int result = 1; DetectFlowData *fd = NULL; fd = DetectFlowParse("to_client,to_server"); @@ -857,7 +886,8 @@ 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) { +int DetectFlowTestParse17 (void) +{ int result = 1; DetectFlowData *fd = NULL; fd = DetectFlowParse("to_client,from_server"); @@ -873,7 +903,8 @@ 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) { +int DetectFlowTestParse18 (void) +{ int result = 0; DetectFlowData *fd = NULL; fd = DetectFlowParse("from_server,established,only_stream"); @@ -893,7 +924,8 @@ 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) { +int DetectFlowTestParseNocase18 (void) +{ int result = 0; DetectFlowData *fd = NULL; fd = DetectFlowParse("FROM_SERVER,ESTABLISHED,ONLY_STREAM"); @@ -914,7 +946,8 @@ int DetectFlowTestParseNocase18 (void) { /** * \test DetectFlowTestParse19 is a test for one to many options passed to DetectFlowParse */ -int DetectFlowTestParse19 (void) { +int DetectFlowTestParse19 (void) +{ int result = 1; DetectFlowData *fd = NULL; fd = DetectFlowParse("from_server,established,only_stream,a"); @@ -930,7 +963,8 @@ int DetectFlowTestParse19 (void) { /** * \test DetectFlowTestParse20 is a test for setting from_server, established, no_stream */ -int DetectFlowTestParse20 (void) { +int DetectFlowTestParse20 (void) +{ int result = 0; DetectFlowData *fd = NULL; fd = DetectFlowParse("from_server,established,no_stream"); @@ -951,7 +985,8 @@ int DetectFlowTestParse20 (void) { /** * \test DetectFlowTestParse20 is a test for setting from_server, established, no_stream */ -int DetectFlowTestParseNocase20 (void) { +int DetectFlowTestParseNocase20 (void) +{ int result = 0; DetectFlowData *fd = NULL; fd = DetectFlowParse("FROM_SERVER,ESTABLISHED,NO_STREAM"); @@ -972,7 +1007,8 @@ int DetectFlowTestParseNocase20 (void) { /** * \test DetectFlowTestParse21 is a test for an invalid opt between to valid opts */ -int DetectFlowTestParse21 (void) { +int DetectFlowTestParse21 (void) +{ int result = 1; DetectFlowData *fd = NULL; fd = DetectFlowParse("from_server,a,no_stream"); @@ -1050,7 +1086,8 @@ static int DetectFlowSigTest01(void) /** * \brief this function registers unit tests for DetectFlow */ -void DetectFlowRegisterTests(void) { +void DetectFlowRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("DetectFlowTestParse01", DetectFlowTestParse01, 1); UtRegisterTest("DetectFlowTestParse02", DetectFlowTestParse02, 1); diff --git a/src/detect-flowbits.c b/src/detect-flowbits.c index 62f8a06a4a..1294037924 100644 --- a/src/detect-flowbits.c +++ b/src/detect-flowbits.c @@ -55,7 +55,8 @@ static int DetectFlowbitSetup (DetectEngineCtx *, Signature *, char *); void DetectFlowbitFree (void *); void FlowBitsRegisterTests(void); -void DetectFlowbitsRegister (void) { +void DetectFlowbitsRegister (void) +{ sigmatch_table[DETECT_FLOWBITS].name = "flowbits"; sigmatch_table[DETECT_FLOWBITS].desc = "operate on flow flag"; sigmatch_table[DETECT_FLOWBITS].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/Flow-keywords#Flowbits"; @@ -91,7 +92,8 @@ error: } -static int DetectFlowbitMatchToggle (Packet *p, DetectFlowbitsData *fd) { +static int DetectFlowbitMatchToggle (Packet *p, DetectFlowbitsData *fd) +{ if (p->flow == NULL) return 0; @@ -99,7 +101,8 @@ static int DetectFlowbitMatchToggle (Packet *p, DetectFlowbitsData *fd) { return 1; } -static int DetectFlowbitMatchUnset (Packet *p, DetectFlowbitsData *fd) { +static int DetectFlowbitMatchUnset (Packet *p, DetectFlowbitsData *fd) +{ if (p->flow == NULL) return 0; @@ -107,7 +110,8 @@ static int DetectFlowbitMatchUnset (Packet *p, DetectFlowbitsData *fd) { return 1; } -static int DetectFlowbitMatchSet (Packet *p, DetectFlowbitsData *fd) { +static int DetectFlowbitMatchSet (Packet *p, DetectFlowbitsData *fd) +{ if (p->flow == NULL) return 0; @@ -115,14 +119,16 @@ static int DetectFlowbitMatchSet (Packet *p, DetectFlowbitsData *fd) { return 1; } -static int DetectFlowbitMatchIsset (Packet *p, DetectFlowbitsData *fd) { +static int DetectFlowbitMatchIsset (Packet *p, DetectFlowbitsData *fd) +{ if (p->flow == NULL) return 0; return FlowBitIsset(p->flow,fd->idx); } -static int DetectFlowbitMatchIsnotset (Packet *p, DetectFlowbitsData *fd) { +static int DetectFlowbitMatchIsnotset (Packet *p, DetectFlowbitsData *fd) +{ if (p->flow == NULL) return 0; @@ -272,7 +278,8 @@ error: return -1; } -void DetectFlowbitFree (void *ptr) { +void DetectFlowbitFree (void *ptr) +{ DetectFlowbitsData *fd = (DetectFlowbitsData *)ptr; if (fd == NULL) @@ -289,7 +296,8 @@ void DetectFlowbitFree (void *ptr) { * \retval 0 on failure */ -static int FlowBitsTestSig01(void) { +static int FlowBitsTestSig01(void) +{ uint8_t *buf = (uint8_t *) "GET /one/ HTTP/1.1\r\n" "Host: one.example.org\r\n" @@ -363,7 +371,8 @@ end: * \retval 0 on failure */ -static int FlowBitsTestSig02(void) { +static int FlowBitsTestSig02(void) +{ uint8_t *buf = (uint8_t *) "GET /one/ HTTP/1.1\r\n" "Host: one.example.org\r\n" @@ -484,7 +493,8 @@ end: * \retval 0 on failure */ -static int FlowBitsTestSig03(void) { +static int FlowBitsTestSig03(void) +{ uint8_t *buf = (uint8_t *) "GET /one/ HTTP/1.1\r\n" "Host: one.example.org\r\n" @@ -561,7 +571,8 @@ end: * \retval 0 on failure */ -static int FlowBitsTestSig04(void) { +static int FlowBitsTestSig04(void) +{ uint8_t *buf = (uint8_t *) "GET /one/ HTTP/1.1\r\n" "Host: one.example.org\r\n" @@ -642,7 +653,8 @@ end: * \retval 0 on failure */ -static int FlowBitsTestSig05(void) { +static int FlowBitsTestSig05(void) +{ uint8_t *buf = (uint8_t *) "GET /one/ HTTP/1.1\r\n" "Host: one.example.org\r\n" @@ -720,7 +732,8 @@ end: * \retval 0 on failure */ -static int FlowBitsTestSig06(void) { +static int FlowBitsTestSig06(void) +{ uint8_t *buf = (uint8_t *) "GET /one/ HTTP/1.1\r\n" "Host: one.example.org\r\n" @@ -823,7 +836,8 @@ end: * \retval 0 on failure */ -static int FlowBitsTestSig07(void) { +static int FlowBitsTestSig07(void) +{ uint8_t *buf = (uint8_t *) "GET /one/ HTTP/1.1\r\n" "Host: one.example.org\r\n" @@ -929,7 +943,8 @@ end: * \retval 0 on failure */ -static int FlowBitsTestSig08(void) { +static int FlowBitsTestSig08(void) +{ uint8_t *buf = (uint8_t *) "GET /one/ HTTP/1.1\r\n" "Host: one.example.org\r\n" @@ -1034,7 +1049,8 @@ end: /** * \brief this function registers unit tests for FlowBits */ -void FlowBitsRegisterTests(void) { +void FlowBitsRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("FlowBitsTestSig01", FlowBitsTestSig01, 0); UtRegisterTest("FlowBitsTestSig02", FlowBitsTestSig02, 0); diff --git a/src/detect-flowvar.c b/src/detect-flowvar.c index 13000503b4..b9f9696079 100644 --- a/src/detect-flowvar.c +++ b/src/detect-flowvar.c @@ -49,7 +49,8 @@ static int DetectFlowvarSetup (DetectEngineCtx *, Signature *, char *); static int DetectFlowvarPostMatch(ThreadVars *tv, DetectEngineThreadCtx *det_ctx, Packet *p, Signature *s, SigMatch *sm); static void DetectFlowvarDataFree(void *ptr); -void DetectFlowvarRegister (void) { +void DetectFlowvarRegister (void) +{ sigmatch_table[DETECT_FLOWVAR].name = "flowvar"; sigmatch_table[DETECT_FLOWVAR].Match = DetectFlowvarMatch; sigmatch_table[DETECT_FLOWVAR].Setup = DetectFlowvarSetup; @@ -92,7 +93,8 @@ error: * * \param cd pointer to DetectCotentData */ -static void DetectFlowvarDataFree(void *ptr) { +static void DetectFlowvarDataFree(void *ptr) +{ if (ptr == NULL) SCReturn; @@ -249,7 +251,8 @@ int DetectFlowvarStoreMatch(DetectEngineThreadCtx *det_ctx, uint16_t idx, /** \brief Setup a post-match for flowvar storage * We're piggyback riding the DetectFlowvarData struct */ -int DetectFlowvarPostMatchSetup(Signature *s, uint16_t idx) { +int DetectFlowvarPostMatchSetup(Signature *s, uint16_t idx) +{ SigMatch *sm = NULL; DetectFlowvarData *fv = NULL; @@ -281,7 +284,8 @@ error: * \param sm sigmatch containing the idx to store * \retval 1 or -1 in case of error */ -static int DetectFlowvarPostMatch(ThreadVars *tv, DetectEngineThreadCtx *det_ctx, Packet *p, Signature *s, SigMatch *sm) { +static int DetectFlowvarPostMatch(ThreadVars *tv, DetectEngineThreadCtx *det_ctx, Packet *p, Signature *s, SigMatch *sm) +{ DetectFlowvarList *fs, *prev; DetectFlowvarData *fd; @@ -321,7 +325,8 @@ static int DetectFlowvarPostMatch(ThreadVars *tv, DetectEngineThreadCtx *det_ctx /** \brief Handle flowvar candidate list in det_ctx: * - clean up the list * - enforce storage for type ALWAYS (luajit) */ -void DetectFlowvarProcessList(DetectEngineThreadCtx *det_ctx, Flow *f) { +void DetectFlowvarProcessList(DetectEngineThreadCtx *det_ctx, Flow *f) +{ DetectFlowvarList *fs, *next; SCLogDebug("det_ctx->flowvarlist %p", det_ctx->flowvarlist); diff --git a/src/detect-fragbits.c b/src/detect-fragbits.c index ec3c041e41..2be69b76d2 100644 --- a/src/detect-fragbits.c +++ b/src/detect-fragbits.c @@ -73,7 +73,8 @@ static void DetectFragBitsFree(void *); * \brief Registration function for fragbits: keyword */ -void DetectFragBitsRegister (void) { +void DetectFragBitsRegister (void) +{ sigmatch_table[DETECT_FRAGBITS].name = "fragbits"; sigmatch_table[DETECT_FRAGBITS].desc = "check if the fragmentation and reserved bits are set in the IP header"; sigmatch_table[DETECT_FRAGBITS].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/Header_keywords#Fragbits"; @@ -320,7 +321,8 @@ error: * * \param de pointer to DetectFragBitsData */ -static void DetectFragBitsFree(void *de_ptr) { +static void DetectFragBitsFree(void *de_ptr) +{ DetectFragBitsData *de = (DetectFragBitsData *)de_ptr; if(de) SCFree(de); } @@ -336,7 +338,8 @@ static void DetectFragBitsFree(void *de_ptr) { * \retval 1 on succces * \retval 0 on failure */ -static int FragBitsTestParse01 (void) { +static int FragBitsTestParse01 (void) +{ DetectFragBitsData *de = NULL; de = DetectFragBitsParse("M"); if (de && (de->fragbits == FRAGBITS_HAVE_MF) ) { @@ -353,7 +356,8 @@ static int FragBitsTestParse01 (void) { * \retval 1 on succces * \retval 0 on failure */ -static int FragBitsTestParse02 (void) { +static int FragBitsTestParse02 (void) +{ DetectFragBitsData *de = NULL; de = DetectFragBitsParse("G"); if (de) { @@ -370,7 +374,8 @@ static int FragBitsTestParse02 (void) { * \retval 1 on success * \retval 0 on failure */ -static int FragBitsTestParse03 (void) { +static int FragBitsTestParse03 (void) +{ uint8_t raw_eth[] = { 0x00 ,0x40 ,0x33 ,0xd9 ,0x7c ,0xfd ,0x00 ,0x00, 0x39 ,0xcf ,0xd9 ,0xcd ,0x08 ,0x00 ,0x45 ,0x00, @@ -466,7 +471,8 @@ error: * \retval 1 on success * \retval 0 on failure */ -static int FragBitsTestParse04 (void) { +static int FragBitsTestParse04 (void) +{ uint8_t raw_eth[] = { 0x00 ,0x40 ,0x33 ,0xd9 ,0x7c ,0xfd ,0x00 ,0x00, 0x39 ,0xcf ,0xd9 ,0xcd ,0x08 ,0x00 ,0x45 ,0x00, @@ -564,7 +570,8 @@ error: /** * \brief this function registers unit tests for FragBits */ -void FragBitsRegisterTests(void) { +void FragBitsRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("FragBitsTestParse01", FragBitsTestParse01, 1); UtRegisterTest("FragBitsTestParse02", FragBitsTestParse02, 0); diff --git a/src/detect-fragoffset.c b/src/detect-fragoffset.c index 2cbf0bdf4c..3c5cc1697d 100644 --- a/src/detect-fragoffset.c +++ b/src/detect-fragoffset.c @@ -51,7 +51,8 @@ void DetectFragOffsetFree(void *); /** * \brief Registration function for fragoffset */ -void DetectFragOffsetRegister (void) { +void DetectFragOffsetRegister (void) +{ sigmatch_table[DETECT_FRAGOFFSET].name = "fragoffset"; sigmatch_table[DETECT_FRAGOFFSET].desc = "match on specific decimal values of the IP fragment offset field"; sigmatch_table[DETECT_FRAGOFFSET].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/Header_keywords#Fragoffset"; @@ -93,7 +94,8 @@ error: * \retval 1 match * */ -int DetectFragOffsetMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p, Signature *s, SigMatch *m) { +int DetectFragOffsetMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p, Signature *s, SigMatch *m) +{ uint16_t frag = 0; DetectFragOffsetData *fragoff = (DetectFragOffsetData *)m->ctx; @@ -135,7 +137,8 @@ int DetectFragOffsetMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet * \retval fragoff pointer to DetectFragOffsetData on success * \retval NULL on failure */ -DetectFragOffsetData *DetectFragOffsetParse (char *fragoffsetstr) { +DetectFragOffsetData *DetectFragOffsetParse (char *fragoffsetstr) +{ DetectFragOffsetData *fragoff = NULL; char *substr[3] = {NULL, NULL, NULL}; #define MAX_SUBSTRINGS 30 @@ -215,7 +218,8 @@ 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, char *fragoffsetstr) +{ DetectFragOffsetData *fragoff = NULL; SigMatch *sm = NULL; @@ -245,7 +249,8 @@ error: * * \param ptr pointer to DetectFragOffsetData */ -void DetectFragOffsetFree (void *ptr) { +void DetectFragOffsetFree (void *ptr) +{ DetectFragOffsetData *fragoff = (DetectFragOffsetData *)ptr; SCFree(fragoff); } @@ -259,7 +264,8 @@ void DetectFragOffsetFree (void *ptr) { /** * \test DetectFragOffsetParseTest01 is a test for setting a valid fragoffset value */ -int DetectFragOffsetParseTest01 (void) { +int DetectFragOffsetParseTest01 (void) +{ DetectFragOffsetData *fragoff = NULL; fragoff = DetectFragOffsetParse("300"); if (fragoff != NULL && fragoff->frag_off == 300) { @@ -273,7 +279,8 @@ int DetectFragOffsetParseTest01 (void) { * \test DetectFragOffsetParseTest02 is a test for setting a valid fragoffset value * with spaces all around */ -int DetectFragOffsetParseTest02 (void) { +int DetectFragOffsetParseTest02 (void) +{ DetectFragOffsetData *fragoff = NULL; fragoff = DetectFragOffsetParse(">300"); if (fragoff != NULL && fragoff->frag_off == 300 && fragoff->mode == FRAG_MORE) { @@ -286,7 +293,8 @@ int DetectFragOffsetParseTest02 (void) { /** * \test DetectFragOffsetParseTest03 is a test for setting an invalid fragoffset value */ -int DetectFragOffsetParseTest03 (void) { +int DetectFragOffsetParseTest03 (void) +{ DetectFragOffsetData *fragoff = NULL; fragoff = DetectFragOffsetParse("badc"); if (fragoff != NULL) { @@ -301,7 +309,8 @@ 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) { +int DetectFragOffsetMatchTest01 (void) +{ int result = 0; Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) @@ -375,7 +384,8 @@ end: } #endif /* UNITTESTS */ -void DetectFragOffsetRegisterTests (void) { +void DetectFragOffsetRegisterTests (void) +{ #ifdef UNITTESTS UtRegisterTest("DetectFragOffsetParseTest01", DetectFragOffsetParseTest01, 1); UtRegisterTest("DetectFragOffsetParseTest02", DetectFragOffsetParseTest02, 1); diff --git a/src/detect-ftpbounce.c b/src/detect-ftpbounce.c index c9942816b6..74ab43445b 100644 --- a/src/detect-ftpbounce.c +++ b/src/detect-ftpbounce.c @@ -273,7 +273,8 @@ int DetectFtpbounceTestSetup01(void) * \brief This test tests the ftpbounce condition match, based on the * ftp layer parser */ -static int DetectFtpbounceTestALMatch02(void) { +static int DetectFtpbounceTestALMatch02(void) +{ int result = 0; uint8_t ftpbuf1[] = { 'P','O' }; @@ -405,7 +406,8 @@ end: * \brief This test tests the ftpbounce condition match, based on * the ftp layer parser */ -static int DetectFtpbounceTestALMatch03(void) { +static int DetectFtpbounceTestALMatch03(void) +{ int result = 0; uint8_t ftpbuf1[] = { 'P','O' }; diff --git a/src/detect-geoip.c b/src/detect-geoip.c index a7a1d05eef..5c72449690 100644 --- a/src/detect-geoip.c +++ b/src/detect-geoip.c @@ -39,7 +39,8 @@ #ifndef HAVE_GEOIP -static int DetectGeoipSetupNoSupport (DetectEngineCtx *a, Signature *b, char *c) { +static int DetectGeoipSetupNoSupport (DetectEngineCtx *a, Signature *b, char *c) +{ SCLogError(SC_ERR_NO_GEOIP_SUPPORT, "no GeoIP support built in, needed for geoip keyword"); return -1; } @@ -359,7 +360,8 @@ error: * * \param geoipdata pointer to DetectGeoipData */ -static void DetectGeoipDataFree(void *ptr) { +static void DetectGeoipDataFree(void *ptr) +{ if (ptr != NULL) { DetectGeoipData *geoipdata = (DetectGeoipData *)ptr; SCFree(geoipdata); @@ -368,7 +370,8 @@ static void DetectGeoipDataFree(void *ptr) { #ifdef UNITTESTS -static int GeoipParseTest(char *rule, int ncountries, char **countries, uint32_t flags) { +static int GeoipParseTest(char *rule, int ncountries, char **countries, uint32_t flags) +{ DetectEngineCtx *de_ctx = NULL; int result = 0; Signature *s = NULL; @@ -427,43 +430,50 @@ end: return result; } -static int GeoipParseTest01(void) { +static int GeoipParseTest01(void) +{ 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) { +static int GeoipParseTest02(void) +{ 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) { +static int GeoipParseTest03(void) +{ 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) { +static int GeoipParseTest04(void) +{ 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) { +static int GeoipParseTest05(void) +{ 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) { +static int GeoipParseTest06(void) +{ 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) { +static int GeoipParseTest07(void) +{ 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); @@ -522,48 +532,55 @@ end: return result; } -static int GeoipMatchTest01(void) { +static int GeoipMatchTest01(void) +{ /* Tests with IP of google DNS as US for both src and dst IPs */ return GeoipMatchTest("alert tcp any any -> any any (geoip:US;sid:1;)", "8.8.8.8", "8.8.8.8"); /* Expected result 1 = match */ } -static int GeoipMatchTest02(void) { +static int GeoipMatchTest02(void) +{ /* Tests with IP of google DNS as US, and m.root-servers.net as japan */ return GeoipMatchTest("alert tcp any any -> any any (geoip:JP;sid:1;)", "8.8.8.8", "202.12.27.33"); /* Expected result 1 = match */ } -static int GeoipMatchTest03(void) { +static int GeoipMatchTest03(void) +{ /* Tests with IP of google DNS as US, and m.root-servers.net as japan */ return GeoipMatchTest("alert tcp any any -> any any (geoip:dst,JP;sid:1;)", "8.8.8.8", "202.12.27.33"); /* Expected result 1 = match */ } -static int GeoipMatchTest04(void) { +static int GeoipMatchTest04(void) +{ /* Tests with IP of google DNS as US, and m.root-servers.net as japan */ return GeoipMatchTest("alert tcp any any -> any any (geoip:src,JP;sid:1;)", "8.8.8.8", "202.12.27.33"); /* Expected result 2 = NO match */ } -static int GeoipMatchTest05(void) { +static int GeoipMatchTest05(void) +{ /* Tests with IP of google DNS as US, and m.root-servers.net as japan */ return GeoipMatchTest("alert tcp any any -> any any (geoip:src,JP,US;sid:1;)", "8.8.8.8", "202.12.27.33"); /* Expected result 1 = match */ } -static int GeoipMatchTest06(void) { +static int GeoipMatchTest06(void) +{ /* Tests with IP of google DNS as US, and m.root-servers.net as japan */ return GeoipMatchTest("alert tcp any any -> any any (geoip:src,ES,JP,US,UK,PT;sid:1;)", "8.8.8.8", "202.12.27.33"); /* Expected result 1 = match */ } -static int GeoipMatchTest07(void) { +static int GeoipMatchTest07(void) +{ /* Tests with IP of google DNS as US, and m.root-servers.net as japan */ return GeoipMatchTest("alert tcp any any -> any any (geoip:src,!ES,JP,US,UK,PT;sid:1;)", "8.8.8.8", "202.12.27.33"); diff --git a/src/detect-gid.c b/src/detect-gid.c index 4c918d2d92..b25dc01579 100644 --- a/src/detect-gid.c +++ b/src/detect-gid.c @@ -44,7 +44,8 @@ static int DetectGidSetup (DetectEngineCtx *, Signature *, char *); * \brief Registration function for gid: keyword */ -void DetectGidRegister (void) { +void DetectGidRegister (void) +{ sigmatch_table[DETECT_GID].name = "gid"; sigmatch_table[DETECT_GID].desc = "give different groups of signatures another id value"; sigmatch_table[DETECT_GID].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/Meta-settings#Gid-group-id"; @@ -116,7 +117,8 @@ static int DetectGidSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr) * \retval 1 on succces * \retval 0 on failure */ -static int GidTestParse01 (void) { +static int GidTestParse01 (void) +{ int result = 0; Signature *s = NULL; @@ -141,7 +143,8 @@ end: * \retval 1 on succces * \retval 0 on failure */ -static int GidTestParse02 (void) { +static int GidTestParse02 (void) +{ int result = 0; DetectEngineCtx *de_ctx = DetectEngineCtxInit(); @@ -162,7 +165,8 @@ end: /** * \brief this function registers unit tests for Gid */ -void GidRegisterTests(void) { +void GidRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("GidTestParse01", GidTestParse01, 1); UtRegisterTest("GidTestParse02", GidTestParse02, 1); diff --git a/src/detect-http-client-body.c b/src/detect-http-client-body.c index 33c0a8ecfc..d29dc23b00 100644 --- a/src/detect-http-client-body.c +++ b/src/detect-http-client-body.c @@ -1210,7 +1210,8 @@ end: } /** \test multiple http transactions and body chunks of request handling */ -static int DetectHttpClientBodyTest14(void) { +static int DetectHttpClientBodyTest14(void) +{ int result = 0; Signature *s = NULL; DetectEngineThreadCtx *det_ctx = NULL; @@ -1428,7 +1429,8 @@ end: } /** \test multiple http transactions and body chunks of request handling */ -static int DetectHttpClientBodyTest15(void) { +static int DetectHttpClientBodyTest15(void) +{ int result = 0; Signature *s = NULL; DetectEngineThreadCtx *det_ctx = NULL; diff --git a/src/detect-http-cookie.c b/src/detect-http-cookie.c index 3a1e0c589a..facf64ad71 100644 --- a/src/detect-http-cookie.c +++ b/src/detect-http-cookie.c @@ -312,7 +312,8 @@ end: } /** \test Check the signature working to alert when http_cookie is matched . */ -static int DetectHttpCookieSigTest01(void) { +static int DetectHttpCookieSigTest01(void) +{ int result = 0; Flow f; uint8_t httpbuf1[] = "POST / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\nCookie:" @@ -417,7 +418,8 @@ end: } /** \test Check the signature working to alert when http_cookie is not present */ -static int DetectHttpCookieSigTest02(void) { +static int DetectHttpCookieSigTest02(void) +{ int result = 0; Flow f; uint8_t httpbuf1[] = "POST / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n\r\n"; @@ -509,7 +511,8 @@ end: } /** \test Check the signature working to alert when http_cookie is not present */ -static int DetectHttpCookieSigTest03(void) { +static int DetectHttpCookieSigTest03(void) +{ int result = 0; Flow f; uint8_t httpbuf1[] = "POST / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n" @@ -601,7 +604,8 @@ end: } /** \test Check the signature working to alert when http_cookie is not present */ -static int DetectHttpCookieSigTest04(void) { +static int DetectHttpCookieSigTest04(void) +{ int result = 0; Flow f; uint8_t httpbuf1[] = "POST / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n" @@ -694,7 +698,8 @@ end: } /** \test Check the signature working to alert when http_cookie is not present */ -static int DetectHttpCookieSigTest05(void) { +static int DetectHttpCookieSigTest05(void) +{ int result = 0; Flow f; uint8_t httpbuf1[] = "POST / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n" @@ -787,7 +792,8 @@ end: } /** \test Check the signature working to alert when http_cookie is not present */ -static int DetectHttpCookieSigTest06(void) { +static int DetectHttpCookieSigTest06(void) +{ int result = 0; Flow f; uint8_t httpbuf1[] = "POST / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n" @@ -880,7 +886,8 @@ end: } /** \test Check the signature working to alert when http_cookie is not present */ -static int DetectHttpCookieSigTest07(void) { +static int DetectHttpCookieSigTest07(void) +{ int result = 0; Flow f; uint8_t httpbuf1[] = "POST / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n" diff --git a/src/detect-http-method.c b/src/detect-http-method.c index 347131d44a..9c419e3345 100644 --- a/src/detect-http-method.c +++ b/src/detect-http-method.c @@ -67,7 +67,8 @@ void DetectHttpMethodFree(void *); /** * \brief Registration function for keyword: http_method */ -void DetectHttpMethodRegister(void) { +void DetectHttpMethodRegister(void) +{ sigmatch_table[DETECT_AL_HTTP_METHOD].name = "http_method"; sigmatch_table[DETECT_AL_HTTP_METHOD].desc = "content modifier to match only on the HTTP method-buffer"; sigmatch_table[DETECT_AL_HTTP_METHOD].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/HTTP-keywords#http_method"; @@ -107,7 +108,8 @@ static int DetectHttpMethodSetup(DetectEngineCtx *de_ctx, Signature *s, char *st * * \param id_d pointer to DetectContentData */ -void DetectHttpMethodFree(void *ptr) { +void DetectHttpMethodFree(void *ptr) +{ DetectContentData *data = (DetectContentData *)ptr; if (data->content != NULL) @@ -805,7 +807,8 @@ end: /** * \brief this function registers unit tests for DetectHttpMethod */ -void DetectHttpMethodRegisterTests(void) { +void DetectHttpMethodRegisterTests(void) +{ #ifdef UNITTESTS /* UNITTESTS */ SCLogDebug("Registering tests for DetectHttpMethod..."); UtRegisterTest("DetectHttpMethodTest01", DetectHttpMethodTest01, 1); diff --git a/src/detect-http-server-body.c b/src/detect-http-server-body.c index 4e74bfcdab..882c81e418 100644 --- a/src/detect-http-server-body.c +++ b/src/detect-http-server-body.c @@ -1402,7 +1402,8 @@ end: } /** \test multiple http transactions and body chunks of request handling */ -static int DetectHttpServerBodyTest14(void) { +static int DetectHttpServerBodyTest14(void) +{ int result = 0; Signature *s = NULL; DetectEngineThreadCtx *det_ctx = NULL; @@ -1569,7 +1570,8 @@ end: return result; } -static int DetectHttpServerBodyTest15(void) { +static int DetectHttpServerBodyTest15(void) +{ int result = 0; Signature *s = NULL; DetectEngineThreadCtx *det_ctx = NULL; @@ -3503,7 +3505,8 @@ end: } /** \test multiple http transactions and body chunks of request handling */ -static int DetectHttpServerBodyFileDataTest09(void) { +static int DetectHttpServerBodyFileDataTest09(void) +{ int result = 0; Signature *s = NULL; DetectEngineThreadCtx *det_ctx = NULL; @@ -3658,7 +3661,8 @@ end: return result; } -static int DetectHttpServerBodyFileDataTest10(void) { +static int DetectHttpServerBodyFileDataTest10(void) +{ int result = 0; Signature *s = NULL; DetectEngineThreadCtx *det_ctx = NULL; diff --git a/src/detect-http-stat-code.c b/src/detect-http-stat-code.c index e41cd16f89..5510549568 100644 --- a/src/detect-http-stat-code.c +++ b/src/detect-http-stat-code.c @@ -72,7 +72,8 @@ void DetectHttpStatCodeFree(void *); /** * \brief Registration function for keyword: http_stat_code */ -void DetectHttpStatCodeRegister (void) { +void DetectHttpStatCodeRegister (void) +{ sigmatch_table[DETECT_AL_HTTP_STAT_CODE].name = "http_stat_code"; sigmatch_table[DETECT_AL_HTTP_STAT_CODE].desc = "content modifier to match only on HTTP stat-code-buffer"; sigmatch_table[DETECT_AL_HTTP_STAT_CODE].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/HTTP-keywords#http_stat_code"; @@ -214,7 +215,8 @@ end: } /** \test Check the signature working to alert when http_stat_code is matched . */ -static int DetectHttpStatCodeSigTest01(void) { +static int DetectHttpStatCodeSigTest01(void) +{ int result = 0; Flow f; uint8_t httpbuf1[] = "POST / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n\r\n"; @@ -315,7 +317,8 @@ end: } /** \test Check the signature working to alert when http_stat_code is not matched . */ -static int DetectHttpStatCodeSigTest02(void) { +static int DetectHttpStatCodeSigTest02(void) +{ int result = 0; Flow f; uint8_t httpbuf1[] = "POST / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n\r\n"; @@ -430,7 +433,8 @@ end: /** \test Check the signature working to alert when http_stat_code is matched for * for nocase or not */ -static int DetectHttpStatCodeSigTest03(void) { +static int DetectHttpStatCodeSigTest03(void) +{ int result = 0; Flow f; uint8_t httpbuf1[] = "POST / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n\r\n"; @@ -545,7 +549,8 @@ end: /** \test Check the signature working to alert when http_stat_code is matched for * for negatoin or not */ -static int DetectHttpStatCodeSigTest04(void) { +static int DetectHttpStatCodeSigTest04(void) +{ int result = 0; Flow f; uint8_t httpbuf1[] = "POST / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n\r\n"; diff --git a/src/detect-http-stat-msg.c b/src/detect-http-stat-msg.c index 1654915e3b..ff97651261 100644 --- a/src/detect-http-stat-msg.c +++ b/src/detect-http-stat-msg.c @@ -72,7 +72,8 @@ void DetectHttpStatMsgFree(void *); /** * \brief Registration function for keyword: http_stat_msg */ -void DetectHttpStatMsgRegister (void) { +void DetectHttpStatMsgRegister (void) +{ sigmatch_table[DETECT_AL_HTTP_STAT_MSG].name = "http_stat_msg"; sigmatch_table[DETECT_AL_HTTP_STAT_MSG].desc = "content modifier to match on HTTP stat-msg-buffer"; sigmatch_table[DETECT_AL_HTTP_STAT_MSG].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/HTTP-keywords#http_stat_msg"; @@ -206,7 +207,8 @@ end: } /** \test Check the signature working to alert when http_stat_msg is matched . */ -static int DetectHttpStatMsgSigTest01(void) { +static int DetectHttpStatMsgSigTest01(void) +{ int result = 0; Flow f; uint8_t httpbuf1[] = "POST / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n\r\n"; @@ -320,7 +322,8 @@ end: } /** \test Check the signature working to alert when http_stat_msg is not matched . */ -static int DetectHttpStatMsgSigTest02(void) { +static int DetectHttpStatMsgSigTest02(void) +{ int result = 0; Flow f; uint8_t httpbuf1[] = "POST / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n\r\n"; @@ -424,7 +427,8 @@ end: /** \test Check the signature working to alert when http_stat_msg is used with * negated content . */ -static int DetectHttpStatMsgSigTest03(void) { +static int DetectHttpStatMsgSigTest03(void) +{ int result = 0; Flow f; uint8_t httpbuf1[] = "POST / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n\r\n"; diff --git a/src/detect-http-uri.c b/src/detect-http-uri.c index 5747d5d56b..4620c1a22d 100644 --- a/src/detect-http-uri.c +++ b/src/detect-http-uri.c @@ -61,7 +61,8 @@ void DetectHttpUriRegisterTests(void); /** * \brief Registration function for keyword: http_uri */ -void DetectHttpUriRegister (void) { +void DetectHttpUriRegister (void) +{ sigmatch_table[DETECT_AL_HTTP_URI].name = "http_uri"; sigmatch_table[DETECT_AL_HTTP_URI].desc = "content modifier to match specifically and only on the HTTP uri-buffer"; sigmatch_table[DETECT_AL_HTTP_URI].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/HTTP-keywords#http_uri-and-http_raw_uri"; diff --git a/src/detect-icmp-id.c b/src/detect-icmp-id.c index 8678f9c200..fefcd025f6 100644 --- a/src/detect-icmp-id.c +++ b/src/detect-icmp-id.c @@ -50,7 +50,8 @@ void DetectIcmpIdFree(void *); /** * \brief Registration function for icode: icmp_id */ -void DetectIcmpIdRegister (void) { +void DetectIcmpIdRegister (void) +{ sigmatch_table[DETECT_ICMP_ID].name = "icmp_id"; sigmatch_table[DETECT_ICMP_ID].desc = "check for a ICMP id"; sigmatch_table[DETECT_ICMP_ID].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/Header_keywords#icmp_id"; @@ -91,7 +92,8 @@ error: * \retval 0 no match * \retval 1 match */ -int DetectIcmpIdMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p, Signature *s, SigMatch *m) { +int DetectIcmpIdMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p, Signature *s, SigMatch *m) +{ uint16_t pid; DetectIcmpIdData *iid = (DetectIcmpIdData *)m->ctx; @@ -151,7 +153,8 @@ int DetectIcmpIdMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p, * \retval iid pointer to DetectIcmpIdData on success * \retval NULL on failure */ -DetectIcmpIdData *DetectIcmpIdParse (char *icmpidstr) { +DetectIcmpIdData *DetectIcmpIdParse (char *icmpidstr) +{ DetectIcmpIdData *iid = NULL; char *substr[3] = {NULL, NULL, NULL}; #define MAX_SUBSTRINGS 30 @@ -225,7 +228,8 @@ 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, char *icmpidstr) +{ DetectIcmpIdData *iid = NULL; SigMatch *sm = NULL; @@ -255,7 +259,8 @@ error: * * \param ptr pointer to DetectIcmpIdData */ -void DetectIcmpIdFree (void *ptr) { +void DetectIcmpIdFree (void *ptr) +{ DetectIcmpIdData *iid = (DetectIcmpIdData *)ptr; SCFree(iid); } @@ -269,7 +274,8 @@ void DetectIcmpIdFree (void *ptr) { /** * \test DetectIcmpIdParseTest01 is a test for setting a valid icmp_id value */ -int DetectIcmpIdParseTest01 (void) { +int DetectIcmpIdParseTest01 (void) +{ DetectIcmpIdData *iid = NULL; iid = DetectIcmpIdParse("300"); if (iid != NULL && iid->id == htons(300)) { @@ -283,7 +289,8 @@ int DetectIcmpIdParseTest01 (void) { * \test DetectIcmpIdParseTest02 is a test for setting a valid icmp_id value * with spaces all around */ -int DetectIcmpIdParseTest02 (void) { +int DetectIcmpIdParseTest02 (void) +{ DetectIcmpIdData *iid = NULL; iid = DetectIcmpIdParse(" 300 "); if (iid != NULL && iid->id == htons(300)) { @@ -297,7 +304,8 @@ int DetectIcmpIdParseTest02 (void) { * \test DetectIcmpIdParseTest03 is a test for setting a valid icmp_id value * with quotation marks */ -int DetectIcmpIdParseTest03 (void) { +int DetectIcmpIdParseTest03 (void) +{ DetectIcmpIdData *iid = NULL; iid = DetectIcmpIdParse("\"300\""); if (iid != NULL && iid->id == htons(300)) { @@ -311,7 +319,8 @@ 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) { +int DetectIcmpIdParseTest04 (void) +{ DetectIcmpIdData *iid = NULL; iid = DetectIcmpIdParse(" \" 300 \""); if (iid != NULL && iid->id == htons(300)) { @@ -325,7 +334,8 @@ int DetectIcmpIdParseTest04 (void) { * \test DetectIcmpIdParseTest05 is a test for setting an invalid icmp_id * value with missing quotation marks */ -int DetectIcmpIdParseTest05 (void) { +int DetectIcmpIdParseTest05 (void) +{ DetectIcmpIdData *iid = NULL; iid = DetectIcmpIdParse("\"300"); if (iid == NULL) { @@ -340,7 +350,8 @@ 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) { +int DetectIcmpIdMatchTest01 (void) +{ int result = 0; Packet *p = NULL; Signature *s = NULL; @@ -402,7 +413,8 @@ end: * against them. The packet is an ICMP packet with no "id" field, * therefore the rule should not trigger. */ -int DetectIcmpIdMatchTest02 (void) { +int DetectIcmpIdMatchTest02 (void) +{ int result = 0; uint8_t raw_icmpv4[] = { @@ -473,7 +485,8 @@ end: } #endif /* UNITTESTS */ -void DetectIcmpIdRegisterTests (void) { +void DetectIcmpIdRegisterTests (void) +{ #ifdef UNITTESTS UtRegisterTest("DetectIcmpIdParseTest01", DetectIcmpIdParseTest01, 1); UtRegisterTest("DetectIcmpIdParseTest02", DetectIcmpIdParseTest02, 1); diff --git a/src/detect-icmp-seq.c b/src/detect-icmp-seq.c index 72778c78a9..b5bccc0c1c 100644 --- a/src/detect-icmp-seq.c +++ b/src/detect-icmp-seq.c @@ -50,7 +50,8 @@ void DetectIcmpSeqFree(void *); /** * \brief Registration function for icmp_seq */ -void DetectIcmpSeqRegister (void) { +void DetectIcmpSeqRegister (void) +{ sigmatch_table[DETECT_ICMP_SEQ].name = "icmp_seq"; sigmatch_table[DETECT_ICMP_SEQ].desc = "check for a ICMP sequence number"; sigmatch_table[DETECT_ICMP_SEQ].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/Header_keywords#icmp_seq"; @@ -91,7 +92,8 @@ error: * \retval 0 no match * \retval 1 match */ -int DetectIcmpSeqMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p, Signature *s, SigMatch *m) { +int DetectIcmpSeqMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p, Signature *s, SigMatch *m) +{ uint16_t seqn; DetectIcmpSeqData *iseq = (DetectIcmpSeqData *)m->ctx; @@ -152,7 +154,8 @@ int DetectIcmpSeqMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p * \retval iseq pointer to DetectIcmpSeqData on success * \retval NULL on failure */ -DetectIcmpSeqData *DetectIcmpSeqParse (char *icmpseqstr) { +DetectIcmpSeqData *DetectIcmpSeqParse (char *icmpseqstr) +{ DetectIcmpSeqData *iseq = NULL; char *substr[3] = {NULL, NULL, NULL}; #define MAX_SUBSTRINGS 30 @@ -227,7 +230,8 @@ 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, char *icmpseqstr) +{ DetectIcmpSeqData *iseq = NULL; SigMatch *sm = NULL; @@ -256,7 +260,8 @@ error: * * \param ptr pointer to DetectIcmpSeqData */ -void DetectIcmpSeqFree (void *ptr) { +void DetectIcmpSeqFree (void *ptr) +{ DetectIcmpSeqData *iseq = (DetectIcmpSeqData *)ptr; SCFree(iseq); } @@ -270,7 +275,8 @@ void DetectIcmpSeqFree (void *ptr) { /** * \test DetectIcmpSeqParseTest01 is a test for setting a valid icmp_seq value */ -int DetectIcmpSeqParseTest01 (void) { +int DetectIcmpSeqParseTest01 (void) +{ DetectIcmpSeqData *iseq = NULL; iseq = DetectIcmpSeqParse("300"); if (iseq != NULL && htons(iseq->seq) == 300) { @@ -284,7 +290,8 @@ int DetectIcmpSeqParseTest01 (void) { * \test DetectIcmpSeqParseTest02 is a test for setting a valid icmp_seq value * with spaces all around */ -int DetectIcmpSeqParseTest02 (void) { +int DetectIcmpSeqParseTest02 (void) +{ DetectIcmpSeqData *iseq = NULL; iseq = DetectIcmpSeqParse(" 300 "); if (iseq != NULL && htons(iseq->seq) == 300) { @@ -297,7 +304,8 @@ int DetectIcmpSeqParseTest02 (void) { /** * \test DetectIcmpSeqParseTest03 is a test for setting an invalid icmp_seq value */ -int DetectIcmpSeqParseTest03 (void) { +int DetectIcmpSeqParseTest03 (void) +{ DetectIcmpSeqData *iseq = NULL; iseq = DetectIcmpSeqParse("badc"); if (iseq != NULL) { @@ -312,7 +320,8 @@ 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) { +int DetectIcmpSeqMatchTest01 (void) +{ int result = 0; Packet *p = NULL; Signature *s = NULL; @@ -369,7 +378,8 @@ end: } #endif /* UNITTESTS */ -void DetectIcmpSeqRegisterTests (void) { +void DetectIcmpSeqRegisterTests (void) +{ #ifdef UNITTESTS UtRegisterTest("DetectIcmpSeqParseTest01", DetectIcmpSeqParseTest01, 1); UtRegisterTest("DetectIcmpSeqParseTest02", DetectIcmpSeqParseTest02, 1); diff --git a/src/detect-icode.c b/src/detect-icode.c index 0ff677378d..ff82274e34 100644 --- a/src/detect-icode.c +++ b/src/detect-icode.c @@ -54,7 +54,8 @@ void DetectICodeFree(void *); /** * \brief Registration function for icode: keyword */ -void DetectICodeRegister (void) { +void DetectICodeRegister (void) +{ sigmatch_table[DETECT_ICODE].name = "icode"; sigmatch_table[DETECT_ICODE].desc = "match on specific ICMP id-value"; sigmatch_table[DETECT_ICODE].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/Header_keywords#icode"; @@ -97,7 +98,8 @@ error: * \retval 0 no match * \retval 1 match */ -int DetectICodeMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p, Signature *s, SigMatch *m) { +int DetectICodeMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p, Signature *s, SigMatch *m) +{ int ret = 0; uint8_t picode; DetectICodeData *icd = (DetectICodeData *)m->ctx; @@ -140,7 +142,8 @@ int DetectICodeMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p, * \retval icd pointer to DetectICodeData on success * \retval NULL on failure */ -DetectICodeData *DetectICodeParse(char *icodestr) { +DetectICodeData *DetectICodeParse(char *icodestr) +{ DetectICodeData *icd = NULL; char *args[3] = {NULL, NULL, NULL}; #define MAX_SUBSTRINGS 30 @@ -243,7 +246,8 @@ 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, char *icodestr) +{ DetectICodeData *icd = NULL; SigMatch *sm = NULL; @@ -273,7 +277,8 @@ error: * * \param ptr pointer to DetectICodeData */ -void DetectICodeFree(void *ptr) { +void DetectICodeFree(void *ptr) +{ DetectICodeData *icd = (DetectICodeData *)ptr; SCFree(icd); } @@ -287,7 +292,8 @@ void DetectICodeFree(void *ptr) { /** * \test DetectICodeParseTest01 is a test for setting a valid icode value */ -int DetectICodeParseTest01(void) { +int DetectICodeParseTest01(void) +{ DetectICodeData *icd = NULL; int result = 0; icd = DetectICodeParse("8"); @@ -303,7 +309,8 @@ int DetectICodeParseTest01(void) { * \test DetectICodeParseTest02 is a test for setting a valid icode value * with ">" operator */ -int DetectICodeParseTest02(void) { +int DetectICodeParseTest02(void) +{ DetectICodeData *icd = NULL; int result = 0; icd = DetectICodeParse(">8"); @@ -319,7 +326,8 @@ int DetectICodeParseTest02(void) { * \test DetectICodeParseTest03 is a test for setting a valid icode value * with "<" operator */ -int DetectICodeParseTest03(void) { +int DetectICodeParseTest03(void) +{ DetectICodeData *icd = NULL; int result = 0; icd = DetectICodeParse("<8"); @@ -335,7 +343,8 @@ int DetectICodeParseTest03(void) { * \test DetectICodeParseTest04 is a test for setting a valid icode value * with "<>" operator */ -int DetectICodeParseTest04(void) { +int DetectICodeParseTest04(void) +{ DetectICodeData *icd = NULL; int result = 0; icd = DetectICodeParse("8<>20"); @@ -351,7 +360,8 @@ int DetectICodeParseTest04(void) { * \test DetectICodeParseTest05 is a test for setting a valid icode value * with spaces all around */ -int DetectICodeParseTest05(void) { +int DetectICodeParseTest05(void) +{ DetectICodeData *icd = NULL; int result = 0; icd = DetectICodeParse(" 8 "); @@ -367,7 +377,8 @@ int DetectICodeParseTest05(void) { * \test DetectICodeParseTest06 is a test for setting a valid icode value * with ">" operator and spaces all around */ -int DetectICodeParseTest06(void) { +int DetectICodeParseTest06(void) +{ DetectICodeData *icd = NULL; int result = 0; icd = DetectICodeParse(" > 8 "); @@ -383,7 +394,8 @@ int DetectICodeParseTest06(void) { * \test DetectICodeParseTest07 is a test for setting a valid icode value * with "<>" operator and spaces all around */ -int DetectICodeParseTest07(void) { +int DetectICodeParseTest07(void) +{ DetectICodeData *icd = NULL; int result = 0; icd = DetectICodeParse(" 8 <> 20 "); @@ -398,7 +410,8 @@ int DetectICodeParseTest07(void) { /** * \test DetectICodeParseTest08 is a test for setting an invalid icode value */ -int DetectICodeParseTest08(void) { +int DetectICodeParseTest08(void) +{ DetectICodeData *icd = NULL; icd = DetectICodeParse("> 8 <> 20"); if (icd == NULL) @@ -412,7 +425,8 @@ 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) { +int DetectICodeMatchTest01(void) +{ Packet *p = NULL; Signature *s = NULL; @@ -498,7 +512,8 @@ end: /** * \brief this function registers unit tests for DetectICode */ -void DetectICodeRegisterTests(void) { +void DetectICodeRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("DetectICodeParseTest01", DetectICodeParseTest01, 1); UtRegisterTest("DetectICodeParseTest02", DetectICodeParseTest02, 1); diff --git a/src/detect-id.c b/src/detect-id.c index ad48785367..d9b861c800 100644 --- a/src/detect-id.c +++ b/src/detect-id.c @@ -57,7 +57,8 @@ void DetectIdFree(void *); /** * \brief Registration function for keyword: id */ -void DetectIdRegister (void) { +void DetectIdRegister (void) +{ sigmatch_table[DETECT_ID].name = "id"; sigmatch_table[DETECT_ID].desc = "match on a specific IP ID value"; sigmatch_table[DETECT_ID].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/Header_keywords#Id"; @@ -251,7 +252,8 @@ error: * * \param id_d pointer to DetectIdData */ -void DetectIdFree(void *ptr) { +void DetectIdFree(void *ptr) +{ DetectIdData *id_d = (DetectIdData *)ptr; SCFree(id_d); } @@ -262,7 +264,8 @@ void DetectIdFree(void *ptr) { * \test DetectIdTestParse01 is a test to make sure that we parse the "id" * option correctly when given valid id option */ -int DetectIdTestParse01 (void) { +int DetectIdTestParse01 (void) +{ DetectIdData *id_d = NULL; id_d = DetectIdParse(" 35402 "); if (id_d != NULL &&id_d->id==35402) { @@ -278,7 +281,8 @@ int DetectIdTestParse01 (void) { * option correctly when given an invalid id option * it should return id_d = NULL */ -int DetectIdTestParse02 (void) { +int DetectIdTestParse02 (void) +{ DetectIdData *id_d = NULL; id_d = DetectIdParse("65537"); if (id_d == NULL) { @@ -294,7 +298,8 @@ int DetectIdTestParse02 (void) { * option correctly when given an invalid id option * it should return id_d = NULL */ -int DetectIdTestParse03 (void) { +int DetectIdTestParse03 (void) +{ DetectIdData *id_d = NULL; id_d = DetectIdParse("12what?"); if (id_d == NULL) { @@ -309,7 +314,8 @@ 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) { +int DetectIdTestParse04 (void) +{ DetectIdData *id_d = NULL; /* yep, look if we trim blank spaces correctly and ignore "'s */ id_d = DetectIdParse(" \"35402\" "); @@ -325,7 +331,8 @@ int DetectIdTestParse04 (void) { * \test DetectIdTestSig01 * \brief Test to check "id" keyword with constructed packets */ -int DetectIdTestMatch01(void) { +int DetectIdTestMatch01(void) +{ int result = 0; uint8_t *buf = (uint8_t *)"Hi all!"; uint16_t buflen = strlen((char *)buf); @@ -372,7 +379,8 @@ end: /** * \brief this function registers unit tests for DetectId */ -void DetectIdRegisterTests(void) { +void DetectIdRegisterTests(void) +{ #ifdef UNITTESTS /* UNITTESTS */ UtRegisterTest("DetectIdTestParse01", DetectIdTestParse01, 1); UtRegisterTest("DetectIdTestParse02", DetectIdTestParse02, 1); diff --git a/src/detect-ipopts.c b/src/detect-ipopts.c index 3791966cb0..a8bfc065b6 100644 --- a/src/detect-ipopts.c +++ b/src/detect-ipopts.c @@ -54,7 +54,8 @@ void DetectIpOptsFree(void *); /** * \brief Registration function for ipopts: keyword */ -void DetectIpOptsRegister (void) { +void DetectIpOptsRegister (void) +{ sigmatch_table[DETECT_IPOPTS].name = "ipopts"; sigmatch_table[DETECT_IPOPTS].desc = "check if a specific IP option is set"; sigmatch_table[DETECT_IPOPTS].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/Header_keywords#Ipopts"; @@ -219,7 +220,8 @@ error: * * \param de pointer to DetectIpOptsData */ -void DetectIpOptsFree(void *de_ptr) { +void DetectIpOptsFree(void *de_ptr) +{ DetectIpOptsData *de = (DetectIpOptsData *)de_ptr; if(de) SCFree(de); } @@ -235,7 +237,8 @@ void DetectIpOptsFree(void *de_ptr) { * \retval 1 on succces * \retval 0 on failure */ -int IpOptsTestParse01 (void) { +int IpOptsTestParse01 (void) +{ DetectIpOptsData *de = NULL; de = DetectIpOptsParse("lsrr"); if (de) { @@ -252,7 +255,8 @@ int IpOptsTestParse01 (void) { * \retval 1 on succces * \retval 0 on failure */ -int IpOptsTestParse02 (void) { +int IpOptsTestParse02 (void) +{ DetectIpOptsData *de = NULL; de = DetectIpOptsParse("invalidopt"); if (de) { @@ -269,7 +273,8 @@ int IpOptsTestParse02 (void) { * \retval 1 on succces * \retval 0 on failure */ -int IpOptsTestParse03 (void) { +int IpOptsTestParse03 (void) +{ Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) return 0; @@ -320,7 +325,8 @@ error: * \retval 1 on succces * \retval 0 on failure */ -int IpOptsTestParse04 (void) { +int IpOptsTestParse04 (void) +{ Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) return 0; @@ -369,7 +375,8 @@ error: /** * \brief this function registers unit tests for IpOpts */ -void IpOptsRegisterTests(void) { +void IpOptsRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("IpOptsTestParse01", IpOptsTestParse01, 1); UtRegisterTest("IpOptsTestParse02", IpOptsTestParse02, 0); diff --git a/src/detect-ipproto.c b/src/detect-ipproto.c index 934cbed2f9..a404036818 100644 --- a/src/detect-ipproto.c +++ b/src/detect-ipproto.c @@ -573,7 +573,8 @@ void DetectIPProtoRemoveAllSMs(Signature *s) return; } -static void DetectIPProtoFree(void *ptr) { +static void DetectIPProtoFree(void *ptr) +{ DetectIPProtoData *data = (DetectIPProtoData *)ptr; if (data) { SCFree(data); diff --git a/src/detect-iprep.c b/src/detect-iprep.c index 0491f43eef..820bfee3ae 100644 --- a/src/detect-iprep.c +++ b/src/detect-iprep.c @@ -54,7 +54,8 @@ static int DetectIPRepSetup (DetectEngineCtx *, Signature *, char *); void DetectIPRepFree (void *); void IPRepRegisterTests(void); -void DetectIPRepRegister (void) { +void DetectIPRepRegister (void) +{ sigmatch_table[DETECT_IPREP].name = "iprep"; sigmatch_table[DETECT_IPREP].Match = DetectIPRepMatch; sigmatch_table[DETECT_IPREP].Setup = DetectIPRepSetup; @@ -87,7 +88,8 @@ error: return; } -static uint8_t GetHostRepSrc(Packet *p, uint8_t cat, uint32_t version) { +static uint8_t GetHostRepSrc(Packet *p, uint8_t cat, uint32_t version) +{ uint8_t val = 0; Host *h = NULL; @@ -125,7 +127,8 @@ static uint8_t GetHostRepSrc(Packet *p, uint8_t cat, uint32_t version) { return val; } -static uint8_t GetHostRepDst(Packet *p, uint8_t cat, uint32_t version) { +static uint8_t GetHostRepDst(Packet *p, uint8_t cat, uint32_t version) +{ uint8_t val = 0; Host *h = NULL; @@ -164,7 +167,8 @@ static uint8_t GetHostRepDst(Packet *p, uint8_t cat, uint32_t version) { return val; } -static inline int RepMatch(uint8_t op, uint8_t val1, uint8_t val2) { +static inline int RepMatch(uint8_t op, uint8_t val1, uint8_t val2) +{ if (op == DETECT_IPREP_OP_GT && val1 > val2) { return 1; } else if (op == DETECT_IPREP_OP_LT && val1 < val2) { @@ -367,7 +371,8 @@ error: return -1; } -void DetectIPRepFree (void *ptr) { +void DetectIPRepFree (void *ptr) +{ DetectIPRepData *fd = (DetectIPRepData *)ptr; if (fd == NULL) @@ -382,7 +387,8 @@ void DetectIPRepFree (void *ptr) { /** * \brief this function registers unit tests for IPRep */ -void IPRepRegisterTests(void) { +void IPRepRegisterTests(void) +{ #ifdef UNITTESTS #endif /* UNITTESTS */ } diff --git a/src/detect-isdataat.c b/src/detect-isdataat.c index cb754bcc77..9c515c145d 100644 --- a/src/detect-isdataat.c +++ b/src/detect-isdataat.c @@ -424,7 +424,8 @@ end: * * \param idad pointer to DetectIsdataatData */ -void DetectIsdataatFree(void *ptr) { +void DetectIsdataatFree(void *ptr) +{ DetectIsdataatData *idad = (DetectIsdataatData *)ptr; SCFree(idad); } @@ -436,7 +437,8 @@ void DetectIsdataatFree(void *ptr) { * \test DetectIsdataatTestParse01 is a test to make sure that we return a correct IsdataatData structure * when given valid isdataat opt */ -int DetectIsdataatTestParse01 (void) { +int DetectIsdataatTestParse01 (void) +{ int result = 0; DetectIsdataatData *idad = NULL; idad = DetectIsdataatParse("30 ", NULL); @@ -452,7 +454,8 @@ 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) { +int DetectIsdataatTestParse02 (void) +{ int result = 0; DetectIsdataatData *idad = NULL; idad = DetectIsdataatParse("30 , relative", NULL); @@ -468,7 +471,8 @@ 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) { +int DetectIsdataatTestParse03 (void) +{ int result = 0; DetectIsdataatData *idad = NULL; idad = DetectIsdataatParse("30,relative, rawbytes ", NULL); @@ -1113,7 +1117,8 @@ static int DetectIsdataatTestParse16(void) * \test DetectIsdataatTestPacket01 is a test to check matches of * isdataat, and isdataat relative */ -int DetectIsdataatTestPacket01 (void) { +int DetectIsdataatTestPacket01 (void) +{ int result = 0; uint8_t *buf = (uint8_t *)"Hi all!"; uint16_t buflen = strlen((char *)buf); @@ -1154,7 +1159,8 @@ end: * isdataat, and isdataat relative works if the previous keyword is pcre * (bug 144) */ -int DetectIsdataatTestPacket02 (void) { +int DetectIsdataatTestPacket02 (void) +{ int result = 0; uint8_t *buf = (uint8_t *)"GET /AllWorkAndNoPlayMakesWillADullBoy HTTP/1.0" "User-Agent: Wget/1.11.4" @@ -1185,7 +1191,8 @@ end: * isdataat, and isdataat relative works if the previous keyword is byte_jump * (bug 146) */ -int DetectIsdataatTestPacket03 (void) { +int DetectIsdataatTestPacket03 (void) +{ int result = 0; uint8_t *buf = (uint8_t *)"GET /AllWorkAndNoPlayMakesWillADullBoy HTTP/1.0" "User-Agent: Wget/1.11.4" @@ -1215,7 +1222,8 @@ end: /** * \brief this function registers unit tests for DetectIsdataat */ -void DetectIsdataatRegisterTests(void) { +void DetectIsdataatRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("DetectIsdataatTestParse01", DetectIsdataatTestParse01, 1); UtRegisterTest("DetectIsdataatTestParse02", DetectIsdataatTestParse02, 1); diff --git a/src/detect-itype.c b/src/detect-itype.c index ea7ee032c9..1828dbc025 100644 --- a/src/detect-itype.c +++ b/src/detect-itype.c @@ -54,7 +54,8 @@ void DetectITypeFree(void *); /** * \brief Registration function for itype: keyword */ -void DetectITypeRegister (void) { +void DetectITypeRegister (void) +{ sigmatch_table[DETECT_ITYPE].name = "itype"; sigmatch_table[DETECT_ITYPE].desc = "matching on a specific ICMP type"; sigmatch_table[DETECT_ITYPE].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/Header_keywords#itype"; @@ -97,7 +98,8 @@ error: * \retval 0 no match * \retval 1 match */ -int DetectITypeMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p, Signature *s, SigMatch *m) { +int DetectITypeMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p, Signature *s, SigMatch *m) +{ int ret = 0; uint8_t pitype; DetectITypeData *itd = (DetectITypeData *)m->ctx; @@ -140,7 +142,8 @@ int DetectITypeMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p, * \retval itd pointer to DetectITypeData on success * \retval NULL on failure */ -DetectITypeData *DetectITypeParse(char *itypestr) { +DetectITypeData *DetectITypeParse(char *itypestr) +{ DetectITypeData *itd = NULL; char *args[3] = {NULL, NULL, NULL}; #define MAX_SUBSTRINGS 30 @@ -243,7 +246,8 @@ 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, char *itypestr) +{ DetectITypeData *itd = NULL; SigMatch *sm = NULL; @@ -273,7 +277,8 @@ error: * * \param ptr pointer to DetectITypeData */ -void DetectITypeFree(void *ptr) { +void DetectITypeFree(void *ptr) +{ DetectITypeData *itd = (DetectITypeData *)ptr; SCFree(itd); } @@ -287,7 +292,8 @@ void DetectITypeFree(void *ptr) { /** * \test DetectITypeParseTest01 is a test for setting a valid itype value */ -int DetectITypeParseTest01(void) { +int DetectITypeParseTest01(void) +{ DetectITypeData *itd = NULL; int result = 0; itd = DetectITypeParse("8"); @@ -303,7 +309,8 @@ int DetectITypeParseTest01(void) { * \test DetectITypeParseTest02 is a test for setting a valid itype value * with ">" operator */ -int DetectITypeParseTest02(void) { +int DetectITypeParseTest02(void) +{ DetectITypeData *itd = NULL; int result = 0; itd = DetectITypeParse(">8"); @@ -319,7 +326,8 @@ DetectITypeData *itd = NULL; * \test DetectITypeParseTest03 is a test for setting a valid itype value * with "<" operator */ -int DetectITypeParseTest03(void) { +int DetectITypeParseTest03(void) +{ DetectITypeData *itd = NULL; int result = 0; itd = DetectITypeParse("<8"); @@ -335,7 +343,8 @@ int DetectITypeParseTest03(void) { * \test DetectITypeParseTest04 is a test for setting a valid itype value * with "<>" operator */ -int DetectITypeParseTest04(void) { +int DetectITypeParseTest04(void) +{ DetectITypeData *itd = NULL; int result = 0; itd = DetectITypeParse("8<>20"); @@ -351,7 +360,8 @@ DetectITypeData *itd = NULL; * \test DetectITypeParseTest05 is a test for setting a valid itype value * with spaces all around */ -int DetectITypeParseTest05(void) { +int DetectITypeParseTest05(void) +{ DetectITypeData *itd = NULL; int result = 0; itd = DetectITypeParse(" 8 "); @@ -367,7 +377,8 @@ DetectITypeData *itd = NULL; * \test DetectITypeParseTest06 is a test for setting a valid itype value * with ">" operator and spaces all around */ -int DetectITypeParseTest06(void) { +int DetectITypeParseTest06(void) +{ DetectITypeData *itd = NULL; int result = 0; itd = DetectITypeParse(" > 8 "); @@ -383,7 +394,8 @@ DetectITypeData *itd = NULL; * \test DetectITypeParseTest07 is a test for setting a valid itype value * with "<>" operator and spaces all around */ -int DetectITypeParseTest07(void) { +int DetectITypeParseTest07(void) +{ DetectITypeData *itd = NULL; int result = 0; itd = DetectITypeParse(" 8 <> 20 "); @@ -398,7 +410,8 @@ DetectITypeData *itd = NULL; /** * \test DetectITypeParseTest08 is a test for setting an invalid itype value */ -int DetectITypeParseTest08(void) { +int DetectITypeParseTest08(void) +{ DetectITypeData *itd = NULL; itd = DetectITypeParse("> 8 <> 20"); if (itd == NULL) @@ -412,7 +425,8 @@ 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) { +int DetectITypeMatchTest01(void) +{ Packet *p = NULL; Signature *s = NULL; @@ -499,7 +513,8 @@ end: /** * \brief this function registers unit tests for DetectIType */ -void DetectITypeRegisterTests(void) { +void DetectITypeRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("DetectITypeParseTest01", DetectITypeParseTest01, 1); UtRegisterTest("DetectITypeParseTest02", DetectITypeParseTest02, 1); diff --git a/src/detect-l3proto.c b/src/detect-l3proto.c index 316f1245d0..c67b47c8bb 100644 --- a/src/detect-l3proto.c +++ b/src/detect-l3proto.c @@ -130,7 +130,8 @@ error: * the received packet against the sig. */ -static int DetectL3protoTestSig1(void) { +static int DetectL3protoTestSig1(void) +{ Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) @@ -213,7 +214,8 @@ end: * the received IPv6 packet against the sig. */ -static int DetectL3protoTestSig2(void) { +static int DetectL3protoTestSig2(void) +{ Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) @@ -295,7 +297,8 @@ end: * in conjonction with ip_proto keyword. */ -static int DetectL3protoTestSig3(void) { +static int DetectL3protoTestSig3(void) +{ Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) @@ -378,7 +381,8 @@ end: /** * \brief this function registers unit tests for DetectL3proto */ -void DetectL3protoRegisterTests(void) { +void DetectL3protoRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("DetectL3protoTestSig1", DetectL3protoTestSig1, 1); UtRegisterTest("DetectL3protoTestSig2", DetectL3protoTestSig2, 1); diff --git a/src/detect-luajit-extensions.c b/src/detect-luajit-extensions.c index 0fa3aced21..1ea1497813 100644 --- a/src/detect-luajit-extensions.c +++ b/src/detect-luajit-extensions.c @@ -65,7 +65,8 @@ static const char luaext_key_det_ctx[] = "suricata:det_ctx"; static const char luaext_key_flow[] = "suricata:flow"; static const char luaext_key_need_flow_lock[] = "suricata:need_flow_lock"; -static int LuajitGetFlowvar(lua_State *luastate) { +static int LuajitGetFlowvar(lua_State *luastate) +{ uint16_t idx; int id; Flow *f; @@ -157,7 +158,8 @@ static int LuajitGetFlowvar(lua_State *luastate) { } -int LuajitSetFlowvar(lua_State *luastate) { +int LuajitSetFlowvar(lua_State *luastate) +{ uint16_t idx; int id; Flow *f; @@ -269,7 +271,8 @@ int LuajitSetFlowvar(lua_State *luastate) { return 0; } -static int LuajitGetFlowint(lua_State *luastate) { +static int LuajitGetFlowint(lua_State *luastate) +{ uint16_t idx; int id; Flow *f; @@ -354,7 +357,8 @@ static int LuajitGetFlowint(lua_State *luastate) { } -int LuajitSetFlowint(lua_State *luastate) { +int LuajitSetFlowint(lua_State *luastate) +{ uint16_t idx; int id; Flow *f; @@ -443,7 +447,8 @@ int LuajitSetFlowint(lua_State *luastate) { return 0; } -static int LuajitIncrFlowint(lua_State *luastate) { +static int LuajitIncrFlowint(lua_State *luastate) +{ uint16_t idx; int id; Flow *f; @@ -526,7 +531,8 @@ static int LuajitIncrFlowint(lua_State *luastate) { } -static int LuajitDecrFlowint(lua_State *luastate) { +static int LuajitDecrFlowint(lua_State *luastate) +{ uint16_t idx; int id; Flow *f; @@ -609,7 +615,8 @@ static int LuajitDecrFlowint(lua_State *luastate) { } -void LuajitExtensionsMatchSetup(lua_State *lua_state, DetectLuajitData *ld, DetectEngineThreadCtx *det_ctx, Flow *f, int need_flow_lock) { +void LuajitExtensionsMatchSetup(lua_State *lua_state, DetectLuajitData *ld, DetectEngineThreadCtx *det_ctx, Flow *f, int need_flow_lock) +{ SCLogDebug("det_ctx %p, f %p", det_ctx, f); /* luajit keyword data */ @@ -636,7 +643,8 @@ void LuajitExtensionsMatchSetup(lua_State *lua_state, DetectLuajitData *ld, Dete /** * \brief Register Suricata Lua functions */ -int LuajitRegisterExtensions(lua_State *lua_state) { +int LuajitRegisterExtensions(lua_State *lua_state) +{ lua_pushcfunction(lua_state, LuajitGetFlowvar); lua_setglobal(lua_state, "ScFlowvarGet"); diff --git a/src/detect-luajit.c b/src/detect-luajit.c index 0d1aff6176..dcb74c35b8 100644 --- a/src/detect-luajit.c +++ b/src/detect-luajit.c @@ -61,7 +61,8 @@ #ifndef HAVE_LUA -static int DetectLuajitSetupNoSupport (DetectEngineCtx *a, Signature *b, char *c) { +static int DetectLuajitSetupNoSupport (DetectEngineCtx *a, Signature *b, char *c) +{ SCLogError(SC_ERR_NO_LUAJIT_SUPPORT, "no LuaJIT support built in, needed for luajit keyword"); return -1; } @@ -69,7 +70,8 @@ static int DetectLuajitSetupNoSupport (DetectEngineCtx *a, Signature *b, char *c /** * \brief Registration function for keyword: luajit */ -void DetectLuajitRegister(void) { +void DetectLuajitRegister(void) +{ sigmatch_table[DETECT_LUAJIT].name = "luajit"; sigmatch_table[DETECT_LUAJIT].alias = "lua"; sigmatch_table[DETECT_LUAJIT].Setup = DetectLuajitSetupNoSupport; @@ -112,7 +114,8 @@ static void DetectLuajitFree(void *); /** * \brief Registration function for keyword: luajit */ -void DetectLuajitRegister(void) { +void DetectLuajitRegister(void) +{ sigmatch_table[DETECT_LUAJIT].name = "luajit"; sigmatch_table[DETECT_LUAJIT].alias = "lua"; sigmatch_table[DETECT_LUAJIT].desc = "match via a luajit script"; @@ -148,11 +151,13 @@ void DetectLuajitRegister(void) { #define DATATYPE_HTTP_RESPONSE_HEADERS_RAW (1<<14) #ifdef HAVE_LUAJIT -static void *LuaStatePoolAlloc(void) { +static void *LuaStatePoolAlloc(void) +{ return luaL_newstate(); } -static void LuaStatePoolFree(void *d) { +static void LuaStatePoolFree(void *d) +{ lua_State *s = (lua_State *)d; if (s != NULL) lua_close(s); @@ -163,7 +168,8 @@ static void LuaStatePoolFree(void *d) { * \param num keyword instances * \param reloads bool indicating we have rule reloads enabled */ -int DetectLuajitSetupStatesPool(int num, int reloads) { +int DetectLuajitSetupStatesPool(int num, int reloads) +{ int retval = 0; pthread_mutex_lock(&luajit_states_lock); @@ -198,7 +204,8 @@ int DetectLuajitSetupStatesPool(int num, int reloads) { } #endif /* HAVE_LUAJIT */ -static lua_State *DetectLuajitGetState(void) { +static lua_State *DetectLuajitGetState(void) +{ lua_State *s = NULL; #ifdef HAVE_LUAJIT @@ -212,7 +219,8 @@ static lua_State *DetectLuajitGetState(void) { return s; } -static void DetectLuajitReturnState(lua_State *s) { +static void DetectLuajitReturnState(lua_State *s) +{ if (s != NULL) { #ifdef HAVE_LUAJIT pthread_mutex_lock(&luajit_states_lock); @@ -225,7 +233,8 @@ static void DetectLuajitReturnState(lua_State *s) { } /** \brief dump stack from lua state to screen */ -void LuaDumpStack(lua_State *state) { +void LuaDumpStack(lua_State *state) +{ int size = lua_gettop(state); int i; @@ -507,7 +516,8 @@ static int DetectLuajitMatch (ThreadVars *tv, DetectEngineThreadCtx *det_ctx, static const char *ut_script = NULL; #endif -static void *DetectLuajitThreadInit(void *data) { +static void *DetectLuajitThreadInit(void *data) +{ int status; DetectLuajitData *luajit = (DetectLuajitData *)data; BUG_ON(luajit == NULL); @@ -573,7 +583,8 @@ error: return NULL; } -static void DetectLuajitThreadFree(void *ctx) { +static void DetectLuajitThreadFree(void *ctx) +{ if (ctx != NULL) { DetectLuajitThreadData *t = (DetectLuajitThreadData *)ctx; if (t->luastate != NULL) @@ -620,7 +631,8 @@ error: return NULL; } -static int DetectLuaSetupPrime(DetectEngineCtx *de_ctx, DetectLuajitData *ld) { +static int DetectLuaSetupPrime(DetectEngineCtx *de_ctx, DetectLuajitData *ld) +{ int status; lua_State *luastate = luaL_newstate(); @@ -912,7 +924,8 @@ error: /** \brief post-sig parse function to set the sid,rev,gid into the * ctx, as this isn't available yet during parsing. */ -void DetectLuajitPostSetup(Signature *s) { +void DetectLuajitPostSetup(Signature *s) +{ int i; SigMatch *sm; @@ -934,7 +947,8 @@ void DetectLuajitPostSetup(Signature *s) { * * \param luajit pointer to DetectLuajitData */ -static void DetectLuajitFree(void *ptr) { +static void DetectLuajitFree(void *ptr) +{ if (ptr != NULL) { DetectLuajitData *luajit = (DetectLuajitData *)ptr; @@ -949,7 +963,8 @@ static void DetectLuajitFree(void *ptr) { #ifdef UNITTESTS /** \test http buffer */ -static int LuajitMatchTest01(void) { +static int LuajitMatchTest01(void) +{ const char script[] = "function init (args)\n" " local needs = {}\n" @@ -1112,7 +1127,8 @@ end: } /** \test payload buffer */ -static int LuajitMatchTest02(void) { +static int LuajitMatchTest02(void) +{ const char script[] = "function init (args)\n" " local needs = {}\n" @@ -1247,7 +1263,8 @@ end: } /** \test packet buffer */ -static int LuajitMatchTest03(void) { +static int LuajitMatchTest03(void) +{ const char script[] = "function init (args)\n" " local needs = {}\n" @@ -1382,7 +1399,8 @@ end: } /** \test http buffer, flowints */ -static int LuajitMatchTest04(void) { +static int LuajitMatchTest04(void) +{ const char script[] = "function init (args)\n" " local needs = {}\n" @@ -1536,7 +1554,8 @@ end: } /** \test http buffer, flowints */ -static int LuajitMatchTest05(void) { +static int LuajitMatchTest05(void) +{ const char script[] = "function init (args)\n" " local needs = {}\n" @@ -1683,7 +1702,8 @@ end: } /** \test http buffer, flowints */ -static int LuajitMatchTest06(void) { +static int LuajitMatchTest06(void) +{ const char script[] = "function init (args)\n" " local needs = {}\n" @@ -1836,7 +1856,8 @@ end: #endif -void DetectLuajitRegisterTests(void) { +void DetectLuajitRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("LuajitMatchTest01", LuajitMatchTest01, 1); UtRegisterTest("LuajitMatchTest02", LuajitMatchTest02, 1); diff --git a/src/detect-mark.c b/src/detect-mark.c index 926c1a6e9a..d641df6fd2 100644 --- a/src/detect-mark.c +++ b/src/detect-mark.c @@ -50,7 +50,8 @@ void DetectMarkDataFree(void *ptr); * \brief Registration function for nfq_set_mark: keyword */ -void DetectMarkRegister (void) { +void DetectMarkRegister (void) +{ sigmatch_table[DETECT_MARK].name = "nfq_set_mark"; sigmatch_table[DETECT_MARK].Match = DetectMarkPacket; sigmatch_table[DETECT_MARK].Setup = DetectMarkSetup; @@ -260,7 +261,8 @@ int DetectMarkPacket(ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p, S * \retval 1 on succces * \retval 0 on failure */ -static int MarkTestParse01 (void) { +static int MarkTestParse01 (void) +{ DetectMarkData *data; data = DetectMarkParse("1/1"); @@ -279,7 +281,8 @@ static int MarkTestParse01 (void) { * \retval 1 on succces * \retval 0 on failure */ -static int MarkTestParse02 (void) { +static int MarkTestParse02 (void) +{ DetectMarkData *data; data = DetectMarkParse("4"); @@ -298,7 +301,8 @@ static int MarkTestParse02 (void) { * \retval 1 on succces * \retval 0 on failure */ -static int MarkTestParse03 (void) { +static int MarkTestParse03 (void) +{ DetectMarkData *data; data = DetectMarkParse("0x10/0xff"); @@ -317,7 +321,8 @@ static int MarkTestParse03 (void) { * \retval 1 on succces * \retval 0 on failure */ -static int MarkTestParse04 (void) { +static int MarkTestParse04 (void) +{ DetectMarkData *data; data = DetectMarkParse("0x1g/0xff"); @@ -337,7 +342,8 @@ static int MarkTestParse04 (void) { /** * \brief this function registers unit tests for Mark */ -void MarkRegisterTests(void) { +void MarkRegisterTests(void) +{ #if defined UNITTESTS && defined NFQ UtRegisterTest("MarkTestParse01", MarkTestParse01, 1); UtRegisterTest("MarkTestParse02", MarkTestParse02, 0); diff --git a/src/detect-metadata.c b/src/detect-metadata.c index fd2088e94e..3055ec7886 100644 --- a/src/detect-metadata.c +++ b/src/detect-metadata.c @@ -31,7 +31,8 @@ static int DetectMetadataSetup (DetectEngineCtx *, Signature *, char *); -void DetectMetadataRegister (void) { +void DetectMetadataRegister (void) +{ sigmatch_table[DETECT_METADATA].name = "metadata"; sigmatch_table[DETECT_METADATA].desc = "ignored by suricata"; sigmatch_table[DETECT_METADATA].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/Meta-settings#Metadata"; diff --git a/src/detect-msg.c b/src/detect-msg.c index 48f53e2fd9..abd861001d 100644 --- a/src/detect-msg.c +++ b/src/detect-msg.c @@ -36,7 +36,8 @@ static int DetectMsgSetup (DetectEngineCtx *, Signature *, char *); void DetectMsgRegisterTests(void); -void DetectMsgRegister (void) { +void DetectMsgRegister (void) +{ sigmatch_table[DETECT_MSG].name = "msg"; sigmatch_table[DETECT_MSG].desc = "information about the rule and the possible alert"; sigmatch_table[DETECT_MSG].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/Meta-settings#msg-message"; @@ -201,7 +202,8 @@ end: /** * \brief this function registers unit tests for DetectMsg */ -void DetectMsgRegisterTests(void) { +void DetectMsgRegisterTests(void) +{ #ifdef UNITTESTS /* UNITTESTS */ UtRegisterTest("DetectMsgParseTest01", DetectMsgParseTest01, 1); UtRegisterTest("DetectMsgParseTest02", DetectMsgParseTest02, 1); diff --git a/src/detect-noalert.c b/src/detect-noalert.c index e4b6058b15..b4f69af42f 100644 --- a/src/detect-noalert.c +++ b/src/detect-noalert.c @@ -29,7 +29,8 @@ static int DetectNoalertSetup (DetectEngineCtx *, Signature *, char *); -void DetectNoalertRegister (void) { +void DetectNoalertRegister (void) +{ sigmatch_table[DETECT_NOALERT].name = "noalert"; sigmatch_table[DETECT_NOALERT].Match = NULL; sigmatch_table[DETECT_NOALERT].Setup = DetectNoalertSetup; diff --git a/src/detect-offset.c b/src/detect-offset.c index 34f45736e9..5786ac3f2f 100644 --- a/src/detect-offset.c +++ b/src/detect-offset.c @@ -41,7 +41,8 @@ static int DetectOffsetSetup(DetectEngineCtx *, Signature *, char *); -void DetectOffsetRegister (void) { +void DetectOffsetRegister (void) +{ sigmatch_table[DETECT_OFFSET].name = "offset"; sigmatch_table[DETECT_OFFSET].desc = "designate from which byte in the payload will be checked to find a match"; sigmatch_table[DETECT_OFFSET].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/Payload_keywords#Offset"; diff --git a/src/detect-parse.c b/src/detect-parse.c index 77f50e9f36..4de1d37d58 100644 --- a/src/detect-parse.c +++ b/src/detect-parse.c @@ -227,15 +227,18 @@ int DetectEngineContentModifierBufferSetup(DetectEngineCtx *de_ctx, Signature *s return ret; } -uint32_t DbgGetSrcPortAnyCnt(void) { +uint32_t DbgGetSrcPortAnyCnt(void) +{ return dbg_srcportany_cnt; } -uint32_t DbgGetDstPortAnyCnt(void) { +uint32_t DbgGetDstPortAnyCnt(void) +{ return dbg_dstportany_cnt; } -SigMatch *SigMatchAlloc(void) { +SigMatch *SigMatchAlloc(void) +{ SigMatch *sm = SCMalloc(sizeof(SigMatch)); if (unlikely(sm == NULL)) return NULL; @@ -249,7 +252,8 @@ SigMatch *SigMatchAlloc(void) { /** \brief free a SigMatch * \param sm SigMatch to free. */ -void SigMatchFree(SigMatch *sm) { +void SigMatchFree(SigMatch *sm) +{ if (sm == NULL) return; @@ -263,7 +267,8 @@ void SigMatchFree(SigMatch *sm) { } /* Get the detection module by name */ -SigTableElmt *SigTableGet(char *name) { +SigTableElmt *SigTableGet(char *name) +{ SigTableElmt *st = NULL; int i = 0; @@ -456,7 +461,8 @@ int SigMatchListSMBelongsTo(Signature *s, SigMatch *key_sm) return -1; } -void SigParsePrepare(void) { +void SigParsePrepare(void) +{ char *regexstr = CONFIG_PCRE; const char *eb; int eo; @@ -495,7 +501,8 @@ void SigParsePrepare(void) { } } -static int SigParseOptions(DetectEngineCtx *de_ctx, Signature *s, char *optstr, char *output, size_t output_size) { +static int SigParseOptions(DetectEngineCtx *de_ctx, Signature *s, char *optstr, char *output, size_t output_size) +{ #define MAX_SUBSTRINGS 30 int ov[MAX_SUBSTRINGS]; int ret = 0; @@ -601,7 +608,8 @@ error: * \retval 0 On successfully parsing the protocl sent as the argument. * \retval -1 On failure */ -int SigParseProto(Signature *s, const char *protostr) { +int SigParseProto(Signature *s, const char *protostr) +{ SCEnter(); int r = DetectProtoParse(&s->proto, (char *)protostr); @@ -673,7 +681,8 @@ int SigParsePort(Signature *s, const char *portstr, char flag) /** \retval 1 valid * \retval 0 invalid */ -static int SigParseActionRejectValidate(const char *action) { +static int SigParseActionRejectValidate(const char *action) +{ #ifdef HAVE_LIBNET11 #ifdef HAVE_LIBCAP_NG if (sc_set_caps == TRUE) { @@ -703,7 +712,8 @@ static int SigParseActionRejectValidate(const char *action) { * Signature. * \retval -1 On failure. */ -int SigParseAction(Signature *s, const char *action) { +int SigParseAction(Signature *s, const char *action) +{ if (strcasecmp(action, "alert") == 0) { s->action = ACTION_ALERT; return 0; @@ -743,7 +753,8 @@ int SigParseAction(Signature *s, const char *action) { * \internal * \brief split a signature string into a few blocks for further parsing */ -static int SigParseBasics(Signature *s, char *sigstr, SignatureParser *parser, uint8_t addrs_direction) { +static int SigParseBasics(Signature *s, char *sigstr, SignatureParser *parser, uint8_t addrs_direction) +{ #define MAX_SUBSTRINGS 30 int ov[MAX_SUBSTRINGS]; int ret = 0; @@ -828,7 +839,8 @@ 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, char *sigstr, uint8_t addrs_direction) +{ SCEnter(); SignatureParser parser; @@ -870,7 +882,8 @@ int SigParse(DetectEngineCtx *de_ctx, Signature *s, char *sigstr, uint8_t addrs_ SCReturnInt(ret); } -Signature *SigAlloc (void) { +Signature *SigAlloc (void) +{ Signature *sig = SCMalloc(sizeof(Signature)); if (unlikely(sig == NULL)) return NULL; @@ -892,7 +905,8 @@ Signature *SigAlloc (void) { * * \param s Pointer to the signature */ -static void SigRefFree (Signature *s) { +static void SigRefFree (Signature *s) +{ SCEnter(); DetectReference *ref = NULL; @@ -915,7 +929,8 @@ static void SigRefFree (Signature *s) { SCReturn; } -void SigFree(Signature *s) { +void SigFree(Signature *s) +{ if (s == NULL) return; @@ -972,7 +987,8 @@ void SigFree(Signature *s) { * * \param s the signature */ -static void SigBuildAddressMatchArray(Signature *s) { +static void SigBuildAddressMatchArray(Signature *s) +{ /* source addresses */ uint16_t cnt = 0; uint16_t idx = 0; @@ -1079,7 +1095,8 @@ static void SigBuildAddressMatchArray(Signature *s) { * \retval 0 invalid * \retval 1 valid */ -int SigValidate(DetectEngineCtx *de_ctx, Signature *s) { +int SigValidate(DetectEngineCtx *de_ctx, Signature *s) +{ uint32_t u = 0; uint32_t sig_flags = 0; SigMatch *sm, *pm; @@ -1879,7 +1896,8 @@ error: */ #ifdef UNITTESTS -int SigParseTest01 (void) { +int SigParseTest01 (void) +{ int result = 1; Signature *sig = NULL; @@ -1897,7 +1915,8 @@ end: return result; } -int SigParseTest02 (void) { +int SigParseTest02 (void) +{ int result = 0; Signature *sig = NULL; DetectPort *port = NULL; @@ -1936,7 +1955,8 @@ end: /** * \test SigParseTest03 test for invalid direction operator in rule */ -int SigParseTest03 (void) { +int SigParseTest03 (void) +{ int result = 1; Signature *sig = NULL; @@ -1956,7 +1976,8 @@ end: return result; } -int SigParseTest04 (void) { +int SigParseTest04 (void) +{ int result = 1; Signature *sig = NULL; @@ -1975,7 +1996,8 @@ end: } /** \test Port validation */ -int SigParseTest05 (void) { +int SigParseTest05 (void) +{ int result = 0; Signature *sig = NULL; @@ -1997,7 +2019,8 @@ end: } /** \test Parsing bug debugging at 2010-03-18 */ -int SigParseTest06 (void) { +int SigParseTest06 (void) +{ int result = 0; Signature *sig = NULL; @@ -2023,7 +2046,8 @@ end: /** * \test Parsing duplicate sigs. */ -int SigParseTest07(void) { +int SigParseTest07(void) +{ int result = 0; DetectEngineCtx *de_ctx = DetectEngineCtxInit(); @@ -2044,7 +2068,8 @@ end: /** * \test Parsing duplicate sigs. */ -int SigParseTest08(void) { +int SigParseTest08(void) +{ int result = 0; DetectEngineCtx *de_ctx = DetectEngineCtxInit(); @@ -2066,7 +2091,8 @@ end: /** * \test Parsing duplicate sigs. */ -int SigParseTest09(void) { +int SigParseTest09(void) +{ int result = 1; DetectEngineCtx *de_ctx = DetectEngineCtxInit(); @@ -2116,7 +2142,8 @@ end: /** * \test Parsing duplicate sigs. */ -int SigParseTest10(void) { +int SigParseTest10(void) +{ int result = 1; DetectEngineCtx *de_ctx = DetectEngineCtxInit(); @@ -2147,7 +2174,8 @@ end: * \test Parsing sig with trailing space(s) as reported by * Morgan Cox on oisf-users. */ -int SigParseTest11(void) { +int SigParseTest11(void) +{ int result = 0; DetectEngineCtx *de_ctx = DetectEngineCtxInit(); @@ -2178,7 +2206,8 @@ end: /** * \test file_data with rawbytes */ -static int SigParseTest12(void) { +static int SigParseTest12(void) +{ int result = 0; DetectEngineCtx *de_ctx = DetectEngineCtxInit(); @@ -2203,7 +2232,8 @@ end: /** * \test packet/stream sig */ -static int SigParseTest13(void) { +static int SigParseTest13(void) +{ int result = 0; DetectEngineCtx *de_ctx = DetectEngineCtxInit(); @@ -2239,7 +2269,8 @@ end: /** * \test packet/stream sig */ -static int SigParseTest14(void) { +static int SigParseTest14(void) +{ int result = 0; DetectEngineCtx *de_ctx = DetectEngineCtxInit(); @@ -2275,7 +2306,8 @@ end: /** * \test packet/stream sig */ -static int SigParseTest15(void) { +static int SigParseTest15(void) +{ int result = 0; DetectEngineCtx *de_ctx = DetectEngineCtxInit(); @@ -2311,7 +2343,8 @@ end: /** * \test packet/stream sig */ -static int SigParseTest16(void) { +static int SigParseTest16(void) +{ int result = 0; DetectEngineCtx *de_ctx = DetectEngineCtxInit(); @@ -2347,7 +2380,8 @@ end: /** * \test packet/stream sig */ -static int SigParseTest17(void) { +static int SigParseTest17(void) +{ int result = 0; DetectEngineCtx *de_ctx = DetectEngineCtxInit(); @@ -2381,7 +2415,8 @@ end: } /** \test sid value too large. Bug #779 */ -static int SigParseTest18 (void) { +static int SigParseTest18 (void) +{ int result = 0; DetectEngineCtx *de_ctx = DetectEngineCtxInit(); @@ -2399,7 +2434,8 @@ end: } /** \test gid value too large. Related to bug #779 */ -static int SigParseTest19 (void) { +static int SigParseTest19 (void) +{ int result = 0; DetectEngineCtx *de_ctx = DetectEngineCtxInit(); @@ -2417,7 +2453,8 @@ end: } /** \test rev value too large. Related to bug #779 */ -static int SigParseTest20 (void) { +static int SigParseTest20 (void) +{ int result = 0; DetectEngineCtx *de_ctx = DetectEngineCtxInit(); @@ -2435,7 +2472,8 @@ end: } /** \test address parsing */ -static int SigParseTest21 (void) { +static int SigParseTest21 (void) +{ int result = 0; DetectEngineCtx *de_ctx = DetectEngineCtxInit(); @@ -2453,7 +2491,8 @@ end: } /** \test address parsing */ -static int SigParseTest22 (void) { +static int SigParseTest22 (void) +{ int result = 0; DetectEngineCtx *de_ctx = DetectEngineCtxInit(); @@ -2471,7 +2510,8 @@ end: } /** \test Direction operator validation (invalid) */ -int SigParseBidirecTest06 (void) { +int SigParseBidirecTest06 (void) +{ int result = 1; Signature *sig = NULL; @@ -2490,7 +2530,8 @@ end: } /** \test Direction operator validation (invalid) */ -int SigParseBidirecTest07 (void) { +int SigParseBidirecTest07 (void) +{ int result = 1; Signature *sig = NULL; @@ -2509,7 +2550,8 @@ end: } /** \test Direction operator validation (invalid) */ -int SigParseBidirecTest08 (void) { +int SigParseBidirecTest08 (void) +{ int result = 1; Signature *sig = NULL; @@ -2528,7 +2570,8 @@ end: } /** \test Direction operator validation (invalid) */ -int SigParseBidirecTest09 (void) { +int SigParseBidirecTest09 (void) +{ int result = 1; Signature *sig = NULL; @@ -2547,7 +2590,8 @@ end: } /** \test Direction operator validation (invalid) */ -int SigParseBidirecTest10 (void) { +int SigParseBidirecTest10 (void) +{ int result = 1; Signature *sig = NULL; @@ -2566,7 +2610,8 @@ end: } /** \test Direction operator validation (invalid) */ -int SigParseBidirecTest11 (void) { +int SigParseBidirecTest11 (void) +{ int result = 1; Signature *sig = NULL; @@ -2585,7 +2630,8 @@ end: } /** \test Direction operator validation (invalid) */ -int SigParseBidirecTest12 (void) { +int SigParseBidirecTest12 (void) +{ int result = 1; Signature *sig = NULL; @@ -2604,7 +2650,8 @@ end: } /** \test Direction operator validation (valid) */ -int SigParseBidirecTest13 (void) { +int SigParseBidirecTest13 (void) +{ int result = 1; Signature *sig = NULL; @@ -2622,7 +2669,8 @@ end: } /** \test Direction operator validation (valid) */ -int SigParseBidirecTest14 (void) { +int SigParseBidirecTest14 (void) +{ int result = 1; Signature *sig = NULL; @@ -2642,7 +2690,8 @@ end: /** \test Ensure that we don't set bidirectional in a * normal (one direction) Signature */ -int SigTestBidirec01 (void) { +int SigTestBidirec01 (void) +{ Signature *sig = NULL; int result = 0; @@ -2672,7 +2721,8 @@ end: } /** \test Ensure that we set a bidirectional Signature correctly */ -int SigTestBidirec02 (void) { +int SigTestBidirec02 (void) +{ int result = 0; Signature *sig = NULL; Signature *copy = NULL; @@ -2716,7 +2766,8 @@ end: * and we install it with the rest of the signatures, checking * also that it match with the correct addr directions */ -int SigTestBidirec03 (void) { +int SigTestBidirec03 (void) +{ int result = 0; Signature *sig = NULL; Packet *p = NULL; @@ -2836,7 +2887,8 @@ end: * and we install it with the rest of the signatures, checking * also that it match with the correct addr directions */ -int SigTestBidirec04 (void) { +int SigTestBidirec04 (void) +{ int result = 0; Signature *sig = NULL; Packet *p = NULL; @@ -2985,7 +3037,8 @@ end: /** * \test check that we don't allow invalid negation options */ -static int SigParseTestNegation01 (void) { +static int SigParseTestNegation01 (void) +{ int result = 0; DetectEngineCtx *de_ctx; Signature *s=NULL; @@ -3010,7 +3063,8 @@ end: /** * \test check that we don't allow invalid negation options */ -static int SigParseTestNegation02 (void) { +static int SigParseTestNegation02 (void) +{ int result = 0; DetectEngineCtx *de_ctx; Signature *s=NULL; @@ -3035,7 +3089,8 @@ end: /** * \test check that we don't allow invalid negation options */ -static int SigParseTestNegation03 (void) { +static int SigParseTestNegation03 (void) +{ int result = 0; DetectEngineCtx *de_ctx; Signature *s=NULL; @@ -3060,7 +3115,8 @@ end: /** * \test check that we don't allow invalid negation options */ -static int SigParseTestNegation04 (void) { +static int SigParseTestNegation04 (void) +{ int result = 0; DetectEngineCtx *de_ctx; Signature *s=NULL; @@ -3085,7 +3141,8 @@ end: /** * \test check that we don't allow invalid negation options */ -static int SigParseTestNegation05 (void) { +static int SigParseTestNegation05 (void) +{ int result = 0; DetectEngineCtx *de_ctx; Signature *s=NULL; @@ -3110,7 +3167,8 @@ end: /** * \test check that we don't allow invalid negation options */ -static int SigParseTestNegation06 (void) { +static int SigParseTestNegation06 (void) +{ int result = 0; DetectEngineCtx *de_ctx; Signature *s=NULL; @@ -3136,7 +3194,8 @@ end: /** * \test check that we don't allow invalid negation options */ -static int SigParseTestNegation07 (void) { +static int SigParseTestNegation07 (void) +{ int result = 0; DetectEngineCtx *de_ctx; Signature *s=NULL; @@ -3162,7 +3221,8 @@ end: /** * \test check valid negation bug 1079 */ -static int SigParseTestNegation08 (void) { +static int SigParseTestNegation08 (void) +{ int result = 0; DetectEngineCtx *de_ctx; Signature *s=NULL; @@ -3187,7 +3247,8 @@ end: /** * \test mpm */ -int SigParseTestMpm01 (void) { +int SigParseTestMpm01 (void) +{ int result = 0; Signature *sig = NULL; @@ -3227,7 +3288,8 @@ end: /** * \test mpm */ -int SigParseTestMpm02 (void) { +int SigParseTestMpm02 (void) +{ int result = 0; Signature *sig = NULL; @@ -3267,7 +3329,8 @@ end: /** * \test test tls (app layer) rule */ -static int SigParseTestAppLayerTLS01(void) { +static int SigParseTestAppLayerTLS01(void) +{ int result = 0; DetectEngineCtx *de_ctx; Signature *s=NULL; @@ -3301,7 +3364,8 @@ end: /** * \test test tls (app layer) rule */ -static int SigParseTestAppLayerTLS02(void) { +static int SigParseTestAppLayerTLS02(void) +{ int result = 0; DetectEngineCtx *de_ctx; Signature *s=NULL; @@ -3334,7 +3398,8 @@ end: /** * \test test tls (app layer) rule */ -static int SigParseTestAppLayerTLS03(void) { +static int SigParseTestAppLayerTLS03(void) +{ int result = 0; DetectEngineCtx *de_ctx; Signature *s=NULL; @@ -3359,7 +3424,8 @@ end: #endif /* UNITTESTS */ -void SigParseRegisterTests(void) { +void SigParseRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("SigParseTest01", SigParseTest01, 1); UtRegisterTest("SigParseTest02", SigParseTest02, 1); diff --git a/src/detect-pcre.c b/src/detect-pcre.c index c326129958..d87bc5cb05 100644 --- a/src/detect-pcre.c +++ b/src/detect-pcre.c @@ -265,7 +265,8 @@ int DetectPcrePayloadMatch(DetectEngineThreadCtx *det_ctx, Signature *s, SCReturnInt(ret); } -static int DetectPcreSetList(int list, int set) { +static int DetectPcreSetList(int list, int set) +{ if (list != DETECT_SM_LIST_NOTSET) { SCLogError(SC_ERR_INVALID_SIGNATURE, "only one pcre option to specify a buffer type is allowed"); return -1; @@ -4057,7 +4058,8 @@ end: /** * \brief this function registers unit tests for DetectPcre */ -void DetectPcreRegisterTests(void) { +void DetectPcreRegisterTests(void) +{ #ifdef UNITTESTS /* UNITTESTS */ UtRegisterTest("DetectPcreParseTest01", DetectPcreParseTest01, 1); UtRegisterTest("DetectPcreParseTest02", DetectPcreParseTest02, 1); diff --git a/src/detect-pkt-data.c b/src/detect-pkt-data.c index c159a0ff1b..9c39b52d71 100644 --- a/src/detect-pkt-data.c +++ b/src/detect-pkt-data.c @@ -49,7 +49,8 @@ static void DetectPktDataTestRegister(void); /** * \brief Registration function for keyword: file_data */ -void DetectPktDataRegister(void) { +void DetectPktDataRegister(void) +{ sigmatch_table[DETECT_PKT_DATA].name = "pkt_data"; sigmatch_table[DETECT_PKT_DATA].Match = NULL; sigmatch_table[DETECT_PKT_DATA].AppLayerMatch = NULL; @@ -141,7 +142,8 @@ end: } #endif -static void DetectPktDataTestRegister(void){ +static void DetectPktDataTestRegister(void) +{ #ifdef UNITTESTS UtRegisterTest("DetectPktDataTest01", DetectPktDataTest01, 1); #endif diff --git a/src/detect-pktvar.c b/src/detect-pktvar.c index e7f12cc2cf..813c20ed30 100644 --- a/src/detect-pktvar.c +++ b/src/detect-pktvar.c @@ -42,7 +42,8 @@ static pcre_extra *parse_regex_study; int DetectPktvarMatch (ThreadVars *, DetectEngineThreadCtx *, Packet *, Signature *, SigMatch *); static int DetectPktvarSetup (DetectEngineCtx *, Signature *, char *); -void DetectPktvarRegister (void) { +void DetectPktvarRegister (void) +{ sigmatch_table[DETECT_PKTVAR].name = "pktvar"; sigmatch_table[DETECT_PKTVAR].Match = DetectPktvarMatch; sigmatch_table[DETECT_PKTVAR].Setup = DetectPktvarSetup; diff --git a/src/detect-rawbytes.c b/src/detect-rawbytes.c index cf676d005b..872a71a072 100644 --- a/src/detect-rawbytes.c +++ b/src/detect-rawbytes.c @@ -39,7 +39,8 @@ static int DetectRawbytesSetup (DetectEngineCtx *, Signature *, char *); -void DetectRawbytesRegister (void) { +void DetectRawbytesRegister (void) +{ sigmatch_table[DETECT_RAWBYTES].name = "rawbytes"; sigmatch_table[DETECT_RAWBYTES].Match = NULL; sigmatch_table[DETECT_RAWBYTES].Setup = DetectRawbytesSetup; diff --git a/src/detect-replace.c b/src/detect-replace.c index 0300d3426e..c2587d8e5c 100644 --- a/src/detect-replace.c +++ b/src/detect-replace.c @@ -62,7 +62,8 @@ extern int run_mode; static int DetectReplaceSetup (DetectEngineCtx *, Signature *, char *); void DetectReplaceRegisterTests(void); -void DetectReplaceRegister (void) { +void DetectReplaceRegister (void) +{ sigmatch_table[DETECT_REPLACE].name = "replace"; sigmatch_table[DETECT_REPLACE].Match = NULL; sigmatch_table[DETECT_REPLACE].Setup = DetectReplaceSetup; @@ -303,7 +304,8 @@ end: /** * \brief Wrapper for DetectContentLongPatternMatchTest */ -int DetectReplaceLongPatternMatchTestWrp(char *sig, uint32_t sid, char *sig_rep, uint32_t sid_rep) { +int DetectReplaceLongPatternMatchTestWrp(char *sig, uint32_t sid, char *sig_rep, uint32_t sid_rep) +{ int ret; /** Real packet with the following tcp data: * "Hi, this is a big test to check content matches of splitted" @@ -350,7 +352,8 @@ 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) { +int DetectReplaceLongPatternMatchTestUDPWrp(char *sig, uint32_t sid, char *sig_rep, uint32_t sid_rep) +{ int ret; /** Real UDP DNS packet with a request A to a1.twimg.com */ diff --git a/src/detect-rev.c b/src/detect-rev.c index 5496200321..6306f6cc7d 100644 --- a/src/detect-rev.c +++ b/src/detect-rev.c @@ -30,7 +30,8 @@ static int DetectRevSetup (DetectEngineCtx *, Signature *, char *); -void DetectRevRegister (void) { +void DetectRevRegister (void) +{ sigmatch_table[DETECT_REV].name = "rev"; sigmatch_table[DETECT_REV].desc = "set version of the rule"; sigmatch_table[DETECT_REV].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/Meta-settings#Rev-Revision"; diff --git a/src/detect-rpc.c b/src/detect-rpc.c index c71cd03488..ba7b426c17 100644 --- a/src/detect-rpc.c +++ b/src/detect-rpc.c @@ -56,7 +56,8 @@ void DetectRpcFree(void *); /** * \brief Registration function for rpc keyword */ -void DetectRpcRegister (void) { +void DetectRpcRegister (void) +{ sigmatch_table[DETECT_RPC].name = "rpc"; sigmatch_table[DETECT_RPC].desc = "match RPC procedure numbers and RPC version"; sigmatch_table[DETECT_RPC].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/Payload_keywords#rpc"; @@ -304,7 +305,8 @@ error: * * \param rd pointer to DetectRpcData */ -void DetectRpcFree(void *ptr) { +void DetectRpcFree(void *ptr) +{ SCEnter(); if (ptr == NULL) { @@ -322,7 +324,8 @@ void DetectRpcFree(void *ptr) { * \test DetectRpcTestParse01 is a test to make sure that we return "something" * when given valid rpc opt */ -int DetectRpcTestParse01 (void) { +int DetectRpcTestParse01 (void) +{ int result = 0; DetectRpcData *rd = NULL; rd = DetectRpcParse("123,444,555"); @@ -337,7 +340,8 @@ int DetectRpcTestParse01 (void) { /** * \test DetectRpcTestParse02 is a test for setting the established rpc opt */ -int DetectRpcTestParse02 (void) { +int DetectRpcTestParse02 (void) +{ int result = 0; DetectRpcData *rd = NULL; rd = DetectRpcParse("111,222,333"); @@ -361,7 +365,8 @@ int DetectRpcTestParse02 (void) { * \test DetectRpcTestParse03 is a test for checking the wildcards * and not specified fields */ -int DetectRpcTestParse03 (void) { +int DetectRpcTestParse03 (void) +{ int result = 1; DetectRpcData *rd = NULL; rd = DetectRpcParse("111,*,333"); @@ -439,7 +444,8 @@ int DetectRpcTestParse03 (void) { /** * \test DetectRpcTestParse04 is a test for check the discarding of empty options */ -int DetectRpcTestParse04 (void) { +int DetectRpcTestParse04 (void) +{ int result = 0; DetectRpcData *rd = NULL; rd = DetectRpcParse(""); @@ -456,7 +462,8 @@ int DetectRpcTestParse04 (void) { /** * \test DetectRpcTestParse05 is a test for check invalid values */ -int DetectRpcTestParse05 (void) { +int DetectRpcTestParse05 (void) +{ int result = 0; DetectRpcData *rd = NULL; rd = DetectRpcParse("111,aaa,*"); @@ -473,7 +480,8 @@ int DetectRpcTestParse05 (void) { /** * \test DetectRpcTestParse05 is a test to check the match function */ -static int DetectRpcTestSig01(void) { +static int DetectRpcTestSig01(void) +{ /* RPC Call */ uint8_t buf[] = { /* XID */ @@ -588,7 +596,8 @@ end: /** * \brief this function registers unit tests for DetectRpc */ -void DetectRpcRegisterTests(void) { +void DetectRpcRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("DetectRpcTestParse01", DetectRpcTestParse01, 1); UtRegisterTest("DetectRpcTestParse02", DetectRpcTestParse02, 1); diff --git a/src/detect-seq.c b/src/detect-seq.c index db78e07bc2..b78fa567de 100644 --- a/src/detect-seq.c +++ b/src/detect-seq.c @@ -46,7 +46,8 @@ static void DetectSeqRegisterTests(void); static void DetectSeqFree(void *); -void DetectSeqRegister(void) { +void DetectSeqRegister(void) +{ sigmatch_table[DETECT_SEQ].name = "seq"; sigmatch_table[DETECT_SEQ].desc = "check for a specific TCP sequence number"; sigmatch_table[DETECT_SEQ].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/Header_keywords#seq"; diff --git a/src/detect-sid.c b/src/detect-sid.c index 452d83572a..1c7666bb17 100644 --- a/src/detect-sid.c +++ b/src/detect-sid.c @@ -30,7 +30,8 @@ static int DetectSidSetup (DetectEngineCtx *, Signature *, char *); -void DetectSidRegister (void) { +void DetectSidRegister (void) +{ sigmatch_table[DETECT_SID].name = "sid"; sigmatch_table[DETECT_SID].desc = "set rule id"; sigmatch_table[DETECT_SID].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/Meta-settings#Sid-signature-id"; diff --git a/src/detect-ssh-proto-version.c b/src/detect-ssh-proto-version.c index 9073b8bcfb..96a8b67630 100644 --- a/src/detect-ssh-proto-version.c +++ b/src/detect-ssh-proto-version.c @@ -70,7 +70,8 @@ void DetectSshVersionFree(void *); /** * \brief Registration function for keyword: ssh.protoversion */ -void DetectSshVersionRegister(void) { +void DetectSshVersionRegister(void) +{ sigmatch_table[DETECT_AL_SSH_PROTOVERSION].name = "ssh.protoversion"; sigmatch_table[DETECT_AL_SSH_PROTOVERSION].Match = NULL; sigmatch_table[DETECT_AL_SSH_PROTOVERSION].AppLayerMatch = DetectSshVersionMatch; @@ -270,7 +271,8 @@ error: * * \param id_d pointer to DetectSshVersionData */ -void DetectSshVersionFree(void *ptr) { +void DetectSshVersionFree(void *ptr) +{ DetectSshVersionData *id_d = (DetectSshVersionData *)ptr; SCFree(id_d); } @@ -281,7 +283,8 @@ void DetectSshVersionFree(void *ptr) { * \test DetectSshVersionTestParse01 is a test to make sure that we parse * a proto version correctly */ -int DetectSshVersionTestParse01 (void) { +int DetectSshVersionTestParse01 (void) +{ DetectSshVersionData *ssh = NULL; ssh = DetectSshVersionParse("1.0"); if (ssh != NULL && strncmp((char *) ssh->ver, "1.0", 3) == 0) { @@ -296,7 +299,8 @@ 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) { +int DetectSshVersionTestParse02 (void) +{ DetectSshVersionData *ssh = NULL; ssh = DetectSshVersionParse("2_compat"); if (ssh->flags & SSH_FLAG_PROTOVERSION_2_COMPAT) { @@ -311,7 +315,8 @@ 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) { +int DetectSshVersionTestParse03 (void) +{ DetectSshVersionData *ssh = NULL; ssh = DetectSshVersionParse("2_com"); if (ssh != NULL) { @@ -341,7 +346,8 @@ int DetectSshVersionTestParse03 (void) { #include "stream-tcp-reassemble.h" /** \test Send a get request in three chunks + more data. */ -static int DetectSshVersionTestDetect01(void) { +static int DetectSshVersionTestDetect01(void) +{ int result = 0; Flow f; uint8_t sshbuf1[] = "SSH-1."; @@ -453,7 +459,8 @@ end: } /** \test Send a get request in three chunks + more data. */ -static int DetectSshVersionTestDetect02(void) { +static int DetectSshVersionTestDetect02(void) +{ int result = 0; Flow f; uint8_t sshbuf1[] = "SSH-1."; @@ -563,7 +570,8 @@ end: } /** \test Send a get request in three chunks + more data. */ -static int DetectSshVersionTestDetect03(void) { +static int DetectSshVersionTestDetect03(void) +{ int result = 0; Flow f; uint8_t sshbuf1[] = "SSH-1."; @@ -678,7 +686,8 @@ end: /** * \brief this function registers unit tests for DetectSshVersion */ -void DetectSshVersionRegisterTests(void) { +void DetectSshVersionRegisterTests(void) +{ #ifdef UNITTESTS /* UNITTESTS */ UtRegisterTest("DetectSshVersionTestParse01", DetectSshVersionTestParse01, 1); UtRegisterTest("DetectSshVersionTestParse02", DetectSshVersionTestParse02, 1); diff --git a/src/detect-ssh-software-version.c b/src/detect-ssh-software-version.c index 277f035476..b31d51bead 100644 --- a/src/detect-ssh-software-version.c +++ b/src/detect-ssh-software-version.c @@ -75,7 +75,8 @@ void DetectSshSoftwareVersionRegister(void); /** * \brief Registration function for keyword: ssh.softwareversion */ -void DetectSshSoftwareVersionRegister(void) { +void DetectSshSoftwareVersionRegister(void) +{ sigmatch_table[DETECT_AL_SSH_SOFTWAREVERSION].name = "ssh.softwareversion"; sigmatch_table[DETECT_AL_SSH_SOFTWAREVERSION].Match = NULL; sigmatch_table[DETECT_AL_SSH_SOFTWAREVERSION].AppLayerMatch = DetectSshSoftwareVersionMatch; @@ -252,7 +253,8 @@ error: * * \param id_d pointer to DetectSshSoftwareVersionData */ -void DetectSshSoftwareVersionFree(void *ptr) { +void DetectSshSoftwareVersionFree(void *ptr) +{ if (ptr == NULL) return; @@ -268,7 +270,8 @@ void DetectSshSoftwareVersionFree(void *ptr) { * \test DetectSshSoftwareVersionTestParse01 is a test to make sure that we parse * a software version correctly */ -int DetectSshSoftwareVersionTestParse01 (void) { +int DetectSshSoftwareVersionTestParse01 (void) +{ DetectSshSoftwareVersionData *ssh = NULL; ssh = DetectSshSoftwareVersionParse("PuTTY_1.0"); if (ssh != NULL && strncmp((char *) ssh->software_ver, "PuTTY_1.0", 9) == 0) { @@ -283,7 +286,8 @@ int DetectSshSoftwareVersionTestParse01 (void) { * \test DetectSshSoftwareVersionTestParse02 is a test to make sure that we parse * the software version correctly */ -int DetectSshSoftwareVersionTestParse02 (void) { +int DetectSshSoftwareVersionTestParse02 (void) +{ DetectSshSoftwareVersionData *ssh = NULL; ssh = DetectSshSoftwareVersionParse("\"SecureCRT-4.0\""); if (ssh != NULL && strncmp((char *) ssh->software_ver, "SecureCRT-4.0", 13) == 0) { @@ -298,7 +302,8 @@ int DetectSshSoftwareVersionTestParse02 (void) { * \test DetectSshSoftwareVersionTestParse03 is a test to make sure that we * don't return a ssh_data with an empty value specified */ -int DetectSshSoftwareVersionTestParse03 (void) { +int DetectSshSoftwareVersionTestParse03 (void) +{ DetectSshSoftwareVersionData *ssh = NULL; ssh = DetectSshSoftwareVersionParse(""); if (ssh != NULL) { @@ -313,7 +318,8 @@ int DetectSshSoftwareVersionTestParse03 (void) { #include "stream-tcp-reassemble.h" /** \test Send a get request in three chunks + more data. */ -static int DetectSshSoftwareVersionTestDetect01(void) { +static int DetectSshSoftwareVersionTestDetect01(void) +{ int result = 0; Flow f; uint8_t sshbuf1[] = "SSH-1."; @@ -425,7 +431,8 @@ end: } /** \test Send a get request in three chunks + more data. */ -static int DetectSshSoftwareVersionTestDetect02(void) { +static int DetectSshSoftwareVersionTestDetect02(void) +{ int result = 0; Flow f; uint8_t sshbuf1[] = "SSH-1.99-Pu"; @@ -536,7 +543,8 @@ end: } /** \test Send a get request in three chunks + more data. */ -static int DetectSshSoftwareVersionTestDetect03(void) { +static int DetectSshSoftwareVersionTestDetect03(void) +{ int result = 0; Flow f; uint8_t sshbuf1[] = "SSH-1."; @@ -651,7 +659,8 @@ end: /** * \brief this function registers unit tests for DetectSshSoftwareVersion */ -void DetectSshSoftwareVersionRegisterTests(void) { +void DetectSshSoftwareVersionRegisterTests(void) +{ #ifdef UNITTESTS /* UNITTESTS */ UtRegisterTest("DetectSshSoftwareVersionTestParse01", DetectSshSoftwareVersionTestParse01, 1); UtRegisterTest("DetectSshSoftwareVersionTestParse02", DetectSshSoftwareVersionTestParse02, 1); diff --git a/src/detect-ssl-state.c b/src/detect-ssl-state.c index d8556d4f90..ade6435878 100644 --- a/src/detect-ssl-state.c +++ b/src/detect-ssl-state.c @@ -327,7 +327,8 @@ error: * * \param ptr pointer to the data to be freed. */ -void DetectSslStateFree(void *ptr) { +void DetectSslStateFree(void *ptr) +{ if (ptr != NULL) SCFree(ptr); diff --git a/src/detect-ssl-version.c b/src/detect-ssl-version.c index e95fbc20a4..599d26b877 100644 --- a/src/detect-ssl-version.c +++ b/src/detect-ssl-version.c @@ -350,7 +350,8 @@ void DetectSslVersionFree(void *ptr) * \test DetectSslVersionTestParse01 is a test to make sure that we parse the * "ssl_version" option correctly when given valid ssl_version option */ -int DetectSslVersionTestParse01(void) { +int DetectSslVersionTestParse01(void) +{ DetectSslVersionData *ssl = NULL; ssl = DetectSslVersionParse("SSlv3"); if (ssl != NULL && ssl->data[SSLv3].ver == SSL_VERSION_3) { @@ -366,7 +367,8 @@ int DetectSslVersionTestParse01(void) { * "ssl_version" option correctly when given an invalid ssl_version option * it should return ssl = NULL */ -int DetectSslVersionTestParse02(void) { +int DetectSslVersionTestParse02(void) +{ DetectSslVersionData *ssl = NULL; ssl = DetectSslVersionParse("2.5"); if (ssl == NULL) { @@ -381,7 +383,8 @@ int DetectSslVersionTestParse02(void) { * \test DetectSslVersionTestParse03 is a test to make sure that we parse the * "ssl_version" options correctly when given valid ssl_version options */ -int DetectSslVersionTestParse03(void) { +int DetectSslVersionTestParse03(void) +{ DetectSslVersionData *ssl = NULL; ssl = DetectSslVersionParse("SSlv3,tls1.0, !tls1.2"); if (ssl != NULL && ssl->data[SSLv3].ver == SSL_VERSION_3 && diff --git a/src/detect-stream_size.c b/src/detect-stream_size.c index a864f43882..200ce76b5a 100644 --- a/src/detect-stream_size.c +++ b/src/detect-stream_size.c @@ -53,7 +53,8 @@ void DetectStreamSizeRegisterTests(void); * \brief Registration function for stream_size: keyword */ -void DetectStreamSizeRegister(void) { +void DetectStreamSizeRegister(void) +{ sigmatch_table[DETECT_STREAM_SIZE].name = "stream_size"; sigmatch_table[DETECT_STREAM_SIZE].desc = "match on amount of bytes of a stream"; sigmatch_table[DETECT_STREAM_SIZE].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/Flow-keywords#stream_size"; @@ -140,7 +141,8 @@ static int DetectStreamSizeCompare (uint32_t diff, uint32_t stream_size, uint8_t * \retval 0 no match * \retval 1 match */ -int DetectStreamSizeMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p, Signature *s, SigMatch *m) { +int DetectStreamSizeMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p, Signature *s, SigMatch *m) +{ int ret = 0; DetectStreamSizeData *sd = (DetectStreamSizeData *) m->ctx; @@ -193,7 +195,8 @@ int DetectStreamSizeMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet * \retval NULL on failure */ -DetectStreamSizeData *DetectStreamSizeParse (char *streamstr) { +DetectStreamSizeData *DetectStreamSizeParse (char *streamstr) +{ DetectStreamSizeData *sd = NULL; char *arg = NULL; @@ -302,7 +305,8 @@ 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, char *streamstr) +{ DetectStreamSizeData *sd = NULL; SigMatch *sm = NULL; @@ -333,7 +337,8 @@ error: * * \param ptr pointer to DetectStreamSizeData */ -void DetectStreamSizeFree(void *ptr) { +void DetectStreamSizeFree(void *ptr) +{ DetectStreamSizeData *sd = (DetectStreamSizeData *)ptr; SCFree(sd); } @@ -344,7 +349,8 @@ void DetectStreamSizeFree(void *ptr) { * user options correctly, when given valid stream_size options. */ -static int DetectStreamSizeParseTest01 (void) { +static int DetectStreamSizeParseTest01 (void) +{ int result = 0; DetectStreamSizeData *sd = NULL; sd = DetectStreamSizeParse("server,<,6"); @@ -362,7 +368,8 @@ static int DetectStreamSizeParseTest01 (void) { * invalid stream_size options. */ -static int DetectStreamSizeParseTest02 (void) { +static int DetectStreamSizeParseTest02 (void) +{ int result = 1; DetectStreamSizeData *sd = NULL; sd = DetectStreamSizeParse("invalidoption,<,6"); @@ -380,7 +387,8 @@ static int DetectStreamSizeParseTest02 (void) { * packet correctly provided valid stream size. */ -static int DetectStreamSizeParseTest03 (void) { +static int DetectStreamSizeParseTest03 (void) +{ int result = 0; DetectStreamSizeData *sd = NULL; @@ -455,7 +463,8 @@ static int DetectStreamSizeParseTest03 (void) { * stream_size against invalid packet parameters. */ -static int DetectStreamSizeParseTest04 (void) { +static int DetectStreamSizeParseTest04 (void) +{ int result = 0; DetectStreamSizeData *sd = NULL; @@ -511,7 +520,8 @@ static int DetectStreamSizeParseTest04 (void) { /** * \brief this function registers unit tests for DetectStreamSize */ -void DetectStreamSizeRegisterTests(void) { +void DetectStreamSizeRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("DetectStreamSizeParseTest01", DetectStreamSizeParseTest01, 1); UtRegisterTest("DetectStreamSizeParseTest02", DetectStreamSizeParseTest02, 1); diff --git a/src/detect-threshold.c b/src/detect-threshold.c index a74b0cb4d7..08eadbebda 100644 --- a/src/detect-threshold.c +++ b/src/detect-threshold.c @@ -1119,7 +1119,8 @@ end: /** * \test Test drop action being set even if thresholded */ -static int DetectThresholdTestSig9(void) { +static int DetectThresholdTestSig9(void) +{ Packet *p = NULL; Signature *s = NULL; ThreadVars th_v; diff --git a/src/detect-tls-version.c b/src/detect-tls-version.c index 06fd67384d..51547260cc 100644 --- a/src/detect-tls-version.c +++ b/src/detect-tls-version.c @@ -67,7 +67,8 @@ void DetectTlsVersionFree(void *); /** * \brief Registration function for keyword: tls.version */ -void DetectTlsVersionRegister (void) { +void DetectTlsVersionRegister (void) +{ sigmatch_table[DETECT_AL_TLS_VERSION].name = "tls.version"; sigmatch_table[DETECT_AL_TLS_VERSION].desc = "match on TLS/SSL version"; sigmatch_table[DETECT_AL_TLS_VERSION].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/TLS-keywords#tlsversion"; @@ -269,7 +270,8 @@ error: * * \param id_d pointer to DetectTlsVersionData */ -void DetectTlsVersionFree(void *ptr) { +void DetectTlsVersionFree(void *ptr) +{ DetectTlsVersionData *id_d = (DetectTlsVersionData *)ptr; SCFree(id_d); } @@ -280,7 +282,8 @@ void DetectTlsVersionFree(void *ptr) { * \test DetectTlsVersionTestParse01 is a test to make sure that we parse the "id" * option correctly when given valid id option */ -int DetectTlsVersionTestParse01 (void) { +int DetectTlsVersionTestParse01 (void) +{ DetectTlsVersionData *tls = NULL; tls = DetectTlsVersionParse("1.0"); if (tls != NULL && tls->ver == TLS_VERSION_10) { @@ -296,7 +299,8 @@ int DetectTlsVersionTestParse01 (void) { * option correctly when given an invalid id option * it should return id_d = NULL */ -int DetectTlsVersionTestParse02 (void) { +int DetectTlsVersionTestParse02 (void) +{ DetectTlsVersionData *tls = NULL; tls = DetectTlsVersionParse("2.5"); if (tls == NULL) { @@ -310,7 +314,8 @@ int DetectTlsVersionTestParse02 (void) { #include "stream-tcp-reassemble.h" /** \test Send a get request in three chunks + more data. */ -static int DetectTlsVersionTestDetect01(void) { +static int DetectTlsVersionTestDetect01(void) +{ int result = 0; Flow f; uint8_t tlsbuf1[] = { 0x16 }; @@ -437,7 +442,8 @@ end: return result; } -static int DetectTlsVersionTestDetect02(void) { +static int DetectTlsVersionTestDetect02(void) +{ int result = 0; Flow f; uint8_t tlsbuf1[] = { 0x16 }; @@ -560,7 +566,8 @@ end: return result; } -static int DetectTlsVersionTestDetect03(void) { +static int DetectTlsVersionTestDetect03(void) +{ DetectEngineCtx *de_ctx = NULL; int result = 0; Flow f; @@ -702,7 +709,8 @@ end: /** * \brief this function registers unit tests for DetectTlsVersion */ -void DetectTlsVersionRegisterTests(void) { +void DetectTlsVersionRegisterTests(void) +{ #ifdef UNITTESTS /* UNITTESTS */ UtRegisterTest("DetectTlsVersionTestParse01", DetectTlsVersionTestParse01, 1); UtRegisterTest("DetectTlsVersionTestParse02", DetectTlsVersionTestParse02, 1); diff --git a/src/detect-tls.c b/src/detect-tls.c index 05169e6036..56ae94fab2 100644 --- a/src/detect-tls.c +++ b/src/detect-tls.c @@ -91,7 +91,8 @@ static int DetectTlsStoreMatch (ThreadVars *, DetectEngineThreadCtx *, Flow *, u /** * \brief Registration function for keyword: tls.version */ -void DetectTlsRegister (void) { +void DetectTlsRegister (void) +{ sigmatch_table[DETECT_AL_TLS_SUBJECT].name = "tls.subject"; sigmatch_table[DETECT_AL_TLS_SUBJECT].desc = "match TLS/SSL certificate Subject field"; sigmatch_table[DETECT_AL_TLS_SUBJECT].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/TLS-keywords#tlssubject"; @@ -377,7 +378,8 @@ error: * * \param id_d pointer to DetectTlsData */ -static void DetectTlsSubjectFree(void *ptr) { +static void DetectTlsSubjectFree(void *ptr) +{ DetectTlsData *id_d = (DetectTlsData *)ptr; if (ptr == NULL) return; @@ -389,7 +391,8 @@ static void DetectTlsSubjectFree(void *ptr) { /** * \brief this function registers unit tests for DetectTlsSubject */ -static void DetectTlsSubjectRegisterTests(void) { +static void DetectTlsSubjectRegisterTests(void) +{ } /** @@ -774,7 +777,8 @@ error: * * \param pointer to DetectTlsData */ -static void DetectTlsFingerprintFree(void *ptr) { +static void DetectTlsFingerprintFree(void *ptr) +{ DetectTlsData *id_d = (DetectTlsData *)ptr; if (id_d->fingerprint) SCFree(id_d->fingerprint); diff --git a/src/detect-ttl.c b/src/detect-ttl.c index 1cb4177aec..f348ea2b02 100644 --- a/src/detect-ttl.c +++ b/src/detect-ttl.c @@ -51,7 +51,8 @@ void DetectTtlRegisterTests (void); * \brief Registration function for ttl: keyword */ -void DetectTtlRegister(void) { +void DetectTtlRegister(void) +{ sigmatch_table[DETECT_TTL].name = "ttl"; sigmatch_table[DETECT_TTL].desc = "check for a specific IP time-to-live value"; sigmatch_table[DETECT_TTL].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/Header_keywords#ttl"; @@ -94,7 +95,8 @@ error: * \retval 0 no match * \retval 1 match */ -int DetectTtlMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p, Signature *s, SigMatch *m) { +int DetectTtlMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p, Signature *s, SigMatch *m) +{ int ret = 0; uint8_t pttl; @@ -133,7 +135,8 @@ int DetectTtlMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p, Si * \retval NULL on failure */ -DetectTtlData *DetectTtlParse (char *ttlstr) { +DetectTtlData *DetectTtlParse (char *ttlstr) +{ DetectTtlData *ttld = NULL; char *arg1 = NULL; @@ -270,7 +273,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, char *ttlstr) +{ DetectTtlData *ttld = NULL; SigMatch *sm = NULL; @@ -302,7 +306,8 @@ error: * * \param ptr pointer to DetectTtlData */ -void DetectTtlFree(void *ptr) { +void DetectTtlFree(void *ptr) +{ DetectTtlData *ttld = (DetectTtlData *)ptr; SCFree(ttld); } @@ -319,7 +324,8 @@ void DetectTtlFree(void *ptr) { * */ -static int DetectTtlInitTest(DetectEngineCtx **de_ctx, Signature **sig, DetectTtlData **ttld, char *str) { +static int DetectTtlInitTest(DetectEngineCtx **de_ctx, Signature **sig, DetectTtlData **ttld, char *str) +{ char fullstr[1024]; int result = 0; @@ -356,7 +362,8 @@ end: * \test DetectTtlParseTest01 is a test for setting up an valid ttl value. */ -static int DetectTtlParseTest01 (void) { +static int DetectTtlParseTest01 (void) +{ DetectTtlData *ttld = NULL; uint8_t res = 0; @@ -376,7 +383,8 @@ static int DetectTtlParseTest01 (void) { * "<" operator. */ -static int DetectTtlParseTest02 (void) { +static int DetectTtlParseTest02 (void) +{ DetectTtlData *ttld = NULL; uint8_t res = 0; ttld = DetectTtlParse("<10"); @@ -394,7 +402,8 @@ static int DetectTtlParseTest02 (void) { * "-" operator. */ -static int DetectTtlParseTest03 (void) { +static int DetectTtlParseTest03 (void) +{ DetectTtlData *ttld = NULL; uint8_t res = 0; ttld = DetectTtlParse("1-2"); @@ -412,7 +421,8 @@ static int DetectTtlParseTest03 (void) { * ">" operator and include spaces arround the given values. */ -static int DetectTtlParseTest04 (void) { +static int DetectTtlParseTest04 (void) +{ DetectTtlData *ttld = NULL; uint8_t res = 0; @@ -432,7 +442,8 @@ static int DetectTtlParseTest04 (void) { * "-" operator and include spaces arround the given values. */ -static int DetectTtlParseTest05 (void) { +static int DetectTtlParseTest05 (void) +{ DetectTtlData *ttld = NULL; uint8_t res = 0; @@ -451,7 +462,8 @@ static int DetectTtlParseTest05 (void) { * invalid "=" operator and include spaces arround the given values. */ -static int DetectTtlParseTest06 (void) { +static int DetectTtlParseTest06 (void) +{ DetectTtlData *ttld = NULL; uint8_t res = 0; @@ -468,7 +480,8 @@ static int DetectTtlParseTest06 (void) { * invalid "<>" operator and include spaces arround the given values. */ -static int DetectTtlParseTest07 (void) { +static int DetectTtlParseTest07 (void) +{ DetectTtlData *ttld = NULL; uint8_t res = 0; @@ -488,7 +501,8 @@ static int DetectTtlParseTest07 (void) { * setting up the signature itself. */ -static int DetectTtlSetpTest01(void) { +static int DetectTtlSetpTest01(void) +{ DetectTtlData *ttld = NULL; uint8_t res = 0; @@ -523,7 +537,8 @@ end: * the received packet against the sig. */ -static int DetectTtlTestSig1(void) { +static int DetectTtlTestSig1(void) +{ Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) @@ -607,7 +622,8 @@ end: /** * \brief this function registers unit tests for DetectTtl */ -void DetectTtlRegisterTests(void) { +void DetectTtlRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("DetectTtlParseTest01", DetectTtlParseTest01, 1); UtRegisterTest("DetectTtlParseTest02", DetectTtlParseTest02, 1); diff --git a/src/detect-uricontent.c b/src/detect-uricontent.c index 682bed199c..a22479b079 100644 --- a/src/detect-uricontent.c +++ b/src/detect-uricontent.c @@ -96,7 +96,8 @@ uint32_t DetectUricontentMaxId(DetectEngineCtx *de_ctx) * * \param cd pointer to DetectUricotentData */ -void DetectUricontentFree(void *ptr) { +void DetectUricontentFree(void *ptr) +{ SCEnter(); DetectContentData *cd = (DetectContentData *)ptr; @@ -274,7 +275,8 @@ end: /** \test Test case where path traversal has been sent as a path string in the * HTTP URL and normalized path string is checked */ -static int HTTPUriTest01(void) { +static int HTTPUriTest01(void) +{ int result = 0; Flow f; uint8_t httpbuf1[] = "GET /../../images.gif HTTP/1.1\r\nHost: www.ExA" @@ -339,7 +341,8 @@ end: /** \test Test case where path traversal has been sent in special characters in * HEX encoding in the HTTP URL and normalized path string is checked */ -static int HTTPUriTest02(void) { +static int HTTPUriTest02(void) +{ int result = 0; Flow f; HtpState *htp_state = NULL; @@ -408,7 +411,8 @@ end: /** \test Test case where NULL character has been sent in HEX encoding in the * HTTP URL and normalized path string is checked */ -static int HTTPUriTest03(void) { +static int HTTPUriTest03(void) +{ int result = 0; Flow f; HtpState *htp_state = NULL; @@ -478,7 +482,8 @@ end: /** \test Test case where self referencing directories request has been sent * in the HTTP URL and normalized path string is checked */ -static int HTTPUriTest04(void) { +static int HTTPUriTest04(void) +{ int result = 0; Flow f; HtpState *htp_state = NULL; @@ -592,7 +597,8 @@ int DetectUriSigTest01(void) } /** \test Check the signature working to alert when http_cookie is matched . */ -static int DetectUriSigTest02(void) { +static int DetectUriSigTest02(void) +{ int result = 0; Flow f; uint8_t httpbuf1[] = "POST /one HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\nCookie:" @@ -704,7 +710,8 @@ end: /** \test Check the working of search once per packet only in applayer * match */ -static int DetectUriSigTest03(void) { +static int DetectUriSigTest03(void) +{ int result = 0; Flow f; HtpState *http_state = NULL; @@ -845,7 +852,8 @@ end: * \test Check that modifiers of content apply only to content keywords * and the same for uricontent modifiers */ -static int DetectUriSigTest04(void) { +static int DetectUriSigTest04(void) +{ int result = 0; Signature *s = NULL; @@ -1045,7 +1053,8 @@ end: /** \test Check the modifiers for uricontent and content * match */ -static int DetectUriSigTest05(void) { +static int DetectUriSigTest05(void) +{ DetectEngineCtx *de_ctx = NULL; int result = 0; Flow f; @@ -1171,7 +1180,8 @@ end: /** \test Check the modifiers for uricontent and content * match */ -static int DetectUriSigTest06(void) { +static int DetectUriSigTest06(void) +{ DetectEngineCtx *de_ctx = NULL; int result = 0; Flow f; @@ -1310,7 +1320,8 @@ end: /** \test Check the modifiers for uricontent and content * match */ -static int DetectUriSigTest07(void) { +static int DetectUriSigTest07(void) +{ int result = 0; Flow f; HtpState *http_state = NULL; @@ -1935,7 +1946,8 @@ int DetectUriContentParseTest24(void) #endif /* UNITTESTS */ -void HttpUriRegisterTests(void) { +void HttpUriRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("HTTPUriTest01", HTTPUriTest01, 1); UtRegisterTest("HTTPUriTest02", HTTPUriTest02, 1); diff --git a/src/detect-urilen.c b/src/detect-urilen.c index 56eef38adf..1355f55942 100644 --- a/src/detect-urilen.c +++ b/src/detect-urilen.c @@ -543,7 +543,8 @@ end: * context and setting up the signature itself. */ -static int DetectUrilenSetpTest01(void) { +static int DetectUrilenSetpTest01(void) +{ DetectUrilenData *urilend = NULL; uint8_t res = 0; diff --git a/src/detect-window.c b/src/detect-window.c index b265a6d917..f98e0258eb 100644 --- a/src/detect-window.c +++ b/src/detect-window.c @@ -55,7 +55,8 @@ void DetectWindowFree(void *); /** * \brief Registration function for window: keyword */ -void DetectWindowRegister (void) { +void DetectWindowRegister (void) +{ sigmatch_table[DETECT_WINDOW].name = "window"; sigmatch_table[DETECT_WINDOW].desc = "check for a specific TCP window size"; sigmatch_table[DETECT_WINDOW].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/Header_keywords#Window"; @@ -103,7 +104,8 @@ error: * \retval 0 no match * \retval 1 match */ -int DetectWindowMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p, Signature *s, SigMatch *m) { +int DetectWindowMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p, Signature *s, SigMatch *m) +{ DetectWindowData *wd = (DetectWindowData *)m->ctx; if ( !(PKT_IS_TCP(p)) || wd == NULL || PKT_IS_PSEUDOPKT(p)) { @@ -125,7 +127,8 @@ int DetectWindowMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p, * \retval wd pointer to DetectWindowData on success * \retval NULL on failure */ -DetectWindowData *DetectWindowParse(char *windowstr) { +DetectWindowData *DetectWindowParse(char *windowstr) +{ DetectWindowData *wd = NULL; char *args[3] = {NULL,NULL,NULL}; /* PR: Why PCRE MAX_SUBSTRING must be multiple of 3? */ #define MAX_SUBSTRINGS 30 @@ -235,7 +238,8 @@ error: * * \param wd pointer to DetectWindowData */ -void DetectWindowFree(void *ptr) { +void DetectWindowFree(void *ptr) +{ DetectWindowData *wd = (DetectWindowData *)ptr; SCFree(wd); } @@ -246,7 +250,8 @@ 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) { +int DetectWindowTestParse01 (void) +{ int result = 0; DetectWindowData *wd = NULL; wd = DetectWindowParse("35402"); @@ -261,7 +266,8 @@ int DetectWindowTestParse01 (void) { /** * \test DetectWindowTestParse02 is a test for setting the window opt negated */ -int DetectWindowTestParse02 (void) { +int DetectWindowTestParse02 (void) +{ int result = 0; DetectWindowData *wd = NULL; wd = DetectWindowParse("!35402"); @@ -280,7 +286,8 @@ int DetectWindowTestParse02 (void) { /** * \test DetectWindowTestParse03 is a test to check for an empty value */ -int DetectWindowTestParse03 (void) { +int DetectWindowTestParse03 (void) +{ int result = 0; DetectWindowData *wd = NULL; wd = DetectWindowParse(""); @@ -297,7 +304,8 @@ int DetectWindowTestParse03 (void) { /** * \test DetectWindowTestParse03 is a test to check for a big value */ -int DetectWindowTestParse04 (void) { +int DetectWindowTestParse04 (void) +{ int result = 0; DetectWindowData *wd = NULL; wd = DetectWindowParse("1235402"); @@ -313,7 +321,8 @@ int DetectWindowTestParse04 (void) { /** * \test DetectWindowTestPacket01 is a test to check window with constructed packets */ -int DetectWindowTestPacket01 (void) { +int DetectWindowTestPacket01 (void) +{ int result = 0; uint8_t *buf = (uint8_t *)"Hi all!"; uint16_t buflen = strlen((char *)buf); @@ -356,7 +365,8 @@ end: /** * \brief this function registers unit tests for DetectWindow */ -void DetectWindowRegisterTests(void) { +void DetectWindowRegisterTests(void) +{ #ifdef UNITTESTS /* UNITTESTS */ UtRegisterTest("DetectWindowTestParse01", DetectWindowTestParse01, 1); UtRegisterTest("DetectWindowTestParse02", DetectWindowTestParse02, 1); diff --git a/src/detect-within.c b/src/detect-within.c index 6e02ef0375..9b35cbbc21 100644 --- a/src/detect-within.c +++ b/src/detect-within.c @@ -197,7 +197,8 @@ 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) { +int DetectWithinTestPacket01 (void) +{ int result = 0; uint8_t *buf = (uint8_t *)"GET /AllWorkAndNoPlayMakesWillADullBoy HTTP/1.0" "User-Agent: Wget/1.11.4" @@ -224,7 +225,8 @@ end: } -int DetectWithinTestPacket02 (void) { +int DetectWithinTestPacket02 (void) +{ int result = 0; uint8_t *buf = (uint8_t *)"Zero Five Ten Fourteen"; uint16_t buflen = strlen((char *)buf); @@ -247,7 +249,8 @@ end: #endif /* UNITTESTS */ -void DetectWithinRegisterTests(void) { +void DetectWithinRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("DetectWithinTestPacket01", DetectWithinTestPacket01, 1); UtRegisterTest("DetectWithinTestPacket02", DetectWithinTestPacket02, 1); diff --git a/src/detect.c b/src/detect.c index 6853d563a8..28e0da4cd7 100644 --- a/src/detect.c +++ b/src/detect.c @@ -212,7 +212,8 @@ TmEcode Detect(ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *); TmEcode DetectThreadInit(ThreadVars *, void *, void **); TmEcode DetectThreadDeinit(ThreadVars *, void *); -void TmModuleDetectRegister (void) { +void TmModuleDetectRegister (void) +{ tmm_modules[TMM_DETECT].name = "Detect"; tmm_modules[TMM_DETECT].ThreadInit = DetectThreadInit; tmm_modules[TMM_DETECT].Func = Detect; @@ -225,7 +226,8 @@ void TmModuleDetectRegister (void) { PacketAlertTagInit(); } -void DetectExitPrintStats(ThreadVars *tv, void *data) { +void DetectExitPrintStats(ThreadVars *tv, void *data) +{ DetectEngineThreadCtx *det_ctx = (DetectEngineThreadCtx *)data; if (det_ctx == NULL) return; @@ -279,7 +281,8 @@ char *DetectLoadCompleteSigPath(char *sig_file) * \param sigs_tot Will store number of signatures processed in the file * \retval Number of rules loaded successfully, -1 on error */ -int DetectLoadSigFile(DetectEngineCtx *de_ctx, char *sig_file, int *sigs_tot) { +int DetectLoadSigFile(DetectEngineCtx *de_ctx, char *sig_file, int *sigs_tot) +{ Signature *sig = NULL; int good = 0, bad = 0; char line[DETECT_MAX_RULE_SIZE] = ""; @@ -632,7 +635,8 @@ int SigMatchSignaturesRunPostMatch(ThreadVars *tv, * * \retval sgh the SigGroupHead or NULL if non applies to the packet */ -SigGroupHead *SigMatchSignaturesGetSgh(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p) { +SigGroupHead *SigMatchSignaturesGetSgh(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p) +{ SCEnter(); int f; @@ -693,7 +697,8 @@ SigGroupHead *SigMatchSignaturesGetSgh(DetectEngineCtx *de_ctx, DetectEngineThre * \param p packet * \param flags stream flags */ -static StreamMsg *SigMatchSignaturesGetSmsg(Flow *f, Packet *p, uint8_t flags) { +static StreamMsg *SigMatchSignaturesGetSmsg(Flow *f, Packet *p, uint8_t flags) +{ SCEnter(); DEBUG_ASSERT_FLOW_LOCKED(f); @@ -1741,7 +1746,8 @@ TmEcode DetectThreadInit(ThreadVars *t, void *initdata, void **data) return DetectEngineThreadCtxInit(t,initdata,data); } -TmEcode DetectThreadDeinit(ThreadVars *t, void *data) { +TmEcode DetectThreadDeinit(ThreadVars *t, void *data) +{ return DetectEngineThreadCtxDeinit(t,data); } @@ -1788,7 +1794,8 @@ Signature *SigFindSignatureBySidGid(DetectEngineCtx *de_ctx, uint32_t sid, uint3 } -int SignatureIsAppLayer(DetectEngineCtx *de_ctx, Signature *s) { +int SignatureIsAppLayer(DetectEngineCtx *de_ctx, Signature *s) +{ if (s->alproto != 0) return 1; @@ -1803,7 +1810,8 @@ int SignatureIsAppLayer(DetectEngineCtx *de_ctx, Signature *s) { * \retval 0 no * \retval 1 yes */ -int SignatureIsFilestoring(Signature *s) { +int SignatureIsFilestoring(Signature *s) +{ if (s == NULL) return 0; @@ -1821,7 +1829,8 @@ int SignatureIsFilestoring(Signature *s) { * \retval 0 no * \retval 1 yes */ -int SignatureIsFilemagicInspecting(Signature *s) { +int SignatureIsFilemagicInspecting(Signature *s) +{ if (s == NULL) return 0; @@ -1839,7 +1848,8 @@ int SignatureIsFilemagicInspecting(Signature *s) { * \retval 0 no * \retval 1 yes */ -int SignatureIsFileMd5Inspecting(Signature *s) { +int SignatureIsFileMd5Inspecting(Signature *s) +{ if (s == NULL) return 0; @@ -1857,7 +1867,8 @@ int SignatureIsFileMd5Inspecting(Signature *s) { * \retval 0 no * \retval 1 yes */ -int SignatureIsFilesizeInspecting(Signature *s) { +int SignatureIsFilesizeInspecting(Signature *s) +{ if (s == NULL) return 0; @@ -1873,7 +1884,8 @@ int SignatureIsFilesizeInspecting(Signature *s) { * \retval 1 sig is ip only * \retval 0 sig is not ip only */ -int SignatureIsIPOnly(DetectEngineCtx *de_ctx, Signature *s) { +int SignatureIsIPOnly(DetectEngineCtx *de_ctx, Signature *s) +{ if (s->alproto != ALPROTO_UNKNOWN) return 0; @@ -1973,7 +1985,8 @@ iponly: * \retval 1 sig is inspecting the payload * \retval 0 sig is not inspecting the payload */ -static int SignatureIsInspectingPayload(DetectEngineCtx *de_ctx, Signature *s) { +static int SignatureIsInspectingPayload(DetectEngineCtx *de_ctx, Signature *s) +{ if (s->sm_lists[DETECT_SM_LIST_PMATCH] != NULL) { return 1; @@ -2002,7 +2015,8 @@ static int SignatureIsInspectingPayload(DetectEngineCtx *de_ctx, Signature *s) { * \retval 0 not a DEOnly sig * \retval 1 DEOnly sig */ -static int SignatureIsDEOnly(DetectEngineCtx *de_ctx, Signature *s) { +static int SignatureIsDEOnly(DetectEngineCtx *de_ctx, Signature *s) +{ if (s->alproto != ALPROTO_UNKNOWN) { SCReturnInt(0); } @@ -2117,7 +2131,8 @@ PacketCreateMask(Packet *p, SignatureMask *mask, AppProto alproto, int has_state } } -static int SignatureCreateMask(Signature *s) { +static int SignatureCreateMask(Signature *s) +{ SCEnter(); if (s->sm_lists[DETECT_SM_LIST_PMATCH] != NULL) { @@ -2383,7 +2398,8 @@ static void SigInitStandardMpmFactoryContexts(DetectEngineCtx *de_ctx) * \param s signature to get dsize value from * \retval depth or negative value */ -static int SigParseGetMaxDsize(Signature *s) { +static int SigParseGetMaxDsize(Signature *s) +{ if (s->flags & SIG_FLAG_DSIZE && s->dsize_sm != NULL) { DetectDsizeData *dd = (DetectDsizeData *)s->dsize_sm->ctx; @@ -2404,7 +2420,8 @@ static int SigParseGetMaxDsize(Signature *s) { /** \brief set prefilter dsize pair * \param s signature to get dsize value from */ -static void SigParseSetDsizePair(Signature *s) { +static void SigParseSetDsizePair(Signature *s) +{ if (s->flags & SIG_FLAG_DSIZE && s->dsize_sm != NULL) { DetectDsizeData *dd = (DetectDsizeData *)s->dsize_sm->ctx; @@ -2440,7 +2457,8 @@ static void SigParseSetDsizePair(Signature *s) { * \brief Apply dsize as depth to content matches in the rule * \param s signature to get dsize value from */ -static void SigParseApplyDsizeToContent(Signature *s) { +static void SigParseApplyDsizeToContent(Signature *s) +{ SCEnter(); if (s->flags & SIG_FLAG_DSIZE) { @@ -2480,7 +2498,8 @@ static void SigParseApplyDsizeToContent(Signature *s) { * \retval 0 on success * \retval -1 on failure */ -int SigAddressPrepareStage1(DetectEngineCtx *de_ctx) { +int SigAddressPrepareStage1(DetectEngineCtx *de_ctx) +{ Signature *tmp_s = NULL; uint32_t cnt_iponly = 0; uint32_t cnt_payload = 0; @@ -2599,7 +2618,8 @@ error: return -1; } -static int DetectEngineLookupBuildSourceAddressList(DetectEngineCtx *de_ctx, DetectEngineLookupFlow *flow_gh, Signature *s, int family) { +static int DetectEngineLookupBuildSourceAddressList(DetectEngineCtx *de_ctx, DetectEngineLookupFlow *flow_gh, Signature *s, int family) +{ DetectAddress *gr = NULL, *lookup_gr = NULL, *head = NULL; int proto; @@ -2659,7 +2679,8 @@ error: /** * \brief add signature to the right flow group(s) */ -static int DetectEngineLookupFlowAddSig(DetectEngineCtx *de_ctx, Signature *s, int family) { +static int DetectEngineLookupFlowAddSig(DetectEngineCtx *de_ctx, Signature *s, int family) +{ SCLogDebug("s->id %u", s->id); if (s->flags & SIG_FLAG_TOCLIENT) { @@ -2677,7 +2698,8 @@ static int DetectEngineLookupFlowAddSig(DetectEngineCtx *de_ctx, Signature *s, i return 0; } -static DetectAddress *GetHeadPtr(DetectAddressHead *head, int family) { +static DetectAddress *GetHeadPtr(DetectAddressHead *head, int family) +{ DetectAddress *grhead; if (head == NULL) @@ -2699,13 +2721,15 @@ static DetectAddress *GetHeadPtr(DetectAddressHead *head, int family) { // || (c) == 2) // || (c) == 3) -int CreateGroupedAddrListCmpCnt(DetectAddress *a, DetectAddress *b) { +int CreateGroupedAddrListCmpCnt(DetectAddress *a, DetectAddress *b) +{ if (a->cnt > b->cnt) return 1; return 0; } -int CreateGroupedAddrListCmpMpmMaxlen(DetectAddress *a, DetectAddress *b) { +int CreateGroupedAddrListCmpMpmMaxlen(DetectAddress *a, DetectAddress *b) +{ if (a->sh == NULL || b->sh == NULL) return 0; @@ -2872,13 +2896,15 @@ error: return -1; } -int CreateGroupedPortListCmpCnt(DetectPort *a, DetectPort *b) { +int CreateGroupedPortListCmpCnt(DetectPort *a, DetectPort *b) +{ if (a->cnt > b->cnt) return 1; return 0; } -int CreateGroupedPortListCmpMpmMaxlen(DetectPort *a, DetectPort *b) { +int CreateGroupedPortListCmpMpmMaxlen(DetectPort *a, DetectPort *b) +{ if (a->sh == NULL || b->sh == NULL) return 0; @@ -2895,7 +2921,8 @@ static uint32_t g_groupportlist_maxgroups = 0; static uint32_t g_groupportlist_groupscnt = 0; static uint32_t g_groupportlist_totgroups = 0; -int CreateGroupedPortList(DetectEngineCtx *de_ctx,HashListTable *port_hash, DetectPort **newhead, uint32_t unique_groups, int (*CompareFunc)(DetectPort *, DetectPort *), uint32_t max_idx) { +int CreateGroupedPortList(DetectEngineCtx *de_ctx,HashListTable *port_hash, DetectPort **newhead, uint32_t unique_groups, int (*CompareFunc)(DetectPort *, DetectPort *), uint32_t max_idx) +{ DetectPort *tmplist = NULL, *tmplist2 = NULL, *joingr = NULL; char insert = 0; DetectPort *gr, *next_gr; @@ -3034,7 +3061,8 @@ error: * \internal * \brief add a decoder event signature to the detection engine ctx */ -static void DetectEngineAddDecoderEventSig(DetectEngineCtx *de_ctx, Signature *s) { +static void DetectEngineAddDecoderEventSig(DetectEngineCtx *de_ctx, Signature *s) +{ SCLogDebug("adding signature %"PRIu32" to the decoder event sgh", s->id); SigGroupHeadAppendSig(de_ctx, &de_ctx->decoder_event_sgh, s); } @@ -3048,7 +3076,8 @@ static void DetectEngineAddDecoderEventSig(DetectEngineCtx *de_ctx, Signature *s * \retval 0 On success * \retval -1 On failure */ -int SigAddressPrepareStage2(DetectEngineCtx *de_ctx) { +int SigAddressPrepareStage2(DetectEngineCtx *de_ctx) +{ Signature *tmp_s = NULL; uint32_t sigs = 0; @@ -3226,7 +3255,8 @@ error: /** * \brief Build the destination address portion of the match tree */ -int BuildDestinationAddressHeads(DetectEngineCtx *de_ctx, DetectAddressHead *head, int family, int flow) { +int BuildDestinationAddressHeads(DetectEngineCtx *de_ctx, DetectAddressHead *head, int family, int flow) +{ Signature *tmp_s = NULL; DetectAddress *gr = NULL, *sgr = NULL, *lookup_gr = NULL; uint32_t max_idx = 0; @@ -3399,7 +3429,8 @@ error: } //static -int BuildDestinationAddressHeadsWithBothPorts(DetectEngineCtx *de_ctx, DetectAddressHead *head, int family, int flow) { +int BuildDestinationAddressHeadsWithBothPorts(DetectEngineCtx *de_ctx, DetectAddressHead *head, int family, int flow) +{ Signature *tmp_s = NULL; DetectAddress *src_gr = NULL, *dst_gr = NULL, *sig_gr = NULL, *lookup_gr = NULL; DetectAddress *src_gr_head = NULL, *dst_gr_head = NULL, *sig_gr_head = NULL; @@ -3731,7 +3762,8 @@ error: return -1; } -static void DetectEngineBuildDecoderEventSgh(DetectEngineCtx *de_ctx) { +static void DetectEngineBuildDecoderEventSgh(DetectEngineCtx *de_ctx) +{ if (de_ctx->decoder_event_sgh == NULL) return; @@ -3740,7 +3772,8 @@ static void DetectEngineBuildDecoderEventSgh(DetectEngineCtx *de_ctx) { SigGroupHeadBuildMatchArray(de_ctx, de_ctx->decoder_event_sgh, max_idx); } -int SigAddressPrepareStage3(DetectEngineCtx *de_ctx) { +int SigAddressPrepareStage3(DetectEngineCtx *de_ctx) +{ int r; if (!(de_ctx->flags & DE_QUIET)) { @@ -3864,7 +3897,8 @@ error: return -1; } -int SigAddressCleanupStage1(DetectEngineCtx *de_ctx) { +int SigAddressCleanupStage1(DetectEngineCtx *de_ctx) +{ BUG_ON(de_ctx == NULL); if (!(de_ctx->flags & DE_QUIET)) { @@ -3892,7 +3926,8 @@ int SigAddressCleanupStage1(DetectEngineCtx *de_ctx) { return 0; } -void DbgPrintSigs(DetectEngineCtx *de_ctx, SigGroupHead *sgh) { +void DbgPrintSigs(DetectEngineCtx *de_ctx, SigGroupHead *sgh) +{ if (sgh == NULL) { printf("\n"); return; @@ -3905,7 +3940,8 @@ void DbgPrintSigs(DetectEngineCtx *de_ctx, SigGroupHead *sgh) { printf("\n"); } -void DbgPrintSigs2(DetectEngineCtx *de_ctx, SigGroupHead *sgh) { +void DbgPrintSigs2(DetectEngineCtx *de_ctx, SigGroupHead *sgh) +{ if (sgh == NULL || sgh->init == NULL) { printf("\n"); return; @@ -3920,7 +3956,8 @@ void DbgPrintSigs2(DetectEngineCtx *de_ctx, SigGroupHead *sgh) { printf("\n"); } -void DbgSghContainsSig(DetectEngineCtx *de_ctx, SigGroupHead *sgh, uint32_t sid) { +void DbgSghContainsSig(DetectEngineCtx *de_ctx, SigGroupHead *sgh, uint32_t sid) +{ if (sgh == NULL || sgh->init == NULL) { printf("\n"); return; @@ -3943,7 +3980,8 @@ void DbgSghContainsSig(DetectEngineCtx *de_ctx, SigGroupHead *sgh, uint32_t sid) } /** \brief finalize preparing sgh's */ -int SigAddressPrepareStage4(DetectEngineCtx *de_ctx) { +int SigAddressPrepareStage4(DetectEngineCtx *de_ctx) +{ SCEnter(); //SCLogInfo("sgh's %"PRIu32, de_ctx->sgh_array_cnt); @@ -3981,7 +4019,8 @@ int SigAddressPrepareStage4(DetectEngineCtx *de_ctx) { #define PRINTSIGS /* just printing */ -int SigAddressPrepareStage5(DetectEngineCtx *de_ctx) { +int SigAddressPrepareStage5(DetectEngineCtx *de_ctx) +{ DetectAddressHead *global_dst_gh = NULL; DetectAddress *global_src_gr = NULL, *global_dst_gr = NULL; uint32_t u; @@ -4561,7 +4600,8 @@ int SigGroupBuild(DetectEngineCtx *de_ctx) return 0; } -int SigGroupCleanup (DetectEngineCtx *de_ctx) { +int SigGroupCleanup (DetectEngineCtx *de_ctx) +{ SigAddressCleanupStage1(de_ctx); return 0; @@ -4674,7 +4714,8 @@ void SigTableList(const char *keyword) return; } -void SigTableSetup(void) { +void SigTableSetup(void) +{ memset(sigmatch_table, 0, sizeof(sigmatch_table)); DetectSidRegister(); @@ -4868,7 +4909,8 @@ static const char *dummy_conf_string = " SSH_PORTS: 22\n" "\n"; -static int SigTest01Real (int mpm_type) { +static int SigTest01Real (int mpm_type) +{ uint8_t *buf = (uint8_t *) "GET /one/ HTTP/1.1\r\n" "Host: one.example.org\r\n" @@ -4905,17 +4947,21 @@ end: return result; } -static int SigTest01B2g (void) { +static int SigTest01B2g (void) +{ return SigTest01Real(MPM_B2G); } -static int SigTest01B3g (void) { +static int SigTest01B3g (void) +{ return SigTest01Real(MPM_B3G); } -static int SigTest01Wm (void) { +static int SigTest01Wm (void) +{ return SigTest01Real(MPM_WUMANBER); } -static int SigTest02Real (int mpm_type) { +static int SigTest02Real (int mpm_type) +{ uint8_t *buf = (uint8_t *) "GET /one/ HTTP/1.1\r\n" "Host: one.example.org\r\n" @@ -4931,18 +4977,22 @@ static int SigTest02Real (int mpm_type) { return ret; } -static int SigTest02B2g (void) { +static int SigTest02B2g (void) +{ return SigTest02Real(MPM_B2G); } -static int SigTest02B3g (void) { +static int SigTest02B3g (void) +{ return SigTest02Real(MPM_B3G); } -static int SigTest02Wm (void) { +static int SigTest02Wm (void) +{ return SigTest02Real(MPM_WUMANBER); } -static int SigTest03Real (int mpm_type) { +static int SigTest03Real (int mpm_type) +{ uint8_t *buf = (uint8_t *) "GET /one/ HTTP/1.1\r\n" "Host: one.example.org\r\n" @@ -4992,18 +5042,22 @@ end: UTHFreePackets(&p, 1); return result; } -static int SigTest03B2g (void) { +static int SigTest03B2g (void) +{ return SigTest03Real(MPM_B2G); } -static int SigTest03B3g (void) { +static int SigTest03B3g (void) +{ return SigTest03Real(MPM_B3G); } -static int SigTest03Wm (void) { +static int SigTest03Wm (void) +{ return SigTest03Real(MPM_WUMANBER); } -static int SigTest04Real (int mpm_type) { +static int SigTest04Real (int mpm_type) +{ uint8_t *buf = (uint8_t *) "GET /one/ HTTP/1.1\r\n" /* 20*/ "Host: one.example.org\r\n" /* 23, post "Host:" 18 */ @@ -5052,18 +5106,22 @@ end: UTHFreePackets(&p, 1); return result; } -static int SigTest04B2g (void) { +static int SigTest04B2g (void) +{ return SigTest04Real(MPM_B2G); } -static int SigTest04B3g (void) { +static int SigTest04B3g (void) +{ return SigTest04Real(MPM_B3G); } -static int SigTest04Wm (void) { +static int SigTest04Wm (void) +{ return SigTest04Real(MPM_WUMANBER); } -static int SigTest05Real (int mpm_type) { +static int SigTest05Real (int mpm_type) +{ uint8_t *buf = (uint8_t *) "GET /one/ HTTP/1.1\r\n" /* 20 */ "Host: one.example.org\r\n" /* 23, 43 */ @@ -5114,18 +5172,22 @@ end: UTHFreePackets(&p, 1); return result; } -static int SigTest05B2g (void) { +static int SigTest05B2g (void) +{ return SigTest05Real(MPM_B2G); } -static int SigTest05B3g (void) { +static int SigTest05B3g (void) +{ return SigTest05Real(MPM_B3G); } -static int SigTest05Wm (void) { +static int SigTest05Wm (void) +{ return SigTest05Real(MPM_WUMANBER); } -static int SigTest06Real (int mpm_type) { +static int SigTest06Real (int mpm_type) +{ uint8_t *buf = (uint8_t *) "GET /one/ HTTP/1.1\r\n" /* 20 */ "Host: one.example.org\r\n" /* 23, 43 */ @@ -5214,18 +5276,22 @@ end: FLOW_DESTROY(&f); return result; } -static int SigTest06B2g (void) { +static int SigTest06B2g (void) +{ return SigTest06Real(MPM_B2G); } -static int SigTest06B3g (void) { +static int SigTest06B3g (void) +{ return SigTest06Real(MPM_B3G); } -static int SigTest06Wm (void) { +static int SigTest06Wm (void) +{ return SigTest06Real(MPM_WUMANBER); } -static int SigTest07Real (int mpm_type) { +static int SigTest07Real (int mpm_type) +{ uint8_t *buf = (uint8_t *) "GET /one/ HTTP/1.1\r\n" /* 20 */ "Host: one.example.org\r\n" /* 23, 43 */ @@ -5314,18 +5380,22 @@ end: return result; } -static int SigTest07B2g (void) { +static int SigTest07B2g (void) +{ return SigTest07Real(MPM_B2G); } -static int SigTest07B3g (void) { +static int SigTest07B3g (void) +{ return SigTest07Real(MPM_B3G); } -static int SigTest07Wm (void) { +static int SigTest07Wm (void) +{ return SigTest07Real(MPM_WUMANBER); } -static int SigTest08Real (int mpm_type) { +static int SigTest08Real (int mpm_type) +{ uint8_t *buf = (uint8_t *) "GET /one/ HTTP/1.0\r\n" /* 20 */ "Host: one.example.org\r\n" /* 23, 43 */ @@ -5415,18 +5485,22 @@ end: FLOW_DESTROY(&f); return result; } -static int SigTest08B2g (void) { +static int SigTest08B2g (void) +{ return SigTest08Real(MPM_B2G); } -static int SigTest08B3g (void) { +static int SigTest08B3g (void) +{ return SigTest08Real(MPM_B3G); } -static int SigTest08Wm (void) { +static int SigTest08Wm (void) +{ return SigTest08Real(MPM_WUMANBER); } -static int SigTest09Real (int mpm_type) { +static int SigTest09Real (int mpm_type) +{ uint8_t *buf = (uint8_t *) "GET /one/ HTTP/1.0\r\n" /* 20 */ "Host: one.example.org\r\n" /* 23, 43 */ @@ -5513,18 +5587,22 @@ end: FLOW_DESTROY(&f); return result; } -static int SigTest09B2g (void) { +static int SigTest09B2g (void) +{ return SigTest09Real(MPM_B2G); } -static int SigTest09B3g (void) { +static int SigTest09B3g (void) +{ return SigTest09Real(MPM_B3G); } -static int SigTest09Wm (void) { +static int SigTest09Wm (void) +{ return SigTest09Real(MPM_WUMANBER); } -static int SigTest10Real (int mpm_type) { +static int SigTest10Real (int mpm_type) +{ uint8_t *buf = (uint8_t *) "ABC"; uint16_t buflen = strlen((char *)buf); @@ -5607,18 +5685,22 @@ static int SigTest10Real (int mpm_type) { FLOW_DESTROY(&f); return result; } -static int SigTest10B2g (void) { +static int SigTest10B2g (void) +{ return SigTest10Real(MPM_B2G); } -static int SigTest10B3g (void) { +static int SigTest10B3g (void) +{ return SigTest10Real(MPM_B3G); } -static int SigTest10Wm (void) { +static int SigTest10Wm (void) +{ return SigTest10Real(MPM_WUMANBER); } -static int SigTest11Real (int mpm_type) { +static int SigTest11Real (int mpm_type) +{ uint8_t *buf = (uint8_t *) "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+"; uint16_t buflen = strlen((char *)buf); @@ -5681,18 +5763,22 @@ static int SigTest11Real (int mpm_type) { FLOW_DESTROY(&f); return result; } -static int SigTest11B2g (void) { +static int SigTest11B2g (void) +{ return SigTest11Real(MPM_B2G); } -static int SigTest11B3g (void) { +static int SigTest11B3g (void) +{ return SigTest11Real(MPM_B3G); } -static int SigTest11Wm (void) { +static int SigTest11Wm (void) +{ return SigTest11Real(MPM_WUMANBER); } -static int SigTest12Real (int mpm_type) { +static int SigTest12Real (int mpm_type) +{ uint8_t *buf = (uint8_t *) "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+"; uint16_t buflen = strlen((char *)buf); @@ -5746,18 +5832,22 @@ end: FLOW_DESTROY(&f); return result; } -static int SigTest12B2g (void) { +static int SigTest12B2g (void) +{ return SigTest12Real(MPM_B2G); } -static int SigTest12B3g (void) { +static int SigTest12B3g (void) +{ return SigTest12Real(MPM_B3G); } -static int SigTest12Wm (void) { +static int SigTest12Wm (void) +{ return SigTest12Real(MPM_WUMANBER); } -static int SigTest13Real (int mpm_type) { +static int SigTest13Real (int mpm_type) +{ uint8_t *buf = (uint8_t *) "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+"; uint16_t buflen = strlen((char *)buf); @@ -5808,18 +5898,22 @@ end: FLOW_DESTROY(&f); return result; } -static int SigTest13B2g (void) { +static int SigTest13B2g (void) +{ return SigTest13Real(MPM_B2G); } -static int SigTest13B3g (void) { +static int SigTest13B3g (void) +{ return SigTest13Real(MPM_B3G); } -static int SigTest13Wm (void) { +static int SigTest13Wm (void) +{ return SigTest13Real(MPM_WUMANBER); } -static int SigTest14Real (int mpm_type) { +static int SigTest14Real (int mpm_type) +{ uint8_t *buf = (uint8_t *) "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+"; uint16_t buflen = strlen((char *)buf); @@ -5863,18 +5957,22 @@ end: UTHFreePackets(&p, 1); return result; } -static int SigTest14B2g (void) { +static int SigTest14B2g (void) +{ return SigTest14Real(MPM_B2G); } -static int SigTest14B3g (void) { +static int SigTest14B3g (void) +{ return SigTest14Real(MPM_B3G); } -static int SigTest14Wm (void) { +static int SigTest14Wm (void) +{ return SigTest14Real(MPM_WUMANBER); } -static int SigTest15Real (int mpm_type) { +static int SigTest15Real (int mpm_type) +{ uint8_t *buf = (uint8_t *) "CONNECT 213.92.8.7:31204 HTTP/1.1"; uint16_t buflen = strlen((char *)buf); @@ -5932,18 +6030,22 @@ end: SCFree(p); return result; } -static int SigTest15B2g (void) { +static int SigTest15B2g (void) +{ return SigTest15Real(MPM_B2G); } -static int SigTest15B3g (void) { +static int SigTest15B3g (void) +{ return SigTest15Real(MPM_B3G); } -static int SigTest15Wm (void) { +static int SigTest15Wm (void) +{ return SigTest15Real(MPM_WUMANBER); } -static int SigTest16Real (int mpm_type) { +static int SigTest16Real (int mpm_type) +{ uint8_t *buf = (uint8_t *) "CONNECT 213.92.8.7:31204 HTTP/1.1"; uint16_t buflen = strlen((char *)buf); @@ -5993,18 +6095,22 @@ end: UTHFreePackets(&p, 1); return result; } -static int SigTest16B2g (void) { +static int SigTest16B2g (void) +{ return SigTest16Real(MPM_B2G); } -static int SigTest16B3g (void) { +static int SigTest16B3g (void) +{ return SigTest16Real(MPM_B3G); } -static int SigTest16Wm (void) { +static int SigTest16Wm (void) +{ return SigTest16Real(MPM_WUMANBER); } -static int SigTest17Real (int mpm_type) { +static int SigTest17Real (int mpm_type) +{ uint8_t *buf = (uint8_t *) "GET /one/ HTTP/1.1\r\n" /* 20 */ "Host: one.example.org\r\n" /* 23, 43 */ @@ -6071,17 +6177,21 @@ end: UTHFreePackets(&p, 1); return result; } -static int SigTest17B2g (void) { +static int SigTest17B2g (void) +{ return SigTest17Real(MPM_B2G); } -static int SigTest17B3g (void) { +static int SigTest17B3g (void) +{ return SigTest17Real(MPM_B3G); } -static int SigTest17Wm (void) { +static int SigTest17Wm (void) +{ return SigTest17Real(MPM_WUMANBER); } -static int SigTest18Real (int mpm_type) { +static int SigTest18Real (int mpm_type) +{ uint8_t *buf = (uint8_t *) "220 (vsFTPd 2.0.5)\r\n"; uint16_t buflen = strlen((char *)buf); @@ -6134,17 +6244,21 @@ end: SCFree(p); return result; } -static int SigTest18B2g (void) { +static int SigTest18B2g (void) +{ return SigTest18Real(MPM_B2G); } -static int SigTest18B3g (void) { +static int SigTest18B3g (void) +{ return SigTest18Real(MPM_B3G); } -static int SigTest18Wm (void) { +static int SigTest18Wm (void) +{ return SigTest18Real(MPM_WUMANBER); } -int SigTest19Real (int mpm_type) { +int SigTest19Real (int mpm_type) +{ uint8_t *buf = (uint8_t *) "220 (vsFTPd 2.0.5)\r\n"; uint16_t buflen = strlen((char *)buf); @@ -6204,17 +6318,21 @@ end: SCFree(p); return result; } -static int SigTest19B2g (void) { +static int SigTest19B2g (void) +{ return SigTest19Real(MPM_B2G); } -static int SigTest19B3g (void) { +static int SigTest19B3g (void) +{ return SigTest19Real(MPM_B3G); } -static int SigTest19Wm (void) { +static int SigTest19Wm (void) +{ return SigTest19Real(MPM_WUMANBER); } -static int SigTest20Real (int mpm_type) { +static int SigTest20Real (int mpm_type) +{ uint8_t *buf = (uint8_t *) "220 (vsFTPd 2.0.5)\r\n"; uint16_t buflen = strlen((char *)buf); @@ -6278,18 +6396,22 @@ end: SCFree(p); return result; } -static int SigTest20B2g (void) { +static int SigTest20B2g (void) +{ return SigTest20Real(MPM_B2G); } -static int SigTest20B3g (void) { +static int SigTest20B3g (void) +{ return SigTest20Real(MPM_B3G); } -static int SigTest20Wm (void) { +static int SigTest20Wm (void) +{ return SigTest20Real(MPM_WUMANBER); } -static int SigTest21Real (int mpm_type) { +static int SigTest21Real (int mpm_type) +{ ThreadVars th_v; memset(&th_v, 0, sizeof(th_v)); DetectEngineThreadCtx *det_ctx = NULL; @@ -6366,18 +6488,22 @@ end: FLOW_DESTROY(&f); return result; } -static int SigTest21B2g (void) { +static int SigTest21B2g (void) +{ return SigTest21Real(MPM_B2G); } -static int SigTest21B3g (void) { +static int SigTest21B3g (void) +{ return SigTest21Real(MPM_B3G); } -static int SigTest21Wm (void) { +static int SigTest21Wm (void) +{ return SigTest21Real(MPM_WUMANBER); } -static int SigTest22Real (int mpm_type) { +static int SigTest22Real (int mpm_type) +{ ThreadVars th_v; memset(&th_v, 0, sizeof(th_v)); DetectEngineThreadCtx *det_ctx = NULL; @@ -6453,17 +6579,21 @@ end: FLOW_DESTROY(&f); return result; } -static int SigTest22B2g (void) { +static int SigTest22B2g (void) +{ return SigTest22Real(MPM_B2G); } -static int SigTest22B3g (void) { +static int SigTest22B3g (void) +{ return SigTest22Real(MPM_B3G); } -static int SigTest22Wm (void) { +static int SigTest22Wm (void) +{ return SigTest22Real(MPM_WUMANBER); } -static int SigTest23Real (int mpm_type) { +static int SigTest23Real (int mpm_type) +{ ThreadVars th_v; memset(&th_v, 0, sizeof(th_v)); DetectEngineThreadCtx *det_ctx = NULL; @@ -6537,13 +6667,16 @@ end: FLOW_DESTROY(&f); return result; } -static int SigTest23B2g (void) { +static int SigTest23B2g (void) +{ return SigTest23Real(MPM_B2G); } -static int SigTest23B3g (void) { +static int SigTest23B3g (void) +{ return SigTest23Real(MPM_B3G); } -static int SigTest23Wm (void) { +static int SigTest23Wm (void) +{ return SigTest23Real(MPM_WUMANBER); } @@ -8579,13 +8712,16 @@ end: SCFree(p1); return result; } -static int SigTest38B2g (void) { +static int SigTest38B2g (void) +{ return SigTest38Real(MPM_B2G); } -static int SigTest38B3g (void) { +static int SigTest38B3g (void) +{ return SigTest38Real(MPM_B3G); } -static int SigTest38Wm (void) { +static int SigTest38Wm (void) +{ return SigTest38Real(MPM_WUMANBER); } @@ -8725,13 +8861,16 @@ end: SCFree(p1); return result; } -static int SigTest39B2g (void) { +static int SigTest39B2g (void) +{ return SigTest39Real(MPM_B2G); } -static int SigTest39B3g (void) { +static int SigTest39B3g (void) +{ return SigTest39Real(MPM_B3G); } -static int SigTest39Wm (void) { +static int SigTest39Wm (void) +{ return SigTest39Real(MPM_WUMANBER); } @@ -8742,7 +8881,8 @@ static int SigTest39Wm (void) { * \brief expecting to match a size */ -int SigTest36ContentAndIsdataatKeywords01Real (int mpm_type) { +int SigTest36ContentAndIsdataatKeywords01Real (int mpm_type) +{ int result = 0; // Buid and decode the packet @@ -8863,7 +9003,8 @@ end: * \brief not expecting to match a size */ -int SigTest37ContentAndIsdataatKeywords02Real (int mpm_type) { +int SigTest37ContentAndIsdataatKeywords02Real (int mpm_type) +{ int result = 0; // Buid and decode the packet @@ -8993,23 +9134,29 @@ end: // Wrapper functions to pass the mpm_type -static int SigTest36ContentAndIsdataatKeywords01B2g (void) { +static int SigTest36ContentAndIsdataatKeywords01B2g (void) +{ return SigTest36ContentAndIsdataatKeywords01Real(MPM_B2G); } -static int SigTest36ContentAndIsdataatKeywords01B3g (void) { +static int SigTest36ContentAndIsdataatKeywords01B3g (void) +{ return SigTest36ContentAndIsdataatKeywords01Real(MPM_B3G); } -static int SigTest36ContentAndIsdataatKeywords01Wm (void) { +static int SigTest36ContentAndIsdataatKeywords01Wm (void) +{ return SigTest36ContentAndIsdataatKeywords01Real(MPM_WUMANBER); } -static int SigTest37ContentAndIsdataatKeywords02B2g (void) { +static int SigTest37ContentAndIsdataatKeywords02B2g (void) +{ return SigTest37ContentAndIsdataatKeywords02Real(MPM_B2G); } -static int SigTest37ContentAndIsdataatKeywords02B3g (void) { +static int SigTest37ContentAndIsdataatKeywords02B3g (void) +{ return SigTest37ContentAndIsdataatKeywords02Real(MPM_B3G); } -static int SigTest37ContentAndIsdataatKeywords02Wm (void) { +static int SigTest37ContentAndIsdataatKeywords02Wm (void) +{ return SigTest37ContentAndIsdataatKeywords02Real(MPM_WUMANBER); } @@ -9019,7 +9166,8 @@ static int SigTest37ContentAndIsdataatKeywords02Wm (void) { * flag is set, we don't need to inspect the packet protocol header or its contents. */ -int SigTest40NoPacketInspection01(void) { +int SigTest40NoPacketInspection01(void) +{ uint8_t *buf = (uint8_t *) "220 (vsFTPd 2.0.5)\r\n"; @@ -9094,7 +9242,8 @@ end: * flasg is set, we don't need to inspect the packet contents. */ -int SigTest40NoPayloadInspection02(void) { +int SigTest40NoPayloadInspection02(void) +{ uint8_t *buf = (uint8_t *) "220 (vsFTPd 2.0.5)\r\n"; @@ -9151,7 +9300,8 @@ end: return result; } -static int SigTestMemory01 (void) { +static int SigTestMemory01 (void) +{ uint8_t *buf = (uint8_t *) "GET /one/ HTTP/1.1\r\n" "Host: one.example.org\r\n" @@ -9211,7 +9361,8 @@ end: return result; } -static int SigTestMemory02 (void) { +static int SigTestMemory02 (void) +{ ThreadVars th_v; int result = 0; @@ -9254,7 +9405,8 @@ end: return result; } -static int SigTestMemory03 (void) { +static int SigTestMemory03 (void) +{ ThreadVars th_v; int result = 0; @@ -9298,7 +9450,8 @@ end: return result; } -static int SigTestSgh01 (void) { +static int SigTestSgh01 (void) +{ ThreadVars th_v; int result = 0; DetectEngineThreadCtx *det_ctx = NULL; @@ -9439,7 +9592,8 @@ end: return result; } -static int SigTestSgh02 (void) { +static int SigTestSgh02 (void) +{ ThreadVars th_v; int result = 0; DetectEngineThreadCtx *det_ctx = NULL; @@ -9626,7 +9780,8 @@ end: return result; } -static int SigTestSgh03 (void) { +static int SigTestSgh03 (void) +{ ThreadVars th_v; int result = 0; Packet *p = SCMalloc(SIZE_OF_PACKET); @@ -9797,7 +9952,8 @@ end: return result; } -static int SigTestSgh04 (void) { +static int SigTestSgh04 (void) +{ ThreadVars th_v; int result = 0; Packet *p = SCMalloc(SIZE_OF_PACKET); @@ -9989,7 +10145,8 @@ end: } /** \test setting of mpm type */ -static int SigTestSgh05 (void) { +static int SigTestSgh05 (void) +{ ThreadVars th_v; int result = 0; Packet *p = SCMalloc(SIZE_OF_PACKET); @@ -10057,7 +10214,8 @@ end: return result; } -static int SigTestContent01Real (int mpm_type) { +static int SigTestContent01Real (int mpm_type) +{ uint8_t *buf = (uint8_t *)"01234567890123456789012345678901"; uint16_t buflen = strlen((char *)buf); ThreadVars th_v; @@ -10101,17 +10259,21 @@ end: UTHFreePackets(&p, 1); return result; } -static int SigTestContent01B2g (void) { +static int SigTestContent01B2g (void) +{ return SigTestContent01Real(MPM_B2G); } -static int SigTestContent01B3g (void) { +static int SigTestContent01B3g (void) +{ return SigTestContent01Real(MPM_B3G); } -static int SigTestContent01Wm (void) { +static int SigTestContent01Wm (void) +{ return SigTestContent01Real(MPM_WUMANBER); } -static int SigTestContent02Real (int mpm_type) { +static int SigTestContent02Real (int mpm_type) +{ uint8_t *buf = (uint8_t *)"01234567890123456789012345678901"; uint16_t buflen = strlen((char *)buf); ThreadVars th_v; @@ -10164,17 +10326,21 @@ end: UTHFreePackets(&p, 1); return result; } -static int SigTestContent02B2g (void) { +static int SigTestContent02B2g (void) +{ return SigTestContent02Real(MPM_B2G); } -static int SigTestContent02B3g (void) { +static int SigTestContent02B3g (void) +{ return SigTestContent02Real(MPM_B3G); } -static int SigTestContent02Wm (void) { +static int SigTestContent02Wm (void) +{ return SigTestContent02Real(MPM_WUMANBER); } -static int SigTestContent03Real (int mpm_type) { +static int SigTestContent03Real (int mpm_type) +{ uint8_t *buf = (uint8_t *)"01234567890123456789012345678901abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; uint16_t buflen = strlen((char *)buf); ThreadVars th_v; @@ -10217,17 +10383,21 @@ end: UTHFreePackets(&p, 1); return result; } -static int SigTestContent03B2g (void) { +static int SigTestContent03B2g (void) +{ return SigTestContent03Real(MPM_B2G); } -static int SigTestContent03B3g (void) { +static int SigTestContent03B3g (void) +{ return SigTestContent03Real(MPM_B3G); } -static int SigTestContent03Wm (void) { +static int SigTestContent03Wm (void) +{ return SigTestContent03Real(MPM_WUMANBER); } -static int SigTestContent04Real (int mpm_type) { +static int SigTestContent04Real (int mpm_type) +{ uint8_t *buf = (uint8_t *)"01234567890123456789012345678901abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; uint16_t buflen = strlen((char *)buf); ThreadVars th_v; @@ -10271,18 +10441,22 @@ end: UTHFreePackets(&p, 1); return result; } -static int SigTestContent04B2g (void) { +static int SigTestContent04B2g (void) +{ return SigTestContent04Real(MPM_B2G); } -static int SigTestContent04B3g (void) { +static int SigTestContent04B3g (void) +{ return SigTestContent04Real(MPM_B3G); } -static int SigTestContent04Wm (void) { +static int SigTestContent04Wm (void) +{ return SigTestContent04Real(MPM_WUMANBER); } /** \test sigs with patterns at the limit of the pm's size limit */ -static int SigTestContent05Real (int mpm_type) { +static int SigTestContent05Real (int mpm_type) +{ uint8_t *buf = (uint8_t *)"01234567890123456789012345678901PADabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; uint16_t buflen = strlen((char *)buf); ThreadVars th_v; @@ -10342,17 +10516,21 @@ end: } return result; } -static int SigTestContent05B2g (void) { +static int SigTestContent05B2g (void) +{ return SigTestContent05Real(MPM_B2G); } -static int SigTestContent05B3g (void) { +static int SigTestContent05B3g (void) +{ return SigTestContent05Real(MPM_B3G); } -static int SigTestContent05Wm (void) { +static int SigTestContent05Wm (void) +{ return SigTestContent05Real(MPM_WUMANBER); } -static int SigTestContent06Real (int mpm_type) { +static int SigTestContent06Real (int mpm_type) +{ uint8_t *buf = (uint8_t *)"01234567890123456789012345678901abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; uint16_t buflen = strlen((char *)buf); ThreadVars th_v; @@ -10409,17 +10587,21 @@ end: UTHFreePackets(&p, 1); return result; } -static int SigTestContent06B2g (void) { +static int SigTestContent06B2g (void) +{ return SigTestContent06Real(MPM_B2G); } -static int SigTestContent06B3g (void) { +static int SigTestContent06B3g (void) +{ return SigTestContent06Real(MPM_B3G); } -static int SigTestContent06Wm (void) { +static int SigTestContent06Wm (void) +{ return SigTestContent06Real(MPM_WUMANBER); } -static int SigTestWithinReal01 (int mpm_type) { +static int SigTestWithinReal01 (int mpm_type) +{ DecodeThreadVars dtv; ThreadVars th_v; int result = 0; @@ -10632,17 +10814,21 @@ end: return result; } -static int SigTestWithinReal01B2g (void) { +static int SigTestWithinReal01B2g (void) +{ return SigTestWithinReal01(MPM_B2G); } -static int SigTestWithinReal01B3g (void) { +static int SigTestWithinReal01B3g (void) +{ return SigTestWithinReal01(MPM_B3G); } -static int SigTestWithinReal01Wm (void) { +static int SigTestWithinReal01Wm (void) +{ return SigTestWithinReal01(MPM_WUMANBER); } -static int SigTestDepthOffset01Real (int mpm_type) { +static int SigTestDepthOffset01Real (int mpm_type) +{ uint8_t *buf = (uint8_t *)"01234567890123456789012345678901abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; uint16_t buflen = strlen((char *)buf); Packet *p = NULL; @@ -10684,13 +10870,16 @@ end: UTHFreePackets(&p, 1); return result; } -static int SigTestDepthOffset01B2g (void) { +static int SigTestDepthOffset01B2g (void) +{ return SigTestDepthOffset01Real(MPM_B2G); } -static int SigTestDepthOffset01B3g (void) { +static int SigTestDepthOffset01B3g (void) +{ return SigTestDepthOffset01Real(MPM_B3G); } -static int SigTestDepthOffset01Wm (void) { +static int SigTestDepthOffset01Wm (void) +{ return SigTestDepthOffset01Real(MPM_WUMANBER); } @@ -11386,7 +11575,8 @@ static const char *dummy_conf_string2 = " HTTP_PORTS: \"80:81,88\"\n" "\n"; -static int DetectAddressYamlParsing01 (void) { +static int DetectAddressYamlParsing01 (void) +{ int result = 0; ConfCreateContextBackup(); @@ -11432,7 +11622,8 @@ static const char *dummy_conf_string3 = " HTTP_PORTS: \"80:81,88\"\n" "\n"; -static int DetectAddressYamlParsing02 (void) { +static int DetectAddressYamlParsing02 (void) +{ int result = 0; ConfCreateContextBackup(); @@ -11478,7 +11669,8 @@ static const char *dummy_conf_string4 = " HTTP_PORTS: \"80:81,88\"\n" "\n"; -static int DetectAddressYamlParsing03 (void) { +static int DetectAddressYamlParsing03 (void) +{ int result = 0; ConfCreateContextBackup(); @@ -11525,7 +11717,8 @@ static const char *dummy_conf_string5 = "\n"; /** \test bug #815 */ -static int DetectAddressYamlParsing04 (void) { +static int DetectAddressYamlParsing04 (void) +{ int result = 0; ConfCreateContextBackup(); @@ -11556,7 +11749,8 @@ end: } #endif /* UNITTESTS */ -void SigRegisterTests(void) { +void SigRegisterTests(void) +{ #ifdef UNITTESTS SigParseRegisterTests(); IPOnlyRegisterTests(); diff --git a/src/flow-manager.c b/src/flow-manager.c index 45d5ecc334..e663f568f0 100644 --- a/src/flow-manager.c +++ b/src/flow-manager.c @@ -163,7 +163,8 @@ void FlowKillFlowManagerThread(void) * * \retval timeout timeout in seconds */ -static inline uint32_t FlowGetFlowTimeout(Flow *f, int state, int emergency) { +static inline uint32_t FlowGetFlowTimeout(Flow *f, int state, int emergency) +{ uint32_t timeout; if (emergency) { @@ -207,7 +208,8 @@ static inline uint32_t FlowGetFlowTimeout(Flow *f, int state, int emergency) { * \retval 0 not timed out * \retval 1 timed out */ -static int FlowManagerFlowTimeout(Flow *f, int state, struct timeval *ts, int emergency) { +static int FlowManagerFlowTimeout(Flow *f, int state, struct timeval *ts, int emergency) +{ /* set the timeout value according to the flow operating mode, * flow's state and protocol.*/ uint32_t timeout = FlowGetFlowTimeout(f, state, emergency); @@ -231,7 +233,8 @@ static int FlowManagerFlowTimeout(Flow *f, int state, struct timeval *ts, int em * \retval 0 not timed out just yet * \retval 1 fully timed out, lets kill it */ -static int FlowManagerFlowTimedOut(Flow *f, struct timeval *ts) { +static int FlowManagerFlowTimedOut(Flow *f, struct timeval *ts) +{ /** never prune a flow that is used by a packet or stream msg * we are currently processing in one of the threads */ if (SC_ATOMIC_GET(f->use_cnt) > 0) { @@ -921,7 +924,8 @@ void TmModuleFlowRecyclerRegister (void) * \retval On success it returns 1 and on failure 0. */ -static int FlowMgrTest01 (void) { +static int FlowMgrTest01 (void) +{ TcpSession ssn; Flow f; FlowBucket fb; @@ -968,7 +972,8 @@ static int FlowMgrTest01 (void) { * \retval On success it returns 1 and on failure 0. */ -static int FlowMgrTest02 (void) { +static int FlowMgrTest02 (void) +{ TcpSession ssn; Flow f; FlowBucket fb; @@ -1025,7 +1030,8 @@ static int FlowMgrTest02 (void) { * \retval On success it returns 1 and on failure 0. */ -static int FlowMgrTest03 (void) { +static int FlowMgrTest03 (void) +{ TcpSession ssn; Flow f; FlowBucket fb; @@ -1071,7 +1077,8 @@ static int FlowMgrTest03 (void) { * \retval On success it returns 1 and on failure 0. */ -static int FlowMgrTest04 (void) { +static int FlowMgrTest04 (void) +{ TcpSession ssn; Flow f; @@ -1130,7 +1137,8 @@ static int FlowMgrTest04 (void) { * \retval On success it returns 1 and on failure 0. */ -static int FlowMgrTest05 (void) { +static int FlowMgrTest05 (void) +{ int result = 0; FlowInitConfig(FLOW_QUIET); @@ -1178,7 +1186,8 @@ static int FlowMgrTest05 (void) { /** * \brief Function to register the Flow Unitests. */ -void FlowMgrRegisterTests (void) { +void FlowMgrRegisterTests (void) +{ #ifdef UNITTESTS UtRegisterTest("FlowMgrTest01 -- Timeout a flow having fresh TcpSession", FlowMgrTest01, 1); UtRegisterTest("FlowMgrTest02 -- Timeout a flow having TcpSession with segments", FlowMgrTest02, 1); diff --git a/src/flow-private.h b/src/flow-private.h index 32163c75d2..2c7b8f6dbd 100644 --- a/src/flow-private.h +++ b/src/flow-private.h @@ -103,7 +103,8 @@ SCMutex flowbits_mutex; * * \retval state either FLOW_STATE_NEW, FLOW_STATE_ESTABLISHED or FLOW_STATE_CLOSED */ -static inline int FlowGetFlowState(Flow *f) { +static inline int FlowGetFlowState(Flow *f) +{ if (flow_proto[f->protomap].GetProtoState != NULL) { return flow_proto[f->protomap].GetProtoState(f->protoctx); } else { diff --git a/src/flow-storage.c b/src/flow-storage.c index ea2f1dd7c8..e4f4f8aeb2 100644 --- a/src/flow-storage.c +++ b/src/flow-storage.c @@ -31,27 +31,33 @@ #include "flow-util.h" #include "util-unittest.h" -unsigned int FlowStorageSize(void) { +unsigned int FlowStorageSize(void) +{ return StorageGetSize(STORAGE_FLOW); } -void *FlowGetStorageById(Flow *f, int id) { +void *FlowGetStorageById(Flow *f, int id) +{ return StorageGetById((Storage *)((void *)f + sizeof(Flow)), STORAGE_FLOW, id); } -int FlowSetStorageById(Flow *f, int id, void *ptr) { +int FlowSetStorageById(Flow *f, int id, void *ptr) +{ return StorageSetById((Storage *)((void *)f + sizeof(Flow)), STORAGE_FLOW, id, ptr); } -void *FlowAllocStorageById(Flow *f, int id) { +void *FlowAllocStorageById(Flow *f, int id) +{ return StorageAllocByIdPrealloc((Storage *)((void *)f + sizeof(Flow)), STORAGE_FLOW, id); } -void FlowFreeStorageById(Flow *f, int id) { +void FlowFreeStorageById(Flow *f, int id) +{ StorageFreeById((Storage *)((void *)f + sizeof(Flow)), STORAGE_FLOW, id); } -void FlowFreeStorage(Flow *f) { +void FlowFreeStorage(Flow *f) +{ if (FlowStorageSize() > 0) StorageFreeAll((Storage *)((void *)f + sizeof(Flow)), STORAGE_FLOW); } @@ -62,16 +68,19 @@ int FlowStorageRegister(const char *name, const unsigned int size, void *(*Alloc #ifdef UNITTESTS -static void *StorageTestAlloc(unsigned int size) { +static void *StorageTestAlloc(unsigned int size) +{ void *x = SCMalloc(size); return x; } -static void StorageTestFree(void *x) { +static void StorageTestFree(void *x) +{ if (x) SCFree(x); } -static int FlowStorageTest01(void) { +static int FlowStorageTest01(void) +{ Flow *f = NULL; StorageInit(); @@ -150,7 +159,8 @@ error: return 0; } -static int FlowStorageTest02(void) { +static int FlowStorageTest02(void) +{ Flow *f = NULL; StorageInit(); @@ -200,7 +210,8 @@ error: return 0; } -static int FlowStorageTest03(void) { +static int FlowStorageTest03(void) +{ Flow *f = NULL; StorageInit(); @@ -275,7 +286,8 @@ error: } #endif -void RegisterFlowStorageTests(void) { +void RegisterFlowStorageTests(void) +{ #ifdef UNITTESTS UtRegisterTest("FlowStorageTest01", FlowStorageTest01, 1); UtRegisterTest("FlowStorageTest02", FlowStorageTest02, 1); diff --git a/src/flow-timeout.c b/src/flow-timeout.c index 9f57130e43..4f62d89d3a 100644 --- a/src/flow-timeout.c +++ b/src/flow-timeout.c @@ -290,7 +290,8 @@ static inline Packet *FlowForceReassemblyPseudoPacketGet(int direction, * \retval 0 no * \retval 1 yes */ -int FlowForceReassemblyNeedReassembly(Flow *f, int *server, int *client) { +int FlowForceReassemblyNeedReassembly(Flow *f, int *server, int *client) +{ TcpSession *ssn; if (f == NULL) { diff --git a/src/flow-var.c b/src/flow-var.c index d70dcad3b7..5262b5a795 100644 --- a/src/flow-var.c +++ b/src/flow-var.c @@ -33,7 +33,8 @@ #include "util-debug.h" /* puts a new value into a flowvar */ -static void FlowVarUpdateStr(FlowVar *fv, uint8_t *value, uint16_t size) { +static void FlowVarUpdateStr(FlowVar *fv, uint8_t *value, uint16_t size) +{ if (fv->data.fv_str.value) SCFree(fv->data.fv_str.value); fv->data.fv_str.value = value; @@ -41,7 +42,8 @@ static void FlowVarUpdateStr(FlowVar *fv, uint8_t *value, uint16_t size) { } /* puts a new value into a flowvar */ -static void FlowVarUpdateInt(FlowVar *fv, uint32_t value) { +static void FlowVarUpdateInt(FlowVar *fv, uint32_t value) +{ fv->data.fv_int.value = value; } @@ -49,7 +51,8 @@ static void FlowVarUpdateInt(FlowVar *fv, uint32_t value) { * \note flow is not locked by this function, caller is * responsible */ -FlowVar *FlowVarGet(Flow *f, uint16_t idx) { +FlowVar *FlowVarGet(Flow *f, uint16_t idx) +{ GenericVar *gv = f->flowvar; for ( ; gv != NULL; gv = gv->next) { @@ -61,7 +64,8 @@ FlowVar *FlowVarGet(Flow *f, uint16_t idx) { } /* add a flowvar to the flow, or update it */ -void FlowVarAddStrNoLock(Flow *f, uint16_t idx, uint8_t *value, uint16_t size) { +void FlowVarAddStrNoLock(Flow *f, uint16_t idx, uint8_t *value, uint16_t size) +{ FlowVar *fv = FlowVarGet(f, idx); if (fv == NULL) { fv = SCMalloc(sizeof(FlowVar)); @@ -82,14 +86,16 @@ void FlowVarAddStrNoLock(Flow *f, uint16_t idx, uint8_t *value, uint16_t size) { } /* add a flowvar to the flow, or update it */ -void FlowVarAddStr(Flow *f, uint16_t idx, uint8_t *value, uint16_t size) { +void FlowVarAddStr(Flow *f, uint16_t idx, uint8_t *value, uint16_t size) +{ FLOWLOCK_WRLOCK(f); FlowVarAddStrNoLock(f, idx, value, size); FLOWLOCK_UNLOCK(f); } /* add a flowvar to the flow, or update it */ -void FlowVarAddIntNoLock(Flow *f, uint16_t idx, uint32_t value) { +void FlowVarAddIntNoLock(Flow *f, uint16_t idx, uint32_t value) +{ FlowVar *fv = FlowVarGet(f, idx); if (fv == NULL) { fv = SCMalloc(sizeof(FlowVar)); @@ -109,13 +115,15 @@ void FlowVarAddIntNoLock(Flow *f, uint16_t idx, uint32_t value) { } /* add a flowvar to the flow, or update it */ -void FlowVarAddInt(Flow *f, uint16_t idx, uint32_t value) { +void FlowVarAddInt(Flow *f, uint16_t idx, uint32_t value) +{ FLOWLOCK_WRLOCK(f); FlowVarAddIntNoLock(f, idx, value); FLOWLOCK_UNLOCK(f); } -void FlowVarFree(FlowVar *fv) { +void FlowVarFree(FlowVar *fv) +{ if (fv == NULL) return; @@ -126,7 +134,8 @@ void FlowVarFree(FlowVar *fv) { SCFree(fv); } -void FlowVarPrint(GenericVar *gv) { +void FlowVarPrint(GenericVar *gv) +{ uint16_t u; if (!SCLogDebugEnabled()) diff --git a/src/flow.h b/src/flow.h index 99dd7f9738..194df001eb 100644 --- a/src/flow.h +++ b/src/flow.h @@ -444,7 +444,8 @@ void FlowCleanupAppLayer(Flow *); * * \param f Flow to set the flag in */ -static inline void FlowLockSetNoPacketInspectionFlag(Flow *f) { +static inline void FlowLockSetNoPacketInspectionFlag(Flow *f) +{ SCEnter(); SCLogDebug("flow %p", f); @@ -459,7 +460,8 @@ static inline void FlowLockSetNoPacketInspectionFlag(Flow *f) { * * \param f Flow to set the flag in */ -static inline void FlowSetNoPacketInspectionFlag(Flow *f) { +static inline void FlowSetNoPacketInspectionFlag(Flow *f) +{ SCEnter(); SCLogDebug("flow %p", f); @@ -472,7 +474,8 @@ static inline void FlowSetNoPacketInspectionFlag(Flow *f) { * * \param f Flow to set the flag in */ -static inline void FlowLockSetNoPayloadInspectionFlag(Flow *f) { +static inline void FlowLockSetNoPayloadInspectionFlag(Flow *f) +{ SCEnter(); SCLogDebug("flow %p", f); @@ -487,7 +490,8 @@ static inline void FlowLockSetNoPayloadInspectionFlag(Flow *f) { * * \param f Flow to set the flag in */ -static inline void FlowSetNoPayloadInspectionFlag(Flow *f) { +static inline void FlowSetNoPayloadInspectionFlag(Flow *f) +{ SCEnter(); SCLogDebug("flow %p", f); @@ -500,7 +504,8 @@ static inline void FlowSetNoPayloadInspectionFlag(Flow *f) { * * \param f *LOCKED* flow */ -static inline void FlowSetSessionNoApplayerInspectionFlag(Flow *f) { +static inline void FlowSetSessionNoApplayerInspectionFlag(Flow *f) +{ f->flags |= FLOW_NO_APPLAYER_INSPECTION; } @@ -533,7 +538,8 @@ static inline void FlowDecrUsecnt(Flow *f) /** \brief Reference the flow, bumping the flows use_cnt * \note This should only be called once for a destination * pointer */ -static inline void FlowReference(Flow **d, Flow *f) { +static inline void FlowReference(Flow **d, Flow *f) +{ if (likely(f != NULL)) { #ifdef DEBUG_VALIDATION BUG_ON(*d == f); @@ -546,7 +552,8 @@ static inline void FlowReference(Flow **d, Flow *f) { } } -static inline void FlowDeReference(Flow **d) { +static inline void FlowDeReference(Flow **d) +{ if (likely(*d != NULL)) { FlowDecrUsecnt(*d); *d = NULL; diff --git a/src/host-queue.c b/src/host-queue.c index 0e44b01e17..2ef1628d33 100644 --- a/src/host-queue.c +++ b/src/host-queue.c @@ -31,7 +31,8 @@ #include "util-debug.h" #include "util-print.h" -HostQueue *HostQueueInit (HostQueue *q) { +HostQueue *HostQueueInit (HostQueue *q) +{ if (q != NULL) { memset(q, 0, sizeof(HostQueue)); HQLOCK_INIT(q); @@ -39,7 +40,8 @@ HostQueue *HostQueueInit (HostQueue *q) { return q; } -HostQueue *HostQueueNew() { +HostQueue *HostQueueNew() +{ HostQueue *q = (HostQueue *)SCMalloc(sizeof(HostQueue)); if (q == NULL) { SCLogError(SC_ERR_FATAL, "Fatal error encountered in HostQueueNew. Exiting..."); @@ -54,7 +56,8 @@ HostQueue *HostQueueNew() { * * \param q the host queue to destroy */ -void HostQueueDestroy (HostQueue *q) { +void HostQueueDestroy (HostQueue *q) +{ HQLOCK_DESTROY(q); } @@ -64,7 +67,8 @@ void HostQueueDestroy (HostQueue *q) { * \param q queue * \param h host */ -void HostEnqueue (HostQueue *q, Host *h) { +void HostEnqueue (HostQueue *q, Host *h) +{ #ifdef DEBUG BUG_ON(q == NULL || h == NULL); #endif @@ -96,7 +100,8 @@ void HostEnqueue (HostQueue *q, Host *h) { * * \retval h host or NULL if empty list. */ -Host *HostDequeue (HostQueue *q) { +Host *HostDequeue (HostQueue *q) +{ HQLOCK_LOCK(q); Host *h = q->bot; @@ -128,7 +133,8 @@ Host *HostDequeue (HostQueue *q) { return h; } -uint32_t HostQueueLen(HostQueue *q) { +uint32_t HostQueueLen(HostQueue *q) +{ uint32_t len; HQLOCK_LOCK(q); len = q->len; diff --git a/src/host-storage.c b/src/host-storage.c index a895538c4c..6748089cd7 100644 --- a/src/host-storage.c +++ b/src/host-storage.c @@ -27,27 +27,33 @@ #include "host-storage.h" #include "util-unittest.h" -unsigned int HostStorageSize(void) { +unsigned int HostStorageSize(void) +{ return StorageGetSize(STORAGE_HOST); } -void *HostGetStorageById(Host *h, int id) { +void *HostGetStorageById(Host *h, int id) +{ return StorageGetById((Storage *)((void *)h + sizeof(Host)), STORAGE_HOST, id); } -int HostSetStorageById(Host *h, int id, void *ptr) { +int HostSetStorageById(Host *h, int id, void *ptr) +{ return StorageSetById((Storage *)((void *)h + sizeof(Host)), STORAGE_HOST, id, ptr); } -void *HostAllocStorageById(Host *h, int id) { +void *HostAllocStorageById(Host *h, int id) +{ return StorageAllocByIdPrealloc((Storage *)((void *)h + sizeof(Host)), STORAGE_HOST, id); } -void HostFreeStorageById(Host *h, int id) { +void HostFreeStorageById(Host *h, int id) +{ StorageFreeById((Storage *)((void *)h + sizeof(Host)), STORAGE_HOST, id); } -void HostFreeStorage(Host *h) { +void HostFreeStorage(Host *h) +{ if (HostStorageSize() > 0) StorageFreeAll((Storage *)((void *)h + sizeof(Host)), STORAGE_HOST); } @@ -58,16 +64,19 @@ int HostStorageRegister(const char *name, const unsigned int size, void *(*Alloc #ifdef UNITTESTS -static void *StorageTestAlloc(unsigned int size) { +static void *StorageTestAlloc(unsigned int size) +{ void *x = SCMalloc(size); return x; } -static void StorageTestFree(void *x) { +static void StorageTestFree(void *x) +{ if (x) SCFree(x); } -static int HostStorageTest01(void) { +static int HostStorageTest01(void) +{ StorageInit(); int id1 = HostStorageRegister("test", 8, StorageTestAlloc, StorageTestFree); @@ -145,7 +154,8 @@ error: return 0; } -static int HostStorageTest02(void) { +static int HostStorageTest02(void) +{ StorageInit(); int id1 = HostStorageRegister("test", sizeof(void *), NULL, StorageTestFree); @@ -194,7 +204,8 @@ error: return 0; } -static int HostStorageTest03(void) { +static int HostStorageTest03(void) +{ StorageInit(); int id1 = HostStorageRegister("test1", sizeof(void *), NULL, StorageTestFree); @@ -269,7 +280,8 @@ error: } #endif -void RegisterHostStorageTests(void) { +void RegisterHostStorageTests(void) +{ #ifdef UNITTESTS UtRegisterTest("HostStorageTest01", HostStorageTest01, 1); UtRegisterTest("HostStorageTest02", HostStorageTest02, 1); diff --git a/src/host-timeout.c b/src/host-timeout.c index 1d7e0866f0..a8b08b8d85 100644 --- a/src/host-timeout.c +++ b/src/host-timeout.c @@ -28,11 +28,13 @@ #include "detect-engine-threshold.h" #include "reputation.h" -uint32_t HostGetSpareCount(void) { +uint32_t HostGetSpareCount(void) +{ return HostSpareQueueGetSize(); } -uint32_t HostGetActiveCount(void) { +uint32_t HostGetActiveCount(void) +{ return SC_ATOMIC_GET(host_counter); } @@ -45,7 +47,8 @@ uint32_t HostGetActiveCount(void) { * \retval 0 not timed out just yet * \retval 1 fully timed out, lets kill it */ -static int HostHostTimedOut(Host *h, struct timeval *ts) { +static int HostHostTimedOut(Host *h, struct timeval *ts) +{ int tags = 0; int thresholds = 0; @@ -142,7 +145,8 @@ static uint32_t HostHashRowTimeout(HostHashRow *hb, Host *h, struct timeval *ts) * * \retval cnt number of timed out host */ -uint32_t HostTimeoutHash(struct timeval *ts) { +uint32_t HostTimeoutHash(struct timeval *ts) +{ uint32_t idx = 0; uint32_t cnt = 0; diff --git a/src/host.c b/src/host.c index bd96c43850..c3831c757e 100644 --- a/src/host.c +++ b/src/host.c @@ -47,16 +47,19 @@ static Host *HostGetUsedHost(void); /** queue with spare hosts */ static HostQueue host_spare_q; -uint32_t HostSpareQueueGetSize(void) { +uint32_t HostSpareQueueGetSize(void) +{ return HostQueueLen(&host_spare_q); } -void HostMoveToSpare(Host *h) { +void HostMoveToSpare(Host *h) +{ HostEnqueue(&host_spare_q, h); (void) SC_ATOMIC_SUB(host_counter, 1); } -Host *HostAlloc(void) { +Host *HostAlloc(void) +{ size_t size = sizeof(Host) + HostStorageSize(); if (!(HOST_CHECK_MEMCAP(size))) { @@ -79,7 +82,8 @@ error: return NULL; } -void HostFree(Host *h) { +void HostFree(Host *h) +{ if (h != NULL) { HostClearMemory(h); @@ -90,7 +94,8 @@ void HostFree(Host *h) { } } -Host *HostNew(Address *a) { +Host *HostNew(Address *a) +{ Host *h = HostAlloc(); if (h == NULL) goto error; @@ -104,7 +109,8 @@ error: return NULL; } -void HostClearMemory(Host *h) { +void HostClearMemory(Host *h) +{ if (h->iprep != NULL) { SCFree(h->iprep); h->iprep = NULL; @@ -337,7 +343,8 @@ void HostCleanup(void) * hash_rand -- set at init time * source address */ -uint32_t HostGetKey(Address *a) { +uint32_t HostGetKey(Address *a) +{ uint32_t key; if (a->family == AF_INET) { @@ -357,7 +364,8 @@ uint32_t HostGetKey(Address *a) { #define CMP_HOST(h,a) \ (CMP_ADDR(&(h)->a, (a))) -static inline int HostCompare(Host *h, Address *a) { +static inline int HostCompare(Host *h, Address *a) +{ return CMP_HOST(h, a); } @@ -369,7 +377,8 @@ static inline int HostCompare(Host *h, Address *a) { * * \retval h *LOCKED* host on succes, NULL on error. */ -static Host *HostGetNew(Address *a) { +static Host *HostGetNew(Address *a) +{ Host *h = NULL; /* get a host from the spare queue */ @@ -413,17 +422,20 @@ static Host *HostGetNew(Address *a) { return h; } -void HostInit(Host *h, Address *a) { +void HostInit(Host *h, Address *a) +{ COPY_ADDRESS(a, &h->a); (void) HostIncrUsecnt(h); } -void HostRelease(Host *h) { +void HostRelease(Host *h) +{ (void) HostDecrUsecnt(h); SCMutexUnlock(&h->m); } -void HostLock(Host *h) { +void HostLock(Host *h) +{ SCMutexLock(&h->m); } @@ -608,7 +620,8 @@ Host *HostLookupHostFromHash (Address *a) * * \retval h host or NULL */ -static Host *HostGetUsedHost(void) { +static Host *HostGetUsedHost(void) +{ uint32_t idx = SC_ATOMIC_GET(host_prune_idx) % host_config.hash_size; uint32_t cnt = host_config.hash_size; @@ -665,7 +678,8 @@ static Host *HostGetUsedHost(void) { return NULL; } -void HostRegisterUnittests(void) { +void HostRegisterUnittests(void) +{ RegisterHostStorageTests(); } diff --git a/src/log-dnslog.c b/src/log-dnslog.c index 913bed93d4..7d226e8b8a 100644 --- a/src/log-dnslog.c +++ b/src/log-dnslog.c @@ -71,7 +71,8 @@ typedef struct LogDnsLogThread_ { MemBuffer *buffer; } LogDnsLogThread; -static void LogQuery(LogDnsLogThread *aft, char *timebuf, char *srcip, char *dstip, Port sp, Port dp, DNSTransaction *tx, DNSQueryEntry *entry) { +static void LogQuery(LogDnsLogThread *aft, char *timebuf, char *srcip, char *dstip, Port sp, Port dp, DNSTransaction *tx, DNSQueryEntry *entry) +{ LogDnsFileCtx *hlog = aft->dnslog_ctx; SCLogDebug("got a DNS request and now logging !!"); @@ -100,7 +101,8 @@ static void LogQuery(LogDnsLogThread *aft, char *timebuf, char *srcip, char *dst SCMutexUnlock(&hlog->file_ctx->fp_mutex); } -static void LogAnswer(LogDnsLogThread *aft, char *timebuf, char *srcip, char *dstip, Port sp, Port dp, DNSTransaction *tx, DNSAnswerEntry *entry) { +static void LogAnswer(LogDnsLogThread *aft, char *timebuf, char *srcip, char *dstip, Port sp, Port dp, DNSTransaction *tx, DNSAnswerEntry *entry) +{ LogDnsFileCtx *hlog = aft->dnslog_ctx; SCLogDebug("got a DNS response and now logging !!"); @@ -276,7 +278,8 @@ static TmEcode LogDnsLogThreadDeinit(ThreadVars *t, void *data) return TM_ECODE_OK; } -static void LogDnsLogExitPrintStats(ThreadVars *tv, void *data) { +static void LogDnsLogExitPrintStats(ThreadVars *tv, void *data) +{ LogDnsLogThread *aft = (LogDnsLogThread *)data; if (aft == NULL) { return; @@ -340,7 +343,8 @@ static OutputCtx *LogDnsLogInitCtx(ConfNode *conf) return output_ctx; } -void TmModuleLogDnsLogRegister (void) { +void TmModuleLogDnsLogRegister (void) +{ tmm_modules[TMM_LOGDNSLOG].name = MODULE_NAME; tmm_modules[TMM_LOGDNSLOG].ThreadInit = LogDnsLogThreadInit; tmm_modules[TMM_LOGDNSLOG].ThreadExitPrintStats = LogDnsLogExitPrintStats; diff --git a/src/log-droplog.c b/src/log-droplog.c index 74a81fb52c..34447ae217 100644 --- a/src/log-droplog.c +++ b/src/log-droplog.c @@ -278,7 +278,8 @@ static int LogDropLogNetFilter (ThreadVars *tv, const Packet *p, void *data) * * \retval bool TRUE or FALSE */ -static int LogDropCondition(ThreadVars *tv, const Packet *p) { +static int LogDropCondition(ThreadVars *tv, const Packet *p) +{ if (!EngineModeIsIPS()) { SCLogDebug("engine is not running in inline mode, so returning"); return FALSE; @@ -315,7 +316,8 @@ static int LogDropCondition(ThreadVars *tv, const Packet *p) { * * \retval 0 on succes */ -static int LogDropLogger(ThreadVars *tv, void *thread_data, const Packet *p) { +static int LogDropLogger(ThreadVars *tv, void *thread_data, const Packet *p) +{ int r = LogDropLogNetFilter(tv, p, thread_data); if (r < 0) @@ -334,7 +336,8 @@ static int LogDropLogger(ThreadVars *tv, void *thread_data, const Packet *p) { return 0; } -static void LogDropLogExitPrintStats(ThreadVars *tv, void *data) { +static void LogDropLogExitPrintStats(ThreadVars *tv, void *data) +{ LogDropLogThread *dlt = (LogDropLogThread *)data; if (dlt == NULL) { return; @@ -498,7 +501,8 @@ static void LogDropLogRegisterTests(void) #endif /** \brief function to register the drop log module */ -void TmModuleLogDropLogRegister (void) { +void TmModuleLogDropLogRegister (void) +{ tmm_modules[TMM_LOGDROPLOG].name = MODULE_NAME; tmm_modules[TMM_LOGDROPLOG].ThreadInit = LogDropLogThreadInit; diff --git a/src/log-file.c b/src/log-file.c index 688edff369..8cb7a662bb 100644 --- a/src/log-file.c +++ b/src/log-file.c @@ -68,7 +68,8 @@ typedef struct LogFileLogThread_ { uint32_t file_cnt; } LogFileLogThread; -static void LogFileMetaGetUri(FILE *fp, const Packet *p, const File *ff) { +static void LogFileMetaGetUri(FILE *fp, const Packet *p, const File *ff) +{ HtpState *htp_state = (HtpState *)p->flow->alstate; if (htp_state != NULL) { htp_tx_t *tx = AppLayerParserGetTx(IPPROTO_TCP, ALPROTO_HTTP, htp_state, ff->txid); @@ -88,7 +89,8 @@ static void LogFileMetaGetUri(FILE *fp, const Packet *p, const File *ff) { fprintf(fp, ""); } -static void LogFileMetaGetHost(FILE *fp, const Packet *p, const File *ff) { +static void LogFileMetaGetHost(FILE *fp, const Packet *p, const File *ff) +{ HtpState *htp_state = (HtpState *)p->flow->alstate; if (htp_state != NULL) { htp_tx_t *tx = AppLayerParserGetTx(IPPROTO_TCP, ALPROTO_HTTP, htp_state, ff->txid); @@ -102,7 +104,8 @@ static void LogFileMetaGetHost(FILE *fp, const Packet *p, const File *ff) { fprintf(fp, ""); } -static void LogFileMetaGetReferer(FILE *fp, const Packet *p, const File *ff) { +static void LogFileMetaGetReferer(FILE *fp, const Packet *p, const File *ff) +{ HtpState *htp_state = (HtpState *)p->flow->alstate; if (htp_state != NULL) { htp_tx_t *tx = AppLayerParserGetTx(IPPROTO_TCP, ALPROTO_HTTP, htp_state, ff->txid); @@ -121,7 +124,8 @@ static void LogFileMetaGetReferer(FILE *fp, const Packet *p, const File *ff) { fprintf(fp, ""); } -static void LogFileMetaGetUserAgent(FILE *fp, const Packet *p, const File *ff) { +static void LogFileMetaGetUserAgent(FILE *fp, const Packet *p, const File *ff) +{ HtpState *htp_state = (HtpState *)p->flow->alstate; if (htp_state != NULL) { htp_tx_t *tx = AppLayerParserGetTx(IPPROTO_TCP, ALPROTO_HTTP, htp_state, ff->txid); @@ -144,7 +148,8 @@ static void LogFileMetaGetUserAgent(FILE *fp, const Packet *p, const File *ff) { * \internal * \brief Write meta data on a single line json record */ -static void LogFileWriteJsonRecord(LogFileLogThread *aft, const Packet *p, const File *ff, int ipver) { +static void LogFileWriteJsonRecord(LogFileLogThread *aft, const Packet *p, const File *ff, int ipver) +{ SCMutexLock(&aft->file_ctx->fp_mutex); /* As writes are done via the LogFileCtx, check for rotation here. */ @@ -330,7 +335,8 @@ TmEcode LogFileLogThreadDeinit(ThreadVars *t, void *data) return TM_ECODE_OK; } -void LogFileLogExitPrintStats(ThreadVars *tv, void *data) { +void LogFileLogExitPrintStats(ThreadVars *tv, void *data) +{ LogFileLogThread *aft = (LogFileLogThread *)data; if (aft == NULL) { return; @@ -410,7 +416,8 @@ int LogFileLogOpenFileCtx(LogFileCtx *file_ctx, const char *filename, const return 0; } -void TmModuleLogFileLogRegister (void) { +void TmModuleLogFileLogRegister (void) +{ tmm_modules[TMM_FILELOG].name = MODULE_NAME; tmm_modules[TMM_FILELOG].ThreadInit = LogFileLogThreadInit; tmm_modules[TMM_FILELOG].Func = NULL; diff --git a/src/log-filestore.c b/src/log-filestore.c index d6b3863a59..989b51dee5 100644 --- a/src/log-filestore.c +++ b/src/log-filestore.c @@ -66,7 +66,8 @@ typedef struct LogFilestoreLogThread_ { uint32_t file_cnt; } LogFilestoreLogThread; -static void LogFilestoreMetaGetUri(FILE *fp, const Packet *p, const File *ff) { +static void LogFilestoreMetaGetUri(FILE *fp, const Packet *p, const File *ff) +{ HtpState *htp_state = (HtpState *)p->flow->alstate; if (htp_state != NULL) { htp_tx_t *tx = AppLayerParserGetTx(IPPROTO_TCP, ALPROTO_HTTP, htp_state, ff->txid); @@ -83,7 +84,8 @@ static void LogFilestoreMetaGetUri(FILE *fp, const Packet *p, const File *ff) { fprintf(fp, ""); } -static void LogFilestoreMetaGetHost(FILE *fp, const Packet *p, const File *ff) { +static void LogFilestoreMetaGetHost(FILE *fp, const Packet *p, const File *ff) +{ HtpState *htp_state = (HtpState *)p->flow->alstate; if (htp_state != NULL) { htp_tx_t *tx = AppLayerParserGetTx(IPPROTO_TCP, ALPROTO_HTTP, htp_state, ff->txid); @@ -97,7 +99,8 @@ static void LogFilestoreMetaGetHost(FILE *fp, const Packet *p, const File *ff) { fprintf(fp, ""); } -static void LogFilestoreMetaGetReferer(FILE *fp, const Packet *p, const File *ff) { +static void LogFilestoreMetaGetReferer(FILE *fp, const Packet *p, const File *ff) +{ HtpState *htp_state = (HtpState *)p->flow->alstate; if (htp_state != NULL) { htp_tx_t *tx = AppLayerParserGetTx(IPPROTO_TCP, ALPROTO_HTTP, htp_state, ff->txid); @@ -116,7 +119,8 @@ static void LogFilestoreMetaGetReferer(FILE *fp, const Packet *p, const File *ff fprintf(fp, ""); } -static void LogFilestoreMetaGetUserAgent(FILE *fp, const Packet *p, const File *ff) { +static void LogFilestoreMetaGetUserAgent(FILE *fp, const Packet *p, const File *ff) +{ HtpState *htp_state = (HtpState *)p->flow->alstate; if (htp_state != NULL) { htp_tx_t *tx = AppLayerParserGetTx(IPPROTO_TCP, ALPROTO_HTTP, htp_state, ff->txid); @@ -135,7 +139,8 @@ static void LogFilestoreMetaGetUserAgent(FILE *fp, const Packet *p, const File * fprintf(fp, ""); } -static void LogFilestoreLogCreateMetaFile(const Packet *p, const File *ff, const char *filename, int ipver) { +static void LogFilestoreLogCreateMetaFile(const Packet *p, const File *ff, const char *filename, int ipver) +{ char metafilename[PATH_MAX] = ""; snprintf(metafilename, sizeof(metafilename), "%s.meta", filename); FILE *fp = fopen(metafilename, "w+"); @@ -195,7 +200,8 @@ static void LogFilestoreLogCreateMetaFile(const Packet *p, const File *ff, const } } -static void LogFilestoreLogCloseMetaFile(const File *ff) { +static void LogFilestoreLogCloseMetaFile(const File *ff) +{ char filename[PATH_MAX] = ""; snprintf(filename, sizeof(filename), "%s/file.%u", g_logfile_base_dir, ff->file_id); @@ -353,7 +359,8 @@ static TmEcode LogFilestoreLogThreadDeinit(ThreadVars *t, void *data) return TM_ECODE_OK; } -static void LogFilestoreLogExitPrintStats(ThreadVars *tv, void *data) { +static void LogFilestoreLogExitPrintStats(ThreadVars *tv, void *data) +{ LogFilestoreLogThread *aft = (LogFilestoreLogThread *)data; if (aft == NULL) { return; @@ -434,7 +441,8 @@ static OutputCtx *LogFilestoreLogInitCtx(ConfNode *conf) SCReturnPtr(output_ctx, "OutputCtx"); } -void TmModuleLogFilestoreRegister (void) { +void TmModuleLogFilestoreRegister (void) +{ tmm_modules[TMM_FILESTORE].name = MODULE_NAME; tmm_modules[TMM_FILESTORE].ThreadInit = LogFilestoreLogThreadInit; tmm_modules[TMM_FILESTORE].Func = NULL; diff --git a/src/log-httplog.c b/src/log-httplog.c index bbff5470c3..609157808b 100644 --- a/src/log-httplog.c +++ b/src/log-httplog.c @@ -63,7 +63,8 @@ static void LogHttpLogDeInitCtx(OutputCtx *); int LogHttpLogger(ThreadVars *tv, void *thread_data, const Packet *, Flow *f, void *state, void *tx, uint64_t tx_id); -void TmModuleLogHttpLogRegister (void) { +void TmModuleLogHttpLogRegister (void) +{ tmm_modules[TMM_LOGHTTPLOG].name = MODULE_NAME; tmm_modules[TMM_LOGHTTPLOG].ThreadInit = LogHttpLogThreadInit; tmm_modules[TMM_LOGHTTPLOG].ThreadExitPrintStats = LogHttpLogExitPrintStats; @@ -128,7 +129,8 @@ typedef struct LogHttpLogThread_ { /* Retrieves the selected cookie value */ static uint32_t GetCookieValue(uint8_t *rawcookies, uint32_t rawcookies_len, char *cookiename, - uint8_t **cookievalue) { + uint8_t **cookievalue) +{ uint8_t *p = rawcookies; uint8_t *cn = p; /* ptr to cookie name start */ uint8_t *cv = NULL; /* ptr to cookie value start */ @@ -573,7 +575,8 @@ TmEcode LogHttpLogThreadDeinit(ThreadVars *t, void *data) return TM_ECODE_OK; } -void LogHttpLogExitPrintStats(ThreadVars *tv, void *data) { +void LogHttpLogExitPrintStats(ThreadVars *tv, void *data) +{ LogHttpLogThread *aft = (LogHttpLogThread *)data; if (aft == NULL) { return; diff --git a/src/log-pcap.c b/src/log-pcap.c index bc27414670..87f654d46f 100644 --- a/src/log-pcap.c +++ b/src/log-pcap.c @@ -277,7 +277,8 @@ static int PcapLogRotateFile(ThreadVars *t, PcapLogData *pl) return 0; } -static int PcapLogOpenHandles(PcapLogData *pl, Packet *p) { +static int PcapLogOpenHandles(PcapLogData *pl, Packet *p) +{ PCAPLOG_PROFILE_START; SCLogDebug("Setting pcap-log link type to %u", p->datalink); @@ -1029,7 +1030,8 @@ static int profiling_pcaplog_output_to_file = 0; static char *profiling_pcaplog_file_name = NULL; static char *profiling_pcaplog_file_mode = "a"; -static void FormatNumber(uint64_t num, char *str, size_t size) { +static void FormatNumber(uint64_t num, char *str, size_t size) +{ if (num < 1000UL) snprintf(str, size, "%"PRIu64, num); else if (num < 1000000UL) @@ -1040,7 +1042,8 @@ static void FormatNumber(uint64_t num, char *str, size_t size) { snprintf(str, size, "%3.1fb", (float)num/1000000000UL); } -static void ProfileReportPair(FILE *fp, const char *name, PcapLogProfileData *p) { +static void ProfileReportPair(FILE *fp, const char *name, PcapLogProfileData *p) +{ char ticks_str[32] = "n/a"; char cnt_str[32] = "n/a"; char avg_str[32] = "n/a"; @@ -1053,7 +1056,8 @@ static void ProfileReportPair(FILE *fp, const char *name, PcapLogProfileData *p) fprintf(fp, "%-28s %-10s %-10s %-10s\n", name, cnt_str, avg_str, ticks_str); } -static void ProfileReport(FILE *fp, PcapLogData *pl) { +static void ProfileReport(FILE *fp, PcapLogData *pl) +{ ProfileReportPair(fp, "open", &pl->profile_open); ProfileReportPair(fp, "close", &pl->profile_close); ProfileReportPair(fp, "write", &pl->profile_write); @@ -1063,7 +1067,8 @@ static void ProfileReport(FILE *fp, PcapLogData *pl) { ProfileReportPair(fp, "unlock", &pl->profile_unlock); } -static void FormatBytes(uint64_t num, char *str, size_t size) { +static void FormatBytes(uint64_t num, char *str, size_t size) +{ if (num < 1000UL) snprintf(str, size, "%"PRIu64, num); else if (num < 1048576UL) @@ -1074,7 +1079,8 @@ static void FormatBytes(uint64_t num, char *str, size_t size) { snprintf(str, size, "%3.1fGiB", (float)num/1000000000UL); } -static void PcapLogProfilingDump(PcapLogData *pl) { +static void PcapLogProfilingDump(PcapLogData *pl) +{ FILE *fp = NULL; if (profiling_pcaplog_enabled == 0) @@ -1134,7 +1140,8 @@ static void PcapLogProfilingDump(PcapLogData *pl) { fclose(fp); } -void PcapLogProfileSetup(void) { +void PcapLogProfileSetup(void) +{ ConfNode *conf = ConfGetNode("profiling.pcap-log"); if (conf != NULL && ConfNodeChildValueIsTrue(conf, "enabled")) { profiling_pcaplog_enabled = 1; diff --git a/src/log-tlslog.c b/src/log-tlslog.c index f45ca28934..580b0a2022 100644 --- a/src/log-tlslog.c +++ b/src/log-tlslog.c @@ -479,7 +479,8 @@ filectx_error: * \brief Condition function for TLS logger * \retval bool true or false -- log now? */ -static int LogTlsCondition(ThreadVars *tv, const Packet *p) { +static int LogTlsCondition(ThreadVars *tv, const Packet *p) +{ if (p->flow == NULL) { return FALSE; } @@ -518,7 +519,8 @@ dontlog: return FALSE; } -static int LogTlsLogger(ThreadVars *tv, void *thread_data, const Packet *p) { +static int LogTlsLogger(ThreadVars *tv, void *thread_data, const Packet *p) +{ LogTlsLogThread *aft = (LogTlsLogThread *)thread_data; LogTlsFileCtx *hlog = aft->tlslog_ctx; char timebuf[64]; diff --git a/src/output-file.c b/src/output-file.c index 0a99b06038..0f1e852106 100644 --- a/src/output-file.c +++ b/src/output-file.c @@ -84,7 +84,8 @@ int OutputRegisterFileLogger(const char *name, FileLogger LogFunc, OutputCtx *ou return 0; } -static TmEcode OutputFileLog(ThreadVars *tv, Packet *p, void *thread_data, PacketQueue *pq, PacketQueue *postpq) { +static TmEcode OutputFileLog(ThreadVars *tv, Packet *p, void *thread_data, PacketQueue *pq, PacketQueue *postpq) +{ BUG_ON(thread_data == NULL); BUG_ON(list == NULL); @@ -176,7 +177,8 @@ static TmEcode OutputFileLog(ThreadVars *tv, Packet *p, void *thread_data, Packe /** \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, void *initdata, void **data) +{ OutputLoggerThreadData *td = SCMalloc(sizeof(*td)); if (td == NULL) return TM_ECODE_FAILED; @@ -224,7 +226,8 @@ static TmEcode OutputFileLogThreadInit(ThreadVars *tv, void *initdata, void **da return TM_ECODE_OK; } -static TmEcode OutputFileLogThreadDeinit(ThreadVars *tv, void *thread_data) { +static TmEcode OutputFileLogThreadDeinit(ThreadVars *tv, void *thread_data) +{ OutputLoggerThreadData *op_thread_data = (OutputLoggerThreadData *)thread_data; OutputLoggerThreadStore *store = op_thread_data->store; OutputFileLogger *logger = list; @@ -249,7 +252,8 @@ static TmEcode OutputFileLogThreadDeinit(ThreadVars *tv, void *thread_data) { return TM_ECODE_OK; } -static void OutputFileLogExitPrintStats(ThreadVars *tv, void *thread_data) { +static void OutputFileLogExitPrintStats(ThreadVars *tv, void *thread_data) +{ OutputLoggerThreadData *op_thread_data = (OutputLoggerThreadData *)thread_data; OutputLoggerThreadStore *store = op_thread_data->store; OutputFileLogger *logger = list; @@ -271,7 +275,8 @@ static void OutputFileLogExitPrintStats(ThreadVars *tv, void *thread_data) { } } -void TmModuleFileLoggerRegister (void) { +void TmModuleFileLoggerRegister (void) +{ tmm_modules[TMM_FILELOGGER].name = "__file_logger__"; tmm_modules[TMM_FILELOGGER].ThreadInit = OutputFileLogThreadInit; tmm_modules[TMM_FILELOGGER].Func = OutputFileLog; diff --git a/src/output-filedata.c b/src/output-filedata.c index 946b601f79..cd624437a0 100644 --- a/src/output-filedata.c +++ b/src/output-filedata.c @@ -91,7 +91,8 @@ int OutputRegisterFiledataLogger(const char *name, FiledataLogger LogFunc, Outpu SC_ATOMIC_DECLARE(unsigned int, file_id); -static TmEcode OutputFiledataLog(ThreadVars *tv, Packet *p, void *thread_data, PacketQueue *pq, PacketQueue *postpq) { +static TmEcode OutputFiledataLog(ThreadVars *tv, Packet *p, void *thread_data, PacketQueue *pq, PacketQueue *postpq) +{ BUG_ON(thread_data == NULL); BUG_ON(list == NULL); @@ -233,7 +234,8 @@ static TmEcode OutputFiledataLog(ThreadVars *tv, Packet *p, void *thread_data, P * * \param path full path for the waldo file */ -static void LogFiledataLogLoadWaldo(const char *path) { +static void LogFiledataLogLoadWaldo(const char *path) +{ char line[16] = ""; unsigned int id = 0; @@ -259,7 +261,8 @@ static void LogFiledataLogLoadWaldo(const char *path) { * * \param path full path for the waldo file */ -static void LogFiledataLogStoreWaldo(const char *path) { +static void LogFiledataLogStoreWaldo(const char *path) +{ char line[16] = ""; if (SC_ATOMIC_GET(file_id) == 0) { @@ -282,7 +285,8 @@ 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, void *initdata, void **data) +{ OutputLoggerThreadData *td = SCMalloc(sizeof(*td)); if (td == NULL) return TM_ECODE_FAILED; @@ -379,7 +383,8 @@ static TmEcode OutputFiledataLogThreadInit(ThreadVars *tv, void *initdata, void return TM_ECODE_OK; } -static TmEcode OutputFiledataLogThreadDeinit(ThreadVars *tv, void *thread_data) { +static TmEcode OutputFiledataLogThreadDeinit(ThreadVars *tv, void *thread_data) +{ OutputLoggerThreadData *op_thread_data = (OutputLoggerThreadData *)thread_data; OutputLoggerThreadStore *store = op_thread_data->store; OutputFiledataLogger *logger = list; @@ -414,7 +419,8 @@ static TmEcode OutputFiledataLogThreadDeinit(ThreadVars *tv, void *thread_data) return TM_ECODE_OK; } -static void OutputFiledataLogExitPrintStats(ThreadVars *tv, void *thread_data) { +static void OutputFiledataLogExitPrintStats(ThreadVars *tv, void *thread_data) +{ OutputLoggerThreadData *op_thread_data = (OutputLoggerThreadData *)thread_data; OutputLoggerThreadStore *store = op_thread_data->store; OutputFiledataLogger *logger = list; @@ -436,7 +442,8 @@ static void OutputFiledataLogExitPrintStats(ThreadVars *tv, void *thread_data) { } } -void TmModuleFiledataLoggerRegister (void) { +void TmModuleFiledataLoggerRegister (void) +{ tmm_modules[TMM_FILEDATALOGGER].name = "__filedata_logger__"; tmm_modules[TMM_FILEDATALOGGER].ThreadInit = OutputFiledataLogThreadInit; tmm_modules[TMM_FILEDATALOGGER].Func = OutputFiledataLog; diff --git a/src/output-flow.c b/src/output-flow.c index 9364ca5e02..20d5d7d423 100644 --- a/src/output-flow.c +++ b/src/output-flow.c @@ -84,7 +84,8 @@ int OutputRegisterFlowLogger(const char *name, FlowLogger LogFunc, OutputCtx *ou /** \brief Run flow logger(s) * \note flow is already write locked */ -TmEcode OutputFlowLog(ThreadVars *tv, void *thread_data, Flow *f) { +TmEcode OutputFlowLog(ThreadVars *tv, void *thread_data, Flow *f) +{ BUG_ON(thread_data == NULL); if (list == NULL) @@ -122,7 +123,8 @@ TmEcode OutputFlowLog(ThreadVars *tv, void *thread_data, Flow *f) { /** \brief thread init for the flow logger * This will run the thread init functions for the individual registered * loggers */ -TmEcode OutputFlowLogThreadInit(ThreadVars *tv, void *initdata, void **data) { +TmEcode OutputFlowLogThreadInit(ThreadVars *tv, void *initdata, void **data) +{ OutputLoggerThreadData *td = SCMalloc(sizeof(*td)); if (td == NULL) return TM_ECODE_FAILED; @@ -170,7 +172,8 @@ TmEcode OutputFlowLogThreadInit(ThreadVars *tv, void *initdata, void **data) { return TM_ECODE_OK; } -TmEcode OutputFlowLogThreadDeinit(ThreadVars *tv, void *thread_data) { +TmEcode OutputFlowLogThreadDeinit(ThreadVars *tv, void *thread_data) +{ OutputLoggerThreadData *op_thread_data = (OutputLoggerThreadData *)thread_data; OutputLoggerThreadStore *store = op_thread_data->store; OutputFlowLogger *logger = list; @@ -197,7 +200,8 @@ TmEcode OutputFlowLogThreadDeinit(ThreadVars *tv, void *thread_data) { return TM_ECODE_OK; } -void OutputFlowLogExitPrintStats(ThreadVars *tv, void *thread_data) { +void OutputFlowLogExitPrintStats(ThreadVars *tv, void *thread_data) +{ OutputLoggerThreadData *op_thread_data = (OutputLoggerThreadData *)thread_data; OutputLoggerThreadStore *store = op_thread_data->store; OutputFlowLogger *logger = list; diff --git a/src/output-json-alert.c b/src/output-json-alert.c index 58bdad36a7..f7b6ba9015 100644 --- a/src/output-json-alert.c +++ b/src/output-json-alert.c @@ -436,7 +436,8 @@ static OutputCtx *JsonAlertLogInitCtxSub(ConfNode *conf, OutputCtx *parent_ctx) return output_ctx; } -void TmModuleJsonAlertLogRegister (void) { +void TmModuleJsonAlertLogRegister (void) +{ tmm_modules[TMM_JSONALERTLOG].name = MODULE_NAME; tmm_modules[TMM_JSONALERTLOG].ThreadInit = JsonAlertLogThreadInit; tmm_modules[TMM_JSONALERTLOG].ThreadDeinit = JsonAlertLogThreadDeinit; diff --git a/src/output-json-dns.c b/src/output-json-dns.c index 71d8adb820..44494dbc09 100644 --- a/src/output-json-dns.c +++ b/src/output-json-dns.c @@ -113,7 +113,8 @@ static void LogQuery(LogDnsLogThread *aft, json_t *js, DNSTransaction *tx, json_object_del(js, "dns"); } -static void OutputAnswer(LogDnsLogThread *aft, json_t *djs, DNSTransaction *tx, DNSAnswerEntry *entry) { +static void OutputAnswer(LogDnsLogThread *aft, json_t *djs, DNSTransaction *tx, DNSAnswerEntry *entry) +{ MemBuffer *buffer = (MemBuffer *)aft->buffer; json_t *js = json_object(); if (js == NULL) @@ -179,7 +180,8 @@ static void OutputAnswer(LogDnsLogThread *aft, json_t *djs, DNSTransaction *tx, return; } -static void LogAnswers(LogDnsLogThread *aft, json_t *js, DNSTransaction *tx, uint64_t tx_id) { +static void LogAnswers(LogDnsLogThread *aft, json_t *js, DNSTransaction *tx, uint64_t tx_id) +{ SCLogDebug("got a DNS response and now logging !!"); @@ -365,7 +367,8 @@ static OutputCtx *JsonDnsLogInitCtx(ConfNode *conf) #define MODULE_NAME "JsonDnsLog" -void TmModuleJsonDnsLogRegister (void) { +void TmModuleJsonDnsLogRegister (void) +{ tmm_modules[TMM_JSONDNSLOG].name = MODULE_NAME; tmm_modules[TMM_JSONDNSLOG].ThreadInit = LogDnsLogThreadInit; tmm_modules[TMM_JSONDNSLOG].ThreadDeinit = LogDnsLogThreadDeinit; diff --git a/src/output-json-drop.c b/src/output-json-drop.c index cea1d9865b..19a4f07119 100644 --- a/src/output-json-drop.c +++ b/src/output-json-drop.c @@ -288,7 +288,8 @@ static int JsonDropLogger(ThreadVars *tv, void *thread_data, const Packet *p) * * \retval bool TRUE or FALSE */ -static int JsonDropLogCondition(ThreadVars *tv, const Packet *p) { +static int JsonDropLogCondition(ThreadVars *tv, const Packet *p) +{ if (!EngineModeIsIPS()) { SCLogDebug("engine is not running in inline mode, so returning"); return FALSE; @@ -316,7 +317,8 @@ static int JsonDropLogCondition(ThreadVars *tv, const Packet *p) { return FALSE; } -void TmModuleJsonDropLogRegister (void) { +void TmModuleJsonDropLogRegister (void) +{ tmm_modules[TMM_JSONDROPLOG].name = MODULE_NAME; tmm_modules[TMM_JSONDROPLOG].ThreadInit = JsonDropLogThreadInit; tmm_modules[TMM_JSONDROPLOG].ThreadDeinit = JsonDropLogThreadDeinit; diff --git a/src/output-json-file.c b/src/output-json-file.c index e56ef579d5..aacb60c6c1 100644 --- a/src/output-json-file.c +++ b/src/output-json-file.c @@ -74,7 +74,8 @@ typedef struct JsonFileLogThread_ { MemBuffer *buffer; } JsonFileLogThread; -static json_t *LogFileMetaGetUri(const Packet *p, const File *ff) { +static json_t *LogFileMetaGetUri(const Packet *p, const File *ff) +{ HtpState *htp_state = (HtpState *)p->flow->alstate; json_t *js = NULL; if (htp_state != NULL) { @@ -96,7 +97,8 @@ static json_t *LogFileMetaGetUri(const Packet *p, const File *ff) { return NULL; } -static json_t *LogFileMetaGetHost(const Packet *p, const File *ff) { +static json_t *LogFileMetaGetHost(const Packet *p, const File *ff) +{ HtpState *htp_state = (HtpState *)p->flow->alstate; json_t *js = NULL; if (htp_state != NULL) { @@ -115,7 +117,8 @@ static json_t *LogFileMetaGetHost(const Packet *p, const File *ff) { return NULL; } -static json_t *LogFileMetaGetReferer(const Packet *p, const File *ff) { +static json_t *LogFileMetaGetReferer(const Packet *p, const File *ff) +{ HtpState *htp_state = (HtpState *)p->flow->alstate; json_t *js = NULL; if (htp_state != NULL) { @@ -139,7 +142,8 @@ static json_t *LogFileMetaGetReferer(const Packet *p, const File *ff) { return NULL; } -static json_t *LogFileMetaGetUserAgent(const Packet *p, const File *ff) { +static json_t *LogFileMetaGetUserAgent(const Packet *p, const File *ff) +{ HtpState *htp_state = (HtpState *)p->flow->alstate; json_t *js = NULL; if (htp_state != NULL) { @@ -167,7 +171,8 @@ static json_t *LogFileMetaGetUserAgent(const Packet *p, const File *ff) { * \internal * \brief Write meta data on a single line json record */ -static void FileWriteJsonRecord(JsonFileLogThread *aft, const Packet *p, const File *ff) { +static void FileWriteJsonRecord(JsonFileLogThread *aft, const Packet *p, const File *ff) +{ MemBuffer *buffer = (MemBuffer *)aft->buffer; json_t *js = CreateJSONHeader((Packet *)p, 0, "fileinfo"); //TODO const if (unlikely(js == NULL)) @@ -353,7 +358,8 @@ OutputCtx *OutputFileLogInitSub(ConfNode *conf, OutputCtx *parent_ctx) return output_ctx; } -void TmModuleJsonFileLogRegister (void) { +void TmModuleJsonFileLogRegister (void) +{ tmm_modules[TMM_JSONFILELOG].name = "JsonFileLog"; tmm_modules[TMM_JSONFILELOG].ThreadInit = JsonFileLogThreadInit; tmm_modules[TMM_JSONFILELOG].ThreadDeinit = JsonFileLogThreadDeinit; diff --git a/src/output-json-flow.c b/src/output-json-flow.c index 107e4ffe89..100d9979b7 100644 --- a/src/output-json-flow.c +++ b/src/output-json-flow.c @@ -448,7 +448,8 @@ static TmEcode JsonFlowLogThreadDeinit(ThreadVars *t, void *data) return TM_ECODE_OK; } -void TmModuleJsonFlowLogRegister (void) { +void TmModuleJsonFlowLogRegister (void) +{ tmm_modules[TMM_JSONFLOWLOG].name = "JsonFlowLog"; tmm_modules[TMM_JSONFLOWLOG].ThreadInit = JsonFlowLogThreadInit; tmm_modules[TMM_JSONFLOWLOG].ThreadDeinit = JsonFlowLogThreadDeinit; diff --git a/src/output-json-http.c b/src/output-json-http.c index 827cff89d7..2746672b83 100644 --- a/src/output-json-http.c +++ b/src/output-json-http.c @@ -548,7 +548,8 @@ static TmEcode JsonHttpLogThreadDeinit(ThreadVars *t, void *data) return TM_ECODE_OK; } -void TmModuleJsonHttpLogRegister (void) { +void TmModuleJsonHttpLogRegister (void) +{ tmm_modules[TMM_JSONHTTPLOG].name = "JsonHttpLog"; tmm_modules[TMM_JSONHTTPLOG].ThreadInit = JsonHttpLogThreadInit; tmm_modules[TMM_JSONHTTPLOG].ThreadDeinit = JsonHttpLogThreadDeinit; diff --git a/src/output-json-netflow.c b/src/output-json-netflow.c index a7d54c8b9d..3a1b57d0f7 100644 --- a/src/output-json-netflow.c +++ b/src/output-json-netflow.c @@ -432,7 +432,8 @@ static TmEcode JsonNetFlowLogThreadDeinit(ThreadVars *t, void *data) return TM_ECODE_OK; } -void TmModuleJsonNetFlowLogRegister (void) { +void TmModuleJsonNetFlowLogRegister (void) +{ tmm_modules[TMM_JSONNETFLOWLOG].name = "JsonNetFlowLog"; tmm_modules[TMM_JSONNETFLOWLOG].ThreadInit = JsonNetFlowLogThreadInit; tmm_modules[TMM_JSONNETFLOWLOG].ThreadDeinit = JsonNetFlowLogThreadDeinit; diff --git a/src/output-json-ssh.c b/src/output-json-ssh.c index 43816eb866..0a6ea46230 100644 --- a/src/output-json-ssh.c +++ b/src/output-json-ssh.c @@ -65,7 +65,8 @@ typedef struct JsonSshLogThread_ { MemBuffer *buffer; } JsonSshLogThread; -static int JsonSshLogger(ThreadVars *tv, void *thread_data, const Packet *p) { +static int JsonSshLogger(ThreadVars *tv, void *thread_data, const Packet *p) +{ JsonSshLogThread *aft = (JsonSshLogThread *)thread_data; MemBuffer *buffer = (MemBuffer *)aft->buffer; OutputSshCtx *ssh_ctx = aft->sshlog_ctx; @@ -270,7 +271,8 @@ OutputCtx *OutputSshLogInitSub(ConfNode *conf, OutputCtx *parent_ctx) * \brief Condition function for SSH logger * \retval bool true or false -- log now? */ -static int JsonSshCondition(ThreadVars *tv, const Packet *p) { +static int JsonSshCondition(ThreadVars *tv, const Packet *p) +{ if (p->flow == NULL) { return FALSE; } @@ -307,7 +309,8 @@ dontlog: return FALSE; } -void TmModuleJsonSshLogRegister (void) { +void TmModuleJsonSshLogRegister (void) +{ tmm_modules[TMM_JSONSSHLOG].name = "JsonSshLog"; tmm_modules[TMM_JSONSSHLOG].ThreadInit = JsonSshLogThreadInit; tmm_modules[TMM_JSONSSHLOG].ThreadDeinit = JsonSshLogThreadDeinit; diff --git a/src/output-json-tls.c b/src/output-json-tls.c index 869f8fc38e..129b8177bf 100644 --- a/src/output-json-tls.c +++ b/src/output-json-tls.c @@ -108,7 +108,8 @@ static void LogTlsLogExtendedJSON(json_t *tjs, SSLState * state) json_object_set_new(tjs, "version", json_string(ssl_version)); } -static int JsonTlsLogger(ThreadVars *tv, void *thread_data, const Packet *p) { +static int JsonTlsLogger(ThreadVars *tv, void *thread_data, const Packet *p) +{ JsonTlsLogThread *aft = (JsonTlsLogThread *)thread_data; MemBuffer *buffer = (MemBuffer *)aft->buffer; OutputTlsCtx *tls_ctx = aft->tlslog_ctx; @@ -325,7 +326,8 @@ OutputCtx *OutputTlsLogInitSub(ConfNode *conf, OutputCtx *parent_ctx) * \brief Condition function for TLS logger * \retval bool true or false -- log now? */ -static int JsonTlsCondition(ThreadVars *tv, const Packet *p) { +static int JsonTlsCondition(ThreadVars *tv, const Packet *p) +{ if (p->flow == NULL) { return FALSE; } @@ -362,7 +364,8 @@ dontlog: return FALSE; } -void TmModuleJsonTlsLogRegister (void) { +void TmModuleJsonTlsLogRegister (void) +{ tmm_modules[TMM_JSONTLSLOG].name = "JsonTlsLog"; tmm_modules[TMM_JSONTLSLOG].ThreadInit = JsonTlsLogThreadInit; tmm_modules[TMM_JSONTLSLOG].ThreadDeinit = JsonTlsLogThreadDeinit; diff --git a/src/output-json.c b/src/output-json.c index 1c65e087ab..b37e9ad173 100644 --- a/src/output-json.c +++ b/src/output-json.c @@ -72,7 +72,8 @@ TmEcode OutputJsonThreadDeinit(ThreadVars *, void *); int OutputJsonOpenFileCtx(LogFileCtx *, char *); void OutputJsonRegisterTests(void); -void TmModuleOutputJsonRegister (void) { +void TmModuleOutputJsonRegister (void) +{ tmm_modules[TMM_OUTPUTJSON].name = "OutputJSON"; tmm_modules[TMM_OUTPUTJSON].ThreadInit = OutputJsonThreadInit; tmm_modules[TMM_OUTPUTJSON].Func = OutputJson; @@ -129,7 +130,8 @@ void OutputJsonExitPrintStats(ThreadVars *, void *); void OutputJsonRegisterTests(void); static void OutputJsonDeInitCtx(OutputCtx *); -void TmModuleOutputJsonRegister (void) { +void TmModuleOutputJsonRegister (void) +{ tmm_modules[TMM_OUTPUTJSON].name = MODULE_NAME; tmm_modules[TMM_OUTPUTJSON].ThreadInit = OutputJsonThreadInit; tmm_modules[TMM_OUTPUTJSON].Func = OutputJson; @@ -151,7 +153,8 @@ static enum JsonFormat format = COMPACT; /** \brief jsonify tcp flags field * Only add 'true' fields in an attempt to keep things reasonably compact. */ -void JsonTcpFlags(uint8_t flags, json_t *js) { +void JsonTcpFlags(uint8_t flags, json_t *js) +{ if (flags & TH_SYN) json_object_set_new(js, "syn", json_true()); if (flags & TH_FIN) @@ -328,7 +331,8 @@ json_t *CreateJSONHeader(Packet *p, int direction_sensitive, char *event_type) return js; } -int OutputJSONBuffer(json_t *js, LogFileCtx *file_ctx, MemBuffer *buffer) { +int OutputJSONBuffer(json_t *js, LogFileCtx *file_ctx, MemBuffer *buffer) +{ char *js_s = json_dumps(js, JSON_PRESERVE_ORDER|JSON_COMPACT|JSON_ENSURE_ASCII| #ifdef JSON_ESCAPE_SLASH @@ -387,7 +391,8 @@ TmEcode OutputJsonThreadDeinit(ThreadVars *t, void *data) return TM_ECODE_OK; } -void OutputJsonExitPrintStats(ThreadVars *tv, void *data) { +void OutputJsonExitPrintStats(ThreadVars *tv, void *data) +{ AlertJsonThread *aft = (AlertJsonThread *)data; if (aft == NULL) { return; diff --git a/src/output-packet.c b/src/output-packet.c index 3f96f8eb56..d2cd901c88 100644 --- a/src/output-packet.c +++ b/src/output-packet.c @@ -53,7 +53,8 @@ typedef struct OutputPacketLogger_ { static OutputPacketLogger *list = NULL; -int OutputRegisterPacketLogger(const char *name, PacketLogger LogFunc, PacketLogCondition ConditionFunc, OutputCtx *output_ctx) { +int OutputRegisterPacketLogger(const char *name, PacketLogger LogFunc, PacketLogCondition ConditionFunc, OutputCtx *output_ctx) +{ int module_id = TmModuleGetIdByName(name); if (module_id < 0) return -1; @@ -82,7 +83,8 @@ int OutputRegisterPacketLogger(const char *name, PacketLogger LogFunc, PacketLog return 0; } -static TmEcode OutputPacketLog(ThreadVars *tv, Packet *p, void *thread_data, PacketQueue *pq, PacketQueue *postpq) { +static TmEcode OutputPacketLog(ThreadVars *tv, Packet *p, void *thread_data, PacketQueue *pq, PacketQueue *postpq) +{ BUG_ON(thread_data == NULL); BUG_ON(list == NULL); @@ -116,7 +118,8 @@ static TmEcode OutputPacketLog(ThreadVars *tv, Packet *p, void *thread_data, Pac /** \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, void *initdata, void **data) +{ OutputLoggerThreadData *td = SCMalloc(sizeof(*td)); if (td == NULL) return TM_ECODE_FAILED; @@ -164,7 +167,8 @@ static TmEcode OutputPacketLogThreadInit(ThreadVars *tv, void *initdata, void ** return TM_ECODE_OK; } -static TmEcode OutputPacketLogThreadDeinit(ThreadVars *tv, void *thread_data) { +static TmEcode OutputPacketLogThreadDeinit(ThreadVars *tv, void *thread_data) +{ OutputLoggerThreadData *op_thread_data = (OutputLoggerThreadData *)thread_data; OutputLoggerThreadStore *store = op_thread_data->store; OutputPacketLogger *logger = list; @@ -190,7 +194,8 @@ static TmEcode OutputPacketLogThreadDeinit(ThreadVars *tv, void *thread_data) { return TM_ECODE_OK; } -static void OutputPacketLogExitPrintStats(ThreadVars *tv, void *thread_data) { +static void OutputPacketLogExitPrintStats(ThreadVars *tv, void *thread_data) +{ OutputLoggerThreadData *op_thread_data = (OutputLoggerThreadData *)thread_data; OutputLoggerThreadStore *store = op_thread_data->store; OutputPacketLogger *logger = list; @@ -212,7 +217,8 @@ static void OutputPacketLogExitPrintStats(ThreadVars *tv, void *thread_data) { } } -void TmModulePacketLoggerRegister (void) { +void TmModulePacketLoggerRegister (void) +{ tmm_modules[TMM_PACKETLOGGER].name = "__packet_logger__"; tmm_modules[TMM_PACKETLOGGER].ThreadInit = OutputPacketLogThreadInit; tmm_modules[TMM_PACKETLOGGER].Func = OutputPacketLog; diff --git a/src/output-tx.c b/src/output-tx.c index 06c20823c1..9bb7c277db 100644 --- a/src/output-tx.c +++ b/src/output-tx.c @@ -85,7 +85,8 @@ int OutputRegisterTxLogger(const char *name, AppProto alproto, TxLogger LogFunc, return 0; } -static TmEcode OutputTxLog(ThreadVars *tv, Packet *p, void *thread_data, PacketQueue *pq, PacketQueue *postpq) { +static TmEcode OutputTxLog(ThreadVars *tv, Packet *p, void *thread_data, PacketQueue *pq, PacketQueue *postpq) +{ BUG_ON(thread_data == NULL); BUG_ON(list == NULL); @@ -183,7 +184,8 @@ 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, void *initdata, void **data) +{ OutputLoggerThreadData *td = SCMalloc(sizeof(*td)); if (td == NULL) return TM_ECODE_FAILED; @@ -231,7 +233,8 @@ static TmEcode OutputTxLogThreadInit(ThreadVars *tv, void *initdata, void **data return TM_ECODE_OK; } -static TmEcode OutputTxLogThreadDeinit(ThreadVars *tv, void *thread_data) { +static TmEcode OutputTxLogThreadDeinit(ThreadVars *tv, void *thread_data) +{ OutputLoggerThreadData *op_thread_data = (OutputLoggerThreadData *)thread_data; OutputLoggerThreadStore *store = op_thread_data->store; OutputTxLogger *logger = list; @@ -256,7 +259,8 @@ static TmEcode OutputTxLogThreadDeinit(ThreadVars *tv, void *thread_data) { return TM_ECODE_OK; } -static void OutputTxLogExitPrintStats(ThreadVars *tv, void *thread_data) { +static void OutputTxLogExitPrintStats(ThreadVars *tv, void *thread_data) +{ OutputLoggerThreadData *op_thread_data = (OutputLoggerThreadData *)thread_data; OutputLoggerThreadStore *store = op_thread_data->store; OutputTxLogger *logger = list; @@ -278,7 +282,8 @@ static void OutputTxLogExitPrintStats(ThreadVars *tv, void *thread_data) { } } -void TmModuleTxLoggerRegister (void) { +void TmModuleTxLoggerRegister (void) +{ tmm_modules[TMM_TXLOGGER].name = "__tx_logger__"; tmm_modules[TMM_TXLOGGER].ThreadInit = OutputTxLogThreadInit; tmm_modules[TMM_TXLOGGER].Func = OutputTxLog; diff --git a/src/output.c b/src/output.c index ebf2dda6ef..986ddce678 100644 --- a/src/output.c +++ b/src/output.c @@ -459,42 +459,48 @@ OutputDeregisterAll(void) static int drop_loggers = 0; -int OutputDropLoggerEnable(void) { +int OutputDropLoggerEnable(void) +{ if (drop_loggers) return -1; drop_loggers++; return 0; } -void OutputDropLoggerDisable(void) { +void OutputDropLoggerDisable(void) +{ if (drop_loggers) drop_loggers--; } static int tls_loggers = 0; -int OutputTlsLoggerEnable(void) { +int OutputTlsLoggerEnable(void) +{ if (tls_loggers) return -1; tls_loggers++; return 0; } -void OutputTlsLoggerDisable(void) { +void OutputTlsLoggerDisable(void) +{ if (tls_loggers) tls_loggers--; } static int ssh_loggers = 0; -int OutputSshLoggerEnable(void) { +int OutputSshLoggerEnable(void) +{ if (ssh_loggers) return -1; ssh_loggers++; return 0; } -void OutputSshLoggerDisable(void) { +void OutputSshLoggerDisable(void) +{ if (ssh_loggers) ssh_loggers--; } @@ -505,7 +511,8 @@ void OutputSshLoggerDisable(void) { * \param flag A pointer that will be set to 1 when file rotation is * requested. */ -void OutputRegisterFileRotationFlag(int *flag) { +void OutputRegisterFileRotationFlag(int *flag) +{ OutputFileRolloverFlag *flag_entry = SCCalloc(1, sizeof(*flag_entry)); if (unlikely(flag_entry == NULL)) { SCLogError(SC_ERR_MEM_ALLOC, @@ -526,10 +533,12 @@ void OutputRegisterFileRotationFlag(int *flag) { * \param flag A pointer that has been previously registered for file * rotation notifications. */ -void OutputUnregisterFileRotationFlag(int *flag) { +void OutputUnregisterFileRotationFlag(int *flag) +{ OutputFileRolloverFlag *entry, *next; for (entry = TAILQ_FIRST(&output_file_rotation_flags); entry != NULL; - entry = next) { + entry = next) +{ next = TAILQ_NEXT(entry, entries); if (entry->flag == flag) { TAILQ_REMOVE(&output_file_rotation_flags, entry, entries); diff --git a/src/packet-queue.c b/src/packet-queue.c index 0963916756..c500971bd1 100644 --- a/src/packet-queue.c +++ b/src/packet-queue.c @@ -32,7 +32,8 @@ #include "pkt-var.h" #ifdef DEBUG -void PacketQueueValidateDebug(PacketQueue *q) { +void PacketQueueValidateDebug(PacketQueue *q) +{ SCLogDebug("q->len %u, q->top %p, q->bot %p", q->len, q->top, q->bot); if (q->len == 0) { @@ -90,7 +91,8 @@ void PacketQueueValidateDebug(PacketQueue *q) { } \ } -void PacketQueueValidate(PacketQueue *q) { +void PacketQueueValidate(PacketQueue *q) +{ if (q->len == 0) { BUGGER_ON(q->top != NULL); BUGGER_ON(q->bot != NULL); @@ -131,7 +133,8 @@ void PacketQueueValidate(PacketQueue *q) { } #endif /* DEBUG */ -void PacketEnqueue (PacketQueue *q, Packet *p) { +void PacketEnqueue (PacketQueue *q, Packet *p) +{ //PacketQueueValidateDebug(q); if (p == NULL) @@ -158,7 +161,8 @@ void PacketEnqueue (PacketQueue *q, Packet *p) { //PacketQueueValidateDebug(q); } -Packet *PacketDequeue (PacketQueue *q) { +Packet *PacketDequeue (PacketQueue *q) +{ Packet *p = NULL; //PacketQueueValidateDebug(q); diff --git a/src/pkt-var.c b/src/pkt-var.c index d4e48526c4..b3878bde04 100644 --- a/src/pkt-var.c +++ b/src/pkt-var.c @@ -35,7 +35,8 @@ #include "util-debug.h" /* puts a new value into a pktvar */ -void PktVarUpdate(PktVar *pv, uint8_t *value, uint16_t size) { +void PktVarUpdate(PktVar *pv, uint8_t *value, uint16_t size) +{ if (pv->value) SCFree(pv->value); pv->value = value; pv->value_len = size; @@ -44,7 +45,8 @@ void PktVarUpdate(PktVar *pv, uint8_t *value, uint16_t size) { /* get the pktvar with name 'name' from the pkt * * name is a normal string*/ -PktVar *PktVarGet(Packet *p, char *name) { +PktVar *PktVarGet(Packet *p, char *name) +{ PktVar *pv = p->pktvar; for (;pv != NULL; pv = pv->next) { @@ -56,7 +58,8 @@ PktVar *PktVarGet(Packet *p, char *name) { } /* add a pktvar to the pkt, or update it */ -void PktVarAdd(Packet *p, char *name, uint8_t *value, uint16_t size) { +void PktVarAdd(Packet *p, char *name, uint8_t *value, uint16_t size) +{ //printf("Adding packet var \"%s\" with value(%" PRId32 ") \"%s\"\n", name, size, value); PktVar *pv = PktVarGet(p, name); @@ -86,7 +89,8 @@ void PktVarAdd(Packet *p, char *name, uint8_t *value, uint16_t size) { } } -void PktVarFree(PktVar *pv) { +void PktVarFree(PktVar *pv) +{ if (pv == NULL) return; @@ -101,7 +105,8 @@ void PktVarFree(PktVar *pv) { PktVarFree(pv_next); } -void PktVarPrint(PktVar *pv) { +void PktVarPrint(PktVar *pv) +{ uint16_t i; if (pv == NULL) diff --git a/src/reputation.c b/src/reputation.c index c9c0d1d563..f84c1a8808 100644 --- a/src/reputation.c +++ b/src/reputation.c @@ -47,28 +47,33 @@ SC_ATOMIC_DECLARE(uint32_t, srep_eversion); * so hosts will always have a minial value of 1 */ static uint32_t srep_version = 0; -static uint32_t SRepIncrVersion(void) { +static uint32_t SRepIncrVersion(void) +{ return ++srep_version; } -static uint32_t SRepGetVersion(void) { +static uint32_t SRepGetVersion(void) +{ return srep_version; } -static uint32_t SRepGetEffectiveVersion(void) { +static uint32_t SRepGetEffectiveVersion(void) +{ return SC_ATOMIC_GET(srep_eversion); } /** \brief Increment effective reputation version after * a rule/reputatio reload is complete. */ -void SRepReloadComplete(void) { +void SRepReloadComplete(void) +{ (void) SC_ATOMIC_ADD(srep_eversion, 1); SCLogDebug("effective Reputation version %u", SRepGetEffectiveVersion()); } /** \brief Set effective reputation version after * reputation initialization is complete. */ -void SRepInitComplete(void) { +void SRepInitComplete(void) +{ (void) SC_ATOMIC_SET(srep_eversion, 1); SCLogDebug("effective Reputation version %u", SRepGetEffectiveVersion()); } @@ -83,7 +88,8 @@ void SRepInitComplete(void) { * \retval 0 not timed out * \retval 1 timed out */ -int SRepHostTimedOut(Host *h) { +int SRepHostTimedOut(Host *h) +{ BUG_ON(h == NULL); if (h->iprep == NULL) @@ -105,7 +111,8 @@ int SRepHostTimedOut(Host *h) { return 0; } -static int SRepCatSplitLine(char *line, uint8_t *cat, char *shortname, size_t shortname_len) { +static int SRepCatSplitLine(char *line, uint8_t *cat, char *shortname, size_t shortname_len) +{ size_t line_len = strlen(line); char *ptrs[2] = {NULL,NULL}; int i = 0; @@ -155,7 +162,8 @@ static int SRepCatSplitLine(char *line, uint8_t *cat, char *shortname, size_t sh * \retval 1 header * \retval -1 boo */ -static int SRepSplitLine(char *line, uint32_t *ip, uint8_t *cat, uint8_t *value) { +static int SRepSplitLine(char *line, uint32_t *ip, uint8_t *cat, uint8_t *value) +{ size_t line_len = strlen(line); char *ptrs[3] = {NULL,NULL,NULL}; int i = 0; @@ -216,7 +224,8 @@ static int SRepSplitLine(char *line, uint32_t *ip, uint8_t *cat, uint8_t *value) #define SREP_SHORTNAME_LEN 32 static char srep_cat_table[SREP_MAX_CATS][SREP_SHORTNAME_LEN]; -int SRepCatValid(uint8_t cat) { +int SRepCatValid(uint8_t cat) +{ if (cat >= SREP_MAX_CATS) return 0; @@ -226,7 +235,8 @@ int SRepCatValid(uint8_t cat) { return 1; } -uint8_t SRepCatGetByShortname(char *shortname) { +uint8_t SRepCatGetByShortname(char *shortname) +{ uint8_t cat; for (cat = 0; cat < SREP_MAX_CATS; cat++) { if (strcmp(srep_cat_table[cat], shortname) == 0) @@ -236,7 +246,8 @@ uint8_t SRepCatGetByShortname(char *shortname) { return 0; } -int SRepLoadCatFile(char *filename) { +int SRepLoadCatFile(char *filename) +{ char line[8192] = ""; Address a; memset(&a, 0x00, sizeof(a)); @@ -292,7 +303,8 @@ int SRepLoadCatFile(char *filename) { return 0; } -static int SRepLoadFile(char *filename) { +static int SRepLoadFile(char *filename) +{ char line[8192] = ""; Address a; memset(&a, 0x00, sizeof(a)); @@ -439,7 +451,8 @@ static char *SRepCompleteFilePath(char *file) * If this function is called more than once, the category file * is not reloaded. */ -int SRepInit(DetectEngineCtx *de_ctx) { +int SRepInit(DetectEngineCtx *de_ctx) +{ ConfNode *files; ConfNode *file = NULL; int r = 0; @@ -510,7 +523,8 @@ int SRepInit(DetectEngineCtx *de_ctx) { } #ifdef UNITTESTS -static int SRepTest01(void) { +static int SRepTest01(void) +{ char str[] = "1.2.3.4,1,2"; uint32_t ip = 0; @@ -534,7 +548,8 @@ static int SRepTest01(void) { return 1; } -static int SRepTest02(void) { +static int SRepTest02(void) +{ char str[] = "1.1.1.1,"; uint32_t ip = 0; @@ -545,7 +560,8 @@ static int SRepTest02(void) { return 1; } -static int SRepTest03(void) { +static int SRepTest03(void) +{ char str[] = "1,Shortname,Long Name"; uint8_t cat = 0; @@ -581,7 +597,8 @@ IPReputationCtx *rep_ctx; * \retval Pointer to the IPReputationCtx created * NULL Error initializing moule; */ -IPReputationCtx *SCReputationInitCtx(void) { +IPReputationCtx *SCReputationInitCtx(void) +{ rep_ctx = (IPReputationCtx *)SCMalloc(sizeof(IPReputationCtx)); if (rep_ctx == NULL) return NULL; @@ -684,7 +701,8 @@ void SCReputationTransactionFreeData(void *data) * \param rep_data pointer to the reputation to update * \param rtx pointer to the transaction data */ -void SCReputationApplyTransaction(Reputation *rep_data, ReputationTransaction *rtx) { +void SCReputationApplyTransaction(Reputation *rep_data, ReputationTransaction *rtx) +{ int i = 0; /* No modification needed */ diff --git a/src/runmode-napatech.c b/src/runmode-napatech.c index a395d8bc04..e064bb1674 100644 --- a/src/runmode-napatech.c +++ b/src/runmode-napatech.c @@ -159,7 +159,8 @@ int NapatechRegisterDeviceStreams() return 0; } -void *NapatechConfigParser(const char *device) { +void *NapatechConfigParser(const char *device) +{ // Expect device to be of the form nt%d where %d is the stream id to use int dev_len = strlen(device); struct NapatechStreamDevConf *conf = SCMalloc(sizeof(struct NapatechStreamDevConf)); @@ -188,7 +189,8 @@ int NapatechGetThreadsCount(void *conf __attribute__((unused))) { return 1; } -int NapatechInit(DetectEngineCtx *de_ctx, int runmode) { +int NapatechInit(DetectEngineCtx *de_ctx, int runmode) +{ int ret; char errbuf[100]; @@ -235,15 +237,18 @@ int NapatechInit(DetectEngineCtx *de_ctx, int runmode) { return 0; } -int RunModeNapatechAuto(DetectEngineCtx *de_ctx) { +int RunModeNapatechAuto(DetectEngineCtx *de_ctx) +{ return NapatechInit(de_ctx, NT_RUNMODE_AUTO); } -int RunModeNapatechAutoFp(DetectEngineCtx *de_ctx) { +int RunModeNapatechAutoFp(DetectEngineCtx *de_ctx) +{ return NapatechInit(de_ctx, NT_RUNMODE_AUTOFP); } -int RunModeNapatechWorkers(DetectEngineCtx *de_ctx) { +int RunModeNapatechWorkers(DetectEngineCtx *de_ctx) +{ return NapatechInit(de_ctx, NT_RUNMODE_WORKERS); } diff --git a/src/source-af-packet.c b/src/source-af-packet.c index d6971ffa40..f5858ac522 100644 --- a/src/source-af-packet.c +++ b/src/source-af-packet.c @@ -103,7 +103,8 @@ extern int max_pending_packets; TmEcode NoAFPSupportExit(ThreadVars *, void *, void **); -void TmModuleReceiveAFPRegister (void) { +void TmModuleReceiveAFPRegister (void) +{ tmm_modules[TMM_RECEIVEAFP].name = "ReceiveAFP"; tmm_modules[TMM_RECEIVEAFP].ThreadInit = NoAFPSupportExit; tmm_modules[TMM_RECEIVEAFP].Func = NULL; @@ -118,7 +119,8 @@ void TmModuleReceiveAFPRegister (void) { * \brief Registration Function for DecodeAFP. * \todo Unit tests are needed for this module. */ -void TmModuleDecodeAFPRegister (void) { +void TmModuleDecodeAFPRegister (void) +{ tmm_modules[TMM_DECODEAFP].name = "DecodeAFP"; tmm_modules[TMM_DECODEAFP].ThreadInit = NoAFPSupportExit; tmm_modules[TMM_DECODEAFP].Func = NULL; @@ -264,7 +266,8 @@ static int AFPRefSocket(AFPPeer* peer); * \brief Registration Function for RecieveAFP. * \todo Unit tests are needed for this module. */ -void TmModuleReceiveAFPRegister (void) { +void TmModuleReceiveAFPRegister (void) +{ tmm_modules[TMM_RECEIVEAFP].name = "ReceiveAFP"; tmm_modules[TMM_RECEIVEAFP].ThreadInit = ReceiveAFPThreadInit; tmm_modules[TMM_RECEIVEAFP].Func = NULL; @@ -484,7 +487,8 @@ void AFPPeersListClean() * \brief Registration Function for DecodeAFP. * \todo Unit tests are needed for this module. */ -void TmModuleDecodeAFPRegister (void) { +void TmModuleDecodeAFPRegister (void) +{ tmm_modules[TMM_DECODEAFP].name = "DecodeAFP"; tmm_modules[TMM_DECODEAFP].ThreadInit = DecodeAFPThreadInit; tmm_modules[TMM_DECODEAFP].Func = DecodeAFP; @@ -1653,7 +1657,8 @@ TmEcode AFPSetBPFFilter(AFPThreadVars *ptv) * * \todo Create a general AFP setup function. */ -TmEcode ReceiveAFPThreadInit(ThreadVars *tv, void *initdata, void **data) { +TmEcode ReceiveAFPThreadInit(ThreadVars *tv, void *initdata, void **data) +{ SCEnter(); AFPIfaceConfig *afpconfig = initdata; @@ -1789,7 +1794,8 @@ TmEcode ReceiveAFPThreadInit(ThreadVars *tv, void *initdata, void **data) { * \param tv pointer to ThreadVars * \param data pointer that gets cast into AFPThreadVars for ptv */ -void ReceiveAFPThreadExitStats(ThreadVars *tv, void *data) { +void ReceiveAFPThreadExitStats(ThreadVars *tv, void *data) +{ SCEnter(); AFPThreadVars *ptv = (AFPThreadVars *)data; @@ -1809,7 +1815,8 @@ void ReceiveAFPThreadExitStats(ThreadVars *tv, void *data) { * \param tv pointer to ThreadVars * \param data pointer that gets cast into AFPThreadVars for ptv */ -TmEcode ReceiveAFPThreadDeinit(ThreadVars *tv, void *data) { +TmEcode ReceiveAFPThreadDeinit(ThreadVars *tv, void *data) +{ AFPThreadVars *ptv = (AFPThreadVars *)data; AFPSwitchState(ptv, AFP_STATE_DOWN); diff --git a/src/source-ipfw.c b/src/source-ipfw.c index 6bd50e06e9..53bb03f289 100644 --- a/src/source-ipfw.c +++ b/src/source-ipfw.c @@ -56,7 +56,8 @@ TmEcode NoIPFWSupportExit(ThreadVars *, void *, void **); -void TmModuleReceiveIPFWRegister (void) { +void TmModuleReceiveIPFWRegister (void) +{ tmm_modules[TMM_RECEIVEIPFW].name = "ReceiveIPFW"; tmm_modules[TMM_RECEIVEIPFW].ThreadInit = NoIPFWSupportExit; @@ -67,7 +68,8 @@ void TmModuleReceiveIPFWRegister (void) { tmm_modules[TMM_RECEIVEIPFW].flags = TM_FLAG_RECEIVE_TM; } -void TmModuleVerdictIPFWRegister (void) { +void TmModuleVerdictIPFWRegister (void) +{ tmm_modules[TMM_VERDICTIPFW].name = "VerdictIPFW"; tmm_modules[TMM_VERDICTIPFW].ThreadInit = NoIPFWSupportExit; tmm_modules[TMM_VERDICTIPFW].Func = NULL; @@ -76,7 +78,8 @@ void TmModuleVerdictIPFWRegister (void) { tmm_modules[TMM_VERDICTIPFW].RegisterTests = NULL; } -void TmModuleDecodeIPFWRegister (void) { +void TmModuleDecodeIPFWRegister (void) +{ tmm_modules[TMM_DECODEIPFW].name = "DecodeIPFW"; tmm_modules[TMM_DECODEIPFW].ThreadInit = NoIPFWSupportExit; tmm_modules[TMM_DECODEIPFW].Func = NULL; @@ -87,7 +90,8 @@ void TmModuleDecodeIPFWRegister (void) { tmm_modules[TMM_DECODEIPFW].flags = TM_FLAG_DECODE_TM; } -TmEcode NoIPFWSupportExit(ThreadVars *tv, void *initdata, void **data) { +TmEcode NoIPFWSupportExit(ThreadVars *tv, void *initdata, void **data) +{ SCLogError(SC_ERR_IPFW_NOSUPPORT,"Error creating thread %s: you do not have support for ipfw " "enabled please recompile with --enable-ipfw", tv->name); @@ -146,7 +150,8 @@ TmEcode DecodeIPFW(ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *) * \brief Registration Function for RecieveIPFW. * \todo Unit tests are needed for this module. */ -void TmModuleReceiveIPFWRegister (void) { +void TmModuleReceiveIPFWRegister (void) +{ SCMutexInit(&ipfw_init_lock, NULL); tmm_modules[TMM_RECEIVEIPFW].name = "ReceiveIPFW"; @@ -166,7 +171,8 @@ void TmModuleReceiveIPFWRegister (void) { * \brief Registration Function for VerdictIPFW. * \todo Unit tests are needed for this module. */ -void TmModuleVerdictIPFWRegister (void) { +void TmModuleVerdictIPFWRegister (void) +{ tmm_modules[TMM_VERDICTIPFW].name = "VerdictIPFW"; tmm_modules[TMM_VERDICTIPFW].ThreadInit = VerdictIPFWThreadInit; tmm_modules[TMM_VERDICTIPFW].Func = VerdictIPFW; @@ -181,7 +187,8 @@ void TmModuleVerdictIPFWRegister (void) { * \brief Registration Function for DecodeIPFW. * \todo Unit tests are needed for this module. */ -void TmModuleDecodeIPFWRegister (void) { +void TmModuleDecodeIPFWRegister (void) +{ tmm_modules[TMM_DECODEIPFW].name = "DecodeIPFW"; tmm_modules[TMM_DECODEIPFW].ThreadInit = DecodeIPFWThreadInit; tmm_modules[TMM_DECODEIPFW].Func = DecodeIPFW; @@ -760,7 +767,8 @@ int IPFWRegisterQueue(char *queue) * \retval ptr pointer to the IPFWThreadVars at index * \retval NULL on error */ -void *IPFWGetQueue(int number) { +void *IPFWGetQueue(int number) +{ if (number >= receive_port_num) return NULL; @@ -777,7 +785,8 @@ void *IPFWGetQueue(int number) { * \retval ptr pointer to the IPFWThreadVars at index * \retval NULL on error */ -void *IPFWGetThread(int number) { +void *IPFWGetThread(int number) +{ if (number >= receive_port_num) return NULL; diff --git a/src/source-napatech.c b/src/source-napatech.c index 36604bacf7..18abd3aa6d 100644 --- a/src/source-napatech.c +++ b/src/source-napatech.c @@ -42,7 +42,8 @@ TmEcode NoNapatechSupportExit(ThreadVars *, void *, void **); -void TmModuleNapatechStreamRegister (void) { +void TmModuleNapatechStreamRegister (void) +{ tmm_modules[TMM_RECEIVENAPATECH].name = "NapatechStream"; tmm_modules[TMM_RECEIVENAPATECH].ThreadInit = NoNapatechSupportExit; tmm_modules[TMM_RECEIVENAPATECH].Func = NULL; @@ -52,7 +53,8 @@ void TmModuleNapatechStreamRegister (void) { tmm_modules[TMM_RECEIVENAPATECH].cap_flags = SC_CAP_NET_ADMIN; } -void TmModuleNapatechDecodeRegister (void) { +void TmModuleNapatechDecodeRegister (void) +{ tmm_modules[TMM_DECODENAPATECH].name = "NapatechDecode"; tmm_modules[TMM_DECODENAPATECH].ThreadInit = NoNapatechSupportExit; tmm_modules[TMM_DECODENAPATECH].Func = NULL; diff --git a/src/source-nflog.c b/src/source-nflog.c index 0ef06f8f7a..f7a36fa16a 100644 --- a/src/source-nflog.c +++ b/src/source-nflog.c @@ -45,12 +45,14 @@ TmEcode NoNFLOGSupportExit(ThreadVars *, void *, void **); -void TmModuleReceiveNFLOGRegister (void) { +void TmModuleReceiveNFLOGRegister (void) +{ tmm_modules[TMM_RECEIVENFLOG].name = "ReceiveNFLOG"; tmm_modules[TMM_RECEIVENFLOG].ThreadInit = NoNFLOGSupportExit; } -void TmModuleDecodeNFLOGRegister (void) { +void TmModuleDecodeNFLOGRegister (void) +{ tmm_modules[TMM_DECODENFLOG].name = "DecodeNFLOG"; tmm_modules[TMM_DECODENFLOG].ThreadInit = NoNFLOGSupportExit; } diff --git a/src/source-nfq.c b/src/source-nfq.c index 629df23d47..91834bb4d3 100644 --- a/src/source-nfq.c +++ b/src/source-nfq.c @@ -62,7 +62,8 @@ TmEcode NoNFQSupportExit(ThreadVars *, void *, void **); -void TmModuleReceiveNFQRegister (void) { +void TmModuleReceiveNFQRegister (void) +{ tmm_modules[TMM_RECEIVENFQ].name = "ReceiveNFQ"; tmm_modules[TMM_RECEIVENFQ].ThreadInit = NoNFQSupportExit; tmm_modules[TMM_RECEIVENFQ].Func = NULL; @@ -73,7 +74,8 @@ void TmModuleReceiveNFQRegister (void) { tmm_modules[TMM_RECEIVENFQ].flags = TM_FLAG_RECEIVE_TM; } -void TmModuleVerdictNFQRegister (void) { +void TmModuleVerdictNFQRegister (void) +{ tmm_modules[TMM_VERDICTNFQ].name = "VerdictNFQ"; tmm_modules[TMM_VERDICTNFQ].ThreadInit = NoNFQSupportExit; tmm_modules[TMM_VERDICTNFQ].Func = NULL; @@ -83,7 +85,8 @@ void TmModuleVerdictNFQRegister (void) { tmm_modules[TMM_VERDICTNFQ].cap_flags = SC_CAP_NET_ADMIN; } -void TmModuleDecodeNFQRegister (void) { +void TmModuleDecodeNFQRegister (void) +{ tmm_modules[TMM_DECODENFQ].name = "DecodeNFQ"; tmm_modules[TMM_DECODENFQ].ThreadInit = NoNFQSupportExit; tmm_modules[TMM_DECODENFQ].Func = NULL; @@ -171,7 +174,8 @@ typedef struct NFQCnf_ { NFQCnf nfq_config; -void TmModuleReceiveNFQRegister (void) { +void TmModuleReceiveNFQRegister (void) +{ /* XXX create a general NFQ setup function */ memset(&nfq_g, 0, sizeof(nfq_g)); SCMutexInit(&nfq_init_lock, NULL); @@ -186,7 +190,8 @@ void TmModuleReceiveNFQRegister (void) { tmm_modules[TMM_RECEIVENFQ].flags = TM_FLAG_RECEIVE_TM; } -void TmModuleVerdictNFQRegister (void) { +void TmModuleVerdictNFQRegister (void) +{ tmm_modules[TMM_VERDICTNFQ].name = "VerdictNFQ"; tmm_modules[TMM_VERDICTNFQ].ThreadInit = VerdictNFQThreadInit; tmm_modules[TMM_VERDICTNFQ].Func = VerdictNFQ; @@ -195,7 +200,8 @@ void TmModuleVerdictNFQRegister (void) { tmm_modules[TMM_VERDICTNFQ].RegisterTests = NULL; } -void TmModuleDecodeNFQRegister (void) { +void TmModuleDecodeNFQRegister (void) +{ tmm_modules[TMM_DECODENFQ].name = "DecodeNFQ"; tmm_modules[TMM_DECODENFQ].ThreadInit = DecodeNFQThreadInit; tmm_modules[TMM_DECODENFQ].Func = DecodeNFQ; @@ -685,7 +691,8 @@ TmEcode NFQInitThread(NFQThreadVars *nfq_t, uint32_t queue_maxlen) return TM_ECODE_OK; } -TmEcode ReceiveNFQThreadInit(ThreadVars *tv, void *initdata, void **data) { +TmEcode ReceiveNFQThreadInit(ThreadVars *tv, void *initdata, void **data) +{ SCMutexLock(&nfq_init_lock); #ifndef OS_WIN32 @@ -746,14 +753,16 @@ TmEcode ReceiveNFQThreadDeinit(ThreadVars *t, void *data) } -TmEcode VerdictNFQThreadInit(ThreadVars *tv, void *initdata, void **data) { +TmEcode VerdictNFQThreadInit(ThreadVars *tv, void *initdata, void **data) +{ *data = (void *)initdata; return TM_ECODE_OK; } -TmEcode VerdictNFQThreadDeinit(ThreadVars *tv, void *data) { +TmEcode VerdictNFQThreadDeinit(ThreadVars *tv, void *data) +{ NFQThreadVars *ntv = (NFQThreadVars *)data; NFQQueueVars *nq = NFQGetQueue(ntv->nfq_index); @@ -825,7 +834,8 @@ int NFQRegisterQueue(char *queue) * \retval ptr pointer to the NFQThreadVars at index * \retval NULL on error */ -void *NFQGetQueue(int number) { +void *NFQGetQueue(int number) +{ if (number >= receive_queue_num) return NULL; @@ -842,7 +852,8 @@ void *NFQGetQueue(int number) { * \retval ptr pointer to the NFQThreadVars at index * \retval NULL on error */ -void *NFQGetThread(int number) { +void *NFQGetThread(int number) +{ if (number >= receive_queue_num) return NULL; @@ -855,7 +866,8 @@ void *NFQGetThread(int number) { * \note separate functions for Linux and Win32 for readability. */ #ifndef OS_WIN32 -void NFQRecvPkt(NFQQueueVars *t, NFQThreadVars *tv) { +void NFQRecvPkt(NFQQueueVars *t, NFQThreadVars *tv) +{ int rv, ret; int flag = NFQVerdictCacheLen(t) ? MSG_DONTWAIT : 0; @@ -899,7 +911,8 @@ void NFQRecvPkt(NFQQueueVars *t, NFQThreadVars *tv) { } } #else /* WIN32 version of NFQRecvPkt */ -void NFQRecvPkt(NFQQueueVars *t, NFQThreadVars *tv) { +void NFQRecvPkt(NFQQueueVars *t, NFQThreadVars *tv) +{ int rv, ret; static int timeouted = 0; @@ -998,7 +1011,8 @@ TmEcode ReceiveNFQLoop(ThreadVars *tv, void *data, void *slot) /** * \brief NFQ receive module stats printing function */ -void ReceiveNFQThreadExitStats(ThreadVars *tv, void *data) { +void ReceiveNFQThreadExitStats(ThreadVars *tv, void *data) +{ NFQThreadVars *ntv = (NFQThreadVars *)data; NFQQueueVars *nq = NFQGetQueue(ntv->nfq_index); #ifdef COUNTERS @@ -1012,7 +1026,8 @@ void ReceiveNFQThreadExitStats(ThreadVars *tv, void *data) { /** * \brief NFQ verdict function */ -TmEcode NFQSetVerdict(Packet *p) { +TmEcode NFQSetVerdict(Packet *p) +{ int iter = 0; int ret = 0; uint32_t verdict = NF_ACCEPT; @@ -1152,7 +1167,8 @@ TmEcode NFQSetVerdict(Packet *p) { /** * \brief NFQ verdict module packet entry function */ -TmEcode VerdictNFQ(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, PacketQueue *postpq) { +TmEcode VerdictNFQ(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, PacketQueue *postpq) +{ int ret; /* if this is a tunnel packet we check if we are ready to verdict * already. */ diff --git a/src/source-pcap-file.c b/src/source-pcap-file.c index e780290d61..d4232bcebb 100644 --- a/src/source-pcap-file.c +++ b/src/source-pcap-file.c @@ -105,7 +105,8 @@ TmEcode DecodePcapFile(ThreadVars *, Packet *, void *, PacketQueue *, PacketQueu TmEcode DecodePcapFileThreadInit(ThreadVars *, void *, void **); TmEcode DecodePcapFileThreadDeinit(ThreadVars *tv, void *data); -void TmModuleReceivePcapFileRegister (void) { +void TmModuleReceivePcapFileRegister (void) +{ memset(&pcap_g, 0x00, sizeof(pcap_g)); tmm_modules[TMM_RECEIVEPCAPFILE].name = "ReceivePcapFile"; @@ -119,7 +120,8 @@ void TmModuleReceivePcapFileRegister (void) { tmm_modules[TMM_RECEIVEPCAPFILE].flags = TM_FLAG_RECEIVE_TM; } -void TmModuleDecodePcapFileRegister (void) { +void TmModuleDecodePcapFileRegister (void) +{ tmm_modules[TMM_DECODEPCAPFILE].name = "DecodePcapFile"; tmm_modules[TMM_DECODEPCAPFILE].ThreadInit = DecodePcapFileThreadInit; tmm_modules[TMM_DECODEPCAPFILE].Func = DecodePcapFile; @@ -130,7 +132,8 @@ void TmModuleDecodePcapFileRegister (void) { tmm_modules[TMM_DECODEPCAPFILE].flags = TM_FLAG_DECODE_TM; } -void PcapFileCallbackLoop(char *user, struct pcap_pkthdr *h, u_char *pkt) { +void PcapFileCallbackLoop(char *user, struct pcap_pkthdr *h, u_char *pkt) +{ SCEnter(); PcapFileThreadVars *ptv = (PcapFileThreadVars *)user; @@ -247,7 +250,8 @@ TmEcode ReceivePcapFileLoop(ThreadVars *tv, void *data, void *slot) SCReturnInt(TM_ECODE_OK); } -TmEcode ReceivePcapFileThreadInit(ThreadVars *tv, void *initdata, void **data) { +TmEcode ReceivePcapFileThreadInit(ThreadVars *tv, void *initdata, void **data) +{ SCEnter(); char *tmpbpfstring = NULL; char *tmpstring = NULL; @@ -344,7 +348,8 @@ TmEcode ReceivePcapFileThreadInit(ThreadVars *tv, void *initdata, void **data) { SCReturnInt(TM_ECODE_OK); } -void ReceivePcapFileThreadExitStats(ThreadVars *tv, void *data) { +void ReceivePcapFileThreadExitStats(ThreadVars *tv, void *data) +{ SCEnter(); PcapFileThreadVars *ptv = (PcapFileThreadVars *)data; @@ -366,7 +371,8 @@ void ReceivePcapFileThreadExitStats(ThreadVars *tv, void *data) { return; } -TmEcode ReceivePcapFileThreadDeinit(ThreadVars *tv, void *data) { +TmEcode ReceivePcapFileThreadDeinit(ThreadVars *tv, void *data) +{ SCEnter(); PcapFileThreadVars *ptv = (PcapFileThreadVars *)data; if (ptv) { diff --git a/src/source-pcap.c b/src/source-pcap.c index fcc4b05c72..0bc76b9ce7 100644 --- a/src/source-pcap.c +++ b/src/source-pcap.c @@ -124,7 +124,8 @@ static SCMutex pcap_bpf_compile_lock = SCMUTEX_INITIALIZER; * \brief Registration Function for RecievePcap. * \todo Unit tests are needed for this module. */ -void TmModuleReceivePcapRegister (void) { +void TmModuleReceivePcapRegister (void) +{ tmm_modules[TMM_RECEIVEPCAP].name = "ReceivePcap"; tmm_modules[TMM_RECEIVEPCAP].ThreadInit = ReceivePcapThreadInit; tmm_modules[TMM_RECEIVEPCAP].Func = NULL; @@ -140,7 +141,8 @@ void TmModuleReceivePcapRegister (void) { * \brief Registration Function for DecodePcap. * \todo Unit tests are needed for this module. */ -void TmModuleDecodePcapRegister (void) { +void TmModuleDecodePcapRegister (void) +{ tmm_modules[TMM_DECODEPCAP].name = "DecodePcap"; tmm_modules[TMM_DECODEPCAP].ThreadInit = DecodePcapThreadInit; tmm_modules[TMM_DECODEPCAP].Func = DecodePcap; @@ -227,7 +229,8 @@ static int PcapTryReopen(PcapThreadVars *ptv) #endif -void PcapCallbackLoop(char *user, struct pcap_pkthdr *h, u_char *pkt) { +void PcapCallbackLoop(char *user, struct pcap_pkthdr *h, u_char *pkt) +{ SCEnter(); PcapThreadVars *ptv = (PcapThreadVars *)user; @@ -363,7 +366,8 @@ TmEcode ReceivePcapLoop(ThreadVars *tv, void *data, void *slot) * \todo Create a general pcap setup function. */ #if LIBPCAP_VERSION_MAJOR == 1 -TmEcode ReceivePcapThreadInit(ThreadVars *tv, void *initdata, void **data) { +TmEcode ReceivePcapThreadInit(ThreadVars *tv, void *initdata, void **data) +{ SCEnter(); PcapIfaceConfig *pcapconfig = initdata; @@ -536,7 +540,8 @@ TmEcode ReceivePcapThreadInit(ThreadVars *tv, void *initdata, void **data) { SCReturnInt(TM_ECODE_OK); } #else /* implied LIBPCAP_VERSION_MAJOR == 0 */ -TmEcode ReceivePcapThreadInit(ThreadVars *tv, void *initdata, void **data) { +TmEcode ReceivePcapThreadInit(ThreadVars *tv, void *initdata, void **data) +{ SCEnter(); PcapIfaceConfig *pcapconfig = initdata; @@ -649,7 +654,8 @@ TmEcode ReceivePcapThreadInit(ThreadVars *tv, void *initdata, void **data) { * \param tv pointer to ThreadVars * \param data pointer that gets cast into PcapThreadVars for ptv */ -void ReceivePcapThreadExitStats(ThreadVars *tv, void *data) { +void ReceivePcapThreadExitStats(ThreadVars *tv, void *data) +{ SCEnter(); PcapThreadVars *ptv = (PcapThreadVars *)data; struct pcap_stat pcap_s; @@ -682,7 +688,8 @@ void ReceivePcapThreadExitStats(ThreadVars *tv, void *data) { * \param tv pointer to ThreadVars * \param data pointer that gets cast into PcapThreadVars for ptv */ -TmEcode ReceivePcapThreadDeinit(ThreadVars *tv, void *data) { +TmEcode ReceivePcapThreadDeinit(ThreadVars *tv, void *data) +{ PcapThreadVars *ptv = (PcapThreadVars *)data; pcap_close(ptv->pcap_handle); diff --git a/src/source-pfring.c b/src/source-pfring.c index 1c5084b5e4..bbf3275ed3 100644 --- a/src/source-pfring.c +++ b/src/source-pfring.c @@ -78,7 +78,8 @@ extern uint8_t suricata_ctl_flags; /*Handle cases where we don't have PF_RING support built-in*/ TmEcode NoPfringSupportExit(ThreadVars *, void *, void **); -void TmModuleReceivePfringRegister (void) { +void TmModuleReceivePfringRegister (void) +{ tmm_modules[TMM_RECEIVEPFRING].name = "ReceivePfring"; tmm_modules[TMM_RECEIVEPFRING].ThreadInit = NoPfringSupportExit; tmm_modules[TMM_RECEIVEPFRING].Func = NULL; @@ -90,7 +91,8 @@ void TmModuleReceivePfringRegister (void) { tmm_modules[TMM_RECEIVEPFRING].flags = TM_FLAG_RECEIVE_TM; } -void TmModuleDecodePfringRegister (void) { +void TmModuleDecodePfringRegister (void) +{ tmm_modules[TMM_DECODEPFRING].name = "DecodePfring"; tmm_modules[TMM_DECODEPFRING].ThreadInit = NoPfringSupportExit; tmm_modules[TMM_DECODEPFRING].Func = NULL; @@ -164,7 +166,8 @@ typedef struct PfringThreadVars_ * \brief Registration Function for RecievePfring. * \todo Unit tests are needed for this module. */ -void TmModuleReceivePfringRegister (void) { +void TmModuleReceivePfringRegister (void) +{ tmm_modules[TMM_RECEIVEPFRING].name = "ReceivePfring"; tmm_modules[TMM_RECEIVEPFRING].ThreadInit = ReceivePfringThreadInit; tmm_modules[TMM_RECEIVEPFRING].Func = NULL; @@ -179,7 +182,8 @@ void TmModuleReceivePfringRegister (void) { * \brief Registration Function for DecodePfring. * \todo Unit tests are needed for this module. */ -void TmModuleDecodePfringRegister (void) { +void TmModuleDecodePfringRegister (void) +{ tmm_modules[TMM_DECODEPFRING].name = "DecodePfring"; tmm_modules[TMM_DECODEPFRING].ThreadInit = DecodePfringThreadInit; tmm_modules[TMM_DECODEPFRING].Func = DecodePfring; @@ -218,7 +222,8 @@ static inline void PfringDumpCounters(PfringThreadVars *ptv) * \param h pointer to pfring packet header * \param p pointer to the current packet */ -static inline void PfringProcessPacket(void *user, struct pfring_pkthdr *h, Packet *p) { +static inline void PfringProcessPacket(void *user, struct pfring_pkthdr *h, Packet *p) +{ PfringThreadVars *ptv = (PfringThreadVars *)user; @@ -389,7 +394,8 @@ TmEcode ReceivePfringLoop(ThreadVars *tv, void *data, void *slot) * \retval TM_ECODE_OK on success * \retval TM_ECODE_FAILED on error */ -TmEcode ReceivePfringThreadInit(ThreadVars *tv, void *initdata, void **data) { +TmEcode ReceivePfringThreadInit(ThreadVars *tv, void *initdata, void **data) +{ int rc; u_int32_t version = 0; PfringIfaceConfig *pfconf = (PfringIfaceConfig *) initdata; @@ -547,7 +553,8 @@ TmEcode ReceivePfringThreadInit(ThreadVars *tv, void *initdata, void **data) { * \param tv pointer to ThreadVars * \param data pointer that gets cast into PfringThreadVars for ptv */ -void ReceivePfringThreadExitStats(ThreadVars *tv, void *data) { +void ReceivePfringThreadExitStats(ThreadVars *tv, void *data) +{ PfringThreadVars *ptv = (PfringThreadVars *)data; PfringDumpCounters(ptv); @@ -564,7 +571,8 @@ void ReceivePfringThreadExitStats(ThreadVars *tv, void *data) { * \param data pointer that gets cast into PfringThreadVars for ptvi * \retval TM_ECODE_OK is always returned */ -TmEcode ReceivePfringThreadDeinit(ThreadVars *tv, void *data) { +TmEcode ReceivePfringThreadDeinit(ThreadVars *tv, void *data) +{ PfringThreadVars *ptv = (PfringThreadVars *)data; if (ptv->interface) SCFree(ptv->interface); diff --git a/src/stream-tcp-inline.c b/src/stream-tcp-inline.c index dbc2685a8d..b8961ba287 100644 --- a/src/stream-tcp-inline.c +++ b/src/stream-tcp-inline.c @@ -41,7 +41,8 @@ extern int stream_inline; * \retval 0 no * \retval 1 yes */ -int StreamTcpInlineMode(void) { +int StreamTcpInlineMode(void) +{ return stream_inline; } @@ -56,7 +57,8 @@ int StreamTcpInlineMode(void) { * \retval 0 shared data is the same (or no data is shared) * \retval 1 shared data is different */ -int StreamTcpInlineSegmentCompare(TcpSegment *seg1, TcpSegment *seg2) { +int StreamTcpInlineSegmentCompare(TcpSegment *seg1, TcpSegment *seg2) +{ SCEnter(); if (seg1 == NULL || seg2 == NULL) { @@ -131,7 +133,8 @@ int StreamTcpInlineSegmentCompare(TcpSegment *seg1, TcpSegment *seg2) { * \todo What about reassembled fragments? * \todo What about unwrapped tunnel packets? */ -void StreamTcpInlineSegmentReplacePacket(Packet *p, TcpSegment *seg) { +void StreamTcpInlineSegmentReplacePacket(Packet *p, TcpSegment *seg) +{ SCEnter(); uint32_t pseq = TCP_GET_SEQ(p); @@ -183,7 +186,8 @@ void StreamTcpInlineSegmentReplacePacket(Packet *p, TcpSegment *seg) { #ifdef UNITTESTS /** \test full overlap */ -static int StreamTcpInlineTest01(void) { +static int StreamTcpInlineTest01(void) +{ SCEnter(); uint8_t payload1[] = "AAC"; /* packet */ @@ -243,7 +247,8 @@ end: } /** \test full overlap */ -static int StreamTcpInlineTest02(void) { +static int StreamTcpInlineTest02(void) +{ SCEnter(); uint8_t payload1[] = "xxx"; /* packet */ @@ -308,7 +313,8 @@ end: } /** \test partial overlap */ -static int StreamTcpInlineTest03(void) { +static int StreamTcpInlineTest03(void) +{ SCEnter(); uint8_t payload1[] = "xxxxxxxxxxxx"; /* packet */ @@ -373,7 +379,8 @@ end: } /** \test partial overlap */ -static int StreamTcpInlineTest04(void) { +static int StreamTcpInlineTest04(void) +{ SCEnter(); uint8_t payload1[] = "xxxxxxxxxxxx"; /* packet */ @@ -437,7 +444,8 @@ end: SCReturnInt(result); } /** \test partial overlap */ -static int StreamTcpInlineTest05(void) { +static int StreamTcpInlineTest05(void) +{ SCEnter(); uint8_t payload1[] = "xxxxxxxxxxxx"; /* packet */ @@ -502,7 +510,8 @@ end: } /** \test no overlap */ -static int StreamTcpInlineTest06(void) { +static int StreamTcpInlineTest06(void) +{ SCEnter(); uint8_t payload1[] = "xxxxxxxxxxxx"; /* packet */ @@ -567,7 +576,8 @@ end: } /** \test no overlap */ -static int StreamTcpInlineTest07(void) { +static int StreamTcpInlineTest07(void) +{ SCEnter(); uint8_t payload1[] = "xxxxxxxxxxxx"; /* packet */ @@ -632,7 +642,8 @@ end: } #endif /* UNITTESTS */ -void StreamTcpInlineRegisterTests(void) { +void StreamTcpInlineRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("StreamTcpInlineTest01", StreamTcpInlineTest01, 1); UtRegisterTest("StreamTcpInlineTest02", StreamTcpInlineTest02, 1); diff --git a/src/stream-tcp-reassemble.c b/src/stream-tcp-reassemble.c index 7dc7b7696a..2d1170a14c 100644 --- a/src/stream-tcp-reassemble.c +++ b/src/stream-tcp-reassemble.c @@ -106,7 +106,8 @@ void StreamTcpReassemblePseudoPacketCreate(TcpStream *, Packet *, PacketQueue *) static int StreamTcpSegmentDataCompare(TcpSegment *dst_seg, TcpSegment *src_seg, uint32_t start_point, uint16_t len); -void StreamTcpReassembleConfigEnableOverlapCheck(void) { +void StreamTcpReassembleConfigEnableOverlapCheck(void) +{ check_overlap_different_data = 1; } @@ -116,7 +117,8 @@ void StreamTcpReassembleConfigEnableOverlapCheck(void) { * * \param size Size of the TCP segment and its payload length memory allocated */ -void StreamTcpReassembleIncrMemuse(uint64_t size) { +void StreamTcpReassembleIncrMemuse(uint64_t size) +{ (void) SC_ATOMIC_ADD(ra_memuse, size); return; } @@ -127,12 +129,14 @@ void StreamTcpReassembleIncrMemuse(uint64_t size) { * * \param size Size of the TCP segment and its payload length memory allocated */ -void StreamTcpReassembleDecrMemuse(uint64_t size) { +void StreamTcpReassembleDecrMemuse(uint64_t size) +{ (void) SC_ATOMIC_SUB(ra_memuse, size); return; } -void StreamTcpReassembleMemuseCounter(ThreadVars *tv, TcpReassemblyThreadCtx *rtv) { +void StreamTcpReassembleMemuseCounter(ThreadVars *tv, TcpReassemblyThreadCtx *rtv) +{ uint64_t smemuse = SC_ATOMIC_GET(ra_memuse); if (tv != NULL && rtv != NULL) SCPerfCounterSetUI64(rtv->counter_tcp_reass_memuse, tv->sc_perf_pca, smemuse); @@ -147,7 +151,8 @@ void StreamTcpReassembleMemuseCounter(ThreadVars *tv, TcpReassemblyThreadCtx *rt * \retval 1 if in bounds * \retval 0 if not in bounds */ -int StreamTcpReassembleCheckMemcap(uint32_t size) { +int StreamTcpReassembleCheckMemcap(uint32_t size) +{ if (stream_config.reassembly_memcap == 0 || (uint64_t)((uint64_t)size + SC_ATOMIC_GET(ra_memuse)) <= stream_config.reassembly_memcap) return 1; @@ -203,7 +208,8 @@ int TcpSegmentPoolInit(void *data, void *payload_len) } /** \brief clean up a tcp segment pool entry */ -void TcpSegmentPoolCleanup(void *ptr) { +void TcpSegmentPoolCleanup(void *ptr) +{ if (ptr == NULL) return; @@ -1695,7 +1701,8 @@ static int HandleSegmentStartsAfterListSegment(ThreadVars *tv, TcpReassemblyThre * \retval 1 stream has depth reached * \retval 0 stream does not have depth reached */ -int StreamTcpReassembleDepthReached(Packet *p) { +int StreamTcpReassembleDepthReached(Packet *p) +{ if (p->flow != NULL && p->flow->protoctx != NULL) { TcpSession *ssn = p->flow->protoctx; TcpStream *stream; @@ -1773,7 +1780,8 @@ static uint32_t StreamTcpReassembleCheckDepth(TcpStream *stream, SCReturnUInt(0); } -static void StreamTcpStoreStreamChunk(TcpSession *ssn, StreamMsg *smsg, const Packet *p, int streaminline) { +static void StreamTcpStoreStreamChunk(TcpSession *ssn, StreamMsg *smsg, const Packet *p, int streaminline) +{ uint8_t direction = 0; if ((!streaminline && (p->flowflags & FLOW_PKT_TOSERVER)) || @@ -2018,7 +2026,8 @@ static int StreamTcpReassembleRawCheckLimit(TcpSession *ssn, TcpStream *stream, SCReturnInt(1); } -static void StreamTcpRemoveSegmentFromStream(TcpStream *stream, TcpSegment *seg) { +static void StreamTcpRemoveSegmentFromStream(TcpStream *stream, TcpSegment *seg) +{ if (seg->prev == NULL) { stream->seg_list = seg->next; if (stream->seg_list != NULL) @@ -2713,7 +2722,8 @@ static int StreamTcpReassembleInlineRaw (TcpReassemblyThreadCtx *ra_ctx, * \retval 1 yes * \retval 0 no */ -static inline int StreamTcpReturnSegmentCheck(const Flow *f, TcpSession *ssn, TcpStream *stream, TcpSegment *seg) { +static inline int StreamTcpReturnSegmentCheck(const Flow *f, TcpSession *ssn, TcpStream *stream, TcpSegment *seg) +{ if (stream == &ssn->client && ssn->toserver_smsg_head != NULL) { /* not (seg is entirely before first smsg, skip) */ if (!(SEQ_LEQ(seg->seq + seg->payload_len, ssn->toserver_smsg_head->seq))) { @@ -2751,7 +2761,8 @@ static inline int StreamTcpReturnSegmentCheck(const Flow *f, TcpSession *ssn, Tc * \param f flow * \param flags direction flags */ -void StreamTcpPruneSession(Flow *f, uint8_t flags) { +void StreamTcpPruneSession(Flow *f, uint8_t flags) +{ if (f == NULL || f->protoctx == NULL) return; @@ -2788,7 +2799,8 @@ void StreamTcpPruneSession(Flow *f, uint8_t flags) { } #ifdef DEBUG -static uint64_t GetStreamSize(TcpStream *stream) { +static uint64_t GetStreamSize(TcpStream *stream) +{ if (stream) { uint64_t size = 0; uint32_t cnt = 0; @@ -2807,7 +2819,8 @@ static uint64_t GetStreamSize(TcpStream *stream) { return (uint64_t)0; } -static void GetSessionSize(TcpSession *ssn, Packet *p) { +static void GetSessionSize(TcpSession *ssn, Packet *p) +{ uint64_t size = 0; if (ssn) { size = GetStreamSize(&ssn->client); @@ -3761,7 +3774,8 @@ TcpSegment* StreamTcpGetSegment(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx, * * \param ssn TcpSession */ -void StreamTcpReassembleTriggerRawReassembly(TcpSession *ssn) { +void StreamTcpReassembleTriggerRawReassembly(TcpSession *ssn) +{ #ifdef DEBUG BUG_ON(ssn == NULL); #endif @@ -3775,7 +3789,8 @@ void StreamTcpReassembleTriggerRawReassembly(TcpSession *ssn) { #ifdef UNITTESTS /** unit tests and it's support functions below */ -static uint32_t UtSsnSmsgCnt(TcpSession *ssn, uint8_t direction) { +static uint32_t UtSsnSmsgCnt(TcpSession *ssn, uint8_t direction) +{ uint32_t cnt = 0; StreamMsg *smsg = (direction == STREAM_TOSERVER) ? ssn->toserver_smsg_head : @@ -3794,7 +3809,8 @@ static uint32_t UtSsnSmsgCnt(TcpSession *ssn, uint8_t direction) { * \param stream The stream which will contain the reassembled segments */ -static int StreamTcpReassembleStreamTest(TcpStream *stream) { +static int StreamTcpReassembleStreamTest(TcpStream *stream) +{ TcpSession ssn; Packet *p = PacketGetFromAlloc(); @@ -4041,7 +4057,8 @@ void StreamTcpCreateTestPacket(uint8_t *payload, uint8_t value, * \param stream Reassembled stream returned from the reassembly functions */ -int StreamTcpCheckStreamContents(uint8_t *stream_policy, uint16_t sp_size, TcpStream *stream) { +int StreamTcpCheckStreamContents(uint8_t *stream_policy, uint16_t sp_size, TcpStream *stream) +{ TcpSegment *temp; uint16_t i = 0; uint8_t j; @@ -4080,7 +4097,8 @@ int StreamTcpCheckStreamContents(uint8_t *stream_policy, uint16_t sp_size, TcpSt * * \retval On success the function returns 1, on failure 0. */ -static int StreamTcpCheckChunks (TcpSession *ssn, uint8_t *stream_contents) { +static int StreamTcpCheckChunks (TcpSession *ssn, uint8_t *stream_contents) +{ SCEnter(); StreamMsg *msg; @@ -4240,7 +4258,8 @@ static int StreamTcpTestStartsBeforeListSegment(TcpStream *stream) { * also tells the OS policy used for reassembling the segments. */ -static int StreamTcpTestStartsAtSameListSegment(TcpStream *stream) { +static int StreamTcpTestStartsAtSameListSegment(TcpStream *stream) +{ TcpSession ssn; Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) @@ -4355,7 +4374,8 @@ static int StreamTcpTestStartsAtSameListSegment(TcpStream *stream) { */ -static int StreamTcpTestStartsAfterListSegment(TcpStream *stream) { +static int StreamTcpTestStartsAfterListSegment(TcpStream *stream) +{ TcpSession ssn; Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) @@ -4457,7 +4477,8 @@ static int StreamTcpTestStartsAfterListSegment(TcpStream *stream) { * segments. */ -static int StreamTcpReassembleTest01(void) { +static int StreamTcpReassembleTest01(void) +{ TcpStream stream; uint8_t stream_before_bsd[10] = {0x4a, 0x4a, 0x4a, 0x4a, 0x4c, 0x4c, 0x4c, 0x4d, 0x4d, 0x4d}; @@ -4484,7 +4505,8 @@ static int StreamTcpReassembleTest01(void) { * to reassemble segments. */ -static int StreamTcpReassembleTest02(void) { +static int StreamTcpReassembleTest02(void) +{ TcpStream stream; uint8_t stream_same_bsd[8] = {0x43, 0x43, 0x43, 0x4c, 0x48, 0x48, 0x49, 0x51}; @@ -4510,7 +4532,8 @@ static int StreamTcpReassembleTest02(void) { * segments. */ -static int StreamTcpReassembleTest03(void) { +static int StreamTcpReassembleTest03(void) +{ TcpStream stream; uint8_t stream_after_bsd[8] = {0x41, 0x41, 0x4a, 0x46, 0x46, 0x46, 0x47, 0x47}; @@ -4536,7 +4559,8 @@ static int StreamTcpReassembleTest03(void) { * reassemble segments. */ -static int StreamTcpReassembleTest04(void) { +static int StreamTcpReassembleTest04(void) +{ TcpStream stream; uint8_t stream_bsd[25] = {0x30, 0x41, 0x41, 0x41, 0x4a, 0x4a, 0x42, 0x43, 0x43, 0x43, 0x4c, 0x4c, 0x4c, 0x4d, 0x4d, 0x4d, @@ -4561,7 +4585,8 @@ static int StreamTcpReassembleTest04(void) { * segments. */ -static int StreamTcpReassembleTest05(void) { +static int StreamTcpReassembleTest05(void) +{ TcpStream stream; uint8_t stream_before_vista[10] = {0x4a, 0x41, 0x42, 0x4a, 0x4c, 0x44, 0x4c, 0x4d, 0x45, 0x45}; @@ -4585,7 +4610,8 @@ static int StreamTcpReassembleTest05(void) { * to reassemble segments. */ -static int StreamTcpReassembleTest06(void) { +static int StreamTcpReassembleTest06(void) +{ TcpStream stream; uint8_t stream_same_vista[8] = {0x43, 0x43, 0x43, 0x4c, 0x48, 0x48, 0x49, 0x51}; @@ -4611,7 +4637,8 @@ static int StreamTcpReassembleTest06(void) { * segments. */ -static int StreamTcpReassembleTest07(void) { +static int StreamTcpReassembleTest07(void) +{ TcpStream stream; uint8_t stream_after_vista[8] = {0x41, 0x41, 0x4a, 0x46, 0x46, 0x46, 0x47, 0x47}; @@ -4637,7 +4664,8 @@ static int StreamTcpReassembleTest07(void) { * reassemble segments. */ -static int StreamTcpReassembleTest08(void) { +static int StreamTcpReassembleTest08(void) +{ TcpStream stream; uint8_t stream_vista[25] = {0x30, 0x41, 0x41, 0x41, 0x4a, 0x42, 0x42, 0x43, 0x43, 0x43, 0x4c, 0x44, 0x4c, 0x4d, 0x45, 0x45, @@ -4662,7 +4690,8 @@ static int StreamTcpReassembleTest08(void) { * segments. */ -static int StreamTcpReassembleTest09(void) { +static int StreamTcpReassembleTest09(void) +{ TcpStream stream; uint8_t stream_before_linux[10] = {0x4a, 0x4a, 0x4a, 0x4a, 0x4c, 0x4c, 0x4c, 0x4d, 0x4d, 0x4d}; @@ -4686,7 +4715,8 @@ static int StreamTcpReassembleTest09(void) { * to reassemble segments. */ -static int StreamTcpReassembleTest10(void) { +static int StreamTcpReassembleTest10(void) +{ TcpStream stream; uint8_t stream_same_linux[8] = {0x4c, 0x4c, 0x4c, 0x4c, 0x48, 0x48, 0x51, 0x51}; @@ -4710,7 +4740,8 @@ static int StreamTcpReassembleTest10(void) { * segments. */ -static int StreamTcpReassembleTest11(void) { +static int StreamTcpReassembleTest11(void) +{ TcpStream stream; uint8_t stream_after_linux[8] = {0x41, 0x41, 0x4a, 0x46, 0x46, 0x46, 0x47, 0x47}; @@ -4734,7 +4765,8 @@ static int StreamTcpReassembleTest11(void) { * reassemble segments. */ -static int StreamTcpReassembleTest12(void) { +static int StreamTcpReassembleTest12(void) +{ TcpStream stream; uint8_t stream_linux[25] = {0x30, 0x41, 0x41, 0x41, 0x4a, 0x4a, 0x42, 0x43, 0x43, 0x43, 0x4c, 0x4c, 0x4c, 0x4d, 0x4d, 0x4d, @@ -4759,7 +4791,8 @@ static int StreamTcpReassembleTest12(void) { * segments. */ -static int StreamTcpReassembleTest13(void) { +static int StreamTcpReassembleTest13(void) +{ TcpStream stream; uint8_t stream_before_old_linux[10] = {0x4a, 0x4a, 0x4a, 0x4a, 0x4c, 0x4c, 0x4c, 0x4d, 0x4d, 0x4d}; @@ -4783,7 +4816,8 @@ static int StreamTcpReassembleTest13(void) { * used to reassemble segments. */ -static int StreamTcpReassembleTest14(void) { +static int StreamTcpReassembleTest14(void) +{ TcpStream stream; uint8_t stream_same_old_linux[8] = {0x4c, 0x4c, 0x4c, 0x4c, 0x48, 0x48, 0x51, 0x51}; @@ -4807,7 +4841,8 @@ static int StreamTcpReassembleTest14(void) { * segments. */ -static int StreamTcpReassembleTest15(void) { +static int StreamTcpReassembleTest15(void) +{ TcpStream stream; uint8_t stream_after_old_linux[8] = {0x41, 0x41, 0x4a, 0x46, 0x46, 0x46, 0x47, 0x47}; @@ -4831,7 +4866,8 @@ static int StreamTcpReassembleTest15(void) { * reassemble segments. */ -static int StreamTcpReassembleTest16(void) { +static int StreamTcpReassembleTest16(void) +{ TcpStream stream; uint8_t stream_old_linux[25] = {0x30, 0x41, 0x41, 0x41, 0x4a, 0x4a, 0x42, 0x4b, 0x4b, 0x4b, 0x4c, 0x4c, 0x4c, 0x4d, 0x4d, 0x4d, @@ -4856,7 +4892,8 @@ static int StreamTcpReassembleTest16(void) { * segments. */ -static int StreamTcpReassembleTest17(void) { +static int StreamTcpReassembleTest17(void) +{ TcpStream stream; uint8_t stream_before_solaris[10] = {0x4a, 0x4a, 0x4a, 0x4a, 0x4c, 0x4c, 0x4c, 0x4d, 0x4d, 0x4d}; @@ -4880,7 +4917,8 @@ static int StreamTcpReassembleTest17(void) { * to reassemble segments. */ -static int StreamTcpReassembleTest18(void) { +static int StreamTcpReassembleTest18(void) +{ TcpStream stream; uint8_t stream_same_solaris[8] = {0x4c, 0x4c, 0x4c, 0x4c, 0x48, 0x48, 0x51, 0x51}; @@ -4904,7 +4942,8 @@ static int StreamTcpReassembleTest18(void) { * segments. */ -static int StreamTcpReassembleTest19(void) { +static int StreamTcpReassembleTest19(void) +{ TcpStream stream; uint8_t stream_after_solaris[8] = {0x41, 0x4a, 0x4a, 0x46, 0x46, 0x46, 0x47, 0x47}; @@ -4930,7 +4969,8 @@ static int StreamTcpReassembleTest19(void) { * reassemble segments. */ -static int StreamTcpReassembleTest20(void) { +static int StreamTcpReassembleTest20(void) +{ TcpStream stream; uint8_t stream_solaris[25] = {0x30, 0x41, 0x4a, 0x4a, 0x4a, 0x42, 0x42, 0x4b, 0x4b, 0x4b, 0x4c, 0x4c, 0x4c, 0x4d, 0x4d, 0x4d, @@ -4957,7 +4997,8 @@ static int StreamTcpReassembleTest20(void) { * segments. */ -static int StreamTcpReassembleTest21(void) { +static int StreamTcpReassembleTest21(void) +{ TcpStream stream; uint8_t stream_before_last[10] = {0x4a, 0x4a, 0x4a, 0x4a, 0x4c, 0x4c, 0x4c, 0x4d, 0x4d, 0x4d}; @@ -4981,7 +5022,8 @@ static int StreamTcpReassembleTest21(void) { * to reassemble segments. */ -static int StreamTcpReassembleTest22(void) { +static int StreamTcpReassembleTest22(void) +{ TcpStream stream; uint8_t stream_same_last[8] = {0x4c, 0x4c, 0x4c, 0x4c, 0x50, 0x48, 0x51, 0x51}; @@ -5004,7 +5046,8 @@ static int StreamTcpReassembleTest22(void) { * after the list segment and LAST policy is used to reassemble * segments. */ -static int StreamTcpReassembleTest23(void) { +static int StreamTcpReassembleTest23(void) +{ TcpStream stream; uint8_t stream_after_last[8] = {0x41, 0x4a, 0x4a, 0x46, 0x4e, 0x46, 0x47, 0x4f}; memset(&stream, 0, sizeof (TcpStream)); @@ -5029,7 +5072,8 @@ static int StreamTcpReassembleTest23(void) { * reassemble segments. */ -static int StreamTcpReassembleTest24(void) { +static int StreamTcpReassembleTest24(void) +{ int ret = 0; TcpStream stream; uint8_t stream_last[25] = {0x30, 0x41, 0x4a, 0x4a, 0x4a, 0x4a, 0x42, 0x4b, @@ -5149,7 +5193,8 @@ static int StreamTcpTestMissedPacket (TcpReassemblyThreadCtx *ra_ctx, * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpReassembleTest25 (void) { +static int StreamTcpReassembleTest25 (void) +{ int ret = 0; uint8_t payload[4]; uint32_t seq; @@ -5207,7 +5252,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpReassembleTest26 (void) { +static int StreamTcpReassembleTest26 (void) +{ int ret = 0; uint8_t payload[4]; uint32_t seq; @@ -5264,7 +5310,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpReassembleTest27 (void) { +static int StreamTcpReassembleTest27 (void) +{ int ret = 0; uint8_t payload[4]; uint32_t seq; @@ -5322,7 +5369,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpReassembleTest28 (void) { +static int StreamTcpReassembleTest28 (void) +{ int ret = 0; uint8_t payload[4]; uint32_t seq; @@ -5402,7 +5450,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpReassembleTest29 (void) { +static int StreamTcpReassembleTest29 (void) +{ int ret = 0; uint8_t payload[4]; uint32_t seq; @@ -5479,7 +5528,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpReassembleTest30 (void) { +static int StreamTcpReassembleTest30 (void) +{ int ret = 0; uint8_t payload[4]; uint32_t seq; @@ -5575,7 +5625,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpReassembleTest31 (void) { +static int StreamTcpReassembleTest31 (void) +{ int ret = 0; uint8_t payload[4]; uint32_t seq; @@ -5646,7 +5697,8 @@ end: return ret; } -static int StreamTcpReassembleTest32(void) { +static int StreamTcpReassembleTest32(void) +{ TcpSession ssn; Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) @@ -5735,7 +5787,8 @@ end: return ret; } -static int StreamTcpReassembleTest33(void) { +static int StreamTcpReassembleTest33(void) +{ TcpSession ssn; Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) @@ -5815,7 +5868,8 @@ static int StreamTcpReassembleTest33(void) { return 1; } -static int StreamTcpReassembleTest34(void) { +static int StreamTcpReassembleTest34(void) +{ TcpSession ssn; Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) @@ -5896,7 +5950,8 @@ static int StreamTcpReassembleTest34(void) { } /** \test Test the bug 56 condition */ -static int StreamTcpReassembleTest35(void) { +static int StreamTcpReassembleTest35(void) +{ TcpSession ssn; Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) @@ -5964,7 +6019,8 @@ static int StreamTcpReassembleTest35(void) { } /** \test Test the bug 57 condition */ -static int StreamTcpReassembleTest36(void) { +static int StreamTcpReassembleTest36(void) +{ TcpSession ssn; Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) @@ -6031,7 +6087,8 @@ static int StreamTcpReassembleTest36(void) { } /** \test Test the bug 76 condition */ -static int StreamTcpReassembleTest37(void) { +static int StreamTcpReassembleTest37(void) +{ TcpSession ssn; Flow f; TCPHdr tcph; @@ -6129,7 +6186,8 @@ static int StreamTcpReassembleTest37(void) { * * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpReassembleTest38 (void) { +static int StreamTcpReassembleTest38 (void) +{ int ret = 0; Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) @@ -6243,7 +6301,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpReassembleTest39 (void) { +static int StreamTcpReassembleTest39 (void) +{ Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) return 0; @@ -6844,7 +6903,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpReassembleTest40 (void) { +static int StreamTcpReassembleTest40 (void) +{ int ret = 0; Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) @@ -7043,7 +7103,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpReassembleTest43 (void) { +static int StreamTcpReassembleTest43 (void) +{ int ret = 0; Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) @@ -7258,7 +7319,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpReassembleTest45 (void) { +static int StreamTcpReassembleTest45 (void) +{ int ret = 0; Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) @@ -7376,7 +7438,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpReassembleTest46 (void) { +static int StreamTcpReassembleTest46 (void) +{ int ret = 0; Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) @@ -7498,7 +7561,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpReassembleTest47 (void) { +static int StreamTcpReassembleTest47 (void) +{ int ret = 0; Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) @@ -7591,7 +7655,8 @@ end: } /** \test 3 in order segments in inline reassembly */ -static int StreamTcpReassembleInlineTest01(void) { +static int StreamTcpReassembleInlineTest01(void) +{ int ret = 0; TcpReassemblyThreadCtx *ra_ctx = NULL; ThreadVars tv; @@ -7668,7 +7733,8 @@ end: /** \test 3 in order segments, then reassemble, add one more and reassemble again. * test the sliding window reassembly. */ -static int StreamTcpReassembleInlineTest02(void) { +static int StreamTcpReassembleInlineTest02(void) +{ int ret = 0; TcpReassemblyThreadCtx *ra_ctx = NULL; ThreadVars tv; @@ -7778,7 +7844,8 @@ end: * test the sliding window reassembly with a small window size so that we * cutting off at the start (left edge) */ -static int StreamTcpReassembleInlineTest03(void) { +static int StreamTcpReassembleInlineTest03(void) +{ int ret = 0; TcpReassemblyThreadCtx *ra_ctx = NULL; ThreadVars tv; @@ -7893,7 +7960,8 @@ end: * test the sliding window reassembly with a small window size so that we * cutting off at the start (left edge) with small packet overlap. */ -static int StreamTcpReassembleInlineTest04(void) { +static int StreamTcpReassembleInlineTest04(void) +{ int ret = 0; TcpReassemblyThreadCtx *ra_ctx = NULL; ThreadVars tv; @@ -8005,7 +8073,8 @@ end: } /** \test with a GAP we should have 2 smsgs */ -static int StreamTcpReassembleInlineTest05(void) { +static int StreamTcpReassembleInlineTest05(void) +{ int ret = 0; TcpReassemblyThreadCtx *ra_ctx = NULL; ThreadVars tv; @@ -8098,7 +8167,8 @@ end: } /** \test with a GAP we should have 2 smsgs, with filling the GAP later */ -static int StreamTcpReassembleInlineTest06(void) { +static int StreamTcpReassembleInlineTest06(void) +{ int ret = 0; TcpReassemblyThreadCtx *ra_ctx = NULL; ThreadVars tv; @@ -8226,7 +8296,8 @@ end: /** \test with a GAP we should have 2 smsgs, with filling the GAP later, small * window */ -static int StreamTcpReassembleInlineTest07(void) { +static int StreamTcpReassembleInlineTest07(void) +{ int ret = 0; TcpReassemblyThreadCtx *ra_ctx = NULL; ThreadVars tv; @@ -8360,7 +8431,8 @@ end: * cutting off at the start (left edge). Test if the first segment is * removed from the list. */ -static int StreamTcpReassembleInlineTest08(void) { +static int StreamTcpReassembleInlineTest08(void) +{ int ret = 0; TcpReassemblyThreadCtx *ra_ctx = NULL; ThreadVars tv; @@ -8492,7 +8564,8 @@ end: * cutting off at the start (left edge). Test if the first segment is * removed from the list. */ -static int StreamTcpReassembleInlineTest09(void) { +static int StreamTcpReassembleInlineTest09(void) +{ int ret = 0; TcpReassemblyThreadCtx *ra_ctx = NULL; ThreadVars tv; @@ -8637,7 +8710,8 @@ end: /** \test App Layer reassembly. */ -static int StreamTcpReassembleInlineTest10(void) { +static int StreamTcpReassembleInlineTest10(void) +{ int ret = 0; TcpReassemblyThreadCtx *ra_ctx = NULL; ThreadVars tv; @@ -8722,7 +8796,8 @@ end: /** \test test insert with overlap */ -static int StreamTcpReassembleInsertTest01(void) { +static int StreamTcpReassembleInsertTest01(void) +{ int ret = 0; TcpReassemblyThreadCtx *ra_ctx = NULL; ThreadVars tv; @@ -8810,7 +8885,8 @@ end: /** \test test insert with overlaps */ -static int StreamTcpReassembleInsertTest02(void) { +static int StreamTcpReassembleInsertTest02(void) +{ int ret = 0; TcpReassemblyThreadCtx *ra_ctx = NULL; ThreadVars tv; @@ -8852,7 +8928,8 @@ end: /** \test test insert with overlaps */ -static int StreamTcpReassembleInsertTest03(void) { +static int StreamTcpReassembleInsertTest03(void) +{ int ret = 0; TcpReassemblyThreadCtx *ra_ctx = NULL; ThreadVars tv; @@ -8898,7 +8975,8 @@ end: * for various OS policies. */ -void StreamTcpReassembleRegisterTests(void) { +void StreamTcpReassembleRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("StreamTcpReassembleTest01 -- BSD OS Before Reassembly Test", StreamTcpReassembleTest01, 1); UtRegisterTest("StreamTcpReassembleTest02 -- BSD OS At Same Reassembly Test", StreamTcpReassembleTest02, 1); diff --git a/src/stream-tcp-sack.c b/src/stream-tcp-sack.c index cd2a94ab85..7dc23eb87e 100644 --- a/src/stream-tcp-sack.c +++ b/src/stream-tcp-sack.c @@ -30,7 +30,8 @@ #include "util-unittest.h" #ifdef DEBUG -void StreamTcpSackPrintList(TcpStream *stream) { +void StreamTcpSackPrintList(TcpStream *stream) +{ StreamTcpSackRecord *rec = stream->sack_head; for (; rec != NULL; rec = rec->next) { SCLogDebug("record %8u - %8u", rec->le, rec->re); @@ -38,7 +39,8 @@ void StreamTcpSackPrintList(TcpStream *stream) { } #endif /* DEBUG */ -static StreamTcpSackRecord *StreamTcpSackRecordAlloc(void) { +static StreamTcpSackRecord *StreamTcpSackRecordAlloc(void) +{ if (StreamTcpCheckMemcap((uint32_t)sizeof(StreamTcpSackRecord)) == 0) return NULL; @@ -50,7 +52,8 @@ static StreamTcpSackRecord *StreamTcpSackRecordAlloc(void) { return rec; } -static void StreamTcpSackRecordFree(StreamTcpSackRecord *rec) { +static void StreamTcpSackRecordFree(StreamTcpSackRecord *rec) +{ SCFree(rec); StreamTcpDecrMemuse((uint64_t)sizeof(*rec)); } @@ -64,7 +67,8 @@ static void StreamTcpSackRecordFree(StreamTcpSackRecord *rec) { * \retval 0 all is good * \retval -1 error */ -static int StreamTcpSackInsertRange(TcpStream *stream, uint32_t le, uint32_t re) { +static int StreamTcpSackInsertRange(TcpStream *stream, uint32_t le, uint32_t re) +{ SCLogDebug("le %u, re %u", le, re); #ifdef DEBUG StreamTcpSackPrintList(stream); @@ -234,7 +238,8 @@ end: * \retval -1 error * \retval 0 ok */ -int StreamTcpSackUpdatePacket(TcpStream *stream, Packet *p) { +int StreamTcpSackUpdatePacket(TcpStream *stream, Packet *p) +{ int records = TCP_GET_SACK_CNT(p); int record = 0; @@ -276,7 +281,8 @@ int StreamTcpSackUpdatePacket(TcpStream *stream, Packet *p) { SCReturnInt(0); } -void StreamTcpSackPruneList(TcpStream *stream) { +void StreamTcpSackPruneList(TcpStream *stream) +{ SCEnter(); StreamTcpSackRecord *rec = stream->sack_head; @@ -317,7 +323,8 @@ void StreamTcpSackPruneList(TcpStream *stream) { * * \param stream Stream to cleanup */ -void StreamTcpSackFreeList(TcpStream *stream) { +void StreamTcpSackFreeList(TcpStream *stream) +{ SCEnter(); StreamTcpSackRecord *rec = stream->sack_head; @@ -343,7 +350,8 @@ void StreamTcpSackFreeList(TcpStream *stream) { * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpSackTest01 (void) { +static int StreamTcpSackTest01 (void) +{ TcpStream stream; int retval = 0; @@ -379,7 +387,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpSackTest02 (void) { +static int StreamTcpSackTest02 (void) +{ TcpStream stream; int retval = 0; @@ -413,7 +422,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpSackTest03 (void) { +static int StreamTcpSackTest03 (void) +{ TcpStream stream; int retval = 0; @@ -449,7 +459,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpSackTest04 (void) { +static int StreamTcpSackTest04 (void) +{ TcpStream stream; int retval = 0; @@ -482,7 +493,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpSackTest05 (void) { +static int StreamTcpSackTest05 (void) +{ TcpStream stream; int retval = 0; @@ -515,7 +527,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpSackTest06 (void) { +static int StreamTcpSackTest06 (void) +{ TcpStream stream; int retval = 0; @@ -550,7 +563,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpSackTest07 (void) { +static int StreamTcpSackTest07 (void) +{ TcpStream stream; int retval = 0; @@ -594,7 +608,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpSackTest08 (void) { +static int StreamTcpSackTest08 (void) +{ TcpStream stream; int retval = 0; @@ -638,7 +653,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpSackTest09 (void) { +static int StreamTcpSackTest09 (void) +{ TcpStream stream; int retval = 0; @@ -683,7 +699,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpSackTest10 (void) { +static int StreamTcpSackTest10 (void) +{ TcpStream stream; int retval = 0; @@ -727,7 +744,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpSackTest11 (void) { +static int StreamTcpSackTest11 (void) +{ TcpStream stream; int retval = 0; @@ -771,7 +789,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpSackTest12 (void) { +static int StreamTcpSackTest12 (void) +{ TcpStream stream; int retval = 0; @@ -818,7 +837,8 @@ end: #endif /* UNITTESTS */ -void StreamTcpSackRegisterTests (void) { +void StreamTcpSackRegisterTests (void) +{ #ifdef UNITTESTS UtRegisterTest("StreamTcpSackTest01 -- Insertion", StreamTcpSackTest01, 1); diff --git a/src/stream-tcp-sack.h b/src/stream-tcp-sack.h index b17a538270..632fa14dbb 100644 --- a/src/stream-tcp-sack.h +++ b/src/stream-tcp-sack.h @@ -38,7 +38,8 @@ * stream, as it *should* only be used in case of packet * loss. */ -static inline uint32_t StreamTcpSackedSize(TcpStream *stream) { +static inline uint32_t StreamTcpSackedSize(TcpStream *stream) +{ if (likely(stream->sack_head == NULL)) { SCReturnUInt(0U); } else { diff --git a/src/stream-tcp-util.c b/src/stream-tcp-util.c index 93fdf9b017..83cccf4ae2 100644 --- a/src/stream-tcp-util.c +++ b/src/stream-tcp-util.c @@ -40,37 +40,44 @@ /* unittest helper functions */ -void StreamTcpUTInit(TcpReassemblyThreadCtx **ra_ctx) { +void StreamTcpUTInit(TcpReassemblyThreadCtx **ra_ctx) +{ StreamTcpInitConfig(TRUE); *ra_ctx = StreamTcpReassembleInitThreadCtx(NULL); } -void StreamTcpUTDeinit(TcpReassemblyThreadCtx *ra_ctx) { +void StreamTcpUTDeinit(TcpReassemblyThreadCtx *ra_ctx) +{ StreamTcpReassembleFreeThreadCtx(ra_ctx); StreamTcpFreeConfig(TRUE); } -void StreamTcpUTSetupSession(TcpSession *ssn) { +void StreamTcpUTSetupSession(TcpSession *ssn) +{ memset(ssn, 0x00, sizeof(TcpSession)); } -void StreamTcpUTClearSession(TcpSession *ssn) { +void StreamTcpUTClearSession(TcpSession *ssn) +{ StreamTcpUTClearStream(&ssn->client); StreamTcpUTClearStream(&ssn->server); } -void StreamTcpUTSetupStream(TcpStream *s, uint32_t isn) { +void StreamTcpUTSetupStream(TcpStream *s, uint32_t isn) +{ memset(s, 0x00, sizeof(TcpStream)); s->isn = isn; STREAMTCP_SET_RA_BASE_SEQ(s, isn); } -void StreamTcpUTClearStream(TcpStream *s) { +void StreamTcpUTClearStream(TcpStream *s) +{ StreamTcpReturnStreamSegments(s); } -int StreamTcpUTAddSegmentWithPayload(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx, TcpStream *stream, uint32_t seq, uint8_t *payload, uint16_t len) { +int StreamTcpUTAddSegmentWithPayload(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx, TcpStream *stream, uint32_t seq, uint8_t *payload, uint16_t len) +{ TcpSegment *s = StreamTcpGetSegment(tv, ra_ctx, len); if (s == NULL) { return -1; @@ -93,7 +100,8 @@ int StreamTcpUTAddSegmentWithPayload(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ return 0; } -int StreamTcpUTAddSegmentWithByte(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx, TcpStream *stream, uint32_t seq, uint8_t byte, uint16_t len) { +int StreamTcpUTAddSegmentWithByte(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx, TcpStream *stream, uint32_t seq, uint8_t byte, uint16_t len) +{ TcpSegment *s = StreamTcpGetSegment(tv, ra_ctx, len); if (s == NULL) { return -1; @@ -117,7 +125,8 @@ int StreamTcpUTAddSegmentWithByte(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx /* tests */ -int StreamTcpUtilTest01(void) { +int StreamTcpUtilTest01(void) +{ int ret = 0; TcpReassemblyThreadCtx *ra_ctx = NULL; @@ -135,7 +144,8 @@ end: } -int StreamTcpUtilStreamTest01(void) { +int StreamTcpUtilStreamTest01(void) +{ int ret = 0; TcpReassemblyThreadCtx *ra_ctx = NULL; ThreadVars tv; @@ -184,7 +194,8 @@ end: return ret; } -int StreamTcpUtilStreamTest02(void) { +int StreamTcpUtilStreamTest02(void) +{ int ret = 0; TcpReassemblyThreadCtx *ra_ctx = NULL; ThreadVars tv; @@ -235,7 +246,8 @@ end: #endif -void StreamTcpUtilRegisterTests(void) { +void StreamTcpUtilRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("StreamTcpUtilTest01", StreamTcpUtilTest01, 1); UtRegisterTest("StreamTcpUtilStreamTest01", StreamTcpUtilStreamTest01, 1); diff --git a/src/stream-tcp.c b/src/stream-tcp.c index 9d60c9761a..607377c1a1 100644 --- a/src/stream-tcp.c +++ b/src/stream-tcp.c @@ -131,17 +131,20 @@ void TmModuleStreamTcpRegister (void) tmm_modules[TMM_STREAMTCP].flags = TM_FLAG_STREAM_TM; } -void StreamTcpIncrMemuse(uint64_t size) { +void StreamTcpIncrMemuse(uint64_t size) +{ (void) SC_ATOMIC_ADD(st_memuse, size); return; } -void StreamTcpDecrMemuse(uint64_t size) { +void StreamTcpDecrMemuse(uint64_t size) +{ (void) SC_ATOMIC_SUB(st_memuse, size); return; } -void StreamTcpMemuseCounter(ThreadVars *tv, StreamTcpThread *stt) { +void StreamTcpMemuseCounter(ThreadVars *tv, StreamTcpThread *stt) +{ uint64_t memusecopy = SC_ATOMIC_GET(st_memuse); SCPerfCounterSetUI64(stt->counter_tcp_memuse, tv->sc_perf_pca, memusecopy); return; @@ -153,7 +156,8 @@ void StreamTcpMemuseCounter(ThreadVars *tv, StreamTcpThread *stt) { * \retval 1 if in bounds * \retval 0 if not in bounds */ -int StreamTcpCheckMemcap(uint64_t size) { +int StreamTcpCheckMemcap(uint64_t size) +{ if (stream_config.memcap == 0 || size + SC_ATOMIC_GET(st_memuse) <= stream_config.memcap) return 1; return 0; @@ -727,7 +731,8 @@ void StreamTcpSetOSPolicy(TcpStream *stream, Packet *p) * * \retval size stream size */ -uint32_t StreamTcpGetStreamSize(TcpStream *stream) { +uint32_t StreamTcpGetStreamSize(TcpStream *stream) +{ return (stream->last_ack - stream->isn - 1); } @@ -761,7 +766,8 @@ uint32_t StreamTcpGetStreamSize(TcpStream *stream) { } \ } -static int StreamTcpPacketIsRetransmission(TcpStream *stream, Packet *p) { +static int StreamTcpPacketIsRetransmission(TcpStream *stream, Packet *p) +{ if (p->payload_len == 0) SCReturnInt(0); @@ -1024,7 +1030,8 @@ static int StreamTcpPacketStateNone(ThreadVars *tv, Packet *p, /** \internal * \brief Setup TcpStateQueue based on SYN/ACK packet */ -static inline void StreamTcp3whsSynAckToStateQueue(Packet *p, TcpStateQueue *q) { +static inline void StreamTcp3whsSynAckToStateQueue(Packet *p, TcpStateQueue *q) +{ q->flags = 0; q->wscale = 0; q->ts = 0; @@ -1049,7 +1056,8 @@ 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) { +TcpStateQueue *StreamTcp3whsFindSynAckBySynAck(TcpSession *ssn, Packet *p) +{ TcpStateQueue *q = ssn->queue; TcpStateQueue search; @@ -1071,7 +1079,8 @@ TcpStateQueue *StreamTcp3whsFindSynAckBySynAck(TcpSession *ssn, Packet *p) { return q; } -int StreamTcp3whsQueueSynAck(TcpSession *ssn, Packet *p) { +int StreamTcp3whsQueueSynAck(TcpSession *ssn, Packet *p) +{ /* first see if this is already in our list */ if (StreamTcp3whsFindSynAckBySynAck(ssn, p) != NULL) return 0; @@ -1107,7 +1116,8 @@ 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) { +TcpStateQueue *StreamTcp3whsFindSynAckByAck(TcpSession *ssn, Packet *p) +{ uint32_t ack = TCP_GET_SEQ(p); uint32_t seq = TCP_GET_ACK(p) - 1; TcpStateQueue *q = ssn->queue; @@ -1138,7 +1148,8 @@ TcpStateQueue *StreamTcp3whsFindSynAckByAck(TcpSession *ssn, Packet *p) { * this function can updated based on Packet or TcpStateQueue, where * the latter takes precedence. */ -static void StreamTcp3whsSynAckUpdate(TcpSession *ssn, Packet *p, TcpStateQueue *q) { +static void StreamTcp3whsSynAckUpdate(TcpSession *ssn, Packet *p, TcpStateQueue *q) +{ TcpStateQueue update; if (likely(q == NULL)) { StreamTcp3whsSynAckToStateQueue(p, &update); @@ -2124,7 +2135,8 @@ static int HandleEstablishedPacketToClient(ThreadVars *tv, TcpSession *ssn, Pack * * \retval ack highest ack we need to set */ -static inline uint32_t StreamTcpResetGetMaxAck(TcpStream *stream, uint32_t seq) { +static inline uint32_t StreamTcpResetGetMaxAck(TcpStream *stream, uint32_t seq) +{ uint32_t ack = seq; if (stream->seg_list_tail != NULL) { @@ -4039,7 +4051,8 @@ static int StreamTcpPacketStateTimeWait(ThreadVars *tv, Packet *p, * \retval 1 packet is a keep alive pkt * \retval 0 packet is not a keep alive pkt */ -static int StreamTcpPacketIsKeepAlive(TcpSession *ssn, Packet *p) { +static int StreamTcpPacketIsKeepAlive(TcpSession *ssn, Packet *p) +{ TcpStream *stream = NULL, *ostream = NULL; uint32_t seq; uint32_t ack; @@ -4085,7 +4098,8 @@ static int StreamTcpPacketIsKeepAlive(TcpSession *ssn, Packet *p) { * \retval 1 packet is a keep alive ACK pkt * \retval 0 packet is not a keep alive ACK pkt */ -static int StreamTcpPacketIsKeepAliveACK(TcpSession *ssn, Packet *p) { +static int StreamTcpPacketIsKeepAliveACK(TcpSession *ssn, Packet *p) +{ TcpStream *stream = NULL, *ostream = NULL; uint32_t seq; uint32_t ack; @@ -4128,7 +4142,8 @@ static int StreamTcpPacketIsKeepAliveACK(TcpSession *ssn, Packet *p) { return 0; } -static void StreamTcpClearKeepAliveFlag(TcpSession *ssn, Packet *p) { +static void StreamTcpClearKeepAliveFlag(TcpSession *ssn, Packet *p) +{ TcpStream *stream = NULL; if (p->flags & PKT_PSEUDO_STREAM_END) @@ -4150,7 +4165,8 @@ static void StreamTcpClearKeepAliveFlag(TcpSession *ssn, Packet *p) { * \retval 1 packet is a window update pkt * \retval 0 packet is not a window update pkt */ -static int StreamTcpPacketIsWindowUpdate(TcpSession *ssn, Packet *p) { +static int StreamTcpPacketIsWindowUpdate(TcpSession *ssn, Packet *p) +{ TcpStream *stream = NULL, *ostream = NULL; uint32_t seq; uint32_t ack; @@ -5494,7 +5510,8 @@ int StreamTcpSegmentForEach(const Packet *p, uint8_t flag, StreamSegmentCallback * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpTest01 (void) { +static int StreamTcpTest01 (void) +{ Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) return 0; @@ -5539,7 +5556,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpTest02 (void) { +static int StreamTcpTest02 (void) +{ Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) return 0; @@ -5637,7 +5655,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpTest03 (void) { +static int StreamTcpTest03 (void) +{ Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) return 0; @@ -5712,7 +5731,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpTest04 (void) { +static int StreamTcpTest04 (void) +{ Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) return 0; @@ -5780,7 +5800,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpTest05 (void) { +static int StreamTcpTest05 (void) +{ Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) return 0; @@ -5884,7 +5905,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpTest06 (void) { +static int StreamTcpTest06 (void) +{ Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) return 0; @@ -5948,7 +5970,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpTest07 (void) { +static int StreamTcpTest07 (void) +{ Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) return 0; @@ -6036,7 +6059,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpTest08 (void) { +static int StreamTcpTest08 (void) +{ Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) @@ -6127,7 +6151,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpTest09 (void) { +static int StreamTcpTest09 (void) +{ Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) @@ -6205,7 +6230,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpTest10 (void) { +static int StreamTcpTest10 (void) +{ Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) return 0; @@ -6306,7 +6332,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpTest11 (void) { +static int StreamTcpTest11 (void) +{ Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) return 0; @@ -6408,7 +6435,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpTest12 (void) { +static int StreamTcpTest12 (void) +{ Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) return 0; @@ -6503,7 +6531,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpTest13 (void) { +static int StreamTcpTest13 (void) +{ Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) return 0; @@ -6702,7 +6731,8 @@ char *StreamTcpParseOSPolicy (char *conf_var_name) * \retval On success it returns 1 and on failure 0 */ -static int StreamTcpTest14 (void) { +static int StreamTcpTest14 (void) +{ Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) return 0; @@ -6873,7 +6903,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcp4WHSTest01 (void) { +static int StreamTcp4WHSTest01 (void) +{ int ret = 0; Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) @@ -6954,7 +6985,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcp4WHSTest02 (void) { +static int StreamTcp4WHSTest02 (void) +{ int ret = 0; Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) @@ -7024,7 +7056,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcp4WHSTest03 (void) { +static int StreamTcp4WHSTest03 (void) +{ int ret = 0; Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) @@ -7104,7 +7137,8 @@ end: * \retval On success it returns 1 and on failure 0 */ -static int StreamTcpTest15 (void) { +static int StreamTcpTest15 (void) +{ Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) return 0; @@ -7275,7 +7309,8 @@ end: * \retval On success it returns 1 and on failure 0 */ -static int StreamTcpTest16 (void) { +static int StreamTcpTest16 (void) +{ Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) return 0; @@ -7447,7 +7482,8 @@ end: * \retval On success it returns 1 and on failure 0 */ -static int StreamTcpTest17 (void) { +static int StreamTcpTest17 (void) +{ Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) return 0; @@ -7613,7 +7649,8 @@ end: /** \test Test the various OS policies based on different IP addresses from confuguration defined in 'dummy_conf_string1' */ -static int StreamTcpTest18 (void) { +static int StreamTcpTest18 (void) +{ struct in_addr addr; char os_policy_name[10] = "windows"; @@ -7661,7 +7698,8 @@ end: } /** \test Test the various OS policies based on different IP addresses from confuguration defined in 'dummy_conf_string1' */ -static int StreamTcpTest19 (void) { +static int StreamTcpTest19 (void) +{ struct in_addr addr; char os_policy_name[10] = "windows"; @@ -7712,7 +7750,8 @@ end: } /** \test Test the various OS policies based on different IP addresses from confuguration defined in 'dummy_conf_string1' */ -static int StreamTcpTest20 (void) { +static int StreamTcpTest20 (void) +{ struct in_addr addr; char os_policy_name[10] = "linux"; @@ -7763,7 +7802,8 @@ end: } /** \test Test the various OS policies based on different IP addresses from confuguration defined in 'dummy_conf_string1' */ -static int StreamTcpTest21 (void) { +static int StreamTcpTest21 (void) +{ struct in_addr addr; char os_policy_name[10] = "linux"; @@ -7814,7 +7854,8 @@ end: } /** \test Test the various OS policies based on different IP addresses from confuguration defined in 'dummy_conf_string1' */ -static int StreamTcpTest22 (void) { +static int StreamTcpTest22 (void) +{ struct in_addr addr; char os_policy_name[10] = "windows"; @@ -8045,7 +8086,8 @@ end: * * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpTest25(void) { +static int StreamTcpTest25(void) +{ Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) return 0; @@ -8144,7 +8186,8 @@ end: * * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpTest26(void) { +static int StreamTcpTest26(void) +{ Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) return 0; @@ -8239,7 +8282,8 @@ end: * * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpTest27(void) { +static int StreamTcpTest27(void) +{ Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) return 0; @@ -8816,7 +8860,8 @@ end: * * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpTest32(void) { +static int StreamTcpTest32(void) +{ Packet p; Flow f; ThreadVars tv; @@ -8906,7 +8951,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpTest33 (void) { +static int StreamTcpTest33 (void) +{ Packet p; Flow f; ThreadVars tv; @@ -9007,7 +9053,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpTest34 (void) { +static int StreamTcpTest34 (void) +{ Packet p; Flow f; ThreadVars tv; @@ -9072,7 +9119,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpTest35 (void) { +static int StreamTcpTest35 (void) +{ Packet p; Flow f; ThreadVars tv; @@ -9135,7 +9183,8 @@ end: * * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpTest36(void) { +static int StreamTcpTest36(void) +{ Packet p; Flow f; ThreadVars tv; @@ -9225,7 +9274,8 @@ end: * * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpTest37(void) { +static int StreamTcpTest37(void) +{ Packet *p = SCMalloc(SIZE_OF_PACKET); if (unlikely(p == NULL)) return 0; @@ -9349,7 +9399,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpTest38 (void) { +static int StreamTcpTest38 (void) +{ int ret = 0; Flow f; ThreadVars tv; @@ -9465,7 +9516,8 @@ end: * \retval On success it returns 1 and on failure 0. */ -static int StreamTcpTest39 (void) { +static int StreamTcpTest39 (void) +{ Flow f; ThreadVars tv; StreamTcpThread stt; @@ -9575,7 +9627,8 @@ end: return ret; } -static int StreamTcpTest40(void) { +static int StreamTcpTest40(void) +{ uint8_t raw_vlan[] = { 0x00, 0x20, 0x08, 0x00, 0x45, 0x00, 0x00, 0x34, 0x3b, 0x36, 0x40, 0x00, 0x40, 0x06, 0xb7, 0xc9, @@ -9632,7 +9685,8 @@ static int StreamTcpTest40(void) { return 1; } -static int StreamTcpTest41(void) { +static int StreamTcpTest41(void) +{ /* IPV6/TCP/no eth header */ uint8_t raw_ip[] = { 0x60, 0x00, 0x00, 0x00, 0x00, 0x28, 0x06, 0x40, @@ -9699,7 +9753,8 @@ static int StreamTcpTest41(void) { } /** \test multiple different SYN/ACK, pick first */ -static int StreamTcpTest42 (void) { +static int StreamTcpTest42 (void) +{ int ret = 0; Flow f; ThreadVars tv; @@ -9790,7 +9845,8 @@ end: } /** \test multiple different SYN/ACK, pick second */ -static int StreamTcpTest43 (void) { +static int StreamTcpTest43 (void) +{ int ret = 0; Flow f; ThreadVars tv; @@ -9881,7 +9937,8 @@ end: } /** \test multiple different SYN/ACK, pick neither */ -static int StreamTcpTest44 (void) { +static int StreamTcpTest44 (void) +{ int ret = 0; Flow f; ThreadVars tv; @@ -9967,7 +10024,8 @@ end: } /** \test multiple different SYN/ACK, over the limit */ -static int StreamTcpTest45 (void) { +static int StreamTcpTest45 (void) +{ int ret = 0; Flow f; ThreadVars tv; @@ -10078,7 +10136,8 @@ end: #endif /* UNITTESTS */ -void StreamTcpRegisterTests (void) { +void StreamTcpRegisterTests (void) +{ #ifdef UNITTESTS UtRegisterTest("StreamTcpTest01 -- TCP session allocation", StreamTcpTest01, 1); diff --git a/src/stream-tcp.h b/src/stream-tcp.h index ce8c2f0b64..71c9f1858a 100644 --- a/src/stream-tcp.h +++ b/src/stream-tcp.h @@ -134,7 +134,8 @@ void StreamTcpReassembleConfigEnableOverlapCheck(void); * \retval 1 if we must drop this stream * \retval 0 if the stream still legal */ -static inline int StreamTcpCheckFlowDrops(Packet *p) { +static inline int StreamTcpCheckFlowDrops(Packet *p) +{ /* If we are on IPS mode, and got a drop action triggered from * the IP only module, or from a reassembled msg and/or from an * applayer detection, then drop the rest of the packets of the diff --git a/src/stream.c b/src/stream.c index 34d122d49b..6d77890bbb 100644 --- a/src/stream.c +++ b/src/stream.c @@ -45,7 +45,8 @@ static uint16_t toclient_min_chunk_len = 2560; static Pool *stream_msg_pool = NULL; static SCMutex stream_msg_pool_mutex = SCMUTEX_INITIALIZER; -static void StreamMsgEnqueue (StreamMsgQueue *q, StreamMsg *s) { +static void StreamMsgEnqueue (StreamMsgQueue *q, StreamMsg *s) +{ SCEnter(); SCLogDebug("s %p", s); /* more packets in queue */ @@ -66,7 +67,8 @@ static void StreamMsgEnqueue (StreamMsgQueue *q, StreamMsg *s) { SCReturn; } -static StreamMsg *StreamMsgDequeue (StreamMsgQueue *q) { +static StreamMsg *StreamMsgDequeue (StreamMsgQueue *q) +{ SCEnter(); /* if the queue is empty there are no packets left. @@ -104,7 +106,8 @@ StreamMsg *StreamMsgGetFromPool(void) } /* Used by l7inspection to return msgs to pool */ -void StreamMsgReturnToPool(StreamMsg *s) { +void StreamMsgReturnToPool(StreamMsg *s) +{ SCLogDebug("s %p", s); SCMutexLock(&stream_msg_pool_mutex); PoolReturn(stream_msg_pool, (void *)s); @@ -130,7 +133,8 @@ void StreamMsgPutInQueue(StreamMsgQueue *q, StreamMsg *s) SCLogDebug("q->len %" PRIu32 "", q->len); } -void *StreamMsgPoolAlloc(void) { +void *StreamMsgPoolAlloc(void) +{ if (StreamTcpReassembleCheckMemcap((uint32_t)sizeof(StreamMsg)) == 0) return NULL; @@ -154,14 +158,16 @@ int StreamMsgInit(void *data, void *initdata) return 1; } -void StreamMsgPoolFree(void *ptr) { +void StreamMsgPoolFree(void *ptr) +{ if (ptr) { SCFree(ptr); StreamTcpReassembleDecrMemuse((uint32_t)sizeof(StreamMsg)); } } -void StreamMsgQueuesInit(uint32_t prealloc) { +void StreamMsgQueuesInit(uint32_t prealloc) +{ #ifdef DEBUG SCMutexInit(&stream_pool_memuse_mutex, NULL); #endif @@ -174,7 +180,8 @@ void StreamMsgQueuesInit(uint32_t prealloc) { SCMutexUnlock(&stream_msg_pool_mutex); } -void StreamMsgQueuesDeinit(char quiet) { +void StreamMsgQueuesDeinit(char quiet) +{ if (quiet == FALSE) { if (stream_msg_pool->max_outstanding > stream_msg_pool->allocated) SCLogInfo("TCP segment chunk pool had a peak use of %u chunks, " @@ -196,7 +203,8 @@ void StreamMsgQueuesDeinit(char quiet) { /** \brief alloc a stream msg queue * \retval smq ptr to the queue or NULL */ -StreamMsgQueue *StreamMsgQueueGetNew(void) { +StreamMsgQueue *StreamMsgQueueGetNew(void) +{ if (StreamTcpReassembleCheckMemcap((uint32_t)sizeof(StreamMsgQueue)) == 0) return NULL; @@ -214,17 +222,20 @@ StreamMsgQueue *StreamMsgQueueGetNew(void) { * \param q the queue to free * \todo we may want to consider non empty queue's */ -void StreamMsgQueueFree(StreamMsgQueue *q) { +void StreamMsgQueueFree(StreamMsgQueue *q) +{ SCFree(q); StreamTcpReassembleDecrMemuse((uint32_t)sizeof(StreamMsgQueue)); } -StreamMsgQueue *StreamMsgQueueGetByPort(uint16_t port) { +StreamMsgQueue *StreamMsgQueueGetByPort(uint16_t port) +{ /* XXX implement this */ return NULL;//&stream_q; } -void StreamMsgQueueSetMinChunkLen(uint8_t dir, uint16_t len) { +void StreamMsgQueueSetMinChunkLen(uint8_t dir, uint16_t len) +{ if (dir == FLOW_PKT_TOSERVER) { toserver_min_chunk_len = len; } else { @@ -232,7 +243,8 @@ void StreamMsgQueueSetMinChunkLen(uint8_t dir, uint16_t len) { } } -uint16_t StreamMsgQueueGetMinChunkLen(uint8_t dir) { +uint16_t StreamMsgQueueGetMinChunkLen(uint8_t dir) +{ if (dir == FLOW_PKT_TOSERVER) { return toserver_min_chunk_len; } else { @@ -241,7 +253,8 @@ uint16_t StreamMsgQueueGetMinChunkLen(uint8_t dir) { } /** \brief Return a list of smsgs to the pool */ -void StreamMsgReturnListToPool(void *list) { +void StreamMsgReturnListToPool(void *list) +{ /* if we have (a) smsg(s), return to the pool */ StreamMsg *smsg = (StreamMsg *)list; while (smsg != NULL) { diff --git a/src/suricata.c b/src/suricata.c index a804b54447..5f96ac410a 100644 --- a/src/suricata.c +++ b/src/suricata.c @@ -242,7 +242,8 @@ void EngineModeSetIDS(void) g_engine_mode = ENGINE_MODE_IDS; } -int RunmodeIsUnittests(void) { +int RunmodeIsUnittests(void) +{ if (run_mode == RUNMODE_UNITTEST) return 1; @@ -254,11 +255,13 @@ int RunmodeGetCurrent(void) return run_mode; } -static void SignalHandlerSigint(/*@unused@*/ int sig) { +static void SignalHandlerSigint(/*@unused@*/ int sig) +{ sigint_count = 1; suricata_ctl_flags |= SURICATA_STOP; } -static void SignalHandlerSigterm(/*@unused@*/ int sig) { +static void SignalHandlerSigterm(/*@unused@*/ int sig) +{ sigterm_count = 1; suricata_ctl_flags |= SURICATA_KILL; } @@ -325,7 +328,8 @@ void SignalHandlerSigusr2(int sig) * SIGHUP handler. Just set sighup_count. The main loop will act on * it. */ -static void SignalHandlerSigHup(/*@unused@*/ int sig) { +static void SignalHandlerSigHup(/*@unused@*/ int sig) +{ sighup_count = 1; } @@ -384,11 +388,13 @@ void GlobalInits() /* XXX hack: make sure threads can stop the engine by calling this function. Purpose: pcap file mode needs to be able to tell the engine the file eof is reached. */ -void EngineStop(void) { +void EngineStop(void) +{ suricata_ctl_flags |= SURICATA_STOP; } -void EngineKill(void) { +void EngineKill(void) +{ suricata_ctl_flags |= SURICATA_KILL; } @@ -398,11 +404,13 @@ void EngineKill(void) { * This is mainly used by pcap-file to tell it has finished * to treat a pcap files when running in unix-socket mode. */ -void EngineDone(void) { +void EngineDone(void) +{ suricata_ctl_flags |= SURICATA_DONE; } -static int SetBpfString(int optind, char *argv[]) { +static int SetBpfString(int optind, char *argv[]) +{ char *bpf_filter = NULL; uint32_t bpf_len = 0; int tmpindex = 0; @@ -449,7 +457,8 @@ static int SetBpfString(int optind, char *argv[]) { return TM_ECODE_OK; } -static void SetBpfStringFromFile(char *filename) { +static void SetBpfStringFromFile(char *filename) +{ char *bpf_filter = NULL; char *bpf_comment_tmp = NULL; char *bpf_comment_start = NULL; @@ -619,7 +628,8 @@ void usage(const char *progname) progname); } -void SCPrintBuildInfo(void) { +void SCPrintBuildInfo(void) +{ char *bits = "-bits"; char *endian = "-endian"; char features[2048] = ""; @@ -888,7 +898,8 @@ void RegisterAllModules() } -TmEcode LoadYamlConfig(char *conf_filename) { +TmEcode LoadYamlConfig(char *conf_filename) +{ SCEnter(); if (conf_filename == NULL) diff --git a/src/threads.c b/src/threads.c index 2b2c919d11..3298901573 100644 --- a/src/threads.c +++ b/src/threads.c @@ -35,7 +35,8 @@ /** * \brief Test Mutex macros */ -int ThreadMacrosTest01Mutex(void) { +int ThreadMacrosTest01Mutex(void) +{ SCMutex mut; int r = 0; r |= SCMutexInit(&mut, NULL); @@ -62,7 +63,8 @@ int ThreadMacrosTest01Mutex(void) { * if a spinlock is actually locked. * */ -int ThreadMacrosTest02Spinlocks(void) { +int ThreadMacrosTest02Spinlocks(void) +{ SCSpinlock mut; int r = 0; r |= SCSpinInit(&mut, 0); @@ -81,7 +83,8 @@ int ThreadMacrosTest02Spinlocks(void) { /** * \brief Test RWLock macros */ -int ThreadMacrosTest03RWLocks(void) { +int ThreadMacrosTest03RWLocks(void) +{ SCRWLock rwl_write; int r = 0; r |= SCRWLockInit(&rwl_write, NULL); @@ -96,7 +99,8 @@ int ThreadMacrosTest03RWLocks(void) { /** * \brief Test RWLock macros */ -int ThreadMacrosTest04RWLocks(void) { +int ThreadMacrosTest04RWLocks(void) +{ SCRWLock rwl_read; int r = 0; r |= SCRWLockInit(&rwl_read, NULL); @@ -111,7 +115,8 @@ int ThreadMacrosTest04RWLocks(void) { /** * \brief Test RWLock macros */ -int ThreadMacrosTest05RWLocks(void) { +int ThreadMacrosTest05RWLocks(void) +{ SCRWLock rwl_read; int r = 0; r |= SCRWLockInit(&rwl_read, NULL); diff --git a/src/tm-modules.c b/src/tm-modules.c index b52a0daa73..40ce0dfc07 100644 --- a/src/tm-modules.c +++ b/src/tm-modules.c @@ -30,7 +30,8 @@ #include "threads.h" #include "util-logopenfile.h" -void TmModuleDebugList(void) { +void TmModuleDebugList(void) +{ TmModule *t; uint16_t i; @@ -47,7 +48,8 @@ void TmModuleDebugList(void) { /** \brief get a tm module ptr by name * \param name name string * \retval ptr to the module or NULL */ -TmModule *TmModuleGetByName(const char *name) { +TmModule *TmModuleGetByName(const char *name) +{ TmModule *t; uint16_t i; @@ -67,7 +69,8 @@ TmModule *TmModuleGetByName(const char *name) { /** \brief get the id of a module from it's name * \param name registered name of the module * \retval id the id or -1 in case of error */ -int TmModuleGetIdByName(const char *name) { +int TmModuleGetIdByName(const char *name) +{ TmModule *tm = TmModuleGetByName(name); if (tm == NULL) return -1;; @@ -120,7 +123,8 @@ int TmModuleGetIDForTM(TmModule *tm) } -void TmModuleRunInit(void) { +void TmModuleRunInit(void) +{ TmModule *t; uint16_t i; @@ -137,7 +141,8 @@ void TmModuleRunInit(void) { } } -void TmModuleRunDeInit(void) { +void TmModuleRunDeInit(void) +{ TmModule *t; uint16_t i; @@ -155,7 +160,8 @@ void TmModuleRunDeInit(void) { } /** \brief register all unittests for the tm modules */ -void TmModuleRegisterTests(void) { +void TmModuleRegisterTests(void) +{ #ifdef UNITTESTS TmModule *t; uint16_t i; diff --git a/src/tm-queuehandlers.c b/src/tm-queuehandlers.c index f2c62cfc50..007a8ab370 100644 --- a/src/tm-queuehandlers.c +++ b/src/tm-queuehandlers.c @@ -36,7 +36,8 @@ #include "tmqh-flow.h" #include "tmqh-ringbuffer.h" -void TmqhSetup (void) { +void TmqhSetup (void) +{ memset(&tmqh_table, 0, sizeof(tmqh_table)); TmqhSimpleRegister(); @@ -47,11 +48,13 @@ void TmqhSetup (void) { } /** \brief Clean up registration time allocs */ -void TmqhCleanup(void) { +void TmqhCleanup(void) +{ TmqhRingBufferDestroy(); } -Tmqh* TmqhGetQueueHandlerByName(char *name) { +Tmqh* TmqhGetQueueHandlerByName(char *name) +{ int i; for (i = 0; i < TMQH_SIZE; i++) { diff --git a/src/tm-queues.c b/src/tm-queues.c index 673e8363e9..e549a975c7 100644 --- a/src/tm-queues.c +++ b/src/tm-queues.c @@ -33,7 +33,8 @@ static uint16_t tmq_id = 0; static Tmq tmqs[TMQ_MAX_QUEUES]; -Tmq* TmqAlloc(void) { +Tmq* TmqAlloc(void) +{ Tmq *q = SCMalloc(sizeof(Tmq)); if (unlikely(q == NULL)) goto error; @@ -45,7 +46,8 @@ error: return NULL; } -Tmq* TmqCreateQueue(char *name) { +Tmq* TmqCreateQueue(char *name) +{ if (tmq_id >= TMQ_MAX_QUEUES) goto error; @@ -63,7 +65,8 @@ error: return NULL; } -Tmq* TmqGetQueueByName(char *name) { +Tmq* TmqGetQueueByName(char *name) +{ uint16_t i; for (i = 0; i < tmq_id; i++) { @@ -74,7 +77,8 @@ Tmq* TmqGetQueueByName(char *name) { return NULL; } -void TmqDebugList(void) { +void TmqDebugList(void) +{ uint16_t i = 0; for (i = 0; i < tmq_id; i++) { /* get a lock accessing the len */ @@ -84,7 +88,8 @@ void TmqDebugList(void) { } } -void TmqResetQueues(void) { +void TmqResetQueues(void) +{ memset(&tmqs, 0x00, sizeof(tmqs)); tmq_id = 0; } diff --git a/src/tm-threads.c b/src/tm-threads.c index 93c7c1c7d4..7cd06e9ea5 100644 --- a/src/tm-threads.c +++ b/src/tm-threads.c @@ -645,7 +645,8 @@ TmEcode TmThreadsSlotVarRun(ThreadVars *tv, Packet *p, */ -void *TmThreadsSlotPktAcqLoop(void *td) { +void *TmThreadsSlotPktAcqLoop(void *td) +{ /* block usr2. usr2 to be handled by the main thread only */ UtilSignalBlock(SIGUSR2); @@ -1111,7 +1112,8 @@ static inline TmSlot * _TmSlotSetFuncAppend(ThreadVars *tv, TmModule *tm, void * return slot; } -void TmSlotFree(TmSlot *tms) { +void TmSlotFree(TmSlot *tms) +{ SC_ATOMIC_DESTROY(tms->slot_data); SCFree(tms); } @@ -1248,7 +1250,8 @@ TmSlot *TmSlotGetSlotForTM(int tm_id) } #if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ -static int SetCPUAffinitySet(cpu_set_t *cs) { +static int SetCPUAffinitySet(cpu_set_t *cs) +{ #if defined OS_FREEBSD int r = cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, SCGetThreadIdLong(), sizeof(cpu_set_t),cs); diff --git a/src/tmqh-nfq.c b/src/tmqh-nfq.c index e423015401..90b9e77a2f 100644 --- a/src/tmqh-nfq.c +++ b/src/tmqh-nfq.c @@ -33,7 +33,8 @@ void TmqhOutputVerdictNfq(ThreadVars *t, Packet *p); -void TmqhNfqRegister (void) { +void TmqhNfqRegister (void) +{ tmqh_table[TMQH_NFQ].name = "nfq"; tmqh_table[TMQH_NFQ].InHandler = NULL; tmqh_table[TMQH_NFQ].OutHandler = TmqhOutputVerdictNfq; diff --git a/src/tmqh-packetpool.c b/src/tmqh-packetpool.c index 36c2047fa8..0729d270c6 100644 --- a/src/tmqh-packetpool.c +++ b/src/tmqh-packetpool.c @@ -124,7 +124,8 @@ static inline PktPool *GetThreadPacketPool(void) * \brief TmqhPacketpoolRegister * \initonly */ -void TmqhPacketpoolRegister (void) { +void TmqhPacketpoolRegister (void) +{ tmqh_table[TMQH_PACKETPOOL].name = "packetpool"; tmqh_table[TMQH_PACKETPOOL].InHandler = TmqhInputPacketpool; tmqh_table[TMQH_PACKETPOOL].OutHandler = TmqhOutputPacketpool; diff --git a/src/tmqh-ringbuffer.c b/src/tmqh-ringbuffer.c index 8c5c95caad..95c8c08b1e 100644 --- a/src/tmqh-ringbuffer.c +++ b/src/tmqh-ringbuffer.c @@ -47,7 +47,8 @@ void TmqhInputRingBufferShutdownHandler(ThreadVars *); * \brief TmqhRingBufferRegister * \initonly */ -void TmqhRingBufferRegister (void) { +void TmqhRingBufferRegister (void) +{ tmqh_table[TMQH_RINGBUFFER_MRSW].name = "ringbuffer_mrsw"; tmqh_table[TMQH_RINGBUFFER_MRSW].InHandler = TmqhInputRingBufferMrSw; tmqh_table[TMQH_RINGBUFFER_MRSW].InShutdownHandler = TmqhInputRingBufferShutdownHandler; @@ -75,14 +76,16 @@ void TmqhRingBufferRegister (void) { } } -void TmqhRingBufferDestroy (void) { +void TmqhRingBufferDestroy (void) +{ int i = 0; for (i = 0; i < 256; i++) { RingBuffer8Destroy(ringbuffers[i]); } } -void TmqhInputRingBufferShutdownHandler(ThreadVars *tv) { +void TmqhInputRingBufferShutdownHandler(ThreadVars *tv) +{ if (tv == NULL || tv->inq == NULL) { return; } diff --git a/src/tmqh-simple.c b/src/tmqh-simple.c index b7dfd44969..26aea2adc2 100644 --- a/src/tmqh-simple.c +++ b/src/tmqh-simple.c @@ -35,7 +35,8 @@ Packet *TmqhInputSimple(ThreadVars *t); void TmqhOutputSimple(ThreadVars *t, Packet *p); void TmqhInputSimpleShutdownHandler(ThreadVars *); -void TmqhSimpleRegister (void) { +void TmqhSimpleRegister (void) +{ tmqh_table[TMQH_SIMPLE].name = "simple"; tmqh_table[TMQH_SIMPLE].InHandler = TmqhInputSimple; tmqh_table[TMQH_SIMPLE].InShutdownHandler = TmqhInputSimpleShutdownHandler; @@ -66,7 +67,8 @@ Packet *TmqhInputSimple(ThreadVars *t) } } -void TmqhInputSimpleShutdownHandler(ThreadVars *tv) { +void TmqhInputSimpleShutdownHandler(ThreadVars *tv) +{ int i; if (tv == NULL || tv->inq == NULL) { diff --git a/src/util-action.c b/src/util-action.c index 4c3a8cfb91..583e371ab8 100644 --- a/src/util-action.c +++ b/src/util-action.c @@ -1554,7 +1554,8 @@ end: #endif /* Register unittests */ -void UtilActionRegisterTests(void) { +void UtilActionRegisterTests(void) +{ #ifdef UNITTESTS /* Generic tests */ UtRegisterTest("UtilActionTest01", UtilActionTest01, 1); diff --git a/src/util-affinity.c b/src/util-affinity.c index 875da6ff89..82456c20cd 100644 --- a/src/util-affinity.c +++ b/src/util-affinity.c @@ -89,7 +89,8 @@ int thread_affinity_init_done = 0; * \brief find affinity by its name * \retval a pointer to the affinity or NULL if not found */ -ThreadsAffinityType * GetAffinityTypeFromName(const char *name) { +ThreadsAffinityType * GetAffinityTypeFromName(const char *name) +{ int i; for (i = 0; i < MAX_CPU_SET; i++) { if (!strcmp(thread_affinity[i].name, name)) { diff --git a/src/util-bloomfilter-counting.c b/src/util-bloomfilter-counting.c index 4e44e68ef2..443b8d79e9 100644 --- a/src/util-bloomfilter-counting.c +++ b/src/util-bloomfilter-counting.c @@ -75,7 +75,8 @@ error: return NULL; } -void BloomFilterCountingFree(BloomFilterCounting *bf) { +void BloomFilterCountingFree(BloomFilterCounting *bf) +{ if (bf != NULL) { if (bf->array != NULL) SCFree(bf->array); @@ -84,7 +85,8 @@ void BloomFilterCountingFree(BloomFilterCounting *bf) { } } -void BloomFilterCountingPrint(BloomFilterCounting *bf) { +void BloomFilterCountingPrint(BloomFilterCounting *bf) +{ printf("\n------ Counting Bloom Filter Stats ------\n"); printf("Buckets: %" PRIu32 "\n", bf->array_size); printf("Counter size: %" PRIu32 "\n", bf->type); @@ -94,7 +96,8 @@ void BloomFilterCountingPrint(BloomFilterCounting *bf) { printf("-----------------------------------------\n"); } -int BloomFilterCountingAdd(BloomFilterCounting *bf, void *data, uint16_t datalen) { +int BloomFilterCountingAdd(BloomFilterCounting *bf, void *data, uint16_t datalen) +{ uint8_t iter = 0; uint32_t hash = 0; @@ -121,7 +124,8 @@ int BloomFilterCountingAdd(BloomFilterCounting *bf, void *data, uint16_t datalen return 0; } -int BloomFilterCountingRemove(BloomFilterCounting *bf, void *data, uint16_t datalen) { +int BloomFilterCountingRemove(BloomFilterCounting *bf, void *data, uint16_t datalen) +{ uint8_t iter = 0; uint32_t hash = 0; @@ -176,7 +180,8 @@ 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, void *data, uint16_t datalen) +{ uint8_t iter = 0; uint32_t hash = 0; int hit = 1; @@ -213,7 +218,8 @@ 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(void *data, uint16_t datalen, uint8_t iter, uint32_t hash_size) +{ uint8_t *d = (uint8_t *)data; uint32_t i; uint32_t hash = 0; @@ -229,7 +235,8 @@ static uint32_t BloomHash(void *data, uint16_t datalen, uint8_t iter, uint32_t h return hash; } -static int BloomFilterCountingTestInit01 (void) { +static int BloomFilterCountingTestInit01 (void) +{ BloomFilterCounting *bf = BloomFilterCountingInit(1024, 4, 4, BloomHash); if (bf == NULL) return 0; @@ -239,7 +246,8 @@ static int BloomFilterCountingTestInit01 (void) { } /* no hash function, so it should fail */ -static int BloomFilterCountingTestInit02 (void) { +static int BloomFilterCountingTestInit02 (void) +{ BloomFilterCounting *bf = BloomFilterCountingInit(1024, 4, 4, NULL); if (bf == NULL) return 1; @@ -248,7 +256,8 @@ static int BloomFilterCountingTestInit02 (void) { return 0; } -static int BloomFilterCountingTestInit03 (void) { +static int BloomFilterCountingTestInit03 (void) +{ int result = 0; BloomFilterCounting *bf = BloomFilterCountingInit(1024, 4, 4, BloomHash); if (bf == NULL) @@ -261,7 +270,8 @@ static int BloomFilterCountingTestInit03 (void) { return result; } -static int BloomFilterCountingTestInit04 (void) { +static int BloomFilterCountingTestInit04 (void) +{ BloomFilterCounting *bf = BloomFilterCountingInit(1024, 0, 4, BloomHash); if (bf == NULL) return 1; @@ -270,7 +280,8 @@ static int BloomFilterCountingTestInit04 (void) { return 0; } -static int BloomFilterCountingTestInit05 (void) { +static int BloomFilterCountingTestInit05 (void) +{ BloomFilterCounting *bf = BloomFilterCountingInit(0, 4, 4, BloomHash); if (bf == NULL) return 1; @@ -279,7 +290,8 @@ static int BloomFilterCountingTestInit05 (void) { return 0; } -static int BloomFilterCountingTestInit06 (void) { +static int BloomFilterCountingTestInit06 (void) +{ BloomFilterCounting *bf = BloomFilterCountingInit(32, 3, 4, BloomHash); if (bf == NULL) return 1; @@ -288,7 +300,8 @@ static int BloomFilterCountingTestInit06 (void) { return 0; } -static int BloomFilterCountingTestAdd01 (void) { +static int BloomFilterCountingTestAdd01 (void) +{ int result = 0; BloomFilterCounting *bf = BloomFilterCountingInit(1024, 4, 4, BloomHash); if (bf == NULL) @@ -305,7 +318,8 @@ end: return result; } -static int BloomFilterCountingTestAdd02 (void) { +static int BloomFilterCountingTestAdd02 (void) +{ int result = 0; BloomFilterCounting *bf = BloomFilterCountingInit(1024, 4, 4, BloomHash); if (bf == NULL) @@ -322,7 +336,8 @@ end: return result; } -static int BloomFilterCountingTestFull01 (void) { +static int BloomFilterCountingTestFull01 (void) +{ int result = 0; BloomFilterCounting *bf = BloomFilterCountingInit(32, 4, 4, BloomHash); if (bf == NULL) { @@ -356,7 +371,8 @@ end: return result; } -static int BloomFilterCountingTestFull02 (void) { +static int BloomFilterCountingTestFull02 (void) +{ int result = 0; BloomFilterCounting *bf = BloomFilterCountingInit(32, 4, 4, BloomHash); if (bf == NULL) @@ -374,7 +390,8 @@ end: } #endif -void BloomFilterCountingRegisterTests(void) { +void BloomFilterCountingRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("BloomFilterCountingTestInit01", BloomFilterCountingTestInit01, 1); UtRegisterTest("BloomFilterCountingTestInit02", BloomFilterCountingTestInit02, 1); diff --git a/src/util-bloomfilter.c b/src/util-bloomfilter.c index b2c9553dcb..5718fb1002 100644 --- a/src/util-bloomfilter.c +++ b/src/util-bloomfilter.c @@ -65,7 +65,8 @@ error: return NULL; } -void BloomFilterFree(BloomFilter *bf) { +void BloomFilterFree(BloomFilter *bf) +{ if (bf != NULL) { if (bf->bitarray != NULL) SCFree(bf->bitarray); @@ -74,7 +75,8 @@ void BloomFilterFree(BloomFilter *bf) { } } -void BloomFilterPrint(BloomFilter *bf) { +void BloomFilterPrint(BloomFilter *bf) +{ printf("\n---------- Bloom Filter Stats -----------\n"); printf("Buckets: %" PRIu32 "\n", bf->bitarray_size); printf("Memory size: %" PRIu32 " bytes\n", bf->bitarray_size/8 + 1); @@ -83,7 +85,8 @@ void BloomFilterPrint(BloomFilter *bf) { printf("-----------------------------------------\n"); } -int BloomFilterAdd(BloomFilter *bf, void *data, uint16_t datalen) { +int BloomFilterAdd(BloomFilter *bf, void *data, uint16_t datalen) +{ uint8_t iter = 0; uint32_t hash = 0; @@ -98,14 +101,16 @@ int BloomFilterAdd(BloomFilter *bf, void *data, uint16_t datalen) { return 0; } -uint32_t BloomFilterMemoryCnt(BloomFilter *bf) { +uint32_t BloomFilterMemoryCnt(BloomFilter *bf) +{ if (bf == NULL) return 0; return 2; } -uint32_t BloomFilterMemorySize(BloomFilter *bf) { +uint32_t BloomFilterMemorySize(BloomFilter *bf) +{ if (bf == NULL) return 0; @@ -117,7 +122,8 @@ uint32_t BloomFilterMemorySize(BloomFilter *bf) { */ #ifdef UNITTESTS -static uint32_t BloomFilterTestHash(void *data, uint16_t datalen, uint8_t iter, uint32_t hash_size) { +static uint32_t BloomFilterTestHash(void *data, uint16_t datalen, uint8_t iter, uint32_t hash_size) +{ uint8_t *d = (uint8_t *)data; uint32_t i; uint32_t hash = 0; @@ -133,7 +139,8 @@ static uint32_t BloomFilterTestHash(void *data, uint16_t datalen, uint8_t iter, return hash; } -static int BloomFilterTestInit01 (void) { +static int BloomFilterTestInit01 (void) +{ BloomFilter *bf = BloomFilterInit(1024, 4, BloomFilterTestHash); if (bf == NULL) return 0; @@ -143,7 +150,8 @@ static int BloomFilterTestInit01 (void) { } /* no hash function, so it should fail */ -static int BloomFilterTestInit02 (void) { +static int BloomFilterTestInit02 (void) +{ BloomFilter *bf = BloomFilterInit(1024, 4, NULL); if (bf == NULL) return 1; @@ -152,7 +160,8 @@ static int BloomFilterTestInit02 (void) { return 0; } -static int BloomFilterTestInit03 (void) { +static int BloomFilterTestInit03 (void) +{ int result = 0; BloomFilter *bf = BloomFilterInit(1024, 4, BloomFilterTestHash); if (bf == NULL) @@ -165,7 +174,8 @@ static int BloomFilterTestInit03 (void) { return result; } -static int BloomFilterTestInit04 (void) { +static int BloomFilterTestInit04 (void) +{ BloomFilter *bf = BloomFilterInit(1024, 0, BloomFilterTestHash); if (bf == NULL) return 1; @@ -174,7 +184,8 @@ static int BloomFilterTestInit04 (void) { return 0; } -static int BloomFilterTestInit05 (void) { +static int BloomFilterTestInit05 (void) +{ BloomFilter *bf = BloomFilterInit(0, 4, BloomFilterTestHash); if (bf == NULL) return 1; @@ -183,7 +194,8 @@ static int BloomFilterTestInit05 (void) { return 0; } -static int BloomFilterTestAdd01 (void) { +static int BloomFilterTestAdd01 (void) +{ int result = 0; BloomFilter *bf = BloomFilterInit(1024, 4, BloomFilterTestHash); if (bf == NULL) @@ -200,7 +212,8 @@ end: return result; } -static int BloomFilterTestAdd02 (void) { +static int BloomFilterTestAdd02 (void) +{ int result = 0; BloomFilter *bf = BloomFilterInit(1024, 4, BloomFilterTestHash); if (bf == NULL) @@ -217,7 +230,8 @@ end: return result; } -static int BloomFilterTestFull01 (void) { +static int BloomFilterTestFull01 (void) +{ int result = 0; BloomFilter *bf = BloomFilterInit(32, 4, BloomFilterTestHash); if (bf == NULL) @@ -238,7 +252,8 @@ end: return result; } -static int BloomFilterTestFull02 (void) { +static int BloomFilterTestFull02 (void) +{ int result = 0; BloomFilter *bf = BloomFilterInit(32, 4, BloomFilterTestHash); if (bf == NULL) @@ -256,7 +271,8 @@ end: } #endif /* UNITTESTS */ -void BloomFilterRegisterTests(void) { +void BloomFilterRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("BloomFilterTestInit01", BloomFilterTestInit01, 1); UtRegisterTest("BloomFilterTestInit02", BloomFilterTestInit02, 1); diff --git a/src/util-bloomfilter.h b/src/util-bloomfilter.h index 7779092ad4..e7a5874f61 100644 --- a/src/util-bloomfilter.h +++ b/src/util-bloomfilter.h @@ -46,7 +46,8 @@ void BloomFilterRegisterTests(void); static inline int BloomFilterTest(BloomFilter *, void *, uint16_t); -static inline int BloomFilterTest(BloomFilter *bf, void *data, uint16_t datalen) { +static inline int BloomFilterTest(BloomFilter *bf, void *data, uint16_t datalen) +{ uint8_t iter = 0; uint32_t hash = 0; int hit = 1; diff --git a/src/util-byte.c b/src/util-byte.c index 352cdeaf01..6f0cd13231 100644 --- a/src/util-byte.c +++ b/src/util-byte.c @@ -378,7 +378,8 @@ int ByteExtractStringInt8(int8_t *res, int base, uint16_t len, const char *str) /* UNITTESTS */ #ifdef UNITTESTS -static int ByteTest01 (void) { +static int ByteTest01 (void) +{ uint16_t val = 0x0102; uint16_t i16 = 0xbfbf; uint8_t bytes[2] = { 0x02, 0x01 }; @@ -391,7 +392,8 @@ static int ByteTest01 (void) { return 0; } -static int ByteTest02 (void) { +static int ByteTest02 (void) +{ uint16_t val = 0x0102; uint16_t i16 = 0xbfbf; uint8_t bytes[2] = { 0x01, 0x02 }; @@ -404,7 +406,8 @@ static int ByteTest02 (void) { return 0; } -static int ByteTest03 (void) { +static int ByteTest03 (void) +{ uint32_t val = 0x01020304; uint32_t i32 = 0xbfbfbfbf; uint8_t bytes[4] = { 0x04, 0x03, 0x02, 0x01 }; @@ -417,7 +420,8 @@ static int ByteTest03 (void) { return 0; } -static int ByteTest04 (void) { +static int ByteTest04 (void) +{ uint32_t val = 0x01020304; uint32_t i32 = 0xbfbfbfbf; uint8_t bytes[4] = { 0x01, 0x02, 0x03, 0x04 }; @@ -430,7 +434,8 @@ static int ByteTest04 (void) { return 0; } -static int ByteTest05 (void) { +static int ByteTest05 (void) +{ uint64_t val = 0x0102030405060708ULL; uint64_t i64 = 0xbfbfbfbfbfbfbfbfULL; uint8_t bytes[8] = { 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 }; @@ -443,7 +448,8 @@ static int ByteTest05 (void) { return 0; } -static int ByteTest06 (void) { +static int ByteTest06 (void) +{ uint64_t val = 0x0102030405060708ULL; uint64_t i64 = 0xbfbfbfbfbfbfbfbfULL; uint8_t bytes[8] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 }; @@ -456,7 +462,8 @@ static int ByteTest06 (void) { return 0; } -static int ByteTest07 (void) { +static int ByteTest07 (void) +{ const char *str = "1234567890"; uint64_t val = 1234567890; uint64_t i64 = 0xbfbfbfbfbfbfbfbfULL; @@ -469,7 +476,8 @@ static int ByteTest07 (void) { return 0; } -static int ByteTest08 (void) { +static int ByteTest08 (void) +{ const char *str = "1234567890"; uint32_t val = 1234567890; uint32_t i32 = 0xbfbfbfbf; @@ -482,7 +490,8 @@ static int ByteTest08 (void) { return 0; } -static int ByteTest09 (void) { +static int ByteTest09 (void) +{ const char *str = "12345"; uint16_t val = 12345; uint16_t i16 = 0xbfbf; @@ -495,7 +504,8 @@ static int ByteTest09 (void) { return 0; } -static int ByteTest10 (void) { +static int ByteTest10 (void) +{ const char *str = "123"; uint8_t val = 123; uint8_t i8 = 0xbf; @@ -508,7 +518,8 @@ static int ByteTest10 (void) { return 0; } -static int ByteTest11 (void) { +static int ByteTest11 (void) +{ const char *str = "-1234567890"; int64_t val = -1234567890; int64_t i64 = 0xbfbfbfbfbfbfbfbfULL; @@ -521,7 +532,8 @@ static int ByteTest11 (void) { return 0; } -static int ByteTest12 (void) { +static int ByteTest12 (void) +{ const char *str = "-1234567890"; int32_t val = -1234567890; int32_t i32 = 0xbfbfbfbf; @@ -534,7 +546,8 @@ static int ByteTest12 (void) { return 0; } -static int ByteTest13 (void) { +static int ByteTest13 (void) +{ const char *str = "-12345"; int16_t val = -12345; int16_t i16 = 0xbfbf; @@ -547,7 +560,8 @@ static int ByteTest13 (void) { return 0; } -static int ByteTest14 (void) { +static int ByteTest14 (void) +{ const char *str = "-123"; int8_t val = -123; int8_t i8 = 0xbf; @@ -561,7 +575,8 @@ static int ByteTest14 (void) { } /** \test max u32 value */ -static int ByteTest15 (void) { +static int ByteTest15 (void) +{ const char *str = "4294967295"; uint32_t val = 4294967295UL; uint32_t u32 = 0xffffffff; @@ -575,7 +590,8 @@ static int ByteTest15 (void) { } /** \test max u32 value + 1 */ -static int ByteTest16 (void) { +static int ByteTest16 (void) +{ const char *str = "4294967296"; uint32_t u32 = 0; @@ -588,7 +604,8 @@ static int ByteTest16 (void) { } #endif /* UNITTESTS */ -void ByteRegisterTests(void) { +void ByteRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("ByteTest01", ByteTest01, 1); UtRegisterTest("ByteTest02", ByteTest02, 1); diff --git a/src/util-cidr.c b/src/util-cidr.c index 7e570a6b7c..300a44551b 100644 --- a/src/util-cidr.c +++ b/src/util-cidr.c @@ -27,7 +27,8 @@ static uint32_t cidrs[33]; -void CIDRInit(void) { +void CIDRInit(void) +{ int i = 0; /* skip 0 as it will result in 0xffffffff */ @@ -38,7 +39,8 @@ void CIDRInit(void) { } } -uint32_t CIDRGet(int cidr) { +uint32_t CIDRGet(int cidr) +{ if (cidr < 0 || cidr > 32) return 0; return cidrs[cidr]; diff --git a/src/util-daemon.c b/src/util-daemon.c index b922a3fe56..2eec7af13b 100644 --- a/src/util-daemon.c +++ b/src/util-daemon.c @@ -41,7 +41,8 @@ static volatile sig_atomic_t sigflag = 0; /** * \brief Signal handler used to take the parent process out of stand-by */ -static void SignalHandlerSigusr1 (int signo) { +static void SignalHandlerSigusr1 (int signo) +{ sigflag = 1; } @@ -50,7 +51,8 @@ static void SignalHandlerSigusr1 (int signo) { * * \param pid pid of the parent process to signal */ -static void TellWaitingParent (pid_t pid) { +static void TellWaitingParent (pid_t pid) +{ kill(pid, SIGUSR1); } @@ -59,7 +61,8 @@ static void TellWaitingParent (pid_t pid) { * * \param pid pid of the child process to wait */ -static void WaitForChild (pid_t pid) { +static void WaitForChild (pid_t pid) +{ int status; SCLogDebug("Daemon: Parent waiting for child to be ready..."); /* Wait until child signals is ready */ @@ -80,7 +83,8 @@ static void WaitForChild (pid_t pid) { * \brief Close stdin, stdout, stderr.Redirect logging info to syslog * */ -static void SetupLogging (void) { +static void SetupLogging (void) +{ /* Redirect stdin, stdout, stderr to /dev/null */ int fd = open("/dev/null", O_RDWR); if (fd < 0) @@ -98,7 +102,8 @@ static void SetupLogging (void) { * \brief Daemonize the process * */ -void Daemonize (void) { +void Daemonize (void) +{ pid_t pid, sid; /* Register the signal handler */ @@ -171,7 +176,8 @@ void Daemonize (void) { * \retval 1 valid combination * \retval 0 invalid combination */ -int CheckValidDaemonModes (int daemon, int mode) { +int CheckValidDaemonModes (int daemon, int mode) +{ if (daemon) { switch (mode) { case RUNMODE_PCAP_FILE: diff --git a/src/util-device.c b/src/util-device.c index 4e4081f707..a98b457597 100644 --- a/src/util-device.c +++ b/src/util-device.c @@ -69,7 +69,8 @@ int LiveRegisterDevice(char *dev) * * \retval cnt the number of registered devices */ -int LiveGetDeviceCount(void) { +int LiveGetDeviceCount(void) +{ int i = 0; LiveDevice *pd; @@ -88,7 +89,8 @@ int LiveGetDeviceCount(void) { * \retval ptr pointer to the string containing the device * \retval NULL on error */ -char *LiveGetDeviceName(int number) { +char *LiveGetDeviceName(int number) +{ int i = 0; LiveDevice *pd; @@ -111,7 +113,8 @@ char *LiveGetDeviceName(int number) { * \retval ptr pointer to the string containing the device * \retval NULL on error */ -LiveDevice *LiveGetDevice(char *name) { +LiveDevice *LiveGetDevice(char *name) +{ int i = 0; LiveDevice *pd; diff --git a/src/util-file.c b/src/util-file.c index 82de4f456e..7788413ff3 100644 --- a/src/util-file.c +++ b/src/util-file.c @@ -54,32 +54,39 @@ static int g_file_force_tracking = 0; static void FileFree(File *); static void FileDataFree(FileData *); -void FileForceMagicEnable(void) { +void FileForceMagicEnable(void) +{ g_file_force_magic = 1; } -void FileForceMd5Enable(void) { +void FileForceMd5Enable(void) +{ g_file_force_md5 = 1; } -int FileForceMagic(void) { +int FileForceMagic(void) +{ return g_file_force_magic; } -int FileForceMd5(void) { +int FileForceMd5(void) +{ return g_file_force_md5; } -void FileForceTrackingEnable(void) { +void FileForceTrackingEnable(void) +{ g_file_force_tracking = 1; } -int FileMagicSize(void) { +int FileMagicSize(void) +{ /** \todo make this size configurable */ return 512; } -static int FileAppendFileDataFilePtr(File *ff, FileData *ffd) { +static int FileAppendFileDataFilePtr(File *ff, FileData *ffd) +{ SCEnter(); if (ff == NULL) { @@ -107,7 +114,8 @@ static int FileAppendFileDataFilePtr(File *ff, FileData *ffd) { SCReturnInt(0); } -static int FileAppendFileData(FileContainer *ffc, FileData *ffd) { +static int FileAppendFileData(FileContainer *ffc, FileData *ffd) +{ SCEnter(); if (ffc == NULL) { @@ -124,7 +132,8 @@ static int FileAppendFileData(FileContainer *ffc, FileData *ffd) { -static void FilePruneFile(File *file) { +static void FilePruneFile(File *file) +{ SCEnter(); SCLogDebug("file %p, file->chunks_cnt %"PRIu64, file, file->chunks_cnt); @@ -166,7 +175,8 @@ static void FilePruneFile(File *file) { SCReturn; } -void FilePrune(FileContainer *ffc) { +void FilePrune(FileContainer *ffc) +{ File *file; for (file = ffc->head; file != NULL; file = file->next) { @@ -180,7 +190,8 @@ void FilePrune(FileContainer *ffc) { * \retval new newly allocated FileContainer * \retval NULL error */ -FileContainer *FileContainerAlloc(void) { +FileContainer *FileContainerAlloc(void) +{ FileContainer *new = SCMalloc(sizeof(FileContainer)); if (unlikely(new == NULL)) { SCLogError(SC_ERR_MEM_ALLOC, "Error allocating mem"); @@ -196,7 +207,8 @@ FileContainer *FileContainerAlloc(void) { * * \param ffc FileContainer */ -void FileContainerRecycle(FileContainer *ffc) { +void FileContainerRecycle(FileContainer *ffc) +{ if (ffc == NULL) return; @@ -214,7 +226,8 @@ void FileContainerRecycle(FileContainer *ffc) { * * \param ffc FileContainer */ -void FileContainerFree(FileContainer *ffc) { +void FileContainerFree(FileContainer *ffc) +{ if (ffc == NULL) return; @@ -238,7 +251,8 @@ void FileContainerFree(FileContainer *ffc) { * * \retval new FileData object */ -static FileData *FileDataAlloc(uint8_t *data, uint32_t data_len) { +static FileData *FileDataAlloc(uint8_t *data, uint32_t data_len) +{ FileData *new = SCMalloc(sizeof(FileData)); if (unlikely(new == NULL)) { return NULL; @@ -265,7 +279,8 @@ static FileData *FileDataAlloc(uint8_t *data, uint32_t data_len) { * * \param ffd the flow file data object to free */ -static void FileDataFree(FileData *ffd) { +static void FileDataFree(FileData *ffd) +{ if (ffd == NULL) return; @@ -284,7 +299,8 @@ static void FileDataFree(FileData *ffd) { * * \retval new File object or NULL on error */ -static File *FileAlloc(uint8_t *name, uint16_t name_len) { +static File *FileAlloc(uint8_t *name, uint16_t name_len) +{ File *new = SCMalloc(sizeof(File)); if (unlikely(new == NULL)) { SCLogError(SC_ERR_MEM_ALLOC, "Error allocating mem"); @@ -304,7 +320,8 @@ static File *FileAlloc(uint8_t *name, uint16_t name_len) { return new; } -static void FileFree(File *ff) { +static void FileFree(File *ff) +{ if (ff == NULL) return; @@ -334,7 +351,8 @@ static void FileFree(File *ff) { SCFree(ff); } -void FileContainerAdd(FileContainer *ffc, File *ff) { +void FileContainerAdd(FileContainer *ffc, File *ff) +{ if (ffc->head == NULL || ffc->tail == NULL) { ffc->head = ffc->tail = ff; } else { @@ -348,7 +366,8 @@ void FileContainerAdd(FileContainer *ffc, File *ff) { * * \param ff The file to store */ -int FileStore(File *ff) { +int FileStore(File *ff) +{ ff->flags |= FILE_STORE; SCReturnInt(0); } @@ -359,7 +378,8 @@ int FileStore(File *ff) { * \param ff The file to store * \param txid the tx id */ -int FileSetTx(File *ff, uint64_t txid) { +int FileSetTx(File *ff, uint64_t txid) +{ SCLogDebug("ff %p txid %"PRIu64, ff, txid); if (ff != NULL) ff->txid = txid; @@ -374,7 +394,8 @@ int FileSetTx(File *ff, uint64_t txid) { * \retval 0 limit not reached yet * \retval 1 limit reached */ -static int FileStoreNoStoreCheck(File *ff) { +static int FileStoreNoStoreCheck(File *ff) +{ SCEnter(); if (ff == NULL) { @@ -404,7 +425,8 @@ static int FileStoreNoStoreCheck(File *ff) { * \retval -1 error * \retval -2 no store for this file */ -int FileAppendData(FileContainer *ffc, uint8_t *data, uint32_t data_len) { +int FileAppendData(FileContainer *ffc, uint8_t *data, uint32_t data_len) +{ SCEnter(); if (ffc == NULL || ffc->tail == NULL || data == NULL || data_len == 0) { @@ -631,7 +653,8 @@ int FileCloseFile(FileContainer *ffc, uint8_t *data, * \param f *LOCKED* flow * \param direction flow direction */ -void FileDisableStoring(Flow *f, uint8_t direction) { +void FileDisableStoring(Flow *f, uint8_t direction) +{ File *ptr = NULL; SCEnter(); @@ -662,7 +685,8 @@ void FileDisableStoring(Flow *f, uint8_t direction) { * \param f *LOCKED* flow * \param direction flow direction */ -void FileDisableMagic(Flow *f, uint8_t direction) { +void FileDisableMagic(Flow *f, uint8_t direction) +{ File *ptr = NULL; SCEnter(); @@ -692,7 +716,8 @@ void FileDisableMagic(Flow *f, uint8_t direction) { * \param f *LOCKED* flow * \param direction flow direction */ -void FileDisableMd5(Flow *f, uint8_t direction) { +void FileDisableMd5(Flow *f, uint8_t direction) +{ File *ptr = NULL; SCEnter(); @@ -730,7 +755,8 @@ void FileDisableMd5(Flow *f, uint8_t direction) { * \param f *LOCKED* flow * \param direction flow direction */ -void FileDisableFilesize(Flow *f, uint8_t direction) { +void FileDisableFilesize(Flow *f, uint8_t direction) +{ File *ptr = NULL; SCEnter(); @@ -760,7 +786,8 @@ void FileDisableFilesize(Flow *f, uint8_t direction) { * * \param ff file */ -void FileDisableStoringForFile(File *ff) { +void FileDisableStoringForFile(File *ff) +{ SCEnter(); if (ff == NULL) { @@ -783,7 +810,8 @@ void FileDisableStoringForFile(File *ff) { * \param direction flow direction * \param tx_id transaction id */ -void FileDisableStoringForTransaction(Flow *f, uint8_t direction, uint64_t tx_id) { +void FileDisableStoringForTransaction(Flow *f, uint8_t direction, uint64_t tx_id) +{ File *ptr = NULL; DEBUG_ASSERT_FLOW_LOCKED(f); @@ -813,7 +841,8 @@ void FileDisableStoringForTransaction(Flow *f, uint8_t direction, uint64_t tx_id * \param fc file store * \param file_id the file's id */ -void FileStoreFileById(FileContainer *fc, uint16_t file_id) { +void FileStoreFileById(FileContainer *fc, uint16_t file_id) +{ File *ptr = NULL; SCEnter(); @@ -827,7 +856,8 @@ void FileStoreFileById(FileContainer *fc, uint16_t file_id) { } } -void FileStoreAllFilesForTx(FileContainer *fc, uint16_t tx_id) { +void FileStoreAllFilesForTx(FileContainer *fc, uint16_t tx_id) +{ File *ptr = NULL; SCEnter(); @@ -841,7 +871,8 @@ void FileStoreAllFilesForTx(FileContainer *fc, uint16_t tx_id) { } } -void FileStoreAllFiles(FileContainer *fc) { +void FileStoreAllFiles(FileContainer *fc) +{ File *ptr = NULL; SCEnter(); @@ -853,7 +884,8 @@ void FileStoreAllFiles(FileContainer *fc) { } } -void FileTruncateAllOpenFiles(FileContainer *fc) { +void FileTruncateAllOpenFiles(FileContainer *fc) +{ File *ptr = NULL; SCEnter(); diff --git a/src/util-fmemopen.c b/src/util-fmemopen.c index d551282368..0a20b80b23 100644 --- a/src/util-fmemopen.c +++ b/src/util-fmemopen.c @@ -48,7 +48,8 @@ * \param mode mode of the file to open * \retval pointer to the file; NULL if something is wrong */ -FILE *SCFmemopen(void *buf, size_t size, const char *mode) { +FILE *SCFmemopen(void *buf, size_t size, const char *mode) +{ char temppath[MAX_PATH - 13]; if (0 == GetTempPath(sizeof(temppath), temppath)) return NULL; @@ -82,7 +83,8 @@ typedef struct SCFmem_ { * \param whence SEEK_SET, SEEK_CUR, SEEK_END * \retval pos the position by the last operation, -1 if sizes are out of bounds */ -static fpos_t SeekFn(void *handler, fpos_t offset, int whence) { +static fpos_t SeekFn(void *handler, fpos_t offset, int whence) +{ size_t pos = 0; SCFmem *mem = handler; @@ -113,7 +115,8 @@ static fpos_t SeekFn(void *handler, fpos_t offset, int whence) { * \param number of bytes to read * \retval count , the number of bytes read */ -static int ReadFn(void *handler, char *buf, int size) { +static int ReadFn(void *handler, char *buf, int size) +{ size_t count = 0; SCFmem *mem = handler; size_t available = mem->size - mem->pos; @@ -143,7 +146,8 @@ static int ReadFn(void *handler, char *buf, int size) { * \param number of bytes to write * \retval count , the number of bytes writen */ -static int WriteFn(void *handler, const char *buf, int size) { +static int WriteFn(void *handler, const char *buf, int size) +{ size_t count = 0; SCFmem *mem = handler; size_t available = mem->size - mem->pos; @@ -164,7 +168,8 @@ static int WriteFn(void *handler, const char *buf, int size) { * \param handler pointer to the memfile * \retval 0 on succesful */ -static int CloseFn(void *handler) { +static int CloseFn(void *handler) +{ SCFree(handler); return 0; } @@ -176,7 +181,8 @@ static int CloseFn(void *handler) { * \param mode mode of the file to open * \retval pointer to the file; NULL if something is wrong */ -FILE *SCFmemopen(void *buf, size_t size, const char *mode) { +FILE *SCFmemopen(void *buf, size_t size, const char *mode) +{ SCFmem *mem = (SCFmem *) SCMalloc(sizeof(SCFmem)); if (mem == NULL) return NULL; diff --git a/src/util-hash.c b/src/util-hash.c index 125165f266..7552867fb5 100644 --- a/src/util-hash.c +++ b/src/util-hash.c @@ -76,7 +76,8 @@ error: return NULL; } -void HashTableFree(HashTable *ht) { +void HashTableFree(HashTable *ht) +{ uint32_t i = 0; if (ht == NULL) @@ -101,14 +102,16 @@ void HashTableFree(HashTable *ht) { SCFree(ht); } -void HashTablePrint(HashTable *ht) { +void HashTablePrint(HashTable *ht) +{ printf("\n----------- Hash Table Stats ------------\n"); printf("Buckets: %" PRIu32 "\n", ht->array_size); printf("Hash function pointer: %p\n", ht->Hash); printf("-----------------------------------------\n"); } -int HashTableAdd(HashTable *ht, void *data, uint16_t datalen) { +int HashTableAdd(HashTable *ht, void *data, uint16_t datalen) +{ if (ht == NULL || data == NULL) return -1; @@ -139,7 +142,8 @@ error: return -1; } -int HashTableRemove(HashTable *ht, void *data, uint16_t datalen) { +int HashTableRemove(HashTable *ht, void *data, uint16_t datalen) +{ uint32_t hash = ht->Hash(ht, data, datalen); if (ht->array[hash] == NULL) { @@ -179,7 +183,8 @@ int HashTableRemove(HashTable *ht, void *data, uint16_t datalen) { return -1; } -void *HashTableLookup(HashTable *ht, void *data, uint16_t datalen) { +void *HashTableLookup(HashTable *ht, void *data, uint16_t datalen) +{ uint32_t hash = 0; if (ht == NULL) @@ -201,7 +206,8 @@ void *HashTableLookup(HashTable *ht, void *data, uint16_t datalen) { return NULL; } -uint32_t HashTableGenericHash(HashTable *ht, void *data, uint16_t datalen) { +uint32_t HashTableGenericHash(HashTable *ht, void *data, uint16_t datalen) +{ uint8_t *d = (uint8_t *)data; uint32_t i; uint32_t hash = 0; @@ -217,7 +223,8 @@ uint32_t HashTableGenericHash(HashTable *ht, void *data, uint16_t datalen) { return hash; } -char HashTableDefaultCompare(void *data1, uint16_t len1, void *data2, uint16_t len2) { +char HashTableDefaultCompare(void *data1, uint16_t len1, void *data2, uint16_t len2) +{ if (len1 != len2) return 0; @@ -232,7 +239,8 @@ char HashTableDefaultCompare(void *data1, uint16_t len1, void *data2, uint16_t l */ #ifdef UNITTESTS -static int HashTableTestInit01 (void) { +static int HashTableTestInit01 (void) +{ HashTable *ht = HashTableInit(1024, HashTableGenericHash, NULL, NULL); if (ht == NULL) return 0; @@ -242,7 +250,8 @@ static int HashTableTestInit01 (void) { } /* no hash function, so it should fail */ -static int HashTableTestInit02 (void) { +static int HashTableTestInit02 (void) +{ HashTable *ht = HashTableInit(1024, NULL, NULL, NULL); if (ht == NULL) return 1; @@ -251,7 +260,8 @@ static int HashTableTestInit02 (void) { return 0; } -static int HashTableTestInit03 (void) { +static int HashTableTestInit03 (void) +{ int result = 0; HashTable *ht = HashTableInit(1024, HashTableGenericHash, NULL, NULL); if (ht == NULL) @@ -264,7 +274,8 @@ static int HashTableTestInit03 (void) { return result; } -static int HashTableTestInit04 (void) { +static int HashTableTestInit04 (void) +{ HashTable *ht = HashTableInit(0, HashTableGenericHash, NULL, NULL); if (ht == NULL) return 1; @@ -273,7 +284,8 @@ static int HashTableTestInit04 (void) { return 0; } -static int HashTableTestInit05 (void) { +static int HashTableTestInit05 (void) +{ int result = 0; HashTable *ht = HashTableInit(1024, HashTableGenericHash, NULL, NULL); if (ht == NULL) @@ -286,7 +298,8 @@ static int HashTableTestInit05 (void) { return result; } -static char HashTableDefaultCompareTest(void *data1, uint16_t len1, void *data2, uint16_t len2) { +static char HashTableDefaultCompareTest(void *data1, uint16_t len1, void *data2, uint16_t len2) +{ if (len1 != len2) return 0; @@ -296,7 +309,8 @@ static char HashTableDefaultCompareTest(void *data1, uint16_t len1, void *data2, return 1; } -static int HashTableTestInit06 (void) { +static int HashTableTestInit06 (void) +{ int result = 0; HashTable *ht = HashTableInit(1024, HashTableGenericHash, HashTableDefaultCompareTest, NULL); if (ht == NULL) @@ -309,7 +323,8 @@ static int HashTableTestInit06 (void) { return result; } -static int HashTableTestAdd01 (void) { +static int HashTableTestAdd01 (void) +{ int result = 0; HashTable *ht = HashTableInit(32, HashTableGenericHash, NULL, NULL); if (ht == NULL) @@ -326,7 +341,8 @@ end: return result; } -static int HashTableTestAdd02 (void) { +static int HashTableTestAdd02 (void) +{ int result = 0; HashTable *ht = HashTableInit(32, HashTableGenericHash, NULL, NULL); if (ht == NULL) @@ -343,7 +359,8 @@ end: return result; } -static int HashTableTestFull01 (void) { +static int HashTableTestFull01 (void) +{ int result = 0; HashTable *ht = HashTableInit(32, HashTableGenericHash, NULL, NULL); if (ht == NULL) @@ -368,7 +385,8 @@ end: return result; } -static int HashTableTestFull02 (void) { +static int HashTableTestFull02 (void) +{ int result = 0; HashTable *ht = HashTableInit(32, HashTableGenericHash, NULL, NULL); if (ht == NULL) @@ -394,7 +412,8 @@ end: } #endif -void HashTableRegisterTests(void) { +void HashTableRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("HashTableTestInit01", HashTableTestInit01, 1); UtRegisterTest("HashTableTestInit02", HashTableTestInit02, 1); diff --git a/src/util-hashlist.c b/src/util-hashlist.c index 19c209ed2d..db8ba9050e 100644 --- a/src/util-hashlist.c +++ b/src/util-hashlist.c @@ -79,7 +79,8 @@ error: return NULL; } -void HashListTableFree(HashListTable *ht) { +void HashListTableFree(HashListTable *ht) +{ uint32_t i = 0; if (ht == NULL) @@ -104,14 +105,16 @@ void HashListTableFree(HashListTable *ht) { SCFree(ht); } -void HashListTablePrint(HashListTable *ht) { +void HashListTablePrint(HashListTable *ht) +{ printf("\n----------- Hash Table Stats ------------\n"); printf("Buckets: %" PRIu32 "\n", ht->array_size); printf("Hash function pointer: %p\n", ht->Hash); printf("-----------------------------------------\n"); } -int HashListTableAdd(HashListTable *ht, void *data, uint16_t datalen) { +int HashListTableAdd(HashListTable *ht, void *data, uint16_t datalen) +{ if (ht == NULL || data == NULL) return -1; @@ -151,7 +154,8 @@ error: return -1; } -int HashListTableRemove(HashListTable *ht, void *data, uint16_t datalen) { +int HashListTableRemove(HashListTable *ht, void *data, uint16_t datalen) +{ uint32_t hash = ht->Hash(ht, data, datalen); SCLogDebug("ht %p hash %"PRIu32"", ht, hash); @@ -230,7 +234,8 @@ int HashListTableRemove(HashListTable *ht, void *data, uint16_t datalen) { return -1; } -char HashListTableDefaultCompare(void *data1, uint16_t len1, void *data2, uint16_t len2) { +char HashListTableDefaultCompare(void *data1, uint16_t len1, void *data2, uint16_t len2) +{ if (len1 != len2) return 0; @@ -240,7 +245,8 @@ char HashListTableDefaultCompare(void *data1, uint16_t len1, void *data2, uint16 return 1; } -void *HashListTableLookup(HashListTable *ht, void *data, uint16_t datalen) { +void *HashListTableLookup(HashListTable *ht, void *data, uint16_t datalen) +{ if (ht == NULL) { SCLogDebug("Hash List table is NULL"); @@ -264,7 +270,8 @@ void *HashListTableLookup(HashListTable *ht, void *data, uint16_t datalen) { return NULL; } -uint32_t HashListTableGenericHash(HashListTable *ht, void *data, uint16_t datalen) { +uint32_t HashListTableGenericHash(HashListTable *ht, void *data, uint16_t datalen) +{ uint8_t *d = (uint8_t *)data; uint32_t i; uint32_t hash = 0; @@ -280,7 +287,8 @@ uint32_t HashListTableGenericHash(HashListTable *ht, void *data, uint16_t datale return hash; } -HashListTableBucket *HashListTableGetListHead(HashListTable *ht) { +HashListTableBucket *HashListTableGetListHead(HashListTable *ht) +{ return ht->listhead; } @@ -289,7 +297,8 @@ HashListTableBucket *HashListTableGetListHead(HashListTable *ht) { */ #ifdef UNITTESTS -static int HashListTableTestInit01 (void) { +static int HashListTableTestInit01 (void) +{ HashListTable *ht = HashListTableInit(1024, HashListTableGenericHash, NULL, NULL); if (ht == NULL) return 0; @@ -299,7 +308,8 @@ static int HashListTableTestInit01 (void) { } /* no hash function, so it should fail */ -static int HashListTableTestInit02 (void) { +static int HashListTableTestInit02 (void) +{ HashListTable *ht = HashListTableInit(1024, NULL, NULL, NULL); if (ht == NULL) return 1; @@ -308,7 +318,8 @@ static int HashListTableTestInit02 (void) { return 0; } -static int HashListTableTestInit03 (void) { +static int HashListTableTestInit03 (void) +{ int result = 0; HashListTable *ht = HashListTableInit(1024, HashListTableGenericHash, NULL, NULL); if (ht == NULL) @@ -321,7 +332,8 @@ static int HashListTableTestInit03 (void) { return result; } -static int HashListTableTestInit04 (void) { +static int HashListTableTestInit04 (void) +{ HashListTable *ht = HashListTableInit(0, HashListTableGenericHash, NULL, NULL); if (ht == NULL) return 1; @@ -330,7 +342,8 @@ static int HashListTableTestInit04 (void) { return 0; } -static int HashListTableTestAdd01 (void) { +static int HashListTableTestAdd01 (void) +{ int result = 0; HashListTable *ht = HashListTableInit(32, HashListTableGenericHash, NULL, NULL); if (ht == NULL) @@ -347,7 +360,8 @@ end: return result; } -static int HashListTableTestAdd02 (void) { +static int HashListTableTestAdd02 (void) +{ int result = 0; HashListTable *ht = HashListTableInit(32, HashListTableGenericHash, NULL, NULL); if (ht == NULL) @@ -364,7 +378,8 @@ end: return result; } -static int HashListTableTestAdd03 (void) { +static int HashListTableTestAdd03 (void) +{ int result = 0; HashListTable *ht = HashListTableInit(32, HashListTableGenericHash, NULL, NULL); if (ht == NULL) @@ -391,7 +406,8 @@ end: return result; } -static int HashListTableTestAdd04 (void) { +static int HashListTableTestAdd04 (void) +{ int result = 0; HashListTable *ht = HashListTableInit(32, HashListTableGenericHash, NULL, NULL); if (ht == NULL) @@ -429,7 +445,8 @@ end: return result; } -static int HashListTableTestFull01 (void) { +static int HashListTableTestFull01 (void) +{ int result = 0; HashListTable *ht = HashListTableInit(32, HashListTableGenericHash, NULL, NULL); if (ht == NULL) @@ -454,7 +471,8 @@ end: return result; } -static int HashListTableTestFull02 (void) { +static int HashListTableTestFull02 (void) +{ int result = 0; HashListTable *ht = HashListTableInit(32, HashListTableGenericHash, NULL, NULL); if (ht == NULL) @@ -480,7 +498,8 @@ end: } #endif /* UNITTESTS */ -void HashListTableRegisterTests(void) { +void HashListTableRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("HashListTableTestInit01", HashListTableTestInit01, 1); UtRegisterTest("HashListTableTestInit02", HashListTableTestInit02, 1); diff --git a/src/util-memcmp.c b/src/util-memcmp.c index e4b74d4d21..f5ab3d095f 100644 --- a/src/util-memcmp.c +++ b/src/util-memcmp.c @@ -33,7 +33,8 @@ /* UNITTESTS */ #ifdef UNITTESTS -static int MemcmpTest01 (void) { +static int MemcmpTest01 (void) +{ uint8_t a[] = "abcd"; uint8_t b[] = "abcd"; @@ -43,7 +44,8 @@ static int MemcmpTest01 (void) { return 1; } -static int MemcmpTest02 (void) { +static int MemcmpTest02 (void) +{ uint8_t a[] = "abcdabcdabcdabcd"; uint8_t b[] = "abcdabcdabcdabcd"; @@ -53,7 +55,8 @@ static int MemcmpTest02 (void) { return 1; } -static int MemcmpTest03 (void) { +static int MemcmpTest03 (void) +{ uint8_t a[] = "abcdabcd"; uint8_t b[] = "abcdabcd"; @@ -63,7 +66,8 @@ static int MemcmpTest03 (void) { return 1; } -static int MemcmpTest04 (void) { +static int MemcmpTest04 (void) +{ uint8_t a[] = "abcd"; uint8_t b[] = "abcD"; @@ -76,7 +80,8 @@ static int MemcmpTest04 (void) { return 1; } -static int MemcmpTest05 (void) { +static int MemcmpTest05 (void) +{ uint8_t a[] = "abcdabcdabcdabcd"; uint8_t b[] = "abcDabcdabcdabcd"; @@ -86,7 +91,8 @@ static int MemcmpTest05 (void) { return 1; } -static int MemcmpTest06 (void) { +static int MemcmpTest06 (void) +{ uint8_t a[] = "abcdabcd"; uint8_t b[] = "abcDabcd"; @@ -96,7 +102,8 @@ static int MemcmpTest06 (void) { return 1; } -static int MemcmpTest07 (void) { +static int MemcmpTest07 (void) +{ uint8_t a[] = "abcd"; uint8_t b[] = "abcde"; @@ -106,7 +113,8 @@ static int MemcmpTest07 (void) { return 1; } -static int MemcmpTest08 (void) { +static int MemcmpTest08 (void) +{ uint8_t a[] = "abcdabcdabcdabcd"; uint8_t b[] = "abcdabcdabcdabcde"; @@ -116,7 +124,8 @@ static int MemcmpTest08 (void) { return 1; } -static int MemcmpTest09 (void) { +static int MemcmpTest09 (void) +{ uint8_t a[] = "abcdabcd"; uint8_t b[] = "abcdabcde"; @@ -126,7 +135,8 @@ static int MemcmpTest09 (void) { return 1; } -static int MemcmpTest10 (void) { +static int MemcmpTest10 (void) +{ uint8_t a[] = "abcd"; uint8_t b[] = "Zbcde"; @@ -136,7 +146,8 @@ static int MemcmpTest10 (void) { return 1; } -static int MemcmpTest11 (void) { +static int MemcmpTest11 (void) +{ uint8_t a[] = "abcdabcdabcdabcd"; uint8_t b[] = "Zbcdabcdabcdabcde"; @@ -146,7 +157,8 @@ static int MemcmpTest11 (void) { return 1; } -static int MemcmpTest12 (void) { +static int MemcmpTest12 (void) +{ uint8_t a[] = "abcdabcd"; uint8_t b[] = "Zbcdabcde"; @@ -156,7 +168,8 @@ static int MemcmpTest12 (void) { return 1; } -static int MemcmpTest13 (void) { +static int MemcmpTest13 (void) +{ uint8_t a[] = "abcdefgh"; uint8_t b[] = "AbCdEfGhIjK"; @@ -170,7 +183,8 @@ static int MemcmpTest13 (void) { #define TEST_RUNS 1000000 -static int MemcmpTest14 (void) { +static int MemcmpTest14 (void) +{ #ifdef PROFILING uint64_t ticks_start = 0; uint64_t ticks_end = 0; @@ -208,7 +222,8 @@ static int MemcmpTest14 (void) { return 1; } -static int MemcmpTest15 (void) { +static int MemcmpTest15 (void) +{ #ifdef PROFILING uint64_t ticks_start = 0; uint64_t ticks_end = 0; @@ -246,7 +261,8 @@ static int MemcmpTest15 (void) { return 1; } -static int MemcmpTest16 (void) { +static int MemcmpTest16 (void) +{ #ifdef PROFILING uint64_t ticks_start = 0; uint64_t ticks_end = 0; @@ -284,7 +300,8 @@ static int MemcmpTest16 (void) { return 1; } -static int MemcmpTest17 (void) { +static int MemcmpTest17 (void) +{ #ifdef PROFILING uint64_t ticks_start = 0; uint64_t ticks_end = 0; @@ -324,7 +341,8 @@ static int MemcmpTest17 (void) { #endif /* UNITTESTS */ -void MemcmpRegisterTests(void) { +void MemcmpRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("MemcmpTest01", MemcmpTest01, 1); UtRegisterTest("MemcmpTest02", MemcmpTest02, 1); diff --git a/src/util-memcmp.h b/src/util-memcmp.h index 7a75bdd9d1..4a5be891ee 100644 --- a/src/util-memcmp.h +++ b/src/util-memcmp.h @@ -39,7 +39,8 @@ static inline int SCMemcmpLowercase(const void *, const void *, size_t); void MemcmpRegisterTests(void); static inline int -MemcmpLowercase(const void *s1, const void *s2, size_t n) { +MemcmpLowercase(const void *s1, const void *s2, size_t n) +{ size_t i; /* check backwards because we already tested the first @@ -147,7 +148,8 @@ static inline int SCMemcmpLowercase(const void *s1, const void *s2, size_t n) #define SCMEMCMP_BYTES 16 -static inline int SCMemcmp(const void *s1, const void *s2, size_t len) { +static inline int SCMemcmp(const void *s1, const void *s2, size_t len) +{ size_t offset = 0; __m128i b1, b2, c; @@ -189,7 +191,8 @@ static inline int SCMemcmp(const void *s1, const void *s2, size_t len) { #define UPPER_LOW 0x40 /* "A" - 1 */ #define UPPER_HIGH 0x5B /* "Z" + 1 */ -static inline int SCMemcmpLowercase(const void *s1, const void *s2, size_t len) { +static inline int SCMemcmpLowercase(const void *s1, const void *s2, size_t len) +{ size_t offset = 0; __m128i b1, b2, mask1, mask2, upper1, upper2, nulls, uplow; @@ -255,7 +258,8 @@ static inline int SCMemcmpLowercase(const void *s1, const void *s2, size_t len) #define SCMEMCMP_BYTES 16 -static inline int SCMemcmp(const void *s1, const void *s2, size_t len) { +static inline int SCMemcmp(const void *s1, const void *s2, size_t len) +{ size_t offset = 0; __m128i b1, b2, c; @@ -298,7 +302,8 @@ static inline int SCMemcmp(const void *s1, const void *s2, size_t len) { #define UPPER_HIGH 0x5B /* "Z" + 1 */ #define UPPER_DELTA 0xDF /* 0xFF - 0x20 */ -static inline int SCMemcmpLowercase(const void *s1, const void *s2, size_t len) { +static inline int SCMemcmpLowercase(const void *s1, const void *s2, size_t len) +{ size_t offset = 0; __m128i b1, b2, mask1, mask2, upper1, upper2, delta; @@ -481,7 +486,8 @@ static inline int SCMemcmpLowercase(const void *s1, const void *s2, size_t len) memcmp((a), (b), (c)) ? 1 : 0; \ }) -static inline int SCMemcmpLowercase(const void *s1, const void *s2, size_t len) { +static inline int SCMemcmpLowercase(const void *s1, const void *s2, size_t len) +{ return MemcmpLowercase(s1, s2, len); } diff --git a/src/util-memrchr.c b/src/util-memrchr.c index dfa54d01f4..ebac1764f0 100644 --- a/src/util-memrchr.c +++ b/src/util-memrchr.c @@ -40,7 +40,8 @@ void *memrchr (const void *s, int c, size_t n) #endif /* HAVE_MEMRCHR */ #ifdef UNITTESTS -static int MemrchrTest01 (void) { +static int MemrchrTest01 (void) +{ char *haystack = "abcabc"; char needle = 'b'; @@ -58,7 +59,8 @@ static int MemrchrTest01 (void) { } #endif -void MemrchrRegisterTests(void) { +void MemrchrRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("MemrchrTest01", MemrchrTest01, 1); #endif diff --git a/src/util-misc.c b/src/util-misc.c index 50de7158b6..fdb3eaeae8 100644 --- a/src/util-misc.c +++ b/src/util-misc.c @@ -32,7 +32,8 @@ static pcre *parse_regex = NULL; static pcre_extra *parse_regex_study = NULL; -void ParseSizeInit(void) { +void ParseSizeInit(void) +{ const char *eb; int eo; int opts = 0; @@ -50,7 +51,8 @@ void ParseSizeInit(void) { } } -void ParseSizeDeinit(void) { +void ParseSizeDeinit(void) +{ if (parse_regex != NULL) pcre_free(parse_regex); diff --git a/src/util-mpm-b2g.c b/src/util-mpm-b2g.c index 70830976d7..31ef46b525 100644 --- a/src/util-mpm-b2g.c +++ b/src/util-mpm-b2g.c @@ -79,7 +79,8 @@ void B2gPrintInfo(MpmCtx *mpm_ctx); void B2gPrintSearchStats(MpmThreadCtx *mpm_thread_ctx); void B2gRegisterTests(void); -void MpmB2gRegister (void) { +void MpmB2gRegister (void) +{ mpm_table[MPM_B2G].name = "b2g"; mpm_table[MPM_B2G].max_pattern_length = B2G_WORD_SIZE; @@ -98,7 +99,8 @@ void MpmB2gRegister (void) { } #ifdef PRINTMATCH -static void prt (uint8_t *buf, uint16_t buflen) { +static void prt (uint8_t *buf, uint16_t buflen) +{ uint16_t i; for (i = 0; i < buflen; i++) { @@ -109,7 +111,8 @@ static void prt (uint8_t *buf, uint16_t buflen) { } #endif -void B2gPrintInfo(MpmCtx *mpm_ctx) { +void B2gPrintInfo(MpmCtx *mpm_ctx) +{ B2gCtx *ctx = (B2gCtx *)mpm_ctx->ctx; printf("MPM B2g Information:\n"); @@ -132,7 +135,8 @@ void B2gPrintInfo(MpmCtx *mpm_ctx) { * and initialize the data * \initonly */ -static inline B2gPattern *B2gAllocPattern(MpmCtx *mpm_ctx) { +static inline B2gPattern *B2gAllocPattern(MpmCtx *mpm_ctx) +{ B2gPattern *p = SCMalloc(sizeof(B2gPattern)); if (unlikely(p == NULL)) return NULL; @@ -144,7 +148,8 @@ static inline B2gPattern *B2gAllocPattern(MpmCtx *mpm_ctx) { } static inline B2gPattern * -B2gAllocHashItem(MpmCtx *mpm_ctx) { +B2gAllocHashItem(MpmCtx *mpm_ctx) +{ B2gPattern *hi = SCMalloc(sizeof(B2gPattern)); if (unlikely(hi == NULL)) return NULL; @@ -155,7 +160,8 @@ B2gAllocHashItem(MpmCtx *mpm_ctx) { return hi; } -static void B2gHashFree(MpmCtx *mpm_ctx, B2gPattern *hi) { +static void B2gHashFree(MpmCtx *mpm_ctx, B2gPattern *hi) +{ if (hi == NULL) return; @@ -170,7 +176,8 @@ static void B2gHashFree(MpmCtx *mpm_ctx, B2gPattern *hi) { /* * INIT HASH START */ -static inline uint32_t B2gInitHash(B2gPattern *p) { +static inline uint32_t B2gInitHash(B2gPattern *p) +{ uint32_t hash = p->len * p->original_pat[0]; if (p->len > 1) hash += p->original_pat[1]; @@ -178,7 +185,8 @@ static inline uint32_t B2gInitHash(B2gPattern *p) { return (hash % INIT_HASH_SIZE); } -static inline uint32_t B2gInitHashRaw(uint8_t *pat, uint16_t patlen) { +static inline uint32_t B2gInitHashRaw(uint8_t *pat, uint16_t patlen) +{ uint32_t hash = patlen * pat[0]; if (patlen > 1) hash += pat[1]; @@ -186,7 +194,8 @@ static inline uint32_t B2gInitHashRaw(uint8_t *pat, uint16_t patlen) { return (hash % INIT_HASH_SIZE); } -static inline int B2gInitHashAdd(B2gCtx *ctx, B2gPattern *p) { +static inline int B2gInitHashAdd(B2gCtx *ctx, B2gPattern *p) +{ uint32_t hash = B2gInitHash(p); //printf("B2gInitHashAdd: %" PRIu32 "\n", hash); @@ -215,7 +224,8 @@ static inline int B2gInitHashAdd(B2gCtx *ctx, B2gPattern *p) { static inline int B2gCmpPattern(B2gPattern *p, uint8_t *pat, uint16_t patlen, char flags); static inline B2gPattern *B2gInitHashLookup(B2gCtx *ctx, uint8_t *pat, uint16_t patlen, char flags, - uint32_t pid) { + uint32_t pid) +{ uint32_t hash = B2gInitHashRaw(pat,patlen); //printf("B2gInitHashLookup: %" PRIu32 ", head %p\n", hash, ctx->init_hash[hash]); @@ -234,7 +244,8 @@ static inline B2gPattern *B2gInitHashLookup(B2gCtx *ctx, uint8_t *pat, uint16_t return NULL; } -static inline int B2gCmpPattern(B2gPattern *p, uint8_t *pat, uint16_t patlen, char flags) { +static inline int B2gCmpPattern(B2gPattern *p, uint8_t *pat, uint16_t patlen, char flags) +{ if (p->len != patlen) return 0; @@ -251,7 +262,8 @@ static inline int B2gCmpPattern(B2gPattern *p, uint8_t *pat, uint16_t patlen, ch * INIT HASH END */ -void B2gFreePattern(MpmCtx *mpm_ctx, B2gPattern *p) { +void B2gFreePattern(MpmCtx *mpm_ctx, B2gPattern *p) +{ if (p && p->cs && p->cs != p->ci) { SCFree(p->cs); mpm_ctx->memory_cnt--; @@ -288,7 +300,8 @@ void B2gFreePattern(MpmCtx *mpm_ctx, B2gPattern *p) { * * \initonly */ -static int B2gAddPattern(MpmCtx *mpm_ctx, uint8_t *pat, uint16_t patlen, uint16_t offset, uint16_t depth, uint32_t pid, uint32_t sid, uint8_t flags) { +static int B2gAddPattern(MpmCtx *mpm_ctx, uint8_t *pat, uint16_t patlen, uint16_t offset, uint16_t depth, uint32_t pid, uint32_t sid, uint8_t flags) +{ B2gCtx *ctx = (B2gCtx *)mpm_ctx->ctx; SCLogDebug("ctx %p len %"PRIu16" pid %" PRIu32, ctx, patlen, pid); @@ -382,7 +395,8 @@ int B2gAddPatternCS(MpmCtx *mpm_ctx, uint8_t *pat, uint16_t patlen, return B2gAddPattern(mpm_ctx, pat, patlen, offset, depth, pid, sid, flags); } -static inline uint32_t B2gBloomHash(void *data, uint16_t datalen, uint8_t iter, uint32_t hash_size) { +static inline uint32_t B2gBloomHash(void *data, uint16_t datalen, uint8_t iter, uint32_t hash_size) +{ uint8_t *d = (uint8_t *)data; uint16_t i; uint32_t hash = (uint32_t)u8_tolower(*d); @@ -397,7 +411,8 @@ static inline uint32_t B2gBloomHash(void *data, uint16_t datalen, uint8_t iter, return hash; } -static void B2gPrepareHash(MpmCtx *mpm_ctx) { +static void B2gPrepareHash(MpmCtx *mpm_ctx) +{ B2gCtx *ctx = (B2gCtx *)mpm_ctx->ctx; uint16_t i; uint16_t idx = 0; @@ -566,7 +581,8 @@ error: return; } -int B2gBuildMatchArray(MpmCtx *mpm_ctx) { +int B2gBuildMatchArray(MpmCtx *mpm_ctx) +{ SCEnter(); B2gCtx *ctx = (B2gCtx *)mpm_ctx->ctx; @@ -599,7 +615,8 @@ int B2gBuildMatchArray(MpmCtx *mpm_ctx) { SCReturnInt(0); } -int B2gPreparePatterns(MpmCtx *mpm_ctx) { +int B2gPreparePatterns(MpmCtx *mpm_ctx) +{ B2gCtx *ctx = (B2gCtx *)mpm_ctx->ctx; /* alloc the pattern array */ @@ -665,7 +682,8 @@ error: return -1; } -void B2gPrintSearchStats(MpmThreadCtx *mpm_thread_ctx) { +void B2gPrintSearchStats(MpmThreadCtx *mpm_thread_ctx) +{ #ifdef B2G_COUNTERS B2gThreadCtx *tctx = (B2gThreadCtx *)mpm_thread_ctx->ctx; @@ -758,7 +776,8 @@ static void B2gGetConfig() } } -void B2gInitCtx (MpmCtx *mpm_ctx) { +void B2gInitCtx (MpmCtx *mpm_ctx) +{ SCLogDebug("mpm_ctx %p, ctx %p", mpm_ctx, mpm_ctx->ctx); if (mpm_ctx->ctx != NULL) @@ -796,7 +815,8 @@ void B2gInitCtx (MpmCtx *mpm_ctx) { SCReturn; } -void B2gDestroyCtx(MpmCtx *mpm_ctx) { +void B2gDestroyCtx(MpmCtx *mpm_ctx) +{ SCLogDebug("mpm_ctx %p", mpm_ctx); B2gCtx *ctx = (B2gCtx *)mpm_ctx->ctx; @@ -871,7 +891,8 @@ void B2gDestroyCtx(MpmCtx *mpm_ctx) { mpm_ctx->memory_size -= sizeof(B2gCtx); } -void B2gThreadInitCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, uint32_t matchsize) { +void B2gThreadInitCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, uint32_t matchsize) +{ memset(mpm_thread_ctx, 0, sizeof(MpmThreadCtx)); if (sizeof(B2gThreadCtx) > 0) { /* size can be null when optimized */ @@ -887,7 +908,8 @@ void B2gThreadInitCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, uint32_t ma } } -void B2gThreadDestroyCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx) { +void B2gThreadDestroyCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx) +{ B2gThreadCtx *ctx = (B2gThreadCtx *)mpm_thread_ctx->ctx; B2gPrintSearchStats(mpm_thread_ctx); @@ -899,12 +921,14 @@ void B2gThreadDestroyCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx) { } } -uint32_t B2gSearchWrap(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) { +uint32_t B2gSearchWrap(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) +{ B2gCtx *ctx = (B2gCtx *)mpm_ctx->ctx; return ctx ? ctx->Search(mpm_ctx, mpm_thread_ctx, pmq, buf, buflen) : 0; } -uint32_t B2gSearchBNDMq(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) { +uint32_t B2gSearchBNDMq(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) +{ B2gCtx *ctx = (B2gCtx *)mpm_ctx->ctx; #ifdef B2G_COUNTERS B2gThreadCtx *tctx = (B2gThreadCtx *)mpm_thread_ctx->ctx; @@ -1021,7 +1045,8 @@ skip_loop: return matches; } -uint32_t B2gSearch(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) { +uint32_t B2gSearch(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) +{ B2gCtx *ctx = (B2gCtx *)mpm_ctx->ctx; #ifdef B2G_COUNTERS B2gThreadCtx *tctx = (B2gThreadCtx *)mpm_thread_ctx->ctx; @@ -1115,7 +1140,8 @@ skip_loop: } #ifdef B2G_SEARCH2 -uint32_t B2gSearch2(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) { +uint32_t B2gSearch2(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) +{ B2gCtx *ctx = (B2gCtx *)mpm_ctx->ctx; uint8_t *bufmin = buf; uint8_t *bufend = buf + buflen - 1; @@ -1187,7 +1213,8 @@ uint32_t B2gSearch2(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatche } #endif -uint32_t B2gSearch1(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) { +uint32_t B2gSearch1(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) +{ SCEnter(); B2gCtx *ctx = (B2gCtx *)mpm_ctx->ctx; @@ -1245,7 +1272,8 @@ uint32_t B2gSearch1(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatche */ #ifdef UNITTESTS -static int B2gTestInit01 (void) { +static int B2gTestInit01 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1266,7 +1294,8 @@ static int B2gTestInit01 (void) { } #if 0 -static int B2gTestS0Init01 (void) { +static int B2gTestS0Init01 (void) +{ int result = 0; MpmCtx mpm_ctx; MpmInitCtx(&mpm_ctx, MPM_B2G); @@ -1285,7 +1314,8 @@ static int B2gTestS0Init01 (void) { return result; } -static int B2gTestS0Init02 (void) { +static int B2gTestS0Init02 (void) +{ int result = 0; MpmCtx mpm_ctx; MpmInitCtx(&mpm_ctx, MPM_B2G); @@ -1305,7 +1335,8 @@ static int B2gTestS0Init02 (void) { return result; } -static int B2gTestS0Init03 (void) { +static int B2gTestS0Init03 (void) +{ int result = 0; MpmCtx mpm_ctx; MpmInitCtx(&mpm_ctx, MPM_B2G); @@ -1325,7 +1356,8 @@ static int B2gTestS0Init03 (void) { return result; } -static int B2gTestS0Init04 (void) { +static int B2gTestS0Init04 (void) +{ int result = 0; MpmCtx mpm_ctx; MpmInitCtx(&mpm_ctx, MPM_B2G); @@ -1344,7 +1376,8 @@ static int B2gTestS0Init04 (void) { return result; } -static int B2gTestS0Init05 (void) { +static int B2gTestS0Init05 (void) +{ int result = 0; MpmCtx mpm_ctx; MpmInitCtx(&mpm_ctx, MPM_B2G); @@ -1364,7 +1397,8 @@ static int B2gTestS0Init05 (void) { } #endif -static int B2gTestSearch01 (void) { +static int B2gTestSearch01 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1389,7 +1423,8 @@ static int B2gTestSearch01 (void) { return result; } -static int B2gTestSearch02 (void) { +static int B2gTestSearch02 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1414,7 +1449,8 @@ static int B2gTestSearch02 (void) { return result; } -static int B2gTestSearch03 (void) { +static int B2gTestSearch03 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1442,7 +1478,8 @@ static int B2gTestSearch03 (void) { } /* test patterns longer than 'm'. M is 4 here. */ -static int B2gTestSearch04 (void) { +static int B2gTestSearch04 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1470,7 +1507,8 @@ static int B2gTestSearch04 (void) { } /* case insensitive test patterns longer than 'm'. M is 4 here. */ -static int B2gTestSearch05 (void) { +static int B2gTestSearch05 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1497,7 +1535,8 @@ static int B2gTestSearch05 (void) { return result; } -static int B2gTestSearch05a (void) { +static int B2gTestSearch05a (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1527,7 +1566,8 @@ static int B2gTestSearch05a (void) { return result; } -static int B2gTestSearch06 (void) { +static int B2gTestSearch06 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1552,7 +1592,8 @@ static int B2gTestSearch06 (void) { return result; } -static int B2gTestSearch07 (void) { +static int B2gTestSearch07 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1583,7 +1624,8 @@ static int B2gTestSearch07 (void) { return result; } -static int B2gTestSearch08 (void) { +static int B2gTestSearch08 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1608,7 +1650,8 @@ static int B2gTestSearch08 (void) { return result; } -static int B2gTestSearch09 (void) { +static int B2gTestSearch09 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1633,7 +1676,8 @@ static int B2gTestSearch09 (void) { return result; } -static int B2gTestSearch10 (void) { +static int B2gTestSearch10 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1663,7 +1707,8 @@ static int B2gTestSearch10 (void) { return result; } -static int B2gTestSearch11 (void) { +static int B2gTestSearch11 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1689,7 +1734,8 @@ static int B2gTestSearch11 (void) { return result; } -static int B2gTestSearch12 (void) { +static int B2gTestSearch12 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1715,7 +1761,8 @@ static int B2gTestSearch12 (void) { return result; } -static int B2gTestSearch13 (void) { +static int B2gTestSearch13 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1740,7 +1787,8 @@ static int B2gTestSearch13 (void) { return result; } -static int B2gTestSearch14 (void) { +static int B2gTestSearch14 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1765,7 +1813,8 @@ static int B2gTestSearch14 (void) { return result; } -static int B2gTestSearch15 (void) { +static int B2gTestSearch15 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1790,7 +1839,8 @@ static int B2gTestSearch15 (void) { return result; } -static int B2gTestSearch16 (void) { +static int B2gTestSearch16 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1815,7 +1865,8 @@ static int B2gTestSearch16 (void) { return result; } -static int B2gTestSearch17 (void) { +static int B2gTestSearch17 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1840,7 +1891,8 @@ static int B2gTestSearch17 (void) { return result; } -static int B2gTestSearch18 (void) { +static int B2gTestSearch18 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1865,7 +1917,8 @@ static int B2gTestSearch18 (void) { return result; } -static int B2gTestSearch19 (void) { +static int B2gTestSearch19 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1890,7 +1943,8 @@ static int B2gTestSearch19 (void) { return result; } -static int B2gTestSearch20 (void) { +static int B2gTestSearch20 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1917,7 +1971,8 @@ static int B2gTestSearch20 (void) { return result; } -static int B2gTestSearch21 (void) { +static int B2gTestSearch21 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1944,7 +1999,8 @@ static int B2gTestSearch21 (void) { #endif /* UNITTESTS */ #if 0 -static int B2gTestSearchXX (void) { +static int B2gTestSearchXX (void) +{ MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; @@ -2661,7 +2717,8 @@ static int B2gTestSearchXX (void) { } #endif -void B2gRegisterTests(void) { +void B2gRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("B2gTestInit01", B2gTestInit01, 1); /* diff --git a/src/util-mpm-b2gc.c b/src/util-mpm-b2gc.c index 22d9f3b42d..b80100d5c3 100644 --- a/src/util-mpm-b2gc.c +++ b/src/util-mpm-b2gc.c @@ -85,7 +85,8 @@ void B2gcPrintInfo(MpmCtx *mpm_ctx); void B2gcPrintSearchStats(MpmThreadCtx *mpm_thread_ctx); void B2gcRegisterTests(void); -void MpmB2gcRegister (void) { +void MpmB2gcRegister (void) +{ mpm_table[MPM_B2GC].name = "b2gc"; mpm_table[MPM_B2GC].max_pattern_length = B2GC_WORD_SIZE; @@ -104,7 +105,8 @@ void MpmB2gcRegister (void) { } #ifdef PRINTMATCH -static void prt (uint8_t *buf, uint16_t buflen) { +static void prt (uint8_t *buf, uint16_t buflen) +{ uint16_t i; for (i = 0; i < buflen; i++) { @@ -115,7 +117,8 @@ static void prt (uint8_t *buf, uint16_t buflen) { } #endif -void B2gcPrintInfo(MpmCtx *mpm_ctx) { +void B2gcPrintInfo(MpmCtx *mpm_ctx) +{ B2gcCtx *ctx = (B2gcCtx *)mpm_ctx->ctx; printf("MPM B2gc Information:\n"); @@ -133,7 +136,8 @@ void B2gcPrintInfo(MpmCtx *mpm_ctx) { } static inline int -memcmp_lowercase(const uint8_t *s1, const uint8_t *s2, const uint16_t n) { +memcmp_lowercase(const uint8_t *s1, const uint8_t *s2, const uint16_t n) +{ size_t i; /* check backwards because we already tested the first @@ -149,7 +153,8 @@ memcmp_lowercase(const uint8_t *s1, const uint8_t *s2, const uint16_t n) { } static inline int -memcmp_lowercase2(uint8_t *s1, uint8_t *s2, uint16_t n) { +memcmp_lowercase2(uint8_t *s1, uint8_t *s2, uint16_t n) +{ size_t i; /* check backwards because we already tested the first @@ -164,14 +169,16 @@ memcmp_lowercase2(uint8_t *s1, uint8_t *s2, uint16_t n) { return 0; } -static inline void memcpy_tolower(uint8_t *d, uint8_t *s, uint16_t len) { +static inline void memcpy_tolower(uint8_t *d, uint8_t *s, uint16_t len) +{ uint16_t i; for (i = 0; i < len; i++) { d[i] = u8_tolower(s[i]); } } -static inline B2gcPattern *B2gcAllocPattern(MpmCtx *mpm_ctx) { +static inline B2gcPattern *B2gcAllocPattern(MpmCtx *mpm_ctx) +{ B2gcPattern *p = SCMalloc(sizeof(B2gcPattern)); if (unlikely(p == NULL)) return NULL; @@ -185,7 +192,8 @@ static inline B2gcPattern *B2gcAllocPattern(MpmCtx *mpm_ctx) { /** \internal * \brief Free a init hash pattern */ -static void B2gcFreePattern(MpmCtx *mpm_ctx, B2gcPattern *p) { +static void B2gcFreePattern(MpmCtx *mpm_ctx, B2gcPattern *p) +{ if (p != NULL) { if (p->pat != NULL) { SCFree(p->pat); @@ -208,7 +216,8 @@ static void B2gcFreePattern(MpmCtx *mpm_ctx, B2gcPattern *p) { * \param sid signature id (internal id) * \param flags pattern MPM_PATTERN_* flags */ -static int B2gcAddPattern(MpmCtx *mpm_ctx, uint8_t *pat, uint16_t patlen, uint16_t offset, uint16_t depth, uint32_t pid, uint32_t sid, uint8_t flags) { +static int B2gcAddPattern(MpmCtx *mpm_ctx, uint8_t *pat, uint16_t patlen, uint16_t offset, uint16_t depth, uint32_t pid, uint32_t sid, uint8_t flags) +{ B2gcCtx *ctx = (B2gcCtx *)mpm_ctx->ctx; SCLogDebug("ctx %p len %"PRIu16" pid %" PRIu32, ctx, patlen, pid); @@ -277,7 +286,8 @@ int B2gcAddPatternCS(MpmCtx *mpm_ctx, uint8_t *pat, uint16_t patlen, return B2gcAddPattern(mpm_ctx, pat, patlen, offset, depth, pid, sid, flags); } -static inline uint32_t B2gcBloomHash(void *data, uint16_t datalen, uint8_t iter, uint32_t hash_size) { +static inline uint32_t B2gcBloomHash(void *data, uint16_t datalen, uint8_t iter, uint32_t hash_size) +{ uint8_t *d = (uint8_t *)data; uint16_t i; uint32_t hash = (uint32_t)u8_tolower(*d); @@ -292,7 +302,8 @@ static inline uint32_t B2gcBloomHash(void *data, uint16_t datalen, uint8_t iter, return hash; } -static uint32_t B2gcHashPatternInitHash(HashListTable *ht, void *pattern, uint16_t len) { +static uint32_t B2gcHashPatternInitHash(HashListTable *ht, void *pattern, uint16_t len) +{ BUG_ON(len != sizeof(B2gcPattern)); BUG_ON(pattern == NULL); @@ -317,7 +328,8 @@ static uint32_t B2gcHashPatternInitHash(HashListTable *ht, void *pattern, uint16 static B2GC_TYPE m; static int b2gc_sorthash_mode = B2GC_SORTHASH_MODE_LL; -static uint32_t B2gcHashPatternSortHash(HashListTable *ht, void *pattern, uint16_t len) { +static uint32_t B2gcHashPatternSortHash(HashListTable *ht, void *pattern, uint16_t len) +{ BUG_ON(len != sizeof(B2gcPattern)); BUG_ON(pattern == NULL); @@ -337,7 +349,8 @@ static uint32_t B2gcHashPatternSortHash(HashListTable *ht, void *pattern, uint16 SCReturnUInt(hash); } -static uint32_t B2gcHashPatternSortHash1(HashListTable *ht, void *pattern, uint16_t len) { +static uint32_t B2gcHashPatternSortHash1(HashListTable *ht, void *pattern, uint16_t len) +{ BUG_ON(len != sizeof(B2gcPattern)); BUG_ON(pattern == NULL); @@ -346,7 +359,8 @@ static uint32_t B2gcHashPatternSortHash1(HashListTable *ht, void *pattern, uint1 } static char B2gcHashPatternCompare(void *pattern1, uint16_t len1, - void *pattern2, uint16_t len2) { + void *pattern2, uint16_t len2) +{ BUG_ON(len1 != sizeof(B2gcPattern)); BUG_ON(len2 != sizeof(B2gcPattern)); @@ -360,7 +374,8 @@ static char B2gcHashPatternCompare(void *pattern1, uint16_t len1, return 1; } -static void B2gcHashPatternFree(void *pattern) { +static void B2gcHashPatternFree(void *pattern) +{ B2gcPattern *p = (B2gcPattern *)pattern; SCFree(p->pat); @@ -368,7 +383,8 @@ static void B2gcHashPatternFree(void *pattern) { SCFree(pattern); } -static void B2gcAddToMatchArray(MpmCtx *mpm_ctx, B2gcPattern *p, int j) { +static void B2gcAddToMatchArray(MpmCtx *mpm_ctx, B2gcPattern *p, int j) +{ B2gcCtx *ctx = (B2gcCtx *)mpm_ctx->ctx; if (p->flags & MPM_PATTERN_FLAG_NOCASE) { @@ -396,7 +412,8 @@ static void B2gcAddToMatchArray(MpmCtx *mpm_ctx, B2gcPattern *p, int j) { } } -int B2gcBuildMatchArray(MpmCtx *mpm_ctx, HashListTable *b2gc_sort_hash) { +int B2gcBuildMatchArray(MpmCtx *mpm_ctx, HashListTable *b2gc_sort_hash) +{ SCEnter(); B2gcCtx *ctx = (B2gcCtx *)mpm_ctx->ctx; @@ -442,7 +459,8 @@ int B2gcBuildMatchArray(MpmCtx *mpm_ctx, HashListTable *b2gc_sort_hash) { SCReturnInt(0); } -static void B2gcAddCopyToHash(MpmCtx *mpm_ctx, HashListTable *ht, B2gcPattern *p) { +static void B2gcAddCopyToHash(MpmCtx *mpm_ctx, HashListTable *ht, B2gcPattern *p) +{ B2gcPattern *pcopy = B2gcAllocPattern(mpm_ctx); BUG_ON(pcopy == NULL); pcopy->id = p->id; @@ -457,7 +475,8 @@ static void B2gcAddCopyToHash(MpmCtx *mpm_ctx, HashListTable *ht, B2gcPattern *p HashListTableAdd(ht, (void *)pcopy, sizeof(B2gcPattern)); } -static int B2gcAddToHash(MpmCtx *mpm_ctx, HashListTable *b2gc_sort_hash, B2gcPattern *p) { +static int B2gcAddToHash(MpmCtx *mpm_ctx, HashListTable *b2gc_sort_hash, B2gcPattern *p) +{ B2gcCtx *ctx = (B2gcCtx *)mpm_ctx->ctx; int added = 0; //printf("%c.%c\n", p->pat[ctx->m - 2], p->pat[ctx->m - 1]); @@ -497,7 +516,8 @@ static int B2gcAddToHash(MpmCtx *mpm_ctx, HashListTable *b2gc_sort_hash, B2gcPat return added; } -static void B2gcPrepareHash(MpmCtx *mpm_ctx) { +static void B2gcPrepareHash(MpmCtx *mpm_ctx) +{ B2gcCtx *ctx = (B2gcCtx *)mpm_ctx->ctx; HashListTable *b2gc_sort_hash = NULL; HashListTable *b2gc_sort_hash1 = NULL; @@ -757,7 +777,8 @@ static void B2gcPrepareHash(MpmCtx *mpm_ctx) { b2gc_sort_hash1 = NULL; } -int B2gcPreparePatterns(MpmCtx *mpm_ctx) { +int B2gcPreparePatterns(MpmCtx *mpm_ctx) +{ B2gcCtx *ctx = (B2gcCtx *)mpm_ctx->ctx; /* set 'm' to the smallest pattern size */ @@ -812,7 +833,8 @@ int B2gcPreparePatterns(MpmCtx *mpm_ctx) { return 0; } -void B2gcPrintSearchStats(MpmThreadCtx *mpm_thread_ctx) { +void B2gcPrintSearchStats(MpmThreadCtx *mpm_thread_ctx) +{ #ifdef B2GC_COUNTERS B2gcThreadCtx *tctx = (B2gcThreadCtx *)mpm_thread_ctx->ctx; @@ -901,7 +923,8 @@ static void B2gcGetConfig() } } -void B2gcInitCtx (MpmCtx *mpm_ctx) { +void B2gcInitCtx (MpmCtx *mpm_ctx) +{ SCLogDebug("mpm_ctx %p, ctx %p", mpm_ctx, mpm_ctx->ctx); if (mpm_ctx->ctx != NULL) @@ -938,7 +961,8 @@ void B2gcInitCtx (MpmCtx *mpm_ctx) { SCReturn; } -void B2gcDestroyCtx(MpmCtx *mpm_ctx) { +void B2gcDestroyCtx(MpmCtx *mpm_ctx) +{ SCLogDebug("mpm_ctx %p", mpm_ctx); @@ -1001,7 +1025,8 @@ void B2gcDestroyCtx(MpmCtx *mpm_ctx) { mpm_ctx->memory_size -= sizeof(B2gcCtx); } -void B2gcThreadInitCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, uint32_t matchsize) { +void B2gcThreadInitCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, uint32_t matchsize) +{ memset(mpm_thread_ctx, 0, sizeof(MpmThreadCtx)); if (sizeof(B2gcThreadCtx) > 0) { /* size can be null when optimized */ @@ -1017,7 +1042,8 @@ void B2gcThreadInitCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, uint32_t m } } -void B2gcThreadDestroyCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx) { +void B2gcThreadDestroyCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx) +{ B2gcThreadCtx *ctx = (B2gcThreadCtx *)mpm_thread_ctx->ctx; B2gcPrintSearchStats(mpm_thread_ctx); @@ -1029,12 +1055,14 @@ void B2gcThreadDestroyCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx) { } } -uint32_t B2gcSearchWrap(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) { +uint32_t B2gcSearchWrap(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) +{ B2gcCtx *ctx = (B2gcCtx *)mpm_ctx->ctx; return ctx ? ctx->Search(mpm_ctx, mpm_thread_ctx, pmq, buf, buflen) : 0; } -uint32_t B2gcSearchBNDMq(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) { +uint32_t B2gcSearchBNDMq(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) +{ B2gcCtx *ctx = (B2gcCtx *)mpm_ctx->ctx; #ifdef B2GC_COUNTERS B2gcThreadCtx *tctx = (B2gcThreadCtx *)mpm_thread_ctx->ctx; @@ -1137,7 +1165,8 @@ uint32_t B2gcSearchBNDMq(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternM return matches; } -uint32_t B2gcSearch(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) { +uint32_t B2gcSearch(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) +{ B2gcCtx *ctx = (B2gcCtx *)mpm_ctx->ctx; #ifdef B2GC_COUNTERS B2gcThreadCtx *tctx = (B2gcThreadCtx *)mpm_thread_ctx->ctx; @@ -1213,7 +1242,8 @@ skip_loop: return matches; } -uint32_t B2gcSearch1(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) { +uint32_t B2gcSearch1(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) +{ SCEnter(); B2gcCtx *ctx = (B2gcCtx *)mpm_ctx->ctx; @@ -1269,7 +1299,8 @@ uint32_t B2gcSearch1(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatch */ #ifdef UNITTESTS -static int B2gcTestMacro01 (void) { +static int B2gcTestMacro01 (void) +{ int result = 1; B2gcPatternHdr a; @@ -1284,7 +1315,8 @@ static int B2gcTestMacro01 (void) { return result; } -static int B2gcTestInit01 (void) { +static int B2gcTestInit01 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1305,7 +1337,8 @@ static int B2gcTestInit01 (void) { } #if 0 -static int B2gcTestS0Init01 (void) { +static int B2gcTestS0Init01 (void) +{ int result = 0; MpmCtx mpm_ctx; MpmInitCtx(&mpm_ctx, MPM_B2GC); @@ -1324,7 +1357,8 @@ static int B2gcTestS0Init01 (void) { return result; } -static int B2gcTestS0Init02 (void) { +static int B2gcTestS0Init02 (void) +{ int result = 0; MpmCtx mpm_ctx; MpmInitCtx(&mpm_ctx, MPM_B2GC); @@ -1344,7 +1378,8 @@ static int B2gcTestS0Init02 (void) { return result; } -static int B2gcTestS0Init03 (void) { +static int B2gcTestS0Init03 (void) +{ int result = 0; MpmCtx mpm_ctx; MpmInitCtx(&mpm_ctx, MPM_B2GC); @@ -1364,7 +1399,8 @@ static int B2gcTestS0Init03 (void) { return result; } -static int B2gcTestS0Init04 (void) { +static int B2gcTestS0Init04 (void) +{ int result = 0; MpmCtx mpm_ctx; MpmInitCtx(&mpm_ctx, MPM_B2GC); @@ -1383,7 +1419,8 @@ static int B2gcTestS0Init04 (void) { return result; } -static int B2gcTestS0Init05 (void) { +static int B2gcTestS0Init05 (void) +{ int result = 0; MpmCtx mpm_ctx; MpmInitCtx(&mpm_ctx, MPM_B2GC); @@ -1403,7 +1440,8 @@ static int B2gcTestS0Init05 (void) { } #endif -static int B2gcTestSearch01 (void) { +static int B2gcTestSearch01 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1428,7 +1466,8 @@ static int B2gcTestSearch01 (void) { return result; } -static int B2gcTestSearch02 (void) { +static int B2gcTestSearch02 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1453,7 +1492,8 @@ static int B2gcTestSearch02 (void) { return result; } -static int B2gcTestSearch03 (void) { +static int B2gcTestSearch03 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1481,7 +1521,8 @@ static int B2gcTestSearch03 (void) { } /* test patterns longer than 'm'. M is 4 here. */ -static int B2gcTestSearch04 (void) { +static int B2gcTestSearch04 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1509,7 +1550,8 @@ static int B2gcTestSearch04 (void) { } /* case insensitive test patterns longer than 'm'. M is 4 here. */ -static int B2gcTestSearch05 (void) { +static int B2gcTestSearch05 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1536,7 +1578,8 @@ static int B2gcTestSearch05 (void) { return result; } -static int B2gcTestSearch05a (void) { +static int B2gcTestSearch05a (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1566,7 +1609,8 @@ static int B2gcTestSearch05a (void) { return result; } -static int B2gcTestSearch05b (void) { +static int B2gcTestSearch05b (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1596,7 +1640,8 @@ static int B2gcTestSearch05b (void) { return result; } -static int B2gcTestSearch05c (void) { +static int B2gcTestSearch05c (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1622,7 +1667,8 @@ static int B2gcTestSearch05c (void) { return result; } -static int B2gcTestSearch05d (void) { +static int B2gcTestSearch05d (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1648,7 +1694,8 @@ static int B2gcTestSearch05d (void) { return result; } -static int B2gcTestSearch06 (void) { +static int B2gcTestSearch06 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1673,7 +1720,8 @@ static int B2gcTestSearch06 (void) { return result; } -static int B2gcTestSearch06a (void) { +static int B2gcTestSearch06a (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1698,7 +1746,8 @@ static int B2gcTestSearch06a (void) { return result; } -static int B2gcTestSearch07 (void) { +static int B2gcTestSearch07 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1732,7 +1781,8 @@ static int B2gcTestSearch07 (void) { return result; } -static int B2gcTestSearch07a (void) { +static int B2gcTestSearch07a (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1757,7 +1807,8 @@ static int B2gcTestSearch07a (void) { return result; } -static int B2gcTestSearch08 (void) { +static int B2gcTestSearch08 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1782,7 +1833,8 @@ static int B2gcTestSearch08 (void) { return result; } -static int B2gcTestSearch09 (void) { +static int B2gcTestSearch09 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1807,7 +1859,8 @@ static int B2gcTestSearch09 (void) { return result; } -static int B2gcTestSearch10 (void) { +static int B2gcTestSearch10 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1837,7 +1890,8 @@ static int B2gcTestSearch10 (void) { return result; } -static int B2gcTestSearch11 (void) { +static int B2gcTestSearch11 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1863,7 +1917,8 @@ static int B2gcTestSearch11 (void) { return result; } -static int B2gcTestSearch12 (void) { +static int B2gcTestSearch12 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1889,7 +1944,8 @@ static int B2gcTestSearch12 (void) { return result; } -static int B2gcTestSearch13 (void) { +static int B2gcTestSearch13 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1914,7 +1970,8 @@ static int B2gcTestSearch13 (void) { return result; } -static int B2gcTestSearch14 (void) { +static int B2gcTestSearch14 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1939,7 +1996,8 @@ static int B2gcTestSearch14 (void) { return result; } -static int B2gcTestSearch15 (void) { +static int B2gcTestSearch15 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1964,7 +2022,8 @@ static int B2gcTestSearch15 (void) { return result; } -static int B2gcTestSearch16 (void) { +static int B2gcTestSearch16 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1989,7 +2048,8 @@ static int B2gcTestSearch16 (void) { return result; } -static int B2gcTestSearch17 (void) { +static int B2gcTestSearch17 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2014,7 +2074,8 @@ static int B2gcTestSearch17 (void) { return result; } -static int B2gcTestSearch18 (void) { +static int B2gcTestSearch18 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2039,7 +2100,8 @@ static int B2gcTestSearch18 (void) { return result; } -static int B2gcTestSearch19 (void) { +static int B2gcTestSearch19 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2064,7 +2126,8 @@ static int B2gcTestSearch19 (void) { return result; } -static int B2gcTestSearch20 (void) { +static int B2gcTestSearch20 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2091,7 +2154,8 @@ static int B2gcTestSearch20 (void) { return result; } -static int B2gcTestSearch21 (void) { +static int B2gcTestSearch21 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2118,7 +2182,8 @@ static int B2gcTestSearch21 (void) { #endif /* UNITTESTS */ #if 0 -static int B2gcTestSearchXX (void) { +static int B2gcTestSearchXX (void) +{ MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; @@ -2834,7 +2899,8 @@ static int B2gcTestSearchXX (void) { } #endif -void B2gcRegisterTests(void) { +void B2gcRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("B2gcTestMacro01", B2gcTestMacro01, 1); UtRegisterTest("B2gcTestInit01", B2gcTestInit01, 1); diff --git a/src/util-mpm-b2gm.c b/src/util-mpm-b2gm.c index 101f90cbfa..2a0dfb14a6 100644 --- a/src/util-mpm-b2gm.c +++ b/src/util-mpm-b2gm.c @@ -76,7 +76,8 @@ void B2gmPrintInfo(MpmCtx *mpm_ctx); void B2gmPrintSearchStats(MpmThreadCtx *mpm_thread_ctx); void B2gmRegisterTests(void); -void MpmB2gmRegister (void) { +void MpmB2gmRegister (void) +{ mpm_table[MPM_B2GM].name = "b2gm"; mpm_table[MPM_B2GM].max_pattern_length = B2GM_WORD_SIZE; @@ -95,7 +96,8 @@ void MpmB2gmRegister (void) { } #ifdef PRINTMATCH -static void prt (uint8_t *buf, uint16_t buflen) { +static void prt (uint8_t *buf, uint16_t buflen) +{ uint16_t i; for (i = 0; i < buflen; i++) { @@ -106,7 +108,8 @@ static void prt (uint8_t *buf, uint16_t buflen) { } #endif -void B2gmPrintInfo(MpmCtx *mpm_ctx) { +void B2gmPrintInfo(MpmCtx *mpm_ctx) +{ B2gmCtx *ctx = (B2gmCtx *)mpm_ctx->ctx; printf("MPM B2gm Information:\n"); @@ -124,7 +127,8 @@ void B2gmPrintInfo(MpmCtx *mpm_ctx) { printf("\n"); } -static inline B2gmPattern *B2gmAllocPattern(MpmCtx *mpm_ctx) { +static inline B2gmPattern *B2gmAllocPattern(MpmCtx *mpm_ctx) +{ B2gmPattern *p = SCMalloc(sizeof(B2gmPattern)); if (unlikely(p == NULL)) return NULL; @@ -136,7 +140,8 @@ static inline B2gmPattern *B2gmAllocPattern(MpmCtx *mpm_ctx) { } static inline B2gmPattern * -B2gmAllocHashItem(MpmCtx *mpm_ctx) { +B2gmAllocHashItem(MpmCtx *mpm_ctx) +{ B2gmPattern *hi = SCMalloc(sizeof(B2gmPattern)); if (unlikely(hi == NULL)) return NULL; @@ -147,7 +152,8 @@ B2gmAllocHashItem(MpmCtx *mpm_ctx) { return hi; } -static void B2gmHashFree(MpmCtx *mpm_ctx, B2gmPattern *hi) { +static void B2gmHashFree(MpmCtx *mpm_ctx, B2gmPattern *hi) +{ if (hi == NULL) return; @@ -159,7 +165,8 @@ static void B2gmHashFree(MpmCtx *mpm_ctx, B2gmPattern *hi) { B2gmHashFree(mpm_ctx, t); } -static inline void memcpy_tolower(uint8_t *d, uint8_t *s, uint16_t len) { +static inline void memcpy_tolower(uint8_t *d, uint8_t *s, uint16_t len) +{ uint16_t i; for (i = 0; i < len; i++) { d[i] = u8_tolower(s[i]); @@ -169,7 +176,8 @@ static inline void memcpy_tolower(uint8_t *d, uint8_t *s, uint16_t len) { /* * INIT HASH START */ -static inline uint32_t B2gmInitHash(B2gmPattern *p) { +static inline uint32_t B2gmInitHash(B2gmPattern *p) +{ uint32_t hash = p->len * p->pat[0]; if (p->len > 1) hash += p->pat[1]; @@ -177,7 +185,8 @@ static inline uint32_t B2gmInitHash(B2gmPattern *p) { return (hash % INIT_HASH_SIZE); } -static inline uint32_t B2gmInitHashRaw(uint8_t *pat, uint16_t patlen) { +static inline uint32_t B2gmInitHashRaw(uint8_t *pat, uint16_t patlen) +{ uint32_t hash = patlen * pat[0]; if (patlen > 1) hash += pat[1]; @@ -185,7 +194,8 @@ static inline uint32_t B2gmInitHashRaw(uint8_t *pat, uint16_t patlen) { return (hash % INIT_HASH_SIZE); } -static inline int B2gmInitHashAdd(B2gmCtx *ctx, B2gmPattern *p) { +static inline int B2gmInitHashAdd(B2gmCtx *ctx, B2gmPattern *p) +{ uint32_t hash = B2gmInitHash(p); if (ctx->init_hash[hash] == NULL) { @@ -209,7 +219,8 @@ static inline int B2gmInitHashAdd(B2gmCtx *ctx, B2gmPattern *p) { static inline int B2gmCmpPattern(B2gmPattern *p, uint8_t *pat, uint16_t patlen, char flags); -static inline B2gmPattern *B2gmInitHashLookup(B2gmCtx *ctx, uint8_t *pat, uint16_t patlen, char flags) { +static inline B2gmPattern *B2gmInitHashLookup(B2gmCtx *ctx, uint8_t *pat, uint16_t patlen, char flags) +{ uint32_t hash = B2gmInitHashRaw(pat,patlen); if (ctx->init_hash[hash] == NULL) { @@ -225,7 +236,8 @@ static inline B2gmPattern *B2gmInitHashLookup(B2gmCtx *ctx, uint8_t *pat, uint16 return NULL; } -static inline int B2gmCmpPattern(B2gmPattern *p, uint8_t *pat, uint16_t patlen, char flags) { +static inline int B2gmCmpPattern(B2gmPattern *p, uint8_t *pat, uint16_t patlen, char flags) +{ if (p->len != patlen) return 0; @@ -242,7 +254,8 @@ static inline int B2gmCmpPattern(B2gmPattern *p, uint8_t *pat, uint16_t patlen, * INIT HASH END */ -void B2gmFreePattern(MpmCtx *mpm_ctx, B2gmPattern *p) { +void B2gmFreePattern(MpmCtx *mpm_ctx, B2gmPattern *p) +{ if (p != NULL) { if (p->pat != NULL) { SCFree(p->pat); @@ -265,7 +278,8 @@ void B2gmFreePattern(MpmCtx *mpm_ctx, B2gmPattern *p) { * \param sid signature id (internal id) * \param flags pattern MPM_PATTERN_* flags */ -static int B2gmAddPattern(MpmCtx *mpm_ctx, uint8_t *pat, uint16_t patlen, uint16_t offset, uint16_t depth, uint32_t pid, uint32_t sid, uint8_t flags) { +static int B2gmAddPattern(MpmCtx *mpm_ctx, uint8_t *pat, uint16_t patlen, uint16_t offset, uint16_t depth, uint32_t pid, uint32_t sid, uint8_t flags) +{ B2gmCtx *ctx = (B2gmCtx *)mpm_ctx->ctx; SCLogDebug("ctx %p len %"PRIu16" pid %" PRIu32, ctx, patlen, pid); @@ -343,7 +357,8 @@ int B2gmAddPatternCS(MpmCtx *mpm_ctx, uint8_t *pat, uint16_t patlen, return B2gmAddPattern(mpm_ctx, pat, patlen, offset, depth, pid, sid, flags); } -static uint32_t B2gmHashPatternSortHash1(HashListTable *ht, void *pattern, uint16_t len) { +static uint32_t B2gmHashPatternSortHash1(HashListTable *ht, void *pattern, uint16_t len) +{ BUG_ON(len != sizeof(B2gmPattern)); BUG_ON(pattern == NULL); @@ -352,7 +367,8 @@ static uint32_t B2gmHashPatternSortHash1(HashListTable *ht, void *pattern, uint1 } static char B2gmHashPatternCompare(void *pattern1, uint16_t len1, - void *pattern2, uint16_t len2) { + void *pattern2, uint16_t len2) +{ BUG_ON(len1 != sizeof(B2gmPattern)); BUG_ON(len2 != sizeof(B2gmPattern)); @@ -366,7 +382,8 @@ static char B2gmHashPatternCompare(void *pattern1, uint16_t len1, return 1; } -static inline uint32_t B2gmBloomHash(void *data, uint16_t datalen, uint8_t iter, uint32_t hash_size) { +static inline uint32_t B2gmBloomHash(void *data, uint16_t datalen, uint8_t iter, uint32_t hash_size) +{ uint8_t *d = (uint8_t *)data; uint16_t i; uint32_t hash = (uint32_t)u8_tolower(*d); @@ -381,7 +398,8 @@ static inline uint32_t B2gmBloomHash(void *data, uint16_t datalen, uint8_t iter, return hash; } -static void B2gmPrepareHashAddPattern(MpmCtx *mpm_ctx, uint16_t idx, uint32_t i) { +static void B2gmPrepareHashAddPattern(MpmCtx *mpm_ctx, uint16_t idx, uint32_t i) +{ B2gmCtx *ctx = (B2gmCtx *)mpm_ctx->ctx; if (ctx->lookup[idx].hash == NULL) { @@ -421,7 +439,8 @@ error: return; } -static void B2gmPrepareHash(MpmCtx *mpm_ctx) { +static void B2gmPrepareHash(MpmCtx *mpm_ctx) +{ B2gmCtx *ctx = (B2gmCtx *)mpm_ctx->ctx; uint16_t i; uint16_t size1 = 1; @@ -565,7 +584,8 @@ static void B2gmPrepareHash(MpmCtx *mpm_ctx) { return; } -static void B2gmAddToMatchArray(MpmCtx *mpm_ctx, B2gmPattern *p, int j) { +static void B2gmAddToMatchArray(MpmCtx *mpm_ctx, B2gmPattern *p, int j) +{ B2gmCtx *ctx = (B2gmCtx *)mpm_ctx->ctx; if (p->flags & MPM_PATTERN_FLAG_NOCASE) { @@ -593,7 +613,8 @@ static void B2gmAddToMatchArray(MpmCtx *mpm_ctx, B2gmPattern *p, int j) { } } -int B2gmBuildMatchArray(MpmCtx *mpm_ctx) { +int B2gmBuildMatchArray(MpmCtx *mpm_ctx) +{ SCEnter(); B2gmCtx *ctx = (B2gmCtx *)mpm_ctx->ctx; @@ -630,7 +651,8 @@ int B2gmBuildMatchArray(MpmCtx *mpm_ctx) { SCReturnInt(0); } -int B2gmPreparePatterns(MpmCtx *mpm_ctx) { +int B2gmPreparePatterns(MpmCtx *mpm_ctx) +{ B2gmCtx *ctx = (B2gmCtx *)mpm_ctx->ctx; /* alloc the lookup array */ @@ -699,7 +721,8 @@ error: return -1; } -void B2gmPrintSearchStats(MpmThreadCtx *mpm_thread_ctx) { +void B2gmPrintSearchStats(MpmThreadCtx *mpm_thread_ctx) +{ #ifdef B2GM_COUNTERS B2gmThreadCtx *tctx = (B2gmThreadCtx *)mpm_thread_ctx->ctx; @@ -723,7 +746,8 @@ void B2gmPrintSearchStats(MpmThreadCtx *mpm_thread_ctx) { } static inline int -memcmp_lowercase(const uint8_t *s1, const uint8_t *s2, const uint16_t n) { +memcmp_lowercase(const uint8_t *s1, const uint8_t *s2, const uint16_t n) +{ size_t i; /* check backwards because we already tested the first @@ -808,7 +832,8 @@ static void B2gmGetConfig() } } -void B2gmInitCtx (MpmCtx *mpm_ctx) { +void B2gmInitCtx (MpmCtx *mpm_ctx) +{ SCLogDebug("mpm_ctx %p, ctx %p", mpm_ctx, mpm_ctx->ctx); BUG_ON(mpm_ctx->ctx != NULL); @@ -847,7 +872,8 @@ void B2gmInitCtx (MpmCtx *mpm_ctx) { SCReturn; } -void B2gmDestroyCtx(MpmCtx *mpm_ctx) { +void B2gmDestroyCtx(MpmCtx *mpm_ctx) +{ SCLogDebug("mpm_ctx %p", mpm_ctx); B2gmCtx *ctx = (B2gmCtx *)mpm_ctx->ctx; @@ -903,7 +929,8 @@ void B2gmDestroyCtx(MpmCtx *mpm_ctx) { mpm_ctx->memory_size -= sizeof(B2gmCtx); } -void B2gmThreadInitCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, uint32_t matchsize) { +void B2gmThreadInitCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, uint32_t matchsize) +{ memset(mpm_thread_ctx, 0, sizeof(MpmThreadCtx)); if (sizeof(B2gmThreadCtx) > 0) { /* size can be null when optimized */ @@ -919,7 +946,8 @@ void B2gmThreadInitCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, uint32_t m } } -void B2gmThreadDestroyCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx) { +void B2gmThreadDestroyCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx) +{ B2gmThreadCtx *ctx = (B2gmThreadCtx *)mpm_thread_ctx->ctx; B2gmPrintSearchStats(mpm_thread_ctx); @@ -931,12 +959,14 @@ void B2gmThreadDestroyCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx) { } } -uint32_t B2gmSearchWrap(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) { +uint32_t B2gmSearchWrap(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) +{ B2gmCtx *ctx = (B2gmCtx *)mpm_ctx->ctx; return ctx ? ctx->Search(mpm_ctx, mpm_thread_ctx, pmq, buf, buflen) : 0; } -uint32_t B2gmSearchBNDMq(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) { +uint32_t B2gmSearchBNDMq(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) +{ B2gmCtx *ctx = (B2gmCtx *)mpm_ctx->ctx; #ifdef B2GM_COUNTERS B2gmThreadCtx *tctx = (B2gmThreadCtx *)mpm_thread_ctx->ctx; @@ -1035,7 +1065,8 @@ uint32_t B2gmSearchBNDMq(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternM return matches; } -uint32_t B2gmSearch(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) { +uint32_t B2gmSearch(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) +{ B2gmCtx *ctx = (B2gmCtx *)mpm_ctx->ctx; #ifdef B2GM_COUNTERS B2gmThreadCtx *tctx = (B2gmThreadCtx *)mpm_thread_ctx->ctx; @@ -1128,7 +1159,8 @@ skip_loop: return matches; } -uint32_t B2gmSearch1(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) { +uint32_t B2gmSearch1(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) +{ SCEnter(); B2gmCtx *ctx = (B2gmCtx *)mpm_ctx->ctx; @@ -1184,7 +1216,8 @@ uint32_t B2gmSearch1(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatch */ #ifdef UNITTESTS -static int B2gmTestInit01 (void) { +static int B2gmTestInit01 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1205,7 +1238,8 @@ static int B2gmTestInit01 (void) { } #if 0 -static int B2gmTestS0Init01 (void) { +static int B2gmTestS0Init01 (void) +{ int result = 0; MpmCtx mpm_ctx; MpmInitCtx(&mpm_ctx, MPM_B2GM); @@ -1224,7 +1258,8 @@ static int B2gmTestS0Init01 (void) { return result; } -static int B2gmTestS0Init02 (void) { +static int B2gmTestS0Init02 (void) +{ int result = 0; MpmCtx mpm_ctx; MpmInitCtx(&mpm_ctx, MPM_B2GM); @@ -1244,7 +1279,8 @@ static int B2gmTestS0Init02 (void) { return result; } -static int B2gmTestS0Init03 (void) { +static int B2gmTestS0Init03 (void) +{ int result = 0; MpmCtx mpm_ctx; MpmInitCtx(&mpm_ctx, MPM_B2GM); @@ -1264,7 +1300,8 @@ static int B2gmTestS0Init03 (void) { return result; } -static int B2gmTestS0Init04 (void) { +static int B2gmTestS0Init04 (void) +{ int result = 0; MpmCtx mpm_ctx; MpmInitCtx(&mpm_ctx, MPM_B2GM); @@ -1283,7 +1320,8 @@ static int B2gmTestS0Init04 (void) { return result; } -static int B2gmTestS0Init05 (void) { +static int B2gmTestS0Init05 (void) +{ int result = 0; MpmCtx mpm_ctx; MpmInitCtx(&mpm_ctx, MPM_B2GM); @@ -1303,7 +1341,8 @@ static int B2gmTestS0Init05 (void) { } #endif -static int B2gmTestSearch01 (void) { +static int B2gmTestSearch01 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1328,7 +1367,8 @@ static int B2gmTestSearch01 (void) { return result; } -static int B2gmTestSearch02 (void) { +static int B2gmTestSearch02 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1353,7 +1393,8 @@ static int B2gmTestSearch02 (void) { return result; } -static int B2gmTestSearch02a (void) { +static int B2gmTestSearch02a (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1378,7 +1419,8 @@ static int B2gmTestSearch02a (void) { return result; } -static int B2gmTestSearch02b (void) { +static int B2gmTestSearch02b (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1403,7 +1445,8 @@ static int B2gmTestSearch02b (void) { return result; } -static int B2gmTestSearch03 (void) { +static int B2gmTestSearch03 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1430,7 +1473,8 @@ static int B2gmTestSearch03 (void) { return result; } -static int B2gmTestSearch03a (void) { +static int B2gmTestSearch03a (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1458,7 +1502,8 @@ static int B2gmTestSearch03a (void) { } /* test patterns longer than 'm'. M is 4 here. */ -static int B2gmTestSearch04 (void) { +static int B2gmTestSearch04 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1486,7 +1531,8 @@ static int B2gmTestSearch04 (void) { } /* case insensitive test patterns longer than 'm'. M is 4 here. */ -static int B2gmTestSearch05 (void) { +static int B2gmTestSearch05 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1513,7 +1559,8 @@ static int B2gmTestSearch05 (void) { return result; } -static int B2gmTestSearch05a (void) { +static int B2gmTestSearch05a (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1543,7 +1590,8 @@ static int B2gmTestSearch05a (void) { return result; } -static int B2gmTestSearch06 (void) { +static int B2gmTestSearch06 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1568,7 +1616,8 @@ static int B2gmTestSearch06 (void) { return result; } -static int B2gmTestSearch07 (void) { +static int B2gmTestSearch07 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1602,7 +1651,8 @@ static int B2gmTestSearch07 (void) { return result; } -static int B2gmTestSearch08 (void) { +static int B2gmTestSearch08 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1627,7 +1677,8 @@ static int B2gmTestSearch08 (void) { return result; } -static int B2gmTestSearch09 (void) { +static int B2gmTestSearch09 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1652,7 +1703,8 @@ static int B2gmTestSearch09 (void) { return result; } -static int B2gmTestSearch10 (void) { +static int B2gmTestSearch10 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1682,7 +1734,8 @@ static int B2gmTestSearch10 (void) { return result; } -static int B2gmTestSearch11 (void) { +static int B2gmTestSearch11 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1708,7 +1761,8 @@ static int B2gmTestSearch11 (void) { return result; } -static int B2gmTestSearch12 (void) { +static int B2gmTestSearch12 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1734,7 +1788,8 @@ static int B2gmTestSearch12 (void) { return result; } -static int B2gmTestSearch13 (void) { +static int B2gmTestSearch13 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1759,7 +1814,8 @@ static int B2gmTestSearch13 (void) { return result; } -static int B2gmTestSearch14 (void) { +static int B2gmTestSearch14 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1784,7 +1840,8 @@ static int B2gmTestSearch14 (void) { return result; } -static int B2gmTestSearch15 (void) { +static int B2gmTestSearch15 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1809,7 +1866,8 @@ static int B2gmTestSearch15 (void) { return result; } -static int B2gmTestSearch16 (void) { +static int B2gmTestSearch16 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1834,7 +1892,8 @@ static int B2gmTestSearch16 (void) { return result; } -static int B2gmTestSearch17 (void) { +static int B2gmTestSearch17 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1859,7 +1918,8 @@ static int B2gmTestSearch17 (void) { return result; } -static int B2gmTestSearch18 (void) { +static int B2gmTestSearch18 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1884,7 +1944,8 @@ static int B2gmTestSearch18 (void) { return result; } -static int B2gmTestSearch19 (void) { +static int B2gmTestSearch19 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1909,7 +1970,8 @@ static int B2gmTestSearch19 (void) { return result; } -static int B2gmTestSearch20 (void) { +static int B2gmTestSearch20 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1936,7 +1998,8 @@ static int B2gmTestSearch20 (void) { return result; } -static int B2gmTestSearch21 (void) { +static int B2gmTestSearch21 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1963,7 +2026,8 @@ static int B2gmTestSearch21 (void) { #endif /* UNITTESTS */ #if 0 -static int B2gmTestSearchXX (void) { +static int B2gmTestSearchXX (void) +{ MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; @@ -2680,7 +2744,8 @@ static int B2gmTestSearchXX (void) { } #endif -void B2gmRegisterTests(void) { +void B2gmRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("B2gmTestInit01", B2gmTestInit01, 1); /* diff --git a/src/util-mpm-b3g.c b/src/util-mpm-b3g.c index 1fa5d210b9..12472528dc 100644 --- a/src/util-mpm-b3g.c +++ b/src/util-mpm-b3g.c @@ -75,7 +75,8 @@ void B3gRegisterTests(void); /** \todo XXX Unused??? */ #if 0 -static void prt (uint8_t *buf, uint16_t buflen) { +static void prt (uint8_t *buf, uint16_t buflen) +{ uint16_t i; for (i = 0; i < buflen; i++) { @@ -86,7 +87,8 @@ static void prt (uint8_t *buf, uint16_t buflen) { } #endif -void B3gPrintInfo(MpmCtx *mpm_ctx) { +void B3gPrintInfo(MpmCtx *mpm_ctx) +{ B3gCtx *ctx = (B3gCtx *)mpm_ctx->ctx; printf("MPM B3g Information:\n"); @@ -104,7 +106,8 @@ void B3gPrintInfo(MpmCtx *mpm_ctx) { printf("\n"); } -static inline B3gPattern *B3gAllocPattern(MpmCtx *mpm_ctx) { +static inline B3gPattern *B3gAllocPattern(MpmCtx *mpm_ctx) +{ B3gPattern *p = SCMalloc(sizeof(B3gPattern)); if (unlikely(p == NULL)) return NULL; @@ -116,7 +119,8 @@ static inline B3gPattern *B3gAllocPattern(MpmCtx *mpm_ctx) { } static inline B3gHashItem * -B3gAllocHashItem(MpmCtx *mpm_ctx) { +B3gAllocHashItem(MpmCtx *mpm_ctx) +{ B3gHashItem *hi = SCMalloc(sizeof(B3gHashItem)); if (unlikely(hi == NULL)) return NULL; @@ -127,7 +131,8 @@ B3gAllocHashItem(MpmCtx *mpm_ctx) { return hi; } -static void B3gHashFree(MpmCtx *mpm_ctx, B3gHashItem *hi) { +static void B3gHashFree(MpmCtx *mpm_ctx, B3gHashItem *hi) +{ if (hi == NULL) return; @@ -142,7 +147,8 @@ static void B3gHashFree(MpmCtx *mpm_ctx, B3gHashItem *hi) { /* * INIT HASH START */ -static inline uint32_t B3gInitHash(B3gPattern *p) { +static inline uint32_t B3gInitHash(B3gPattern *p) +{ uint32_t hash = p->len * p->cs[0]; if (p->len > 1) hash += p->cs[1]; @@ -150,7 +156,8 @@ static inline uint32_t B3gInitHash(B3gPattern *p) { return (hash % INIT_HASH_SIZE); } -static inline uint32_t B3gInitHashRaw(uint8_t *pat, uint16_t patlen) { +static inline uint32_t B3gInitHashRaw(uint8_t *pat, uint16_t patlen) +{ uint32_t hash = patlen * pat[0]; if (patlen > 1) hash += pat[1]; @@ -158,7 +165,8 @@ static inline uint32_t B3gInitHashRaw(uint8_t *pat, uint16_t patlen) { return (hash % INIT_HASH_SIZE); } -static inline int B3gInitHashAdd(B3gCtx *ctx, B3gPattern *p) { +static inline int B3gInitHashAdd(B3gCtx *ctx, B3gPattern *p) +{ uint32_t hash = B3gInitHash(p); //printf("B3gInitHashAdd: %" PRIu32 "\n", hash); @@ -186,7 +194,8 @@ static inline int B3gInitHashAdd(B3gCtx *ctx, B3gPattern *p) { static inline int B3gCmpPattern(B3gPattern *p, uint8_t *pat, uint16_t patlen, char flags); -static inline B3gPattern *B3gInitHashLookup(B3gCtx *ctx, uint8_t *pat, uint16_t patlen, char flags) { +static inline B3gPattern *B3gInitHashLookup(B3gCtx *ctx, uint8_t *pat, uint16_t patlen, char flags) +{ uint32_t hash = B3gInitHashRaw(pat,patlen); //printf("B3gInitHashLookup: %" PRIu32 ", head %p\n", hash, ctx->init_hash[hash]); @@ -204,7 +213,8 @@ static inline B3gPattern *B3gInitHashLookup(B3gCtx *ctx, uint8_t *pat, uint16_t return NULL; } -static inline int B3gCmpPattern(B3gPattern *p, uint8_t *pat, uint16_t patlen, char flags) { +static inline int B3gCmpPattern(B3gPattern *p, uint8_t *pat, uint16_t patlen, char flags) +{ if (p->len != patlen) return 0; @@ -221,7 +231,8 @@ static inline int B3gCmpPattern(B3gPattern *p, uint8_t *pat, uint16_t patlen, ch * INIT HASH END */ -void B3gFreePattern(MpmCtx *mpm_ctx, B3gPattern *p) { +void B3gFreePattern(MpmCtx *mpm_ctx, B3gPattern *p) +{ if (p && p->cs && p->cs != p->ci) { SCFree(p->cs); mpm_ctx->memory_cnt--; @@ -249,7 +260,8 @@ void B3gFreePattern(MpmCtx *mpm_ctx, B3gPattern *p) { * pid: pattern id * sid: signature id (internal id) */ -static int B3gAddPattern(MpmCtx *mpm_ctx, uint8_t *pat, uint16_t patlen, uint16_t offset, uint16_t depth, uint32_t pid, uint32_t sid, uint8_t flags) { +static int B3gAddPattern(MpmCtx *mpm_ctx, uint8_t *pat, uint16_t patlen, uint16_t offset, uint16_t depth, uint32_t pid, uint32_t sid, uint8_t flags) +{ B3gCtx *ctx = (B3gCtx *)mpm_ctx->ctx; if (patlen == 0) @@ -332,7 +344,8 @@ int B3gAddPatternCS(MpmCtx *mpm_ctx, uint8_t *pat, uint16_t patlen, return B3gAddPattern(mpm_ctx, pat, patlen, offset, depth, pid, sid, flags); } -static uint32_t B3gBloomHash(void *data, uint16_t datalen, uint8_t iter, uint32_t hash_size) { +static uint32_t B3gBloomHash(void *data, uint16_t datalen, uint8_t iter, uint32_t hash_size) +{ uint8_t *d = (uint8_t *)data; uint16_t i; uint32_t hash = (uint32_t)u8_tolower(*d); @@ -347,7 +360,8 @@ static uint32_t B3gBloomHash(void *data, uint16_t datalen, uint8_t iter, uint32_ return hash; } -static void B3gPrepareHash(MpmCtx *mpm_ctx) { +static void B3gPrepareHash(MpmCtx *mpm_ctx) +{ B3gCtx *ctx = (B3gCtx *)mpm_ctx->ctx; uint16_t i; uint16_t idx = 0; @@ -491,7 +505,8 @@ error: return; } -int B3gBuildMatchArray(MpmCtx *mpm_ctx) { +int B3gBuildMatchArray(MpmCtx *mpm_ctx) +{ B3gCtx *ctx = (B3gCtx *)mpm_ctx->ctx; ctx->B3G = SCMalloc(sizeof(B3G_TYPE) * ctx->hash_size); @@ -522,7 +537,8 @@ int B3gBuildMatchArray(MpmCtx *mpm_ctx) { return 0; } -int B3gPreparePatterns(MpmCtx *mpm_ctx) { +int B3gPreparePatterns(MpmCtx *mpm_ctx) +{ B3gCtx *ctx = (B3gCtx *)mpm_ctx->ctx; /* alloc the pattern array */ @@ -585,7 +601,8 @@ error: return -1; } -void B3gPrintSearchStats(MpmThreadCtx *mpm_thread_ctx) { +void B3gPrintSearchStats(MpmThreadCtx *mpm_thread_ctx) +{ #ifdef B3G_COUNTERS B3gThreadCtx *tctx = (B3gThreadCtx *)mpm_thread_ctx->ctx; @@ -606,7 +623,8 @@ void B3gPrintSearchStats(MpmThreadCtx *mpm_thread_ctx) { } static inline int -memcmp_lowercase(uint8_t *s1, uint8_t *s2, uint16_t n) { +memcmp_lowercase(uint8_t *s1, uint8_t *s2, uint16_t n) +{ size_t i; /* check backwards because we already tested the first @@ -697,7 +715,8 @@ void B3gGetConfig() } } -void B3gInitCtx (MpmCtx *mpm_ctx) { +void B3gInitCtx (MpmCtx *mpm_ctx) +{ //printf("B3gInitCtx: mpm_ctx %p\n", mpm_ctx); mpm_ctx->ctx = SCMalloc(sizeof(B3gCtx)); @@ -726,7 +745,8 @@ void B3gInitCtx (MpmCtx *mpm_ctx) { ctx->Search = b3g_func; } -void B3gDestroyCtx(MpmCtx *mpm_ctx) { +void B3gDestroyCtx(MpmCtx *mpm_ctx) +{ B3gCtx *ctx = (B3gCtx *)mpm_ctx->ctx; if (ctx == NULL) return; @@ -812,7 +832,8 @@ void B3gDestroyCtx(MpmCtx *mpm_ctx) { mpm_ctx->memory_size -= sizeof(B3gCtx); } -void B3gThreadInitCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, uint32_t matchsize) { +void B3gThreadInitCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, uint32_t matchsize) +{ memset(mpm_thread_ctx, 0, sizeof(MpmThreadCtx)); if (sizeof(B3gThreadCtx) > 0) { /* size can be 0 when optimized */ @@ -827,7 +848,8 @@ void B3gThreadInitCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, uint32_t ma } } -void B3gThreadDestroyCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx) { +void B3gThreadDestroyCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx) +{ B3gThreadCtx *ctx = (B3gThreadCtx *)mpm_thread_ctx->ctx; B3gPrintSearchStats(mpm_thread_ctx); @@ -839,12 +861,14 @@ void B3gThreadDestroyCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx) { } } -inline uint32_t B3gSearchWrap(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) { +inline uint32_t B3gSearchWrap(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) +{ B3gCtx *ctx = (B3gCtx *)mpm_ctx->ctx; return ctx->Search(mpm_ctx, mpm_thread_ctx, pmq, buf, buflen); } -uint32_t B3gSearchBNDMq(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) { +uint32_t B3gSearchBNDMq(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) +{ B3gCtx *ctx = (B3gCtx *)mpm_ctx->ctx; #ifdef B3G_COUNTERS B3gThreadCtx *tctx = (B3gThreadCtx *)mpm_thread_ctx->ctx; @@ -942,7 +966,8 @@ skip_loop: return matches; } -uint32_t B3gSearch(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) { +uint32_t B3gSearch(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) +{ B3gCtx *ctx = (B3gCtx *)mpm_ctx->ctx; #ifdef B3G_COUNTERS B3gThreadCtx *tctx = (B3gThreadCtx *)mpm_thread_ctx->ctx; @@ -1037,7 +1062,8 @@ skip_loop: return matches; } -uint32_t B3gSearch12(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) { +uint32_t B3gSearch12(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) +{ B3gCtx *ctx = (B3gCtx *)mpm_ctx->ctx; uint8_t *bufmin = buf; uint8_t *bufend = buf + buflen - 1; @@ -1099,7 +1125,8 @@ uint32_t B3gSearch12(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatch return cnt; } -uint32_t B3gSearch2(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) { +uint32_t B3gSearch2(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) +{ B3gCtx *ctx = (B3gCtx *)mpm_ctx->ctx; uint8_t *bufmin = buf; uint8_t *bufend = buf + buflen - 1; @@ -1150,7 +1177,8 @@ uint32_t B3gSearch2(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatche } return cnt; } -uint32_t B3gSearch1(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) { +uint32_t B3gSearch1(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) +{ B3gCtx *ctx = (B3gCtx *)mpm_ctx->ctx; uint8_t *bufmin = buf; uint8_t *bufend = buf + buflen - 1; @@ -1198,7 +1226,8 @@ uint32_t B3gSearch1(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatche return cnt; } -void MpmB3gRegister (void) { +void MpmB3gRegister (void) +{ mpm_table[MPM_B3G].name = "b3g"; mpm_table[MPM_B3G].max_pattern_length = B3G_WORD_SIZE; mpm_table[MPM_B3G].InitCtx = B3gInitCtx; @@ -1220,7 +1249,8 @@ void MpmB3gRegister (void) { */ #ifdef UNITTESTS -static int B3gTestInit01 (void) { +static int B3gTestInit01 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1241,7 +1271,8 @@ static int B3gTestInit01 (void) { } #if 0 -static int B3gTestS0Init01 (void) { +static int B3gTestS0Init01 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1261,7 +1292,8 @@ static int B3gTestS0Init01 (void) { return result; } -static int B3gTestS0Init02 (void) { +static int B3gTestS0Init02 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1282,7 +1314,8 @@ static int B3gTestS0Init02 (void) { return result; } -static int B3gTestS0Init03 (void) { +static int B3gTestS0Init03 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1303,7 +1336,8 @@ static int B3gTestS0Init03 (void) { return result; } -static int B3gTestS0Init04 (void) { +static int B3gTestS0Init04 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1323,7 +1357,8 @@ static int B3gTestS0Init04 (void) { return result; } -static int B3gTestS0Init05 (void) { +static int B3gTestS0Init05 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1344,7 +1379,8 @@ static int B3gTestS0Init05 (void) { } #endif -static int B3gTestSearch01 (void) { +static int B3gTestSearch01 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1369,7 +1405,8 @@ static int B3gTestSearch01 (void) { return result; } -static int B3gTestSearch02 (void) { +static int B3gTestSearch02 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1394,7 +1431,8 @@ static int B3gTestSearch02 (void) { return result; } -static int B3gTestSearch03 (void) { +static int B3gTestSearch03 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1422,7 +1460,8 @@ static int B3gTestSearch03 (void) { } /* test patterns longer than 'm'. M is 4 here. */ -static int B3gTestSearch04 (void) { +static int B3gTestSearch04 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1450,7 +1489,8 @@ static int B3gTestSearch04 (void) { } /* case insensitive test patterns longer than 'm'. M is 4 here. */ -static int B3gTestSearch05 (void) { +static int B3gTestSearch05 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1477,7 +1517,8 @@ static int B3gTestSearch05 (void) { return result; } -static int B3gTestSearch06 (void) { +static int B3gTestSearch06 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1502,7 +1543,8 @@ static int B3gTestSearch06 (void) { return result; } -static int B3gTestSearch07 (void) { +static int B3gTestSearch07 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1533,7 +1575,8 @@ static int B3gTestSearch07 (void) { return result; } -static int B3gTestSearch08 (void) { +static int B3gTestSearch08 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1558,7 +1601,8 @@ static int B3gTestSearch08 (void) { return result; } -static int B3gTestSearch09 (void) { +static int B3gTestSearch09 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1583,7 +1627,8 @@ static int B3gTestSearch09 (void) { return result; } -static int B3gTestSearch10 (void) { +static int B3gTestSearch10 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1613,7 +1658,8 @@ static int B3gTestSearch10 (void) { return result; } -static int B3gTestSearch11 (void) { +static int B3gTestSearch11 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1639,7 +1685,8 @@ static int B3gTestSearch11 (void) { return result; } -static int B3gTestSearch12 (void) { +static int B3gTestSearch12 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1667,7 +1714,8 @@ static int B3gTestSearch12 (void) { #endif /* UNITTESTS */ -void B3gRegisterTests(void) { +void B3gRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("B3gTestInit01", B3gTestInit01, 1); /* diff --git a/src/util-mpm-wumanber.c b/src/util-mpm-wumanber.c index 648da6a30b..15d7a23ccd 100644 --- a/src/util-mpm-wumanber.c +++ b/src/util-mpm-wumanber.c @@ -89,7 +89,8 @@ static uint8_t lowercasetable[256]; #define COUNT(counter) #endif /* WUMANBER_COUNTERS */ -void prt (uint8_t *buf, uint16_t buflen) { +void prt (uint8_t *buf, uint16_t buflen) +{ uint16_t i; for (i = 0; i < buflen; i++) { @@ -99,7 +100,8 @@ void prt (uint8_t *buf, uint16_t buflen) { //printf("\n"); } -void WmPrintInfo(MpmCtx *mpm_ctx) { +void WmPrintInfo(MpmCtx *mpm_ctx) +{ WmCtx *ctx = (WmCtx *)mpm_ctx->ctx; printf("MPM WuManber Information:\n"); @@ -134,7 +136,8 @@ void WmPrintInfo(MpmCtx *mpm_ctx) { printf("\n"); } -static inline WmPattern *WmAllocPattern(MpmCtx *mpm_ctx) { +static inline WmPattern *WmAllocPattern(MpmCtx *mpm_ctx) +{ WmPattern *p = SCMalloc(sizeof(WmPattern)); if (unlikely(p == NULL)) return NULL; @@ -146,7 +149,8 @@ static inline WmPattern *WmAllocPattern(MpmCtx *mpm_ctx) { } static inline WmHashItem * -WmAllocHashItem(MpmCtx *mpm_ctx) { +WmAllocHashItem(MpmCtx *mpm_ctx) +{ WmHashItem *hi = SCMalloc(sizeof(WmHashItem)); if (unlikely(hi == NULL)) return NULL; @@ -157,7 +161,8 @@ WmAllocHashItem(MpmCtx *mpm_ctx) { return hi; } -static void WmHashFree(MpmCtx *mpm_ctx, WmHashItem *hi) { +static void WmHashFree(MpmCtx *mpm_ctx, WmHashItem *hi) +{ if (hi == NULL) return; @@ -169,7 +174,8 @@ static void WmHashFree(MpmCtx *mpm_ctx, WmHashItem *hi) { SCFree(hi); } -static inline void memcpy_tolower(uint8_t *d, uint8_t *s, uint16_t len) { +static inline void memcpy_tolower(uint8_t *d, uint8_t *s, uint16_t len) +{ uint16_t i; for (i = 0; i < len; i++) { d[i] = wm_tolower(s[i]); @@ -179,7 +185,8 @@ static inline void memcpy_tolower(uint8_t *d, uint8_t *s, uint16_t len) { /* * INIT HASH START */ -static inline uint32_t WmInitHash(WmPattern *p) { +static inline uint32_t WmInitHash(WmPattern *p) +{ uint32_t hash = p->len * p->cs[0]; if (p->len > 1) hash += p->cs[1]; @@ -187,7 +194,8 @@ static inline uint32_t WmInitHash(WmPattern *p) { return (hash % INIT_HASH_SIZE); } -static inline uint32_t WmInitHashRaw(uint8_t *pat, uint16_t patlen) { +static inline uint32_t WmInitHashRaw(uint8_t *pat, uint16_t patlen) +{ uint32_t hash = patlen * pat[0]; if (patlen > 1) hash += pat[1]; @@ -195,7 +203,8 @@ static inline uint32_t WmInitHashRaw(uint8_t *pat, uint16_t patlen) { return (hash % INIT_HASH_SIZE); } -static inline int WmInitHashAdd(WmCtx *ctx, WmPattern *p) { +static inline int WmInitHashAdd(WmCtx *ctx, WmPattern *p) +{ uint32_t hash = WmInitHash(p); //printf("WmInitHashAdd: %" PRIu32 "\n", hash); @@ -223,7 +232,8 @@ static inline int WmInitHashAdd(WmCtx *ctx, WmPattern *p) { static inline int WmCmpPattern(WmPattern *p, uint8_t *pat, uint16_t patlen, char flags); -static inline WmPattern *WmInitHashLookup(WmCtx *ctx, uint8_t *pat, uint16_t patlen, char flags) { +static inline WmPattern *WmInitHashLookup(WmCtx *ctx, uint8_t *pat, uint16_t patlen, char flags) +{ uint32_t hash = WmInitHashRaw(pat,patlen); //printf("WmInitHashLookup: %" PRIu32 ", head %p\n", hash, ctx->init_hash[hash]); @@ -241,7 +251,8 @@ static inline WmPattern *WmInitHashLookup(WmCtx *ctx, uint8_t *pat, uint16_t pat return NULL; } -static inline int WmCmpPattern(WmPattern *p, uint8_t *pat, uint16_t patlen, char flags) { +static inline int WmCmpPattern(WmPattern *p, uint8_t *pat, uint16_t patlen, char flags) +{ if (p->len != patlen) return 0; @@ -258,7 +269,8 @@ static inline int WmCmpPattern(WmPattern *p, uint8_t *pat, uint16_t patlen, char * INIT HASH END */ -void WmFreePattern(MpmCtx *mpm_ctx, WmPattern *p) { +void WmFreePattern(MpmCtx *mpm_ctx, WmPattern *p) +{ if (p && p->cs && p->cs != p->ci) { SCFree(p->cs); mpm_ctx->memory_cnt--; @@ -286,7 +298,8 @@ void WmFreePattern(MpmCtx *mpm_ctx, WmPattern *p) { * pid: pattern id * sid: signature id (internal id) */ -static int WmAddPattern(MpmCtx *mpm_ctx, uint8_t *pat, uint16_t patlen, uint16_t offset, uint16_t depth, uint32_t pid, uint32_t sid, uint8_t flags) { +static int WmAddPattern(MpmCtx *mpm_ctx, uint8_t *pat, uint16_t patlen, uint16_t offset, uint16_t depth, uint32_t pid, uint32_t sid, uint8_t flags) +{ WmCtx *ctx = (WmCtx *)mpm_ctx->ctx; // printf("WmAddPattern: ctx %p \"", mpm_ctx); prt(pat, patlen); @@ -378,7 +391,8 @@ int WmAddPatternCS(MpmCtx *mpm_ctx, uint8_t *pat, uint16_t patlen, return WmAddPattern(mpm_ctx, pat, patlen, offset, depth, pid, sid, flags); } -static uint32_t WmBloomHash(void *data, uint16_t datalen, uint8_t iter, uint32_t hash_size) { +static uint32_t WmBloomHash(void *data, uint16_t datalen, uint8_t iter, uint32_t hash_size) +{ uint8_t *d = (uint8_t *)data; uint16_t i; uint32_t hash = (uint32_t)wm_tolower(*d); @@ -392,7 +406,8 @@ static uint32_t WmBloomHash(void *data, uint16_t datalen, uint8_t iter, uint32_t return hash; } /* -static uint32_t BloomHash(void *data, uint16_t datalen, uint8_t iter, uint32_t hash_size) { +static uint32_t BloomHash(void *data, uint16_t datalen, uint8_t iter, uint32_t hash_size) +{ uint8_t *d = (uint8_t *)data; uint32_t i; uint32_t hash = 0; @@ -408,7 +423,8 @@ static uint32_t BloomHash(void *data, uint16_t datalen, uint8_t iter, uint32_t h return hash; } */ -static void WmSearchPrepareHash(MpmCtx *mpm_ctx) { +static void WmSearchPrepareHash(MpmCtx *mpm_ctx) +{ WmCtx *ctx = (WmCtx *)mpm_ctx->ctx; uint16_t i; uint16_t idx = 0; @@ -610,7 +626,8 @@ static void WmSearchPrepareShiftTable(MpmCtx *mpm_ctx) } } -int WmPreparePatterns(MpmCtx *mpm_ctx) { +int WmPreparePatterns(MpmCtx *mpm_ctx) +{ WmCtx *ctx = (WmCtx *)mpm_ctx->ctx; /* alloc the pattern array */ @@ -687,7 +704,8 @@ error: return -1; } -void WmPrintSearchStats(MpmThreadCtx *mpm_thread_ctx) { +void WmPrintSearchStats(MpmThreadCtx *mpm_thread_ctx) +{ #ifdef WUMANBER_COUNTERS WmThreadCtx *tctx = (WmThreadCtx *)mpm_thread_ctx->ctx; @@ -700,7 +718,8 @@ void WmPrintSearchStats(MpmThreadCtx *mpm_thread_ctx) { } static inline int -memcmp_lowercase(uint8_t *s1, uint8_t *s2, uint16_t n) { +memcmp_lowercase(uint8_t *s1, uint8_t *s2, uint16_t n) +{ size_t i; /* check backwards because we already tested the first @@ -714,13 +733,15 @@ memcmp_lowercase(uint8_t *s1, uint8_t *s2, uint16_t n) { return 0; } -inline uint32_t WmSearch(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) { +inline uint32_t WmSearch(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) +{ WmCtx *ctx = (WmCtx *)mpm_ctx->ctx; return ctx->Search(mpm_ctx, mpm_thread_ctx, pmq, buf, buflen); } /* SCAN FUNCTIONS */ -uint32_t WmSearch2Hash9(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) { +uint32_t WmSearch2Hash9(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) +{ WmCtx *ctx = (WmCtx *)mpm_ctx->ctx; #ifdef WUMANBER_COUNTERS WmThreadCtx *tctx = (WmThreadCtx *)mpm_thread_ctx->ctx; @@ -820,7 +841,8 @@ skip_loop: return cnt; } -uint32_t WmSearch2Hash12(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) { +uint32_t WmSearch2Hash12(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) +{ WmCtx *ctx = (WmCtx *)mpm_ctx->ctx; #ifdef WUMANBER_COUNTERS WmThreadCtx *tctx = (WmThreadCtx *)mpm_thread_ctx->ctx; @@ -921,7 +943,8 @@ skip_loop: return cnt; } -uint32_t WmSearch2Hash14(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) { +uint32_t WmSearch2Hash14(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) +{ WmCtx *ctx = (WmCtx *)mpm_ctx->ctx; #ifdef WUMANBER_COUNTERS WmThreadCtx *tctx = (WmThreadCtx *)mpm_thread_ctx->ctx; @@ -1018,7 +1041,8 @@ skip_loop: return cnt; } -uint32_t WmSearch2Hash15(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) { +uint32_t WmSearch2Hash15(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) +{ WmCtx *ctx = (WmCtx *)mpm_ctx->ctx; #ifdef WUMANBER_COUNTERS WmThreadCtx *tctx = (WmThreadCtx *)mpm_thread_ctx->ctx; @@ -1117,7 +1141,8 @@ skip_loop: return cnt; } -uint32_t WmSearch2Hash16(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) { +uint32_t WmSearch2Hash16(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) +{ WmCtx *ctx = (WmCtx *)mpm_ctx->ctx; #ifdef WUMANBER_COUNTERS WmThreadCtx *tctx = (WmThreadCtx *)mpm_thread_ctx->ctx; @@ -1214,7 +1239,8 @@ skip_loop: return cnt; } -uint32_t WmSearch1(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) { +uint32_t WmSearch1(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcherQueue *pmq, uint8_t *buf, uint16_t buflen) +{ WmCtx *ctx = (WmCtx *)mpm_ctx->ctx; uint8_t *bufmin = buf; uint8_t *bufend = buf + buflen - 1; @@ -1301,7 +1327,8 @@ void WmGetConfig() } } -void WmInitCtx (MpmCtx *mpm_ctx) { +void WmInitCtx (MpmCtx *mpm_ctx) +{ SCLogDebug("mpm_ctx %p", mpm_ctx); mpm_ctx->ctx = SCMalloc(sizeof(WmCtx)); @@ -1327,7 +1354,8 @@ void WmInitCtx (MpmCtx *mpm_ctx) { } -void WmDestroyCtx(MpmCtx *mpm_ctx) { +void WmDestroyCtx(MpmCtx *mpm_ctx) +{ WmCtx *ctx = (WmCtx *)mpm_ctx->ctx; if (ctx == NULL) return; @@ -1400,7 +1428,8 @@ void WmDestroyCtx(MpmCtx *mpm_ctx) { mpm_ctx->memory_size -= sizeof(WmCtx); } -void WmThreadInitCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, uint32_t matchsize) { +void WmThreadInitCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, uint32_t matchsize) +{ memset(mpm_thread_ctx, 0, sizeof(MpmThreadCtx)); #ifdef WUMANBER_COUNTERS @@ -1415,7 +1444,8 @@ void WmThreadInitCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, uint32_t mat #endif } -void WmThreadDestroyCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx) { +void WmThreadDestroyCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx) +{ WmThreadCtx *ctx = (WmThreadCtx *)mpm_thread_ctx->ctx; if (ctx != NULL) { /* size can be 0 when optimized */ mpm_thread_ctx->memory_cnt--; @@ -1424,7 +1454,8 @@ void WmThreadDestroyCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx) { } } -void MpmWuManberRegister (void) { +void MpmWuManberRegister (void) +{ mpm_table[MPM_WUMANBER].name = "wumanber"; mpm_table[MPM_WUMANBER].max_pattern_length = 0; mpm_table[MPM_WUMANBER].InitCtx = WmInitCtx; @@ -1455,7 +1486,8 @@ void MpmWuManberRegister (void) { */ #ifdef UNITTESTS -int WmTestInitCtx01 (void) { +int WmTestInitCtx01 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1468,7 +1500,8 @@ int WmTestInitCtx01 (void) { return result; } -int WmTestInitCtx02 (void) { +int WmTestInitCtx02 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1483,7 +1516,8 @@ int WmTestInitCtx02 (void) { return result; } -int WmTestInitCtx03 (void) { +int WmTestInitCtx03 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1496,7 +1530,8 @@ int WmTestInitCtx03 (void) { return result; } -int WmTestThreadInitCtx01 (void) { +int WmTestThreadInitCtx01 (void) +{ #ifdef WUMANBER_COUNTERS int result = 0; MpmCtx mpm_ctx; @@ -1519,7 +1554,8 @@ int WmTestThreadInitCtx01 (void) { #endif } -int WmTestThreadInitCtx02 (void) { +int WmTestThreadInitCtx02 (void) +{ #ifdef WUMANBER_COUNTERS int result = 0; MpmCtx mpm_ctx; @@ -1542,7 +1578,8 @@ int WmTestThreadInitCtx02 (void) { return result; } -int WmTestInitAddPattern01 (void) { +int WmTestInitAddPattern01 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1560,7 +1597,8 @@ int WmTestInitAddPattern01 (void) { return result; } -int WmTestInitAddPattern02 (void) { +int WmTestInitAddPattern02 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1579,7 +1617,8 @@ int WmTestInitAddPattern02 (void) { return result; } -int WmTestInitAddPattern03 (void) { +int WmTestInitAddPattern03 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1601,7 +1640,8 @@ int WmTestInitAddPattern03 (void) { return result; } -int WmTestInitAddPattern04 (void) { +int WmTestInitAddPattern04 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1623,7 +1663,8 @@ int WmTestInitAddPattern04 (void) { return result; } -int WmTestInitAddPattern05 (void) { +int WmTestInitAddPattern05 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1645,7 +1686,8 @@ int WmTestInitAddPattern05 (void) { return result; } -int WmTestInitAddPattern06 (void) { +int WmTestInitAddPattern06 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1667,7 +1709,8 @@ int WmTestInitAddPattern06 (void) { return result; } -int WmTestPrepare01 (void) { +int WmTestPrepare01 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1684,7 +1727,8 @@ int WmTestPrepare01 (void) { return result; } -int WmTestPrepare02 (void) { +int WmTestPrepare02 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1701,7 +1745,8 @@ int WmTestPrepare02 (void) { return result; } -int WmTestPrepare03 (void) { +int WmTestPrepare03 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1720,7 +1765,8 @@ int WmTestPrepare03 (void) { return result; } -int WmTestPrepare04 (void) { +int WmTestPrepare04 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1737,7 +1783,8 @@ int WmTestPrepare04 (void) { return result; } -int WmTestPrepare05 (void) { +int WmTestPrepare05 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1754,7 +1801,8 @@ int WmTestPrepare05 (void) { return result; } -int WmTestPrepare06 (void) { +int WmTestPrepare06 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1773,7 +1821,8 @@ int WmTestPrepare06 (void) { return result; } -int WmTestSearch01 (void) { +int WmTestSearch01 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1799,7 +1848,8 @@ int WmTestSearch01 (void) { return result; } -int WmTestSearch01Hash12 (void) { +int WmTestSearch01Hash12 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1827,7 +1877,8 @@ int WmTestSearch01Hash12 (void) { return result; } -int WmTestSearch01Hash14 (void) { +int WmTestSearch01Hash14 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1855,7 +1906,8 @@ int WmTestSearch01Hash14 (void) { return result; } -int WmTestSearch01Hash15 (void) { +int WmTestSearch01Hash15 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1883,7 +1935,8 @@ int WmTestSearch01Hash15 (void) { return result; } -int WmTestSearch01Hash16 (void) { +int WmTestSearch01Hash16 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1911,7 +1964,8 @@ int WmTestSearch01Hash16 (void) { return result; } -int WmTestSearch02 (void) { +int WmTestSearch02 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1933,7 +1987,8 @@ int WmTestSearch02 (void) { return result; } -int WmTestSearch03 (void) { +int WmTestSearch03 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1956,7 +2011,8 @@ int WmTestSearch03 (void) { return result; } -int WmTestSearch04 (void) { +int WmTestSearch04 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -1978,7 +2034,8 @@ int WmTestSearch04 (void) { return result; } -int WmTestSearch05 (void) { +int WmTestSearch05 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2000,7 +2057,8 @@ int WmTestSearch05 (void) { return result; } -int WmTestSearch06 (void) { +int WmTestSearch06 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2022,7 +2080,8 @@ int WmTestSearch06 (void) { return result; } -int WmTestSearch07 (void) { +int WmTestSearch07 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2045,7 +2104,8 @@ int WmTestSearch07 (void) { return result; } -int WmTestSearch08 (void) { +int WmTestSearch08 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2068,7 +2128,8 @@ int WmTestSearch08 (void) { return result; } -int WmTestSearch09 (void) { +int WmTestSearch09 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2090,7 +2151,8 @@ int WmTestSearch09 (void) { return result; } -int WmTestSearch10 (void) { +int WmTestSearch10 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2113,7 +2175,8 @@ int WmTestSearch10 (void) { return result; } -int WmTestSearch11 (void) { +int WmTestSearch11 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2137,7 +2200,8 @@ int WmTestSearch11 (void) { return result; } -int WmTestSearch12 (void) { +int WmTestSearch12 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2163,7 +2227,8 @@ int WmTestSearch12 (void) { return result; } -int WmTestSearch13 (void) { +int WmTestSearch13 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2189,7 +2254,8 @@ int WmTestSearch13 (void) { return result; } -int WmTestSearch14 (void) { +int WmTestSearch14 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2215,7 +2281,8 @@ int WmTestSearch14 (void) { /** \todo VJ disabled because it tests the old match storage */ #if 0 -int WmTestSearch15 (void) { +int WmTestSearch15 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2242,7 +2309,8 @@ int WmTestSearch15 (void) { return result; } -int WmTestSearch16 (void) { +int WmTestSearch16 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2269,7 +2337,8 @@ int WmTestSearch16 (void) { return result; } -int WmTestSearch17 (void) { +int WmTestSearch17 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2294,7 +2363,8 @@ int WmTestSearch17 (void) { return result; } -int WmTestSearch18Hash12 (void) { +int WmTestSearch18Hash12 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2319,7 +2389,8 @@ int WmTestSearch18Hash12 (void) { return result; } -int WmTestSearch18Hash14 (void) { +int WmTestSearch18Hash14 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2344,7 +2415,8 @@ int WmTestSearch18Hash14 (void) { return result; } -int WmTestSearch18Hash15 (void) { +int WmTestSearch18Hash15 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2369,7 +2441,8 @@ int WmTestSearch18Hash15 (void) { return result; } -int WmTestSearch18 (void) { +int WmTestSearch18 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2395,7 +2468,8 @@ int WmTestSearch18 (void) { return result; } -int WmTestSearch18Hash16 (void) { +int WmTestSearch18Hash16 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2421,7 +2495,8 @@ int WmTestSearch18Hash16 (void) { return result; } -int WmTestSearch19 (void) { +int WmTestSearch19 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2446,7 +2521,8 @@ int WmTestSearch19 (void) { return result; } -int WmTestSearch19Hash12 (void) { +int WmTestSearch19Hash12 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2472,7 +2548,8 @@ int WmTestSearch19Hash12 (void) { return result; } -int WmTestSearch19Hash14 (void) { +int WmTestSearch19Hash14 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2498,7 +2575,8 @@ int WmTestSearch19Hash14 (void) { return result; } -int WmTestSearch19Hash15 (void) { +int WmTestSearch19Hash15 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2524,7 +2602,8 @@ int WmTestSearch19Hash15 (void) { return result; } -int WmTestSearch19Hash16 (void) { +int WmTestSearch19Hash16 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2550,7 +2629,8 @@ int WmTestSearch19Hash16 (void) { return result; } -int WmTestSearch20 (void) { +int WmTestSearch20 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2575,7 +2655,8 @@ int WmTestSearch20 (void) { return result; } -int WmTestSearch20Hash12 (void) { +int WmTestSearch20Hash12 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2600,7 +2681,8 @@ int WmTestSearch20Hash12 (void) { return result; } -int WmTestSearch20Hash14 (void) { +int WmTestSearch20Hash14 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2626,7 +2708,8 @@ int WmTestSearch20Hash14 (void) { return result; } -int WmTestSearch20Hash15 (void) { +int WmTestSearch20Hash15 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2652,7 +2735,8 @@ int WmTestSearch20Hash15 (void) { return result; } -int WmTestSearch20Hash16 (void) { +int WmTestSearch20Hash16 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2678,7 +2762,8 @@ int WmTestSearch20Hash16 (void) { return result; } -int WmTestSearch21 (void) { +int WmTestSearch21 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2703,7 +2788,8 @@ int WmTestSearch21 (void) { return result; } -static int WmTestSearch21Hash12 (void) { +static int WmTestSearch21Hash12 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2729,7 +2815,8 @@ static int WmTestSearch21Hash12 (void) { return result; } -static int WmTestSearch21Hash14 (void) { +static int WmTestSearch21Hash14 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2755,7 +2842,8 @@ static int WmTestSearch21Hash14 (void) { return result; } -static int WmTestSearch21Hash15 (void) { +static int WmTestSearch21Hash15 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2781,7 +2869,8 @@ static int WmTestSearch21Hash15 (void) { return result; } -static int WmTestSearch21Hash16 (void) { +static int WmTestSearch21Hash16 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2807,7 +2896,8 @@ static int WmTestSearch21Hash16 (void) { return result; } #endif -static int WmTestSearch22Hash9 (void) { +static int WmTestSearch22Hash9 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2840,7 +2930,8 @@ static int WmTestSearch22Hash9 (void) { return result; } -static int WmTestSearch22Hash12 (void) { +static int WmTestSearch22Hash12 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2873,7 +2964,8 @@ static int WmTestSearch22Hash12 (void) { return result; } -static int WmTestSearch22Hash14 (void) { +static int WmTestSearch22Hash14 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2906,7 +2998,8 @@ static int WmTestSearch22Hash14 (void) { return result; } -static int WmTestSearch22Hash15 (void) { +static int WmTestSearch22Hash15 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2939,7 +3032,8 @@ static int WmTestSearch22Hash15 (void) { return result; } -static int WmTestSearch22Hash16 (void) { +static int WmTestSearch22Hash16 (void) +{ int result = 0; MpmCtx mpm_ctx; memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); @@ -2973,7 +3067,8 @@ static int WmTestSearch22Hash16 (void) { } #endif /* UNITTESTS */ -void WmRegisterTests(void) { +void WmRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("WmTestInitCtx01", WmTestInitCtx01, 1); UtRegisterTest("WmTestInitCtx02", WmTestInitCtx02, 1); diff --git a/src/util-mpm.c b/src/util-mpm.c index 7e711ba715..df81e87a26 100644 --- a/src/util-mpm.c +++ b/src/util-mpm.c @@ -420,7 +420,8 @@ void MpmCudaEnvironmentSetup() * \retval -1 error * \retval 0 ok */ -int PmqSetup(PatternMatcherQueue *pmq, uint32_t patmaxid) { +int PmqSetup(PatternMatcherQueue *pmq, uint32_t patmaxid) +{ SCEnter(); SCLogDebug("patmaxid %u", patmaxid); @@ -497,7 +498,8 @@ MpmVerifyMatch(MpmThreadCtx *thread_ctx, PatternMatcherQueue *pmq, uint32_t pati * \param src source pmq * \param dst destination pmq to merge into */ -void PmqMerge(PatternMatcherQueue *src, PatternMatcherQueue *dst) { +void PmqMerge(PatternMatcherQueue *src, PatternMatcherQueue *dst) +{ uint32_t u; if (src->pattern_id_array_cnt == 0) @@ -515,7 +517,8 @@ void PmqMerge(PatternMatcherQueue *src, PatternMatcherQueue *dst) { * \todo memset is expensive, but we need it as we merge pmq's. We might use * a flag so we can clear pmq's the old way if we can. */ -void PmqReset(PatternMatcherQueue *pmq) { +void PmqReset(PatternMatcherQueue *pmq) +{ if (pmq == NULL) return; @@ -534,7 +537,8 @@ void PmqReset(PatternMatcherQueue *pmq) { /** \brief Cleanup a Pmq * \param pmq Pattern matcher queue to be cleaned up. */ -void PmqCleanup(PatternMatcherQueue *pmq) { +void PmqCleanup(PatternMatcherQueue *pmq) +{ if (pmq == NULL) return; @@ -554,23 +558,27 @@ void PmqCleanup(PatternMatcherQueue *pmq) { /** \brief Cleanup and free a Pmq * \param pmq Pattern matcher queue to be free'd. */ -void PmqFree(PatternMatcherQueue *pmq) { +void PmqFree(PatternMatcherQueue *pmq) +{ if (pmq == NULL) return; PmqCleanup(pmq); } -void MpmInitThreadCtx(MpmThreadCtx *mpm_thread_ctx, uint16_t matcher, uint32_t max_id) { +void MpmInitThreadCtx(MpmThreadCtx *mpm_thread_ctx, uint16_t matcher, uint32_t max_id) +{ mpm_table[matcher].InitThreadCtx(NULL, mpm_thread_ctx, max_id); } -void MpmInitCtx (MpmCtx *mpm_ctx, uint16_t matcher) { +void MpmInitCtx (MpmCtx *mpm_ctx, uint16_t matcher) +{ mpm_ctx->mpm_type = matcher; mpm_table[matcher].InitCtx(mpm_ctx); } -void MpmTableSetup(void) { +void MpmTableSetup(void) +{ memset(mpm_table, 0, sizeof(mpm_table)); MpmWuManberRegister(); @@ -668,7 +676,8 @@ int MpmAddPatternCI(struct MpmCtx_ *mpm_ctx, uint8_t *pat, uint16_t patlen, #ifdef UNITTESTS #endif /* UNITTESTS */ -void MpmRegisterTests(void) { +void MpmRegisterTests(void) +{ #ifdef UNITTESTS uint16_t i; diff --git a/src/util-path.c b/src/util-path.c index 09621320f7..d1b812f028 100644 --- a/src/util-path.c +++ b/src/util-path.c @@ -35,7 +35,8 @@ * \retval 1 absolute * \retval 0 not absolute */ -int PathIsAbsolute(const char *path) { +int PathIsAbsolute(const char *path) +{ if (strlen(path) > 1 && path[0] == '/') { return 1; } @@ -59,6 +60,7 @@ int PathIsAbsolute(const char *path) { * \retval 1 relative * \retval 0 not relative */ -int PathIsRelative(const char *path) { +int PathIsRelative(const char *path) +{ return PathIsAbsolute(path) ? 0 : 1; } diff --git a/src/util-pidfile.c b/src/util-pidfile.c index ed14aa1dda..a13e54efed 100644 --- a/src/util-pidfile.c +++ b/src/util-pidfile.c @@ -80,7 +80,8 @@ int SCPidfileCreate(const char *pidfile) * * \param pointer to the name of the pid file to write (optarg) */ -void SCPidfileRemove(const char *pid_filename) { +void SCPidfileRemove(const char *pid_filename) +{ if (pid_filename != NULL) { /* we ignore the result, the user may have removed the file already. */ (void)unlink(pid_filename); diff --git a/src/util-pool-thread.c b/src/util-pool-thread.c index 32099a9483..fe83a788f8 100644 --- a/src/util-pool-thread.c +++ b/src/util-pool-thread.c @@ -123,13 +123,15 @@ int PoolThreadGrow(PoolThread *pt, uint32_t size, uint32_t prealloc_size, uint32 return (int)(newsize - 1); } -int PoolThreadSize(PoolThread *pt) { +int PoolThreadSize(PoolThread *pt) +{ if (pt == NULL) return -1; return (int)pt->size; } -void PoolThreadFree(PoolThread *pt) { +void PoolThreadFree(PoolThread *pt) +{ int i; if (pt == NULL) @@ -148,7 +150,8 @@ void PoolThreadFree(PoolThread *pt) { SCFree(pt); } -void *PoolThreadGetById(PoolThread *pt, uint16_t id) { +void *PoolThreadGetById(PoolThread *pt, uint16_t id) +{ void *data = NULL; if (pt == NULL || id >= pt->size) @@ -166,7 +169,8 @@ void *PoolThreadGetById(PoolThread *pt, uint16_t id) { return data; } -void PoolThreadReturn(PoolThread *pt, void *data) { +void PoolThreadReturn(PoolThread *pt, void *data) +{ PoolThreadReserved *id = data; if (pt == NULL || *id >= pt->size) @@ -186,13 +190,15 @@ struct PoolThreadTestData { int abc; }; -static void *PoolThreadTestAlloc(void) { +static void *PoolThreadTestAlloc(void) +{ void *data = SCMalloc(sizeof(struct PoolThreadTestData)); return data; } static -int PoolThreadTestInit(void *data, void *allocdata) { +int PoolThreadTestInit(void *data, void *allocdata) +{ if (!data) return 0; @@ -203,10 +209,12 @@ int PoolThreadTestInit(void *data, void *allocdata) { } static -void PoolThreadTestFree(void *data) { +void PoolThreadTestFree(void *data) +{ } -static int PoolThreadTestInit01(void) { +static int PoolThreadTestInit01(void) +{ PoolThread *pt = PoolThreadInit(4, /* threads */ 10, 5, 10, PoolThreadTestAlloc, NULL, NULL, NULL, NULL); if (pt == NULL) @@ -216,7 +224,8 @@ static int PoolThreadTestInit01(void) { return 1; } -static int PoolThreadTestInit02(void) { +static int PoolThreadTestInit02(void) +{ int i = 123; PoolThread *pt = PoolThreadInit(4, /* threads */ @@ -228,7 +237,8 @@ static int PoolThreadTestInit02(void) { return 1; } -static int PoolThreadTestGet01(void) { +static int PoolThreadTestGet01(void) +{ int result = 0; PoolThread *pt = PoolThreadInit(4, /* threads */ 10, 5, 10, PoolThreadTestAlloc, NULL, NULL, NULL, NULL); @@ -253,7 +263,8 @@ end: return result; } -static int PoolThreadTestGet02(void) { +static int PoolThreadTestGet02(void) +{ int i = 123; int result = 0; @@ -285,7 +296,8 @@ end: return result; } -static int PoolThreadTestReturn01(void) { +static int PoolThreadTestReturn01(void) +{ int i = 123; int result = 0; @@ -332,7 +344,8 @@ end: return result; } -static int PoolThreadTestGrow01(void) { +static int PoolThreadTestGrow01(void) +{ PoolThread *pt = PoolThreadInit(4, /* threads */ 10, 5, 10, PoolThreadTestAlloc, NULL, NULL, NULL, NULL); if (pt == NULL) @@ -348,7 +361,8 @@ static int PoolThreadTestGrow01(void) { return 1; } -static int PoolThreadTestGrow02(void) { +static int PoolThreadTestGrow02(void) +{ int i = 123; PoolThread *pt = PoolThreadInit(4, /* threads */ @@ -366,7 +380,8 @@ static int PoolThreadTestGrow02(void) { return 1; } -static int PoolThreadTestGrow03(void) { +static int PoolThreadTestGrow03(void) +{ int i = 123; int result = 0; @@ -421,7 +436,8 @@ end: #endif -void PoolThreadRegisterTests(void) { +void PoolThreadRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("PoolThreadTestInit01", PoolThreadTestInit01, 1); UtRegisterTest("PoolThreadTestInit02", PoolThreadTestInit02, 1); diff --git a/src/util-pool.c b/src/util-pool.c index 2db077fa29..6f40525204 100644 --- a/src/util-pool.c +++ b/src/util-pool.c @@ -222,7 +222,8 @@ error: } -void PoolFree(Pool *p) { +void PoolFree(Pool *p) +{ if (p == NULL) return; @@ -269,13 +270,15 @@ void PoolFree(Pool *p) { SCFree(p); } -void PoolPrint(Pool *p) { +void PoolPrint(Pool *p) +{ printf("\n----------- Hash Table Stats ------------\n"); printf("Buckets: %" PRIu32 "\n", p->empty_stack_size + p->alloc_stack_size); printf("-----------------------------------------\n"); } -void *PoolGet(Pool *p) { +void *PoolGet(Pool *p) +{ SCEnter(); PoolBucket *pb = p->alloc_stack; @@ -331,7 +334,8 @@ void *PoolGet(Pool *p) { SCReturnPtr(ptr,"void"); } -void PoolReturn(Pool *p, void *data) { +void PoolReturn(Pool *p, void *data) +{ SCEnter(); PoolBucket *pb = p->empty_stack; @@ -370,7 +374,8 @@ void PoolReturn(Pool *p, void *data) { SCReturn; } -void PoolPrintSaturation(Pool *p) { +void PoolPrintSaturation(Pool *p) +{ SCLogDebug("pool %p is using %"PRIu32" out of %"PRIu32" items (%02.1f%%), max %"PRIu32" (%02.1f%%): pool struct memory %"PRIu64".", p, p->outstanding, p->max_buckets, (float)(p->outstanding/(float)(p->max_buckets))*100, p->max_outstanding, (float)(p->max_outstanding/(float)(p->max_buckets))*100, (uint64_t)(p->max_buckets * sizeof(PoolBucket))); } @@ -378,13 +383,15 @@ void PoolPrintSaturation(Pool *p) { * ONLY TESTS BELOW THIS COMMENT */ -void *PoolTestAlloc() { +void *PoolTestAlloc() +{ void *ptr = SCMalloc(10); if (unlikely(ptr == NULL)) return NULL; return ptr; } -int PoolTestInitArg(void *data, void *allocdata) { +int PoolTestInitArg(void *data, void *allocdata) +{ size_t len = strlen((char *)allocdata) + 1; char *str = data; if (str != NULL) @@ -392,12 +399,14 @@ int PoolTestInitArg(void *data, void *allocdata) { return 1; } -void PoolTestFree(void *ptr) { +void PoolTestFree(void *ptr) +{ return; } #ifdef UNITTESTS -static int PoolTestInit01 (void) { +static int PoolTestInit01 (void) +{ Pool *p = PoolInit(10,5,10,PoolTestAlloc,NULL,NULL,PoolTestFree, NULL); if (p == NULL) return 0; @@ -406,7 +415,8 @@ static int PoolTestInit01 (void) { return 1; } -static int PoolTestInit02 (void) { +static int PoolTestInit02 (void) +{ int retval = 0; Pool *p = PoolInit(10,5,10,PoolTestAlloc,NULL,NULL,PoolTestFree, NULL); @@ -441,7 +451,8 @@ end: return retval; } -static int PoolTestInit03 (void) { +static int PoolTestInit03 (void) +{ int retval = 0; void *data = NULL; @@ -475,7 +486,8 @@ end: return retval; } -static int PoolTestInit04 (void) { +static int PoolTestInit04 (void) +{ int retval = 0; char *str = NULL; @@ -515,7 +527,8 @@ end: return retval; } -static int PoolTestInit05 (void) { +static int PoolTestInit05 (void) +{ int retval = 0; void *data = NULL; @@ -564,7 +577,8 @@ end: return retval; } -static int PoolTestInit06 (void) { +static int PoolTestInit06 (void) +{ int retval = 0; void *data = NULL; void *data2 = NULL; @@ -622,7 +636,8 @@ end: } /** \test pool with unlimited size */ -static int PoolTestInit07 (void) { +static int PoolTestInit07 (void) +{ int retval = 0; void *data = NULL; void *data2 = NULL; @@ -701,7 +716,8 @@ end: } #endif /* UNITTESTS */ -void PoolRegisterTests(void) { +void PoolRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("PoolTestInit01", PoolTestInit01, 1); UtRegisterTest("PoolTestInit02", PoolTestInit02, 1); diff --git a/src/util-print.c b/src/util-print.c index 2c2343580d..8cdf0c47e9 100644 --- a/src/util-print.c +++ b/src/util-print.c @@ -133,7 +133,8 @@ void PrintRawUriBuf(char *retbuf, uint32_t *offset, uint32_t retbuflen, return; } -void PrintRawDataFp(FILE *fp, uint8_t *buf, uint32_t buflen) { +void PrintRawDataFp(FILE *fp, uint8_t *buf, uint32_t buflen) +{ int ch = 0; uint32_t u = 0; diff --git a/src/util-privs.c b/src/util-privs.c index 0d221b3472..2048d12ac6 100644 --- a/src/util-privs.c +++ b/src/util-privs.c @@ -101,7 +101,8 @@ void SCDropMainThreadCaps(uint32_t userid, uint32_t groupid) SCLogInfo("dropped the caps for main thread"); } -void SCDropCaps(ThreadVars *tv) { +void SCDropCaps(ThreadVars *tv) +{ #if 0 capng_clear(CAPNG_SELECT_BOTH); capng_apply(CAPNG_SELECT_BOTH); diff --git a/src/util-profiling-keywords.c b/src/util-profiling-keywords.c index 4a6bd661f9..84073735ea 100644 --- a/src/util-profiling-keywords.c +++ b/src/util-profiling-keywords.c @@ -66,7 +66,8 @@ __thread int profiling_keyword_entered = 0; static char *profiling_file_name = ""; static const char *profiling_file_mode = "a"; -void SCProfilingKeywordsGlobalInit(void) { +void SCProfilingKeywordsGlobalInit(void) +{ ConfNode *conf; conf = ConfGetNode("profiling.keywords"); @@ -99,7 +100,8 @@ void SCProfilingKeywordsGlobalInit(void) { } } -void DoDump(SCProfileKeywordDetectCtx *rules_ctx, FILE *fp, const char *name) { +void DoDump(SCProfileKeywordDetectCtx *rules_ctx, FILE *fp, const char *name) +{ int i; fprintf(fp, " ----------------------------------------------" "------------------------------------------------------" @@ -150,7 +152,8 @@ void DoDump(SCProfileKeywordDetectCtx *rules_ctx, FILE *fp, const char *name) { } void -SCProfilingKeywordDump(DetectEngineCtx *de_ctx) { +SCProfilingKeywordDump(DetectEngineCtx *de_ctx) +{ int i; FILE *fp; struct timeval tval; @@ -243,7 +246,8 @@ SCProfilingKeywordUpdateCounter(DetectEngineThreadCtx *det_ctx, int id, uint64_t } } -SCProfileKeywordDetectCtx *SCProfilingKeywordInitCtx(void) { +SCProfileKeywordDetectCtx *SCProfilingKeywordInitCtx(void) +{ SCProfileKeywordDetectCtx *ctx = SCMalloc(sizeof(SCProfileKeywordDetectCtx)); if (ctx != NULL) { memset(ctx, 0x00, sizeof(SCProfileKeywordDetectCtx)); @@ -258,7 +262,8 @@ SCProfileKeywordDetectCtx *SCProfilingKeywordInitCtx(void) { return ctx; } -static void DetroyCtx(SCProfileKeywordDetectCtx *ctx) { +static void DetroyCtx(SCProfileKeywordDetectCtx *ctx) +{ if (ctx) { if (ctx->data != NULL) SCFree(ctx->data); @@ -267,7 +272,8 @@ static void DetroyCtx(SCProfileKeywordDetectCtx *ctx) { } } -void SCProfilingKeywordDestroyCtx(DetectEngineCtx *de_ctx) { +void SCProfilingKeywordDestroyCtx(DetectEngineCtx *de_ctx) +{ if (de_ctx != NULL) { SCProfilingKeywordDump(de_ctx); @@ -279,7 +285,8 @@ void SCProfilingKeywordDestroyCtx(DetectEngineCtx *de_ctx) { } } -void SCProfilingKeywordThreadSetup(SCProfileKeywordDetectCtx *ctx, DetectEngineThreadCtx *det_ctx) { +void SCProfilingKeywordThreadSetup(SCProfileKeywordDetectCtx *ctx, DetectEngineThreadCtx *det_ctx) +{ if (ctx == NULL) return; @@ -300,7 +307,8 @@ void SCProfilingKeywordThreadSetup(SCProfileKeywordDetectCtx *ctx, DetectEngineT } } -static void SCProfilingKeywordThreadMerge(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx) { +static void SCProfilingKeywordThreadMerge(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx) +{ if (de_ctx == NULL || de_ctx->profile_keyword_ctx == NULL || de_ctx->profile_keyword_ctx->data == NULL || det_ctx == NULL || det_ctx->keyword_perf_data == NULL) @@ -329,7 +337,8 @@ static void SCProfilingKeywordThreadMerge(DetectEngineCtx *de_ctx, DetectEngineT } } -void SCProfilingKeywordThreadCleanup(DetectEngineThreadCtx *det_ctx) { +void SCProfilingKeywordThreadCleanup(DetectEngineThreadCtx *det_ctx) +{ if (det_ctx == NULL || det_ctx->de_ctx == NULL || det_ctx->keyword_perf_data == NULL) return; diff --git a/src/util-profiling-locks.c b/src/util-profiling-locks.c index 5be0448899..97cc3e0d8a 100644 --- a/src/util-profiling-locks.c +++ b/src/util-profiling-locks.c @@ -57,7 +57,8 @@ typedef struct LockRecord_ { HashListTable *lock_records; pthread_mutex_t lock_records_mutex; -static uint32_t LockRecordHash(HashListTable *ht, void *buf, uint16_t buflen) { +static uint32_t LockRecordHash(HashListTable *ht, void *buf, uint16_t buflen) +{ LockRecord *fn = (LockRecord *)buf; uint32_t hash = strlen(fn->file) + fn->line; uint16_t u; @@ -69,7 +70,8 @@ static uint32_t LockRecordHash(HashListTable *ht, void *buf, uint16_t buflen) { return hash % ht->array_size; } -static char LockRecordCompare(void *buf1, uint16_t len1, void *buf2, uint16_t len2) { +static char LockRecordCompare(void *buf1, uint16_t len1, void *buf2, uint16_t len2) +{ LockRecord *fn1 = (LockRecord *)buf1; LockRecord *fn2 = (LockRecord *)buf2; @@ -82,7 +84,8 @@ static char LockRecordCompare(void *buf1, uint16_t len1, void *buf2, uint16_t le return 0; } -static void LockRecordFree(void *data) { +static void LockRecordFree(void *data) +{ LockRecord *fn = (LockRecord *)data; if (fn == NULL) @@ -90,7 +93,8 @@ static void LockRecordFree(void *data) { SCFree(fn); } -int LockRecordInitHash() { +int LockRecordInitHash() +{ pthread_mutex_init(&lock_records_mutex, NULL); pthread_mutex_lock(&lock_records_mutex); @@ -102,7 +106,8 @@ int LockRecordInitHash() { return 0; } -void LockRecordAdd(ProfilingLock *l) { +void LockRecordAdd(ProfilingLock *l) +{ LockRecord fn = { NULL, NULL, 0,0,0,0,0,0}, *ptr = &fn; fn.file = l->file; fn.line = l->line; @@ -134,7 +139,8 @@ void LockRecordAdd(ProfilingLock *l) { } /** \param p void ptr to Packet struct */ -void SCProfilingAddPacketLocks(void *p) { +void SCProfilingAddPacketLocks(void *p) +{ int i; if (profiling_locks_enabled == 0) @@ -147,7 +153,8 @@ void SCProfilingAddPacketLocks(void *p) { } } -void SCProfilingListLocks(void) { +void SCProfilingListLocks(void) +{ FILE *fp = NULL; if (profiling_locks_output_to_file == 1) { @@ -211,7 +218,8 @@ void SCProfilingListLocks(void) { fclose(fp); } -void LockRecordFreeHash() { +void LockRecordFreeHash() +{ if (profiling_locks_enabled == 0) return; diff --git a/src/util-profiling-rules.c b/src/util-profiling-rules.c index 61ae78e6ca..a6a4189da5 100644 --- a/src/util-profiling-rules.c +++ b/src/util-profiling-rules.c @@ -105,7 +105,8 @@ static int profiling_rules_sort_order = SC_PROFILING_RULES_SORT_BY_TICKS; */ static uint32_t profiling_rules_limit = UINT32_MAX; -void SCProfilingRulesGlobalInit(void) { +void SCProfilingRulesGlobalInit(void) +{ ConfNode *conf; const char *val; @@ -456,7 +457,8 @@ SCProfilingRuleUpdateCounter(DetectEngineThreadCtx *det_ctx, uint16_t id, uint64 } } -SCProfileDetectCtx *SCProfilingRuleInitCtx(void) { +SCProfileDetectCtx *SCProfilingRuleInitCtx(void) +{ SCProfileDetectCtx *ctx = SCMalloc(sizeof(SCProfileDetectCtx)); if (ctx != NULL) { memset(ctx, 0x00, sizeof(SCProfileDetectCtx)); @@ -471,7 +473,8 @@ SCProfileDetectCtx *SCProfilingRuleInitCtx(void) { return ctx; } -void SCProfilingRuleDestroyCtx(SCProfileDetectCtx *ctx) { +void SCProfilingRuleDestroyCtx(SCProfileDetectCtx *ctx) +{ if (ctx != NULL) { SCProfilingRuleDump(ctx); if (ctx->data != NULL) @@ -481,7 +484,8 @@ void SCProfilingRuleDestroyCtx(SCProfileDetectCtx *ctx) { } } -void SCProfilingRuleThreadSetup(SCProfileDetectCtx *ctx, DetectEngineThreadCtx *det_ctx) { +void SCProfilingRuleThreadSetup(SCProfileDetectCtx *ctx, DetectEngineThreadCtx *det_ctx) +{ if (ctx == NULL|| ctx->size == 0) return; @@ -494,7 +498,8 @@ void SCProfilingRuleThreadSetup(SCProfileDetectCtx *ctx, DetectEngineThreadCtx * } } -static void SCProfilingRuleThreadMerge(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx) { +static void SCProfilingRuleThreadMerge(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx) +{ if (de_ctx == NULL || de_ctx->profile_ctx == NULL || de_ctx->profile_ctx->data == NULL || det_ctx == NULL || det_ctx->rule_perf_data == NULL) return; @@ -510,7 +515,8 @@ static void SCProfilingRuleThreadMerge(DetectEngineCtx *de_ctx, DetectEngineThre } } -void SCProfilingRuleThreadCleanup(DetectEngineThreadCtx *det_ctx) { +void SCProfilingRuleThreadCleanup(DetectEngineThreadCtx *det_ctx) +{ if (det_ctx == NULL || det_ctx->de_ctx == NULL || det_ctx->rule_perf_data == NULL) return; diff --git a/src/util-profiling.c b/src/util-profiling.c index faa0592cbe..4cdfdb57a7 100644 --- a/src/util-profiling.c +++ b/src/util-profiling.c @@ -107,7 +107,8 @@ __thread int profiling_rules_entered = 0; void SCProfilingDumpPacketStats(void); const char * PacketProfileDetectIdToString(PacketProfileDetectId id); -static void FormatNumber(uint64_t num, char *str, size_t size) { +static void FormatNumber(uint64_t num, char *str, size_t size) +{ if (num < 1000UL) snprintf(str, size, "%"PRIu64, num); else if (num < 1000000UL) @@ -298,7 +299,8 @@ SCProfilingDump(void) SCLogInfo("Done dumping profiling data."); } -void SCProfilingDumpPacketStats(void) { +void SCProfilingDumpPacketStats(void) +{ int i; FILE *fp; char totalstr[256]; @@ -675,7 +677,8 @@ void SCProfilingDumpPacketStats(void) { fclose(fp); } -void SCProfilingPrintPacketProfile(Packet *p) { +void SCProfilingPrintPacketProfile(Packet *p) +{ if (profiling_packets_csv_enabled == 0 || p == NULL || packet_profile_csv_fp == NULL || p->profile == NULL) { return; } @@ -730,7 +733,8 @@ void SCProfilingPrintPacketProfile(Packet *p) { fprintf(packet_profile_csv_fp,"\n"); } -static void SCProfilingUpdatePacketDetectRecord(PacketProfileDetectId id, uint8_t ipproto, PktProfilingDetectData *pdt, int ipver) { +static void SCProfilingUpdatePacketDetectRecord(PacketProfileDetectId id, uint8_t ipproto, PktProfilingDetectData *pdt, int ipver) +{ if (pdt == NULL) { return; } @@ -752,7 +756,8 @@ static void SCProfilingUpdatePacketDetectRecord(PacketProfileDetectId id, uint8_ pd->cnt ++; } -void SCProfilingUpdatePacketDetectRecords(Packet *p) { +void SCProfilingUpdatePacketDetectRecords(Packet *p) +{ PacketProfileDetectId i; for (i = 0; i < PROF_DETECT_SIZE; i++) { PktProfilingDetectData *pdt = &p->profile->detect[i]; @@ -767,7 +772,8 @@ void SCProfilingUpdatePacketDetectRecords(Packet *p) { } } -static void SCProfilingUpdatePacketAppPdRecord(uint8_t ipproto, uint32_t ticks_spent, int ipver) { +static void SCProfilingUpdatePacketAppPdRecord(uint8_t ipproto, uint32_t ticks_spent, int ipver) +{ SCProfilePacketData *pd; if (ipver == 4) pd = &packet_profile_app_pd_data4[ipproto]; @@ -785,7 +791,8 @@ static void SCProfilingUpdatePacketAppPdRecord(uint8_t ipproto, uint32_t ticks_s pd->cnt ++; } -static void SCProfilingUpdatePacketAppRecord(int alproto, uint8_t ipproto, PktProfilingAppData *pdt, int ipver) { +static void SCProfilingUpdatePacketAppRecord(int alproto, uint8_t ipproto, PktProfilingAppData *pdt, int ipver) +{ if (pdt == NULL) { return; } @@ -807,7 +814,8 @@ static void SCProfilingUpdatePacketAppRecord(int alproto, uint8_t ipproto, PktPr pd->cnt ++; } -void SCProfilingUpdatePacketAppRecords(Packet *p) { +void SCProfilingUpdatePacketAppRecords(Packet *p) +{ int i; for (i = 0; i < ALPROTO_MAX; i++) { PktProfilingAppData *pdt = &p->profile->app[i]; @@ -830,7 +838,8 @@ void SCProfilingUpdatePacketAppRecords(Packet *p) { } } -void SCProfilingUpdatePacketTmmRecord(int module, uint8_t proto, PktProfilingTmmData *pdt, int ipver) { +void SCProfilingUpdatePacketTmmRecord(int module, uint8_t proto, PktProfilingTmmData *pdt, int ipver) +{ if (pdt == NULL) { return; } @@ -862,7 +871,8 @@ void SCProfilingUpdatePacketTmmRecord(int module, uint8_t proto, PktProfilingTmm #endif } -void SCProfilingUpdatePacketTmmRecords(Packet *p) { +void SCProfilingUpdatePacketTmmRecords(Packet *p) +{ int i; for (i = 0; i < TMM_SIZE; i++) { PktProfilingTmmData *pdt = &p->profile->tmm[i]; @@ -879,7 +889,8 @@ void SCProfilingUpdatePacketTmmRecords(Packet *p) { } } -void SCProfilingAddPacket(Packet *p) { +void SCProfilingAddPacket(Packet *p) +{ if (p == NULL || p->profile == NULL || p->profile->ticks_start == 0 || p->profile->ticks_end == 0 || p->profile->ticks_start > p->profile->ticks_end) @@ -959,7 +970,8 @@ void SCProfilingAddPacket(Packet *p) { pthread_mutex_unlock(&packet_profile_lock); } -PktProfiling *SCProfilePacketStart(void) { +PktProfiling *SCProfilePacketStart(void) +{ uint64_t sample = SC_ATOMIC_ADD(samples, 1); if (sample % rate == 0) return SCCalloc(1, sizeof(PktProfiling)); @@ -968,7 +980,8 @@ PktProfiling *SCProfilePacketStart(void) { } /* see if we want to profile rules for this packet */ -int SCProfileRuleStart(Packet *p) { +int SCProfileRuleStart(Packet *p) +{ #ifdef PROFILE_LOCKING if (p->profile != NULL) { p->flags |= PKT_PROFILE; @@ -1031,7 +1044,8 @@ const char * PacketProfileDetectIdToString(PacketProfileDetectId id) #ifdef UNITTESTS static int -ProfilingGenericTicksTest01(void) { +ProfilingGenericTicksTest01(void) +{ #define TEST_RUNS 1024 uint64_t ticks_start = 0; uint64_t ticks_end = 0; diff --git a/src/util-radix-tree.c b/src/util-radix-tree.c index 691a7de0fe..5ae08b472a 100644 --- a/src/util-radix-tree.c +++ b/src/util-radix-tree.c @@ -929,7 +929,8 @@ SCRadixNode *SCRadixAddKeyIPV6Netblock(uint8_t *key_stream, SCRadixTree *tree, * * \retval node Pointer to the newly created node */ -SCRadixNode *SCRadixAddKeyIPV4String(const char *str, SCRadixTree *tree, void *user) { +SCRadixNode *SCRadixAddKeyIPV4String(const char *str, SCRadixTree *tree, void *user) +{ uint32_t ip; uint8_t netmask = 32; char ip_str[32]; /* Max length for full ipv4/mask string with NUL */ @@ -977,7 +978,8 @@ SCRadixNode *SCRadixAddKeyIPV4String(const char *str, SCRadixTree *tree, void *u * * \retval node Pointer to the newly created node */ -SCRadixNode *SCRadixAddKeyIPV6String(const char *str, SCRadixTree *tree, void *user) { +SCRadixNode *SCRadixAddKeyIPV6String(const char *str, SCRadixTree *tree, void *user) +{ uint8_t netmask = 128; char ip_str[80]; /* Max length for full ipv6/mask string with NUL */ char *mask_str = NULL; diff --git a/src/util-random.c b/src/util-random.c index e68a5bf866..3cf5e0756f 100644 --- a/src/util-random.c +++ b/src/util-random.c @@ -32,7 +32,8 @@ * \brief create a seed number to pass to rand() , rand_r(), and similars * \retval seed for rand() */ -unsigned int RandomTimePreseed(void) { +unsigned int RandomTimePreseed(void) +{ /* preseed rand() */ time_t now = time ( 0 ); unsigned char *p = (unsigned char *)&now; diff --git a/src/util-ringbuffer.c b/src/util-ringbuffer.c index 82ed320965..4566bf9f52 100644 --- a/src/util-ringbuffer.c +++ b/src/util-ringbuffer.c @@ -49,7 +49,8 @@ * Based on RINGBUFFER_MUTEX_WAIT define, we either sleep and spin * or use thread condition to wait. */ -static inline void RingBuffer8DoWait(RingBuffer8 *rb) { +static inline void RingBuffer8DoWait(RingBuffer8 *rb) +{ #ifdef RINGBUFFER_MUTEX_WAIT SCMutexLock(&rb->wait_mutex); SCCondWait(&rb->wait_cond, &rb->wait_mutex); @@ -67,7 +68,8 @@ static inline void RingBuffer8DoWait(RingBuffer8 *rb) { * Based on RINGBUFFER_MUTEX_WAIT define, we either sleep and spin * or use thread condition to wait. */ -static inline void RingBufferDoWait(RingBuffer16 *rb) { +static inline void RingBufferDoWait(RingBuffer16 *rb) +{ #ifdef RINGBUFFER_MUTEX_WAIT SCMutexLock(&rb->wait_mutex); SCCondWait(&rb->wait_cond, &rb->wait_mutex); @@ -85,7 +87,8 @@ static inline void RingBufferDoWait(RingBuffer16 *rb) { * Based on RINGBUFFER_MUTEX_WAIT define, we either sleep and spin * or use thread condition to wait. */ -void RingBufferWait(RingBuffer16 *rb) { +void RingBufferWait(RingBuffer16 *rb) +{ RingBufferDoWait(rb); } @@ -93,7 +96,8 @@ void RingBufferWait(RingBuffer16 *rb) { * * \param rb ringbuffer */ -void RingBuffer8Shutdown(RingBuffer8 *rb) { +void RingBuffer8Shutdown(RingBuffer8 *rb) +{ rb->shutdown = 1; #ifdef RINGBUFFER_MUTEX_WAIT SCCondSignal(&rb->wait_cond); @@ -107,7 +111,8 @@ void RingBuffer8Shutdown(RingBuffer8 *rb) { * \retval 1 empty * \retval 0 not empty */ -int RingBuffer8IsEmpty(RingBuffer8 *rb) { +int RingBuffer8IsEmpty(RingBuffer8 *rb) +{ if (SC_ATOMIC_GET(rb->write) == SC_ATOMIC_GET(rb->read)) { return 1; } @@ -122,7 +127,8 @@ int RingBuffer8IsEmpty(RingBuffer8 *rb) { * \retval 1 empty * \retval 0 not empty */ -int RingBuffer8IsFull(RingBuffer8 *rb) { +int RingBuffer8IsFull(RingBuffer8 *rb) +{ if ((unsigned char)(SC_ATOMIC_GET(rb->write) + 1) == SC_ATOMIC_GET(rb->read)) { return 1; } @@ -134,7 +140,8 @@ int RingBuffer8IsFull(RingBuffer8 *rb) { * * \param rb ringbuffer */ -void RingBufferShutdown(RingBuffer16 *rb) { +void RingBufferShutdown(RingBuffer16 *rb) +{ rb->shutdown = 1; #ifdef RINGBUFFER_MUTEX_WAIT SCCondSignal(&rb->wait_cond); @@ -142,7 +149,8 @@ void RingBufferShutdown(RingBuffer16 *rb) { } /** \brief get number of items in the ringbuffer */ -uint16_t RingBufferSize(RingBuffer16 *rb) { +uint16_t RingBufferSize(RingBuffer16 *rb) +{ SCEnter(); uint16_t size = (uint16_t)(SC_ATOMIC_GET(rb->write) - SC_ATOMIC_GET(rb->read)); SCReturnUInt(size); @@ -155,7 +163,8 @@ uint16_t RingBufferSize(RingBuffer16 *rb) { * \retval 1 empty * \retval 0 not empty */ -int RingBufferIsEmpty(RingBuffer16 *rb) { +int RingBufferIsEmpty(RingBuffer16 *rb) +{ if (SC_ATOMIC_GET(rb->write) == SC_ATOMIC_GET(rb->read)) { return 1; } @@ -170,7 +179,8 @@ int RingBufferIsEmpty(RingBuffer16 *rb) { * \retval 1 empty * \retval 0 not empty */ -int RingBufferIsFull(RingBuffer16 *rb) { +int RingBufferIsFull(RingBuffer16 *rb) +{ if ((unsigned short)(SC_ATOMIC_GET(rb->write) + 1) == SC_ATOMIC_GET(rb->read)) { return 1; } @@ -180,7 +190,8 @@ int RingBufferIsFull(RingBuffer16 *rb) { /* Single Reader, Single Writer, 8 bits */ -void *RingBufferSrSw8Get(RingBuffer8 *rb) { +void *RingBufferSrSw8Get(RingBuffer8 *rb) +{ void *ptr = NULL; /* buffer is empty, wait... */ @@ -201,7 +212,8 @@ void *RingBufferSrSw8Get(RingBuffer8 *rb) { return ptr; } -int RingBufferSrSw8Put(RingBuffer8 *rb, void *ptr) { +int RingBufferSrSw8Put(RingBuffer8 *rb, void *ptr) +{ /* buffer is full, wait... */ while ((unsigned char)(SC_ATOMIC_GET(rb->write) + 1) == SC_ATOMIC_GET(rb->read)) { /* break out if the engine wants to shutdown */ @@ -222,7 +234,8 @@ int RingBufferSrSw8Put(RingBuffer8 *rb, void *ptr) { /* Single Reader, Multi Writer, 8 bites */ -void *RingBufferSrMw8Get(RingBuffer8 *rb) { +void *RingBufferSrMw8Get(RingBuffer8 *rb) +{ void *ptr = NULL; /* buffer is empty, wait... */ @@ -261,7 +274,8 @@ void *RingBufferSrMw8Get(RingBuffer8 *rb) { * \retval 0 ok * \retval -1 wait loop interrupted because of engine flags */ -int RingBufferSrMw8Put(RingBuffer8 *rb, void *ptr) { +int RingBufferSrMw8Put(RingBuffer8 *rb, void *ptr) +{ SCLogDebug("ptr %p", ptr); /* buffer is full, wait... */ @@ -305,7 +319,8 @@ retry: * that the threads don't interfere with one another. * */ -void *RingBufferMrSw8Get(RingBuffer8 *rb) { +void *RingBufferMrSw8Get(RingBuffer8 *rb) +{ void *ptr; /** local pointer for data races. If SCAtomicCompareAndSwap (CAS) * fails we increase our local array idx to try the next array member @@ -346,7 +361,8 @@ retry: /** * \brief put a ptr in the RingBuffer */ -int RingBufferMrSw8Put(RingBuffer8 *rb, void *ptr) { +int RingBufferMrSw8Put(RingBuffer8 *rb, void *ptr) +{ SCLogDebug("ptr %p", ptr); /* buffer is full, wait... */ @@ -377,7 +393,8 @@ int RingBufferMrSw8Put(RingBuffer8 *rb, void *ptr) { * that the threads don't interfere with one another. * */ -void *RingBufferMrSwGet(RingBuffer16 *rb) { +void *RingBufferMrSwGet(RingBuffer16 *rb) +{ void *ptr; /** local pointer for data races. If SCAtomicCompareAndSwap (CAS) * fails we increase our local array idx to try the next array member @@ -418,7 +435,8 @@ retry: /** * \brief put a ptr in the RingBuffer */ -int RingBufferMrSwPut(RingBuffer16 *rb, void *ptr) { +int RingBufferMrSwPut(RingBuffer16 *rb, void *ptr) +{ SCLogDebug("ptr %p", ptr); /* buffer is full, wait... */ @@ -442,7 +460,8 @@ int RingBufferMrSwPut(RingBuffer16 *rb, void *ptr) { /* Single Reader, Single Writer */ -void *RingBufferSrSwGet(RingBuffer16 *rb) { +void *RingBufferSrSwGet(RingBuffer16 *rb) +{ void *ptr = NULL; /* buffer is empty, wait... */ @@ -463,7 +482,8 @@ void *RingBufferSrSwGet(RingBuffer16 *rb) { return ptr; } -int RingBufferSrSwPut(RingBuffer16 *rb, void *ptr) { +int RingBufferSrSwPut(RingBuffer16 *rb, void *ptr) +{ /* buffer is full, wait... */ while ((unsigned short)(SC_ATOMIC_GET(rb->write) + 1) == SC_ATOMIC_GET(rb->read)) { /* break out if the engine wants to shutdown */ @@ -484,7 +504,8 @@ int RingBufferSrSwPut(RingBuffer16 *rb, void *ptr) { /* Multi Reader, Multi Writer, 8 bits */ -RingBuffer8 *RingBuffer8Init(void) { +RingBuffer8 *RingBuffer8Init(void) +{ RingBuffer8 *rb = SCMalloc(sizeof(RingBuffer8)); if (unlikely(rb == NULL)) { return NULL; @@ -503,7 +524,8 @@ RingBuffer8 *RingBuffer8Init(void) { return rb; } -void RingBuffer8Destroy(RingBuffer8 *rb) { +void RingBuffer8Destroy(RingBuffer8 *rb) +{ if (rb != NULL) { SC_ATOMIC_DESTROY(rb->write); SC_ATOMIC_DESTROY(rb->read); @@ -525,7 +547,8 @@ void RingBuffer8Destroy(RingBuffer8 *rb) { * that the threads don't interfere with one another. * */ -void *RingBufferMrMw8Get(RingBuffer8 *rb) { +void *RingBufferMrMw8Get(RingBuffer8 *rb) +{ void *ptr; /** local pointer for data races. If SCAtomicCompareAndSwap (CAS) * fails we increase our local array idx to try the next array member @@ -580,7 +603,8 @@ retry: * \retval 0 ok * \retval -1 wait loop interrupted because of engine flags */ -int RingBufferMrMw8Put(RingBuffer8 *rb, void *ptr) { +int RingBufferMrMw8Put(RingBuffer8 *rb, void *ptr) +{ SCLogDebug("ptr %p", ptr); /* buffer is full, wait... */ @@ -617,7 +641,8 @@ retry: /* Multi Reader, Multi Writer, 16 bits */ -RingBuffer16 *RingBufferInit(void) { +RingBuffer16 *RingBufferInit(void) +{ RingBuffer16 *rb = SCMalloc(sizeof(RingBuffer16)); if (unlikely(rb == NULL)) { return NULL; @@ -636,7 +661,8 @@ RingBuffer16 *RingBufferInit(void) { return rb; } -void RingBufferDestroy(RingBuffer16 *rb) { +void RingBufferDestroy(RingBuffer16 *rb) +{ if (rb != NULL) { SC_ATOMIC_DESTROY(rb->write); SC_ATOMIC_DESTROY(rb->read); @@ -659,7 +685,8 @@ void RingBufferDestroy(RingBuffer16 *rb) { * that the threads don't interfere with one another. * */ -void *RingBufferMrMwGet(RingBuffer16 *rb) { +void *RingBufferMrMwGet(RingBuffer16 *rb) +{ void *ptr; /** local pointer for data races. If SCAtomicCompareAndSwap (CAS) * fails we increase our local array idx to try the next array member @@ -707,7 +734,8 @@ retry: * * \retval ptr pointer to the data, or NULL if buffer is empty */ -void *RingBufferMrMwGetNoWait(RingBuffer16 *rb) { +void *RingBufferMrMwGetNoWait(RingBuffer16 *rb) +{ void *ptr; /** local pointer for data races. If SCAtomicCompareAndSwap (CAS) * fails we increase our local array idx to try the next array member @@ -760,7 +788,8 @@ retry: * \retval 0 ok * \retval -1 wait loop interrupted because of engine flags */ -int RingBufferMrMwPut(RingBuffer16 *rb, void *ptr) { +int RingBufferMrMwPut(RingBuffer16 *rb, void *ptr) +{ SCLogDebug("ptr %p", ptr); /* buffer is full, wait... */ @@ -796,7 +825,8 @@ retry: } #ifdef UNITTESTS -static int RingBuffer8SrSwInit01 (void) { +static int RingBuffer8SrSwInit01 (void) +{ int result = 0; RingBuffer8 *rb = NULL; @@ -832,7 +862,8 @@ end: return result; } -static int RingBuffer8SrSwPut01 (void) { +static int RingBuffer8SrSwPut01 (void) +{ int result = 0; RingBuffer8 *rb = NULL; @@ -880,7 +911,8 @@ end: return result; } -static int RingBuffer8SrSwPut02 (void) { +static int RingBuffer8SrSwPut02 (void) +{ int result = 0; RingBuffer8 *rb = NULL; @@ -928,7 +960,8 @@ end: return result; } -static int RingBuffer8SrSwGet01 (void) { +static int RingBuffer8SrSwGet01 (void) +{ int result = 0; RingBuffer8 *rb = NULL; @@ -967,7 +1000,8 @@ end: return result; } -static int RingBuffer8SrSwGet02 (void) { +static int RingBuffer8SrSwGet02 (void) +{ int result = 0; RingBuffer8 *rb = NULL; @@ -1041,7 +1075,8 @@ end: #endif /* UNITTESTS */ -void DetectRingBufferRegisterTests(void) { +void DetectRingBufferRegisterTests(void) +{ #ifdef UNITTESTS /* UNITTESTS */ UtRegisterTest("RingBuffer8SrSwInit01", RingBuffer8SrSwInit01, 1); UtRegisterTest("RingBuffer8SrSwPut01", RingBuffer8SrSwPut01, 1); diff --git a/src/util-rohash.c b/src/util-rohash.c index c2b32b4607..a8e842b732 100644 --- a/src/util-rohash.c +++ b/src/util-rohash.c @@ -61,7 +61,8 @@ typedef struct ROHashTableOffsets_ { * * \retval table ptr or NULL on error */ -ROHashTable *ROHashInit(uint8_t hash_bits, uint16_t item_size) { +ROHashTable *ROHashInit(uint8_t hash_bits, uint16_t item_size) +{ if (item_size % 4 != 0 || item_size == 0) { SCLogError(SC_ERR_HASH_TABLE_INIT, "data size must be multiple of 4"); return NULL; @@ -88,7 +89,8 @@ ROHashTable *ROHashInit(uint8_t hash_bits, uint16_t item_size) { return table; } -void ROHashFree(ROHashTable *table) { +void ROHashFree(ROHashTable *table) +{ if (table != NULL) { if (table->data != NULL) { SCFree(table->data); @@ -98,7 +100,8 @@ void ROHashFree(ROHashTable *table) { } } -uint32_t ROHashMemorySize(ROHashTable *table) { +uint32_t ROHashMemorySize(ROHashTable *table) +{ return (uint32_t)(hashsize(table->hash_bits) * sizeof(ROHashTableOffsets) + table->items * table->item_size + sizeof(ROHashTable)); } @@ -107,7 +110,8 @@ uint32_t ROHashMemorySize(ROHashTable *table) { * \retval NULL not found * \retval ptr found */ -void *ROHashLookup(ROHashTable *table, void *data, uint16_t size) { +void *ROHashLookup(ROHashTable *table, void *data, uint16_t size) +{ if (data == NULL || size != table->item_size) { SCReturnPtr(NULL, "void"); } @@ -145,7 +149,8 @@ void *ROHashLookup(ROHashTable *table, void *data, uint16_t size) { * \retval 0 error * \retval 1 ok */ -int ROHashInitQueueValue(ROHashTable *table, void *value, uint16_t size) { +int ROHashInitQueueValue(ROHashTable *table, void *value, uint16_t size) +{ if (table->locked) { SCLogError(SC_ERR_HASH_TABLE_INIT, "can't add value to locked table"); return 0; @@ -175,7 +180,8 @@ int ROHashInitQueueValue(ROHashTable *table, void *value, uint16_t size) { * * \note after this call the nothing can be added to the hash anymore. */ -int ROHashInitFinalize(ROHashTable *table) { +int ROHashInitFinalize(ROHashTable *table) +{ if (table->locked) { SCLogError(SC_ERR_HASH_TABLE_INIT, "table already locked"); return 0; diff --git a/src/util-runmodes.c b/src/util-runmodes.c index 3c5387e463..e4cd5e0139 100644 --- a/src/util-runmodes.c +++ b/src/util-runmodes.c @@ -296,7 +296,8 @@ int RunModeSetLiveCaptureAuto(DetectEngineCtx *de_ctx, * * The string will be "pickup1,pickup2,pickup3\0" */ -char *RunmodeAutoFpCreatePickupQueuesString(int n) { +char *RunmodeAutoFpCreatePickupQueuesString(int n) +{ char *queues = NULL; /* 13 because pickup12345, = 12 + \0 */ size_t queues_size = n * 13; diff --git a/src/util-spm-bm.c b/src/util-spm-bm.c index c0f385863a..7c5b8d2d4d 100644 --- a/src/util-spm-bm.c +++ b/src/util-spm-bm.c @@ -53,7 +53,8 @@ static void PreBmGsNocase(const uint8_t *x, uint16_t m, uint16_t *bmGs); * \param str pointer to the pattern string * \param size length of the string */ -void BoyerMooreCtxToNocase(BmCtx *bm_ctx, uint8_t *needle, uint16_t needle_len) { +void BoyerMooreCtxToNocase(BmCtx *bm_ctx, uint8_t *needle, uint16_t needle_len) +{ /* Store the content as lower case to make searching faster */ memcpy_tolower(needle, needle, needle_len); @@ -72,7 +73,8 @@ void BoyerMooreCtxToNocase(BmCtx *bm_ctx, uint8_t *needle, uint16_t needle_len) * \retval BmCtx pointer to the newly created Context for the pattern * \initonly BoyerMoore contexts should be created at init */ -BmCtx *BoyerMooreCtxInit(uint8_t *needle, uint16_t needle_len) { +BmCtx *BoyerMooreCtxInit(uint8_t *needle, uint16_t needle_len) +{ BmCtx *new = SCMalloc(sizeof(BmCtx)); if (unlikely(new == NULL)) { SCLogError(SC_ERR_FATAL, "Fatal error encountered in BoyerMooreCtxInit. Exiting..."); @@ -159,7 +161,8 @@ static void PreBmBc(const uint8_t *x, uint16_t m, uint16_t *bmBc) * \param m length of the string * \param suff pointer to an empty array that will hold the prefixes (shifts) */ -static void BoyerMooreSuffixes(const uint8_t *x, uint16_t m, uint16_t *suff) { +static void BoyerMooreSuffixes(const uint8_t *x, uint16_t m, uint16_t *suff) +{ int32_t f = 0, g, i; suff[m - 1] = m; g = m - 1; diff --git a/src/util-spm-bs.c b/src/util-spm-bs.c index 03ea7768eb..6d49ff6583 100644 --- a/src/util-spm-bs.c +++ b/src/util-spm-bs.c @@ -45,7 +45,8 @@ * * \retval ptr to start of the match; NULL if no match */ -uint8_t *BasicSearch(const uint8_t *haystack, uint32_t haystack_len, const uint8_t *needle, uint16_t needle_len) { +uint8_t *BasicSearch(const uint8_t *haystack, uint32_t haystack_len, const uint8_t *needle, uint16_t needle_len) +{ SCEnter(); const uint8_t *h, *n; @@ -98,7 +99,8 @@ uint8_t *BasicSearch(const uint8_t *haystack, uint32_t haystack_len, const uint8 * * \retval ptr to start of the match; NULL if no match */ -uint8_t *BasicSearchNocase(const uint8_t *haystack, uint32_t haystack_len, const uint8_t *needle, uint16_t needle_len) { +uint8_t *BasicSearchNocase(const uint8_t *haystack, uint32_t haystack_len, const uint8_t *needle, uint16_t needle_len) +{ const uint8_t *h, *n; const uint8_t *hmax = haystack + haystack_len; const uint8_t *nmax = needle + needle_len; @@ -130,7 +132,8 @@ uint8_t *BasicSearchNocase(const uint8_t *haystack, uint32_t haystack_len, const return NULL; } -void BasicSearchInit (void) { +void BasicSearchInit (void) +{ /* nothing no more */ } diff --git a/src/util-spm-bs2bm.c b/src/util-spm-bs2bm.c index 4d26f44204..d6529df85d 100644 --- a/src/util-spm-bs2bm.c +++ b/src/util-spm-bs2bm.c @@ -40,7 +40,8 @@ * characters that can't be inside the needle_len. So the skips can be * faster */ -void Bs2BmBadchars(const uint8_t *needle, uint16_t needle_len, uint8_t *badchars) { +void Bs2BmBadchars(const uint8_t *needle, uint16_t needle_len, uint8_t *badchars) +{ uint32_t i; for (i = 0; i < ALPHABET_SIZE; i++) badchars[i] = 1; @@ -61,7 +62,8 @@ void Bs2BmBadchars(const uint8_t *needle, uint16_t needle_len, uint8_t *badchars * characters that can't be inside the needle_len. So the skips can be * faster */ -void Bs2BmBadcharsNocase(const uint8_t *needle, uint16_t needle_len, uint8_t *badchars) { +void Bs2BmBadcharsNocase(const uint8_t *needle, uint16_t needle_len, uint8_t *badchars) +{ uint32_t i; for (i = 0; i < ALPHABET_SIZE; i++) badchars[i] = 1; diff --git a/src/util-spm.c b/src/util-spm.c index 208b9081d8..2da12e7788 100644 --- a/src/util-spm.c +++ b/src/util-spm.c @@ -2315,7 +2315,8 @@ int UtilSpmNocaseSearchStatsTest07() #endif /* Register unittests */ -void UtilSpmSearchRegistertests(void) { +void UtilSpmSearchRegistertests(void) +{ #ifdef UNITTESTS /* Generic tests */ UtRegisterTest("UtilSpmBasicSearchTest01", UtilSpmBasicSearchTest01, 1); diff --git a/src/util-threshold-config.c b/src/util-threshold-config.c index 59e04be9e9..92ddce6a32 100644 --- a/src/util-threshold-config.c +++ b/src/util-threshold-config.c @@ -1118,7 +1118,8 @@ int SCThresholdConfLineIsMultiline(char *line) * \param fd Pointer to file descriptor. * \retval int of the line length */ -int SCThresholdConfLineLength(FILE *fd) { +int SCThresholdConfLineLength(FILE *fd) +{ long pos = ftell(fd); int len = 0; int c; diff --git a/src/util-unittest-helper.c b/src/util-unittest-helper.c index f2c96b08e3..a318205d70 100644 --- a/src/util-unittest-helper.c +++ b/src/util-unittest-helper.c @@ -51,7 +51,8 @@ * * \retval uint the uin32_t representation */ -uint32_t UTHSetIPv4Address(char *str) { +uint32_t UTHSetIPv4Address(char *str) +{ struct in_addr in; if (inet_pton(AF_INET, str, &in) != 1) { printf("invalid IPv6 address %s\n", str); @@ -76,7 +77,8 @@ uint32_t UTHSetIPv4Address(char *str) { */ Packet *UTHBuildPacketIPV6Real(uint8_t *payload, uint16_t payload_len, uint8_t ipproto, char *src, char *dst, - uint16_t sport, uint16_t dport) { + uint16_t sport, uint16_t dport) +{ uint32_t in[4]; Packet *p = PacketGetFromAlloc(); @@ -161,7 +163,8 @@ error: */ Packet *UTHBuildPacketReal(uint8_t *payload, uint16_t payload_len, uint8_t ipproto, char *src, char *dst, - uint16_t sport, uint16_t dport) { + uint16_t sport, uint16_t dport) +{ struct in_addr in; Packet *p = PacketGetFromAlloc(); @@ -252,7 +255,8 @@ error: * \retval Packet pointer to the built in packet */ Packet *UTHBuildPacket(uint8_t *payload, uint16_t payload_len, - uint8_t ipproto) { + uint8_t ipproto) +{ return UTHBuildPacketReal(payload, payload_len, ipproto, "192.168.1.5", "192.168.1.1", 41424, 80); @@ -269,7 +273,8 @@ Packet *UTHBuildPacket(uint8_t *payload, uint16_t payload_len, * * \retval Packet pointer to the array of built in packets; NULL if something fail */ -Packet **UTHBuildPacketArrayFromEth(uint8_t *raw_eth[], int *pktsize, int numpkts) { +Packet **UTHBuildPacketArrayFromEth(uint8_t *raw_eth[], int *pktsize, int numpkts) +{ DecodeThreadVars dtv; ThreadVars th_v; if (raw_eth == NULL || pktsize == NULL || numpkts <= 0) { @@ -306,7 +311,8 @@ Packet **UTHBuildPacketArrayFromEth(uint8_t *raw_eth[], int *pktsize, int numpkt * * \retval Packet pointer to the built in packet; NULL if something fail */ -Packet *UTHBuildPacketFromEth(uint8_t *raw_eth, uint16_t pktsize) { +Packet *UTHBuildPacketFromEth(uint8_t *raw_eth, uint16_t pktsize) +{ DecodeThreadVars dtv; ThreadVars th_v; Packet *p = PacketGetFromAlloc(); @@ -330,7 +336,8 @@ 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, char *src, char *dst) +{ return UTHBuildPacketReal(payload, payload_len, ipproto, src, dst, 41424, 80); @@ -347,7 +354,8 @@ 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, char *src, char *dst) +{ return UTHBuildPacketIPV6Real(payload, payload_len, ipproto, src, dst, 41424, 80); @@ -364,7 +372,8 @@ Packet *UTHBuildPacketIPV6SrcDst(uint8_t *payload, uint16_t payload_len, * \retval Packet pointer to the built in packet */ Packet *UTHBuildPacketSrcDstPorts(uint8_t *payload, uint16_t payload_len, - uint8_t ipproto, uint16_t sport, uint16_t dport) { + uint8_t ipproto, uint16_t sport, uint16_t dport) +{ return UTHBuildPacketReal(payload, payload_len, ipproto, "192.168.1.5", "192.168.1.1", sport, dport); @@ -376,7 +385,8 @@ Packet *UTHBuildPacketSrcDstPorts(uint8_t *payload, uint16_t payload_len, * * \param p pointer to the Packet */ -void UTHFreePackets(Packet **p, int numpkts) { +void UTHFreePackets(Packet **p, int numpkts) +{ if (p == NULL) return; @@ -392,7 +402,8 @@ void UTHFreePackets(Packet **p, int numpkts) { * * \param p pointer to the Packet */ -void UTHFreePacket(Packet *p) { +void UTHFreePacket(Packet *p) +{ if (p == NULL) return; #if 0 // VJ we now use one buffer @@ -419,7 +430,8 @@ void UTHFreePacket(Packet *p) { SCFree(p); } -Flow *UTHBuildFlow(int family, char *src, char *dst, Port sp, Port dp) { +Flow *UTHBuildFlow(int family, char *src, char *dst, Port sp, Port dp) +{ struct in_addr in; Flow *f = SCMalloc(sizeof(Flow)); @@ -469,7 +481,8 @@ Flow *UTHBuildFlow(int family, char *src, char *dst, Port sp, Port dp) { return f; } -void UTHFreeFlow(Flow *flow) { +void UTHFreeFlow(Flow *flow) +{ if (flow != NULL) { FlowFree(flow); } @@ -498,7 +511,8 @@ void UTHFreeFlow(Flow *flow) { * \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, char *sigs[], uint32_t sids[], uint32_t *results, int numsigs) +{ int result = 0; if (pkt == NULL || sigs == NULL || numpkts == 0 @@ -574,7 +588,8 @@ 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, 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"); return 0; @@ -612,7 +627,8 @@ int UTHAppendSigs(DetectEngineCtx *de_ctx, char *sigs[], int numsigs) { * \retval return 1 if all goes well * \retval return 0 if something fail */ -int UTHMatchPacketsWithResults(DetectEngineCtx *de_ctx, Packet **p, int num_packets, uint32_t sids[], uint32_t *results, int numsigs) { +int UTHMatchPacketsWithResults(DetectEngineCtx *de_ctx, Packet **p, int num_packets, uint32_t sids[], uint32_t *results, int numsigs) +{ int result = 0; if (de_ctx == NULL || p == NULL) { @@ -661,7 +677,8 @@ end: * \retval return 1 if all goes well * \retval return 0 if something fail */ -int UTHMatchPackets(DetectEngineCtx *de_ctx, Packet **p, int num_packets) { +int UTHMatchPackets(DetectEngineCtx *de_ctx, Packet **p, int num_packets) +{ int result = 1; if (de_ctx == NULL || p == NULL) { @@ -711,7 +728,8 @@ end: * \retval return 1 if match * \retval return 0 if not */ -int UTHPacketMatchSigMpm(Packet *p, char *sig, uint16_t mpm_type) { +int UTHPacketMatchSigMpm(Packet *p, char *sig, uint16_t mpm_type) +{ SCEnter(); int result = 0; @@ -771,7 +789,8 @@ end: * \retval return 1 if match * \retval return 0 if not */ -int UTHPacketMatchSig(Packet *p, char *sig) { +int UTHPacketMatchSig(Packet *p, char *sig) +{ int result = 1; DecodeThreadVars dtv; @@ -819,7 +838,8 @@ end: return result; } -uint32_t UTHBuildPacketOfFlows(uint32_t start, uint32_t end, uint8_t dir) { +uint32_t UTHBuildPacketOfFlows(uint32_t start, uint32_t end, uint8_t dir) +{ uint32_t i = start; uint8_t payload[] = "Payload"; for (; i < end; i++) { @@ -849,7 +869,8 @@ 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) { +int CheckUTHTestPacket(Packet *p, uint8_t ipproto) +{ uint16_t sport = 41424; uint16_t dport = 80; uint8_t payload[] = "Payload"; @@ -896,7 +917,8 @@ int CheckUTHTestPacket(Packet *p, uint8_t ipproto) { /** * \brief UTHBuildPacketRealTest01 wrapper to check packets for unittests */ -int UTHBuildPacketRealTest01(void) { +int UTHBuildPacketRealTest01(void) +{ uint8_t payload[] = "Payload"; Packet *p = UTHBuildPacketReal(payload, sizeof(payload), IPPROTO_TCP, @@ -911,7 +933,8 @@ int UTHBuildPacketRealTest01(void) { /** * \brief UTHBuildPacketRealTest02 wrapper to check packets for unittests */ -int UTHBuildPacketRealTest02(void) { +int UTHBuildPacketRealTest02(void) +{ uint8_t payload[] = "Payload"; Packet *p = UTHBuildPacketReal(payload, sizeof(payload), IPPROTO_UDP, @@ -925,7 +948,8 @@ int UTHBuildPacketRealTest02(void) { /** * \brief UTHBuildPacketTest01 wrapper to check packets for unittests */ -int UTHBuildPacketTest01(void) { +int UTHBuildPacketTest01(void) +{ uint8_t payload[] = "Payload"; Packet *p = UTHBuildPacket(payload, sizeof(payload), IPPROTO_TCP); @@ -939,7 +963,8 @@ int UTHBuildPacketTest01(void) { /** * \brief UTHBuildPacketTest02 wrapper to check packets for unittests */ -int UTHBuildPacketTest02(void) { +int UTHBuildPacketTest02(void) +{ uint8_t payload[] = "Payload"; Packet *p = UTHBuildPacket(payload, sizeof(payload), IPPROTO_UDP); @@ -953,7 +978,8 @@ int UTHBuildPacketTest02(void) { /** * \brief UTHBuildPacketOfFlowsTest01 wrapper to check packets for unittests */ -int UTHBuildPacketOfFlowsTest01(void) { +int UTHBuildPacketOfFlowsTest01(void) +{ int result = 0; FlowInitConfig(FLOW_QUIET); @@ -974,7 +1000,8 @@ int UTHBuildPacketOfFlowsTest01(void) { /** * \brief UTHBuildPacketSrcDstTest01 wrapper to check packets for unittests */ -int UTHBuildPacketSrcDstTest01(void) { +int UTHBuildPacketSrcDstTest01(void) +{ uint8_t payload[] = "Payload"; Packet *p = UTHBuildPacketSrcDst(payload, sizeof(payload), IPPROTO_TCP, @@ -989,7 +1016,8 @@ int UTHBuildPacketSrcDstTest01(void) { /** * \brief UTHBuildPacketSrcDstTest02 wrapper to check packets for unittests */ -int UTHBuildPacketSrcDstTest02(void) { +int UTHBuildPacketSrcDstTest02(void) +{ uint8_t payload[] = "Payload"; Packet *p = UTHBuildPacketSrcDst(payload, sizeof(payload), IPPROTO_UDP, @@ -1004,7 +1032,8 @@ int UTHBuildPacketSrcDstTest02(void) { /** * \brief UTHBuildPacketSrcDstPortsTest01 wrapper to check packets for unittests */ -int UTHBuildPacketSrcDstPortsTest01(void) { +int UTHBuildPacketSrcDstPortsTest01(void) +{ uint8_t payload[] = "Payload"; Packet *p = UTHBuildPacketSrcDstPorts(payload, sizeof(payload), IPPROTO_TCP, @@ -1019,7 +1048,8 @@ int UTHBuildPacketSrcDstPortsTest01(void) { /** * \brief UTHBuildPacketSrcDstPortsTest02 wrapper to check packets for unittests */ -int UTHBuildPacketSrcDstPortsTest02(void) { +int UTHBuildPacketSrcDstPortsTest02(void) +{ uint8_t payload[] = "Payload"; Packet *p = UTHBuildPacketSrcDstPorts(payload, sizeof(payload), IPPROTO_UDP, @@ -1033,7 +1063,8 @@ int UTHBuildPacketSrcDstPortsTest02(void) { #endif /* UNITTESTS */ -void UTHRegisterTests(void) { +void UTHRegisterTests(void) +{ #ifdef UNITTESTS UtRegisterTest("UTHBuildPacketRealTest01", UTHBuildPacketRealTest01, 1); UtRegisterTest("UTHBuildPacketRealTest02", UTHBuildPacketRealTest02, 1); diff --git a/src/util-unittest.c b/src/util-unittest.c index 4381bcfd53..c3f0fdb296 100644 --- a/src/util-unittest.c +++ b/src/util-unittest.c @@ -44,7 +44,8 @@ static UtTest *ut_list; * \retval ut Pointer to UtTest */ -static UtTest *UtAllocTest(void) { +static UtTest *UtAllocTest(void) +{ UtTest *ut = SCMalloc(sizeof(UtTest)); if (unlikely(ut == NULL)) return NULL; @@ -63,7 +64,8 @@ static UtTest *UtAllocTest(void) { * \retval 0 Function always returns zero */ -static int UtAppendTest(UtTest **list, UtTest *test) { +static int UtAppendTest(UtTest **list, UtTest *test) +{ if (*list == NULL) { *list = test; } else { @@ -87,7 +89,8 @@ static int UtAppendTest(UtTest **list, UtTest *test) { * */ -void UtRegisterTest(char *name, int(*TestFn)(void), int evalue) { +void UtRegisterTest(char *name, int(*TestFn)(void), int evalue) +{ UtTest *ut = UtAllocTest(); if (ut == NULL) return; @@ -110,7 +113,8 @@ void UtRegisterTest(char *name, int(*TestFn)(void), int evalue) { * \retval -1 Regex error */ -int UtRegex (char *regex_arg) { +int UtRegex (char *regex_arg) +{ const char *eb; int eo; int opts = PCRE_CASELESS;; @@ -144,7 +148,8 @@ error: * * \param regex_arg Regular expression to limit listed tests. */ -void UtListTests(char *regex_arg) { +void UtListTests(char *regex_arg) +{ UtTest *ut; int ret = 0, rcomp = 0; int ov[MAX_SUBSTRINGS]; @@ -173,7 +178,8 @@ void UtListTests(char *regex_arg) { * \retval result number of tests that failed */ -uint32_t UtRunTests(char *regex_arg) { +uint32_t UtRunTests(char *regex_arg) +{ UtTest *ut; uint32_t good = 0, bad = 0, matchcnt = 0; int ret = 0, rcomp = 0; @@ -229,7 +235,8 @@ uint32_t UtRunTests(char *regex_arg) { * \brief Initialize unit test list */ -void UtInitialize(void) { +void UtInitialize(void) +{ ut_list = NULL; } @@ -237,7 +244,8 @@ void UtInitialize(void) { * \brief Cleanup unit test list */ -void UtCleanup(void) { +void UtCleanup(void) +{ UtTest *tmp = ut_list, *otmp; @@ -270,7 +278,8 @@ void UtRunModeRegister(void) * \retval 0 False */ -int UtSelftestTrue(void) { +int UtSelftestTrue(void) +{ if (1)return 1; else return 0; } @@ -281,7 +290,8 @@ int UtSelftestTrue(void) { * \retval 0 True */ -int UtSelftestFalse(void) { +int UtSelftestFalse(void) +{ if (0)return 1; else return 0; } @@ -294,7 +304,8 @@ int UtSelftestFalse(void) { * \retval 0 all successful */ -int UtRunSelftest (char *regex_arg) { +int UtRunSelftest (char *regex_arg) +{ #ifdef UNITTESTS printf("* Running Unittesting subsystem selftests...\n"); diff --git a/src/util-var-name.c b/src/util-var-name.c index c7057815db..b50e35c9c4 100644 --- a/src/util-var-name.c +++ b/src/util-var-name.c @@ -35,7 +35,8 @@ typedef struct VariableName_ { uint16_t idx; } VariableName; -static uint32_t VariableNameHash(HashListTable *ht, void *buf, uint16_t buflen) { +static uint32_t VariableNameHash(HashListTable *ht, void *buf, uint16_t buflen) +{ VariableName *fn = (VariableName *)buf; uint32_t hash = strlen(fn->name) + fn->type; uint16_t u; @@ -47,7 +48,8 @@ static uint32_t VariableNameHash(HashListTable *ht, void *buf, uint16_t buflen) return hash; } -static char VariableNameCompare(void *buf1, uint16_t len1, void *buf2, uint16_t len2) { +static char VariableNameCompare(void *buf1, uint16_t len1, void *buf2, uint16_t len2) +{ VariableName *fn1 = (VariableName *)buf1; VariableName *fn2 = (VariableName *)buf2; @@ -81,7 +83,8 @@ static char VariableIdxCompare(void *buf1, uint16_t len1, void *buf2, uint16_t l return 0; } -static void VariableNameFree(void *data) { +static void VariableNameFree(void *data) +{ VariableName *fn = (VariableName *)data; if (fn == NULL) @@ -100,7 +103,8 @@ static void VariableNameFree(void *data) { * \retval -1 in case of error * \retval 0 in case of success */ -int VariableNameInitHash(DetectEngineCtx *de_ctx) { +int VariableNameInitHash(DetectEngineCtx *de_ctx) +{ de_ctx->variable_names = HashListTableInit(4096, VariableNameHash, VariableNameCompare, VariableNameFree); if (de_ctx->variable_names == NULL) return -1; @@ -113,7 +117,8 @@ int VariableNameInitHash(DetectEngineCtx *de_ctx) { return 0; } -void VariableNameFreeHash(DetectEngineCtx *de_ctx) { +void VariableNameFreeHash(DetectEngineCtx *de_ctx) +{ if (de_ctx->variable_names != NULL) { HashListTableFree(de_ctx->variable_names); HashListTableFree(de_ctx->variable_idxs); @@ -130,7 +135,8 @@ void VariableNameFreeHash(DetectEngineCtx *de_ctx) { * \retval 0 in case of error * \retval _ the idx. */ -uint16_t VariableNameGetIdx(DetectEngineCtx *de_ctx, char *name, uint8_t type) { +uint16_t VariableNameGetIdx(DetectEngineCtx *de_ctx, char *name, uint8_t type) +{ uint16_t idx = 0; VariableName *fn = SCMalloc(sizeof(VariableName));