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;
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)) {
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;
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;
LogFileCtx* file_ctx;
} AlertFastLogThread;
-int AlertFastLogCondition(ThreadVars *tv, const Packet *p) {
+int AlertFastLogCondition(ThreadVars *tv, const Packet *p)
+{
return (p->alerts.cnt ? TRUE : FALSE);
}
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;
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))
*
* \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;
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;
* \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;
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)) {
#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;
SCReturnInt(1);
}
-static void *DCERPCUDPStateAlloc(void) {
+static void *DCERPCUDPStateAlloc(void)
+{
void *s = SCMalloc(sizeof(DCERPCUDPState));
if (unlikely(s == NULL))
return NULL;
return s;
}
-static void DCERPCUDPStateFree(void *s) {
+static void DCERPCUDPStateFree(void *s)
+{
DCERPCUDPState *sstate = (DCERPCUDPState *) s;
DCERPCUuidEntry *item;
return 0;
}
-void RegisterDCERPCUDPParsers(void) {
+void RegisterDCERPCUDPParsers(void)
+{
char *proto_name = "dcerpc";
if (AppLayerProtoDetectConfProtoDetectionEnabled("udp", proto_name)) {
/** \test DCERPC UDP Header Parsing and UUID handling
*/
-int DCERPCUDPParserTest01(void) {
+int DCERPCUDPParserTest01(void)
+{
int result = 1;
Flow f;
uint8_t dcerpcrequest[] = {
return result;
}
-void DCERPCUDPParserRegisterTests(void) {
+void DCERPCUDPParserRegisterTests(void)
+{
UtRegisterTest("DCERPCUDPParserTest01", DCERPCUDPParserTest01, 1);
}
#endif
};
/* \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.
* \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;
* \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--) {
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--) {
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) {
* 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;
* 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;
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;
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;
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;
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;
* \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;
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;
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)
}
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 */
* 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;
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;
local_data, 1);
}
-static void *DCERPCStateAlloc(void) {
+static void *DCERPCStateAlloc(void)
+{
SCEnter();
DCERPCState *s = SCMalloc(sizeof(DCERPCState));
SCReturnPtr((void *)s, "void");
}
-static void DCERPCStateFree(void *s) {
+static void DCERPCStateFree(void *s)
+{
DCERPCState *sstate = (DCERPCState *) s;
DCERPCUuidEntry *item;
return 0;
}
-void RegisterDCERPCParsers(void) {
+void RegisterDCERPCParsers(void)
+{
char *proto_name = "dcerpc";
if (AppLayerProtoDetectConfProtoDetectionEnabled("tcp", proto_name)) {
/* set this to 1 to see problem */
-int DCERPCParserTest01(void) {
+int DCERPCParserTest01(void)
+{
int result = 1;
Flow f;
uint8_t dcerpcbind[] = {
/** \test DCERPC Request decoding and opnum parsing.
*/
-int DCERPCParserTest02(void) {
+int DCERPCParserTest02(void)
+{
int result = 1;
Flow f;
uint8_t dcerpcrequest[] = {
/** \test Test endianness handling
*/
-int DCERPCParserTest03(void) {
+int DCERPCParserTest03(void)
+{
int result = 1;
Flow f;
uint8_t dcerpcrequest[] = {
/**
* \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 */
/**
* \test General test.
*/
-int DCERPCParserTest05(void) {
+int DCERPCParserTest05(void)
+{
int result = 1;
Flow f;
int r = 0;
/**
* \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;
/**
* \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;
/**
* \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;
/**
* \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;
/**
* \test DCERPC fragmented PDU.
*/
-int DCERPCParserTest10(void) {
+int DCERPCParserTest10(void)
+{
int result = 1;
Flow f;
int r = 0;
/**
* \test DCERPC fragmented PDU.
*/
-int DCERPCParserTest11(void) {
+int DCERPCParserTest11(void)
+{
int result = 1;
Flow f;
int r = 0;
/**
* \test DCERPC fragmented PDU.
*/
-int DCERPCParserTest12(void) {
+int DCERPCParserTest12(void)
+{
int result = 1;
Flow f;
int r = 0;
* \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;
/**
* \test Check for another endless loop with bind pdus.
*/
-int DCERPCParserTest14(void) {
+int DCERPCParserTest14(void)
+{
int result = 1;
Flow f;
int r = 0;
/**
* \test Check for another endless loop for bind_ack pdus.
*/
-int DCERPCParserTest15(void) {
+int DCERPCParserTest15(void)
+{
int result = 1;
Flow f;
int r = 0;
/**
* \test Check for correct internal ids for bind_acks.
*/
-int DCERPCParserTest16(void) {
+int DCERPCParserTest16(void)
+{
int result = 1;
Flow f;
int r = 0;
/**
* \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;
/**
* \test DCERPC fragmented PDU.
*/
-int DCERPCParserTest18(void) {
+int DCERPCParserTest18(void)
+{
int result = 1;
Flow f;
int r = 0;
#endif /* UNITTESTS */
-void DCERPCParserRegisterTests(void) {
+void DCERPCParserRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("DCERPCParserTest01", DCERPCParserTest01, 1);
UtRegisterTest("DCERPCParserTest02", DCERPCParserTest02, 1);
} 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;
}
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);
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;
(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);
return;
}
-AppLayerDecoderEvents *DNSGetEvents(void *state, uint64_t id) {
+AppLayerDecoderEvents *DNSGetEvents(void *state, uint64_t id)
+{
DNSState *dns_state = (DNSState *)state;
DNSTransaction *tx;
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;
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;
*
* 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);
/** \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;
/** \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;
/**
* \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;
* \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;
return NULL;
}
-void *DNSStateAlloc(void) {
+void *DNSStateAlloc(void)
+{
void *s = SCMalloc(sizeof(DNSState));
if (unlikely(s == NULL))
return NULL;
return s;
}
-void DNSStateFree(void *s) {
+void DNSStateFree(void *s)
+{
SCEnter();
if (s) {
DNSState *dns_state = (DNSState *) 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) {
* \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) {
* \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) {
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");
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;
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)
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)
return ALPROTO_DNS;
}
-void RegisterDNSTCPParsers(void) {
+void RegisterDNSTCPParsers(void)
+{
char *proto_name = "dns";
/** DNS */
/* UNITTESTS */
#ifdef UNITTESTS
-void DNSTCPParserRegisterTests(void) {
+void DNSTCPParserRegisterTests(void)
+{
// UtRegisterTest("DNSTCPParserTest01", DNSTCPParserTest01, 1);
}
#endif
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;
DNSConfigSetGlobalMemcap(global_memcap);
}
-void RegisterDNSUDPParsers(void) {
+void RegisterDNSUDPParsers(void)
+{
char *proto_name = "dns";
/** DNS */
#ifdef UNITTESTS
#include "util-unittest-helper.h"
-static int DNSUDPParserTest01 (void) {
+static int DNSUDPParserTest01 (void)
+{
int result = 0;
/* query: abcdefghijk.com
* TTL: 86400
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,
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,
}
/** \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,
}
/** \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,
}
-void DNSUDPParserRegisterTests(void) {
+void DNSUDPParserRegisterTests(void)
+{
UtRegisterTest("DNSUDPParserTest01", DNSUDPParserTest01, 1);
UtRegisterTest("DNSUDPParserTest02", DNSUDPParserTest02, 1);
UtRegisterTest("DNSUDPParserTest03", DNSUDPParserTest03, 1);
* \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;
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;
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);
return 0;
}
-void RegisterFTPParsers(void) {
+void RegisterFTPParsers(void)
+{
char *proto_name = "ftp";
/** FTP */
#endif
}
-void FTPAtExitPrintStats(void) {
+void FTPAtExitPrintStats(void)
+{
#ifdef DEBUG
SCMutexLock(&ftp_state_mem_lock);
SCLogDebug("ftp_state_memcnt %"PRIu64", ftp_state_memuse %"PRIu64"",
#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";
}
/** \test Send a splitted get request. */
-int FTPParserTest03(void) {
+int FTPParserTest03(void)
+{
int result = 1;
Flow f;
uint8_t ftpbuf1[] = "POR";
}
/** \test See how it deals with an incomplete request. */
-int FTPParserTest06(void) {
+int FTPParserTest06(void)
+{
int result = 1;
Flow f;
uint8_t ftpbuf1[] = "PORT";
}
/** \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";
/** \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";
}
#endif /* UNITTESTS */
-void FTPParserRegisterTests(void) {
+void FTPParserRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("FTPParserTest01", FTPParserTest01, 1);
UtRegisterTest("FTPParserTest03", FTPParserTest03, 1);
}
#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"
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"
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"
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"
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"
}
/** \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"
}
/** \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"
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"
}
/** \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"
}
/** \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"
}
/** \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"
#endif /* UNITTESTS */
-void HTPFileParserRegisterTests(void) {
+void HTPFileParserRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("HTPFileParserTest01", HTPFileParserTest01, 1);
UtRegisterTest("HTPFileParserTest02", HTPFileParserTest02, 1);
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);
}
SCReturnPtr(NULL, "void");
}
-static void HtpTxUserDataFree(HtpTxUserData *htud) {
+static void HtpTxUserDataFree(HtpTxUserData *htud)
+{
if (htud) {
HtpBodyFree(&htud->request_body);
HtpBodyFree(&htud->response_body);
* \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;
*
* \initonly
*/
-void AppLayerHtpNeedMultipartHeader(void) {
+void AppLayerHtpNeedMultipartHeader(void)
+{
SCEnter();
AppLayerHtpEnableRequestBodyCallback();
*
* \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++) {
*
* \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;
*
* \param s state
*/
-static void HTPHandleError(HtpState *s) {
+static void HTPHandleError(HtpState *s)
+{
if (s == NULL || s->conn == NULL ||
s->conn->messages == NULL) {
return;
* 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);
/** \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;
// }
* \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) {
* \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);
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);
* \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;
/** \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"
}
/** \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";
/** \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";
/** \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;
/** \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;
/** \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&"
/** \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";
/** \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";
/** \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";
/** \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";
/** \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";
/** \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";
/** \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";
}
/** \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";
}
/** \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;
/** \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;
/**
* \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);
/** \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];
* 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) {
return idx;
}
-void RegisterAppLayerGetActiveTxIdFunc(GetActiveTxIdFunc FuncPtr) {
+void RegisterAppLayerGetActiveTxIdFunc(GetActiveTxIdFunc FuncPtr)
+{
//BUG_ON(AppLayerGetActiveTxIdFuncPtr != NULL);
AppLayerGetActiveTxIdFuncPtr = FuncPtr;
SCLogDebug("AppLayerGetActiveTxIdFuncPtr is now %p", AppLayerGetActiveTxIdFuncPtr);
*
* \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);
* \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) {
* \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));
/** \internal
* \brief Free a SMBState
*/
-static void SMBStateFree(void *s) {
+static void SMBStateFree(void *s)
+{
SCEnter();
SMBState *sstate = (SMBState *) s;
return 0;
}
-void RegisterSMBParsers(void) {
+void RegisterSMBParsers(void)
+{
char *proto_name = "smb";
if (AppLayerProtoDetectConfProtoDetectionEnabled("tcp", proto_name)) {
/**
* \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
/**
* \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[] = {
return result;
}
-int SMBParserTest03(void) {
+int SMBParserTest03(void)
+{
int result = 0;
Flow f;
uint8_t smbbuf1[] = {
return result;
}
-int SMBParserTest04(void) {
+int SMBParserTest04(void)
+{
int result = 0;
Flow f;
uint8_t smbbuf1[] = {
return result;
}
-int SMBParserTest07(void) {
+int SMBParserTest07(void)
+{
int result = 0;
Flow f;
uint8_t smbbuf1[] = {
return result;
}
-int SMBParserTest08(void) {
+int SMBParserTest08(void)
+{
int result = 0;
Flow f;
uint8_t smbbuf1[] = {
return result;
}
-int SMBParserTest09(void) {
+int SMBParserTest09(void)
+{
int result = 0;
Flow f;
uint8_t smbbuf1[] = {
#endif
-void SMBParserRegisterTests(void) {
+void SMBParserRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("SMBParserTest01", SMBParserTest01, 1);
UtRegisterTest("SMBParserTest02", SMBParserTest02, 1);
}
-static void *SMB2StateAlloc(void) {
+static void *SMB2StateAlloc(void)
+{
void *s = SCMalloc(sizeof(SMB2State));
if (unlikely(s == NULL))
return NULL;
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";
/* UNITTESTS */
#ifdef UNITTESTS
-int SMB2ParserTest01(void) {
+int SMB2ParserTest01(void)
+{
int result = 1;
Flow f;
uint8_t smb2buf[] =
return result;
}
-void SMB2ParserRegisterTests(void) {
+void SMB2ParserRegisterTests(void)
+{
UtRegisterTest("SMB2ParserTest01", SMB2ParserTest01, 1);
}
#endif
#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";
/** \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";
/** \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";
}
/** \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";
/** \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";
/** \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";
return result;
}
-static int SSHParserTest07(void) {
+static int SSHParserTest07(void)
+{
int result = 0;
Flow f;
uint8_t sshbuf1[] = "SSH-2.";
}
/** \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-";
return result;
}
-static int SSHParserTest09(void) {
+static int SSHParserTest09(void)
+{
int result = 0;
Flow f;
uint8_t sshbuf1[] = "SSH-2.";
}
/** \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-";
}
/** \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";
}
/** \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";
}
/** \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";
}
/** \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";
}
/** \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";
}
/** \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-";
}
/** \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-";
}
/** \test 2 directional test */
-static int SSHParserTest18(void) {
+static int SSHParserTest18(void)
+{
int result = 0;
Flow f;
}
/** \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-";
/** \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-";
/** \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-";
/** \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-";
#endif /* UNITTESTS */
-void SSHParserRegisterTests(void) {
+void SSHParserRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("SSHParserTest01 - ToServer", SSHParserTest01, 1);
UtRegisterTest("SSHParserTest02 - ToServer", SSHParserTest02, 1);
/* 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
* \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();
* \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,
* \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,
* \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);
* \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,
* \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,
* \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,
* \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,
* \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,
return ret;
}
-static int ICMPV4CalculateValidChecksumtest05(void) {
+static int ICMPV4CalculateValidChecksumtest05(void)
+{
uint16_t csum = 0;
uint8_t raw_icmpv4[] = {
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[] = {
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,
* \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
};
/**
* \brief Registers ICMPV4 unit test
*/
-void DecodeICMPV4RegisterTests(void) {
+void DecodeICMPV4RegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("DecodeICMPV4test01", DecodeICMPV4test01, 1);
UtRegisterTest("DecodeICMPV4test02", DecodeICMPV4test02, 1);
#ifdef UNITTESTS
-static int ICMPV6CalculateValidChecksumtest01(void) {
+static int ICMPV6CalculateValidChecksumtest01(void)
+{
uint16_t csum = 0;
uint8_t raw_ipv6[] = {
(uint16_t *)(raw_ipv6 + 54), 68));
}
-static int ICMPV6CalculateInvalidChecksumtest02(void) {
+static int ICMPV6CalculateInvalidChecksumtest02(void)
+{
uint16_t csum = 0;
uint8_t raw_ipv6[] = {
*
* 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:
*
* See: RFC 791
*/
-static int IPV4OptValidateRoute(Packet *p, const IPV4Opt *o) {
+static int IPV4OptValidateRoute(Packet *p, const IPV4Opt *o)
+{
uint8_t ptr;
/* Check length */
*
* 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;
* 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;
/* UNITTESTS */
#ifdef UNITTESTS
-void DecodeIPV4OptionsPrint(Packet *p) {
+void DecodeIPV4OptionsPrint(Packet *p)
+{
IPV4Vars *pv = &p->ip4vars;
printf("DecodeIPV4Options: cnt=%" PRIu8
}
/** \test IPV4 with no options. */
-int DecodeIPV4OptionsNONETest01(void) {
+int DecodeIPV4OptionsNONETest01(void)
+{
uint8_t raw_opts[] = { };
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
}
/** \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
};
}
/** \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
};
}
/** \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,
}
/** \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,
}
/** \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,
}
/** \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,
}
/** \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
};
}
/** \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
};
}
/** \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,
}
/** \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,
}
/** \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,
}
/** \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,
}
/** \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
}
/** \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
}
/** \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,
}
/** \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,
}
/** \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,
}
/** \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,
}
/** \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,
}
/** \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
};
}
/** \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
};
}
/** \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,
}
/** \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,
}
/** \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,
}
/** \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,
}
/** \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
};
}
/** \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
};
#endif /* UNITTESTS */
-void DecodeIPV4RegisterTests(void) {
+void DecodeIPV4RegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("DecodeIPV4OptionsNONETest01", DecodeIPV4OptionsNONETest01, 1);
UtRegisterTest("DecodeIPV4OptionsEOLTest01", DecodeIPV4OptionsEOLTest01, 1);
/**
* \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,
/**
* \test routing header decode
*/
-static int DecodeIPV6RouteTest01 (void) {
+static int DecodeIPV6RouteTest01 (void)
+{
uint8_t raw_pkt1[] = {
0x60, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x2b, 0x40,
* \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);
* 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))
* 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,
* \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,
* 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,
}
#endif /* UNITTESTS */
-void DecodePPPRegisterTests(void) {
+void DecodePPPRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("DecodePPPtest01", DecodePPPtest01, 1);
UtRegisterTest("DecodePPPtest02", DecodePPPtest02, 1);
* \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();
* \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,
* \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[] = {
* \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[] = {
* \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[] = {
* 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;
* \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);
* \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[] = {
* \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[] = {
* \brief Valid Raw packet
* \retval 0 Expected test value
*/
-static int DecodeRawTest03 (void) {
+static int DecodeRawTest03 (void)
+{
/* IPV13 */
uint8_t raw_ip[] = {
* \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);
* \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))
* \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,
* \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,
}
#endif /* UNITTESTS */
-void DecodeVLANRegisterTests(void) {
+void DecodeVLANRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("DecodeVLANtest01", DecodeVLANtest01, 1);
UtRegisterTest("DecodeVLANtest02", DecodeVLANtest02, 1);
/** 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;
}
return NULL;
}
-void DefragTrackerFree(DefragTracker *dt) {
+void DefragTrackerFree(DefragTracker *dt)
+{
if (dt != NULL) {
DefragTrackerClearMemory(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);
(void) DefragTrackerIncrUsecnt(dt);
}
-static DefragTracker *DefragTrackerNew(Packet *p) {
+static DefragTracker *DefragTrackerNew(Packet *p)
+{
DefragTracker *dt = DefragTrackerAlloc();
if (dt == NULL)
goto 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);
}
* id
* vlan_id
*/
-static inline uint32_t DefragHashGetKey(Packet *p) {
+static inline uint32_t DefragHashGetKey(Packet *p)
+{
uint32_t key;
if (p->ip4h != NULL) {
(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);
*
* \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 */
*
* \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;
#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);
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...");
*
* \param q the tracker queue to destroy
*/
-void DefragTrackerQueueDestroy (DefragTrackerQueue *q) {
+void DefragTrackerQueueDestroy (DefragTrackerQueue *q)
+{
DQLOCK_DESTROY(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
*
* \retval dt tracker or NULL if empty list.
*/
-DefragTracker *DefragTrackerDequeue (DefragTrackerQueue *q) {
+DefragTracker *DefragTrackerDequeue (DefragTrackerQueue *q)
+{
DQLOCK_LOCK(q);
DefragTracker *dt = q->bot;
return dt;
}
-uint32_t DefragTrackerQueueLen(DefragTrackerQueue *q) {
+uint32_t DefragTrackerQueueLen(DefragTrackerQueue *q)
+{
uint32_t len;
DQLOCK_LOCK(q);
len = q->len;
#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);
}
* \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) {
*
* \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;
DefragInitConfig(FALSE);
}
-void DefragDestroy(void) {
+void DefragDestroy(void)
+{
DefragHashShutdown();
DefragContextDestroy(defrag_context);
defrag_context = NULL;
* fragments.
*/
static int
-DefragVlanTest(void) {
+DefragVlanTest(void)
+{
Packet *p1 = NULL, *p2 = NULL, *r = NULL;
int ret = 0;
* 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;
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";
/**
* \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;
* 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 */
* \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;
* \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;
*
* \param ad pointer to DetectAsn1Data
*/
-void DetectAsn1Free(void *ptr) {
+void DetectAsn1Free(void *ptr)
+{
DetectAsn1Data *ad = (DetectAsn1Data *)ptr;
SCFree(ad);
}
/**
* \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;
/**
* \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";
/**
* \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;
/**
* \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;
/**
* \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;
/**
* \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;
/**
* \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;
/**
* \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;
/**
* \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";
/**
* \test DetectAsn1TestParse10 test that we break with a empty string
*/
-int DetectAsn1TestParse10(void) {
+int DetectAsn1TestParse10(void)
+{
int result = 1;
DetectAsn1Data *fd = NULL;
char str[] = "";
/**
* \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;
/**
* \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;
/**
* \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;
/**
* \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";
/**
* \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";
/**
* \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";
/**
* \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";
/**
* \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";
/**
* \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";
/**
* \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";
/**
* \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";
/**
* \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"
/**
* \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"
/**
* \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) */
* 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"
/**
* \brief this function registers unit tests for DetectAsn1
*/
-void DetectAsn1RegisterTests(void) {
+void DetectAsn1RegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("DetectAsn1TestParse01", DetectAsn1TestParse01, 1);
UtRegisterTest("DetectAsn1TestParse02", DetectAsn1TestParse02, 1);
void DetectBytejumpRegisterTests(void);
-void DetectBytejumpRegister (void) {
+void DetectBytejumpRegister (void)
+{
const char *eb;
int eo;
int opts = 0;
* \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);
/**
* \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);
/**
* \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, "
*
* \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, "
/**
* \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, "
/**
* \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);
/**
* \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);
/**
* \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);
/**
* \test Test dce option.
*/
-int DetectBytejumpTestParse09(void) {
+int DetectBytejumpTestParse09(void)
+{
Signature *s = SigAlloc();
if (s == NULL)
return 0;
* 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"
* 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,
/**
* \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);
/**
* \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);
/**
* \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);
/**
* \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);
/**
* \brief this function registers unit tests for DetectBytejump
*/
-void DetectBytejumpRegisterTests(void) {
+void DetectBytejumpRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("DetectBytejumpTestParse01", DetectBytejumpTestParse01, 1);
UtRegisterTest("DetectBytejumpTestParse02", DetectBytejumpTestParse02, 1);
void DetectBytetestRegisterTests(void);
-void DetectBytetestRegister (void) {
+void DetectBytetestRegister (void)
+{
const char *eb;
int eo;
int opts = 0;
* \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;
* \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);
/**
* \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);
/**
* \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);
/**
* \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);
/**
* \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);
/**
* \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);
/**
* \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);
/**
* \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);
/**
* \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);
/**
* \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);
/**
* \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);
/**
* \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);
/**
* \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);
/**
* \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);
/**
* \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);
/**
* \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);
/**
* \test Test dce option.
*/
-int DetectBytetestTestParse17(void) {
+int DetectBytetestTestParse17(void)
+{
int result = 0;
DetectBytetestData *data = NULL;
data = DetectBytetestParse("4, <, 5, 0, dce", NULL, NULL);
/**
* \test Test dce option.
*/
-int DetectBytetestTestParse18(void) {
+int DetectBytetestTestParse18(void)
+{
int result = 0;
DetectBytetestData *data = NULL;
data = DetectBytetestParse("4, <, 5, 0", NULL, NULL);
/**
* \test Test dce option.
*/
-int DetectBytetestTestParse19(void) {
+int DetectBytetestTestParse19(void)
+{
Signature *s = SigAlloc();
if (s == NULL)
return 0;
* 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"
* 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"
/**
* \brief this function registers unit tests for DetectBytetest
*/
-void DetectBytetestRegisterTests(void) {
+void DetectBytetestRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("DetectBytetestTestParse01", DetectBytetestTestParse01, 1);
UtRegisterTest("DetectBytetestTestParse02", DetectBytetestTestParse02, 1);
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";
}
/* 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);
}
*
* \param cd pointer to DetectCotentData
*/
-void DetectContentFree(void *ptr) {
+void DetectContentFree(void *ptr)
+{
SCEnter();
DetectContentData *cd = (DetectContentData *)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\"";
/**
* \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\"";
/**
* \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\"";
/**
* \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\"";
/**
* \test DetectCotentParseTest05 test illegal escape
*/
-int DetectContentParseTest05 (void) {
+int DetectContentParseTest05 (void)
+{
int result = 1;
DetectContentData *cd = NULL;
char *teststring = "\"abc\\def\"";
/**
* \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|\"";
/**
* \test DetectCotentParseTest07 test an empty content
*/
-int DetectContentParseTest07 (void) {
+int DetectContentParseTest07 (void)
+{
int result = 1;
DetectContentData *cd = NULL;
char *teststring = "\"\"";
/**
* \test DetectCotentParseTest08 test an empty content
*/
-int DetectContentParseTest08 (void) {
+int DetectContentParseTest08 (void)
+{
int result = 1;
DetectContentData *cd = NULL;
char *teststring = "\"\"";
/**
* \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!"
return DetectContentLongPatternMatchTestWrp(sig, 1);
}
-int DetectContentParseTest09(void) {
+int DetectContentParseTest09(void)
+{
int result = 0;
DetectContentData *cd = NULL;
char *teststring = "!\"boo\"";
return result;
}
-int DetectContentParseTest10(void) {
+int DetectContentParseTest10(void)
+{
int result = 0;
DetectContentData *cd = NULL;
char *teststring = "!\"boo\"";
return result;
}
-int DetectContentParseNegTest11(void) {
+int DetectContentParseNegTest11(void)
+{
int result = 0;
DetectContentData *cd = NULL;
char *teststring = "\"boo\"";
return result;
}
-int DetectContentParseNegTest12(void) {
+int DetectContentParseNegTest12(void)
+{
int result = 0;
DetectContentData *cd = NULL;
char *teststring = "\"boo\"";
return result;
}
-int DetectContentParseNegTest13(void) {
+int DetectContentParseNegTest13(void)
+{
int result = 0;
DetectContentData *cd = NULL;
char *teststring = "!\"boo\"";
return result;
}
-int DetectContentParseNegTest14(void) {
+int DetectContentParseNegTest14(void)
+{
int result = 0;
DetectContentData *cd = NULL;
char *teststring = " \"!boo\"";
return result;
}
-int DetectContentParseNegTest15(void) {
+int DetectContentParseNegTest15(void)
+{
int result = 0;
DetectContentData *cd = NULL;
char *teststring = " !\"boo\"";
return result;
}
-int DetectContentParseNegTest16(void) {
+int DetectContentParseNegTest16(void)
+{
int result = 0;
DetectContentData *cd = NULL;
char *teststring = " \"boo\"";
return result;
}
-int DetectCsumICMPV4InValidArgsTestParse02(void) {
+int DetectCsumICMPV4InValidArgsTestParse02(void)
+{
Signature s;
int result = -1;
SigMatch *temp = NULL;
return result;
}
-int DetectCsumICMPV4ValidArgsTestParse03(void) {
+int DetectCsumICMPV4ValidArgsTestParse03(void)
+{
Signature s;
DetectCsumData *cd = NULL;
int result = 0;
return result;
}
-int DetectCsumTCPV4InValidArgsTestParse02(void) {
+int DetectCsumTCPV4InValidArgsTestParse02(void)
+{
Signature s;
int result = -1;
SigMatch *temp = NULL;
return result;
}
-int DetectCsumTCPV4ValidArgsTestParse03(void) {
+int DetectCsumTCPV4ValidArgsTestParse03(void)
+{
Signature s;
DetectCsumData *cd = NULL;
int result = 0;
return result;
}
-int DetectCsumUDPV4InValidArgsTestParse02(void) {
+int DetectCsumUDPV4InValidArgsTestParse02(void)
+{
Signature s;
int result = -1;
SigMatch *temp = NULL;
return result;
}
-int DetectCsumUDPV4ValidArgsTestParse03(void) {
+int DetectCsumUDPV4ValidArgsTestParse03(void)
+{
Signature s;
DetectCsumData *cd = NULL;
int result = 0;
return result;
}
-int DetectCsumTCPV6InValidArgsTestParse02(void) {
+int DetectCsumTCPV6InValidArgsTestParse02(void)
+{
Signature s;
int result = -1;
SigMatch *temp = NULL;
return result;
}
-int DetectCsumTCPV6ValidArgsTestParse03(void) {
+int DetectCsumTCPV6ValidArgsTestParse03(void)
+{
Signature s;
DetectCsumData *cd = NULL;
int result = 0;
return result;
}
-int DetectCsumUDPV6InValidArgsTestParse02(void) {
+int DetectCsumUDPV6InValidArgsTestParse02(void)
+{
Signature s;
int result = -1;
SigMatch *temp = NULL;
return result;
}
-int DetectCsumUDPV6ValidArgsTestParse03(void) {
+int DetectCsumUDPV6ValidArgsTestParse03(void)
+{
Signature s;
DetectCsumData *cd = NULL;
int result = 0;
return result;
}
-int DetectCsumICMPV6InValidArgsTestParse02(void) {
+int DetectCsumICMPV6InValidArgsTestParse02(void)
+{
Signature s;
int result = -1;
SigMatch *temp = NULL;
return result;
}
-int DetectCsumICMPV6ValidArgsTestParse03(void) {
+int DetectCsumICMPV6ValidArgsTestParse03(void)
+{
Signature s;
DetectCsumData *cd = NULL;
int result = 0;
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";
/**
* \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";
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;
}
* \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;
* \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;
*
* \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);
}
* \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)) {
* \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)) {
* \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)) {
* \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)) {
* \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)) {
* \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)) {
* \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;
* \retval 0 on failure
*/
-static int DetectDetectionFilterTestSig2(void) {
+static int DetectDetectionFilterTestSig2(void)
+{
Packet *p = NULL;
Signature *s = NULL;
ThreadVars th_v;
/**
* \test drops
*/
-static int DetectDetectionFilterTestSig3(void) {
+static int DetectDetectionFilterTestSig3(void)
+{
Packet *p = NULL;
Signature *s = NULL;
ThreadVars th_v;
}
#endif /* UNITTESTS */
-void DetectDetectionFilterRegisterTests(void) {
+void DetectDetectionFilterRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("DetectDetectionFilterTestParse01", DetectDetectionFilterTestParse01, 1);
UtRegisterTest("DetectDetectionFilterTestParse02", DetectDetectionFilterTestParse02, 0);
* 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);
}
#endif /* UNITTESTS */
-void DetectDistanceRegisterTests(void) {
+void DetectDistanceRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("DetectDistanceTest01 -- distance / within mix", DetectDistanceTest01, 1);
UtRegisterTest("DetectDistanceTestPacket01", DetectDistanceTestPacket01, 1);
/**
* \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;
#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,
}
/** \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,
}
/** \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,
}
/** \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,
}
/** \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,
}
/** \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,
/** \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,
#endif
-static void DetectDnsQueryRegisterTests(void) {
+static void DetectDnsQueryRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("DetectDnsQueryTest01", DetectDnsQueryTest01, 1);
UtRegisterTest("DetectDnsQueryTest02", DetectDnsQueryTest02, 1);
/**
* \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";
*
* \param de pointer to DetectDsizeData
*/
-void DetectDsizeFree(void *de_ptr) {
+void DetectDsizeFree(void *de_ptr)
+{
DetectDsizeData *dd = (DetectDsizeData *)de_ptr;
if(dd) SCFree(dd);
}
* \retval 1 on succces
* \retval 0 on failure
*/
-int DsizeTestParse01 (void) {
+int DsizeTestParse01 (void)
+{
DetectDsizeData *dd = NULL;
dd = DetectDsizeParse("1");
if (dd) {
* \retval 1 on succces
* \retval 0 on failure
*/
-int DsizeTestParse02 (void) {
+int DsizeTestParse02 (void)
+{
DetectDsizeData *dd = NULL;
dd = DetectDsizeParse(">10");
if (dd) {
* \retval 1 on succces
* \retval 0 on failure
*/
-int DsizeTestParse03 (void) {
+int DsizeTestParse03 (void)
+{
DetectDsizeData *dd = NULL;
dd = DetectDsizeParse("<100");
if (dd) {
* \retval 1 on succces
* \retval 0 on failure
*/
-int DsizeTestParse04 (void) {
+int DsizeTestParse04 (void)
+{
DetectDsizeData *dd = NULL;
dd = DetectDsizeParse("1<>2");
if (dd) {
* \retval 1 on succces
* \retval 0 on failure
*/
-int DsizeTestParse05 (void) {
+int DsizeTestParse05 (void)
+{
int result = 0;
DetectDsizeData *dd = NULL;
dd = DetectDsizeParse("1");
* \retval 1 on succces
* \retval 0 on failure
*/
-int DsizeTestParse06 (void) {
+int DsizeTestParse06 (void)
+{
int result = 0;
DetectDsizeData *dd = NULL;
dd = DetectDsizeParse(">10");
* \retval 1 on succces
* \retval 0 on failure
*/
-int DsizeTestParse07 (void) {
+int DsizeTestParse07 (void)
+{
int result = 0;
DetectDsizeData *dd = NULL;
dd = DetectDsizeParse("<100");
* \retval 1 on succces
* \retval 0 on failure
*/
-int DsizeTestParse08 (void) {
+int DsizeTestParse08 (void)
+{
int result = 0;
DetectDsizeData *dd = NULL;
dd = DetectDsizeParse("1<>2");
* \retval 1 on succces
* \retval 0 on failure
*/
-int DsizeTestParse09 (void) {
+int DsizeTestParse09 (void)
+{
DetectDsizeData *dd = NULL;
dd = DetectDsizeParse("A");
if (dd) {
* \retval 1 on succces
* \retval 0 on failure
*/
-int DsizeTestParse10 (void) {
+int DsizeTestParse10 (void)
+{
DetectDsizeData *dd = NULL;
dd = DetectDsizeParse(">10<>10");
if (dd) {
* \retval 1 on succces
* \retval 0 on failure
*/
-int DsizeTestParse11 (void) {
+int DsizeTestParse11 (void)
+{
DetectDsizeData *dd = NULL;
dd = DetectDsizeParse("<>10");
if (dd) {
* \retval 1 on succces
* \retval 0 on failure
*/
-int DsizeTestParse12 (void) {
+int DsizeTestParse12 (void)
+{
DetectDsizeData *dd = NULL;
dd = DetectDsizeParse("1<>");
if (dd) {
* \retval 1 on succces
* \retval 0 on failure
*/
-int DsizeTestParse13 (void) {
+int DsizeTestParse13 (void)
+{
int result = 0;
DetectDsizeData *dd = NULL;
dd = DetectDsizeParse("1");
* \retval 1 on succces
* \retval 0 on failure
*/
-int DsizeTestParse14 (void) {
+int DsizeTestParse14 (void)
+{
DetectDsizeData *dd = NULL;
dd = DetectDsizeParse("");
if (dd) {
* \retval 1 on succces
* \retval 0 on failure
*/
-int DsizeTestParse15 (void) {
+int DsizeTestParse15 (void)
+{
DetectDsizeData *dd = NULL;
dd = DetectDsizeParse(" ");
if (dd) {
* \retval 1 on succces
* \retval 0 on failure
*/
-int DsizeTestParse16 (void) {
+int DsizeTestParse16 (void)
+{
DetectDsizeData *dd = NULL;
dd = DetectDsizeParse("2<>1");
if (dd) {
* \retval 1 on succces
* \retval 0 on failure
*/
-int DsizeTestParse17 (void) {
+int DsizeTestParse17 (void)
+{
int result = 0;
DetectDsizeData *dd = NULL;
dd = DetectDsizeParse(" 1 <> 2 ");
* \retval 1 on succces
* \retval 0 on failure
*/
-int DsizeTestParse18 (void) {
+int DsizeTestParse18 (void)
+{
int result = 0;
DetectDsizeData *dd = NULL;
dd = DetectDsizeParse("> 2 ");
* \retval 1 on succces
* \retval 0 on failure
*/
-int DsizeTestParse19 (void) {
+int DsizeTestParse19 (void)
+{
int result = 0;
DetectDsizeData *dd = NULL;
dd = DetectDsizeParse("< 12 ");
* \retval 1 on succces
* \retval 0 on failure
*/
-int DsizeTestParse20 (void) {
+int DsizeTestParse20 (void)
+{
int result = 0;
DetectDsizeData *dd = NULL;
dd = DetectDsizeParse(" 12 ");
* 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[] = {
/**
* \brief this function registers unit tests for dsize
*/
-void DsizeRegisterTests(void) {
+void DsizeRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("DsizeTestParse01", DsizeTestParse01, 1);
UtRegisterTest("DsizeTestParse02", DsizeTestParse02, 1);
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++) {
*
* \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) {
*
* \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) {
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;
return result;
}
-int AddressTestAddressGroupSetup36 (void) {
+int AddressTestAddressGroupSetup36 (void)
+{
int result = 0;
DetectAddressHead *gh = DetectAddressHeadInit();
/**
* \test Test sig distribution over address groups
*/
-static int AddressTestFunctions01(void) {
+static int AddressTestFunctions01(void)
+{
DetectAddress *a1 = NULL;
DetectAddress *a2 = NULL;
DetectAddressHead *h = NULL;
/**
* \test Test sig distribution over address groups
*/
-static int AddressTestFunctions02(void) {
+static int AddressTestFunctions02(void)
+{
DetectAddress *a1 = NULL;
DetectAddress *a2 = NULL;
DetectAddressHead *h = NULL;
/**
* \test Test sig distribution over address groups
*/
-static int AddressTestFunctions03(void) {
+static int AddressTestFunctions03(void)
+{
DetectAddress *a1 = NULL;
DetectAddress *a2 = NULL;
DetectAddressHead *h = NULL;
/**
* \test Test sig distribution over address groups
*/
-static int AddressTestFunctions04(void) {
+static int AddressTestFunctions04(void)
+{
DetectAddress *a1 = NULL;
DetectAddress *a2 = NULL;
DetectAddressHead *h = NULL;
/** 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;
g_tag_pa.s = &g_tag_signature;
}
-PacketAlert *PacketAlertGetTag(void) {
+PacketAlert *PacketAlertGetTag(void)
+{
return &g_tag_pa;
}
* \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;
}
-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);
/**
* \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;
*
* \param de pointer to DetectEngineEventData
*/
-static void DetectEngineEventFree(void *ptr) {
+static void DetectEngineEventFree(void *ptr)
+{
DetectEngineEventData *de = (DetectEngineEventData *)ptr;
if (de)
SCFree(de);
/**
* \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) {
/**
* \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) {
/**
* \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) {
/**
* \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) {
/**
* \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) {
/**
* \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;
/**
* \brief this function registers unit tests for EngineEvent
*/
-void EngineEventRegisterTests(void) {
+void EngineEventRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("EngineEventTestParse01", EngineEventTestParse01, 1);
UtRegisterTest("EngineEventTestParse02", EngineEventTestParse02, 1);
#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,
*
* \retval IPOnlyCIDRItem address of the new instance
*/
-static IPOnlyCIDRItem *IPOnlyCIDRItemNew() {
+static IPOnlyCIDRItem *IPOnlyCIDRItemNew()
+{
SCEnter();
IPOnlyCIDRItem *item = NULL;
}
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])
* \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 */
* \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;
* \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;
* \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) {
* 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;
*
* \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)) {
* \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)
* \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) {
* \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);
* \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? */
}
* \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;
* \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);
}
*
* \param de_ctx Pointer to the current detection engine
*/
-void IPOnlyPrepare(DetectEngineCtx *de_ctx) {
+void IPOnlyPrepare(DetectEngineCtx *de_ctx)
+{
SCLogDebug("Preparing Final Lists");
/*
* \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;
* option appending a SigMatch and no port is fixed
*/
-static int IPOnlyTestSig01(void) {
+static int IPOnlyTestSig01(void)
+{
int result = 0;
DetectEngineCtx de_ctx;
* 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));
* 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;
/**
* \test
*/
-static int IPOnlyTestSig04 (void) {
+static int IPOnlyTestSig04 (void)
+{
int result = 1;
IPOnlyCIDRItem *head = NULL;
* \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);
* \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);
* \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);
* \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);
* \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);
* \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);
* \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);
* \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);
#endif /* UNITTESTS */
-void IPOnlyRegisterTests(void) {
+void IPOnlyRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("IPOnlyTestSig01", IPOnlyTestSig01, 1);
UtRegisterTest("IPOnlyTestSig02", IPOnlyTestSig02, 1);
* \retval 1 true
* \retval 0 false
*/
-int SignatureHasPacketContent(Signature *s) {
+int SignatureHasPacketContent(Signature *s)
+{
SCEnter();
if (s == NULL) {
* \retval 1 true
* \retval 0 false
*/
-int SignatureHasStreamContent(Signature *s) {
+int SignatureHasStreamContent(Signature *s)
+{
SCEnter();
if (s == NULL) {
*
* \retval mpm algo value
*/
-uint16_t PatternMatchDefaultMatcher(void) {
+uint16_t PatternMatchDefaultMatcher(void)
+{
char *mpm_algo;
uint16_t mpm_algo_val = DEFAULT_MPM;
}
/** \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)
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) {
}
}
-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)",
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;
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;
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;
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;
return 0;
}
-ContentHash *ContentHashAlloc(DetectContentData *ptr) {
+ContentHash *ContentHashAlloc(DetectContentData *ptr)
+{
ContentHash *ch = SCMalloc(sizeof(ContentHash));
if (unlikely(ch == NULL))
return NULL;
return ch;
}
-UricontentHash *UricontentHashAlloc(DetectContentData *ptr) {
+UricontentHash *UricontentHashAlloc(DetectContentData *ptr)
+{
UricontentHash *ch = SCMalloc(sizeof(UricontentHash));
if (unlikely(ch == NULL))
return NULL;
return ch;
}
-void ContentHashFree(void *ch) {
+void ContentHashFree(void *ch)
+{
SCFree(ch);
}
-void UricontentHashFree(void *ch) {
+void UricontentHashFree(void *ch)
+{
SCFree(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));
has_co_huad ||
has_co_hhhd ||
has_co_hrhhd ||
- has_co_dnsquery) {
+ has_co_dnsquery)
+{
PatternMatchPreparePopulateMpm(de_ctx, sh);
* \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));
/** \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));
}
/** \brief free a MpmPatternIdTableElmt */
-static void MpmPatternIdTableElmtFree(void *e) {
+static void MpmPatternIdTableElmtFree(void *e)
+{
SCEnter();
MpmPatternIdTableElmt *c = (MpmPatternIdTableElmt *)e;
SCFree(c->pattern);
}
/** \brief alloc initialize the MpmPatternIdHash */
-MpmPatternIdStore *MpmPatternIdTableInitHash(void) {
+MpmPatternIdStore *MpmPatternIdTableInitHash(void)
+{
SCEnter();
MpmPatternIdStore *ht = SCMalloc(sizeof(MpmPatternIdStore));
SCReturnPtr(ht, "MpmPatternIdStore");
}
-void MpmPatternIdTableFreeHash(MpmPatternIdStore *ht) {
+void MpmPatternIdTableFreeHash(MpmPatternIdStore *ht)
+{
SCEnter();
if (ht == NULL) {
SCReturn;
}
-uint32_t MpmPatternIdStoreGetMaxId(MpmPatternIdStore *ht) {
+uint32_t MpmPatternIdStoreGetMaxId(MpmPatternIdStore *ht)
+{
if (ht == NULL) {
return 0;
}
* \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);
/** \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);
}
/** \test Nocase matching */
-static int PayloadTestSig02 (void) {
+static int PayloadTestSig02 (void)
+{
uint8_t *buf = (uint8_t *)
"abcaBcd";
uint16_t buflen = strlen((char *)buf);
}
/** \test Negative distance matching */
-static int PayloadTestSig03 (void) {
+static int PayloadTestSig03 (void)
+{
uint8_t *buf = (uint8_t *)
"abcaBcd";
uint16_t buflen = strlen((char *)buf);
#endif /* UNITTESTS */
-void PayloadRegisterTests(void) {
+void PayloadRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("PayloadTestSig01", PayloadTestSig01, 1);
UtRegisterTest("PayloadTestSig02", PayloadTestSig02, 1);
* \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;
*
* \param dp Pointer to the DetectPort that has to be freed.
*/
-void DetectPortFree(DetectPort *dp) {
+void DetectPortFree(DetectPort *dp)
+{
if (dp == NULL)
return;
/**
* \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);
*
* \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) {
*
* \param head Pointer to the DetectPort list head
*/
-void DetectPortPrintList(DetectPort *head) {
+void DetectPortPrintList(DetectPort *head)
+{
DetectPort *cur;
uint16_t cnt = 0;
*
* \param head Pointer to the DetectPort list head
*/
-void DetectPortCleanupList (DetectPort *head) {
+void DetectPortCleanupList (DetectPort *head)
+{
if (head == NULL)
return;
* \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("");
* \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;
* \retval -1 error
* */
int DetectPortInsert(DetectEngineCtx *de_ctx, DetectPort **head,
- DetectPort *new) {
+ DetectPort *new)
+{
if (new == NULL)
return 0;
* \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;
* \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;
* \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;
* \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;
* \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;
* \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;
* \brief Helper function that print the DetectPort info
* \retval none
*/
-void DetectPortPrint(DetectPort *dp) {
+void DetectPortPrint(DetectPort *dp)
+{
if (dp == NULL)
return;
* \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)
* \retval 0 on success
* */
int DetectPortJoin(DetectEngineCtx *de_ctx, DetectPort *target,
- DetectPort *source) {
+ DetectPort *source)
+{
if (target == NULL || source == NULL)
return -1;
* \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);
}
* \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;
* \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;
* \retval 0 no
* \retval 1 yes
*/
-int DetectPortIsCompletePortSpace(DetectPort *p) {
+int DetectPortIsCompletePortSpace(DetectPort *p)
+{
uint16_t next_port = 0;
if (p == NULL)
* \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;
* \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);
* \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;
* \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
*
* \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;
* \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;
return 0;
}
-void DetectPortFreeFunc(void *p) {
+void DetectPortFreeFunc(void *p)
+{
DetectPort *dp = (DetectPort *)p;
DetectPortFree(dp);
}
* \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)
*
* \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;
*
* \param de_ctx Pointer to the current DetectionEngineCtx
*/
-void DetectPortDpHashReset(DetectEngineCtx *de_ctx) {
+void DetectPortDpHashReset(DetectEngineCtx *de_ctx)
+{
DetectPortDpHashFree(de_ctx);
DetectPortDpHashInit(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);
}
* \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;
* \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)
*
* \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;
*
* \param de_ctx Pointer to the current DetectionEngineCtx
*/
-void DetectPortSpHashReset(DetectEngineCtx *de_ctx) {
+void DetectPortSpHashReset(DetectEngineCtx *de_ctx)
+{
DetectPortSpHashFree(de_ctx);
DetectPortSpHashInit(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);
}
* \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;
/**
* \test Check if a DetectPort is properly allocated
*/
-int PortTestParse01 (void) {
+int PortTestParse01 (void)
+{
DetectPort *dd = NULL;
int r = DetectPortParse(&dd,"80");
/**
* \test Check if two ports are properly allocated in the DetectPort group
*/
-int PortTestParse02 (void) {
+int PortTestParse02 (void)
+{
DetectPort *dd = NULL;
int result = 0;
/**
* \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;
/**
* \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");
* \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;
/**
* \test Check if we copy a DetectPort correctly
*/
-int PortTestParse06 (void) {
+int PortTestParse06 (void)
+{
DetectPort *dd = NULL, *copy = NULL;
int result = 0;
* \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;
/**
* \test Check if we dont allow invalid port range specification
*/
-int PortTestParse08 (void) {
+int PortTestParse08 (void)
+{
DetectPort *dd = NULL;
int result = 0;
/**
* \test Check if we autocomplete correctly an open range
*/
-int PortTestParse09 (void) {
+int PortTestParse09 (void)
+{
DetectPort *dd = NULL;
int result = 0;
/**
* \test Test we don't allow a port that is too big
*/
-int PortTestParse10 (void) {
+int PortTestParse10 (void)
+{
DetectPort *dd = NULL;
int result = 0;
/**
* \test Test second port of range being too big
*/
-int PortTestParse11 (void) {
+int PortTestParse11 (void)
+{
DetectPort *dd = NULL;
int result = 0;
/**
* \test Test second port of range being just right
*/
-int PortTestParse12 (void) {
+int PortTestParse12 (void)
+{
DetectPort *dd = NULL;
int result = 0;
/**
* \test Test first port of range being too big
*/
-int PortTestParse13 (void) {
+int PortTestParse13 (void)
+{
DetectPort *dd = NULL;
int result = 0;
/**
* \test Test merging port groups
*/
-int PortTestParse14 (void) {
+int PortTestParse14 (void)
+{
DetectPort *dd = NULL;
int result = 0;
/**
* \test Test merging negated port groups
*/
-int PortTestParse15 (void) {
+int PortTestParse15 (void)
+{
DetectPort *dd = NULL;
int result = 0;
/**
* \test Test parse, copy and cmp functions
*/
-int PortTestParse16 (void) {
+int PortTestParse16 (void)
+{
DetectPort *dd = NULL, *copy = NULL;
int result = 0;
/**
* \test Test general functions
*/
-int PortTestFunctions01(void) {
+int PortTestFunctions01(void)
+{
DetectPort *head = NULL;
DetectPort *dp1= NULL;
int result = 0;
/**
* \test Test general functions
*/
-int PortTestFunctions02(void) {
+int PortTestFunctions02(void)
+{
DetectPort *head = NULL;
DetectPort *dp1= NULL;
DetectPort *dp2= NULL;
/**
* \test Test general functions
*/
-int PortTestFunctions03(void) {
+int PortTestFunctions03(void)
+{
DetectPort *dp1= NULL;
DetectPort *dp2= NULL;
DetectPort *dp3= NULL;
/**
* \test Test general functions
*/
-int PortTestFunctions04(void) {
+int PortTestFunctions04(void)
+{
DetectPort *dp1= NULL;
DetectPort *dp2= NULL;
int result = 0;
/**
* \test Test general functions
*/
-static int PortTestFunctions05(void) {
+static int PortTestFunctions05(void)
+{
DetectPort *dp1 = NULL;
DetectPort *dp2 = NULL;
DetectPort *dp3 = NULL;
/**
* \test Test general functions
*/
-static int PortTestFunctions06(void) {
+static int PortTestFunctions06(void)
+{
DetectPort *dp1 = NULL;
DetectPort *dp2 = NULL;
DetectPort *dp3 = NULL;
/**
* \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
#endif /* UNITTESTS */
-void DetectPortTests(void) {
+void DetectPortTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("PortTestParse01", PortTestParse01, 1);
UtRegisterTest("PortTestParse02", PortTestParse02, 1);
* \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;
* 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;
* 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;
* \test signature parsing with tcp-pkt and tcp-stream
*/
-static int DetectProtoTestSig02(void) {
+static int DetectProtoTestSig02(void)
+{
Signature *s = NULL;
int result = 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;
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;
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) {
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);
}
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);
}
* \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;
* \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;
* \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;
* \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;
}
/** \test multiple pipelined http transactions */
-static int DeStateSigTest02(void) {
+static int DeStateSigTest02(void)
+{
int result = 0;
Signature *s = NULL;
DetectEngineThreadCtx *det_ctx = NULL;
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"
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"
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"
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"
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"
/**
* \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!";
/**
* \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!";
/**
* \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!";
/**
* \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!";
/**
* \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!";
/**
* \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!";
/**
* \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!";
/**
* \brief this function registers unit tests for DetectTag
*/
-void DetectEngineTagRegisterTests(void) {
+void DetectEngineTagRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("DetectTagTestPacket01", DetectTagTestPacket01, 1);
UtRegisterTest("DetectTagTestPacket02", DetectTagTestPacket02, 1);
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");
}
}
-int ThresholdHostHasThreshold(Host *host) {
+int ThresholdHostHasThreshold(Host *host)
+{
return HostGetStorageById(host, threshold_id) ? 1 : 0;
}
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));
* \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);
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)
*
* \param td pointer to DetectTagDataEntryList
*/
-void ThresholdListFree(void *ptr) {
+void ThresholdListFree(void *ptr)
+{
if (ptr != NULL) {
DetectThresholdEntry *entry = ptr;
return NULL;
}
-DetectEngineCtx *DetectEngineCtxInit(void) {
+DetectEngineCtx *DetectEngineCtxInit(void)
+{
DetectEngineCtx *de_ctx;
ConfNode *seq_node = NULL;
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;
*
* \param de_ctx DetectEngineCtx:: to be freed
*/
-void DetectEngineCtxFree(DetectEngineCtx *de_ctx) {
+void DetectEngineCtxFree(DetectEngineCtx *de_ctx)
+{
if (de_ctx == NULL)
return;
* \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;
* 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) {
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) {
/** \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
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) {
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);
* 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) {
*
* \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";
/**
* \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";
/**
* \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";
*
* \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)
/**
* \test DetectFileextTestParse01
*/
-int DetectFileextTestParse01 (void) {
+int DetectFileextTestParse01 (void)
+{
DetectFileextData *dfd = DetectFileextParse("\"doc\"");
if (dfd != NULL) {
DetectFileextFree(dfd);
/**
* \test DetectFileextTestParse02
*/
-int DetectFileextTestParse02 (void) {
+int DetectFileextTestParse02 (void)
+{
int result = 0;
DetectFileextData *dfd = DetectFileextParse("\"tar.gz\"");
/**
* \test DetectFileextTestParse03
*/
-int DetectFileextTestParse03 (void) {
+int DetectFileextTestParse03 (void)
+{
int result = 0;
DetectFileextData *dfd = DetectFileextParse("\"pdf\"");
/**
* \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);
/**
* \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";
* \retval -1 error
* \retval 0 ok
*/
-int FilemagicGlobalLookup(File *file) {
+int FilemagicGlobalLookup(File *file)
+{
if (file == NULL || file->chunks_head == NULL) {
SCReturnInt(-1);
}
* \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);
}
return NULL;
}
-static void *DetectFilemagicThreadInit(void *data) {
+static void *DetectFilemagicThreadInit(void *data)
+{
char *filename = NULL;
FILE *fd = NULL;
DetectFilemagicData *filemagic = (DetectFilemagicData *)data;
return NULL;
}
-static void DetectFilemagicThreadFree(void *ctx) {
+static void DetectFilemagicThreadFree(void *ctx)
+{
if (ctx != NULL) {
DetectFilemagicThreadData *t = (DetectFilemagicThreadData *)ctx;
if (t->ctx)
*
* \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) {
/**
* \test DetectFilemagicTestParse01
*/
-int DetectFilemagicTestParse01 (void) {
+int DetectFilemagicTestParse01 (void)
+{
DetectFilemagicData *dnd = DetectFilemagicParse("\"secret.pdf\"");
if (dnd != NULL) {
DetectFilemagicFree(dnd);
/**
* \test DetectFilemagicTestParse02
*/
-int DetectFilemagicTestParse02 (void) {
+int DetectFilemagicTestParse02 (void)
+{
int result = 0;
DetectFilemagicData *dnd = DetectFilemagicParse("\"backup.tar.gz\"");
/**
* \test DetectFilemagicTestParse03
*/
-int DetectFilemagicTestParse03 (void) {
+int DetectFilemagicTestParse03 (void)
+{
int result = 0;
DetectFilemagicData *dnd = DetectFilemagicParse("\"cmd.exe\"");
/**
* \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);
#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;
}
/**
* \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;
/**
* \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";
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);
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) {
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;
*
* \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)
}
#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));
return 0;
}
-static int MD5MatchTest01(void) {
+static int MD5MatchTest01(void)
+{
ROHashTable *hash = ROHashInit(4, 16);
if (hash == NULL) {
return 0;
}
#endif
-void DetectFileMd5RegisterTests(void) {
+void DetectFileMd5RegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("MD5MatchTest01", MD5MatchTest01, 1);
#endif
/**
* \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";
*
* \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) {
/**
* \test DetectFilenameTestParse01
*/
-int DetectFilenameTestParse01 (void) {
+int DetectFilenameTestParse01 (void)
+{
DetectFilenameData *dnd = DetectFilenameParse("\"secret.pdf\"");
if (dnd != NULL) {
DetectFilenameFree(dnd);
/**
* \test DetectFilenameTestParse02
*/
-int DetectFilenameTestParse02 (void) {
+int DetectFilenameTestParse02 (void)
+{
int result = 0;
DetectFilenameData *dnd = DetectFilenameParse("\"backup.tar.gz\"");
/**
* \test DetectFilenameTestParse03
*/
-int DetectFilenameTestParse03 (void) {
+int DetectFilenameTestParse03 (void)
+{
int result = 0;
DetectFilenameData *dnd = DetectFilenameParse("\"cmd.exe\"");
/**
* \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);
* context and setting up the signature itself.
*/
-static int DetectFilesizeSetpTest01(void) {
+static int DetectFilesizeSetpTest01(void)
+{
DetectFilesizeData *fsd = NULL;
uint8_t res = 0;
/**
* \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";
* 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();
return -1;
}
-static void DetectFilestoreFree(void *ptr) {
+static void DetectFilestoreFree(void *ptr)
+{
if (ptr != NULL) {
SCFree(ptr);
}
* \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;
*
* \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);
}
* \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) ) {
* \retval 1 on succces
* \retval 0 on failure
*/
-static int FlagsTestParse02 (void) {
+static int FlagsTestParse02 (void)
+{
DetectFlagsData *de = NULL;
de = DetectFlagsParse("G");
if (de) {
* \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;
* \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;
* \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;
* \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;
* \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;
* \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;
* \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;
* \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;
* \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;
* \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;
* \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) {
/**
* \brief this function registers unit tests for Flags
*/
-void FlagsRegisterTests(void) {
+void FlagsRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("FlagsTestParse01", FlagsTestParse01, 1);
UtRegisterTest("FlagsTestParse02", FlagsTestParse02, 0);
/**
* \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";
*
* \param fd pointer to DetectFlowData
*/
-void DetectFlowFree(void *ptr) {
+void DetectFlowFree(void *ptr)
+{
DetectFlowData *fd = (DetectFlowData *)ptr;
SCFree(fd);
}
* \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");
/**
* \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");
/**
* \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");
/**
* \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");
/**
* \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");
/**
* \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");
/**
* \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");
/**
* \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");
/**
* \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");
/**
* \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");
/**
* \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 ");
* \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");
/**
* \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");
/**
* \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");
/**
* \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");
/**
* \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");
/**
* \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");
/**
* \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");
/**
* \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");
/**
* \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");
/**
* \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");
/**
* \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 ");
/**
* \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");
/**
* \test DetectFlowTestParse13 is a test for an invalid option
*/
-int DetectFlowTestParse13 (void) {
+int DetectFlowTestParse13 (void)
+{
int result = 1;
DetectFlowData *fd = NULL;
fd = DetectFlowParse("invalidoptiontest");
/**
* \test DetectFlowTestParse14 is a test for a empty option
*/
-int DetectFlowTestParse14 (void) {
+int DetectFlowTestParse14 (void)
+{
int result = 1;
DetectFlowData *fd = NULL;
fd = DetectFlowParse("");
/**
* \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");
/**
* \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");
* \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");
/**
* \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");
/**
* \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");
/**
* \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");
/**
* \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");
/**
* \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");
/**
* \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");
/**
* \brief this function registers unit tests for DetectFlow
*/
-void DetectFlowRegisterTests(void) {
+void DetectFlowRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("DetectFlowTestParse01", DetectFlowTestParse01, 1);
UtRegisterTest("DetectFlowTestParse02", DetectFlowTestParse02, 1);
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";
}
-static int DetectFlowbitMatchToggle (Packet *p, DetectFlowbitsData *fd) {
+static int DetectFlowbitMatchToggle (Packet *p, DetectFlowbitsData *fd)
+{
if (p->flow == NULL)
return 0;
return 1;
}
-static int DetectFlowbitMatchUnset (Packet *p, DetectFlowbitsData *fd) {
+static int DetectFlowbitMatchUnset (Packet *p, DetectFlowbitsData *fd)
+{
if (p->flow == NULL)
return 0;
return 1;
}
-static int DetectFlowbitMatchSet (Packet *p, DetectFlowbitsData *fd) {
+static int DetectFlowbitMatchSet (Packet *p, DetectFlowbitsData *fd)
+{
if (p->flow == NULL)
return 0;
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;
return -1;
}
-void DetectFlowbitFree (void *ptr) {
+void DetectFlowbitFree (void *ptr)
+{
DetectFlowbitsData *fd = (DetectFlowbitsData *)ptr;
if (fd == NULL)
* \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"
* \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"
* \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"
* \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"
* \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"
* \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"
* \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"
* \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"
/**
* \brief this function registers unit tests for FlowBits
*/
-void FlowBitsRegisterTests(void) {
+void FlowBitsRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("FlowBitsTestSig01", FlowBitsTestSig01, 0);
UtRegisterTest("FlowBitsTestSig02", FlowBitsTestSig02, 0);
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;
*
* \param cd pointer to DetectCotentData
*/
-static void DetectFlowvarDataFree(void *ptr) {
+static void DetectFlowvarDataFree(void *ptr)
+{
if (ptr == NULL)
SCReturn;
/** \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;
* \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;
/** \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);
* \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";
*
* \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);
}
* \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) ) {
* \retval 1 on succces
* \retval 0 on failure
*/
-static int FragBitsTestParse02 (void) {
+static int FragBitsTestParse02 (void)
+{
DetectFragBitsData *de = NULL;
de = DetectFragBitsParse("G");
if (de) {
* \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,
* \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,
/**
* \brief this function registers unit tests for FragBits
*/
-void FragBitsRegisterTests(void) {
+void FragBitsRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("FragBitsTestParse01", FragBitsTestParse01, 1);
UtRegisterTest("FragBitsTestParse02", FragBitsTestParse02, 0);
/**
* \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";
* \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;
* \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
* \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;
*
* \param ptr pointer to DetectFragOffsetData
*/
-void DetectFragOffsetFree (void *ptr) {
+void DetectFragOffsetFree (void *ptr)
+{
DetectFragOffsetData *fragoff = (DetectFragOffsetData *)ptr;
SCFree(fragoff);
}
/**
* \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) {
* \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) {
/**
* \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) {
* 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))
}
#endif /* UNITTESTS */
-void DetectFragOffsetRegisterTests (void) {
+void DetectFragOffsetRegisterTests (void)
+{
#ifdef UNITTESTS
UtRegisterTest("DetectFragOffsetParseTest01", DetectFragOffsetParseTest01, 1);
UtRegisterTest("DetectFragOffsetParseTest02", DetectFragOffsetParseTest02, 1);
* \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' };
* \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' };
#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;
}
*
* \param geoipdata pointer to DetectGeoipData
*/
-static void DetectGeoipDataFree(void *ptr) {
+static void DetectGeoipDataFree(void *ptr)
+{
if (ptr != NULL) {
DetectGeoipData *geoipdata = (DetectGeoipData *)ptr;
SCFree(geoipdata);
#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;
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);
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");
* \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";
* \retval 1 on succces
* \retval 0 on failure
*/
-static int GidTestParse01 (void) {
+static int GidTestParse01 (void)
+{
int result = 0;
Signature *s = NULL;
* \retval 1 on succces
* \retval 0 on failure
*/
-static int GidTestParse02 (void) {
+static int GidTestParse02 (void)
+{
int result = 0;
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
/**
* \brief this function registers unit tests for Gid
*/
-void GidRegisterTests(void) {
+void GidRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("GidTestParse01", GidTestParse01, 1);
UtRegisterTest("GidTestParse02", GidTestParse02, 1);
}
/** \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;
}
/** \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;
}
/** \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:"
}
/** \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";
}
/** \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"
}
/** \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"
}
/** \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"
}
/** \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"
}
/** \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"
/**
* \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";
*
* \param id_d pointer to DetectContentData
*/
-void DetectHttpMethodFree(void *ptr) {
+void DetectHttpMethodFree(void *ptr)
+{
DetectContentData *data = (DetectContentData *)ptr;
if (data->content != NULL)
/**
* \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);
}
/** \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;
return result;
}
-static int DetectHttpServerBodyTest15(void) {
+static int DetectHttpServerBodyTest15(void)
+{
int result = 0;
Signature *s = NULL;
DetectEngineThreadCtx *det_ctx = NULL;
}
/** \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;
return result;
}
-static int DetectHttpServerBodyFileDataTest10(void) {
+static int DetectHttpServerBodyFileDataTest10(void)
+{
int result = 0;
Signature *s = NULL;
DetectEngineThreadCtx *det_ctx = NULL;
/**
* \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";
}
/** \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";
}
/** \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";
/** \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";
/** \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";
/**
* \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";
}
/** \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";
}
/** \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";
/** \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";
/**
* \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";
/**
* \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";
* \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;
* \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
* \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;
*
* \param ptr pointer to DetectIcmpIdData
*/
-void DetectIcmpIdFree (void *ptr) {
+void DetectIcmpIdFree (void *ptr)
+{
DetectIcmpIdData *iid = (DetectIcmpIdData *)ptr;
SCFree(iid);
}
/**
* \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)) {
* \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)) {
* \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)) {
* \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)) {
* \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) {
* 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;
* 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[] = {
}
#endif /* UNITTESTS */
-void DetectIcmpIdRegisterTests (void) {
+void DetectIcmpIdRegisterTests (void)
+{
#ifdef UNITTESTS
UtRegisterTest("DetectIcmpIdParseTest01", DetectIcmpIdParseTest01, 1);
UtRegisterTest("DetectIcmpIdParseTest02", DetectIcmpIdParseTest02, 1);
/**
* \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";
* \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;
* \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
* \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;
*
* \param ptr pointer to DetectIcmpSeqData
*/
-void DetectIcmpSeqFree (void *ptr) {
+void DetectIcmpSeqFree (void *ptr)
+{
DetectIcmpSeqData *iseq = (DetectIcmpSeqData *)ptr;
SCFree(iseq);
}
/**
* \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) {
* \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) {
/**
* \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) {
* 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;
}
#endif /* UNITTESTS */
-void DetectIcmpSeqRegisterTests (void) {
+void DetectIcmpSeqRegisterTests (void)
+{
#ifdef UNITTESTS
UtRegisterTest("DetectIcmpSeqParseTest01", DetectIcmpSeqParseTest01, 1);
UtRegisterTest("DetectIcmpSeqParseTest02", DetectIcmpSeqParseTest02, 1);
/**
* \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";
* \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;
* \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
* \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;
*
* \param ptr pointer to DetectICodeData
*/
-void DetectICodeFree(void *ptr) {
+void DetectICodeFree(void *ptr)
+{
DetectICodeData *icd = (DetectICodeData *)ptr;
SCFree(icd);
}
/**
* \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");
* \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");
* \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");
* \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");
* \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 ");
* \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 ");
* \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 ");
/**
* \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)
* 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;
/**
* \brief this function registers unit tests for DetectICode
*/
-void DetectICodeRegisterTests(void) {
+void DetectICodeRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("DetectICodeParseTest01", DetectICodeParseTest01, 1);
UtRegisterTest("DetectICodeParseTest02", DetectICodeParseTest02, 1);
/**
* \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";
*
* \param id_d pointer to DetectIdData
*/
-void DetectIdFree(void *ptr) {
+void DetectIdFree(void *ptr)
+{
DetectIdData *id_d = (DetectIdData *)ptr;
SCFree(id_d);
}
* \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) {
* 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) {
* 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) {
* \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\" ");
* \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);
/**
* \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);
/**
* \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";
*
* \param de pointer to DetectIpOptsData
*/
-void DetectIpOptsFree(void *de_ptr) {
+void DetectIpOptsFree(void *de_ptr)
+{
DetectIpOptsData *de = (DetectIpOptsData *)de_ptr;
if(de) SCFree(de);
}
* \retval 1 on succces
* \retval 0 on failure
*/
-int IpOptsTestParse01 (void) {
+int IpOptsTestParse01 (void)
+{
DetectIpOptsData *de = NULL;
de = DetectIpOptsParse("lsrr");
if (de) {
* \retval 1 on succces
* \retval 0 on failure
*/
-int IpOptsTestParse02 (void) {
+int IpOptsTestParse02 (void)
+{
DetectIpOptsData *de = NULL;
de = DetectIpOptsParse("invalidopt");
if (de) {
* \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;
* \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;
/**
* \brief this function registers unit tests for IpOpts
*/
-void IpOptsRegisterTests(void) {
+void IpOptsRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("IpOptsTestParse01", IpOptsTestParse01, 1);
UtRegisterTest("IpOptsTestParse02", IpOptsTestParse02, 0);
return;
}
-static void DetectIPProtoFree(void *ptr) {
+static void DetectIPProtoFree(void *ptr)
+{
DetectIPProtoData *data = (DetectIPProtoData *)ptr;
if (data) {
SCFree(data);
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;
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;
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;
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) {
return -1;
}
-void DetectIPRepFree (void *ptr) {
+void DetectIPRepFree (void *ptr)
+{
DetectIPRepData *fd = (DetectIPRepData *)ptr;
if (fd == NULL)
/**
* \brief this function registers unit tests for IPRep
*/
-void IPRepRegisterTests(void) {
+void IPRepRegisterTests(void)
+{
#ifdef UNITTESTS
#endif /* UNITTESTS */
}
*
* \param idad pointer to DetectIsdataatData
*/
-void DetectIsdataatFree(void *ptr) {
+void DetectIsdataatFree(void *ptr)
+{
DetectIsdataatData *idad = (DetectIsdataatData *)ptr;
SCFree(idad);
}
* \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);
* \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);
* \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);
* \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);
* 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"
* 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"
/**
* \brief this function registers unit tests for DetectIsdataat
*/
-void DetectIsdataatRegisterTests(void) {
+void DetectIsdataatRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("DetectIsdataatTestParse01", DetectIsdataatTestParse01, 1);
UtRegisterTest("DetectIsdataatTestParse02", DetectIsdataatTestParse02, 1);
/**
* \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";
* \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;
* \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
* \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;
*
* \param ptr pointer to DetectITypeData
*/
-void DetectITypeFree(void *ptr) {
+void DetectITypeFree(void *ptr)
+{
DetectITypeData *itd = (DetectITypeData *)ptr;
SCFree(itd);
}
/**
* \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");
* \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");
* \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");
* \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");
* \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 ");
* \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 ");
* \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 ");
/**
* \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)
* 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;
/**
* \brief this function registers unit tests for DetectIType
*/
-void DetectITypeRegisterTests(void) {
+void DetectITypeRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("DetectITypeParseTest01", DetectITypeParseTest01, 1);
UtRegisterTest("DetectITypeParseTest02", DetectITypeParseTest02, 1);
* the received packet against the sig.
*/
-static int DetectL3protoTestSig1(void) {
+static int DetectL3protoTestSig1(void)
+{
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
* the received IPv6 packet against the sig.
*/
-static int DetectL3protoTestSig2(void) {
+static int DetectL3protoTestSig2(void)
+{
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
* in conjonction with ip_proto keyword.
*/
-static int DetectL3protoTestSig3(void) {
+static int DetectL3protoTestSig3(void)
+{
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
/**
* \brief this function registers unit tests for DetectL3proto
*/
-void DetectL3protoRegisterTests(void) {
+void DetectL3protoRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("DetectL3protoTestSig1", DetectL3protoTestSig1, 1);
UtRegisterTest("DetectL3protoTestSig2", DetectL3protoTestSig2, 1);
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;
}
-int LuajitSetFlowvar(lua_State *luastate) {
+int LuajitSetFlowvar(lua_State *luastate)
+{
uint16_t idx;
int id;
Flow *f;
return 0;
}
-static int LuajitGetFlowint(lua_State *luastate) {
+static int LuajitGetFlowint(lua_State *luastate)
+{
uint16_t idx;
int id;
Flow *f;
}
-int LuajitSetFlowint(lua_State *luastate) {
+int LuajitSetFlowint(lua_State *luastate)
+{
uint16_t idx;
int id;
Flow *f;
return 0;
}
-static int LuajitIncrFlowint(lua_State *luastate) {
+static int LuajitIncrFlowint(lua_State *luastate)
+{
uint16_t idx;
int id;
Flow *f;
}
-static int LuajitDecrFlowint(lua_State *luastate) {
+static int LuajitDecrFlowint(lua_State *luastate)
+{
uint16_t idx;
int id;
Flow *f;
}
-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 */
/**
* \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");
#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;
}
/**
* \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;
/**
* \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";
#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);
* \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);
}
#endif /* HAVE_LUAJIT */
-static lua_State *DetectLuajitGetState(void) {
+static lua_State *DetectLuajitGetState(void)
+{
lua_State *s = NULL;
#ifdef HAVE_LUAJIT
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);
}
/** \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;
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);
return NULL;
}
-static void DetectLuajitThreadFree(void *ctx) {
+static void DetectLuajitThreadFree(void *ctx)
+{
if (ctx != NULL) {
DetectLuajitThreadData *t = (DetectLuajitThreadData *)ctx;
if (t->luastate != NULL)
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();
/** \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;
*
* \param luajit pointer to DetectLuajitData
*/
-static void DetectLuajitFree(void *ptr) {
+static void DetectLuajitFree(void *ptr)
+{
if (ptr != NULL) {
DetectLuajitData *luajit = (DetectLuajitData *)ptr;
#ifdef UNITTESTS
/** \test http buffer */
-static int LuajitMatchTest01(void) {
+static int LuajitMatchTest01(void)
+{
const char script[] =
"function init (args)\n"
" local needs = {}\n"
}
/** \test payload buffer */
-static int LuajitMatchTest02(void) {
+static int LuajitMatchTest02(void)
+{
const char script[] =
"function init (args)\n"
" local needs = {}\n"
}
/** \test packet buffer */
-static int LuajitMatchTest03(void) {
+static int LuajitMatchTest03(void)
+{
const char script[] =
"function init (args)\n"
" local needs = {}\n"
}
/** \test http buffer, flowints */
-static int LuajitMatchTest04(void) {
+static int LuajitMatchTest04(void)
+{
const char script[] =
"function init (args)\n"
" local needs = {}\n"
}
/** \test http buffer, flowints */
-static int LuajitMatchTest05(void) {
+static int LuajitMatchTest05(void)
+{
const char script[] =
"function init (args)\n"
" local needs = {}\n"
}
/** \test http buffer, flowints */
-static int LuajitMatchTest06(void) {
+static int LuajitMatchTest06(void)
+{
const char script[] =
"function init (args)\n"
" local needs = {}\n"
#endif
-void DetectLuajitRegisterTests(void) {
+void DetectLuajitRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("LuajitMatchTest01", LuajitMatchTest01, 1);
UtRegisterTest("LuajitMatchTest02", LuajitMatchTest02, 1);
* \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;
* \retval 1 on succces
* \retval 0 on failure
*/
-static int MarkTestParse01 (void) {
+static int MarkTestParse01 (void)
+{
DetectMarkData *data;
data = DetectMarkParse("1/1");
* \retval 1 on succces
* \retval 0 on failure
*/
-static int MarkTestParse02 (void) {
+static int MarkTestParse02 (void)
+{
DetectMarkData *data;
data = DetectMarkParse("4");
* \retval 1 on succces
* \retval 0 on failure
*/
-static int MarkTestParse03 (void) {
+static int MarkTestParse03 (void)
+{
DetectMarkData *data;
data = DetectMarkParse("0x10/0xff");
* \retval 1 on succces
* \retval 0 on failure
*/
-static int MarkTestParse04 (void) {
+static int MarkTestParse04 (void)
+{
DetectMarkData *data;
data = DetectMarkParse("0x1g/0xff");
/**
* \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);
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";
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";
/**
* \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);
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;
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";
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;
/** \brief free a SigMatch
* \param sm SigMatch to free.
*/
-void SigMatchFree(SigMatch *sm) {
+void SigMatchFree(SigMatch *sm)
+{
if (sm == NULL)
return;
}
/* Get the detection module by name */
-SigTableElmt *SigTableGet(char *name) {
+SigTableElmt *SigTableGet(char *name)
+{
SigTableElmt *st = NULL;
int i = 0;
return -1;
}
-void SigParsePrepare(void) {
+void SigParsePrepare(void)
+{
char *regexstr = CONFIG_PCRE;
const char *eb;
int eo;
}
}
-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;
* \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);
/** \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) {
* 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;
* \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;
* \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;
SCReturnInt(ret);
}
-Signature *SigAlloc (void) {
+Signature *SigAlloc (void)
+{
Signature *sig = SCMalloc(sizeof(Signature));
if (unlikely(sig == NULL))
return NULL;
*
* \param s Pointer to the signature
*/
-static void SigRefFree (Signature *s) {
+static void SigRefFree (Signature *s)
+{
SCEnter();
DetectReference *ref = NULL;
SCReturn;
}
-void SigFree(Signature *s) {
+void SigFree(Signature *s)
+{
if (s == NULL)
return;
*
* \param s the signature
*/
-static void SigBuildAddressMatchArray(Signature *s) {
+static void SigBuildAddressMatchArray(Signature *s)
+{
/* source addresses */
uint16_t cnt = 0;
uint16_t idx = 0;
* \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;
*/
#ifdef UNITTESTS
-int SigParseTest01 (void) {
+int SigParseTest01 (void)
+{
int result = 1;
Signature *sig = NULL;
return result;
}
-int SigParseTest02 (void) {
+int SigParseTest02 (void)
+{
int result = 0;
Signature *sig = NULL;
DetectPort *port = NULL;
/**
* \test SigParseTest03 test for invalid direction operator in rule
*/
-int SigParseTest03 (void) {
+int SigParseTest03 (void)
+{
int result = 1;
Signature *sig = NULL;
return result;
}
-int SigParseTest04 (void) {
+int SigParseTest04 (void)
+{
int result = 1;
Signature *sig = NULL;
}
/** \test Port validation */
-int SigParseTest05 (void) {
+int SigParseTest05 (void)
+{
int result = 0;
Signature *sig = NULL;
}
/** \test Parsing bug debugging at 2010-03-18 */
-int SigParseTest06 (void) {
+int SigParseTest06 (void)
+{
int result = 0;
Signature *sig = NULL;
/**
* \test Parsing duplicate sigs.
*/
-int SigParseTest07(void) {
+int SigParseTest07(void)
+{
int result = 0;
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
/**
* \test Parsing duplicate sigs.
*/
-int SigParseTest08(void) {
+int SigParseTest08(void)
+{
int result = 0;
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
/**
* \test Parsing duplicate sigs.
*/
-int SigParseTest09(void) {
+int SigParseTest09(void)
+{
int result = 1;
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
/**
* \test Parsing duplicate sigs.
*/
-int SigParseTest10(void) {
+int SigParseTest10(void)
+{
int result = 1;
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
* \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();
/**
* \test file_data with rawbytes
*/
-static int SigParseTest12(void) {
+static int SigParseTest12(void)
+{
int result = 0;
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
/**
* \test packet/stream sig
*/
-static int SigParseTest13(void) {
+static int SigParseTest13(void)
+{
int result = 0;
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
/**
* \test packet/stream sig
*/
-static int SigParseTest14(void) {
+static int SigParseTest14(void)
+{
int result = 0;
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
/**
* \test packet/stream sig
*/
-static int SigParseTest15(void) {
+static int SigParseTest15(void)
+{
int result = 0;
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
/**
* \test packet/stream sig
*/
-static int SigParseTest16(void) {
+static int SigParseTest16(void)
+{
int result = 0;
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
/**
* \test packet/stream sig
*/
-static int SigParseTest17(void) {
+static int SigParseTest17(void)
+{
int result = 0;
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
}
/** \test sid value too large. Bug #779 */
-static int SigParseTest18 (void) {
+static int SigParseTest18 (void)
+{
int result = 0;
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
}
/** \test gid value too large. Related to bug #779 */
-static int SigParseTest19 (void) {
+static int SigParseTest19 (void)
+{
int result = 0;
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
}
/** \test rev value too large. Related to bug #779 */
-static int SigParseTest20 (void) {
+static int SigParseTest20 (void)
+{
int result = 0;
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
}
/** \test address parsing */
-static int SigParseTest21 (void) {
+static int SigParseTest21 (void)
+{
int result = 0;
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
}
/** \test address parsing */
-static int SigParseTest22 (void) {
+static int SigParseTest22 (void)
+{
int result = 0;
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
}
/** \test Direction operator validation (invalid) */
-int SigParseBidirecTest06 (void) {
+int SigParseBidirecTest06 (void)
+{
int result = 1;
Signature *sig = NULL;
}
/** \test Direction operator validation (invalid) */
-int SigParseBidirecTest07 (void) {
+int SigParseBidirecTest07 (void)
+{
int result = 1;
Signature *sig = NULL;
}
/** \test Direction operator validation (invalid) */
-int SigParseBidirecTest08 (void) {
+int SigParseBidirecTest08 (void)
+{
int result = 1;
Signature *sig = NULL;
}
/** \test Direction operator validation (invalid) */
-int SigParseBidirecTest09 (void) {
+int SigParseBidirecTest09 (void)
+{
int result = 1;
Signature *sig = NULL;
}
/** \test Direction operator validation (invalid) */
-int SigParseBidirecTest10 (void) {
+int SigParseBidirecTest10 (void)
+{
int result = 1;
Signature *sig = NULL;
}
/** \test Direction operator validation (invalid) */
-int SigParseBidirecTest11 (void) {
+int SigParseBidirecTest11 (void)
+{
int result = 1;
Signature *sig = NULL;
}
/** \test Direction operator validation (invalid) */
-int SigParseBidirecTest12 (void) {
+int SigParseBidirecTest12 (void)
+{
int result = 1;
Signature *sig = NULL;
}
/** \test Direction operator validation (valid) */
-int SigParseBidirecTest13 (void) {
+int SigParseBidirecTest13 (void)
+{
int result = 1;
Signature *sig = NULL;
}
/** \test Direction operator validation (valid) */
-int SigParseBidirecTest14 (void) {
+int SigParseBidirecTest14 (void)
+{
int result = 1;
Signature *sig = NULL;
/** \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;
}
/** \test Ensure that we set a bidirectional Signature correctly */
-int SigTestBidirec02 (void) {
+int SigTestBidirec02 (void)
+{
int result = 0;
Signature *sig = NULL;
Signature *copy = NULL;
* 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;
* 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;
/**
* \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;
/**
* \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;
/**
* \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;
/**
* \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;
/**
* \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;
/**
* \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;
/**
* \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;
/**
* \test check valid negation bug 1079
*/
-static int SigParseTestNegation08 (void) {
+static int SigParseTestNegation08 (void)
+{
int result = 0;
DetectEngineCtx *de_ctx;
Signature *s=NULL;
/**
* \test mpm
*/
-int SigParseTestMpm01 (void) {
+int SigParseTestMpm01 (void)
+{
int result = 0;
Signature *sig = NULL;
/**
* \test mpm
*/
-int SigParseTestMpm02 (void) {
+int SigParseTestMpm02 (void)
+{
int result = 0;
Signature *sig = NULL;
/**
* \test test tls (app layer) rule
*/
-static int SigParseTestAppLayerTLS01(void) {
+static int SigParseTestAppLayerTLS01(void)
+{
int result = 0;
DetectEngineCtx *de_ctx;
Signature *s=NULL;
/**
* \test test tls (app layer) rule
*/
-static int SigParseTestAppLayerTLS02(void) {
+static int SigParseTestAppLayerTLS02(void)
+{
int result = 0;
DetectEngineCtx *de_ctx;
Signature *s=NULL;
/**
* \test test tls (app layer) rule
*/
-static int SigParseTestAppLayerTLS03(void) {
+static int SigParseTestAppLayerTLS03(void)
+{
int result = 0;
DetectEngineCtx *de_ctx;
Signature *s=NULL;
#endif /* UNITTESTS */
-void SigParseRegisterTests(void) {
+void SigParseRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("SigParseTest01", SigParseTest01, 1);
UtRegisterTest("SigParseTest02", SigParseTest02, 1);
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;
/**
* \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);
/**
* \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;
}
#endif
-static void DetectPktDataTestRegister(void){
+static void DetectPktDataTestRegister(void)
+{
#ifdef UNITTESTS
UtRegisterTest("DetectPktDataTest01", DetectPktDataTest01, 1);
#endif
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;
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;
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;
/**
* \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"
/**
* \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
*/
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";
/**
* \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";
*
* \param rd pointer to DetectRpcData
*/
-void DetectRpcFree(void *ptr) {
+void DetectRpcFree(void *ptr)
+{
SCEnter();
if (ptr == NULL) {
* \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");
/**
* \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");
* \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");
/**
* \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("");
/**
* \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,*");
/**
* \test DetectRpcTestParse05 is a test to check the match function
*/
-static int DetectRpcTestSig01(void) {
+static int DetectRpcTestSig01(void)
+{
/* RPC Call */
uint8_t buf[] = {
/* XID */
/**
* \brief this function registers unit tests for DetectRpc
*/
-void DetectRpcRegisterTests(void) {
+void DetectRpcRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("DetectRpcTestParse01", DetectRpcTestParse01, 1);
UtRegisterTest("DetectRpcTestParse02", DetectRpcTestParse02, 1);
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";
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";
/**
* \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;
*
* \param id_d pointer to DetectSshVersionData
*/
-void DetectSshVersionFree(void *ptr) {
+void DetectSshVersionFree(void *ptr)
+{
DetectSshVersionData *id_d = (DetectSshVersionData *)ptr;
SCFree(id_d);
}
* \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) {
* \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) {
* \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) {
#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.";
}
/** \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.";
}
/** \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.";
/**
* \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);
/**
* \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;
*
* \param id_d pointer to DetectSshSoftwareVersionData
*/
-void DetectSshSoftwareVersionFree(void *ptr) {
+void DetectSshSoftwareVersionFree(void *ptr)
+{
if (ptr == NULL)
return;
* \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) {
* \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) {
* \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) {
#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.";
}
/** \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";
}
/** \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.";
/**
* \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);
*
* \param ptr pointer to the data to be freed.
*/
-void DetectSslStateFree(void *ptr) {
+void DetectSslStateFree(void *ptr)
+{
if (ptr != NULL)
SCFree(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) {
* "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) {
* \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 &&
* \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";
* \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;
* \retval NULL on failure
*/
-DetectStreamSizeData *DetectStreamSizeParse (char *streamstr) {
+DetectStreamSizeData *DetectStreamSizeParse (char *streamstr)
+{
DetectStreamSizeData *sd = NULL;
char *arg = NULL;
* \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;
*
* \param ptr pointer to DetectStreamSizeData
*/
-void DetectStreamSizeFree(void *ptr) {
+void DetectStreamSizeFree(void *ptr)
+{
DetectStreamSizeData *sd = (DetectStreamSizeData *)ptr;
SCFree(sd);
}
* 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");
* invalid stream_size options.
*/
-static int DetectStreamSizeParseTest02 (void) {
+static int DetectStreamSizeParseTest02 (void)
+{
int result = 1;
DetectStreamSizeData *sd = NULL;
sd = DetectStreamSizeParse("invalidoption,<,6");
* packet correctly provided valid stream size.
*/
-static int DetectStreamSizeParseTest03 (void) {
+static int DetectStreamSizeParseTest03 (void)
+{
int result = 0;
DetectStreamSizeData *sd = NULL;
* stream_size against invalid packet parameters.
*/
-static int DetectStreamSizeParseTest04 (void) {
+static int DetectStreamSizeParseTest04 (void)
+{
int result = 0;
DetectStreamSizeData *sd = NULL;
/**
* \brief this function registers unit tests for DetectStreamSize
*/
-void DetectStreamSizeRegisterTests(void) {
+void DetectStreamSizeRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("DetectStreamSizeParseTest01", DetectStreamSizeParseTest01, 1);
UtRegisterTest("DetectStreamSizeParseTest02", DetectStreamSizeParseTest02, 1);
/**
* \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;
/**
* \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";
*
* \param id_d pointer to DetectTlsVersionData
*/
-void DetectTlsVersionFree(void *ptr) {
+void DetectTlsVersionFree(void *ptr)
+{
DetectTlsVersionData *id_d = (DetectTlsVersionData *)ptr;
SCFree(id_d);
}
* \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) {
* 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) {
#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 };
return result;
}
-static int DetectTlsVersionTestDetect02(void) {
+static int DetectTlsVersionTestDetect02(void)
+{
int result = 0;
Flow f;
uint8_t tlsbuf1[] = { 0x16 };
return result;
}
-static int DetectTlsVersionTestDetect03(void) {
+static int DetectTlsVersionTestDetect03(void)
+{
DetectEngineCtx *de_ctx = NULL;
int result = 0;
Flow f;
/**
* \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);
/**
* \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";
*
* \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;
/**
* \brief this function registers unit tests for DetectTlsSubject
*/
-static void DetectTlsSubjectRegisterTests(void) {
+static void DetectTlsSubjectRegisterTests(void)
+{
}
/**
*
* \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);
* \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";
* \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;
* \retval NULL on failure
*/
-DetectTtlData *DetectTtlParse (char *ttlstr) {
+DetectTtlData *DetectTtlParse (char *ttlstr)
+{
DetectTtlData *ttld = NULL;
char *arg1 = NULL;
* \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;
*
* \param ptr pointer to DetectTtlData
*/
-void DetectTtlFree(void *ptr) {
+void DetectTtlFree(void *ptr)
+{
DetectTtlData *ttld = (DetectTtlData *)ptr;
SCFree(ttld);
}
*
*/
-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;
* \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;
* "<" operator.
*/
-static int DetectTtlParseTest02 (void) {
+static int DetectTtlParseTest02 (void)
+{
DetectTtlData *ttld = NULL;
uint8_t res = 0;
ttld = DetectTtlParse("<10");
* "-" operator.
*/
-static int DetectTtlParseTest03 (void) {
+static int DetectTtlParseTest03 (void)
+{
DetectTtlData *ttld = NULL;
uint8_t res = 0;
ttld = DetectTtlParse("1-2");
* ">" operator and include spaces arround the given values.
*/
-static int DetectTtlParseTest04 (void) {
+static int DetectTtlParseTest04 (void)
+{
DetectTtlData *ttld = NULL;
uint8_t res = 0;
* "-" operator and include spaces arround the given values.
*/
-static int DetectTtlParseTest05 (void) {
+static int DetectTtlParseTest05 (void)
+{
DetectTtlData *ttld = NULL;
uint8_t res = 0;
* invalid "=" operator and include spaces arround the given values.
*/
-static int DetectTtlParseTest06 (void) {
+static int DetectTtlParseTest06 (void)
+{
DetectTtlData *ttld = NULL;
uint8_t res = 0;
* invalid "<>" operator and include spaces arround the given values.
*/
-static int DetectTtlParseTest07 (void) {
+static int DetectTtlParseTest07 (void)
+{
DetectTtlData *ttld = NULL;
uint8_t res = 0;
* setting up the signature itself.
*/
-static int DetectTtlSetpTest01(void) {
+static int DetectTtlSetpTest01(void)
+{
DetectTtlData *ttld = NULL;
uint8_t res = 0;
* the received packet against the sig.
*/
-static int DetectTtlTestSig1(void) {
+static int DetectTtlTestSig1(void)
+{
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
/**
* \brief this function registers unit tests for DetectTtl
*/
-void DetectTtlRegisterTests(void) {
+void DetectTtlRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("DetectTtlParseTest01", DetectTtlParseTest01, 1);
UtRegisterTest("DetectTtlParseTest02", DetectTtlParseTest02, 1);
*
* \param cd pointer to DetectUricotentData
*/
-void DetectUricontentFree(void *ptr) {
+void DetectUricontentFree(void *ptr)
+{
SCEnter();
DetectContentData *cd = (DetectContentData *)ptr;
/** \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"
/** \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;
/** \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;
/** \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;
}
/** \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:"
/** \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;
* \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;
/** \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;
/** \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;
/** \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;
#endif /* UNITTESTS */
-void HttpUriRegisterTests(void) {
+void HttpUriRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("HTTPUriTest01", HTTPUriTest01, 1);
UtRegisterTest("HTTPUriTest02", HTTPUriTest02, 1);
* context and setting up the signature itself.
*/
-static int DetectUrilenSetpTest01(void) {
+static int DetectUrilenSetpTest01(void)
+{
DetectUrilenData *urilend = NULL;
uint8_t res = 0;
/**
* \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";
* \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)) {
* \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
*
* \param wd pointer to DetectWindowData
*/
-void DetectWindowFree(void *ptr) {
+void DetectWindowFree(void *ptr)
+{
DetectWindowData *wd = (DetectWindowData *)ptr;
SCFree(wd);
}
* \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");
/**
* \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");
/**
* \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("");
/**
* \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");
/**
* \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);
/**
* \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);
* \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"
}
-int DetectWithinTestPacket02 (void) {
+int DetectWithinTestPacket02 (void)
+{
int result = 0;
uint8_t *buf = (uint8_t *)"Zero Five Ten Fourteen";
uint16_t buflen = strlen((char *)buf);
#endif /* UNITTESTS */
-void DetectWithinRegisterTests(void) {
+void DetectWithinRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("DetectWithinTestPacket01", DetectWithinTestPacket01, 1);
UtRegisterTest("DetectWithinTestPacket02", DetectWithinTestPacket02, 1);
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;
PacketAlertTagInit();
}
-void DetectExitPrintStats(ThreadVars *tv, void *data) {
+void DetectExitPrintStats(ThreadVars *tv, void *data)
+{
DetectEngineThreadCtx *det_ctx = (DetectEngineThreadCtx *)data;
if (det_ctx == NULL)
return;
* \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] = "";
*
* \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;
* \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);
return DetectEngineThreadCtxInit(t,initdata,data);
}
-TmEcode DetectThreadDeinit(ThreadVars *t, void *data) {
+TmEcode DetectThreadDeinit(ThreadVars *t, void *data)
+{
return DetectEngineThreadCtxDeinit(t,data);
}
}
-int SignatureIsAppLayer(DetectEngineCtx *de_ctx, Signature *s) {
+int SignatureIsAppLayer(DetectEngineCtx *de_ctx, Signature *s)
+{
if (s->alproto != 0)
return 1;
* \retval 0 no
* \retval 1 yes
*/
-int SignatureIsFilestoring(Signature *s) {
+int SignatureIsFilestoring(Signature *s)
+{
if (s == NULL)
return 0;
* \retval 0 no
* \retval 1 yes
*/
-int SignatureIsFilemagicInspecting(Signature *s) {
+int SignatureIsFilemagicInspecting(Signature *s)
+{
if (s == NULL)
return 0;
* \retval 0 no
* \retval 1 yes
*/
-int SignatureIsFileMd5Inspecting(Signature *s) {
+int SignatureIsFileMd5Inspecting(Signature *s)
+{
if (s == NULL)
return 0;
* \retval 0 no
* \retval 1 yes
*/
-int SignatureIsFilesizeInspecting(Signature *s) {
+int SignatureIsFilesizeInspecting(Signature *s)
+{
if (s == NULL)
return 0;
* \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;
* \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;
* \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);
}
}
}
-static int SignatureCreateMask(Signature *s) {
+static int SignatureCreateMask(Signature *s)
+{
SCEnter();
if (s->sm_lists[DETECT_SM_LIST_PMATCH] != NULL) {
* \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;
/** \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;
* \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) {
* \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;
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;
/**
* \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) {
return 0;
}
-static DetectAddress *GetHeadPtr(DetectAddressHead *head, int family) {
+static DetectAddress *GetHeadPtr(DetectAddressHead *head, int family)
+{
DetectAddress *grhead;
if (head == NULL)
// || (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;
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;
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;
* \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);
}
* \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;
/**
* \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;
}
//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;
return -1;
}
-static void DetectEngineBuildDecoderEventSgh(DetectEngineCtx *de_ctx) {
+static void DetectEngineBuildDecoderEventSgh(DetectEngineCtx *de_ctx)
+{
if (de_ctx->decoder_event_sgh == NULL)
return;
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)) {
return -1;
}
-int SigAddressCleanupStage1(DetectEngineCtx *de_ctx) {
+int SigAddressCleanupStage1(DetectEngineCtx *de_ctx)
+{
BUG_ON(de_ctx == NULL);
if (!(de_ctx->flags & DE_QUIET)) {
return 0;
}
-void DbgPrintSigs(DetectEngineCtx *de_ctx, SigGroupHead *sgh) {
+void DbgPrintSigs(DetectEngineCtx *de_ctx, SigGroupHead *sgh)
+{
if (sgh == NULL) {
printf("\n");
return;
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;
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;
}
/** \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);
#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;
return 0;
}
-int SigGroupCleanup (DetectEngineCtx *de_ctx) {
+int SigGroupCleanup (DetectEngineCtx *de_ctx)
+{
SigAddressCleanupStage1(de_ctx);
return 0;
return;
}
-void SigTableSetup(void) {
+void SigTableSetup(void)
+{
memset(sigmatch_table, 0, sizeof(sigmatch_table));
DetectSidRegister();
" 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"
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"
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"
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 */
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 */
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 */
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 */
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 */
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 */
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);
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);
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);
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);
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);
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);
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);
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 */
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);
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);
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);
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;
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;
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;
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);
}
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);
}
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);
}
* \brief expecting to match a size
*/
-int SigTest36ContentAndIsdataatKeywords01Real (int mpm_type) {
+int SigTest36ContentAndIsdataatKeywords01Real (int mpm_type)
+{
int result = 0;
// Buid and decode the packet
* \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
// 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);
}
* 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";
* 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";
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"
return result;
}
-static int SigTestMemory02 (void) {
+static int SigTestMemory02 (void)
+{
ThreadVars th_v;
int result = 0;
return result;
}
-static int SigTestMemory03 (void) {
+static int SigTestMemory03 (void)
+{
ThreadVars th_v;
int result = 0;
return result;
}
-static int SigTestSgh01 (void) {
+static int SigTestSgh01 (void)
+{
ThreadVars th_v;
int result = 0;
DetectEngineThreadCtx *det_ctx = NULL;
return result;
}
-static int SigTestSgh02 (void) {
+static int SigTestSgh02 (void)
+{
ThreadVars th_v;
int result = 0;
DetectEngineThreadCtx *det_ctx = NULL;
return result;
}
-static int SigTestSgh03 (void) {
+static int SigTestSgh03 (void)
+{
ThreadVars th_v;
int result = 0;
Packet *p = SCMalloc(SIZE_OF_PACKET);
return result;
}
-static int SigTestSgh04 (void) {
+static int SigTestSgh04 (void)
+{
ThreadVars th_v;
int result = 0;
Packet *p = SCMalloc(SIZE_OF_PACKET);
}
/** \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);
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;
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;
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;
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;
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;
}
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;
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;
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;
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);
}
" HTTP_PORTS: \"80:81,88\"\n"
"\n";
-static int DetectAddressYamlParsing01 (void) {
+static int DetectAddressYamlParsing01 (void)
+{
int result = 0;
ConfCreateContextBackup();
" HTTP_PORTS: \"80:81,88\"\n"
"\n";
-static int DetectAddressYamlParsing02 (void) {
+static int DetectAddressYamlParsing02 (void)
+{
int result = 0;
ConfCreateContextBackup();
" HTTP_PORTS: \"80:81,88\"\n"
"\n";
-static int DetectAddressYamlParsing03 (void) {
+static int DetectAddressYamlParsing03 (void)
+{
int result = 0;
ConfCreateContextBackup();
"\n";
/** \test bug #815 */
-static int DetectAddressYamlParsing04 (void) {
+static int DetectAddressYamlParsing04 (void)
+{
int result = 0;
ConfCreateContextBackup();
}
#endif /* UNITTESTS */
-void SigRegisterTests(void) {
+void SigRegisterTests(void)
+{
#ifdef UNITTESTS
SigParseRegisterTests();
IPOnlyRegisterTests();
*
* \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) {
* \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);
* \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) {
* \retval On success it returns 1 and on failure 0.
*/
-static int FlowMgrTest01 (void) {
+static int FlowMgrTest01 (void)
+{
TcpSession ssn;
Flow f;
FlowBucket fb;
* \retval On success it returns 1 and on failure 0.
*/
-static int FlowMgrTest02 (void) {
+static int FlowMgrTest02 (void)
+{
TcpSession ssn;
Flow f;
FlowBucket fb;
* \retval On success it returns 1 and on failure 0.
*/
-static int FlowMgrTest03 (void) {
+static int FlowMgrTest03 (void)
+{
TcpSession ssn;
Flow f;
FlowBucket fb;
* \retval On success it returns 1 and on failure 0.
*/
-static int FlowMgrTest04 (void) {
+static int FlowMgrTest04 (void)
+{
TcpSession ssn;
Flow f;
* \retval On success it returns 1 and on failure 0.
*/
-static int FlowMgrTest05 (void) {
+static int FlowMgrTest05 (void)
+{
int result = 0;
FlowInitConfig(FLOW_QUIET);
/**
* \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);
*
* \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 {
#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);
}
#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();
return 0;
}
-static int FlowStorageTest02(void) {
+static int FlowStorageTest02(void)
+{
Flow *f = NULL;
StorageInit();
return 0;
}
-static int FlowStorageTest03(void) {
+static int FlowStorageTest03(void)
+{
Flow *f = NULL;
StorageInit();
}
#endif
-void RegisterFlowStorageTests(void) {
+void RegisterFlowStorageTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("FlowStorageTest01", FlowStorageTest01, 1);
UtRegisterTest("FlowStorageTest02", FlowStorageTest02, 1);
* \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) {
#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;
}
/* 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;
}
* \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) {
}
/* 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));
}
/* 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));
}
/* 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;
SCFree(fv);
}
-void FlowVarPrint(GenericVar *gv) {
+void FlowVarPrint(GenericVar *gv)
+{
uint16_t u;
if (!SCLogDebugEnabled())
*
* \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);
*
* \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);
*
* \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);
*
* \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);
*
* \param f *LOCKED* flow
*/
-static inline void FlowSetSessionNoApplayerInspectionFlag(Flow *f) {
+static inline void FlowSetSessionNoApplayerInspectionFlag(Flow *f)
+{
f->flags |= FLOW_NO_APPLAYER_INSPECTION;
}
/** \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);
}
}
-static inline void FlowDeReference(Flow **d) {
+static inline void FlowDeReference(Flow **d)
+{
if (likely(*d != NULL)) {
FlowDecrUsecnt(*d);
*d = NULL;
#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);
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...");
*
* \param q the host queue to destroy
*/
-void HostQueueDestroy (HostQueue *q) {
+void HostQueueDestroy (HostQueue *q)
+{
HQLOCK_DESTROY(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
*
* \retval h host or NULL if empty list.
*/
-Host *HostDequeue (HostQueue *q) {
+Host *HostDequeue (HostQueue *q)
+{
HQLOCK_LOCK(q);
Host *h = q->bot;
return h;
}
-uint32_t HostQueueLen(HostQueue *q) {
+uint32_t HostQueueLen(HostQueue *q)
+{
uint32_t len;
HQLOCK_LOCK(q);
len = q->len;
#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);
}
#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);
return 0;
}
-static int HostStorageTest02(void) {
+static int HostStorageTest02(void)
+{
StorageInit();
int id1 = HostStorageRegister("test", sizeof(void *), NULL, StorageTestFree);
return 0;
}
-static int HostStorageTest03(void) {
+static int HostStorageTest03(void)
+{
StorageInit();
int id1 = HostStorageRegister("test1", sizeof(void *), NULL, StorageTestFree);
}
#endif
-void RegisterHostStorageTests(void) {
+void RegisterHostStorageTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("HostStorageTest01", HostStorageTest01, 1);
UtRegisterTest("HostStorageTest02", HostStorageTest02, 1);
#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);
}
* \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;
*
* \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;
/** 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))) {
return NULL;
}
-void HostFree(Host *h) {
+void HostFree(Host *h)
+{
if (h != NULL) {
HostClearMemory(h);
}
}
-Host *HostNew(Address *a) {
+Host *HostNew(Address *a)
+{
Host *h = HostAlloc();
if (h == NULL)
goto error;
return NULL;
}
-void HostClearMemory(Host *h) {
+void HostClearMemory(Host *h)
+{
if (h->iprep != NULL) {
SCFree(h->iprep);
h->iprep = NULL;
* 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) {
#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);
}
*
* \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 */
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);
}
*
* \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;
return NULL;
}
-void HostRegisterUnittests(void) {
+void HostRegisterUnittests(void)
+{
RegisterHostStorageTests();
}
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 !!");
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 !!");
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;
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;
*
* \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;
*
* \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)
return 0;
}
-static void LogDropLogExitPrintStats(ThreadVars *tv, void *data) {
+static void LogDropLogExitPrintStats(ThreadVars *tv, void *data)
+{
LogDropLogThread *dlt = (LogDropLogThread *)data;
if (dlt == NULL) {
return;
#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;
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);
fprintf(fp, "<unknown>");
}
-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);
fprintf(fp, "<unknown>");
}
-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);
fprintf(fp, "<unknown>");
}
-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);
* \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. */
return TM_ECODE_OK;
}
-void LogFileLogExitPrintStats(ThreadVars *tv, void *data) {
+void LogFileLogExitPrintStats(ThreadVars *tv, void *data)
+{
LogFileLogThread *aft = (LogFileLogThread *)data;
if (aft == NULL) {
return;
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;
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);
fprintf(fp, "<unknown>");
}
-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);
fprintf(fp, "<unknown>");
}
-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);
fprintf(fp, "<unknown>");
}
-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);
fprintf(fp, "<unknown>");
}
-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+");
}
}
-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);
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;
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;
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;
/* 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 */
return TM_ECODE_OK;
}
-void LogHttpLogExitPrintStats(ThreadVars *tv, void *data) {
+void LogHttpLogExitPrintStats(ThreadVars *tv, void *data)
+{
LogHttpLogThread *aft = (LogHttpLogThread *)data;
if (aft == NULL) {
return;
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);
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)
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";
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);
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)
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)
fclose(fp);
}
-void PcapLogProfileSetup(void) {
+void PcapLogProfileSetup(void)
+{
ConfNode *conf = ConfGetNode("profiling.pcap-log");
if (conf != NULL && ConfNodeChildValueIsTrue(conf, "enabled")) {
profiling_pcaplog_enabled = 1;
* \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;
}
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];
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);
/** \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;
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;
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;
}
}
-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;
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);
*
* \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;
*
* \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) {
/** \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;
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;
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;
}
}
-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;
/** \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)
/** \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;
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;
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;
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;
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)
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 !!");
#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;
*
* \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;
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;
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) {
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) {
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) {
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) {
* \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))
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;
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;
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;
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;
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;
* \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;
}
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;
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;
* \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;
}
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;
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;
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;
/** \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)
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
return TM_ECODE_OK;
}
-void OutputJsonExitPrintStats(ThreadVars *tv, void *data) {
+void OutputJsonExitPrintStats(ThreadVars *tv, void *data)
+{
AlertJsonThread *aft = (AlertJsonThread *)data;
if (aft == NULL) {
return;
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;
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);
/** \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;
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;
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;
}
}
-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;
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);
/** \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;
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;
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;
}
}
-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;
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--;
}
* \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,
* \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);
#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) {
} \
}
-void PacketQueueValidate(PacketQueue *q) {
+void PacketQueueValidate(PacketQueue *q)
+{
if (q->len == 0) {
BUGGER_ON(q->top != NULL);
BUGGER_ON(q->bot != NULL);
}
#endif /* DEBUG */
-void PacketEnqueue (PacketQueue *q, Packet *p) {
+void PacketEnqueue (PacketQueue *q, Packet *p)
+{
//PacketQueueValidateDebug(q);
if (p == NULL)
//PacketQueueValidateDebug(q);
}
-Packet *PacketDequeue (PacketQueue *q) {
+Packet *PacketDequeue (PacketQueue *q)
+{
Packet *p = NULL;
//PacketQueueValidateDebug(q);
#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;
/* 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) {
}
/* 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);
}
}
-void PktVarFree(PktVar *pv) {
+void PktVarFree(PktVar *pv)
+{
if (pv == NULL)
return;
PktVarFree(pv_next);
}
-void PktVarPrint(PktVar *pv) {
+void PktVarPrint(PktVar *pv)
+{
uint16_t i;
if (pv == NULL)
* 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());
}
* \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)
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;
* \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;
#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;
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)
return 0;
}
-int SRepLoadCatFile(char *filename) {
+int SRepLoadCatFile(char *filename)
+{
char line[8192] = "";
Address a;
memset(&a, 0x00, sizeof(a));
return 0;
}
-static int SRepLoadFile(char *filename) {
+static int SRepLoadFile(char *filename)
+{
char line[8192] = "";
Address a;
memset(&a, 0x00, sizeof(a));
* 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;
}
#ifdef UNITTESTS
-static int SRepTest01(void) {
+static int SRepTest01(void)
+{
char str[] = "1.2.3.4,1,2";
uint32_t ip = 0;
return 1;
}
-static int SRepTest02(void) {
+static int SRepTest02(void)
+{
char str[] = "1.1.1.1,";
uint32_t ip = 0;
return 1;
}
-static int SRepTest03(void) {
+static int SRepTest03(void)
+{
char str[] = "1,Shortname,Long Name";
uint8_t cat = 0;
* \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;
* \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 */
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));
return 1;
}
-int NapatechInit(DetectEngineCtx *de_ctx, int runmode) {
+int NapatechInit(DetectEngineCtx *de_ctx, int runmode)
+{
int ret;
char errbuf[100];
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);
}
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;
* \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;
* \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;
* \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;
*
* \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;
* \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;
* \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);
TmEcode NoIPFWSupportExit(ThreadVars *, void *, void **);
-void TmModuleReceiveIPFWRegister (void) {
+void TmModuleReceiveIPFWRegister (void)
+{
tmm_modules[TMM_RECEIVEIPFW].name = "ReceiveIPFW";
tmm_modules[TMM_RECEIVEIPFW].ThreadInit = NoIPFWSupportExit;
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;
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;
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);
* \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";
* \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;
* \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;
* \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;
* \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;
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;
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;
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;
}
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;
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;
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;
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);
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;
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;
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
}
-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);
* \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;
* \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;
* \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;
}
}
#else /* WIN32 version of NFQRecvPkt */
-void NFQRecvPkt(NFQQueueVars *t, NFQThreadVars *tv) {
+void NFQRecvPkt(NFQQueueVars *t, NFQThreadVars *tv)
+{
int rv, ret;
static int timeouted = 0;
/**
* \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
/**
* \brief NFQ verdict function
*/
-TmEcode NFQSetVerdict(Packet *p) {
+TmEcode NFQSetVerdict(Packet *p)
+{
int iter = 0;
int ret = 0;
uint32_t verdict = NF_ACCEPT;
/**
* \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. */
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";
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;
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;
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;
SCReturnInt(TM_ECODE_OK);
}
-void ReceivePcapFileThreadExitStats(ThreadVars *tv, void *data) {
+void ReceivePcapFileThreadExitStats(ThreadVars *tv, void *data)
+{
SCEnter();
PcapFileThreadVars *ptv = (PcapFileThreadVars *)data;
return;
}
-TmEcode ReceivePcapFileThreadDeinit(ThreadVars *tv, void *data) {
+TmEcode ReceivePcapFileThreadDeinit(ThreadVars *tv, void *data)
+{
SCEnter();
PcapFileThreadVars *ptv = (PcapFileThreadVars *)data;
if (ptv) {
* \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;
* \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;
#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;
* \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;
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;
* \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;
* \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);
/*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;
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;
* \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;
* \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;
* \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;
* \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;
* \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);
* \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);
* \retval 0 no
* \retval 1 yes
*/
-int StreamTcpInlineMode(void) {
+int StreamTcpInlineMode(void)
+{
return stream_inline;
}
* \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) {
* \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);
#ifdef UNITTESTS
/** \test full overlap */
-static int StreamTcpInlineTest01(void) {
+static int StreamTcpInlineTest01(void)
+{
SCEnter();
uint8_t payload1[] = "AAC"; /* packet */
}
/** \test full overlap */
-static int StreamTcpInlineTest02(void) {
+static int StreamTcpInlineTest02(void)
+{
SCEnter();
uint8_t payload1[] = "xxx"; /* packet */
}
/** \test partial overlap */
-static int StreamTcpInlineTest03(void) {
+static int StreamTcpInlineTest03(void)
+{
SCEnter();
uint8_t payload1[] = "xxxxxxxxxxxx"; /* packet */
}
/** \test partial overlap */
-static int StreamTcpInlineTest04(void) {
+static int StreamTcpInlineTest04(void)
+{
SCEnter();
uint8_t payload1[] = "xxxxxxxxxxxx"; /* packet */
SCReturnInt(result);
}
/** \test partial overlap */
-static int StreamTcpInlineTest05(void) {
+static int StreamTcpInlineTest05(void)
+{
SCEnter();
uint8_t payload1[] = "xxxxxxxxxxxx"; /* packet */
}
/** \test no overlap */
-static int StreamTcpInlineTest06(void) {
+static int StreamTcpInlineTest06(void)
+{
SCEnter();
uint8_t payload1[] = "xxxxxxxxxxxx"; /* packet */
}
/** \test no overlap */
-static int StreamTcpInlineTest07(void) {
+static int StreamTcpInlineTest07(void)
+{
SCEnter();
uint8_t payload1[] = "xxxxxxxxxxxx"; /* packet */
}
#endif /* UNITTESTS */
-void StreamTcpInlineRegisterTests(void) {
+void StreamTcpInlineRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("StreamTcpInlineTest01", StreamTcpInlineTest01, 1);
UtRegisterTest("StreamTcpInlineTest02", StreamTcpInlineTest02, 1);
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;
}
*
* \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;
}
*
* \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);
* \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;
}
/** \brief clean up a tcp segment pool entry */
-void TcpSegmentPoolCleanup(void *ptr) {
+void TcpSegmentPoolCleanup(void *ptr)
+{
if (ptr == NULL)
return;
* \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;
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)) ||
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)
* \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))) {
* \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;
}
#ifdef DEBUG
-static uint64_t GetStreamSize(TcpStream *stream) {
+static uint64_t GetStreamSize(TcpStream *stream)
+{
if (stream) {
uint64_t size = 0;
uint32_t cnt = 0;
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);
*
* \param ssn TcpSession
*/
-void StreamTcpReassembleTriggerRawReassembly(TcpSession *ssn) {
+void StreamTcpReassembleTriggerRawReassembly(TcpSession *ssn)
+{
#ifdef DEBUG
BUG_ON(ssn == NULL);
#endif
#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 :
* \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();
* \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;
*
* \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;
* 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))
*/
-static int StreamTcpTestStartsAfterListSegment(TcpStream *stream) {
+static int StreamTcpTestStartsAfterListSegment(TcpStream *stream)
+{
TcpSession ssn;
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
* 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};
* 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};
* 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};
* 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,
* 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};
* 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};
* 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};
* 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,
* 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};
* 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};
* 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};
* 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,
* 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};
* 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};
* 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};
* 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,
* 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};
* 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};
* 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};
* 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,
* 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};
* 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};
* 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));
* 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,
* \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;
* \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;
* \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;
* \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;
* \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;
* \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;
* \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;
return ret;
}
-static int StreamTcpReassembleTest32(void) {
+static int StreamTcpReassembleTest32(void)
+{
TcpSession ssn;
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return ret;
}
-static int StreamTcpReassembleTest33(void) {
+static int StreamTcpReassembleTest33(void)
+{
TcpSession ssn;
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
return 1;
}
-static int StreamTcpReassembleTest34(void) {
+static int StreamTcpReassembleTest34(void)
+{
TcpSession ssn;
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
}
/** \test Test the bug 56 condition */
-static int StreamTcpReassembleTest35(void) {
+static int StreamTcpReassembleTest35(void)
+{
TcpSession ssn;
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
}
/** \test Test the bug 57 condition */
-static int StreamTcpReassembleTest36(void) {
+static int StreamTcpReassembleTest36(void)
+{
TcpSession ssn;
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL))
}
/** \test Test the bug 76 condition */
-static int StreamTcpReassembleTest37(void) {
+static int StreamTcpReassembleTest37(void)
+{
TcpSession ssn;
Flow f;
TCPHdr tcph;
*
* \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))
* \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;
* \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))
* \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))
* \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))
* \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))
* \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))
}
/** \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;
/** \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;
* 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;
* 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;
}
/** \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;
}
/** \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;
/** \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;
* 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;
* 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;
/** \test App Layer reassembly.
*/
-static int StreamTcpReassembleInlineTest10(void) {
+static int StreamTcpReassembleInlineTest10(void)
+{
int ret = 0;
TcpReassemblyThreadCtx *ra_ctx = NULL;
ThreadVars tv;
/** \test test insert with overlap
*/
-static int StreamTcpReassembleInsertTest01(void) {
+static int StreamTcpReassembleInsertTest01(void)
+{
int ret = 0;
TcpReassemblyThreadCtx *ra_ctx = NULL;
ThreadVars tv;
/** \test test insert with overlaps
*/
-static int StreamTcpReassembleInsertTest02(void) {
+static int StreamTcpReassembleInsertTest02(void)
+{
int ret = 0;
TcpReassemblyThreadCtx *ra_ctx = NULL;
ThreadVars tv;
/** \test test insert with overlaps
*/
-static int StreamTcpReassembleInsertTest03(void) {
+static int StreamTcpReassembleInsertTest03(void)
+{
int ret = 0;
TcpReassemblyThreadCtx *ra_ctx = NULL;
ThreadVars tv;
* 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);
#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);
}
#endif /* DEBUG */
-static StreamTcpSackRecord *StreamTcpSackRecordAlloc(void) {
+static StreamTcpSackRecord *StreamTcpSackRecordAlloc(void)
+{
if (StreamTcpCheckMemcap((uint32_t)sizeof(StreamTcpSackRecord)) == 0)
return NULL;
return rec;
}
-static void StreamTcpSackRecordFree(StreamTcpSackRecord *rec) {
+static void StreamTcpSackRecordFree(StreamTcpSackRecord *rec)
+{
SCFree(rec);
StreamTcpDecrMemuse((uint64_t)sizeof(*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);
* \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;
SCReturnInt(0);
}
-void StreamTcpSackPruneList(TcpStream *stream) {
+void StreamTcpSackPruneList(TcpStream *stream)
+{
SCEnter();
StreamTcpSackRecord *rec = stream->sack_head;
*
* \param stream Stream to cleanup
*/
-void StreamTcpSackFreeList(TcpStream *stream) {
+void StreamTcpSackFreeList(TcpStream *stream)
+{
SCEnter();
StreamTcpSackRecord *rec = stream->sack_head;
* \retval On success it returns 1 and on failure 0.
*/
-static int StreamTcpSackTest01 (void) {
+static int StreamTcpSackTest01 (void)
+{
TcpStream stream;
int retval = 0;
* \retval On success it returns 1 and on failure 0.
*/
-static int StreamTcpSackTest02 (void) {
+static int StreamTcpSackTest02 (void)
+{
TcpStream stream;
int retval = 0;
* \retval On success it returns 1 and on failure 0.
*/
-static int StreamTcpSackTest03 (void) {
+static int StreamTcpSackTest03 (void)
+{
TcpStream stream;
int retval = 0;
* \retval On success it returns 1 and on failure 0.
*/
-static int StreamTcpSackTest04 (void) {
+static int StreamTcpSackTest04 (void)
+{
TcpStream stream;
int retval = 0;
* \retval On success it returns 1 and on failure 0.
*/
-static int StreamTcpSackTest05 (void) {
+static int StreamTcpSackTest05 (void)
+{
TcpStream stream;
int retval = 0;
* \retval On success it returns 1 and on failure 0.
*/
-static int StreamTcpSackTest06 (void) {
+static int StreamTcpSackTest06 (void)
+{
TcpStream stream;
int retval = 0;
* \retval On success it returns 1 and on failure 0.
*/
-static int StreamTcpSackTest07 (void) {
+static int StreamTcpSackTest07 (void)
+{
TcpStream stream;
int retval = 0;
* \retval On success it returns 1 and on failure 0.
*/
-static int StreamTcpSackTest08 (void) {
+static int StreamTcpSackTest08 (void)
+{
TcpStream stream;
int retval = 0;
* \retval On success it returns 1 and on failure 0.
*/
-static int StreamTcpSackTest09 (void) {
+static int StreamTcpSackTest09 (void)
+{
TcpStream stream;
int retval = 0;
* \retval On success it returns 1 and on failure 0.
*/
-static int StreamTcpSackTest10 (void) {
+static int StreamTcpSackTest10 (void)
+{
TcpStream stream;
int retval = 0;
* \retval On success it returns 1 and on failure 0.
*/
-static int StreamTcpSackTest11 (void) {
+static int StreamTcpSackTest11 (void)
+{
TcpStream stream;
int retval = 0;
* \retval On success it returns 1 and on failure 0.
*/
-static int StreamTcpSackTest12 (void) {
+static int StreamTcpSackTest12 (void)
+{
TcpStream stream;
int retval = 0;
#endif /* UNITTESTS */
-void StreamTcpSackRegisterTests (void) {
+void StreamTcpSackRegisterTests (void)
+{
#ifdef UNITTESTS
UtRegisterTest("StreamTcpSackTest01 -- Insertion",
StreamTcpSackTest01, 1);
* 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 {
/* 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;
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;
/* tests */
-int StreamTcpUtilTest01(void) {
+int StreamTcpUtilTest01(void)
+{
int ret = 0;
TcpReassemblyThreadCtx *ra_ctx = NULL;
}
-int StreamTcpUtilStreamTest01(void) {
+int StreamTcpUtilStreamTest01(void)
+{
int ret = 0;
TcpReassemblyThreadCtx *ra_ctx = NULL;
ThreadVars tv;
return ret;
}
-int StreamTcpUtilStreamTest02(void) {
+int StreamTcpUtilStreamTest02(void)
+{
int ret = 0;
TcpReassemblyThreadCtx *ra_ctx = NULL;
ThreadVars tv;
#endif
-void StreamTcpUtilRegisterTests(void) {
+void StreamTcpUtilRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("StreamTcpUtilTest01", StreamTcpUtilTest01, 1);
UtRegisterTest("StreamTcpUtilStreamTest01", StreamTcpUtilStreamTest01, 1);
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;
* \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;
*
* \retval size stream size
*/
-uint32_t StreamTcpGetStreamSize(TcpStream *stream) {
+uint32_t StreamTcpGetStreamSize(TcpStream *stream)
+{
return (stream->last_ack - stream->isn - 1);
}
} \
}
-static int StreamTcpPacketIsRetransmission(TcpStream *stream, Packet *p) {
+static int StreamTcpPacketIsRetransmission(TcpStream *stream, Packet *p)
+{
if (p->payload_len == 0)
SCReturnInt(0);
/** \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;
/** \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;
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;
/** \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;
* 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);
*
* \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) {
* \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;
* \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;
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)
* \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;
* \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;
* \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;
* \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;
* \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;
* \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;
* \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;
* \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;
* \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))
* \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))
* \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;
* \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;
* \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;
* \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;
* \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;
* \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))
* \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))
* \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))
* \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;
* \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;
* \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;
/** \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";
}
/** \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";
}
/** \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";
}
/** \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";
}
/** \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";
*
* \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;
*
* \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;
*
* \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;
*
* \retval On success it returns 1 and on failure 0.
*/
-static int StreamTcpTest32(void) {
+static int StreamTcpTest32(void)
+{
Packet p;
Flow f;
ThreadVars tv;
* \retval On success it returns 1 and on failure 0.
*/
-static int StreamTcpTest33 (void) {
+static int StreamTcpTest33 (void)
+{
Packet p;
Flow f;
ThreadVars tv;
* \retval On success it returns 1 and on failure 0.
*/
-static int StreamTcpTest34 (void) {
+static int StreamTcpTest34 (void)
+{
Packet p;
Flow f;
ThreadVars tv;
* \retval On success it returns 1 and on failure 0.
*/
-static int StreamTcpTest35 (void) {
+static int StreamTcpTest35 (void)
+{
Packet p;
Flow f;
ThreadVars tv;
*
* \retval On success it returns 1 and on failure 0.
*/
-static int StreamTcpTest36(void) {
+static int StreamTcpTest36(void)
+{
Packet p;
Flow f;
ThreadVars tv;
*
* \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;
* \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;
* \retval On success it returns 1 and on failure 0.
*/
-static int StreamTcpTest39 (void) {
+static int StreamTcpTest39 (void)
+{
Flow f;
ThreadVars tv;
StreamTcpThread stt;
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,
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,
}
/** \test multiple different SYN/ACK, pick first */
-static int StreamTcpTest42 (void) {
+static int StreamTcpTest42 (void)
+{
int ret = 0;
Flow f;
ThreadVars tv;
}
/** \test multiple different SYN/ACK, pick second */
-static int StreamTcpTest43 (void) {
+static int StreamTcpTest43 (void)
+{
int ret = 0;
Flow f;
ThreadVars tv;
}
/** \test multiple different SYN/ACK, pick neither */
-static int StreamTcpTest44 (void) {
+static int StreamTcpTest44 (void)
+{
int ret = 0;
Flow f;
ThreadVars tv;
}
/** \test multiple different SYN/ACK, over the limit */
-static int StreamTcpTest45 (void) {
+static int StreamTcpTest45 (void)
+{
int ret = 0;
Flow f;
ThreadVars tv;
#endif /* UNITTESTS */
-void StreamTcpRegisterTests (void) {
+void StreamTcpRegisterTests (void)
+{
#ifdef UNITTESTS
UtRegisterTest("StreamTcpTest01 -- TCP session allocation",
StreamTcpTest01, 1);
* \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
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 */
SCReturn;
}
-static StreamMsg *StreamMsgDequeue (StreamMsgQueue *q) {
+static StreamMsg *StreamMsgDequeue (StreamMsgQueue *q)
+{
SCEnter();
/* if the queue is empty there are no packets left.
}
/* 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);
SCLogDebug("q->len %" PRIu32 "", q->len);
}
-void *StreamMsgPoolAlloc(void) {
+void *StreamMsgPoolAlloc(void)
+{
if (StreamTcpReassembleCheckMemcap((uint32_t)sizeof(StreamMsg)) == 0)
return NULL;
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
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, "
/** \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;
* \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 {
}
}
-uint16_t StreamMsgQueueGetMinChunkLen(uint8_t dir) {
+uint16_t StreamMsgQueueGetMinChunkLen(uint8_t dir)
+{
if (dir == FLOW_PKT_TOSERVER) {
return toserver_min_chunk_len;
} else {
}
/** \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) {
g_engine_mode = ENGINE_MODE_IDS;
}
-int RunmodeIsUnittests(void) {
+int RunmodeIsUnittests(void)
+{
if (run_mode == RUNMODE_UNITTEST)
return 1;
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;
}
* 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;
}
/* 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;
}
* 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;
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;
progname);
}
-void SCPrintBuildInfo(void) {
+void SCPrintBuildInfo(void)
+{
char *bits = "<unknown>-bits";
char *endian = "<unknown>-endian";
char features[2048] = "";
}
-TmEcode LoadYamlConfig(char *conf_filename) {
+TmEcode LoadYamlConfig(char *conf_filename)
+{
SCEnter();
if (conf_filename == NULL)
/**
* \brief Test Mutex macros
*/
-int ThreadMacrosTest01Mutex(void) {
+int ThreadMacrosTest01Mutex(void)
+{
SCMutex mut;
int r = 0;
r |= SCMutexInit(&mut, NULL);
* if a spinlock is actually locked.
*
*/
-int ThreadMacrosTest02Spinlocks(void) {
+int ThreadMacrosTest02Spinlocks(void)
+{
SCSpinlock mut;
int r = 0;
r |= SCSpinInit(&mut, 0);
/**
* \brief Test RWLock macros
*/
-int ThreadMacrosTest03RWLocks(void) {
+int ThreadMacrosTest03RWLocks(void)
+{
SCRWLock rwl_write;
int r = 0;
r |= SCRWLockInit(&rwl_write, NULL);
/**
* \brief Test RWLock macros
*/
-int ThreadMacrosTest04RWLocks(void) {
+int ThreadMacrosTest04RWLocks(void)
+{
SCRWLock rwl_read;
int r = 0;
r |= SCRWLockInit(&rwl_read, NULL);
/**
* \brief Test RWLock macros
*/
-int ThreadMacrosTest05RWLocks(void) {
+int ThreadMacrosTest05RWLocks(void)
+{
SCRWLock rwl_read;
int r = 0;
r |= SCRWLockInit(&rwl_read, NULL);
#include "threads.h"
#include "util-logopenfile.h"
-void TmModuleDebugList(void) {
+void TmModuleDebugList(void)
+{
TmModule *t;
uint16_t i;
/** \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;
/** \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;;
}
-void TmModuleRunInit(void) {
+void TmModuleRunInit(void)
+{
TmModule *t;
uint16_t i;
}
}
-void TmModuleRunDeInit(void) {
+void TmModuleRunDeInit(void)
+{
TmModule *t;
uint16_t i;
}
/** \brief register all unittests for the tm modules */
-void TmModuleRegisterTests(void) {
+void TmModuleRegisterTests(void)
+{
#ifdef UNITTESTS
TmModule *t;
uint16_t i;
#include "tmqh-flow.h"
#include "tmqh-ringbuffer.h"
-void TmqhSetup (void) {
+void TmqhSetup (void)
+{
memset(&tmqh_table, 0, sizeof(tmqh_table));
TmqhSimpleRegister();
}
/** \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++) {
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;
return NULL;
}
-Tmq* TmqCreateQueue(char *name) {
+Tmq* TmqCreateQueue(char *name)
+{
if (tmq_id >= TMQ_MAX_QUEUES)
goto error;
return NULL;
}
-Tmq* TmqGetQueueByName(char *name) {
+Tmq* TmqGetQueueByName(char *name)
+{
uint16_t i;
for (i = 0; i < tmq_id; i++) {
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 */
}
}
-void TmqResetQueues(void) {
+void TmqResetQueues(void)
+{
memset(&tmqs, 0x00, sizeof(tmqs));
tmq_id = 0;
}
*/
-void *TmThreadsSlotPktAcqLoop(void *td) {
+void *TmThreadsSlotPktAcqLoop(void *td)
+{
/* block usr2. usr2 to be handled by the main thread only */
UtilSignalBlock(SIGUSR2);
return slot;
}
-void TmSlotFree(TmSlot *tms) {
+void TmSlotFree(TmSlot *tms)
+{
SC_ATOMIC_DESTROY(tms->slot_data);
SCFree(tms);
}
}
#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);
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;
* \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;
* \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;
}
}
-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;
}
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;
}
}
-void TmqhInputSimpleShutdownHandler(ThreadVars *tv) {
+void TmqhInputSimpleShutdownHandler(ThreadVars *tv)
+{
int i;
if (tv == NULL || tv->inq == NULL) {
#endif
/* Register unittests */
-void UtilActionRegisterTests(void) {
+void UtilActionRegisterTests(void)
+{
#ifdef UNITTESTS
/* Generic tests */
UtRegisterTest("UtilActionTest01", UtilActionTest01, 1);
* \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)) {
return NULL;
}
-void BloomFilterCountingFree(BloomFilterCounting *bf) {
+void BloomFilterCountingFree(BloomFilterCounting *bf)
+{
if (bf != NULL) {
if (bf->array != NULL)
SCFree(bf->array);
}
}
-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);
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;
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;
* 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;
*/
#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;
return hash;
}
-static int BloomFilterCountingTestInit01 (void) {
+static int BloomFilterCountingTestInit01 (void)
+{
BloomFilterCounting *bf = BloomFilterCountingInit(1024, 4, 4, BloomHash);
if (bf == NULL)
return 0;
}
/* 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;
return 0;
}
-static int BloomFilterCountingTestInit03 (void) {
+static int BloomFilterCountingTestInit03 (void)
+{
int result = 0;
BloomFilterCounting *bf = BloomFilterCountingInit(1024, 4, 4, BloomHash);
if (bf == NULL)
return result;
}
-static int BloomFilterCountingTestInit04 (void) {
+static int BloomFilterCountingTestInit04 (void)
+{
BloomFilterCounting *bf = BloomFilterCountingInit(1024, 0, 4, BloomHash);
if (bf == NULL)
return 1;
return 0;
}
-static int BloomFilterCountingTestInit05 (void) {
+static int BloomFilterCountingTestInit05 (void)
+{
BloomFilterCounting *bf = BloomFilterCountingInit(0, 4, 4, BloomHash);
if (bf == NULL)
return 1;
return 0;
}
-static int BloomFilterCountingTestInit06 (void) {
+static int BloomFilterCountingTestInit06 (void)
+{
BloomFilterCounting *bf = BloomFilterCountingInit(32, 3, 4, BloomHash);
if (bf == NULL)
return 1;
return 0;
}
-static int BloomFilterCountingTestAdd01 (void) {
+static int BloomFilterCountingTestAdd01 (void)
+{
int result = 0;
BloomFilterCounting *bf = BloomFilterCountingInit(1024, 4, 4, BloomHash);
if (bf == NULL)
return result;
}
-static int BloomFilterCountingTestAdd02 (void) {
+static int BloomFilterCountingTestAdd02 (void)
+{
int result = 0;
BloomFilterCounting *bf = BloomFilterCountingInit(1024, 4, 4, BloomHash);
if (bf == NULL)
return result;
}
-static int BloomFilterCountingTestFull01 (void) {
+static int BloomFilterCountingTestFull01 (void)
+{
int result = 0;
BloomFilterCounting *bf = BloomFilterCountingInit(32, 4, 4, BloomHash);
if (bf == NULL) {
return result;
}
-static int BloomFilterCountingTestFull02 (void) {
+static int BloomFilterCountingTestFull02 (void)
+{
int result = 0;
BloomFilterCounting *bf = BloomFilterCountingInit(32, 4, 4, BloomHash);
if (bf == NULL)
}
#endif
-void BloomFilterCountingRegisterTests(void) {
+void BloomFilterCountingRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("BloomFilterCountingTestInit01", BloomFilterCountingTestInit01, 1);
UtRegisterTest("BloomFilterCountingTestInit02", BloomFilterCountingTestInit02, 1);
return NULL;
}
-void BloomFilterFree(BloomFilter *bf) {
+void BloomFilterFree(BloomFilter *bf)
+{
if (bf != NULL) {
if (bf->bitarray != NULL)
SCFree(bf->bitarray);
}
}
-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);
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;
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;
*/
#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;
return hash;
}
-static int BloomFilterTestInit01 (void) {
+static int BloomFilterTestInit01 (void)
+{
BloomFilter *bf = BloomFilterInit(1024, 4, BloomFilterTestHash);
if (bf == NULL)
return 0;
}
/* 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;
return 0;
}
-static int BloomFilterTestInit03 (void) {
+static int BloomFilterTestInit03 (void)
+{
int result = 0;
BloomFilter *bf = BloomFilterInit(1024, 4, BloomFilterTestHash);
if (bf == NULL)
return result;
}
-static int BloomFilterTestInit04 (void) {
+static int BloomFilterTestInit04 (void)
+{
BloomFilter *bf = BloomFilterInit(1024, 0, BloomFilterTestHash);
if (bf == NULL)
return 1;
return 0;
}
-static int BloomFilterTestInit05 (void) {
+static int BloomFilterTestInit05 (void)
+{
BloomFilter *bf = BloomFilterInit(0, 4, BloomFilterTestHash);
if (bf == NULL)
return 1;
return 0;
}
-static int BloomFilterTestAdd01 (void) {
+static int BloomFilterTestAdd01 (void)
+{
int result = 0;
BloomFilter *bf = BloomFilterInit(1024, 4, BloomFilterTestHash);
if (bf == NULL)
return result;
}
-static int BloomFilterTestAdd02 (void) {
+static int BloomFilterTestAdd02 (void)
+{
int result = 0;
BloomFilter *bf = BloomFilterInit(1024, 4, BloomFilterTestHash);
if (bf == NULL)
return result;
}
-static int BloomFilterTestFull01 (void) {
+static int BloomFilterTestFull01 (void)
+{
int result = 0;
BloomFilter *bf = BloomFilterInit(32, 4, BloomFilterTestHash);
if (bf == NULL)
return result;
}
-static int BloomFilterTestFull02 (void) {
+static int BloomFilterTestFull02 (void)
+{
int result = 0;
BloomFilter *bf = BloomFilterInit(32, 4, BloomFilterTestHash);
if (bf == NULL)
}
#endif /* UNITTESTS */
-void BloomFilterRegisterTests(void) {
+void BloomFilterRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("BloomFilterTestInit01", BloomFilterTestInit01, 1);
UtRegisterTest("BloomFilterTestInit02", BloomFilterTestInit02, 1);
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;
/* 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 };
return 0;
}
-static int ByteTest02 (void) {
+static int ByteTest02 (void)
+{
uint16_t val = 0x0102;
uint16_t i16 = 0xbfbf;
uint8_t bytes[2] = { 0x01, 0x02 };
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 };
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 };
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 };
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 };
return 0;
}
-static int ByteTest07 (void) {
+static int ByteTest07 (void)
+{
const char *str = "1234567890";
uint64_t val = 1234567890;
uint64_t i64 = 0xbfbfbfbfbfbfbfbfULL;
return 0;
}
-static int ByteTest08 (void) {
+static int ByteTest08 (void)
+{
const char *str = "1234567890";
uint32_t val = 1234567890;
uint32_t i32 = 0xbfbfbfbf;
return 0;
}
-static int ByteTest09 (void) {
+static int ByteTest09 (void)
+{
const char *str = "12345";
uint16_t val = 12345;
uint16_t i16 = 0xbfbf;
return 0;
}
-static int ByteTest10 (void) {
+static int ByteTest10 (void)
+{
const char *str = "123";
uint8_t val = 123;
uint8_t i8 = 0xbf;
return 0;
}
-static int ByteTest11 (void) {
+static int ByteTest11 (void)
+{
const char *str = "-1234567890";
int64_t val = -1234567890;
int64_t i64 = 0xbfbfbfbfbfbfbfbfULL;
return 0;
}
-static int ByteTest12 (void) {
+static int ByteTest12 (void)
+{
const char *str = "-1234567890";
int32_t val = -1234567890;
int32_t i32 = 0xbfbfbfbf;
return 0;
}
-static int ByteTest13 (void) {
+static int ByteTest13 (void)
+{
const char *str = "-12345";
int16_t val = -12345;
int16_t i16 = 0xbfbf;
return 0;
}
-static int ByteTest14 (void) {
+static int ByteTest14 (void)
+{
const char *str = "-123";
int8_t val = -123;
int8_t i8 = 0xbf;
}
/** \test max u32 value */
-static int ByteTest15 (void) {
+static int ByteTest15 (void)
+{
const char *str = "4294967295";
uint32_t val = 4294967295UL;
uint32_t u32 = 0xffffffff;
}
/** \test max u32 value + 1 */
-static int ByteTest16 (void) {
+static int ByteTest16 (void)
+{
const char *str = "4294967296";
uint32_t u32 = 0;
}
#endif /* UNITTESTS */
-void ByteRegisterTests(void) {
+void ByteRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("ByteTest01", ByteTest01, 1);
UtRegisterTest("ByteTest02", ByteTest02, 1);
static uint32_t cidrs[33];
-void CIDRInit(void) {
+void CIDRInit(void)
+{
int i = 0;
/* skip 0 as it will result in 0xffffffff */
}
}
-uint32_t CIDRGet(int cidr) {
+uint32_t CIDRGet(int cidr)
+{
if (cidr < 0 || cidr > 32)
return 0;
return cidrs[cidr];
/**
* \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;
}
*
* \param pid pid of the parent process to signal
*/
-static void TellWaitingParent (pid_t pid) {
+static void TellWaitingParent (pid_t pid)
+{
kill(pid, SIGUSR1);
}
*
* \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 */
* \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)
* \brief Daemonize the process
*
*/
-void Daemonize (void) {
+void Daemonize (void)
+{
pid_t pid, sid;
/* Register the signal handler */
* \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:
*
* \retval cnt the number of registered devices
*/
-int LiveGetDeviceCount(void) {
+int LiveGetDeviceCount(void)
+{
int i = 0;
LiveDevice *pd;
* \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;
* \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;
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) {
SCReturnInt(0);
}
-static int FileAppendFileData(FileContainer *ffc, FileData *ffd) {
+static int FileAppendFileData(FileContainer *ffc, FileData *ffd)
+{
SCEnter();
if (ffc == NULL) {
-static void FilePruneFile(File *file) {
+static void FilePruneFile(File *file)
+{
SCEnter();
SCLogDebug("file %p, file->chunks_cnt %"PRIu64, file, file->chunks_cnt);
SCReturn;
}
-void FilePrune(FileContainer *ffc) {
+void FilePrune(FileContainer *ffc)
+{
File *file;
for (file = ffc->head; file != NULL; file = file->next) {
* \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");
*
* \param ffc FileContainer
*/
-void FileContainerRecycle(FileContainer *ffc) {
+void FileContainerRecycle(FileContainer *ffc)
+{
if (ffc == NULL)
return;
*
* \param ffc FileContainer
*/
-void FileContainerFree(FileContainer *ffc) {
+void FileContainerFree(FileContainer *ffc)
+{
if (ffc == NULL)
return;
*
* \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;
*
* \param ffd the flow file data object to free
*/
-static void FileDataFree(FileData *ffd) {
+static void FileDataFree(FileData *ffd)
+{
if (ffd == NULL)
return;
*
* \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");
return new;
}
-static void FileFree(File *ff) {
+static void FileFree(File *ff)
+{
if (ff == NULL)
return;
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 {
*
* \param ff The file to store
*/
-int FileStore(File *ff) {
+int FileStore(File *ff)
+{
ff->flags |= FILE_STORE;
SCReturnInt(0);
}
* \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;
* \retval 0 limit not reached yet
* \retval 1 limit reached
*/
-static int FileStoreNoStoreCheck(File *ff) {
+static int FileStoreNoStoreCheck(File *ff)
+{
SCEnter();
if (ff == NULL) {
* \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) {
* \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();
* \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();
* \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();
* \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();
*
* \param ff file
*/
-void FileDisableStoringForFile(File *ff) {
+void FileDisableStoringForFile(File *ff)
+{
SCEnter();
if (ff == NULL) {
* \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);
* \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();
}
}
-void FileStoreAllFilesForTx(FileContainer *fc, uint16_t tx_id) {
+void FileStoreAllFilesForTx(FileContainer *fc, uint16_t tx_id)
+{
File *ptr = NULL;
SCEnter();
}
}
-void FileStoreAllFiles(FileContainer *fc) {
+void FileStoreAllFiles(FileContainer *fc)
+{
File *ptr = NULL;
SCEnter();
}
}
-void FileTruncateAllOpenFiles(FileContainer *fc) {
+void FileTruncateAllOpenFiles(FileContainer *fc)
+{
File *ptr = NULL;
SCEnter();
* \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;
* \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;
* \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;
* \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;
* \param handler pointer to the memfile
* \retval 0 on succesful
*/
-static int CloseFn(void *handler) {
+static int CloseFn(void *handler)
+{
SCFree(handler);
return 0;
}
* \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;
return NULL;
}
-void HashTableFree(HashTable *ht) {
+void HashTableFree(HashTable *ht)
+{
uint32_t i = 0;
if (ht == NULL)
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;
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) {
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)
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;
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;
*/
#ifdef UNITTESTS
-static int HashTableTestInit01 (void) {
+static int HashTableTestInit01 (void)
+{
HashTable *ht = HashTableInit(1024, HashTableGenericHash, NULL, NULL);
if (ht == NULL)
return 0;
}
/* 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;
return 0;
}
-static int HashTableTestInit03 (void) {
+static int HashTableTestInit03 (void)
+{
int result = 0;
HashTable *ht = HashTableInit(1024, HashTableGenericHash, NULL, NULL);
if (ht == NULL)
return result;
}
-static int HashTableTestInit04 (void) {
+static int HashTableTestInit04 (void)
+{
HashTable *ht = HashTableInit(0, HashTableGenericHash, NULL, NULL);
if (ht == NULL)
return 1;
return 0;
}
-static int HashTableTestInit05 (void) {
+static int HashTableTestInit05 (void)
+{
int result = 0;
HashTable *ht = HashTableInit(1024, HashTableGenericHash, NULL, NULL);
if (ht == NULL)
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;
return 1;
}
-static int HashTableTestInit06 (void) {
+static int HashTableTestInit06 (void)
+{
int result = 0;
HashTable *ht = HashTableInit(1024, HashTableGenericHash, HashTableDefaultCompareTest, NULL);
if (ht == NULL)
return result;
}
-static int HashTableTestAdd01 (void) {
+static int HashTableTestAdd01 (void)
+{
int result = 0;
HashTable *ht = HashTableInit(32, HashTableGenericHash, NULL, NULL);
if (ht == NULL)
return result;
}
-static int HashTableTestAdd02 (void) {
+static int HashTableTestAdd02 (void)
+{
int result = 0;
HashTable *ht = HashTableInit(32, HashTableGenericHash, NULL, NULL);
if (ht == NULL)
return result;
}
-static int HashTableTestFull01 (void) {
+static int HashTableTestFull01 (void)
+{
int result = 0;
HashTable *ht = HashTableInit(32, HashTableGenericHash, NULL, NULL);
if (ht == NULL)
return result;
}
-static int HashTableTestFull02 (void) {
+static int HashTableTestFull02 (void)
+{
int result = 0;
HashTable *ht = HashTableInit(32, HashTableGenericHash, NULL, NULL);
if (ht == NULL)
}
#endif
-void HashTableRegisterTests(void) {
+void HashTableRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("HashTableTestInit01", HashTableTestInit01, 1);
UtRegisterTest("HashTableTestInit02", HashTableTestInit02, 1);
return NULL;
}
-void HashListTableFree(HashListTable *ht) {
+void HashListTableFree(HashListTable *ht)
+{
uint32_t i = 0;
if (ht == NULL)
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;
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);
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;
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");
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;
return hash;
}
-HashListTableBucket *HashListTableGetListHead(HashListTable *ht) {
+HashListTableBucket *HashListTableGetListHead(HashListTable *ht)
+{
return ht->listhead;
}
*/
#ifdef UNITTESTS
-static int HashListTableTestInit01 (void) {
+static int HashListTableTestInit01 (void)
+{
HashListTable *ht = HashListTableInit(1024, HashListTableGenericHash, NULL, NULL);
if (ht == NULL)
return 0;
}
/* 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;
return 0;
}
-static int HashListTableTestInit03 (void) {
+static int HashListTableTestInit03 (void)
+{
int result = 0;
HashListTable *ht = HashListTableInit(1024, HashListTableGenericHash, NULL, NULL);
if (ht == NULL)
return result;
}
-static int HashListTableTestInit04 (void) {
+static int HashListTableTestInit04 (void)
+{
HashListTable *ht = HashListTableInit(0, HashListTableGenericHash, NULL, NULL);
if (ht == NULL)
return 1;
return 0;
}
-static int HashListTableTestAdd01 (void) {
+static int HashListTableTestAdd01 (void)
+{
int result = 0;
HashListTable *ht = HashListTableInit(32, HashListTableGenericHash, NULL, NULL);
if (ht == NULL)
return result;
}
-static int HashListTableTestAdd02 (void) {
+static int HashListTableTestAdd02 (void)
+{
int result = 0;
HashListTable *ht = HashListTableInit(32, HashListTableGenericHash, NULL, NULL);
if (ht == NULL)
return result;
}
-static int HashListTableTestAdd03 (void) {
+static int HashListTableTestAdd03 (void)
+{
int result = 0;
HashListTable *ht = HashListTableInit(32, HashListTableGenericHash, NULL, NULL);
if (ht == NULL)
return result;
}
-static int HashListTableTestAdd04 (void) {
+static int HashListTableTestAdd04 (void)
+{
int result = 0;
HashListTable *ht = HashListTableInit(32, HashListTableGenericHash, NULL, NULL);
if (ht == NULL)
return result;
}
-static int HashListTableTestFull01 (void) {
+static int HashListTableTestFull01 (void)
+{
int result = 0;
HashListTable *ht = HashListTableInit(32, HashListTableGenericHash, NULL, NULL);
if (ht == NULL)
return result;
}
-static int HashListTableTestFull02 (void) {
+static int HashListTableTestFull02 (void)
+{
int result = 0;
HashListTable *ht = HashListTableInit(32, HashListTableGenericHash, NULL, NULL);
if (ht == NULL)
}
#endif /* UNITTESTS */
-void HashListTableRegisterTests(void) {
+void HashListTableRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("HashListTableTestInit01", HashListTableTestInit01, 1);
UtRegisterTest("HashListTableTestInit02", HashListTableTestInit02, 1);
/* UNITTESTS */
#ifdef UNITTESTS
-static int MemcmpTest01 (void) {
+static int MemcmpTest01 (void)
+{
uint8_t a[] = "abcd";
uint8_t b[] = "abcd";
return 1;
}
-static int MemcmpTest02 (void) {
+static int MemcmpTest02 (void)
+{
uint8_t a[] = "abcdabcdabcdabcd";
uint8_t b[] = "abcdabcdabcdabcd";
return 1;
}
-static int MemcmpTest03 (void) {
+static int MemcmpTest03 (void)
+{
uint8_t a[] = "abcdabcd";
uint8_t b[] = "abcdabcd";
return 1;
}
-static int MemcmpTest04 (void) {
+static int MemcmpTest04 (void)
+{
uint8_t a[] = "abcd";
uint8_t b[] = "abcD";
return 1;
}
-static int MemcmpTest05 (void) {
+static int MemcmpTest05 (void)
+{
uint8_t a[] = "abcdabcdabcdabcd";
uint8_t b[] = "abcDabcdabcdabcd";
return 1;
}
-static int MemcmpTest06 (void) {
+static int MemcmpTest06 (void)
+{
uint8_t a[] = "abcdabcd";
uint8_t b[] = "abcDabcd";
return 1;
}
-static int MemcmpTest07 (void) {
+static int MemcmpTest07 (void)
+{
uint8_t a[] = "abcd";
uint8_t b[] = "abcde";
return 1;
}
-static int MemcmpTest08 (void) {
+static int MemcmpTest08 (void)
+{
uint8_t a[] = "abcdabcdabcdabcd";
uint8_t b[] = "abcdabcdabcdabcde";
return 1;
}
-static int MemcmpTest09 (void) {
+static int MemcmpTest09 (void)
+{
uint8_t a[] = "abcdabcd";
uint8_t b[] = "abcdabcde";
return 1;
}
-static int MemcmpTest10 (void) {
+static int MemcmpTest10 (void)
+{
uint8_t a[] = "abcd";
uint8_t b[] = "Zbcde";
return 1;
}
-static int MemcmpTest11 (void) {
+static int MemcmpTest11 (void)
+{
uint8_t a[] = "abcdabcdabcdabcd";
uint8_t b[] = "Zbcdabcdabcdabcde";
return 1;
}
-static int MemcmpTest12 (void) {
+static int MemcmpTest12 (void)
+{
uint8_t a[] = "abcdabcd";
uint8_t b[] = "Zbcdabcde";
return 1;
}
-static int MemcmpTest13 (void) {
+static int MemcmpTest13 (void)
+{
uint8_t a[] = "abcdefgh";
uint8_t b[] = "AbCdEfGhIjK";
#define TEST_RUNS 1000000
-static int MemcmpTest14 (void) {
+static int MemcmpTest14 (void)
+{
#ifdef PROFILING
uint64_t ticks_start = 0;
uint64_t ticks_end = 0;
return 1;
}
-static int MemcmpTest15 (void) {
+static int MemcmpTest15 (void)
+{
#ifdef PROFILING
uint64_t ticks_start = 0;
uint64_t ticks_end = 0;
return 1;
}
-static int MemcmpTest16 (void) {
+static int MemcmpTest16 (void)
+{
#ifdef PROFILING
uint64_t ticks_start = 0;
uint64_t ticks_end = 0;
return 1;
}
-static int MemcmpTest17 (void) {
+static int MemcmpTest17 (void)
+{
#ifdef PROFILING
uint64_t ticks_start = 0;
uint64_t ticks_end = 0;
#endif /* UNITTESTS */
-void MemcmpRegisterTests(void) {
+void MemcmpRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("MemcmpTest01", MemcmpTest01, 1);
UtRegisterTest("MemcmpTest02", MemcmpTest02, 1);
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
#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;
#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;
#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;
#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;
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);
}
#endif /* HAVE_MEMRCHR */
#ifdef UNITTESTS
-static int MemrchrTest01 (void) {
+static int MemrchrTest01 (void)
+{
char *haystack = "abcabc";
char needle = 'b';
}
#endif
-void MemrchrRegisterTests(void) {
+void MemrchrRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("MemrchrTest01", MemrchrTest01, 1);
#endif
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;
}
}
-void ParseSizeDeinit(void) {
+void ParseSizeDeinit(void)
+{
if (parse_regex != NULL)
pcre_free(parse_regex);
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;
}
#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++) {
}
#endif
-void B2gPrintInfo(MpmCtx *mpm_ctx) {
+void B2gPrintInfo(MpmCtx *mpm_ctx)
+{
B2gCtx *ctx = (B2gCtx *)mpm_ctx->ctx;
printf("MPM B2g Information:\n");
* 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;
}
static inline B2gPattern *
-B2gAllocHashItem(MpmCtx *mpm_ctx) {
+B2gAllocHashItem(MpmCtx *mpm_ctx)
+{
B2gPattern *hi = SCMalloc(sizeof(B2gPattern));
if (unlikely(hi == NULL))
return NULL;
return hi;
}
-static void B2gHashFree(MpmCtx *mpm_ctx, B2gPattern *hi) {
+static void B2gHashFree(MpmCtx *mpm_ctx, B2gPattern *hi)
+{
if (hi == NULL)
return;
/*
* 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];
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];
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);
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]);
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;
* 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--;
*
* \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);
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);
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;
return;
}
-int B2gBuildMatchArray(MpmCtx *mpm_ctx) {
+int B2gBuildMatchArray(MpmCtx *mpm_ctx)
+{
SCEnter();
B2gCtx *ctx = (B2gCtx *)mpm_ctx->ctx;
SCReturnInt(0);
}
-int B2gPreparePatterns(MpmCtx *mpm_ctx) {
+int B2gPreparePatterns(MpmCtx *mpm_ctx)
+{
B2gCtx *ctx = (B2gCtx *)mpm_ctx->ctx;
/* alloc the pattern array */
return -1;
}
-void B2gPrintSearchStats(MpmThreadCtx *mpm_thread_ctx) {
+void B2gPrintSearchStats(MpmThreadCtx *mpm_thread_ctx)
+{
#ifdef B2G_COUNTERS
B2gThreadCtx *tctx = (B2gThreadCtx *)mpm_thread_ctx->ctx;
}
}
-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)
SCReturn;
}
-void B2gDestroyCtx(MpmCtx *mpm_ctx) {
+void B2gDestroyCtx(MpmCtx *mpm_ctx)
+{
SCLogDebug("mpm_ctx %p", mpm_ctx);
B2gCtx *ctx = (B2gCtx *)mpm_ctx->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 */
}
}
-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);
}
}
-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;
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;
}
#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;
}
#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;
*/
#ifdef UNITTESTS
-static int B2gTestInit01 (void) {
+static int B2gTestInit01 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
}
#if 0
-static int B2gTestS0Init01 (void) {
+static int B2gTestS0Init01 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
return result;
}
-static int B2gTestS0Init02 (void) {
+static int B2gTestS0Init02 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
return result;
}
-static int B2gTestS0Init03 (void) {
+static int B2gTestS0Init03 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
return result;
}
-static int B2gTestS0Init04 (void) {
+static int B2gTestS0Init04 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
return result;
}
-static int B2gTestS0Init05 (void) {
+static int B2gTestS0Init05 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
}
#endif
-static int B2gTestSearch01 (void) {
+static int B2gTestSearch01 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gTestSearch02 (void) {
+static int B2gTestSearch02 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gTestSearch03 (void) {
+static int B2gTestSearch03 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
}
/* 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));
}
/* 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));
return result;
}
-static int B2gTestSearch05a (void) {
+static int B2gTestSearch05a (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gTestSearch06 (void) {
+static int B2gTestSearch06 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gTestSearch07 (void) {
+static int B2gTestSearch07 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gTestSearch08 (void) {
+static int B2gTestSearch08 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gTestSearch09 (void) {
+static int B2gTestSearch09 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gTestSearch10 (void) {
+static int B2gTestSearch10 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gTestSearch11 (void) {
+static int B2gTestSearch11 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gTestSearch12 (void) {
+static int B2gTestSearch12 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gTestSearch13 (void) {
+static int B2gTestSearch13 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gTestSearch14 (void) {
+static int B2gTestSearch14 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gTestSearch15 (void) {
+static int B2gTestSearch15 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gTestSearch16 (void) {
+static int B2gTestSearch16 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gTestSearch17 (void) {
+static int B2gTestSearch17 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gTestSearch18 (void) {
+static int B2gTestSearch18 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gTestSearch19 (void) {
+static int B2gTestSearch19 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gTestSearch20 (void) {
+static int B2gTestSearch20 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gTestSearch21 (void) {
+static int B2gTestSearch21 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
#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;
}
#endif
-void B2gRegisterTests(void) {
+void B2gRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("B2gTestInit01", B2gTestInit01, 1);
/*
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;
}
#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++) {
}
#endif
-void B2gcPrintInfo(MpmCtx *mpm_ctx) {
+void B2gcPrintInfo(MpmCtx *mpm_ctx)
+{
B2gcCtx *ctx = (B2gcCtx *)mpm_ctx->ctx;
printf("MPM B2gc Information:\n");
}
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
}
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
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;
/** \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);
* \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);
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);
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);
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);
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);
}
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));
return 1;
}
-static void B2gcHashPatternFree(void *pattern) {
+static void B2gcHashPatternFree(void *pattern)
+{
B2gcPattern *p = (B2gcPattern *)pattern;
SCFree(p->pat);
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) {
}
}
-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;
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;
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]);
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;
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 */
return 0;
}
-void B2gcPrintSearchStats(MpmThreadCtx *mpm_thread_ctx) {
+void B2gcPrintSearchStats(MpmThreadCtx *mpm_thread_ctx)
+{
#ifdef B2GC_COUNTERS
B2gcThreadCtx *tctx = (B2gcThreadCtx *)mpm_thread_ctx->ctx;
}
}
-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)
SCReturn;
}
-void B2gcDestroyCtx(MpmCtx *mpm_ctx) {
+void B2gcDestroyCtx(MpmCtx *mpm_ctx)
+{
SCLogDebug("mpm_ctx %p", 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 */
}
}
-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);
}
}
-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;
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;
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;
*/
#ifdef UNITTESTS
-static int B2gcTestMacro01 (void) {
+static int B2gcTestMacro01 (void)
+{
int result = 1;
B2gcPatternHdr a;
return result;
}
-static int B2gcTestInit01 (void) {
+static int B2gcTestInit01 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
}
#if 0
-static int B2gcTestS0Init01 (void) {
+static int B2gcTestS0Init01 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2GC);
return result;
}
-static int B2gcTestS0Init02 (void) {
+static int B2gcTestS0Init02 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2GC);
return result;
}
-static int B2gcTestS0Init03 (void) {
+static int B2gcTestS0Init03 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2GC);
return result;
}
-static int B2gcTestS0Init04 (void) {
+static int B2gcTestS0Init04 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2GC);
return result;
}
-static int B2gcTestS0Init05 (void) {
+static int B2gcTestS0Init05 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2GC);
}
#endif
-static int B2gcTestSearch01 (void) {
+static int B2gcTestSearch01 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gcTestSearch02 (void) {
+static int B2gcTestSearch02 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gcTestSearch03 (void) {
+static int B2gcTestSearch03 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
}
/* 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));
}
/* 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));
return result;
}
-static int B2gcTestSearch05a (void) {
+static int B2gcTestSearch05a (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gcTestSearch05b (void) {
+static int B2gcTestSearch05b (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gcTestSearch05c (void) {
+static int B2gcTestSearch05c (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gcTestSearch05d (void) {
+static int B2gcTestSearch05d (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gcTestSearch06 (void) {
+static int B2gcTestSearch06 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gcTestSearch06a (void) {
+static int B2gcTestSearch06a (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gcTestSearch07 (void) {
+static int B2gcTestSearch07 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gcTestSearch07a (void) {
+static int B2gcTestSearch07a (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gcTestSearch08 (void) {
+static int B2gcTestSearch08 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gcTestSearch09 (void) {
+static int B2gcTestSearch09 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gcTestSearch10 (void) {
+static int B2gcTestSearch10 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gcTestSearch11 (void) {
+static int B2gcTestSearch11 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gcTestSearch12 (void) {
+static int B2gcTestSearch12 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gcTestSearch13 (void) {
+static int B2gcTestSearch13 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gcTestSearch14 (void) {
+static int B2gcTestSearch14 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gcTestSearch15 (void) {
+static int B2gcTestSearch15 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gcTestSearch16 (void) {
+static int B2gcTestSearch16 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gcTestSearch17 (void) {
+static int B2gcTestSearch17 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gcTestSearch18 (void) {
+static int B2gcTestSearch18 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gcTestSearch19 (void) {
+static int B2gcTestSearch19 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gcTestSearch20 (void) {
+static int B2gcTestSearch20 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gcTestSearch21 (void) {
+static int B2gcTestSearch21 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
#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;
}
#endif
-void B2gcRegisterTests(void) {
+void B2gcRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("B2gcTestMacro01", B2gcTestMacro01, 1);
UtRegisterTest("B2gcTestInit01", B2gcTestInit01, 1);
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;
}
#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++) {
}
#endif
-void B2gmPrintInfo(MpmCtx *mpm_ctx) {
+void B2gmPrintInfo(MpmCtx *mpm_ctx)
+{
B2gmCtx *ctx = (B2gmCtx *)mpm_ctx->ctx;
printf("MPM B2gm Information:\n");
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;
}
static inline B2gmPattern *
-B2gmAllocHashItem(MpmCtx *mpm_ctx) {
+B2gmAllocHashItem(MpmCtx *mpm_ctx)
+{
B2gmPattern *hi = SCMalloc(sizeof(B2gmPattern));
if (unlikely(hi == NULL))
return NULL;
return hi;
}
-static void B2gmHashFree(MpmCtx *mpm_ctx, B2gmPattern *hi) {
+static void B2gmHashFree(MpmCtx *mpm_ctx, B2gmPattern *hi)
+{
if (hi == NULL)
return;
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]);
/*
* 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];
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];
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) {
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) {
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;
* 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);
* \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);
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);
}
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));
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);
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) {
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;
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) {
}
}
-int B2gmBuildMatchArray(MpmCtx *mpm_ctx) {
+int B2gmBuildMatchArray(MpmCtx *mpm_ctx)
+{
SCEnter();
B2gmCtx *ctx = (B2gmCtx *)mpm_ctx->ctx;
SCReturnInt(0);
}
-int B2gmPreparePatterns(MpmCtx *mpm_ctx) {
+int B2gmPreparePatterns(MpmCtx *mpm_ctx)
+{
B2gmCtx *ctx = (B2gmCtx *)mpm_ctx->ctx;
/* alloc the lookup array */
return -1;
}
-void B2gmPrintSearchStats(MpmThreadCtx *mpm_thread_ctx) {
+void B2gmPrintSearchStats(MpmThreadCtx *mpm_thread_ctx)
+{
#ifdef B2GM_COUNTERS
B2gmThreadCtx *tctx = (B2gmThreadCtx *)mpm_thread_ctx->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
}
}
-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);
SCReturn;
}
-void B2gmDestroyCtx(MpmCtx *mpm_ctx) {
+void B2gmDestroyCtx(MpmCtx *mpm_ctx)
+{
SCLogDebug("mpm_ctx %p", mpm_ctx);
B2gmCtx *ctx = (B2gmCtx *)mpm_ctx->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 */
}
}
-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);
}
}
-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;
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;
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;
*/
#ifdef UNITTESTS
-static int B2gmTestInit01 (void) {
+static int B2gmTestInit01 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
}
#if 0
-static int B2gmTestS0Init01 (void) {
+static int B2gmTestS0Init01 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2GM);
return result;
}
-static int B2gmTestS0Init02 (void) {
+static int B2gmTestS0Init02 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2GM);
return result;
}
-static int B2gmTestS0Init03 (void) {
+static int B2gmTestS0Init03 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2GM);
return result;
}
-static int B2gmTestS0Init04 (void) {
+static int B2gmTestS0Init04 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2GM);
return result;
}
-static int B2gmTestS0Init05 (void) {
+static int B2gmTestS0Init05 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2GM);
}
#endif
-static int B2gmTestSearch01 (void) {
+static int B2gmTestSearch01 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gmTestSearch02 (void) {
+static int B2gmTestSearch02 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gmTestSearch02a (void) {
+static int B2gmTestSearch02a (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gmTestSearch02b (void) {
+static int B2gmTestSearch02b (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gmTestSearch03 (void) {
+static int B2gmTestSearch03 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gmTestSearch03a (void) {
+static int B2gmTestSearch03a (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
}
/* 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));
}
/* 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));
return result;
}
-static int B2gmTestSearch05a (void) {
+static int B2gmTestSearch05a (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gmTestSearch06 (void) {
+static int B2gmTestSearch06 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gmTestSearch07 (void) {
+static int B2gmTestSearch07 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gmTestSearch08 (void) {
+static int B2gmTestSearch08 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gmTestSearch09 (void) {
+static int B2gmTestSearch09 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gmTestSearch10 (void) {
+static int B2gmTestSearch10 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gmTestSearch11 (void) {
+static int B2gmTestSearch11 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gmTestSearch12 (void) {
+static int B2gmTestSearch12 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gmTestSearch13 (void) {
+static int B2gmTestSearch13 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gmTestSearch14 (void) {
+static int B2gmTestSearch14 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gmTestSearch15 (void) {
+static int B2gmTestSearch15 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gmTestSearch16 (void) {
+static int B2gmTestSearch16 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gmTestSearch17 (void) {
+static int B2gmTestSearch17 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gmTestSearch18 (void) {
+static int B2gmTestSearch18 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gmTestSearch19 (void) {
+static int B2gmTestSearch19 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gmTestSearch20 (void) {
+static int B2gmTestSearch20 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B2gmTestSearch21 (void) {
+static int B2gmTestSearch21 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
#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;
}
#endif
-void B2gmRegisterTests(void) {
+void B2gmRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("B2gmTestInit01", B2gmTestInit01, 1);
/*
/** \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++) {
}
#endif
-void B3gPrintInfo(MpmCtx *mpm_ctx) {
+void B3gPrintInfo(MpmCtx *mpm_ctx)
+{
B3gCtx *ctx = (B3gCtx *)mpm_ctx->ctx;
printf("MPM B3g Information:\n");
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;
}
static inline B3gHashItem *
-B3gAllocHashItem(MpmCtx *mpm_ctx) {
+B3gAllocHashItem(MpmCtx *mpm_ctx)
+{
B3gHashItem *hi = SCMalloc(sizeof(B3gHashItem));
if (unlikely(hi == NULL))
return NULL;
return hi;
}
-static void B3gHashFree(MpmCtx *mpm_ctx, B3gHashItem *hi) {
+static void B3gHashFree(MpmCtx *mpm_ctx, B3gHashItem *hi)
+{
if (hi == NULL)
return;
/*
* 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];
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];
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);
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]);
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;
* 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--;
* 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)
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);
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;
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);
return 0;
}
-int B3gPreparePatterns(MpmCtx *mpm_ctx) {
+int B3gPreparePatterns(MpmCtx *mpm_ctx)
+{
B3gCtx *ctx = (B3gCtx *)mpm_ctx->ctx;
/* alloc the pattern array */
return -1;
}
-void B3gPrintSearchStats(MpmThreadCtx *mpm_thread_ctx) {
+void B3gPrintSearchStats(MpmThreadCtx *mpm_thread_ctx)
+{
#ifdef B3G_COUNTERS
B3gThreadCtx *tctx = (B3gThreadCtx *)mpm_thread_ctx->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
}
}
-void B3gInitCtx (MpmCtx *mpm_ctx) {
+void B3gInitCtx (MpmCtx *mpm_ctx)
+{
//printf("B3gInitCtx: mpm_ctx %p\n", mpm_ctx);
mpm_ctx->ctx = SCMalloc(sizeof(B3gCtx));
ctx->Search = b3g_func;
}
-void B3gDestroyCtx(MpmCtx *mpm_ctx) {
+void B3gDestroyCtx(MpmCtx *mpm_ctx)
+{
B3gCtx *ctx = (B3gCtx *)mpm_ctx->ctx;
if (ctx == NULL)
return;
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 */
}
}
-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);
}
}
-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;
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;
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;
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;
}
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;
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;
*/
#ifdef UNITTESTS
-static int B3gTestInit01 (void) {
+static int B3gTestInit01 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
}
#if 0
-static int B3gTestS0Init01 (void) {
+static int B3gTestS0Init01 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B3gTestS0Init02 (void) {
+static int B3gTestS0Init02 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B3gTestS0Init03 (void) {
+static int B3gTestS0Init03 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B3gTestS0Init04 (void) {
+static int B3gTestS0Init04 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B3gTestS0Init05 (void) {
+static int B3gTestS0Init05 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
}
#endif
-static int B3gTestSearch01 (void) {
+static int B3gTestSearch01 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B3gTestSearch02 (void) {
+static int B3gTestSearch02 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B3gTestSearch03 (void) {
+static int B3gTestSearch03 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
}
/* 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));
}
/* 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));
return result;
}
-static int B3gTestSearch06 (void) {
+static int B3gTestSearch06 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B3gTestSearch07 (void) {
+static int B3gTestSearch07 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B3gTestSearch08 (void) {
+static int B3gTestSearch08 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B3gTestSearch09 (void) {
+static int B3gTestSearch09 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B3gTestSearch10 (void) {
+static int B3gTestSearch10 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B3gTestSearch11 (void) {
+static int B3gTestSearch11 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int B3gTestSearch12 (void) {
+static int B3gTestSearch12 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
#endif /* UNITTESTS */
-void B3gRegisterTests(void) {
+void B3gRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("B3gTestInit01", B3gTestInit01, 1);
/*
#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++) {
//printf("\n");
}
-void WmPrintInfo(MpmCtx *mpm_ctx) {
+void WmPrintInfo(MpmCtx *mpm_ctx)
+{
WmCtx *ctx = (WmCtx *)mpm_ctx->ctx;
printf("MPM WuManber Information:\n");
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;
}
static inline WmHashItem *
-WmAllocHashItem(MpmCtx *mpm_ctx) {
+WmAllocHashItem(MpmCtx *mpm_ctx)
+{
WmHashItem *hi = SCMalloc(sizeof(WmHashItem));
if (unlikely(hi == NULL))
return NULL;
return hi;
}
-static void WmHashFree(MpmCtx *mpm_ctx, WmHashItem *hi) {
+static void WmHashFree(MpmCtx *mpm_ctx, WmHashItem *hi)
+{
if (hi == NULL)
return;
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]);
/*
* 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];
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];
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);
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]);
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;
* 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--;
* 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);
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);
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;
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;
}
}
-int WmPreparePatterns(MpmCtx *mpm_ctx) {
+int WmPreparePatterns(MpmCtx *mpm_ctx)
+{
WmCtx *ctx = (WmCtx *)mpm_ctx->ctx;
/* alloc the pattern array */
return -1;
}
-void WmPrintSearchStats(MpmThreadCtx *mpm_thread_ctx) {
+void WmPrintSearchStats(MpmThreadCtx *mpm_thread_ctx)
+{
#ifdef WUMANBER_COUNTERS
WmThreadCtx *tctx = (WmThreadCtx *)mpm_thread_ctx->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
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;
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;
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;
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;
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;
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;
}
}
-void WmInitCtx (MpmCtx *mpm_ctx) {
+void WmInitCtx (MpmCtx *mpm_ctx)
+{
SCLogDebug("mpm_ctx %p", mpm_ctx);
mpm_ctx->ctx = SCMalloc(sizeof(WmCtx));
}
-void WmDestroyCtx(MpmCtx *mpm_ctx) {
+void WmDestroyCtx(MpmCtx *mpm_ctx)
+{
WmCtx *ctx = (WmCtx *)mpm_ctx->ctx;
if (ctx == NULL)
return;
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
#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--;
}
}
-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;
*/
#ifdef UNITTESTS
-int WmTestInitCtx01 (void) {
+int WmTestInitCtx01 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestInitCtx02 (void) {
+int WmTestInitCtx02 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestInitCtx03 (void) {
+int WmTestInitCtx03 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestThreadInitCtx01 (void) {
+int WmTestThreadInitCtx01 (void)
+{
#ifdef WUMANBER_COUNTERS
int result = 0;
MpmCtx mpm_ctx;
#endif
}
-int WmTestThreadInitCtx02 (void) {
+int WmTestThreadInitCtx02 (void)
+{
#ifdef WUMANBER_COUNTERS
int result = 0;
MpmCtx mpm_ctx;
return result;
}
-int WmTestInitAddPattern01 (void) {
+int WmTestInitAddPattern01 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestInitAddPattern02 (void) {
+int WmTestInitAddPattern02 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestInitAddPattern03 (void) {
+int WmTestInitAddPattern03 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestInitAddPattern04 (void) {
+int WmTestInitAddPattern04 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestInitAddPattern05 (void) {
+int WmTestInitAddPattern05 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestInitAddPattern06 (void) {
+int WmTestInitAddPattern06 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestPrepare01 (void) {
+int WmTestPrepare01 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestPrepare02 (void) {
+int WmTestPrepare02 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestPrepare03 (void) {
+int WmTestPrepare03 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestPrepare04 (void) {
+int WmTestPrepare04 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestPrepare05 (void) {
+int WmTestPrepare05 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestPrepare06 (void) {
+int WmTestPrepare06 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestSearch01 (void) {
+int WmTestSearch01 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestSearch01Hash12 (void) {
+int WmTestSearch01Hash12 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestSearch01Hash14 (void) {
+int WmTestSearch01Hash14 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestSearch01Hash15 (void) {
+int WmTestSearch01Hash15 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestSearch01Hash16 (void) {
+int WmTestSearch01Hash16 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestSearch02 (void) {
+int WmTestSearch02 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestSearch03 (void) {
+int WmTestSearch03 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestSearch04 (void) {
+int WmTestSearch04 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestSearch05 (void) {
+int WmTestSearch05 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestSearch06 (void) {
+int WmTestSearch06 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestSearch07 (void) {
+int WmTestSearch07 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestSearch08 (void) {
+int WmTestSearch08 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestSearch09 (void) {
+int WmTestSearch09 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestSearch10 (void) {
+int WmTestSearch10 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestSearch11 (void) {
+int WmTestSearch11 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestSearch12 (void) {
+int WmTestSearch12 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestSearch13 (void) {
+int WmTestSearch13 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestSearch14 (void) {
+int WmTestSearch14 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
/** \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));
return result;
}
-int WmTestSearch16 (void) {
+int WmTestSearch16 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestSearch17 (void) {
+int WmTestSearch17 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestSearch18Hash12 (void) {
+int WmTestSearch18Hash12 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestSearch18Hash14 (void) {
+int WmTestSearch18Hash14 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestSearch18Hash15 (void) {
+int WmTestSearch18Hash15 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestSearch18 (void) {
+int WmTestSearch18 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestSearch18Hash16 (void) {
+int WmTestSearch18Hash16 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestSearch19 (void) {
+int WmTestSearch19 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestSearch19Hash12 (void) {
+int WmTestSearch19Hash12 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestSearch19Hash14 (void) {
+int WmTestSearch19Hash14 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestSearch19Hash15 (void) {
+int WmTestSearch19Hash15 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestSearch19Hash16 (void) {
+int WmTestSearch19Hash16 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestSearch20 (void) {
+int WmTestSearch20 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestSearch20Hash12 (void) {
+int WmTestSearch20Hash12 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestSearch20Hash14 (void) {
+int WmTestSearch20Hash14 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestSearch20Hash15 (void) {
+int WmTestSearch20Hash15 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestSearch20Hash16 (void) {
+int WmTestSearch20Hash16 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-int WmTestSearch21 (void) {
+int WmTestSearch21 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int WmTestSearch21Hash12 (void) {
+static int WmTestSearch21Hash12 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int WmTestSearch21Hash14 (void) {
+static int WmTestSearch21Hash14 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int WmTestSearch21Hash15 (void) {
+static int WmTestSearch21Hash15 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int WmTestSearch21Hash16 (void) {
+static int WmTestSearch21Hash16 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
#endif
-static int WmTestSearch22Hash9 (void) {
+static int WmTestSearch22Hash9 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int WmTestSearch22Hash12 (void) {
+static int WmTestSearch22Hash12 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int WmTestSearch22Hash14 (void) {
+static int WmTestSearch22Hash14 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int WmTestSearch22Hash15 (void) {
+static int WmTestSearch22Hash15 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
return result;
}
-static int WmTestSearch22Hash16 (void) {
+static int WmTestSearch22Hash16 (void)
+{
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
}
#endif /* UNITTESTS */
-void WmRegisterTests(void) {
+void WmRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("WmTestInitCtx01", WmTestInitCtx01, 1);
UtRegisterTest("WmTestInitCtx02", WmTestInitCtx02, 1);
* \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);
* \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)
* \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;
/** \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;
/** \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();
#ifdef UNITTESTS
#endif /* UNITTESTS */
-void MpmRegisterTests(void) {
+void MpmRegisterTests(void)
+{
#ifdef UNITTESTS
uint16_t i;
* \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;
}
* \retval 1 relative
* \retval 0 not relative
*/
-int PathIsRelative(const char *path) {
+int PathIsRelative(const char *path)
+{
return PathIsAbsolute(path) ? 0 : 1;
}
*
* \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);
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)
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)
return data;
}
-void PoolThreadReturn(PoolThread *pt, void *data) {
+void PoolThreadReturn(PoolThread *pt, void *data)
+{
PoolThreadReserved *id = data;
if (pt == NULL || *id >= pt->size)
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;
}
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)
return 1;
}
-static int PoolThreadTestInit02(void) {
+static int PoolThreadTestInit02(void)
+{
int i = 123;
PoolThread *pt = PoolThreadInit(4, /* threads */
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);
return result;
}
-static int PoolThreadTestGet02(void) {
+static int PoolThreadTestGet02(void)
+{
int i = 123;
int result = 0;
return result;
}
-static int PoolThreadTestReturn01(void) {
+static int PoolThreadTestReturn01(void)
+{
int i = 123;
int result = 0;
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)
return 1;
}
-static int PoolThreadTestGrow02(void) {
+static int PoolThreadTestGrow02(void)
+{
int i = 123;
PoolThread *pt = PoolThreadInit(4, /* threads */
return 1;
}
-static int PoolThreadTestGrow03(void) {
+static int PoolThreadTestGrow03(void)
+{
int i = 123;
int result = 0;
#endif
-void PoolThreadRegisterTests(void) {
+void PoolThreadRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("PoolThreadTestInit01", PoolThreadTestInit01, 1);
UtRegisterTest("PoolThreadTestInit02", PoolThreadTestInit02, 1);
}
-void PoolFree(Pool *p) {
+void PoolFree(Pool *p)
+{
if (p == NULL)
return;
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;
SCReturnPtr(ptr,"void");
}
-void PoolReturn(Pool *p, void *data) {
+void PoolReturn(Pool *p, void *data)
+{
SCEnter();
PoolBucket *pb = p->empty_stack;
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)));
}
* 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)
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;
return 1;
}
-static int PoolTestInit02 (void) {
+static int PoolTestInit02 (void)
+{
int retval = 0;
Pool *p = PoolInit(10,5,10,PoolTestAlloc,NULL,NULL,PoolTestFree, NULL);
return retval;
}
-static int PoolTestInit03 (void) {
+static int PoolTestInit03 (void)
+{
int retval = 0;
void *data = NULL;
return retval;
}
-static int PoolTestInit04 (void) {
+static int PoolTestInit04 (void)
+{
int retval = 0;
char *str = NULL;
return retval;
}
-static int PoolTestInit05 (void) {
+static int PoolTestInit05 (void)
+{
int retval = 0;
void *data = NULL;
return retval;
}
-static int PoolTestInit06 (void) {
+static int PoolTestInit06 (void)
+{
int retval = 0;
void *data = NULL;
void *data2 = NULL;
}
/** \test pool with unlimited size */
-static int PoolTestInit07 (void) {
+static int PoolTestInit07 (void)
+{
int retval = 0;
void *data = NULL;
void *data2 = NULL;
}
#endif /* UNITTESTS */
-void PoolRegisterTests(void) {
+void PoolRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("PoolTestInit01", PoolTestInit01, 1);
UtRegisterTest("PoolTestInit02", PoolTestInit02, 1);
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;
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);
static char *profiling_file_name = "";
static const char *profiling_file_mode = "a";
-void SCProfilingKeywordsGlobalInit(void) {
+void SCProfilingKeywordsGlobalInit(void)
+{
ConfNode *conf;
conf = ConfGetNode("profiling.keywords");
}
}
-void DoDump(SCProfileKeywordDetectCtx *rules_ctx, FILE *fp, const char *name) {
+void DoDump(SCProfileKeywordDetectCtx *rules_ctx, FILE *fp, const char *name)
+{
int i;
fprintf(fp, " ----------------------------------------------"
"------------------------------------------------------"
}
void
-SCProfilingKeywordDump(DetectEngineCtx *de_ctx) {
+SCProfilingKeywordDump(DetectEngineCtx *de_ctx)
+{
int i;
FILE *fp;
struct timeval tval;
}
}
-SCProfileKeywordDetectCtx *SCProfilingKeywordInitCtx(void) {
+SCProfileKeywordDetectCtx *SCProfilingKeywordInitCtx(void)
+{
SCProfileKeywordDetectCtx *ctx = SCMalloc(sizeof(SCProfileKeywordDetectCtx));
if (ctx != NULL) {
memset(ctx, 0x00, sizeof(SCProfileKeywordDetectCtx));
return ctx;
}
-static void DetroyCtx(SCProfileKeywordDetectCtx *ctx) {
+static void DetroyCtx(SCProfileKeywordDetectCtx *ctx)
+{
if (ctx) {
if (ctx->data != NULL)
SCFree(ctx->data);
}
}
-void SCProfilingKeywordDestroyCtx(DetectEngineCtx *de_ctx) {
+void SCProfilingKeywordDestroyCtx(DetectEngineCtx *de_ctx)
+{
if (de_ctx != NULL) {
SCProfilingKeywordDump(de_ctx);
}
}
-void SCProfilingKeywordThreadSetup(SCProfileKeywordDetectCtx *ctx, DetectEngineThreadCtx *det_ctx) {
+void SCProfilingKeywordThreadSetup(SCProfileKeywordDetectCtx *ctx, DetectEngineThreadCtx *det_ctx)
+{
if (ctx == NULL)
return;
}
}
-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)
}
}
-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;
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;
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;
return 0;
}
-static void LockRecordFree(void *data) {
+static void LockRecordFree(void *data)
+{
LockRecord *fn = (LockRecord *)data;
if (fn == NULL)
SCFree(fn);
}
-int LockRecordInitHash() {
+int LockRecordInitHash()
+{
pthread_mutex_init(&lock_records_mutex, NULL);
pthread_mutex_lock(&lock_records_mutex);
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;
}
/** \param p void ptr to Packet struct */
-void SCProfilingAddPacketLocks(void *p) {
+void SCProfilingAddPacketLocks(void *p)
+{
int i;
if (profiling_locks_enabled == 0)
}
}
-void SCProfilingListLocks(void) {
+void SCProfilingListLocks(void)
+{
FILE *fp = NULL;
if (profiling_locks_output_to_file == 1) {
fclose(fp);
}
-void LockRecordFreeHash() {
+void LockRecordFreeHash()
+{
if (profiling_locks_enabled == 0)
return;
*/
static uint32_t profiling_rules_limit = UINT32_MAX;
-void SCProfilingRulesGlobalInit(void) {
+void SCProfilingRulesGlobalInit(void)
+{
ConfNode *conf;
const char *val;
}
}
-SCProfileDetectCtx *SCProfilingRuleInitCtx(void) {
+SCProfileDetectCtx *SCProfilingRuleInitCtx(void)
+{
SCProfileDetectCtx *ctx = SCMalloc(sizeof(SCProfileDetectCtx));
if (ctx != NULL) {
memset(ctx, 0x00, sizeof(SCProfileDetectCtx));
return ctx;
}
-void SCProfilingRuleDestroyCtx(SCProfileDetectCtx *ctx) {
+void SCProfilingRuleDestroyCtx(SCProfileDetectCtx *ctx)
+{
if (ctx != NULL) {
SCProfilingRuleDump(ctx);
if (ctx->data != NULL)
}
}
-void SCProfilingRuleThreadSetup(SCProfileDetectCtx *ctx, DetectEngineThreadCtx *det_ctx) {
+void SCProfilingRuleThreadSetup(SCProfileDetectCtx *ctx, DetectEngineThreadCtx *det_ctx)
+{
if (ctx == NULL|| ctx->size == 0)
return;
}
}
-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;
}
}
-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;
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)
SCLogInfo("Done dumping profiling data.");
}
-void SCProfilingDumpPacketStats(void) {
+void SCProfilingDumpPacketStats(void)
+{
int i;
FILE *fp;
char totalstr[256];
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;
}
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;
}
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];
}
}
-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];
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;
}
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];
}
}
-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;
}
#endif
}
-void SCProfilingUpdatePacketTmmRecords(Packet *p) {
+void SCProfilingUpdatePacketTmmRecords(Packet *p)
+{
int i;
for (i = 0; i < TMM_SIZE; i++) {
PktProfilingTmmData *pdt = &p->profile->tmm[i];
}
}
-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)
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));
}
/* 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;
#ifdef UNITTESTS
static int
-ProfilingGenericTicksTest01(void) {
+ProfilingGenericTicksTest01(void)
+{
#define TEST_RUNS 1024
uint64_t ticks_start = 0;
uint64_t ticks_end = 0;
*
* \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 */
*
* \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;
* \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;
* 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);
* 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);
* 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);
}
*
* \param rb ringbuffer
*/
-void RingBuffer8Shutdown(RingBuffer8 *rb) {
+void RingBuffer8Shutdown(RingBuffer8 *rb)
+{
rb->shutdown = 1;
#ifdef RINGBUFFER_MUTEX_WAIT
SCCondSignal(&rb->wait_cond);
* \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;
}
* \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;
}
*
* \param rb ringbuffer
*/
-void RingBufferShutdown(RingBuffer16 *rb) {
+void RingBufferShutdown(RingBuffer16 *rb)
+{
rb->shutdown = 1;
#ifdef RINGBUFFER_MUTEX_WAIT
SCCondSignal(&rb->wait_cond);
}
/** \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);
* \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;
}
* \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;
}
/* Single Reader, Single Writer, 8 bits */
-void *RingBufferSrSw8Get(RingBuffer8 *rb) {
+void *RingBufferSrSw8Get(RingBuffer8 *rb)
+{
void *ptr = NULL;
/* buffer is empty, wait... */
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 */
/* Single Reader, Multi Writer, 8 bites */
-void *RingBufferSrMw8Get(RingBuffer8 *rb) {
+void *RingBufferSrMw8Get(RingBuffer8 *rb)
+{
void *ptr = NULL;
/* buffer is empty, wait... */
* \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... */
* 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
/**
* \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... */
* 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
/**
* \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... */
/* Single Reader, Single Writer */
-void *RingBufferSrSwGet(RingBuffer16 *rb) {
+void *RingBufferSrSwGet(RingBuffer16 *rb)
+{
void *ptr = NULL;
/* buffer is empty, wait... */
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 */
/* Multi Reader, Multi Writer, 8 bits */
-RingBuffer8 *RingBuffer8Init(void) {
+RingBuffer8 *RingBuffer8Init(void)
+{
RingBuffer8 *rb = SCMalloc(sizeof(RingBuffer8));
if (unlikely(rb == NULL)) {
return NULL;
return rb;
}
-void RingBuffer8Destroy(RingBuffer8 *rb) {
+void RingBuffer8Destroy(RingBuffer8 *rb)
+{
if (rb != NULL) {
SC_ATOMIC_DESTROY(rb->write);
SC_ATOMIC_DESTROY(rb->read);
* 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
* \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... */
/* Multi Reader, Multi Writer, 16 bits */
-RingBuffer16 *RingBufferInit(void) {
+RingBuffer16 *RingBufferInit(void)
+{
RingBuffer16 *rb = SCMalloc(sizeof(RingBuffer16));
if (unlikely(rb == NULL)) {
return NULL;
return rb;
}
-void RingBufferDestroy(RingBuffer16 *rb) {
+void RingBufferDestroy(RingBuffer16 *rb)
+{
if (rb != NULL) {
SC_ATOMIC_DESTROY(rb->write);
SC_ATOMIC_DESTROY(rb->read);
* 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
*
* \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
* \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... */
}
#ifdef UNITTESTS
-static int RingBuffer8SrSwInit01 (void) {
+static int RingBuffer8SrSwInit01 (void)
+{
int result = 0;
RingBuffer8 *rb = NULL;
return result;
}
-static int RingBuffer8SrSwPut01 (void) {
+static int RingBuffer8SrSwPut01 (void)
+{
int result = 0;
RingBuffer8 *rb = NULL;
return result;
}
-static int RingBuffer8SrSwPut02 (void) {
+static int RingBuffer8SrSwPut02 (void)
+{
int result = 0;
RingBuffer8 *rb = NULL;
return result;
}
-static int RingBuffer8SrSwGet01 (void) {
+static int RingBuffer8SrSwGet01 (void)
+{
int result = 0;
RingBuffer8 *rb = NULL;
return result;
}
-static int RingBuffer8SrSwGet02 (void) {
+static int RingBuffer8SrSwGet02 (void)
+{
int result = 0;
RingBuffer8 *rb = NULL;
#endif /* UNITTESTS */
-void DetectRingBufferRegisterTests(void) {
+void DetectRingBufferRegisterTests(void)
+{
#ifdef UNITTESTS /* UNITTESTS */
UtRegisterTest("RingBuffer8SrSwInit01", RingBuffer8SrSwInit01, 1);
UtRegisterTest("RingBuffer8SrSwPut01", RingBuffer8SrSwPut01, 1);
*
* \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;
return table;
}
-void ROHashFree(ROHashTable *table) {
+void ROHashFree(ROHashTable *table)
+{
if (table != NULL) {
if (table->data != NULL) {
SCFree(table->data);
}
}
-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));
}
* \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");
}
* \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;
*
* \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;
*
* 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;
* \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);
* \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...");
* \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;
*
* \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;
*
* \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;
return NULL;
}
-void BasicSearchInit (void) {
+void BasicSearchInit (void)
+{
/* nothing no more */
}
* 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;
* 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;
#endif
/* Register unittests */
-void UtilSpmSearchRegistertests(void) {
+void UtilSpmSearchRegistertests(void)
+{
#ifdef UNITTESTS
/* Generic tests */
UtRegisterTest("UtilSpmBasicSearchTest01", UtilSpmBasicSearchTest01, 1);
* \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;
*
* \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);
*/
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();
*/
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();
* \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);
*
* \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) {
*
* \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();
* \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);
* \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);
* \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);
*
* \param p pointer to the Packet
*/
-void UTHFreePackets(Packet **p, int numpkts) {
+void UTHFreePackets(Packet **p, int numpkts)
+{
if (p == NULL)
return;
*
* \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
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));
return f;
}
-void UTHFreeFlow(Flow *flow) {
+void UTHFreeFlow(Flow *flow)
+{
if (flow != NULL) {
FlowFree(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
*
* \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;
* \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) {
* \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) {
* \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;
* \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;
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++) {
/**
* \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";
/**
* \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,
/**
* \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,
/**
* \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);
/**
* \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);
/**
* \brief UTHBuildPacketOfFlowsTest01 wrapper to check packets for unittests
*/
-int UTHBuildPacketOfFlowsTest01(void) {
+int UTHBuildPacketOfFlowsTest01(void)
+{
int result = 0;
FlowInitConfig(FLOW_QUIET);
/**
* \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,
/**
* \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,
/**
* \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,
/**
* \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,
#endif /* UNITTESTS */
-void UTHRegisterTests(void) {
+void UTHRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("UTHBuildPacketRealTest01", UTHBuildPacketRealTest01, 1);
UtRegisterTest("UTHBuildPacketRealTest02", UTHBuildPacketRealTest02, 1);
* \retval ut Pointer to UtTest
*/
-static UtTest *UtAllocTest(void) {
+static UtTest *UtAllocTest(void)
+{
UtTest *ut = SCMalloc(sizeof(UtTest));
if (unlikely(ut == NULL))
return NULL;
* \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 {
*
*/
-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;
* \retval -1 Regex error
*/
-int UtRegex (char *regex_arg) {
+int UtRegex (char *regex_arg)
+{
const char *eb;
int eo;
int opts = PCRE_CASELESS;;
*
* \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];
* \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;
* \brief Initialize unit test list
*/
-void UtInitialize(void) {
+void UtInitialize(void)
+{
ut_list = NULL;
}
* \brief Cleanup unit test list
*/
-void UtCleanup(void) {
+void UtCleanup(void)
+{
UtTest *tmp = ut_list, *otmp;
* \retval 0 False
*/
-int UtSelftestTrue(void) {
+int UtSelftestTrue(void)
+{
if (1)return 1;
else return 0;
}
* \retval 0 True
*/
-int UtSelftestFalse(void) {
+int UtSelftestFalse(void)
+{
if (0)return 1;
else return 0;
}
* \retval 0 all successful
*/
-int UtRunSelftest (char *regex_arg) {
+int UtRunSelftest (char *regex_arg)
+{
#ifdef UNITTESTS
printf("* Running Unittesting subsystem selftests...\n");
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;
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;
return 0;
}
-static void VariableNameFree(void *data) {
+static void VariableNameFree(void *data)
+{
VariableName *fn = (VariableName *)data;
if (fn == NULL)
* \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;
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);
* \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));