Put open brace { for function on a new line to match coding standard.
Changed:
int foo(int x) {
}
to:
int foo(int x)
{
}
-/* Copyright (C) 2007-2012 Open Information Security Foundation
+/* Copyright (C) 2007-2013 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
static int host_tag_id = -1; /**< Host storage id for tags */
static int flow_tag_id = -1; /**< Flow storage id for tags */
-void TagInitCtx(void) {
+void TagInitCtx(void)
+{
SC_ATOMIC_INIT(num_tags);
host_tag_id = HostStorageRegister("tag", sizeof(void *), NULL, DetectTagDataListFree);
/** \brief Reset the tagging engine context
*/
-void TagRestartCtx() {
+void TagRestartCtx()
+{
TagDestroyCtx();
TagInitCtx();
}
-int TagHostHasTag(Host *host) {
+int TagHostHasTag(Host *host)
+{
return HostGetStorageById(host, host_tag_id) ? 1 : 0;
}
-static DetectTagDataEntry *DetectTagDataCopy(DetectTagDataEntry *dtd) {
+static DetectTagDataEntry *DetectTagDataCopy(DetectTagDataEntry *dtd)
+{
DetectTagDataEntry *tde = SCMalloc(sizeof(DetectTagDataEntry));
if (unlikely(tde == NULL)) {
return NULL;
* \retval 0 if the tde was added succesfuly
* \retval 1 if an entry of this sid/gid already exist and was updated
*/
-int TagFlowAdd(Packet *p, DetectTagDataEntry *tde) {
+int TagFlowAdd(Packet *p, DetectTagDataEntry *tde)
+{
uint8_t updated = 0;
uint16_t num_tags = 0;
DetectTagDataEntry *iter = NULL;
SCReturnInt(updated);
}
-static void TagHandlePacketFlow(Flow *f, Packet *p) {
+static void TagHandlePacketFlow(Flow *f, Packet *p)
+{
if (FlowGetStorageById(f, flow_tag_id) == NULL)
return;
}
}
-void TagHandlePacketHost(Host *host, Packet *p) {
+void TagHandlePacketHost(Host *host, Packet *p)
+{
DetectTagDataEntry *tde = NULL;
DetectTagDataEntry *prev = NULL;
DetectTagDataEntry *iter;
*
*/
void TagHandlePacket(DetectEngineCtx *de_ctx,
- DetectEngineThreadCtx *det_ctx, Packet *p)
+ DetectEngineThreadCtx *det_ctx, Packet *p)
{
/* If there's no tag, get out of here */
unsigned int current_tags = SC_ATOMIC_GET(num_tags);
-/* Copyright (C) 2007-2010 Open Information Security Foundation
+/* Copyright (C) 2007-2013 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
void DetectPcreFree(void *);
void DetectPcreRegisterTests(void);
-void DetectPcreRegister (void) {
+void DetectPcreRegister (void)
+{
sigmatch_table[DETECT_PCRE].name = "pcre";
sigmatch_table[DETECT_PCRE].desc = "match on regular expression";
sigmatch_table[DETECT_PCRE].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/HTTP-keywords#Pcre-Perl-Compatible-Regular-Expressions";
SCReturnInt(ret);
}
-void DetectPcreFree(void *ptr) {
+void DetectPcreFree(void *ptr)
+{
if (ptr == NULL)
return;
/**
* \test DetectPcreParseTest01 make sure we don't allow invalid opts 7.
*/
-static int DetectPcreParseTest01 (void) {
+static int DetectPcreParseTest01 (void)
+{
int result = 1;
DetectPcreData *pd = NULL;
char *teststring = "/blah/7";
/**
* \test DetectPcreParseTest02 make sure we don't allow invalid opts Ui$.
*/
-static int DetectPcreParseTest02 (void) {
+static int DetectPcreParseTest02 (void)
+{
int result = 1;
DetectPcreData *pd = NULL;
char *teststring = "/blah/Ui$";
/**
* \test DetectPcreParseTest03 make sure we don't allow invalid opts UZi.
*/
-static int DetectPcreParseTest03 (void) {
+static int DetectPcreParseTest03 (void)
+{
int result = 1;
DetectPcreData *pd = NULL;
char *teststring = "/blah/UNi";
/**
* \test DetectPcreParseTest04 make sure we allow escaped "
*/
-static int DetectPcreParseTest04 (void) {
+static int DetectPcreParseTest04 (void)
+{
int result = 1;
DetectPcreData *pd = NULL;
char *teststring = "/b\\\"lah/i";
/**
* \test DetectPcreParseTest05 make sure we parse pcre with no opts
*/
-static int DetectPcreParseTest05 (void) {
+static int DetectPcreParseTest05 (void)
+{
int result = 1;
DetectPcreData *pd = NULL;
char *teststring = "/b(l|a)h/";
/**
* \test DetectPcreParseTest06 make sure we parse pcre with smi opts
*/
-static int DetectPcreParseTest06 (void) {
+static int DetectPcreParseTest06 (void)
+{
int result = 1;
DetectPcreData *pd = NULL;
char *teststring = "/b(l|a)h/smi";
/**
* \test DetectPcreParseTest07 make sure we parse pcre with /Ui opts
*/
-static int DetectPcreParseTest07 (void) {
+static int DetectPcreParseTest07 (void)
+{
int result = 1;
DetectPcreData *pd = NULL;
char *teststring = "/blah/Ui";
/**
* \test DetectPcreParseTest08 make sure we parse pcre with O opts
*/
-static int DetectPcreParseTest08 (void) {
+static int DetectPcreParseTest08 (void)
+{
int result = 1;
DetectPcreData *pd = NULL;
char *teststring = "/b(l|a)h/O";
* \test DetectPcreParseTest09 make sure we parse pcre with a content
* that has slashes
*/
-static int DetectPcreParseTest09 (void) {
+static int DetectPcreParseTest09 (void)
+{
int result = 1;
DetectPcreData *pd = NULL;
char *teststring = "/lala\\\\/";
return result;
}
-static int DetectPcreTestSig01Real(int mpm_type) {
+static int DetectPcreTestSig01Real(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 DetectPcreTestSig01B2g (void) {
+static int DetectPcreTestSig01B2g (void)
+{
return DetectPcreTestSig01Real(MPM_B2G);
}
-static int DetectPcreTestSig01B3g (void) {
+static int DetectPcreTestSig01B3g (void)
+{
return DetectPcreTestSig01Real(MPM_B3G);
}
-static int DetectPcreTestSig01Wm (void) {
+static int DetectPcreTestSig01Wm (void)
+{
return DetectPcreTestSig01Real(MPM_WUMANBER);
}
-static int DetectPcreTestSig02Real(int mpm_type) {
+static int DetectPcreTestSig02Real(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 DetectPcreTestSig02B2g (void) {
+static int DetectPcreTestSig02B2g (void)
+{
return DetectPcreTestSig02Real(MPM_B2G);
}
-static int DetectPcreTestSig02B3g (void) {
+static int DetectPcreTestSig02B3g (void)
+{
return DetectPcreTestSig02Real(MPM_B3G);
}
-static int DetectPcreTestSig02Wm (void) {
+static int DetectPcreTestSig02Wm (void)
+{
return DetectPcreTestSig02Real(MPM_WUMANBER);
}
/**
* \test DetectPcreTestSig03Real negation test ! outside of "" this sig should not match
*/
-static int DetectPcreTestSig03Real(int mpm_type) {
+static int DetectPcreTestSig03Real(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 DetectPcreTestSig03B2g (void) {
+static int DetectPcreTestSig03B2g (void)
+{
return DetectPcreTestSig03Real(MPM_B2G);
}
-static int DetectPcreTestSig03B3g (void) {
+static int DetectPcreTestSig03B3g (void)
+{
return DetectPcreTestSig03Real(MPM_B3G);
}
-static int DetectPcreTestSig03Wm (void) {
+static int DetectPcreTestSig03Wm (void)
+{
return DetectPcreTestSig03Real(MPM_WUMANBER);
}
/**
* \test Check the signature with pcre modifier P (match with L7 to http body data)
*/
-static int DetectPcreModifPTest04(void) {
+static int DetectPcreModifPTest04(void)
+{
int result = 0;
uint8_t httpbuf1[] =
"GET / HTTP/1.1\r\n"
* \test Check the signature with pcre modifier P (match with L7 to http body data)
* over fragmented chunks (DOCTYPE fragmented)
*/
-static int DetectPcreModifPTest05(void) {
+static int DetectPcreModifPTest05(void)
+{
int result = 0;
uint8_t httpbuf1[] =
"GET / HTTP/1.1\r\n"
return result;
}
-int DetectPcreTestSig06() {
+int DetectPcreTestSig06()
+{
uint8_t *buf = (uint8_t *)
"lalala lalala\\ lala\n";
uint16_t buflen = strlen((char *)buf);
}
/** \test anchored pcre */
-int DetectPcreTestSig07() {
+int DetectPcreTestSig07()
+{
uint8_t *buf = (uint8_t *)
"lalala\n";
uint16_t buflen = strlen((char *)buf);
}
/** \test anchored pcre */
-int DetectPcreTestSig08() {
+int DetectPcreTestSig08()
+{
/* test it also without ending in a newline "\n" */
uint8_t *buf = (uint8_t *)
"lalala";
/** \test Check the signature working to alert when cookie modifier is
* passed to pcre
*/
-static int DetectPcreTestSig09(void) {
+static int DetectPcreTestSig09(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 cookie modifier is
* passed to a negated pcre
*/
-static int DetectPcreTestSig10(void) {
+static int DetectPcreTestSig10(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 method modifier is
* passed to pcre
*/
-static int DetectPcreTestSig11(void) {
+static int DetectPcreTestSig11(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 method modifier is
* passed to a negated pcre
*/
-static int DetectPcreTestSig12(void) {
+static int DetectPcreTestSig12(void)
+{
int result = 0;
Flow f;
uint8_t httpbuf1[] = "GET / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n"
/** \test Check the signature working to alert when header modifier is
* passed to pcre
*/
-static int DetectPcreTestSig13(void) {
+static int DetectPcreTestSig13(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 header modifier is
* passed to a negated pcre
*/
-static int DetectPcreTestSig14(void) {
+static int DetectPcreTestSig14(void)
+{
int result = 0;
Flow f;
uint8_t httpbuf1[] = "GET / HTTP/1.0\r\nUser-Agent: IEXPLORER/1.0\r\n"
/** \test Check the signature working to alert when cookie and relative modifiers are
* passed to pcre
*/
-static int DetectPcreTestSig15(void) {
+static int DetectPcreTestSig15(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 method and relative modifiers are
* passed to pcre
*/
-static int DetectPcreTestSig16(void) {
+static int DetectPcreTestSig16(void)
+{
int result = 0;
Flow f;
uint8_t httpbuf1[] = "POST / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n"
/** \test Test tracking of body chunks per transactions (on requests)
*/
-static int DetectPcreTxBodyChunksTest01(void) {
+static int DetectPcreTxBodyChunksTest01(void)
+{
int result = 0;
Flow f;
TcpSession ssn;
}
/** \test test pcre P modifier with multiple pipelined http transactions */
-static int DetectPcreTxBodyChunksTest02(void) {
+static int DetectPcreTxBodyChunksTest02(void)
+{
int result = 0;
Signature *s = NULL;
DetectEngineThreadCtx *det_ctx = NULL;
}
/** \test multiple http transactions and body chunks of request handling */
-static int DetectPcreTxBodyChunksTest03(void) {
+static int DetectPcreTxBodyChunksTest03(void)
+{
int result = 0;
Signature *s = NULL;
DetectEngineThreadCtx *det_ctx = NULL;
/**
* \test flowvar capture on http buffer
*/
-static int DetectPcreFlowvarCapture01(void) {
+static int DetectPcreFlowvarCapture01(void)
+{
int result = 0;
uint8_t uabuf1[] =
"Mozilla/5.0 (X11; U; Linux i686; es-ES; rv:1.9.0.13) Gecko/2009080315 Ubuntu/8.10 (intrepid) Firefox/3.0.13";
/**
* \test flowvar capture on http buffer, capture overwrite
*/
-static int DetectPcreFlowvarCapture02(void) {
+static int DetectPcreFlowvarCapture02(void)
+{
int result = 0;
uint8_t uabuf1[] =
"Apache";
/**
* \test flowvar capture on http buffer, capture overwrite + no matching sigs, so flowvars should not be set.
*/
-static int DetectPcreFlowvarCapture03(void) {
+static int DetectPcreFlowvarCapture03(void)
+{
int result = 0;
uint8_t httpbuf1[] =
"GET / HTTP/1.1\r\n"
-/* Copyright (C) 2007-2012 Open Information Security Foundation
+/* Copyright (C) 2007-2013 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
#include "util-debug.h"
#include "util-print.h"
-FlowQueue *FlowQueueNew() {
+FlowQueue *FlowQueueNew()
+{
FlowQueue *q = (FlowQueue *)SCMalloc(sizeof(FlowQueue));
if (q == NULL) {
SCLogError(SC_ERR_FATAL, "Fatal error encountered in FlowQueueNew. Exiting...");
return q;
}
-FlowQueue *FlowQueueInit (FlowQueue *q) {
+FlowQueue *FlowQueueInit (FlowQueue *q)
+{
if (q != NULL) {
memset(q, 0, sizeof(FlowQueue));
FQLOCK_INIT(q);
*
* \param q the flow queue to destroy
*/
-void FlowQueueDestroy (FlowQueue *q) {
+void FlowQueueDestroy (FlowQueue *q)
+{
FQLOCK_DESTROY(q);
}
* \param q queue
* \param f flow
*/
-void FlowEnqueue (FlowQueue *q, Flow *f) {
+void FlowEnqueue (FlowQueue *q, Flow *f)
+{
#ifdef DEBUG
BUG_ON(q == NULL || f == NULL);
#endif
*
* \retval f flow or NULL if empty list.
*/
-Flow *FlowDequeue (FlowQueue *q) {
+Flow *FlowDequeue (FlowQueue *q)
+{
FQLOCK_LOCK(q);
Flow *f = q->bot;
-/* Copyright (C) 2007-2010 Open Information Security Foundation
+/* Copyright (C) 2007-2013 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
* ACTION_REJECT or ACTION_ALERT
* \retval uint8_t the priority (order of this actions)
*/
-uint8_t ActionOrderVal(uint8_t action) {
+uint8_t ActionOrderVal(uint8_t action)
+{
/* reject_both and reject_dst have the same prio as reject */
if( (action & ACTION_REJECT) ||
(action & ACTION_REJECT_BOTH) ||
* \retval uint8_t can be one of ACTION_PASS, ACTION_DROP,
* ACTION_REJECT or ACTION_ALERT
*/
-uint8_t ActionAsciiToFlag(char *action) {
+uint8_t ActionAsciiToFlag(char *action)
+{
if (strcmp(action,"pass") == 0)
return ACTION_PASS;
if (strcmp(action,"drop") == 0)
*
* \retval 0 on success; -1 on fatal error;
*/
-int ActionInitConfig() {
+int ActionInitConfig()
+{
uint8_t actions_used = 0;
uint8_t action_flag = 0;
uint8_t actions_config[4] = {0, 0, 0, 0};
* \retval 0 if the syscall is not available or we have an error;
* otherwise it will return the number of cpus configured
*/
-uint16_t UtilCpuGetNumProcessorsConfigured() {
+uint16_t UtilCpuGetNumProcessorsConfigured()
+{
#ifdef SYSCONF_NPROCESSORS_CONF_COMPAT
long nprocs = -1;
nprocs = sysconf(_SC_NPROCESSORS_CONF);
* \retval 0 if the syscall is not available or we have an error;
* otherwise it will return the number of cpus online
*/
-uint16_t UtilCpuGetNumProcessorsOnline() {
+uint16_t UtilCpuGetNumProcessorsOnline()
+{
#ifdef SYSCONF_NPROCESSORS_ONLN_COMPAT
long nprocs = -1;
nprocs = sysconf(_SC_NPROCESSORS_ONLN);
* \retval 0 if the syscall is not available or we have an error;
* otherwise it will return the number of cpus allowed
*/
-uint16_t UtilCpuGetNumProcessorsMax() {
+uint16_t UtilCpuGetNumProcessorsMax()
+{
#ifdef SYSCONF_NPROCESSORS_MAX_COMPAT
long nprocs = -1;
nprocs = sysconf(_SC_NPROCESSORS_MAX);
/**
* \brief Print a summary of CPUs detected (configured and online)
*/
-void UtilCpuPrintSummary() {
+void UtilCpuPrintSummary()
+{
uint16_t cpus_conf = UtilCpuGetNumProcessorsConfigured();
uint16_t cpus_online = UtilCpuGetNumProcessorsOnline();
-/* Copyright (C) 2007-2010 Open Information Security Foundation
+/* Copyright (C) 2007-2013 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
uint16_t asn1_max_frames_config = ASN1_MAX_FRAMES;
-void SCAsn1LoadConfig() {
+void SCAsn1LoadConfig()
+{
intmax_t value = 0;
/** set config defaults */
*
* \retval byte of the status of the parser
*/
-uint8_t SCAsn1GetHighTagNumber(Asn1Ctx *ac) {
+uint8_t SCAsn1GetHighTagNumber(Asn1Ctx *ac)
+{
uint8_t ret = 0;
uint32_t tag_num = 0;
*
* \retval byte of the status of the parser
*/
-uint32_t SCAsn1GetLengthLongForm(Asn1Ctx *ac) {
+uint32_t SCAsn1GetLengthLongForm(Asn1Ctx *ac)
+{
uint8_t raw_len = *ac->iter;
uint8_t ret = 0;
uint32_t content_len = 0;
*
* \retval byte of the status of the parser
*/
-uint8_t SCAsn1DecodeContent(Asn1Ctx *ac) {
+uint8_t SCAsn1DecodeContent(Asn1Ctx *ac)
+{
Asn1Node *node = ASN1CTX_CUR_NODE(ac);
*
* \retval byte of the status of the parser
*/
-uint8_t SCAsn1DecodeLength(Asn1Ctx *ac) {
+uint8_t SCAsn1DecodeLength(Asn1Ctx *ac)
+{
uint8_t ret = 0;
ret = SCAsn1CheckBounds(ac);
if (ret == ASN1_PARSER_ERR) {
*
* \retval byte of the status of the parser
*/
-uint8_t SCAsn1DecodeIdentifier(Asn1Ctx *ac) {
+uint8_t SCAsn1DecodeIdentifier(Asn1Ctx *ac)
+{
uint8_t ret = 0;
ret = SCAsn1CheckBounds(ac);
if (ret == ASN1_PARSER_ERR) {
* to check encoding internals
* \param byte value of the byte
*/
-void SCPrintByteBin(uint8_t byte) {
+void SCPrintByteBin(uint8_t byte)
+{
uint8_t i = 0;
for (i = 8; i > 0; i--) {
printf("%"PRIu8, ((byte >> (i - 1)) & 0x01));
* \param ac Asn1Ctx pointer initialized
* \retval 1 if we are out of bounds, 0 if not
*/
-uint8_t SCAsn1CheckBounds(Asn1Ctx *ac) {
+uint8_t SCAsn1CheckBounds(Asn1Ctx *ac)
+{
return (ac->iter < ac->end && ac->iter >= ac->data)? ASN1_PARSER_OK : ASN1_PARSER_ERR;
}
*
* \retval Asn1Ctx pointer to the new ctx
*/
-Asn1Ctx *SCAsn1CtxNew(void) {
+Asn1Ctx *SCAsn1CtxNew(void)
+{
Asn1Ctx *ac = SCMalloc(sizeof(Asn1Ctx));
if (unlikely(ac == NULL)) {
*
* \param Asn1Ctx pointer to the new ctx
*/
-void SCAsn1CtxDestroy(Asn1Ctx *ac) {
+void SCAsn1CtxDestroy(Asn1Ctx *ac)
+{
if (ac == NULL)
return;
*
* \retval Asn1Node pointer to the new node allocated
*/
-Asn1Node *SCAsn1CtxNewFrame(Asn1Ctx *ac, uint16_t node) {
+Asn1Node *SCAsn1CtxNewFrame(Asn1Ctx *ac, uint16_t node)
+{
if (node >= asn1_max_frames_config) {
return NULL;
}
*
* \retval void
*/
-void SCAsn1CtxInit(Asn1Ctx *ac, uint8_t *data, uint16_t length) {
-
+void SCAsn1CtxInit(Asn1Ctx *ac, uint8_t *data, uint16_t length)
+{
ac->data = data;
ac->iter = data;
ac->len = length;
*
* \retval byte of parser status
*/
-uint8_t SCAsn1Decode(Asn1Ctx *ac, uint16_t node_id) {
+uint8_t SCAsn1Decode(Asn1Ctx *ac, uint16_t node_id)
+{
Asn1Node *node = NULL;
uint8_t ret = 0;
/**
* \test Check we handle extended identifiers correctly
*/
-int DecodeAsn1Test01(void) {
+int DecodeAsn1Test01(void)
+{
uint8_t *str = (uint8_t *) "\x3F\x84\x06";
Asn1Ctx *ac = SCAsn1CtxNew();
/**
* \test Check we handle extended identifiers correctly
*/
-int DecodeAsn1Test02(void) {
+int DecodeAsn1Test02(void)
+{
uint8_t *str = (uint8_t *) "\x3F\x81\x81\x81\x81\x06";
Asn1Ctx *ac = SCAsn1CtxNew();
/**
* \test Check we handle short identifiers correctly
*/
-int DecodeAsn1Test03(void) {
+int DecodeAsn1Test03(void)
+{
uint8_t *str = (uint8_t *) "\x28";
Asn1Ctx *ac = SCAsn1CtxNew();
/**
* \test Check we handle extended lengths correctly with indefinite form
*/
-int DecodeAsn1Test04(void) {
+int DecodeAsn1Test04(void)
+{
uint8_t *str = (uint8_t *) "\x3F\x84\x06\x80\x12\x12\x12\x00\x00";
Asn1Ctx *ac = SCAsn1CtxNew();
* \test Check we handle extended lengths correctly
* in the definite form
*/
-int DecodeAsn1Test05(void) {
+int DecodeAsn1Test05(void)
+{
uint8_t *str = (uint8_t *) "\x3F\x84\x06\x82\x10\x10";
Asn1Ctx *ac = SCAsn1CtxNew();
/**
* \test Check we handle short lengths correctly
*/
-int DecodeAsn1Test06(void) {
+int DecodeAsn1Test06(void)
+{
uint8_t *str = (uint8_t *) "\x3F\x84\x06\x26";
Asn1Ctx *ac = SCAsn1CtxNew();
/**
* \test Check we handle events correctly
*/
-int DecodeAsn1Test07(void) {
+int DecodeAsn1Test07(void)
+{
uint8_t *str = (uint8_t *) "\x3F\x00\x84\x06";
Asn1Ctx *ac = SCAsn1CtxNew();
/**
* \test Check we handle events correctly
*/
-int DecodeAsn1Test08(void) {
+int DecodeAsn1Test08(void)
+{
uint8_t *str = (uint8_t *) "\x3F\x84\x06\x81\xFF";
Asn1Ctx *ac = SCAsn1CtxNew();
/**
* \test Check we handle events correctly
*/
-int DecodeAsn1Test09(void) {
+int DecodeAsn1Test09(void)
+{
uint8_t *str = (uint8_t *) "\x3F\x84\x06\x80\xAB\xCD\xEF";
Asn1Ctx *ac = SCAsn1CtxNew();
/**
* \test Decode a big chunk of data
*/
-int DecodeAsn1Test10(void) {
+int DecodeAsn1Test10(void)
+{
// Example from the specification X.690-0207 Appendix A.3
uint8_t *str = (uint8_t *) "\x60\x81\x85\x61\x10\x1A\x04""John""\x1A\x01"
"P""\x1A\x05""Smith""\xA0\x0A\x1A\x08""Director"
#endif
-void DecodeAsn1RegisterTests(void) {
+void DecodeAsn1RegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("DecodeAsn1Test01", DecodeAsn1Test01, 1);
UtRegisterTest("DecodeAsn1Test02", DecodeAsn1Test02, 1);
-/* Copyright (C) 2007-2011 Open Information Security Foundation
+/* Copyright (C) 2007-2013 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
/**
* \brief Initialize the "magic" context.
*/
-int MagicInit(void) {
+int MagicInit(void)
+{
BUG_ON(g_magic_ctx != NULL);
SCEnter();
*
* \retval result pointer to null terminated string
*/
-char *MagicGlobalLookup(uint8_t *buf, uint32_t buflen) {
+char *MagicGlobalLookup(uint8_t *buf, uint32_t buflen)
+{
const char *result = NULL;
char *magic = NULL;
*
* \retval result pointer to null terminated string
*/
-char *MagicThreadLookup(magic_t *ctx, uint8_t *buf, uint32_t buflen) {
+char *MagicThreadLookup(magic_t *ctx, uint8_t *buf, uint32_t buflen)
+{
const char *result = NULL;
char *magic = NULL;
SCReturnPtr(magic, "const char");
}
-void MagicDeinit(void) {
+void MagicDeinit(void)
+{
SCMutexLock(&g_magic_lock);
if (g_magic_ctx != NULL) {
magic_close(g_magic_ctx);
}
/** \test magic lib calls -- lookup */
-int MagicDetectTest03(void) {
+int MagicDetectTest03(void)
+{
magic_t magic_ctx;
char *result = NULL;
}
/** \test magic lib calls -- lookup */
-int MagicDetectTest04(void) {
+int MagicDetectTest04(void)
+{
magic_t magic_ctx;
char *result = NULL;
}
/** \test magic api calls -- lookup */
-int MagicDetectTest05(void) {
+int MagicDetectTest05(void)
+{
const char *result = NULL;
uint8_t buffer[] = { 0x25, 'P', 'D', 'F', '-', '1', '.', '3', 0x0d, 0x0a};
size_t buffer_len = sizeof(buffer);
}
/** \test magic api calls -- lookup */
-int MagicDetectTest06(void) {
+int MagicDetectTest06(void)
+{
const char *result = NULL;
uint8_t buffer[] = {
0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1,
}
/** \test magic api calls -- lookup */
-int MagicDetectTest07(void) {
+int MagicDetectTest07(void)
+{
const char *result = NULL;
uint8_t buffer[] = {
0x50, 0x4b, 0x03, 0x04, 0x14, 0x00, 0x00, 0x00,
}
/** \test magic api calls -- lookup */
-int MagicDetectTest08(void) {
+int MagicDetectTest08(void)
+{
const char *result = NULL;
uint8_t buffer[] = {
0x50, 0x4b, 0x03, 0x04, 0x14, 0x00, 0x00, 0x08,
}
/** \test magic api calls -- make sure memory is shared */
-int MagicDetectTest09(void) {
+int MagicDetectTest09(void)
+{
const char *result1 = NULL;
const char *result2 = NULL;
uint8_t buffer[] = { 0x25, 'P', 'D', 'F', '-', '1', '.', '3', 0x0d, 0x0a};
/** \test results in valgrind warning about invalid read, tested with
* file 5.09 and 5.11 */
-static int MagicDetectTest10ValgrindError(void) {
+static int MagicDetectTest10ValgrindError(void)
+{
const char *result = NULL;
uint8_t buffer[] = {
0xFF,0xD8,0xFF,0xE0,0x00,0x10,0x4A,0x46,0x49,0x46,0x00,0x01,0x01,0x01,0x01,0x2C,
#endif /* UNITTESTS */
-void MagicRegisterTests(void) {
+void MagicRegisterTests(void)
+{
#ifdef UNITTESTS
UtRegisterTest("MagicInitTest01", MagicInitTest01, 1);
UtRegisterTest("MagicInitTest02", MagicInitTest02, 1);
-/* Copyright (C) 2007-2010 Open Information Security Foundation
+/* Copyright (C) 2007-2013 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
* \param needle pattern to search for
* \param needlelen length of the pattern
*/
-uint8_t *Bs2bmSearch(uint8_t *text, uint32_t textlen, uint8_t *needle, uint16_t needlelen) {
+uint8_t *Bs2bmSearch(uint8_t *text, uint32_t textlen, uint8_t *needle, uint16_t needlelen)
+{
uint8_t badchars[ALPHABET_SIZE];
Bs2BmBadchars(needle, needlelen, badchars);
* \param needle pattern to search for
* \param needlelen length of the pattern
*/
-uint8_t *Bs2bmNocaseSearch(uint8_t *text, uint32_t textlen, uint8_t *needle, uint16_t needlelen) {
+uint8_t *Bs2bmNocaseSearch(uint8_t *text, uint32_t textlen, uint8_t *needle, uint16_t needlelen)
+{
uint8_t badchars[ALPHABET_SIZE];
Bs2BmBadchars(needle, needlelen, badchars);
* \param needle pattern to search for
* \param needlelen length of the pattern
*/
-uint8_t *BoyerMooreSearch(uint8_t *text, uint32_t textlen, uint8_t *needle, uint16_t needlelen) {
+uint8_t *BoyerMooreSearch(uint8_t *text, uint32_t textlen, uint8_t *needle, uint16_t needlelen)
+{
uint16_t bmBc[ALPHABET_SIZE];
uint16_t *bmGs = SCMalloc(sizeof(uint16_t)*(needlelen + 1));
if (unlikely(bmGs == NULL))
* \param needle pattern to search for
* \param needlelen length of the pattern
*/
-uint8_t *BoyerMooreNocaseSearch(uint8_t *text, uint32_t textlen, uint8_t *needle, uint16_t needlelen) {
+uint8_t *BoyerMooreNocaseSearch(uint8_t *text, uint32_t textlen, uint8_t *needle, uint16_t needlelen)
+{
uint16_t bmBc[ALPHABET_SIZE];
uint16_t *bmGs = SCMalloc(sizeof(uint16_t)*(needlelen + 1));
if (unlikely(bmGs == NULL))
* \param times If you are testing performance, se the numebr of times
* that you want to repeat the search
*/
-uint8_t *BasicSearchWrapper(uint8_t *text, uint8_t *needle, int times) {
+uint8_t *BasicSearchWrapper(uint8_t *text, uint8_t *needle, int times)
+{
uint32_t textlen = strlen((char *)text);
uint16_t needlelen = strlen((char *)needle);
return ret;
}
-uint8_t *BasicSearchNocaseWrapper(uint8_t *text, uint8_t *needle, int times) {
+uint8_t *BasicSearchNocaseWrapper(uint8_t *text, uint8_t *needle, int times)
+{
uint32_t textlen = strlen((char *)text);
uint16_t needlelen = strlen((char *)needle);
return ret;
}
-uint8_t *Bs2bmWrapper(uint8_t *text, uint8_t *needle, int times) {
+uint8_t *Bs2bmWrapper(uint8_t *text, uint8_t *needle, int times)
+{
uint32_t textlen = strlen((char *)text);
uint16_t needlelen = strlen((char *)needle);
return ret;
}
-uint8_t *Bs2bmNocaseWrapper(uint8_t *text, uint8_t *needle, int times) {
+uint8_t *Bs2bmNocaseWrapper(uint8_t *text, uint8_t *needle, int times)
+{
uint32_t textlen = strlen((char *)text);
uint16_t needlelen = strlen((char *)needle);
return ret;
}
-uint8_t *BoyerMooreWrapper(uint8_t *text, uint8_t *needle, int times) {
+uint8_t *BoyerMooreWrapper(uint8_t *text, uint8_t *needle, int times)
+{
uint32_t textlen = strlen((char *)text);
uint16_t needlelen = strlen((char *)needle);
return ret;
}
-uint8_t *BoyerMooreNocaseWrapper(uint8_t *text, uint8_t *needle, int times) {
+uint8_t *BoyerMooreNocaseWrapper(uint8_t *text, uint8_t *needle, int times)
+{
uint32_t textlen = strlen((char *)text);
uint16_t needlelen = strlen((char *)needle);
* \param times If you are testing performance, se the numebr of times
* that you want to repeat the search
*/
-uint8_t *BasicSearchCtxWrapper(uint8_t *text, uint8_t *needle, int times) {
+uint8_t *BasicSearchCtxWrapper(uint8_t *text, uint8_t *needle, int times)
+{
uint32_t textlen = strlen((char *)text);
uint16_t needlelen = strlen((char *)needle);
return ret;
}
-uint8_t *BasicSearchNocaseCtxWrapper(uint8_t *text, uint8_t *needle, int times) {
+uint8_t *BasicSearchNocaseCtxWrapper(uint8_t *text, uint8_t *needle, int times)
+{
uint32_t textlen = strlen((char *)text);
uint16_t needlelen = strlen((char *)needle);
return ret;
}
-uint8_t *Bs2bmCtxWrapper(uint8_t *text, uint8_t *needle, int times) {
+uint8_t *Bs2bmCtxWrapper(uint8_t *text, uint8_t *needle, int times)
+{
uint32_t textlen = strlen((char *)text);
uint16_t needlelen = strlen((char *)needle);
return ret;
}
-uint8_t *Bs2bmNocaseCtxWrapper(uint8_t *text, uint8_t *needle, int times) {
+uint8_t *Bs2bmNocaseCtxWrapper(uint8_t *text, uint8_t *needle, int times)
+{
uint32_t textlen = strlen((char *)text);
uint16_t needlelen = strlen((char *)needle);
return ret;
}
-uint8_t *BoyerMooreCtxWrapper(uint8_t *text, uint8_t *needle, int times) {
+uint8_t *BoyerMooreCtxWrapper(uint8_t *text, uint8_t *needle, int times)
+{
uint32_t textlen = strlen((char *)text);
uint16_t needlelen = strlen((char *)needle);
return ret;
}
-uint8_t *RawCtxWrapper(uint8_t *text, uint8_t *needle, int times) {
+uint8_t *RawCtxWrapper(uint8_t *text, uint8_t *needle, int times)
+{
uint32_t textlen = strlen((char *)text);
uint16_t needlelen = strlen((char *)needle);
return ret;
}
-uint8_t *BoyerMooreNocaseCtxWrapper(uint8_t *text, uint8_t *needle, int times) {
+uint8_t *BoyerMooreNocaseCtxWrapper(uint8_t *text, uint8_t *needle, int times)
+{
uint32_t textlen = strlen((char *)text);
uint16_t needlelen = strlen((char *)needle);
/**
* \test Generic test for BasicSearch matching
*/
-int UtilSpmBasicSearchTest01() {
+int UtilSpmBasicSearchTest01()
+{
uint8_t *needle = (uint8_t *)"oPqRsT";
uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ";
uint8_t *found = BasicSearchWrapper(text, needle, 1);
/**
* \test Generic test for BasicSearch nocase matching
*/
-int UtilSpmBasicSearchNocaseTest01() {
+int UtilSpmBasicSearchNocaseTest01()
+{
uint8_t *needle = (uint8_t *)"OpQrSt";
uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ";
uint8_t *found = BasicSearchNocaseWrapper(text, needle, 1);
/**
* \test Generic test for Bs2Bm matching
*/
-int UtilSpmBs2bmSearchTest01() {
+int UtilSpmBs2bmSearchTest01()
+{
uint8_t *needle = (uint8_t *)"oPqRsT";
uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ";
uint8_t *found = Bs2bmWrapper(text, needle, 1);
/**
* \test Generic test for Bs2Bm no case matching
*/
-int UtilSpmBs2bmSearchNocaseTest01() {
+int UtilSpmBs2bmSearchNocaseTest01()
+{
uint8_t *needle = (uint8_t *)"OpQrSt";
uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ";
uint8_t *found = Bs2bmNocaseWrapper(text, needle, 1);
/**
* \test Generic test for boyer moore matching
*/
-int UtilSpmBoyerMooreSearchTest01() {
+int UtilSpmBoyerMooreSearchTest01()
+{
uint8_t *needle = (uint8_t *)"oPqRsT";
uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ";
uint8_t *found = BoyerMooreWrapper(text, needle, 1);
/**
* \test Generic test for boyer moore nocase matching
*/
-int UtilSpmBoyerMooreSearchNocaseTest01() {
+int UtilSpmBoyerMooreSearchNocaseTest01()
+{
uint8_t *needle = (uint8_t *)"OpQrSt";
uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ";
uint8_t *found = BoyerMooreNocaseWrapper(text, needle, 1);
* \test issue 130 (@redmine) check to ensure that the
* problem is not the algorithm implementation
*/
-int UtilSpmBoyerMooreSearchNocaseTestIssue130() {
+int UtilSpmBoyerMooreSearchNocaseTestIssue130()
+{
uint8_t *needle = (uint8_t *)"WWW-Authenticate: ";
uint8_t *text = (uint8_t *)"Date: Mon, 23 Feb 2009 13:31:49 GMT"
"Server: Apache\r\n"
}
/* Generic tests that should not match */
-int UtilSpmBasicSearchTest02() {
+int UtilSpmBasicSearchTest02()
+{
uint8_t *needle = (uint8_t *)"oPQRsT";
uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ";
uint8_t *found = BasicSearchWrapper(text, needle, 1);
return 1;
}
-int UtilSpmBasicSearchNocaseTest02() {
+int UtilSpmBasicSearchNocaseTest02()
+{
uint8_t *needle = (uint8_t *)"OpZrSt";
uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ";
uint8_t *found = BasicSearchNocaseWrapper(text, needle, 1);
return 1;
}
-int UtilSpmBs2bmSearchTest02() {
+int UtilSpmBs2bmSearchTest02()
+{
uint8_t *needle = (uint8_t *)"oPQRsT";
uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ";
uint8_t *found = Bs2bmWrapper(text, needle, 1);
return 1;
}
-int UtilSpmBs2bmSearchNocaseTest02() {
+int UtilSpmBs2bmSearchNocaseTest02()
+{
uint8_t *needle = (uint8_t *)"OpZrSt";
uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ";
uint8_t *found = Bs2bmNocaseWrapper(text, needle, 1);
return 1;
}
-int UtilSpmBoyerMooreSearchTest02() {
+int UtilSpmBoyerMooreSearchTest02()
+{
uint8_t *needle = (uint8_t *)"oPQRsT";
uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ";
uint8_t *found = BoyerMooreWrapper(text, needle, 1);
return 1;
}
-int UtilSpmBoyerMooreSearchNocaseTest02() {
+int UtilSpmBoyerMooreSearchNocaseTest02()
+{
uint8_t *needle = (uint8_t *)"OpZrSt";
uint8_t *text = (uint8_t *)"aBcDeFgHiJkLmNoPqRsTuVwXyZ";
uint8_t *found = BoyerMooreNocaseWrapper(text, needle, 1);
/**
* \test Check that all the algorithms work at any offset and any pattern length
*/
-int UtilSpmSearchOffsetsTest01() {
+int UtilSpmSearchOffsetsTest01()
+{
char *text[26][27];
text[0][0]="azzzzzzzzzzzzzzzzzzzzzzzzzz";
text[0][1]="zazzzzzzzzzzzzzzzzzzzzzzzzz";
/**
* \test Check that all the algorithms (no case) work at any offset and any pattern length
*/
-int UtilSpmSearchOffsetsNocaseTest01() {
+int UtilSpmSearchOffsetsNocaseTest01()
+{
char *text[26][27];
text[0][0]="azzzzzzzzzzzzzzzzzzzzzzzzzz";
text[0][1]="zazzzzzzzzzzzzzzzzzzzzzzzzz";
/**
* \test Give some stats
*/
-int UtilSpmSearchStatsTest01() {
+int UtilSpmSearchStatsTest01()
+{
char *text[16];
text[0]="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzza";
text[1]="aaaaaaaaazaaaaaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaaaazaaaaaaaaazaaaaaaaaaazaaaaaaaaaaaaazaaaaaaaaazaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaazaaaaaaaaazaaaaaaaaaazaaaaaraaaaazaaaaaaazaaaaaaaaaaaaaazaaaaaaaazaaaaaaaaazaaaaaaaaaaaaB";
/**
* \test Give some stats for
*/
-int UtilSpmSearchStatsTest02() {
+int UtilSpmSearchStatsTest02()
+{
char *text[16];
text[0]="zzzzzzzzzzzzzzzzzza";
text[1]="zzzzzzzzzzzzzzzzzzaB";
}
-int UtilSpmSearchStatsTest03() {
+int UtilSpmSearchStatsTest03()
+{
char *text[16];
text[0]="zzzzzza";
text[1]="zzzzzzaB";
/**
* \test Give some stats
*/
-int UtilSpmSearchStatsTest04() {
+int UtilSpmSearchStatsTest04()
+{
char *text[16];
text[0]="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzza";
text[1]="aaaaaaaaazaaaaaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaaaazaaaaaaaaazaaaaaaaaaazaaaaaaaaaaaaazaaaaaaaaazaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaazaaaaaaaaazaaaaaaaaaazaaaaaraaaaazaaaaaaazaaaaaaaaaaaaaazaaaaaaaazaaaaaaaaazaaaaaaaaaaaaB";
/**
* \test Give some stats for
*/
-int UtilSpmSearchStatsTest05() {
+int UtilSpmSearchStatsTest05()
+{
char *text[16];
text[0]="zzzzzzzzzzzzzzzzzza";
text[1]="zzzzzzzzzzzzzzzzzzaB";
}
-int UtilSpmSearchStatsTest06() {
+int UtilSpmSearchStatsTest06()
+{
char *text[16];
text[0]="zzzzkzzzzzzzkzzzzzza";
text[1]="BBBBkBBBBBBBkBBBBBaB";
return 1;
}
-int UtilSpmSearchStatsTest07() {
+int UtilSpmSearchStatsTest07()
+{
char *text[16];
text[0]="zzzza";
text[1]="BBBaB";
/**
* \test Give some stats for no case algorithms
*/
-int UtilSpmNocaseSearchStatsTest01() {
+int UtilSpmNocaseSearchStatsTest01()
+{
char *text[16];
text[0]="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzza";
text[1]="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzaB";
return 1;
}
-int UtilSpmNocaseSearchStatsTest02() {
+int UtilSpmNocaseSearchStatsTest02()
+{
char *text[16];
text[0]="zzzzzzzzzzzzzzzzzza";
text[1]="zzzzzzzzzzzzzzzzzzaB";
}
-int UtilSpmNocaseSearchStatsTest03() {
+int UtilSpmNocaseSearchStatsTest03()
+{
char *text[16];
text[0]="zzzzkzzzzzzzkzzzzzza";
text[1]="BBBBkBBBBBBBkBBBBBaB";
/**
* \test Give some stats for no case algorithms
*/
-int UtilSpmNocaseSearchStatsTest04() {
+int UtilSpmNocaseSearchStatsTest04()
+{
char *text[16];
text[0]="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzza";
text[1]="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzaB";
return 1;
}
-int UtilSpmNocaseSearchStatsTest05() {
+int UtilSpmNocaseSearchStatsTest05()
+{
char *text[16];
text[0]="zzzzzzzzzzzzzzzzzza";
text[1]="zzzzzzzzzzzzzzzzzzaB";
}
-int UtilSpmNocaseSearchStatsTest06() {
+int UtilSpmNocaseSearchStatsTest06()
+{
char *text[16];
text[0]="zzzzkzzzzzzzkzzzzzza";
text[1]="BBBBkBBBBBBBkBBBBBaB";
return 1;
}
-int UtilSpmNocaseSearchStatsTest07() {
+int UtilSpmNocaseSearchStatsTest07()
+{
char *text[16];
text[0]="zzzza";
text[1]="bbbAb";
static int storage_registraton_closed = 0;
static StorageMapping **storage_map = NULL;
-const char *StoragePrintType(StorageEnum type) {
+const char *StoragePrintType(StorageEnum type)
+{
switch(type) {
case STORAGE_HOST:
return "host";
return "invalid";
}
-void StorageInit(void) {
+void StorageInit(void)
+{
memset(&storage_max_id, 0x00, sizeof(storage_max_id));
storage_list = NULL;
storage_map = NULL;
storage_registraton_closed = 0;
}
-void StorageCleanup(void) {
+void StorageCleanup(void)
+{
if (storage_map) {
int i;
for (i = 0; i < STORAGE_MAX; i++) {
storage_list = NULL;
}
-int StorageRegister(const StorageEnum type, const char *name, const unsigned int size, void *(*Alloc)(unsigned int), void (*Free)(void *)) {
+int StorageRegister(const StorageEnum type, const char *name, const unsigned int size, void *(*Alloc)(unsigned int), void (*Free)(void *))
+{
if (storage_registraton_closed)
return -1;
return entry->id;
}
-int StorageFinalize(void) {
+int StorageFinalize(void)
+{
int count = 0;
int i;
return 0;
}
-unsigned int StorageGetCnt(StorageEnum type) {
+unsigned int StorageGetCnt(StorageEnum type)
+{
return storage_max_id[type];
}
*
* \todo we could return -1 when registration isn't closed yet, however
* this will break lots of tests currently, so not doing it now */
-unsigned int StorageGetSize(StorageEnum type) {
+unsigned int StorageGetSize(StorageEnum type)
+{
return storage_max_id[type] * sizeof(void *);
}
-void *StorageGetById(const Storage *storage, const StorageEnum type, const int id) {
+void *StorageGetById(const Storage *storage, const StorageEnum type, const int id)
+{
#ifdef DEBUG
BUG_ON(!storage_registraton_closed);
#endif
return storage[id];
}
-int StorageSetById(Storage *storage, const StorageEnum type, const int id, void *ptr) {
+int StorageSetById(Storage *storage, const StorageEnum type, const int id, void *ptr)
+{
#ifdef DEBUG
BUG_ON(!storage_registraton_closed);
#endif
return 0;
}
-void *StorageAllocByIdPrealloc(Storage *storage, StorageEnum type, int id) {
+void *StorageAllocByIdPrealloc(Storage *storage, StorageEnum type, int id)
+{
#ifdef DEBUG
BUG_ON(!storage_registraton_closed);
#endif
return storage[id];
}
-void *StorageAllocById(Storage **storage, StorageEnum type, int id) {
+void *StorageAllocById(Storage **storage, StorageEnum type, int id)
+{
#ifdef DEBUG
BUG_ON(!storage_registraton_closed);
#endif
return store[id];
}
-void StorageFreeById(Storage *storage, StorageEnum type, int id) {
+void StorageFreeById(Storage *storage, StorageEnum type, int id)
+{
#ifdef DEBUG
BUG_ON(!storage_registraton_closed);
#endif
}
}
-void StorageFreeAll(Storage *storage, StorageEnum type) {
+void StorageFreeAll(Storage *storage, StorageEnum type)
+{
if (*storage == NULL)
return;
}
}
-void StorageFree(Storage **storage, StorageEnum type) {
+void StorageFree(Storage **storage, StorageEnum type)
+{
if (*storage == NULL)
return;
#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 StorageTest01(void) {
+static int StorageTest01(void)
+{
StorageInit();
int id = StorageRegister(STORAGE_HOST, "test", 8, StorageTestAlloc, StorageTestFree);
int abc;
};
-static void *StorageTest02Init(unsigned int size) {
+static void *StorageTest02Init(unsigned int size)
+{
struct StorageTest02Data *data = (struct StorageTest02Data *)SCMalloc(size);
if (data != NULL)
data->abc = 1234;
return (void *)data;
}
-static int StorageTest02(void) {
+static int StorageTest02(void)
+{
struct StorageTest02Data *test = NULL;
StorageInit();
return 0;
}
-static int StorageTest03(void) {
+static int StorageTest03(void)
+{
StorageInit();
int id = StorageRegister(STORAGE_HOST, "test", 8, StorageTestAlloc, StorageTestFree);
return 0;
}
-void StorageRegisterTests(void) {
+void StorageRegisterTests(void)
+{
UtRegisterTest("StorageTest01", StorageTest01, 1);
UtRegisterTest("StorageTest02", StorageTest02, 1);
UtRegisterTest("StorageTest03", StorageTest03, 1);
-/* Copyright (C) 2007-2010 Open Information Security Foundation
+/* Copyright (C) 2007-2013 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
};
/** \brief returns the syslog facility enum map */
-SCEnumCharMap *SCSyslogGetFacilityMap() {
+SCEnumCharMap *SCSyslogGetFacilityMap()
+{
return sc_syslog_facility_map;
}
};
/** \brief returns the syslog facility enum map */
-SCEnumCharMap *SCSyslogGetLogLevelMap() {
+SCEnumCharMap *SCSyslogGetLogLevelMap()
+{
return sc_syslog_level_map;
}
tzset();
}
-void TimeDeinit(void) {
+void TimeDeinit(void)
+{
SCSpinDestroy(¤t_time_spinlock);
}
}
/** \brief set the time to "gettimeofday" meant for testing */
-void TimeSetToCurrentTime(void) {
+void TimeSetToCurrentTime(void)
+{
struct timeval tv;
memset(&tv, 0x00, sizeof(tv));
/** \brief increment the time in the engine
* \param tv_sec seconds to increment the time with */
-void TimeSetIncrementTime(uint32_t tv_sec) {
+void TimeSetIncrementTime(uint32_t tv_sec)
+{
struct timeval tv;
memset(&tv, 0x00, sizeof(tv));
TimeGet(&tv);
-/* Copyright (C) 2007-2010 Open Information Security Foundation
+/* Copyright (C) 2007-2013 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
#include "util-debug.h"
-void GenericVarFree(GenericVar *gv) {
+void GenericVarFree(GenericVar *gv)
+{
if (gv == NULL)
return;
GenericVarFree(next_gv);
}
-void GenericVarAppend(GenericVar **list, GenericVar *gv) {
+void GenericVarAppend(GenericVar **list, GenericVar *gv)
+{
gv->next = NULL;
if (*list == NULL) {
}
}
-void GenericVarRemove(GenericVar **list, GenericVar *gv) {
+void GenericVarRemove(GenericVar **list, GenericVar *gv)
+{
if (*list == NULL)
return;
listgv = listgv->next;
}
}
-