compiler: more strict compiler warnings

Set flags by default:

    -Wmissing-prototypes
    -Wmissing-declarations
    -Wstrict-prototypes
    -Wwrite-strings
    -Wcast-align
    -Wbad-function-cast
    -Wformat-security
    -Wno-format-nonliteral
    -Wmissing-format-attribute
    -funsigned-char

Fix minor compiler warnings for these new flags on gcc and clang.
pull/2684/head
Victor Julien 8 years ago
parent 342059835f
commit ab1200fbd7

@ -524,7 +524,14 @@ CLEANFILES = $(PTXS) cuda-ptxdump.h
endif
# default CFLAGS
AM_CFLAGS = ${OPTIMIZATION_CFLAGS} ${GCC_CFLAGS} ${CLANG_CFLAGS} ${SECCFLAGS} ${PCAP_CFLAGS} -Wall -Wno-unused-parameter -std=gnu99 -DLOCAL_STATE_DIR=\"$(localstatedir)\"
AM_CFLAGS = ${OPTIMIZATION_CFLAGS} ${GCC_CFLAGS} ${CLANG_CFLAGS} \
${SECCFLAGS} ${PCAP_CFLAGS} -DLOCAL_STATE_DIR=\"$(localstatedir)\" \
-std=gnu99 \
-Wall -Wno-unused-parameter -Wmissing-prototypes -Wmissing-declarations \
-Wstrict-prototypes -Wwrite-strings -Wbad-function-cast \
-Wformat-security -Wno-format-nonliteral -Wmissing-format-attribute \
-funsigned-char
# different flags for different cases
if DEBUG
AM_CFLAGS += -ggdb -O0

@ -370,7 +370,7 @@ static TmEcode AlertDebugLogDecoderEvent(ThreadVars *tv, const Packet *p, void *
return TM_ECODE_OK;
}
static TmEcode AlertDebugLogThreadInit(ThreadVars *t, void *initdata, void **data)
static TmEcode AlertDebugLogThreadInit(ThreadVars *t, const void *initdata, void **data)
{
AlertDebugLogThread *aft = SCMalloc(sizeof(AlertDebugLogThread));
if (unlikely(aft == NULL))

@ -67,7 +67,7 @@
* holding multiple alerts. */
#define MAX_FASTLOG_BUFFER_SIZE (2 * MAX_FASTLOG_ALERT_SIZE)
TmEcode AlertFastLogThreadInit(ThreadVars *, void *, void **);
TmEcode AlertFastLogThreadInit(ThreadVars *, const void *, void **);
TmEcode AlertFastLogThreadDeinit(ThreadVars *, void *);
void AlertFastLogRegisterTests(void);
static void AlertFastLogDeInitCtx(OutputCtx *);
@ -134,7 +134,7 @@ int AlertFastLogger(ThreadVars *tv, void *data, const Packet *p)
continue;
}
char *action = "";
const char *action = "";
if ((pa->action & ACTION_DROP) && EngineModeIsIPS()) {
action = "[Drop] ";
} else if (pa->action & ACTION_DROP) {
@ -182,7 +182,7 @@ int AlertFastLogger(ThreadVars *tv, void *data, const Packet *p)
return TM_ECODE_OK;
}
TmEcode AlertFastLogThreadInit(ThreadVars *t, void *initdata, void **data)
TmEcode AlertFastLogThreadInit(ThreadVars *t, const void *initdata, void **data)
{
AlertFastLogThread *aft = SCMalloc(sizeof(AlertFastLogThread));
if (unlikely(aft == NULL))
@ -253,7 +253,7 @@ static void AlertFastLogDeInitCtx(OutputCtx *output_ctx)
#ifdef UNITTESTS
static int AlertFastLogTest01()
static int AlertFastLogTest01(void)
{
int result = 0;
uint8_t *buf = (uint8_t *) "GET /one/ HTTP/1.1\r\n"
@ -298,7 +298,7 @@ static int AlertFastLogTest01()
return result;
}
static int AlertFastLogTest02()
static int AlertFastLogTest02(void)
{
int result = 0;
uint8_t *buf = (uint8_t *) "GET /one/ HTTP/1.1\r\n"

@ -58,6 +58,8 @@
#include "stream.h"
#include "alert-prelude.h"
#ifndef PRELUDE
/* Handle the case where no PRELUDE support is compiled in. */

@ -88,7 +88,7 @@ static void AlertSyslogDeInitCtx(OutputCtx *output_ctx)
* \param conf The configuration node for this output.
* \return A OutputCtx pointer on success, NULL on failure.
*/
OutputCtx *AlertSyslogInitCtx(ConfNode *conf)
static OutputCtx *AlertSyslogInitCtx(ConfNode *conf)
{
const char *facility_s = ConfNodeLookupChildValue(conf, "facility");
if (facility_s == NULL) {
@ -146,7 +146,7 @@ OutputCtx *AlertSyslogInitCtx(ConfNode *conf)
* \param initdata Pointer to the output context
* \param data pointer to pointer to point to the AlertSyslogThread
*/
static TmEcode AlertSyslogThreadInit(ThreadVars *t, void *initdata, void **data)
static TmEcode AlertSyslogThreadInit(ThreadVars *t, const void *initdata, void **data)
{
if(initdata == NULL) {
SCLogDebug("Error getting context for AlertSyslog. \"initdata\" "
@ -200,7 +200,7 @@ static TmEcode AlertSyslogIPv4(ThreadVars *tv, const Packet *p, void *data)
{
AlertSyslogThread *ast = (AlertSyslogThread *)data;
int i;
char *action = "";
const char *action = "";
if (p->alerts.cnt == 0)
return TM_ECODE_OK;
@ -257,7 +257,7 @@ static TmEcode AlertSyslogIPv6(ThreadVars *tv, const Packet *p, void *data)
{
AlertSyslogThread *ast = (AlertSyslogThread *)data;
int i;
char *action = "";
const char *action = "";
if (p->alerts.cnt == 0)
return TM_ECODE_OK;
@ -318,7 +318,7 @@ static TmEcode AlertSyslogDecoderEvent(ThreadVars *tv, const Packet *p, void *da
{
AlertSyslogThread *ast = (AlertSyslogThread *)data;
int i;
char *action = "";
const char *action = "";
if (p->alerts.cnt == 0)
return TM_ECODE_OK;

@ -218,8 +218,7 @@ typedef struct Unified2AlertThread_ {
SC_ATOMIC_DECLARE(unsigned int, unified2_event_id); /**< Atomic counter, to link relative event */
/** prototypes */
//TmEcode Unified2Alert (ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *);
TmEcode Unified2AlertThreadInit(ThreadVars *, void *, void **);
TmEcode Unified2AlertThreadInit(ThreadVars *, const void *, void **);
TmEcode Unified2AlertThreadDeinit(ThreadVars *, void *);
static int Unified2IPv4TypeAlert(ThreadVars *, const Packet *, void *);
static int Unified2IPv6TypeAlert(ThreadVars *, const Packet *, void *);
@ -1147,7 +1146,7 @@ static int Unified2IPv4TypeAlert (ThreadVars *tv, const Packet *p, void *data)
* \retval TM_ECODE_FAILED on failure
*/
TmEcode Unified2AlertThreadInit(ThreadVars *t, void *initdata, void **data)
TmEcode Unified2AlertThreadInit(ThreadVars *t, const void *initdata, void **data)
{
Unified2AlertThread *aun = SCMalloc(sizeof(Unified2AlertThread));
if (unlikely(aun == NULL))
@ -1406,7 +1405,7 @@ static int Unified2AlertOpenFileCtx(LogFileCtx *file_ctx, const char *prefix,
gettimeofday(&ts, NULL);
/* create the filename to use */
char *log_dir;
const char *log_dir;
log_dir = ConfigGetLogDirectory();
if (file_ctx->nostamp) {

@ -242,7 +242,7 @@ typedef struct DCERPCUDP_ {
int32_t DCERPCParser(DCERPC *, uint8_t *, uint32_t);
void hexdump(const void *buf, size_t len);
void printUUID(char *type, DCERPCUuidEntry *uuid);
void printUUID(const char *type, DCERPCUuidEntry *uuid);
#endif /* __APP_LAYER_DCERPC_COMMON_H__ */

@ -835,7 +835,7 @@ static int DCERPCUDPRegisterPatternsForProtocolDetection(void)
void RegisterDCERPCUDPParsers(void)
{
char *proto_name = "dcerpc";
const char *proto_name = "dcerpc";
if (AppLayerProtoDetectConfProtoDetectionEnabled("udp", proto_name)) {
AppLayerProtoDetectRegisterProtocol(ALPROTO_DCERPC, proto_name);
@ -871,7 +871,7 @@ void RegisterDCERPCUDPParsers(void)
/** \test DCERPC UDP Header Parsing and UUID handling
*/
int DCERPCUDPParserTest01(void)
static int DCERPCUDPParserTest01(void)
{
int result = 1;
Flow f;

@ -143,7 +143,7 @@ void hexdump(/*Flow *f,*/ const void *buf, size_t len)
* \brief printUUID function used to print UUID, Major and Minor Version Number
* and if it was Accepted or Rejected in the BIND_ACK.
*/
void printUUID(char *type, DCERPCUuidEntry *uuid)
void printUUID(const char *type, DCERPCUuidEntry *uuid)
{
uint8_t i = 0;
if (uuid == NULL) {
@ -2091,7 +2091,7 @@ static int DCERPCRegisterPatternsForProtocolDetection(void)
void RegisterDCERPCParsers(void)
{
char *proto_name = "dcerpc";
const char *proto_name = "dcerpc";
if (AppLayerProtoDetectConfProtoDetectionEnabled("tcp", proto_name)) {
AppLayerProtoDetectRegisterProtocol(ALPROTO_DCERPC, proto_name);
@ -2144,7 +2144,7 @@ void RegisterDCERPCParsers(void)
/* set this to 1 to see problem */
int DCERPCParserTest01(void)
static int DCERPCParserTest01(void)
{
int result = 1;
Flow f;
@ -2603,7 +2603,7 @@ end:
/** \test DCERPC Request decoding and opnum parsing.
*/
int DCERPCParserTest02(void)
static int DCERPCParserTest02(void)
{
int result = 1;
Flow f;
@ -2806,7 +2806,7 @@ end:
/** \test Test endianness handling
*/
int DCERPCParserTest03(void)
static int DCERPCParserTest03(void)
{
int result = 1;
Flow f;
@ -3003,7 +3003,7 @@ end:
/**
* \todo Needs to be rewritten
*/
int DCERPCParserTest04(void)
static int DCERPCParserTest04(void)
{
/* AWS - Disabled this test since clamav FPs on the payloads used.
* We will have to rewrite this test with new payloads. Will be done
@ -4363,7 +4363,7 @@ end:
/**
* \test General test.
*/
int DCERPCParserTest05(void)
static int DCERPCParserTest05(void)
{
int result = 1;
Flow f;
@ -4465,7 +4465,7 @@ end:
/**
* \test DCERPC fragmented bind PDU(one PDU which is frag'ed)
*/
int DCERPCParserTest06(void)
static int DCERPCParserTest06(void)
{
int result = 1;
Flow f;
@ -4631,7 +4631,7 @@ end:
/**
* \test DCERPC fragmented bind PDU(one PDU which is frag'ed).
*/
int DCERPCParserTest07(void)
static int DCERPCParserTest07(void)
{
int result = 1;
Flow f;
@ -4734,7 +4734,7 @@ end:
/**
* \test DCERPC fragmented bind PDU(one PDU which is frag'ed).
*/
int DCERPCParserTest08(void)
static int DCERPCParserTest08(void)
{
int result = 1;
Flow f;
@ -4795,7 +4795,7 @@ end:
/**
* \test DCERPC fragmented bind PDU(one PDU which is frag'ed).
*/
int DCERPCParserTest09(void)
static int DCERPCParserTest09(void)
{
int result = 1;
Flow f;
@ -4856,7 +4856,7 @@ end:
/**
* \test DCERPC fragmented PDU.
*/
int DCERPCParserTest10(void)
static int DCERPCParserTest10(void)
{
int result = 1;
Flow f;
@ -4956,7 +4956,7 @@ end:
/**
* \test DCERPC fragmented PDU.
*/
int DCERPCParserTest11(void)
static int DCERPCParserTest11(void)
{
int result = 1;
Flow f;
@ -5061,7 +5061,7 @@ end:
/**
* \test DCERPC fragmented PDU.
*/
int DCERPCParserTest12(void)
static int DCERPCParserTest12(void)
{
int result = 1;
Flow f;
@ -5143,7 +5143,7 @@ end:
* \test Check if the parser accepts bind pdus that have context ids starting
* from a non-zero value.
*/
int DCERPCParserTest13(void)
static int DCERPCParserTest13(void)
{
int result = 1;
Flow f;
@ -5228,7 +5228,7 @@ end:
/**
* \test Check for another endless loop with bind pdus.
*/
int DCERPCParserTest14(void)
static int DCERPCParserTest14(void)
{
int result = 1;
Flow f;
@ -5294,7 +5294,7 @@ end:
/**
* \test Check for another endless loop for bind_ack pdus.
*/
int DCERPCParserTest15(void)
static int DCERPCParserTest15(void)
{
int result = 1;
Flow f;
@ -5356,7 +5356,7 @@ end:
/**
* \test Check for correct internal ids for bind_acks.
*/
int DCERPCParserTest16(void)
static int DCERPCParserTest16(void)
{
int result = 1;
Flow f;
@ -5955,7 +5955,7 @@ end:
/**
* \test Check for correct internal ids for bind_acks + alter_contexts
*/
int DCERPCParserTest17(void)
static int DCERPCParserTest17(void)
{
int result = 1;
Flow f;
@ -6149,7 +6149,7 @@ end:
/**
* \test DCERPC fragmented PDU.
*/
int DCERPCParserTest18(void)
static int DCERPCParserTest18(void)
{
int result = 1;
Flow f;
@ -6228,7 +6228,7 @@ end:
return result;
}
int DCERPCParserTest19(void)
static int DCERPCParserTest19(void)
{
int result = 0;
Flow f;

@ -154,7 +154,7 @@ typedef struct AppLayerProtoDetectCtx_ {
/* Indicates the protocols that have registered themselves
* for protocol detection. This table is independent of the
* ipproto. */
char *alproto_names[ALPROTO_MAX];
const char *alproto_names[ALPROTO_MAX];
} AppLayerProtoDetectCtx;
/**
@ -636,7 +636,8 @@ AppLayerProtoDetectProbingParserElementDuplicate(AppLayerProtoDetectProbingParse
SCReturnPtr(new_pe, "AppLayerProtoDetectProbingParserElement");
}
void AppLayerProtoDetectPrintProbingParsers(AppLayerProtoDetectProbingParser *pp)
#ifdef DEBUG
static void AppLayerProtoDetectPrintProbingParsers(AppLayerProtoDetectProbingParser *pp)
{
SCEnter();
@ -772,6 +773,7 @@ void AppLayerProtoDetectPrintProbingParsers(AppLayerProtoDetectProbingParser *pp
SCReturn;
}
#endif
static void AppLayerProtoDetectProbingParserElementAppend(AppLayerProtoDetectProbingParserElement **head_pe,
AppLayerProtoDetectProbingParserElement *new_pe)
@ -1244,7 +1246,7 @@ static int AppLayerProtoDetectPMAddSignature(AppLayerProtoDetectPMCtx *ctx, Dete
}
static int AppLayerProtoDetectPMRegisterPattern(uint8_t ipproto, AppProto alproto,
char *pattern,
const char *pattern,
uint16_t depth, uint16_t offset,
uint8_t direction,
uint8_t is_cs)
@ -1393,7 +1395,7 @@ int AppLayerProtoDetectPrepareState(void)
* \param direction STREAM_TOSERVER or STREAM_TOCLIENT for dp or sp
*/
void AppLayerProtoDetectPPRegister(uint8_t ipproto,
char *portstr,
const char *portstr,
AppProto alproto,
uint16_t min_depth, uint16_t max_depth,
uint8_t direction,
@ -1505,7 +1507,7 @@ int AppLayerProtoDetectPPParseConfPorts(const char *ipproto_name,
/***** PM registration *****/
int AppLayerProtoDetectPMRegisterPatternCS(uint8_t ipproto, AppProto alproto,
char *pattern,
const char *pattern,
uint16_t depth, uint16_t offset,
uint8_t direction)
{
@ -1520,7 +1522,7 @@ int AppLayerProtoDetectPMRegisterPatternCS(uint8_t ipproto, AppProto alproto,
}
int AppLayerProtoDetectPMRegisterPatternCI(uint8_t ipproto, AppProto alproto,
char *pattern,
const char *pattern,
uint16_t depth, uint16_t offset,
uint8_t direction)
{
@ -1598,7 +1600,7 @@ int AppLayerProtoDetectDeSetup(void)
SCReturnInt(0);
}
void AppLayerProtoDetectRegisterProtocol(AppProto alproto, char *alproto_name)
void AppLayerProtoDetectRegisterProtocol(AppProto alproto, const char *alproto_name)
{
SCEnter();
@ -1770,7 +1772,7 @@ void AppLayerProtoDetectSupportedIpprotos(AppProto alproto, uint8_t *ipprotos)
SCReturn;
}
AppProto AppLayerProtoDetectGetProtoByName(char *alproto_name)
AppProto AppLayerProtoDetectGetProtoByName(const char *alproto_name)
{
SCEnter();
@ -1787,7 +1789,7 @@ AppProto AppLayerProtoDetectGetProtoByName(char *alproto_name)
SCReturnCT(ALPROTO_UNKNOWN, "AppProto");
}
char *AppLayerProtoDetectGetProtoName(AppProto alproto)
const char *AppLayerProtoDetectGetProtoName(AppProto alproto)
{
return alpd_ctx.alproto_names[alproto];
}
@ -1830,12 +1832,12 @@ void AppLayerProtoDetectUnittestCtxRestore(void)
SCReturn;
}
int AppLayerProtoDetectTest01(void)
static int AppLayerProtoDetectTest01(void)
{
AppLayerProtoDetectUnittestCtxBackup();
AppLayerProtoDetectSetup();
char *buf;
const char *buf;
int r = 0;
buf = "HTTP";
@ -1863,15 +1865,14 @@ int AppLayerProtoDetectTest01(void)
return r;
}
int AppLayerProtoDetectTest02(void)
static int AppLayerProtoDetectTest02(void)
{
AppLayerProtoDetectUnittestCtxBackup();
AppLayerProtoDetectSetup();
char *buf;
int r = 0;
buf = "HTTP";
const char *buf = "HTTP";
AppLayerProtoDetectPMRegisterPatternCS(IPPROTO_TCP, ALPROTO_HTTP, buf, 4, 0, STREAM_TOCLIENT);
buf = "ftp";
AppLayerProtoDetectPMRegisterPatternCS(IPPROTO_TCP, ALPROTO_FTP, buf, 4, 0, STREAM_TOCLIENT);
@ -1912,13 +1913,13 @@ int AppLayerProtoDetectTest02(void)
return r;
}
int AppLayerProtoDetectTest03(void)
static int AppLayerProtoDetectTest03(void)
{
AppLayerProtoDetectUnittestCtxBackup();
AppLayerProtoDetectSetup();
uint8_t l7data[] = "HTTP/1.1 200 OK\r\nServer: Apache/1.0\r\n\r\n";
char *buf;
const char *buf;
int r = 0;
Flow f;
AppProto pm_results[ALPROTO_MAX];
@ -1987,13 +1988,13 @@ int AppLayerProtoDetectTest03(void)
return r;
}
int AppLayerProtoDetectTest04(void)
static int AppLayerProtoDetectTest04(void)
{
AppLayerProtoDetectUnittestCtxBackup();
AppLayerProtoDetectSetup();
uint8_t l7data[] = "HTTP/1.1 200 OK\r\nServer: Apache/1.0\r\n\r\n";
char *buf;
const char *buf;
int r = 0;
Flow f;
AppProto pm_results[ALPROTO_MAX];
@ -2056,13 +2057,13 @@ int AppLayerProtoDetectTest04(void)
return r;
}
int AppLayerProtoDetectTest05(void)
static int AppLayerProtoDetectTest05(void)
{
AppLayerProtoDetectUnittestCtxBackup();
AppLayerProtoDetectSetup();
uint8_t l7data[] = "HTTP/1.1 200 OK\r\nServer: Apache/1.0\r\n\r\n<HTML><BODY>Blahblah</BODY></HTML>";
char *buf;
const char *buf;
int r = 0;
Flow f;
AppProto pm_results[ALPROTO_MAX];
@ -2131,13 +2132,13 @@ int AppLayerProtoDetectTest05(void)
return r;
}
int AppLayerProtoDetectTest06(void)
static int AppLayerProtoDetectTest06(void)
{
AppLayerProtoDetectUnittestCtxBackup();
AppLayerProtoDetectSetup();
uint8_t l7data[] = "220 Welcome to the OISF FTP server\r\n";
char *buf;
const char *buf;
int r = 0;
Flow f;
AppProto pm_results[ALPROTO_MAX];
@ -2204,13 +2205,13 @@ int AppLayerProtoDetectTest06(void)
return r;
}
int AppLayerProtoDetectTest07(void)
static int AppLayerProtoDetectTest07(void)
{
AppLayerProtoDetectUnittestCtxBackup();
AppLayerProtoDetectSetup();
uint8_t l7data[] = "220 Welcome to the OISF HTTP/FTP server\r\n";
char *buf;
const char *buf;
int r = 0;
Flow f;
AppProto pm_results[ALPROTO_MAX];
@ -2273,7 +2274,7 @@ int AppLayerProtoDetectTest07(void)
return r;
}
int AppLayerProtoDetectTest08(void)
static int AppLayerProtoDetectTest08(void)
{
AppLayerProtoDetectUnittestCtxBackup();
AppLayerProtoDetectSetup();
@ -2298,7 +2299,7 @@ int AppLayerProtoDetectTest08(void)
0x20, 0x4c, 0x4d, 0x20, 0x30, 0x2e, 0x31, 0x32,
0x00
};
char *buf;
const char *buf;
int r = 0;
Flow f;
AppProto pm_results[ALPROTO_MAX];
@ -2361,7 +2362,7 @@ int AppLayerProtoDetectTest08(void)
return r;
}
int AppLayerProtoDetectTest09(void)
static int AppLayerProtoDetectTest09(void)
{
AppLayerProtoDetectUnittestCtxBackup();
AppLayerProtoDetectSetup();
@ -2382,7 +2383,7 @@ int AppLayerProtoDetectTest09(void)
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x02, 0x02
};
char *buf;
const char *buf;
int r = 0;
Flow f;
AppProto pm_results[ALPROTO_MAX];
@ -2445,7 +2446,7 @@ int AppLayerProtoDetectTest09(void)
return r;
}
int AppLayerProtoDetectTest10(void)
static int AppLayerProtoDetectTest10(void)
{
AppLayerProtoDetectUnittestCtxBackup();
AppLayerProtoDetectSetup();
@ -2461,7 +2462,7 @@ int AppLayerProtoDetectTest10(void)
0xeb, 0x1c, 0xc9, 0x11, 0x9f, 0xe8, 0x08, 0x00,
0x2b, 0x10, 0x48, 0x60, 0x02, 0x00, 0x00, 0x00
};
char *buf;
const char *buf;
int r = 0;
Flow f;
AppProto pm_results[ALPROTO_MAX];
@ -2528,7 +2529,7 @@ int AppLayerProtoDetectTest10(void)
* \test Why we still get http for connect... obviously because
* we also match on the reply, duh
*/
int AppLayerProtoDetectTest11(void)
static int AppLayerProtoDetectTest11(void)
{
AppLayerProtoDetectUnittestCtxBackup();
AppLayerProtoDetectSetup();
@ -2627,7 +2628,7 @@ int AppLayerProtoDetectTest11(void)
/**
* \test AlpProtoSignature test
*/
int AppLayerProtoDetectTest12(void)
static int AppLayerProtoDetectTest12(void)
{
AppLayerProtoDetectUnittestCtxBackup();
AppLayerProtoDetectSetup();
@ -2678,7 +2679,7 @@ int AppLayerProtoDetectTest12(void)
* \test What about if we add some sigs only for udp but call for tcp?
* It should not detect any proto
*/
int AppLayerProtoDetectTest13(void)
static int AppLayerProtoDetectTest13(void)
{
AppLayerProtoDetectUnittestCtxBackup();
AppLayerProtoDetectSetup();
@ -2769,7 +2770,7 @@ int AppLayerProtoDetectTest13(void)
* It should detect ALPROTO_HTTP (over udp). This is just a check
* to ensure that TCP/UDP differences work correctly.
*/
int AppLayerProtoDetectTest14(void)
static int AppLayerProtoDetectTest14(void)
{
AppLayerProtoDetectUnittestCtxBackup();
AppLayerProtoDetectSetup();
@ -2856,7 +2857,7 @@ int AppLayerProtoDetectTest14(void)
}
typedef struct AppLayerProtoDetectPPTestDataElement_ {
char *alproto_name;
const char *alproto_name;
AppProto alproto;
uint16_t port;
uint32_t alproto_mask;

@ -61,7 +61,7 @@ int AppLayerProtoDetectPrepareState(void);
/***** PP registration *****/
void AppLayerProtoDetectPPRegister(uint8_t ipproto,
char *portstr,
const char *portstr,
AppProto alproto,
uint16_t min_depth, uint16_t max_depth,
uint8_t direction,
@ -84,14 +84,14 @@ int AppLayerProtoDetectPPParseConfPorts(const char *ipproto_name,
* \brief Registers a case-sensitive pattern for protocol detection.
*/
int AppLayerProtoDetectPMRegisterPatternCS(uint8_t ipproto, AppProto alproto,
char *pattern,
const char *pattern,
uint16_t depth, uint16_t offset,
uint8_t direction);
/**
* \brief Registers a case-insensitive pattern for protocol detection.
*/
int AppLayerProtoDetectPMRegisterPatternCI(uint8_t ipproto, AppProto alproto,
char *pattern,
const char *pattern,
uint16_t depth, uint16_t offset,
uint8_t direction);
@ -134,7 +134,7 @@ int AppLayerProtoDetectDeSetup(void);
* \retval 0 On success;
* -1 On failure.
*/
void AppLayerProtoDetectRegisterProtocol(AppProto alproto, char *alproto_name);
void AppLayerProtoDetectRegisterProtocol(AppProto alproto, const char *alproto_name);
/**
* \brief Given a protocol name, checks if proto detection is enabled in
@ -168,8 +168,8 @@ void AppLayerProtoDetectDestroyCtxThread(AppLayerProtoDetectThreadCtx *tctx);
/***** Utility *****/
void AppLayerProtoDetectSupportedIpprotos(AppProto alproto, uint8_t *ipprotos);
AppProto AppLayerProtoDetectGetProtoByName(char *alproto_name);
char *AppLayerProtoDetectGetProtoName(AppProto alproto);
AppProto AppLayerProtoDetectGetProtoByName(const char *alproto_name);
const char *AppLayerProtoDetectGetProtoName(AppProto alproto);
void AppLayerProtoDetectSupportedAppProtocols(AppProto *alprotos);
/***** Unittests *****/

@ -1583,7 +1583,7 @@ void RegisterDNP3Parsers(void)
{
SCEnter();
char *proto_name = "dnp3";
const char *proto_name = "dnp3";
if (AppLayerProtoDetectConfProtoDetectionEnabled("tcp", proto_name))
{
@ -2081,7 +2081,7 @@ static int DNP3ProbingParserTest(void)
/**
* \test Test a basic request/response.
*/
int DNP3ParserTestRequestResponse(void)
static int DNP3ParserTestRequestResponse(void)
{
DNP3State *state = NULL;
@ -2231,7 +2231,7 @@ static int DNP3ParserTestUnsolicitedResponseConfirm(void)
/**
* \test Test flood state.
*/
int DNP3ParserTestFlooded(void)
static int DNP3ParserTestFlooded(void)
{
DNP3State *state = NULL;

@ -651,7 +651,7 @@ static uint16_t DNSTcpProbeResponse(uint8_t *input, uint32_t len,
void RegisterDNSTCPParsers(void)
{
char *proto_name = "dns";
const char *proto_name = "dns";
/** DNS */
if (AppLayerProtoDetectConfProtoDetectionEnabled("tcp", proto_name)) {

@ -383,7 +383,7 @@ static void DNSUDPConfigure(void)
void RegisterDNSUDPParsers(void)
{
char *proto_name = "dns";
const char *proto_name = "dns";
/** DNS */
if (AppLayerProtoDetectConfProtoDetectionEnabled("udp", proto_name)) {

@ -41,7 +41,7 @@
* @param input
* @param offset
*/
int ENIPExtractUint8(uint8_t *res, uint8_t *input, uint16_t *offset, uint32_t input_len)
static int ENIPExtractUint8(uint8_t *res, uint8_t *input, uint16_t *offset, uint32_t input_len)
{
if (*offset > (input_len - sizeof(uint8_t)))
@ -61,7 +61,7 @@ int ENIPExtractUint8(uint8_t *res, uint8_t *input, uint16_t *offset, uint32_t in
* @param input
* @param offset
*/
int ENIPExtractUint16(uint16_t *res, uint8_t *input, uint16_t *offset, uint32_t input_len)
static int ENIPExtractUint16(uint16_t *res, uint8_t *input, uint16_t *offset, uint32_t input_len)
{
if (*offset > (input_len - sizeof(uint16_t)))
@ -82,7 +82,7 @@ int ENIPExtractUint16(uint16_t *res, uint8_t *input, uint16_t *offset, uint32_t
* @param input
* @param offset
*/
int ENIPExtractUint32(uint32_t *res, uint8_t *input, uint16_t *offset, uint32_t input_len)
static int ENIPExtractUint32(uint32_t *res, uint8_t *input, uint16_t *offset, uint32_t input_len)
{
if (*offset > (input_len - sizeof(uint32_t)))
@ -103,7 +103,7 @@ int ENIPExtractUint32(uint32_t *res, uint8_t *input, uint16_t *offset, uint32_t
* @param input
* @param offset
*/
int ENIPExtractUint64(uint64_t *res, uint8_t *input, uint16_t *offset, uint32_t input_len)
static int ENIPExtractUint64(uint64_t *res, uint8_t *input, uint16_t *offset, uint32_t input_len)
{
if (*offset > (input_len - sizeof(uint64_t)))
@ -143,12 +143,12 @@ static CIPServiceEntry *CIPServiceAlloc(ENIPTransaction *tx)
}
#if 0
/**
* \brief Delete service entry
*/
void CIPServiceFree(void *s)
static void CIPServiceFree(void *s)
{
SCEnter();
if (s)
@ -173,8 +173,7 @@ void CIPServiceFree(void *s)
}
SCReturn;
}
#endif
/**
* \brief Decode ENIP Encapsulation Header

@ -61,7 +61,7 @@ SCEnumCharMap enip_decoder_event_table[ ] = {
*
* For ENIP we use a simple bool.
*/
int ENIPGetAlstateProgress(void *tx, uint8_t direction)
static int ENIPGetAlstateProgress(void *tx, uint8_t direction)
{
return 1;
}
@ -70,25 +70,26 @@ int ENIPGetAlstateProgress(void *tx, uint8_t direction)
*
* For ENIP we use a simple bool.
*/
int ENIPGetAlstateProgressCompletionStatus(uint8_t direction)
static int ENIPGetAlstateProgressCompletionStatus(uint8_t direction)
{
return 1;
}
DetectEngineState *ENIPGetTxDetectState(void *vtx)
static DetectEngineState *ENIPGetTxDetectState(void *vtx)
{
ENIPTransaction *tx = (ENIPTransaction *)vtx;
return tx->de_state;
}
int ENIPSetTxDetectState(void *state, void *vtx, DetectEngineState *s)
static int ENIPSetTxDetectState(void *state, void *vtx, DetectEngineState *s)
{
ENIPTransaction *tx = (ENIPTransaction *)vtx;
tx->de_state = s;
return 0;
}
void *ENIPGetTx(void *alstate, uint64_t tx_id) {
static void *ENIPGetTx(void *alstate, uint64_t tx_id)
{
ENIPState *enip = (ENIPState *) alstate;
ENIPTransaction *tx = NULL;
@ -106,11 +107,13 @@ void *ENIPGetTx(void *alstate, uint64_t tx_id) {
return NULL;
}
uint64_t ENIPGetTxCnt(void *alstate) {
static uint64_t ENIPGetTxCnt(void *alstate)
{
return ((uint64_t) ((ENIPState *) alstate)->transaction_max);
}
AppLayerDecoderEvents *ENIPGetEvents(void *state, uint64_t id) {
static AppLayerDecoderEvents *ENIPGetEvents(void *state, uint64_t id)
{
ENIPState *enip = (ENIPState *) state;
ENIPTransaction *tx;
@ -125,11 +128,13 @@ AppLayerDecoderEvents *ENIPGetEvents(void *state, uint64_t id) {
return NULL;
}
int ENIPHasEvents(void *state) {
static int ENIPHasEvents(void *state)
{
return (((ENIPState *) state)->events > 0);
}
int ENIPStateGetEventInfo(const char *event_name, int *event_id, AppLayerEventType *event_type) {
static int ENIPStateGetEventInfo(const char *event_name, int *event_id, AppLayerEventType *event_type)
{
*event_id = SCMapEnumNameToValue(event_name, enip_decoder_event_table);
if (*event_id == -1) {
@ -148,7 +153,7 @@ int ENIPStateGetEventInfo(const char *event_name, int *event_id, AppLayerEventTy
*
* return state
*/
void *ENIPStateAlloc(void)
static void *ENIPStateAlloc(void)
{
SCLogDebug("ENIPStateAlloc");
void *s = SCMalloc(sizeof(ENIPState));
@ -211,7 +216,7 @@ static void ENIPTransactionFree(ENIPTransaction *tx, ENIPState *state)
/** \brief Free enip state
*
*/
void ENIPStateFree(void *s)
static void ENIPStateFree(void *s)
{
SCEnter();
SCLogDebug("ENIPStateFree");
@ -265,7 +270,7 @@ static ENIPTransaction *ENIPTransactionAlloc(ENIPState *state)
/**
* \brief enip transaction cleanup callback
*/
void ENIPStateTransactionFree(void *state, uint64_t tx_id)
static void ENIPStateTransactionFree(void *state, uint64_t tx_id)
{
SCEnter();
SCLogDebug("ENIPStateTransactionFree");
@ -374,7 +379,7 @@ static uint16_t ENIPProbingParser(uint8_t *input, uint32_t input_len,
void RegisterENIPUDPParsers(void)
{
SCEnter();
char *proto_name = "enip";
const char *proto_name = "enip";
if (AppLayerProtoDetectConfProtoDetectionEnabled("udp", proto_name))
{
@ -462,7 +467,7 @@ void RegisterENIPUDPParsers(void)
void RegisterENIPTCPParsers(void)
{
SCEnter();
char *proto_name = "enip";
const char *proto_name = "enip";
if (AppLayerProtoDetectConfProtoDetectionEnabled("tcp", proto_name))
{
@ -555,7 +560,7 @@ static uint8_t listIdentity[] = {/* List ID */ 0x63, 0x00,
/**
* \brief Test if ENIP Packet matches signature
*/
int ALDecodeENIPTest(void)
static int ALDecodeENIPTest(void)
{
AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc();
Flow f;

@ -400,7 +400,7 @@ static int FTPRegisterPatternsForProtocolDetection(void)
void RegisterFTPParsers(void)
{
char *proto_name = "ftp";
const char *proto_name = "ftp";
/** FTP */
if (AppLayerProtoDetectConfProtoDetectionEnabled("tcp", proto_name)) {
@ -453,7 +453,7 @@ void FTPAtExitPrintStats(void)
#ifdef UNITTESTS
/** \test Send a get request in one chunk. */
int FTPParserTest01(void)
static int FTPParserTest01(void)
{
int result = 1;
Flow f;
@ -504,7 +504,7 @@ end:
}
/** \test Send a splitted get request. */
int FTPParserTest03(void)
static int FTPParserTest03(void)
{
int result = 1;
Flow f;
@ -581,7 +581,7 @@ end:
}
/** \test See how it deals with an incomplete request. */
int FTPParserTest06(void)
static int FTPParserTest06(void)
{
int result = 1;
Flow f;
@ -634,7 +634,7 @@ end:
}
/** \test See how it deals with an incomplete request in multiple chunks. */
int FTPParserTest07(void)
static int FTPParserTest07(void)
{
int result = 1;
Flow f;
@ -701,7 +701,7 @@ end:
/** \test Test case where chunks are smaller than the delim length and the
* last chunk is supposed to match the delim. */
int FTPParserTest10(void)
static int FTPParserTest10(void)
{
int result = 1;
Flow f;

@ -44,6 +44,7 @@
#include "app-layer-protos.h"
#include "app-layer-parser.h"
#include "app-layer-htp.h"
#include "app-layer-htp-body.h"
#include "util-spm.h"
#include "util-debug.h"

@ -43,6 +43,7 @@
#include "app-layer-protos.h"
#include "app-layer-parser.h"
#include "app-layer-htp.h"
#include "app-layer-htp-file.h"
#include "util-spm.h"
#include "util-debug.h"

@ -41,56 +41,7 @@
#include "suricata.h"
#include "suricata-common.h"
/**
* \brief A direct flick off libhtp-0.5.x htp_is_lws().
*/
static int SC_htp_is_lws(int c)
{
if ((c == ' ') || (c == '\t')) return 1;
else return 0;
}
/**
* \brief A direct flick off libhtp-0.5.x htp_parse_positive_integer_whitespace().
*/
static int64_t SC_htp_parse_positive_integer_whitespace(unsigned char *data, size_t len, int base)
{
if (len == 0) return -1003;
size_t last_pos;
size_t pos = 0;
// Ignore LWS before
while ((pos < len) && (SC_htp_is_lws(data[pos]))) pos++;
if (pos == len) return -1001;
int64_t r = bstr_util_mem_to_pint(data + pos, len - pos, base, &last_pos);
if (r < 0) return r;
// Move after the last digit
pos += last_pos;
// Ignore LWS after
while (pos < len) {
if (!SC_htp_is_lws(data[pos])) {
return -1002;
}
pos++;
}
return r;
}
/**
* \brief A direct flick off libhtp-0.5.x htp_parse_content_length()
*/
int64_t SC_htp_parse_content_length(bstr *b)
{
return SC_htp_parse_positive_integer_whitespace((unsigned char *) bstr_ptr(b), bstr_len(b), 10);
}
#include "app-layer-htp-libhtp.h"
/**
* \brief Generates the normalized uri.

@ -46,6 +46,5 @@
#include "suricata-common.h"
bstr *SCHTPGenerateNormalizedUri(htp_tx_t *tx, htp_uri_t *uri, int uri_include_all);
int64_t SC_htp_parse_content_length(bstr *b);
#endif /* __APP_LAYER_HTP_LIBHTP__H__ */

@ -45,7 +45,7 @@ SC_ATOMIC_DECLARE(uint64_t, htp_memcap);
void HTPParseMemcap()
{
char *conf_val;
const char *conf_val;
/** set config values for memcap, prealloc and hash_size */
if ((ConfGet("app-layer.protocols.http.memcap", &conf_val)) == 1)
@ -66,13 +66,13 @@ void HTPParseMemcap()
SC_ATOMIC_INIT(htp_memcap);
}
void HTPIncrMemuse(uint64_t size)
static void HTPIncrMemuse(uint64_t size)
{
(void) SC_ATOMIC_ADD(htp_memuse, size);
return;
}
void HTPDecrMemuse(uint64_t size)
static void HTPDecrMemuse(uint64_t size)
{
(void) SC_ATOMIC_SUB(htp_memuse, size);
return;
@ -96,7 +96,7 @@ uint64_t HTPMemcapGlobalCounter(void)
* \retval 1 if in bounds
* \retval 0 if not in bounds
*/
int HTPCheckMemcap(uint64_t size)
static int HTPCheckMemcap(uint64_t size)
{
if (htp_config_memcap == 0 || size + SC_ATOMIC_GET(htp_memuse) <= htp_config_memcap)
return 1;

@ -17,7 +17,7 @@
#include "stream-tcp-reassemble.h"
void HTPParseMemcap();
void HTPParseMemcap(void);
void *HTPMalloc(size_t size);
void *HTPCalloc(size_t n, size_t size);
void *HTPRealloc(void *ptr, size_t orig_size, size_t size);

@ -40,7 +40,7 @@
typedef struct HttpXFFCfg_ {
uint8_t flags; /**< XFF operation mode and deployment */
char *header; /**< XFF header name */
const char *header; /**< XFF header name */
} HttpXFFCfg;
void HttpXFFGetCfg(ConfNode *conf, HttpXFFCfg *result);

@ -234,7 +234,7 @@ static int HTPLookupPersonality(const char *str)
return -1;
}
void HTPSetEvent(HtpState *s, HtpTxUserData *htud, uint8_t e)
static void HTPSetEvent(HtpState *s, HtpTxUserData *htud, uint8_t e)
{
SCLogDebug("setting event %u", e);
@ -447,7 +447,7 @@ void AppLayerHtpEnableResponseBodyCallback(void)
*
* \initonly
*/
void AppLayerHtpNeedMultipartHeader(void)
static void AppLayerHtpNeedMultipartHeader(void)
{
SCEnter();
AppLayerHtpEnableRequestBodyCallback();
@ -475,7 +475,7 @@ void AppLayerHtpNeedFileInspection(void)
/* below error messages updated up to libhtp 0.5.7 (git 379632278b38b9a792183694a4febb9e0dbd1e7a) */
struct {
char *msg;
const char *msg;
int de;
} htp_errors[] = {
{ "GZip decompressor: inflateInit2 failed", HTTP_DECODER_EVENT_GZIP_DECOMPRESSION_FAILED},
@ -496,7 +496,7 @@ struct {
};
struct {
char *msg;
const char *msg;
int de;
} htp_warnings[] = {
{ "GZip decompressor:", HTTP_DECODER_EVENT_GZIP_DECOMPRESSION_FAILED},
@ -1201,7 +1201,7 @@ static void HtpRequestBodySetupBoundary(HtpTxUserData *htud,
memcpy(boundary + 2, htud->boundary, htud->boundary_len);
}
int HtpRequestBodyHandleMultipart(HtpState *hstate, HtpTxUserData *htud, void *tx,
static int HtpRequestBodyHandleMultipart(HtpState *hstate, HtpTxUserData *htud, void *tx,
const uint8_t *chunks_buffer, uint32_t chunks_buffer_len)
{
int result = 0;
@ -1498,7 +1498,7 @@ end:
/** \brief setup things for put request
* \todo really needed? */
int HtpRequestBodySetupPUT(htp_tx_data_t *d, HtpTxUserData *htud)
static int HtpRequestBodySetupPUT(htp_tx_data_t *d, HtpTxUserData *htud)
{
// if (d->tx->parsed_uri == NULL || d->tx->parsed_uri->path == NULL) {
// return -1;
@ -1617,7 +1617,7 @@ end:
return -1;
}
int HtpResponseBodyHandle(HtpState *hstate, HtpTxUserData *htud,
static int HtpResponseBodyHandle(HtpState *hstate, HtpTxUserData *htud,
htp_tx_t *tx, uint8_t *data, uint32_t data_len)
{
SCEnter();
@ -1692,7 +1692,7 @@ end:
* \param d pointer to the htp_tx_data_t structure (a chunk from htp lib)
* \retval int HTP_OK if all goes well
*/
int HTPCallbackRequestBodyData(htp_tx_data_t *d)
static int HTPCallbackRequestBodyData(htp_tx_data_t *d)
{
SCEnter();
@ -1809,7 +1809,7 @@ end:
* \param d pointer to the htp_tx_data_t structure (a chunk from htp lib)
* \retval int HTP_OK if all goes well
*/
int HTPCallbackResponseBodyData(htp_tx_data_t *d)
static int HTPCallbackResponseBodyData(htp_tx_data_t *d)
{
SCEnter();
@ -2195,7 +2195,7 @@ static void HTPConfigSetDefaultsPhase1(HTPCfgRec *cfg_prec)
* before the callback set by Phase2() is called. We need this, since
* the callback in Phase2() generates the normalized uri which utilizes
* the query and path. */
static void HTPConfigSetDefaultsPhase2(char *name, HTPCfgRec *cfg_prec)
static void HTPConfigSetDefaultsPhase2(const char *name, HTPCfgRec *cfg_prec)
{
/* randomize inspection size if needed */
if (cfg_prec->randomize) {
@ -2664,7 +2664,7 @@ static int HTPStateGetAlstateProgressCompletionStatus(uint8_t direction)
return (direction & STREAM_TOSERVER) ? HTP_REQUEST_COMPLETE : HTP_RESPONSE_COMPLETE;
}
int HTPStateGetEventInfo(const char *event_name,
static int HTPStateGetEventInfo(const char *event_name,
int *event_id, AppLayerEventType *event_type)
{
*event_id = SCMapEnumNameToValue(event_name, http_decoder_event_table);
@ -2742,13 +2742,13 @@ static int HTPSetTxMpmIDs(void *vtx, uint64_t mpm_ids)
static int HTPRegisterPatternsForProtocolDetection(void)
{
char *methods[] = { "GET", "PUT", "POST", "HEAD", "TRACE", "OPTIONS",
const char *methods[] = { "GET", "PUT", "POST", "HEAD", "TRACE", "OPTIONS",
"CONNECT", "DELETE", "PATCH", "PROPFIND", "PROPPATCH", "MKCOL",
"COPY", "MOVE", "LOCK", "UNLOCK", "CHECKOUT", "UNCHECKOUT", "CHECKIN",
"UPDATE", "LABEL", "REPORT", "MKWORKSPACE", "MKACTIVITY", "MERGE",
"INVALID", "VERSION-CONTROL", "BASELINE-CONTROL", NULL};
char *spacings[] = { "|20|", "|09|", NULL };
char *versions[] = { "HTTP/0.9", "HTTP/1.0", "HTTP/1.1", NULL };
const char *spacings[] = { "|20|", "|09|", NULL };
const char *versions[] = { "HTTP/0.9", "HTTP/1.0", "HTTP/1.1", NULL };
int methods_pos;
int spacings_pos;
@ -2796,7 +2796,7 @@ void RegisterHTPParsers(void)
{
SCEnter();
char *proto_name = "http";
const char *proto_name = "http";
/** HTTP */
if (AppLayerProtoDetectConfProtoDetectionEnabled("tcp", proto_name)) {
@ -2868,7 +2868,7 @@ void HtpConfigRestoreBackup(void)
/** \test Test case where chunks are sent in smaller chunks and check the
* response of the parser from HTP library. */
int HTPParserTest01(void)
static int HTPParserTest01(void)
{
int result = 0;
Flow *f = NULL;
@ -3022,7 +3022,7 @@ end:
}
/** \test See how it deals with an incomplete request. */
int HTPParserTest02(void)
static int HTPParserTest02(void)
{
int result = 0;
Flow *f = NULL;
@ -3080,7 +3080,7 @@ end:
/** \test Test case where method is invalid and data is sent in smaller chunks
* and check the response of the parser from HTP library. */
int HTPParserTest03(void)
static int HTPParserTest03(void)
{
int result = 0;
Flow *f = NULL;
@ -3150,7 +3150,7 @@ end:
/** \test Test case where invalid data is sent and check the response of the
* parser from HTP library. */
int HTPParserTest04(void)
static int HTPParserTest04(void)
{
int result = 0;
Flow *f = NULL;
@ -3211,7 +3211,7 @@ end:
/** \test Test both sides of a http stream mixed up to see if the HTP parser
* properly parsed them and also keeps them separated. */
int HTPParserTest05(void)
static int HTPParserTest05(void)
{
int result = 0;
Flow *f = NULL;
@ -3331,7 +3331,7 @@ end:
/** \test Test proper chunked encoded response body
*/
int HTPParserTest06(void)
static int HTPParserTest06(void)
{
int result = 0;
Flow *f = NULL;
@ -3450,7 +3450,7 @@ end:
/** \test
*/
int HTPParserTest07(void)
static int HTPParserTest07(void)
{
int result = 0;
Flow *f = NULL;
@ -3542,7 +3542,7 @@ end:
/** \test Abort
*/
int HTPParserTest08(void)
static int HTPParserTest08(void)
{
int result = 0;
Flow *f = NULL;
@ -3629,7 +3629,7 @@ end:
/** \test Abort
*/
int HTPParserTest09(void)
static int HTPParserTest09(void)
{
int result = 0;
Flow *f = NULL;
@ -3715,7 +3715,7 @@ end:
/** \test Host:www.google.com <- missing space between name:value (rfc violation)
*/
int HTPParserTest10(void)
static int HTPParserTest10(void)
{
int result = 0;
Flow *f = NULL;
@ -3983,7 +3983,7 @@ static int HTPParserTest12(void)
/** \test Host:www.google.com0dName: Value0d0a <- missing space between name:value (rfc violation)
*/
int HTPParserTest13(void)
static int HTPParserTest13(void)
{
int result = 0;
Flow *f = NULL;
@ -4077,7 +4077,7 @@ end:
}
/** \test Test basic config */
int HTPParserConfigTest01(void)
static int HTPParserConfigTest01(void)
{
int ret = 0;
char input[] = "\
@ -4256,7 +4256,7 @@ end:
}
/** \test Test config builds radix correctly */
int HTPParserConfigTest02(void)
static int HTPParserConfigTest02(void)
{
int ret = 0;
char input[] = "\
@ -4352,7 +4352,7 @@ end:
}
/** \test Test traffic is handled by the correct htp config */
int HTPParserConfigTest03(void)
static int HTPParserConfigTest03(void)
{
int result = 1;
Flow *f = NULL;
@ -4393,7 +4393,7 @@ libhtp:\n\
HTPConfigure();
char *addr = "192.168.10.42";
const char *addr = "192.168.10.42";
memset(&ssn, 0, sizeof(ssn));
@ -4486,7 +4486,7 @@ end:
/* disabled when we upgraded to libhtp 0.5.x */
#if 0
int HTPParserConfigTest04(void)
static int HTPParserConfigTest04(void)
{
int result = 0;
@ -4592,7 +4592,7 @@ libhtp:\n\
HtpConfigCreateBackup();
ConfYamlLoadString(input, strlen(input));
HTPConfigure();
char *addr = "4.3.2.1";
const char *addr = "4.3.2.1";
memset(&ssn, 0, sizeof(ssn));
f = UTHBuildFlow(AF_INET, "1.2.3.4", addr, 1024, 80);
@ -4762,7 +4762,7 @@ libhtp:\n\
HtpConfigCreateBackup();
ConfYamlLoadString(input, strlen(input));
HTPConfigure();
char *addr = "4.3.2.1";
const char *addr = "4.3.2.1";
memset(&ssn, 0, sizeof(ssn));
f = UTHBuildFlow(AF_INET, "1.2.3.4", addr, 1024, 80);
@ -4930,7 +4930,7 @@ libhtp:\n\
HtpConfigCreateBackup();
ConfYamlLoadString(input, strlen(input));
HTPConfigure();
char *addr = "4.3.2.1";
const char *addr = "4.3.2.1";
memset(&ssn, 0, sizeof(ssn));
f = UTHBuildFlow(AF_INET, "1.2.3.4", addr, 1024, 80);
@ -5068,7 +5068,7 @@ libhtp:\n\
HtpConfigCreateBackup();
ConfYamlLoadString(input, strlen(input));
HTPConfigure();
char *addr = "4.3.2.1";
const char *addr = "4.3.2.1";
memset(&ssn, 0, sizeof(ssn));
f = UTHBuildFlow(AF_INET, "1.2.3.4", addr, 1024, 80);
@ -5179,7 +5179,7 @@ libhtp:\n\
HtpConfigCreateBackup();
ConfYamlLoadString(input, strlen(input));
HTPConfigure();
char *addr = "4.3.2.1";
const char *addr = "4.3.2.1";
memset(&ssn, 0, sizeof(ssn));
f = UTHBuildFlow(AF_INET, "1.2.3.4", addr, 1024, 80);
@ -5290,7 +5290,7 @@ libhtp:\n\
HtpConfigCreateBackup();
ConfYamlLoadString(input, strlen(input));
HTPConfigure();
char *addr = "4.3.2.1";
const char *addr = "4.3.2.1";
memset(&ssn, 0, sizeof(ssn));
f = UTHBuildFlow(AF_INET, "1.2.3.4", addr, 1024, 80);
@ -5402,7 +5402,7 @@ libhtp:\n\
HtpConfigCreateBackup();
ConfYamlLoadString(input, strlen(input));
HTPConfigure();
char *addr = "4.3.2.1";
const char *addr = "4.3.2.1";
memset(&ssn, 0, sizeof(ssn));
f = UTHBuildFlow(AF_INET, "1.2.3.4", addr, 1024, 80);
@ -5511,7 +5511,7 @@ libhtp:\n\
HtpConfigCreateBackup();
ConfYamlLoadString(input, strlen(input));
HTPConfigure();
char *addr = "4.3.2.1";
const char *addr = "4.3.2.1";
memset(&ssn, 0, sizeof(ssn));
f = UTHBuildFlow(AF_INET, "1.2.3.4", addr, 1024, 80);
@ -5621,7 +5621,7 @@ libhtp:\n\
HtpConfigCreateBackup();
ConfYamlLoadString(input, strlen(input));
HTPConfigure();
char *addr = "4.3.2.1";
const char *addr = "4.3.2.1";
memset(&ssn, 0, sizeof(ssn));
f = UTHBuildFlow(AF_INET, "1.2.3.4", addr, 1024, 80);
@ -5847,7 +5847,7 @@ end:
}
/** \test Test really long request, this should result in HTTP_DECODER_EVENT_REQUEST_FIELD_TOO_LONG */
int HTPParserTest14(void)
static int HTPParserTest14(void)
{
int result = 0;
Flow *f = NULL;
@ -5989,7 +5989,7 @@ end:
/** \test Test really long request (same as HTPParserTest14), now with config
* update to allow it */
int HTPParserTest15(void)
static int HTPParserTest15(void)
{
int result = 0;
Flow *f = NULL;
@ -6113,7 +6113,7 @@ end:
}
/** \test Test unusual delims in request line HTTP_DECODER_EVENT_REQUEST_FIELD_TOO_LONG */
int HTPParserTest16(void)
static int HTPParserTest16(void)
{
int result = 0;
Flow *f = NULL;
@ -6200,7 +6200,7 @@ end:
}
/** \test CONNECT with plain text HTTP being tunneled */
int HTPParserTest17(void)
static int HTPParserTest17(void)
{
int result = 0;
Flow *f = NULL;
@ -6323,7 +6323,7 @@ end:
}
/** \test CONNECT with plain text HTTP being tunneled */
int HTPParserTest18(void)
static int HTPParserTest18(void)
{
int result = 0;
Flow *f = NULL;
@ -6456,7 +6456,7 @@ end:
}
/** \test CONNECT with TLS content (start of it at least) */
int HTPParserTest19(void)
static int HTPParserTest19(void)
{
int result = 0;
Flow *f = NULL;

@ -264,10 +264,6 @@ void HTPParserRegisterTests(void);
void HTPAtExitPrintStats(void);
void HTPFreeConfig(void);
htp_tx_t *HTPTransactionMain(const HtpState *);
int HTPCallbackRequestBodyData(htp_tx_data_t *);
int HtpTransactionGetLoggableId(Flow *);
void HtpBodyPrint(HtpBody *);
void HtpBodyFree(HtpBody *);
/* To free the state from unittests using app-layer-htp */

@ -171,7 +171,8 @@ typedef struct ModbusHeader_ ModbusHeader;
static uint32_t request_flood = MODBUS_CONFIG_DEFAULT_REQUEST_FLOOD;
static uint32_t stream_depth = MODBUS_CONFIG_DEFAULT_STREAM_DEPTH;
int ModbusStateGetEventInfo(const char *event_name, int *event_id, AppLayerEventType *event_type) {
static int ModbusStateGetEventInfo(const char *event_name, int *event_id, AppLayerEventType *event_type)
{
*event_id = SCMapEnumNameToValue(event_name, modbus_decoder_event_table);
if (*event_id == -1) {
@ -186,7 +187,8 @@ int ModbusStateGetEventInfo(const char *event_name, int *event_id, AppLayerEvent
return 0;
}
void ModbusSetEvent(ModbusState *modbus, uint8_t e) {
static void ModbusSetEvent(ModbusState *modbus, uint8_t e)
{
if (modbus && modbus->curr) {
SCLogDebug("modbus->curr->decoder_events %p", modbus->curr->decoder_events);
AppLayerDecoderEventsSetEventRaw(&modbus->curr->decoder_events, e);
@ -196,7 +198,8 @@ void ModbusSetEvent(ModbusState *modbus, uint8_t e) {
SCLogDebug("couldn't set event %u", e);
}
AppLayerDecoderEvents *ModbusGetEvents(void *state, uint64_t id) {
static AppLayerDecoderEvents *ModbusGetEvents(void *state, uint64_t id)
{
ModbusState *modbus = (ModbusState *) state;
ModbusTransaction *tx;
@ -211,11 +214,13 @@ AppLayerDecoderEvents *ModbusGetEvents(void *state, uint64_t id) {
return NULL;
}
int ModbusHasEvents(void *state) {
static int ModbusHasEvents(void *state)
{
return (((ModbusState *) state)->events > 0);
}
int ModbusGetAlstateProgress(void *modbus_tx, uint8_t direction) {
static int ModbusGetAlstateProgress(void *modbus_tx, uint8_t direction)
{
ModbusTransaction *tx = (ModbusTransaction *) modbus_tx;
ModbusState *modbus = tx->modbus;
@ -232,11 +237,13 @@ int ModbusGetAlstateProgress(void *modbus_tx, uint8_t direction) {
/** \brief Get value for 'complete' status in Modbus
*/
int ModbusGetAlstateProgressCompletionStatus(uint8_t direction) {
static int ModbusGetAlstateProgressCompletionStatus(uint8_t direction)
{
return 1;
}
void *ModbusGetTx(void *alstate, uint64_t tx_id) {
static void *ModbusGetTx(void *alstate, uint64_t tx_id)
{
ModbusState *modbus = (ModbusState *) alstate;
ModbusTransaction *tx = NULL;
@ -255,13 +262,13 @@ void *ModbusGetTx(void *alstate, uint64_t tx_id) {
return NULL;
}
void ModbusSetTxLogged(void *alstate, void *vtx, uint32_t logger)
static void ModbusSetTxLogged(void *alstate, void *vtx, uint32_t logger)
{
ModbusTransaction *tx = (ModbusTransaction *)vtx;
tx->logged |= logger;
}
int ModbusGetTxLogged(void *alstate, void *vtx, uint32_t logger)
static int ModbusGetTxLogged(void *alstate, void *vtx, uint32_t logger)
{
ModbusTransaction *tx = (ModbusTransaction *)vtx;
if (tx->logged & logger)
@ -270,7 +277,8 @@ int ModbusGetTxLogged(void *alstate, void *vtx, uint32_t logger)
return 0;
}
uint64_t ModbusGetTxCnt(void *alstate) {
static uint64_t ModbusGetTxCnt(void *alstate)
{
return ((uint64_t) ((ModbusState *) alstate)->transaction_max);
}
@ -283,7 +291,8 @@ uint64_t ModbusGetTxCnt(void *alstate) {
* \retval tx or NULL if not found
*/
static ModbusTransaction *ModbusTxFindByTransaction(const ModbusState *modbus,
const uint16_t transactionId) {
const uint16_t transactionId)
{
ModbusTransaction *tx = NULL;
if (modbus->curr == NULL)
@ -363,7 +372,8 @@ static void ModbusTxFree(ModbusTransaction *tx) {
/**
* \brief Modbus transaction cleanup callback
*/
void ModbusStateTxFree(void *state, uint64_t tx_id) {
static void ModbusStateTxFree(void *state, uint64_t tx_id)
{
SCEnter();
ModbusState *modbus = (ModbusState *) state;
ModbusTransaction *tx = NULL, *ttx;
@ -1439,13 +1449,13 @@ static uint16_t ModbusProbingParser(uint8_t *input,
return ALPROTO_MODBUS;
}
DetectEngineState *ModbusGetTxDetectState(void *vtx)
static DetectEngineState *ModbusGetTxDetectState(void *vtx)
{
ModbusTransaction *tx = (ModbusTransaction *)vtx;
return tx->de_state;
}
int ModbusSetTxDetectState(void *state, void *vtx, DetectEngineState *s)
static int ModbusSetTxDetectState(void *state, void *vtx, DetectEngineState *s)
{
ModbusTransaction *tx = (ModbusTransaction *)vtx;
tx->de_state = s;
@ -1458,7 +1468,7 @@ int ModbusSetTxDetectState(void *state, void *vtx, DetectEngineState *s)
void RegisterModbusParsers(void)
{
SCEnter();
char *proto_name = "modbus";
const char *proto_name = "modbus";
/* Modbus application protocol V1.1b3 */
if (AppLayerProtoDetectConfProtoDetectionEnabled("tcp", proto_name)) {

@ -1567,7 +1567,7 @@ static int SMBRegisterPatternsForProtocolDetection(void)
void RegisterSMBParsers(void)
{
char *proto_name = "smb";
const char *proto_name = "smb";
if (AppLayerProtoDetectConfProtoDetectionEnabled("tcp", proto_name)) {
AppLayerProtoDetectRegisterProtocol(ALPROTO_SMB, proto_name);
@ -1631,7 +1631,7 @@ void RegisterSMBParsers(void)
/**
* \test SMBParserTest01 tests the NBSS and SMB header decoding
*/
int SMBParserTest01(void)
static int SMBParserTest01(void)
{
int result = 0;
Flow f;
@ -1703,7 +1703,7 @@ end:
/**
* \test SMBParserTest02 tests the NBSS, SMB, and DCERPC over SMB header decoding
*/
int SMBParserTest02(void)
static int SMBParserTest02(void)
{
int result = 0;
Flow f;
@ -1781,7 +1781,7 @@ end:
return result;
}
int SMBParserTest03(void)
static int SMBParserTest03(void)
{
int result = 0;
Flow f;
@ -2088,7 +2088,7 @@ end:
return result;
}
int SMBParserTest04(void)
static int SMBParserTest04(void)
{
int result = 0;
Flow f;
@ -2219,7 +2219,7 @@ end:
return result;
}
int SMBParserTest05(void)
static int SMBParserTest05(void)
{
AppLayerProtoDetectUnittestCtxBackup();
AppLayerProtoDetectSetup();
@ -2320,7 +2320,7 @@ int SMBParserTest05(void)
return result;
}
int SMBParserTest06(void)
static int SMBParserTest06(void)
{
AppLayerProtoDetectUnittestCtxBackup();
AppLayerProtoDetectSetup();
@ -2404,7 +2404,7 @@ int SMBParserTest06(void)
return result;
}
int SMBParserTest07(void)
static int SMBParserTest07(void)
{
int result = 0;
Flow f;
@ -2465,7 +2465,7 @@ end:
return result;
}
int SMBParserTest08(void)
static int SMBParserTest08(void)
{
int result = 0;
Flow f;
@ -2569,7 +2569,7 @@ end:
return result;
}
int SMBParserTest09(void)
static int SMBParserTest09(void)
{
int result = 0;
Flow f;
@ -2691,7 +2691,7 @@ end:
* \test Test to temporarily to show the direction demaraction issue in the
* smb parser.
*/
int SMBParserTest10(void)
static int SMBParserTest10(void)
{
int result = 0;
Flow f;

@ -597,7 +597,7 @@ static void SMB2StateFree(void *s)
void RegisterSMB2Parsers(void)
{
/** SMB2 */
char *proto_name = "smb2";
const char *proto_name = "smb2";
if (AppLayerProtoDetectConfProtoDetectionEnabled("tcp", proto_name)) {
AppLayerParserRegisterParser(IPPROTO_TCP, ALPROTO_SMB2, STREAM_TOSERVER, SMB2Parse);
@ -617,7 +617,7 @@ void RegisterSMB2Parsers(void)
/* UNITTESTS */
#ifdef UNITTESTS
int SMB2ParserTest01(void)
static int SMB2ParserTest01(void)
{
int result = 1;
Flow f;

@ -328,7 +328,7 @@ static void SMTPConfigure(void) {
SCReturn;
}
void SMTPSetEvent(SMTPState *s, uint8_t e)
static void SMTPSetEvent(SMTPState *s, uint8_t e)
{
SCLogDebug("setting event %u", e);
@ -1472,7 +1472,7 @@ static void SMTPFreeMpmState(void)
}
}
int SMTPStateGetEventInfo(const char *event_name,
static int SMTPStateGetEventInfo(const char *event_name,
int *event_id, AppLayerEventType *event_type)
{
*event_id = SCMapEnumNameToValue(event_name, smtp_decoder_event_table);
@ -1640,7 +1640,7 @@ static int SMTPSetTxDetectState(void *state, void *vtx, DetectEngineState *s)
*/
void RegisterSMTPParsers(void)
{
char *proto_name = "smtp";
const char *proto_name = "smtp";
if (AppLayerProtoDetectConfProtoDetectionEnabled("tcp", proto_name)) {
AppLayerProtoDetectRegisterProtocol(ALPROTO_SMTP, proto_name);

@ -616,7 +616,7 @@ static int SSHRegisterPatternsForProtocolDetection(void)
*/
void RegisterSSHParsers(void)
{
char *proto_name = "ssh";
const char *proto_name = "ssh";
if (AppLayerProtoDetectConfProtoDetectionEnabled("tcp", proto_name)) {
AppLayerProtoDetectRegisterProtocol(ALPROTO_SSH, proto_name);

@ -152,19 +152,19 @@ void SSLSetEvent(SSLState *ssl_state, uint8_t event)
ssl_state->events++;
}
AppLayerDecoderEvents *SSLGetEvents(void *state, uint64_t id)
static AppLayerDecoderEvents *SSLGetEvents(void *state, uint64_t id)
{
SSLState *ssl_state = (SSLState *)state;
return ssl_state->decoder_events;
}
int SSLHasEvents(void *state)
static int SSLHasEvents(void *state)
{
SSLState *ssl_state = (SSLState *)state;
return (ssl_state->events > 0);
}
int SSLStateHasTxDetectState(void *state)
static int SSLStateHasTxDetectState(void *state)
{
SSLState *ssl_state = (SSLState *)state;
if (ssl_state->de_state)
@ -173,39 +173,39 @@ int SSLStateHasTxDetectState(void *state)
return 0;
}
int SSLSetTxDetectState(void *state, void *vtx, DetectEngineState *de_state)
static int SSLSetTxDetectState(void *state, void *vtx, DetectEngineState *de_state)
{
SSLState *ssl_state = (SSLState *)state;
ssl_state->de_state = de_state;
return 0;
}
DetectEngineState *SSLGetTxDetectState(void *vtx)
static DetectEngineState *SSLGetTxDetectState(void *vtx)
{
SSLState *ssl_state = (SSLState *)vtx;
return ssl_state->de_state;
}
void *SSLGetTx(void *state, uint64_t tx_id)
static void *SSLGetTx(void *state, uint64_t tx_id)
{
SSLState *ssl_state = (SSLState *)state;
return ssl_state;
}
uint64_t SSLGetTxCnt(void *state)
static uint64_t SSLGetTxCnt(void *state)
{
/* single tx */
return 1;
}
void SSLSetTxLogged(void *state, void *tx, uint32_t logger)
static void SSLSetTxLogged(void *state, void *tx, uint32_t logger)
{
SSLState *ssl_state = (SSLState *)state;
if (ssl_state)
ssl_state->logged |= logger;
}
int SSLGetTxLogged(void *state, void *tx, uint32_t logger)
static int SSLGetTxLogged(void *state, void *tx, uint32_t logger)
{
SSLState *ssl_state = (SSLState *)state;
if (ssl_state && (ssl_state->logged & logger))
@ -214,12 +214,12 @@ int SSLGetTxLogged(void *state, void *tx, uint32_t logger)
return 0;
}
int SSLGetAlstateProgressCompletionStatus(uint8_t direction)
static int SSLGetAlstateProgressCompletionStatus(uint8_t direction)
{
return TLS_STATE_FINISHED;
}
int SSLGetAlstateProgress(void *tx, uint8_t direction)
static int SSLGetAlstateProgress(void *tx, uint8_t direction)
{
SSLState *ssl_state = (SSLState *)tx;
@ -1520,14 +1520,14 @@ static int SSLDecode(Flow *f, uint8_t direction, void *alstate, AppLayerParserSt
return 1;
}
int SSLParseClientRecord(Flow *f, void *alstate, AppLayerParserState *pstate,
static int SSLParseClientRecord(Flow *f, void *alstate, AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len,
void *local_data)
{
return SSLDecode(f, 0 /* toserver */, alstate, pstate, input, input_len);
}
int SSLParseServerRecord(Flow *f, void *alstate, AppLayerParserState *pstate,
static int SSLParseServerRecord(Flow *f, void *alstate, AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len,
void *local_data)
{
@ -1538,7 +1538,7 @@ int SSLParseServerRecord(Flow *f, void *alstate, AppLayerParserState *pstate,
* \internal
* \brief Function to allocate the SSL state memory.
*/
void *SSLStateAlloc(void)
static void *SSLStateAlloc(void)
{
SSLState *ssl_state = SCMalloc(sizeof(SSLState));
if (unlikely(ssl_state == NULL))
@ -1555,7 +1555,7 @@ void *SSLStateAlloc(void)
* \internal
* \brief Function to free the SSL state memory.
*/
void SSLStateFree(void *p)
static void SSLStateFree(void *p)
{
SSLState *ssl_state = (SSLState *)p;
SSLCertsChain *item;
@ -1602,7 +1602,7 @@ void SSLStateFree(void *p)
return;
}
void SSLStateTransactionFree(void *state, uint64_t tx_id)
static void SSLStateTransactionFree(void *state, uint64_t tx_id)
{
/* do nothing */
}
@ -1622,7 +1622,7 @@ static uint16_t SSLProbingParser(uint8_t *input, uint32_t ilen, uint32_t *offset
return ALPROTO_FAILED;
}
int SSLStateGetEventInfo(const char *event_name,
static int SSLStateGetEventInfo(const char *event_name,
int *event_id, AppLayerEventType *event_type)
{
*event_id = SCMapEnumNameToValue(event_name, tls_decoder_event_table);
@ -1788,7 +1788,7 @@ static int SSLRegisterPatternsForProtocolDetection(void)
*/
void RegisterSSLParsers(void)
{
char *proto_name = "tls";
const char *proto_name = "tls";
/** SSLv2 and SSLv23*/
if (AppLayerProtoDetectConfProtoDetectionEnabled("tcp", proto_name)) {

@ -452,7 +452,7 @@ static int TemplateSetTxDetectState(void *state, void *vtx,
void RegisterTemplateParsers(void)
{
char *proto_name = "template";
const char *proto_name = "template";
/* TEMPLATE_START_REMOVE */
if (ConfGetNode("app-layer.protocols.template") == NULL) {

@ -84,8 +84,8 @@ AppLayerCounterNames applayer_counter_names[FLOW_PROTO_APPLAYER_MAX][ALPROTO_MAX
/* counter id's. Used that runtime. */
AppLayerCounters applayer_counters[FLOW_PROTO_APPLAYER_MAX][ALPROTO_MAX];
void AppLayerSetupCounters();
void AppLayerDeSetupCounters();
void AppLayerSetupCounters(void);
void AppLayerDeSetupCounters(void);
/***** L7 layer dispatchers *****/
@ -672,10 +672,10 @@ AppProto AppLayerGetProtoByName(char *alproto_name)
SCReturnCT(r, "AppProto");
}
char *AppLayerGetProtoName(AppProto alproto)
const char *AppLayerGetProtoName(AppProto alproto)
{
SCEnter();
char * r = AppLayerProtoDetectGetProtoName(alproto);
const char * r = AppLayerProtoDetectGetProtoName(alproto);
SCReturnCT(r, "char *");
}

@ -71,7 +71,7 @@ AppProto AppLayerGetProtoByName(char *alproto_name);
*
* \retval String representation of the protocol.
*/
char *AppLayerGetProtoName(AppProto alproto);
const char *AppLayerGetProtoName(AppProto alproto);
void AppLayerListSupportedProtocols(void);

@ -26,6 +26,7 @@
#include <yaml.h>
#include "suricata-common.h"
#include "conf.h"
#include "conf-yaml-loader.h"
#include "util-path.h"
#include "util-debug.h"
#include "util-unittest.h"
@ -871,7 +872,7 @@ ConfYamlOverrideTest(void)
" child1:\n"
" key: value\n"
;
char *value;
const char *value;
ConfCreateContextBackup();
ConfInit();
@ -918,7 +919,7 @@ ConfYamlOverrideFinalTest(void)
if (ConfYamlLoadString(config, strlen(config)) != 0)
return 0;
char *default_log_dir;
const char *default_log_dir;
if (!ConfGet("default-log-dir", &default_log_dir))
return 0;

@ -217,7 +217,7 @@ ConfNode *ConfGetRootNode(void)
*
* \retval 1 if the value was set otherwise 0.
*/
int ConfSet(const char *name, char *val)
int ConfSet(const char *name, const char *val)
{
ConfNode *node = ConfGetNodeOrCreate(name, 0);
if (node == NULL || node->final) {
@ -296,7 +296,7 @@ done:
*
* \retval 1 if the value was set otherwise 0.
*/
int ConfSetFinal(const char *name, char *val)
int ConfSetFinal(const char *name, const char *val)
{
ConfNode *node = ConfGetNodeOrCreate(name, 1);
if (node == NULL) {
@ -328,7 +328,7 @@ int ConfSetFinal(const char *name, char *val)
* \retval 1 will be returned if the name is found, otherwise 0 will
* be returned.
*/
int ConfGet(const char *name, char **vptr)
int ConfGet(const char *name, const char **vptr)
{
ConfNode *node = ConfGetNode(name);
if (node == NULL) {
@ -341,7 +341,7 @@ int ConfGet(const char *name, char **vptr)
}
}
int ConfGetChildValue(const ConfNode *base, const char *name, char **vptr)
int ConfGetChildValue(const ConfNode *base, const char *name, const char **vptr)
{
ConfNode *node = ConfNodeLookupChild(base, name);
@ -357,7 +357,7 @@ int ConfGetChildValue(const ConfNode *base, const char *name, char **vptr)
int ConfGetChildValueWithDefault(const ConfNode *base, const ConfNode *dflt,
const char *name, char **vptr)
const char *name, const char **vptr)
{
int ret = ConfGetChildValue(base, name, vptr);
/* Get 'default' value */
@ -379,7 +379,7 @@ int ConfGetChildValueWithDefault(const ConfNode *base, const ConfNode *dflt,
*/
int ConfGetInt(const char *name, intmax_t *val)
{
char *strval = NULL;
const char *strval = NULL;
intmax_t tmpint;
char *endptr;
@ -399,7 +399,7 @@ int ConfGetInt(const char *name, intmax_t *val)
int ConfGetChildValueInt(const ConfNode *base, const char *name, intmax_t *val)
{
char *strval = NULL;
const char *strval = NULL;
intmax_t tmpint;
char *endptr;
@ -441,7 +441,7 @@ int ConfGetChildValueIntWithDefault(const ConfNode *base, const ConfNode *dflt,
*/
int ConfGetBool(const char *name, int *val)
{
char *strval = NULL;
const char *strval = NULL;
*val = 0;
if (ConfGet(name, &strval) != 1)
@ -454,7 +454,7 @@ int ConfGetBool(const char *name, int *val)
int ConfGetChildValueBool(const ConfNode *base, const char *name, int *val)
{
char *strval = NULL;
const char *strval = NULL;
*val = 0;
if (ConfGetChildValue(base, name, &strval) == 0)
@ -490,7 +490,7 @@ int ConfGetChildValueBoolWithDefault(const ConfNode *base, const ConfNode *dflt,
*/
int ConfValIsTrue(const char *val)
{
char *trues[] = {"1", "yes", "true", "on"};
const char *trues[] = {"1", "yes", "true", "on"};
size_t u;
for (u = 0; u < sizeof(trues) / sizeof(trues[0]); u++) {
@ -515,7 +515,7 @@ int ConfValIsTrue(const char *val)
*/
int ConfValIsFalse(const char *val)
{
char *falses[] = {"0", "no", "false", "off"};
const char *falses[] = {"0", "no", "false", "off"};
size_t u;
for (u = 0; u < sizeof(falses) / sizeof(falses[0]); u++) {
@ -539,7 +539,7 @@ int ConfValIsFalse(const char *val)
*/
int ConfGetDouble(const char *name, double *val)
{
char *strval = NULL;
const char *strval = NULL;
double tmpdo;
char *endptr;
@ -569,7 +569,7 @@ int ConfGetDouble(const char *name, double *val)
*/
int ConfGetFloat(const char *name, float *val)
{
char *strval = NULL;
const char *strval = NULL;
double tmpfl;
char *endptr;
@ -807,7 +807,7 @@ int ConfNodeChildValueIsTrue(const ConfNode *node, const char *key)
*/
char *ConfLoadCompleteIncludePath(const char *file)
{
char *defaultpath = NULL;
const char *defaultpath = NULL;
char *path = NULL;
/* Path not specified */
@ -891,7 +891,7 @@ int ConfNodeIsSequence(const ConfNode *node)
static int ConfTestGetNonExistant(void)
{
char name[] = "non-existant-value";
char *value;
const char *value;
FAIL_IF(ConfGet(name, &value));
PASS;
@ -904,7 +904,7 @@ static int ConfTestSetAndGet(void)
{
char name[] = "some-name";
char value[] = "some-value";
char *value0;
const char *value0;
FAIL_IF(ConfSet(name, value) != 1);
FAIL_IF(ConfGet(name, &value0) != 1);
@ -925,7 +925,7 @@ static int ConfTestOverrideValue1(void)
char name[] = "some-name";
char value0[] = "some-value";
char value1[] = "new-value";
char *val;
const char *val;
FAIL_IF(ConfSet(name, value0) != 1);
FAIL_IF(ConfSet(name, value1) != 1);
@ -946,7 +946,7 @@ static int ConfTestOverrideValue2(void)
char name[] = "some-name";
char value0[] = "some-value";
char value1[] = "new-value";
char *val;
const char *val;
FAIL_IF(ConfSetFinal(name, value0) != 1);
FAIL_IF(ConfSet(name, value1) != 0);
@ -991,13 +991,13 @@ static int ConfTestGetInt(void)
static int ConfTestGetBool(void)
{
char name[] = "some-bool";
char *trues[] = {
const char *trues[] = {
"1",
"on", "ON",
"yes", "YeS",
"true", "TRUE",
};
char *falses[] = {
const char *falses[] = {
"0",
"something",
"off", "OFF",
@ -1024,7 +1024,7 @@ static int ConfTestGetBool(void)
static int ConfNodeLookupChildTest(void)
{
char *test_vals[] = { "one", "two", "three" };
const char *test_vals[] = { "one", "two", "three" };
size_t u;
ConfNode *parent = ConfNodeNew();
@ -1066,7 +1066,7 @@ static int ConfNodeLookupChildTest(void)
static int ConfNodeLookupChildValueTest(void)
{
char *test_vals[] = { "one", "two", "three" };
const char *test_vals[] = { "one", "two", "three" };
size_t u;
ConfNode *parent = ConfNodeNew();
@ -1102,7 +1102,7 @@ static int ConfNodeLookupChildValueTest(void)
static int ConfGetChildValueWithDefaultTest(void)
{
char *val = "";
const char *val = "";
ConfCreateContextBackup();
ConfInit();
ConfSet("af-packet.0.interface", "eth0");
@ -1297,7 +1297,7 @@ static int ConfNodePruneTest(void)
PASS;
}
int ConfNodeIsSequenceTest(void)
static int ConfNodeIsSequenceTest(void)
{
ConfNode *node = ConfNodeNew();
FAIL_IF(node == NULL);

@ -56,14 +56,14 @@ typedef struct ConfNode_ {
void ConfInit(void);
void ConfDeInit(void);
ConfNode *ConfGetRootNode(void);
int ConfGet(const char *name, char **vptr);
int ConfGet(const char *name, const char **vptr);
int ConfGetInt(const char *name, intmax_t *val);
int ConfGetBool(const char *name, int *val);
int ConfGetDouble(const char *name, double *val);
int ConfGetFloat(const char *name, float *val);
int ConfSet(const char *name, char *val);
int ConfSet(const char *name, const char *val);
int ConfSetFromString(const char *input, int final);
int ConfSetFinal(const char *name, char *val);
int ConfSetFinal(const char *name, const char *val);
void ConfDump(void);
void ConfNodeDump(const ConfNode *node, const char *prefix);
ConfNode *ConfNodeNew(void);
@ -74,17 +74,18 @@ void ConfRestoreContextBackup(void);
ConfNode *ConfNodeLookupChild(const ConfNode *node, const char *key);
const char *ConfNodeLookupChildValue(const ConfNode *node, const char *key);
void ConfNodeRemove(ConfNode *);
void ConfRegisterTests();
void ConfRegisterTests(void);
int ConfNodeChildValueIsTrue(const ConfNode *node, const char *key);
int ConfValIsTrue(const char *val);
int ConfValIsFalse(const char *val);
void ConfNodePrune(ConfNode *node);
int ConfRemove(const char *name);
ConfNode *ConfNodeLookupKeyValue(const ConfNode *base, const char *key, const char *value);
int ConfGetChildValue(const ConfNode *base, const char *name, char **vptr);
int ConfGetChildValue(const ConfNode *base, const char *name, const char **vptr);
int ConfGetChildValueInt(const ConfNode *base, const char *name, intmax_t *val);
int ConfGetChildValueBool(const ConfNode *base, const char *name, int *val);
int ConfGetChildValueWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name, char **vptr);
int ConfGetChildValueWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name, const char **vptr);
int ConfGetChildValueIntWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name, intmax_t *val);
int ConfGetChildValueBoolWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name, int *val);
char *ConfLoadCompleteIncludePath(const char *);

@ -267,7 +267,7 @@ static void StatsInitCtx(void)
* \brief Releases the resources alloted to the output context of the
* Stats API
*/
static void StatsReleaseCtx()
static void StatsReleaseCtx(void)
{
if (stats_ctx == NULL) {
SCLogDebug("Counter module has been disabled");
@ -528,7 +528,7 @@ static void StatsReleaseCounter(StatsCounter *pc)
* present counter on success
* \retval 0 on failure
*/
static uint16_t StatsRegisterQualifiedCounter(char *name, char *tm_name,
static uint16_t StatsRegisterQualifiedCounter(const char *name, const char *tm_name,
StatsPublicThreadContext *pctx,
int type_q, uint64_t (*Func)(void))
{
@ -883,7 +883,7 @@ void StatsSpawnThreads(void)
* \retval id Counter id for the newly registered counter, or the already
* present counter
*/
uint16_t StatsRegisterCounter(char *name, struct ThreadVars_ *tv)
uint16_t StatsRegisterCounter(const char *name, struct ThreadVars_ *tv)
{
uint16_t id = StatsRegisterQualifiedCounter(name,
(tv->thread_group_name != NULL) ? tv->thread_group_name : tv->name,
@ -904,7 +904,7 @@ uint16_t StatsRegisterCounter(char *name, struct ThreadVars_ *tv)
* \retval id Counter id for the newly registered counter, or the already
* present counter
*/
uint16_t StatsRegisterAvgCounter(char *name, struct ThreadVars_ *tv)
uint16_t StatsRegisterAvgCounter(const char *name, struct ThreadVars_ *tv)
{
uint16_t id = StatsRegisterQualifiedCounter(name,
(tv->thread_group_name != NULL) ? tv->thread_group_name : tv->name,
@ -925,7 +925,7 @@ uint16_t StatsRegisterAvgCounter(char *name, struct ThreadVars_ *tv)
* \retval the counter id for the newly registered counter, or the already
* present counter
*/
uint16_t StatsRegisterMaxCounter(char *name, struct ThreadVars_ *tv)
uint16_t StatsRegisterMaxCounter(const char *name, struct ThreadVars_ *tv)
{
uint16_t id = StatsRegisterQualifiedCounter(name,
(tv->thread_group_name != NULL) ? tv->thread_group_name : tv->name,
@ -944,7 +944,7 @@ uint16_t StatsRegisterMaxCounter(char *name, struct ThreadVars_ *tv)
* \retval id Counter id for the newly registered counter, or the already
* present counter
*/
uint16_t StatsRegisterGlobalCounter(char *name, uint64_t (*Func)(void))
uint16_t StatsRegisterGlobalCounter(const char *name, uint64_t (*Func)(void))
{
#ifdef UNITTESTS
if (stats_ctx == NULL)
@ -964,7 +964,7 @@ typedef struct CountersIdType_ {
const char *string;
} CountersIdType;
uint32_t CountersIdHashFunc(HashTable *ht, void *data, uint16_t datalen)
static uint32_t CountersIdHashFunc(HashTable *ht, void *data, uint16_t datalen)
{
CountersIdType *t = (CountersIdType *)data;
uint32_t hash = 0;
@ -980,7 +980,7 @@ uint32_t CountersIdHashFunc(HashTable *ht, void *data, uint16_t datalen)
return hash;
}
char CountersIdHashCompareFunc(void *data1, uint16_t datalen1,
static char CountersIdHashCompareFunc(void *data1, uint16_t datalen1,
void *data2, uint16_t datalen2)
{
CountersIdType *t1 = (CountersIdType *)data1;
@ -1004,7 +1004,7 @@ char CountersIdHashCompareFunc(void *data1, uint16_t datalen1,
return 0;
}
void CountersIdHashFreeFunc(void *data)
static void CountersIdHashFreeFunc(void *data)
{
SCFree(data);
}
@ -1232,13 +1232,13 @@ void StatsReleaseCounters(StatsCounter *head)
return;
}
/**
* \brief Releases the StatsPrivateThreadContext allocated by the user, for storing and
* updating local counter values
/** \internal
* \brief Releases the StatsPrivateThreadContext allocated by the user,
* for storing and updating local counter values
*
* \param pca Pointer to the StatsPrivateThreadContext
*/
void StatsReleasePrivateThreadContext(StatsPrivateThreadContext *pca)
static void StatsReleasePrivateThreadContext(StatsPrivateThreadContext *pca)
{
if (pca != NULL) {
if (pca->head != NULL) {
@ -1274,7 +1274,7 @@ void StatsThreadCleanup(ThreadVars *tv)
* \retval id Counter id for the newly registered counter, or the already
* present counter
*/
static uint16_t RegisterCounter(char *name, char *tm_name,
static uint16_t RegisterCounter(const char *name, const char *tm_name,
StatsPublicThreadContext *pctx)
{
uint16_t id = StatsRegisterQualifiedCounter(name, tm_name, pctx,
@ -1282,7 +1282,7 @@ static uint16_t RegisterCounter(char *name, char *tm_name,
return id;
}
static int StatsTestCounterReg02()
static int StatsTestCounterReg02(void)
{
StatsPublicThreadContext pctx;
@ -1291,7 +1291,7 @@ static int StatsTestCounterReg02()
return RegisterCounter(NULL, NULL, &pctx) == 0;
}
static int StatsTestCounterReg03()
static int StatsTestCounterReg03(void)
{
StatsPublicThreadContext pctx;
int result;
@ -1305,7 +1305,7 @@ static int StatsTestCounterReg03()
return result;
}
static int StatsTestCounterReg04()
static int StatsTestCounterReg04(void)
{
StatsPublicThreadContext pctx;
int result;
@ -1323,7 +1323,7 @@ static int StatsTestCounterReg04()
return result;
}
static int StatsTestGetCntArray05()
static int StatsTestGetCntArray05(void)
{
ThreadVars tv;
int id;
@ -1340,7 +1340,7 @@ static int StatsTestGetCntArray05()
return (r == -1) ? 1 : 0;
}
static int StatsTestGetCntArray06()
static int StatsTestGetCntArray06(void)
{
ThreadVars tv;
int id;
@ -1362,7 +1362,7 @@ static int StatsTestGetCntArray06()
return result;
}
static int StatsTestCntArraySize07()
static int StatsTestCntArraySize07(void)
{
ThreadVars tv;
StatsPrivateThreadContext *pca = NULL;
@ -1389,7 +1389,7 @@ static int StatsTestCntArraySize07()
PASS_IF(result == 2);
}
static int StatsTestUpdateCounter08()
static int StatsTestUpdateCounter08(void)
{
ThreadVars tv;
StatsPrivateThreadContext *pca = NULL;
@ -1414,7 +1414,7 @@ static int StatsTestUpdateCounter08()
return result == 101;
}
static int StatsTestUpdateCounter09()
static int StatsTestUpdateCounter09(void)
{
ThreadVars tv;
StatsPrivateThreadContext *pca = NULL;
@ -1443,7 +1443,7 @@ static int StatsTestUpdateCounter09()
return result;
}
static int StatsTestUpdateGlobalCounter10()
static int StatsTestUpdateGlobalCounter10(void)
{
ThreadVars tv;
StatsPrivateThreadContext *pca = NULL;
@ -1477,7 +1477,7 @@ static int StatsTestUpdateGlobalCounter10()
return result;
}
static int StatsTestCounterValues11()
static int StatsTestCounterValues11(void)
{
ThreadVars tv;
StatsPrivateThreadContext *pca = NULL;
@ -1518,7 +1518,7 @@ static int StatsTestCounterValues11()
#endif
void StatsRegisterTests()
void StatsRegisterTests(void)
{
#ifdef UNITTESTS
UtRegisterTest("StatsTestCounterReg02", StatsTestCounterReg02);

@ -113,10 +113,10 @@ void StatsRegisterTests(void);
void StatsReleaseResources(void);
/* counter registration functions */
uint16_t StatsRegisterCounter(char *, struct ThreadVars_ *);
uint16_t StatsRegisterAvgCounter(char *, struct ThreadVars_ *);
uint16_t StatsRegisterMaxCounter(char *, struct ThreadVars_ *);
uint16_t StatsRegisterGlobalCounter(char *cname, uint64_t (*Func)(void));
uint16_t StatsRegisterCounter(const char *, struct ThreadVars_ *);
uint16_t StatsRegisterAvgCounter(const char *, struct ThreadVars_ *);
uint16_t StatsRegisterMaxCounter(const char *, struct ThreadVars_ *);
uint16_t StatsRegisterGlobalCounter(const char *cname, uint64_t (*Func)(void));
/* functions used to update local counter values */
void StatsAddUI64(struct ThreadVars_ *, uint16_t, uint64_t);

@ -54,5 +54,7 @@ typedef struct EthernetHdr_ {
uint16_t eth_type;
} __attribute__((__packed__)) EthernetHdr;
void DecodeEthernetRegisterTests(void);
#endif /* __DECODE_ETHERNET_H__ */

@ -263,7 +263,7 @@ enum {
/* supported decoder events */
struct DecodeEvents_ {
char *event_name;
const char *event_name;
uint8_t code;
};
extern const struct DecodeEvents_ DEvents[DECODE_EVENT_MAX];

@ -47,7 +47,7 @@
/**
* Note, this is the IP header, plus a bit of the original packet, not the whole thing!
*/
int DecodePartialIPV4( Packet* p, uint8_t* partial_packet, uint16_t len )
static int DecodePartialIPV4(Packet* p, uint8_t* partial_packet, uint16_t len)
{
/** Check the sizes, the header must fit at least */
if (len < IPV4_HEADER_LEN) {

@ -56,7 +56,7 @@
*
* \retval void No return value
*/
void DecodePartialIPV6(Packet *p, uint8_t *partial_packet, uint16_t len )
static void DecodePartialIPV6(Packet *p, uint8_t *partial_packet, uint16_t len )
{
/** Check the sizes, the header must fit at least */
if (len < IPV6_HEADER_LEN) {

@ -623,7 +623,7 @@ int DecodeIPV4(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, u
#ifdef UNITTESTS
/** \test IPV4 with no options. */
int DecodeIPV4OptionsNONETest01(void)
static int DecodeIPV4OptionsNONETest01(void)
{
uint8_t raw_opts[] = { };
Packet *p = PacketGetFromAlloc();
@ -639,7 +639,7 @@ int DecodeIPV4OptionsNONETest01(void)
}
/** \test IPV4 with EOL option. */
int DecodeIPV4OptionsEOLTest01(void)
static int DecodeIPV4OptionsEOLTest01(void)
{
uint8_t raw_opts[] = {
IPV4_OPT_EOL, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
@ -655,7 +655,7 @@ int DecodeIPV4OptionsEOLTest01(void)
}
/** \test IPV4 with NOP option. */
int DecodeIPV4OptionsNOPTest01(void)
static int DecodeIPV4OptionsNOPTest01(void)
{
uint8_t raw_opts[] = {
IPV4_OPT_NOP, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
@ -671,7 +671,7 @@ int DecodeIPV4OptionsNOPTest01(void)
}
/** \test IPV4 with RR option. */
int DecodeIPV4OptionsRRTest01(void)
static int DecodeIPV4OptionsRRTest01(void)
{
uint8_t raw_opts[] = {
IPV4_OPT_RR, 0x27, 0x08, 0xc0, 0xa8, 0x2a, 0x64, 0x00,
@ -693,7 +693,7 @@ int DecodeIPV4OptionsRRTest01(void)
}
/** \test IPV4 with RR option (len too large). */
int DecodeIPV4OptionsRRTest02(void)
static int DecodeIPV4OptionsRRTest02(void)
{
uint8_t raw_opts[] = {
IPV4_OPT_RR, 0xff, 0x08, 0xc0, 0xa8, 0x2a, 0x64, 0x00,
@ -715,7 +715,7 @@ int DecodeIPV4OptionsRRTest02(void)
}
/** \test IPV4 with RR option (ptr too large). */
int DecodeIPV4OptionsRRTest03(void)
static int DecodeIPV4OptionsRRTest03(void)
{
uint8_t raw_opts[] = {
IPV4_OPT_RR, 0x27, 0xff, 0xc0, 0xa8, 0x2a, 0x64, 0x00,
@ -737,7 +737,7 @@ int DecodeIPV4OptionsRRTest03(void)
}
/** \test IPV4 with RR option (ptr not in 4 byte increment). */
int DecodeIPV4OptionsRRTest04(void)
static int DecodeIPV4OptionsRRTest04(void)
{
uint8_t raw_opts[] = {
IPV4_OPT_RR, 0x27, 0x05, 0xc0, 0xa8, 0x2a, 0x64, 0x00,
@ -759,7 +759,7 @@ int DecodeIPV4OptionsRRTest04(void)
}
/** \test IPV4 with QS option. */
int DecodeIPV4OptionsQSTest01(void)
static int DecodeIPV4OptionsQSTest01(void)
{
uint8_t raw_opts[] = {
IPV4_OPT_QS, 0x08, 0x0d, 0x00, 0xbe, 0xef, 0x00, 0x00
@ -777,7 +777,7 @@ int DecodeIPV4OptionsQSTest01(void)
}
/** \test IPV4 with QS option (len too small) */
int DecodeIPV4OptionsQSTest02(void)
static int DecodeIPV4OptionsQSTest02(void)
{
uint8_t raw_opts[] = {
IPV4_OPT_QS, 0x07, 0x0d, 0x00, 0xbe, 0xef, 0x00, 0x00
@ -795,7 +795,7 @@ int DecodeIPV4OptionsQSTest02(void)
}
/** \test IPV4 with TS option. */
int DecodeIPV4OptionsTSTest01(void)
static int DecodeIPV4OptionsTSTest01(void)
{
uint8_t raw_opts[] = {
IPV4_OPT_TS, 0x24, 0x0d, 0x01, 0x0a, 0x0a, 0x0a, 0x69,
@ -817,7 +817,7 @@ int DecodeIPV4OptionsTSTest01(void)
}
/** \test IPV4 with TS option (ptr too small). */
int DecodeIPV4OptionsTSTest02(void)
static int DecodeIPV4OptionsTSTest02(void)
{
uint8_t raw_opts[] = {
IPV4_OPT_TS, 0x24, 0x04, 0x01, 0x0a, 0x0a, 0x0a, 0x69,
@ -839,7 +839,7 @@ int DecodeIPV4OptionsTSTest02(void)
}
/** \test IPV4 with TS option (ptr too large). */
int DecodeIPV4OptionsTSTest03(void)
static int DecodeIPV4OptionsTSTest03(void)
{
uint8_t raw_opts[] = {
IPV4_OPT_TS, 0x24, 0xff, 0x01, 0x0a, 0x0a, 0x0a, 0x69,
@ -861,7 +861,7 @@ int DecodeIPV4OptionsTSTest03(void)
}
/** \test IPV4 with TS option (ptr not valid). */
int DecodeIPV4OptionsTSTest04(void)
static int DecodeIPV4OptionsTSTest04(void)
{
uint8_t raw_opts[] = {
IPV4_OPT_TS, 0x24, 0x0a, 0x01, 0x0a, 0x0a, 0x0a, 0x69,
@ -883,7 +883,7 @@ int DecodeIPV4OptionsTSTest04(void)
}
/** \test IPV4 with SEC option. */
int DecodeIPV4OptionsSECTest01(void)
static int DecodeIPV4OptionsSECTest01(void)
{
uint8_t raw_opts[] = {
IPV4_OPT_SEC, 0x0b, 0xf1, 0x35, 0x00, 0x00, 0x00, 0x00,
@ -902,7 +902,7 @@ int DecodeIPV4OptionsSECTest01(void)
}
/** \test IPV4 with SEC option (invalid length). */
int DecodeIPV4OptionsSECTest02(void)
static int DecodeIPV4OptionsSECTest02(void)
{
uint8_t raw_opts[] = {
IPV4_OPT_SEC, 0x0a, 0xf1, 0x35, 0x00, 0x00, 0x00, 0x00,
@ -921,7 +921,7 @@ int DecodeIPV4OptionsSECTest02(void)
}
/** \test IPV4 with LSRR option. */
int DecodeIPV4OptionsLSRRTest01(void)
static int DecodeIPV4OptionsLSRRTest01(void)
{
uint8_t raw_opts[] = {
IPV4_OPT_LSRR, 0x27, 0x08, 0xc0, 0xa8, 0x2a, 0x64, 0x00,
@ -943,7 +943,7 @@ int DecodeIPV4OptionsLSRRTest01(void)
}
/** \test IPV4 with LSRR option (len too large). */
int DecodeIPV4OptionsLSRRTest02(void)
static int DecodeIPV4OptionsLSRRTest02(void)
{
uint8_t raw_opts[] = {
IPV4_OPT_LSRR, 0xff, 0x08, 0xc0, 0xa8, 0x2a, 0x64, 0x00,
@ -965,7 +965,7 @@ int DecodeIPV4OptionsLSRRTest02(void)
}
/** \test IPV4 with LSRR option (ptr too large). */
int DecodeIPV4OptionsLSRRTest03(void)
static int DecodeIPV4OptionsLSRRTest03(void)
{
uint8_t raw_opts[] = {
IPV4_OPT_LSRR, 0x27, 0xff, 0xc0, 0xa8, 0x2a, 0x64, 0x00,
@ -987,7 +987,7 @@ int DecodeIPV4OptionsLSRRTest03(void)
}
/** \test IPV4 with LSRR option (ptr not in 4 byte increment). */
int DecodeIPV4OptionsLSRRTest04(void)
static int DecodeIPV4OptionsLSRRTest04(void)
{
uint8_t raw_opts[] = {
IPV4_OPT_LSRR, 0x27, 0x05, 0xc0, 0xa8, 0x2a, 0x64, 0x00,
@ -1009,7 +1009,7 @@ int DecodeIPV4OptionsLSRRTest04(void)
}
/** \test IPV4 with CIPSO option. */
int DecodeIPV4OptionsCIPSOTest01(void)
static int DecodeIPV4OptionsCIPSOTest01(void)
{
uint8_t raw_opts[] = {
IPV4_OPT_CIPSO, 0x18, 0x00, 0x00, 0x00, 0x05, 0x05, 0x12,
@ -1029,7 +1029,7 @@ int DecodeIPV4OptionsCIPSOTest01(void)
}
/** \test IPV4 with SID option. */
int DecodeIPV4OptionsSIDTest01(void)
static int DecodeIPV4OptionsSIDTest01(void)
{
uint8_t raw_opts[] = {
IPV4_OPT_SID, 0x04, 0xbe, 0xef, 0x00, 0x00, 0x00, 0x00
@ -1047,7 +1047,7 @@ int DecodeIPV4OptionsSIDTest01(void)
}
/** \test IPV4 with SID option (len invalid. */
int DecodeIPV4OptionsSIDTest02(void)
static int DecodeIPV4OptionsSIDTest02(void)
{
uint8_t raw_opts[] = {
IPV4_OPT_SID, 0x05, 0xbe, 0xef, 0x00, 0x00, 0x00, 0x00
@ -1065,7 +1065,7 @@ int DecodeIPV4OptionsSIDTest02(void)
}
/** \test IPV4 with SSRR option. */
int DecodeIPV4OptionsSSRRTest01(void)
static int DecodeIPV4OptionsSSRRTest01(void)
{
uint8_t raw_opts[] = {
IPV4_OPT_SSRR, 0x27, 0x08, 0xc0, 0xa8, 0x2a, 0x64, 0x00,
@ -1087,7 +1087,7 @@ int DecodeIPV4OptionsSSRRTest01(void)
}
/** \test IPV4 with SSRR option (len too large). */
int DecodeIPV4OptionsSSRRTest02(void)
static int DecodeIPV4OptionsSSRRTest02(void)
{
uint8_t raw_opts[] = {
IPV4_OPT_SSRR, 0xff, 0x08, 0xc0, 0xa8, 0x2a, 0x64, 0x00,
@ -1109,7 +1109,7 @@ int DecodeIPV4OptionsSSRRTest02(void)
}
/** \test IPV4 with SSRR option (ptr too large). */
int DecodeIPV4OptionsSSRRTest03(void)
static int DecodeIPV4OptionsSSRRTest03(void)
{
uint8_t raw_opts[] = {
IPV4_OPT_SSRR, 0x27, 0xff, 0xc0, 0xa8, 0x2a, 0x64, 0x00,
@ -1131,7 +1131,7 @@ int DecodeIPV4OptionsSSRRTest03(void)
}
/** \test IPV4 with SSRR option (ptr not in 4 byte increment). */
int DecodeIPV4OptionsSSRRTest04(void)
static int DecodeIPV4OptionsSSRRTest04(void)
{
uint8_t raw_opts[] = {
IPV4_OPT_SSRR, 0x27, 0x05, 0xc0, 0xa8, 0x2a, 0x64, 0x00,
@ -1153,7 +1153,7 @@ int DecodeIPV4OptionsSSRRTest04(void)
}
/** \test IPV4 with RTRALT option. */
int DecodeIPV4OptionsRTRALTTest01(void)
static int DecodeIPV4OptionsRTRALTTest01(void)
{
uint8_t raw_opts[] = {
IPV4_OPT_RTRALT, 0x04, 0xbe, 0xef, 0x00, 0x00, 0x00, 0x00
@ -1171,7 +1171,7 @@ int DecodeIPV4OptionsRTRALTTest01(void)
}
/** \test IPV4 with RTRALT option (len invalid. */
int DecodeIPV4OptionsRTRALTTest02(void)
static int DecodeIPV4OptionsRTRALTTest02(void)
{
uint8_t raw_opts[] = {
IPV4_OPT_RTRALT, 0x05, 0xbe, 0xef, 0x00, 0x00, 0x00, 0x00
@ -1221,7 +1221,7 @@ static int IPV4CalculateInvalidChecksumtest02(void)
/**
* \test IPV4 defrag and packet recursion level test
*/
int DecodeIPV4DefragTest01(void)
static int DecodeIPV4DefragTest01(void)
{
uint8_t pkt1[] = {
0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
@ -1345,7 +1345,7 @@ end:
* \test Don't send IPv4 fragments to the upper layer decoder and
* and packet recursion level test.
*/
int DecodeIPV4DefragTest02(void)
static int DecodeIPV4DefragTest02(void)
{
uint8_t pkt1[] = {
0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,
@ -1476,7 +1476,7 @@ end:
/**
* \test IPV4 defrag and flow retrieval test.
*/
int DecodeIPV4DefragTest03(void)
static int DecodeIPV4DefragTest03(void)
{
uint8_t pkt[] = {
0x00, 0x50, 0x56, 0x00, 0x03, 0x05, 0xde, 0xad,

@ -35,6 +35,7 @@
#include "suricata-common.h"
#include "decode.h"
#include "decode-ipv6.h"
#include "decode-teredo.h"
#include "util-debug.h"
#define TEREDO_ORIG_INDICATION_LENGTH 8

@ -549,7 +549,7 @@ inline int PacketSetData(Packet *p, uint8_t *pktdata, int pktlen)
const char *PktSrcToString(enum PktSrcEnum pkt_src)
{
char *pkt_src_str = "<unknown>";
const char *pkt_src_str = "<unknown>";
switch (pkt_src) {
case PKT_SRC_WIRE:
pkt_src_str = "wire/pcap";

@ -948,6 +948,13 @@ int DecodeGRE(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint16_t, P
int DecodeVLAN(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint16_t, PacketQueue *);
int DecodeMPLS(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint16_t, PacketQueue *);
int DecodeERSPAN(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint16_t, PacketQueue *);
int DecodeTEMPLATE(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t, PacketQueue *);
#ifdef UNITTESTS
void DecodeIPV6FragHeader(Packet *p, uint8_t *pkt,
uint16_t hdrextlen, uint16_t plen,
uint16_t prev_hdrextlen);
#endif
void AddressDebugPrint(Address *);

@ -41,7 +41,7 @@ void DefragTrackerMoveToSpare(DefragTracker *h)
(void) SC_ATOMIC_SUB(defragtracker_counter, 1);
}
DefragTracker *DefragTrackerAlloc(void)
static DefragTracker *DefragTrackerAlloc(void)
{
if (!(DEFRAG_CHECK_MEMCAP(sizeof(DefragTracker)))) {
return NULL;
@ -63,7 +63,7 @@ error:
return NULL;
}
void DefragTrackerFree(DefragTracker *dt)
static void DefragTrackerFree(DefragTracker *dt)
{
if (dt != NULL) {
DefragTrackerClearMemory(dt);
@ -140,7 +140,7 @@ void DefragInitConfig(char quiet)
defrag_config.prealloc = DEFRAG_DEFAULT_PREALLOC;
/* Check if we have memcap and hash_size defined at config */
char *conf_val;
const char *conf_val;
uint32_t configval = 0;
/** set config values for memcap, prealloc and hash_size */

@ -72,7 +72,7 @@ typedef struct DefragTrackerQueue_
#endif
/* prototypes */
DefragTrackerQueue *DefragTrackerQueueNew();
DefragTrackerQueue *DefragTrackerQueueNew(void);
DefragTrackerQueue *DefragTrackerQueueInit(DefragTrackerQueue *);
void DefragTrackerQueueDestroy (DefragTrackerQueue *);

@ -24,16 +24,7 @@
#include "suricata-common.h"
#include "defrag.h"
#include "defrag-hash.h"
uint32_t DefragTrackerGetSpareCount(void)
{
return DefragTrackerSpareQueueGetSize();
}
uint32_t DefragTrackerGetActiveCount(void)
{
return SC_ATOMIC_GET(defragtracker_counter);
}
#include "defrag-timeout.h"
/** \internal
* \brief See if we can really discard this tracker. Check use_cnt reference.

@ -1119,10 +1119,6 @@ error:
return NULL;
}
void DecodeIPV6FragHeader(Packet *p, uint8_t *pkt,
uint16_t hdrextlen, uint16_t plen,
uint16_t prev_hdrextlen);
static Packet *IPV6BuildTestPacket(uint8_t proto, uint32_t id, uint16_t off,
int mf, const char content, int content_len)
{

@ -43,7 +43,7 @@
#include "util-debug.h"
/* prototypes */
static int DetectAckSetup(DetectEngineCtx *, Signature *, char *);
static int DetectAckSetup(DetectEngineCtx *, Signature *, const char *);
static int DetectAckMatch(ThreadVars *, DetectEngineThreadCtx *,
Packet *, const Signature *, const SigMatchCtx *);
static void DetectAckRegisterTests(void);
@ -103,7 +103,7 @@ static int DetectAckMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx,
* \retval 0 on Success
* \retval -1 on Failure
*/
static int DetectAckSetup(DetectEngineCtx *de_ctx, Signature *s, char *optstr)
static int DetectAckSetup(DetectEngineCtx *de_ctx, Signature *s, const char *optstr)
{
DetectAckData *data = NULL;
SigMatch *sm = NULL;

@ -50,7 +50,7 @@
static int DetectAppLayerEventPktMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx,
Packet *p, const Signature *s, const SigMatchCtx *ctx);
static int DetectAppLayerEventSetupP1(DetectEngineCtx *, Signature *, char *);
static int DetectAppLayerEventSetupP1(DetectEngineCtx *, Signature *, const char *);
static void DetectAppLayerEventRegisterTests(void);
static void DetectAppLayerEventFree(void *);
static int DetectEngineAptEventInspect(ThreadVars *tv,
@ -319,7 +319,7 @@ static int DetectAppLayerEventSetupP2(Signature *s,
return 0;
}
static int DetectAppLayerEventSetupP1(DetectEngineCtx *de_ctx, Signature *s, char *arg)
static int DetectAppLayerEventSetupP1(DetectEngineCtx *de_ctx, Signature *s, const char *arg)
{
DetectAppLayerEventData *data = NULL;
SigMatch *sm = NULL;
@ -425,7 +425,7 @@ static int DetectAppLayerEventTestGetEventInfo(const char *event_name,
}
int DetectAppLayerEventTest01(void)
static int DetectAppLayerEventTest01(void)
{
AppLayerParserBackupParserTable();
AppLayerParserRegisterGetEventInfo(IPPROTO_TCP, ALPROTO_SMTP,
@ -460,7 +460,7 @@ int DetectAppLayerEventTest01(void)
return result;
}
int DetectAppLayerEventTest02(void)
static int DetectAppLayerEventTest02(void)
{
AppLayerParserBackupParserTable();
@ -558,7 +558,7 @@ int DetectAppLayerEventTest02(void)
return result;
}
int DetectAppLayerEventTest03(void)
static int DetectAppLayerEventTest03(void)
{
ThreadVars tv;
TcpReassemblyThreadCtx *ra_ctx = NULL;
@ -645,7 +645,7 @@ int DetectAppLayerEventTest03(void)
PASS;
}
int DetectAppLayerEventTest04(void)
static int DetectAppLayerEventTest04(void)
{
ThreadVars tv;
TcpReassemblyThreadCtx *ra_ctx = NULL;
@ -728,7 +728,7 @@ int DetectAppLayerEventTest04(void)
PASS;
}
int DetectAppLayerEventTest05(void)
static int DetectAppLayerEventTest05(void)
{
ThreadVars tv;
TcpReassemblyThreadCtx *ra_ctx = NULL;

@ -86,29 +86,10 @@ static int DetectAppLayerProtocolPacketMatch(ThreadVars *tv,
SCReturnInt(r);
}
static DetectAppLayerProtocolData *DetectAppLayerProtocolParse(const char *arg)
static DetectAppLayerProtocolData *DetectAppLayerProtocolParse(const char *arg, bool negate)
{
DetectAppLayerProtocolData *data;
AppProto alproto = ALPROTO_UNKNOWN;
uint8_t negated = 0;
if (arg == NULL) {
SCLogError(SC_ERR_INVALID_SIGNATURE, "app-layer-protocol keyword "
"supplied with no arguments. This keyword needs "
"an argument.");
return NULL;
}
while (*arg != '\0' && isspace((unsigned char)*arg))
arg++;
if (arg[0] == '!') {
negated = 1;
arg++;
}
while (*arg != '\0' && isspace((unsigned char)*arg))
arg++;
if (strcmp(arg, "failed") == 0) {
alproto = ALPROTO_FAILED;
@ -125,7 +106,7 @@ static DetectAppLayerProtocolData *DetectAppLayerProtocolParse(const char *arg)
if (unlikely(data == NULL))
return NULL;
data->alproto = alproto;
data->negated = negated;
data->negated = negate;
return data;
}
@ -148,7 +129,7 @@ static _Bool HasConflicts(const DetectAppLayerProtocolData *us,
}
static int DetectAppLayerProtocolSetup(DetectEngineCtx *de_ctx,
Signature *s, char *arg)
Signature *s, const char *arg)
{
DetectAppLayerProtocolData *data = NULL;
SigMatch *sm = NULL;
@ -161,7 +142,7 @@ static int DetectAppLayerProtocolSetup(DetectEngineCtx *de_ctx,
goto error;
}
data = DetectAppLayerProtocolParse(arg);
data = DetectAppLayerProtocolParse(arg, s->init_data->negated);
if (data == NULL)
goto error;
@ -285,6 +266,8 @@ void DetectAppLayerProtocolRegister(void)
DetectAppLayerProtocolFree;
sigmatch_table[DETECT_AL_APP_LAYER_PROTOCOL].RegisterTests =
DetectAppLayerProtocolRegisterTests;
sigmatch_table[DETECT_AL_APP_LAYER_PROTOCOL].flags =
(SIGMATCH_QUOTES_OPTIONAL|SIGMATCH_HANDLE_NEGATION);
sigmatch_table[DETECT_AL_APP_LAYER_PROTOCOL].SetupPrefilter =
PrefilterSetupAppProto;
@ -299,7 +282,7 @@ void DetectAppLayerProtocolRegister(void)
static int DetectAppLayerProtocolTest01(void)
{
DetectAppLayerProtocolData *data = DetectAppLayerProtocolParse("http");
DetectAppLayerProtocolData *data = DetectAppLayerProtocolParse("http", false);
FAIL_IF_NULL(data);
FAIL_IF(data->alproto != ALPROTO_HTTP);
FAIL_IF(data->negated != 0);
@ -309,7 +292,7 @@ static int DetectAppLayerProtocolTest01(void)
static int DetectAppLayerProtocolTest02(void)
{
DetectAppLayerProtocolData *data = DetectAppLayerProtocolParse("!http");
DetectAppLayerProtocolData *data = DetectAppLayerProtocolParse("http", true);
FAIL_IF_NULL(data);
FAIL_IF(data->alproto != ALPROTO_HTTP);
FAIL_IF(data->negated == 0);
@ -470,7 +453,7 @@ static int DetectAppLayerProtocolTest10(void)
static int DetectAppLayerProtocolTest11(void)
{
DetectAppLayerProtocolData *data = DetectAppLayerProtocolParse("failed");
DetectAppLayerProtocolData *data = DetectAppLayerProtocolParse("failed", false);
FAIL_IF_NULL(data);
FAIL_IF(data->alproto != ALPROTO_FAILED);
FAIL_IF(data->negated != 0);
@ -480,7 +463,7 @@ static int DetectAppLayerProtocolTest11(void)
static int DetectAppLayerProtocolTest12(void)
{
DetectAppLayerProtocolData *data = DetectAppLayerProtocolParse("!failed");
DetectAppLayerProtocolData *data = DetectAppLayerProtocolParse("failed", true);
FAIL_IF_NULL(data);
FAIL_IF(data->alproto != ALPROTO_FAILED);
FAIL_IF(data->negated == 0);

@ -44,7 +44,7 @@ const char *ASN_DELIM = " \t,\n";
static int DetectAsn1Match(ThreadVars *, DetectEngineThreadCtx *, Packet *,
const Signature *, const SigMatchCtx *);
static int DetectAsn1Setup (DetectEngineCtx *, Signature *, char *);
static int DetectAsn1Setup (DetectEngineCtx *, Signature *, const char *);
static void DetectAsn1RegisterTests(void);
static void DetectAsn1Free(void *);
@ -197,7 +197,7 @@ static int DetectAsn1Match(ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet
* \retval fd pointer to DetectAsn1Data on success
* \retval NULL on failure
*/
static DetectAsn1Data *DetectAsn1Parse(char *asn1str)
static DetectAsn1Data *DetectAsn1Parse(const char *instr)
{
DetectAsn1Data *fd = NULL;
char *tok = NULL;
@ -207,10 +207,15 @@ static DetectAsn1Data *DetectAsn1Parse(char *asn1str)
uint8_t flags = 0;
char *saveptr = NULL;
char *asn1str = SCStrdup(instr);
if (asn1str == NULL)
return NULL;
tok = strtok_r(asn1str, ASN_DELIM, &saveptr);
if (tok == NULL) {
SCLogError(SC_ERR_INVALID_VALUE, "Malformed asn1 argument: %s",
asn1str);
SCFree(asn1str);
return NULL;
}
@ -289,7 +294,7 @@ error:
* \retval 0 on Success
* \retval -1 on Failure
*/
static int DetectAsn1Setup(DetectEngineCtx *de_ctx, Signature *s, char *asn1str)
static int DetectAsn1Setup(DetectEngineCtx *de_ctx, Signature *s, const char *asn1str)
{
DetectAsn1Data *ad = NULL;
SigMatch *sm = NULL;
@ -1078,7 +1083,7 @@ static int DetectAsn1TestReal01(void)
if (p[0] == NULL || p[1] == NULL)
goto end;
char *sigs[3];
const char *sigs[3];
sigs[0]= "alert ip any any -> any any (msg:\"Testing id 1\"; "
"content:\"Pablo\"; asn1:absolute_offset 0, "
"oversize_length 130; sid:1;)";
@ -1157,7 +1162,7 @@ static int DetectAsn1TestReal02(void)
if (p[0] == NULL || p[1] == NULL)
goto end;
char *sigs[3];
const char *sigs[3];
sigs[0]= "alert ip any any -> any any (msg:\"Testing id 1\"; "
"content:\"Pablo\"; asn1:absolute_offset 0, "
"oversize_length 140; sid:1;)";
@ -1216,7 +1221,7 @@ static int DetectAsn1TestReal03(void)
if (p[0] == NULL || p[1] == NULL)
goto end;
char *sigs[3];
const char *sigs[3];
/* This should match the first packet */
sigs[0]= "alert ip any any -> any any (msg:\"Testing id 1\"; "
"asn1:absolute_offset 0, double_overflow; sid:1;)";
@ -1295,7 +1300,7 @@ static int DetectAsn1TestReal04(void)
if (p[0] == NULL || p[1] == NULL)
goto end;
char *sigs[3];
const char *sigs[3];
sigs[0]= "alert ip any any -> any any (msg:\"Testing id 1\"; "
"content:\"Pablo\"; asn1:absolute_offset 0, "
"oversize_length 140; sid:1;)";

@ -20,10 +20,11 @@
#include "detect-engine.h"
#include "detect-engine-content-inspection.h"
#include "detect-parse.h"
#include "detect-base64-data.h"
#include "util-unittest.h"
static int DetectBase64DataSetup(DetectEngineCtx *, Signature *, char *);
static int DetectBase64DataSetup(DetectEngineCtx *, Signature *, const char *);
static void DetectBase64DataRegisterTests(void);
void DetectBase64DataRegister(void)
@ -41,7 +42,7 @@ void DetectBase64DataRegister(void)
}
static int DetectBase64DataSetup(DetectEngineCtx *de_ctx, Signature *s,
char *str)
const char *str)
{
SigMatch *pm = NULL;
@ -58,7 +59,7 @@ static int DetectBase64DataSetup(DetectEngineCtx *de_ctx, Signature *s,
}
int DetectBase64DataDoMatch(DetectEngineCtx *de_ctx,
DetectEngineThreadCtx *det_ctx, Signature *s, Flow *f)
DetectEngineThreadCtx *det_ctx, const Signature *s, Flow *f)
{
if (det_ctx->base64_decoded_len) {
return DetectEngineContentInspection(de_ctx, det_ctx, s,

@ -32,7 +32,7 @@ static const char decode_pattern[] = "\\s*(bytes\\s+(\\d+),?)?"
static pcre *decode_pcre = NULL;
static pcre_extra *decode_pcre_study = NULL;
static int DetectBase64DecodeSetup(DetectEngineCtx *, Signature *, char *);
static int DetectBase64DecodeSetup(DetectEngineCtx *, Signature *, const char *);
static void DetectBase64DecodeFree(void *);
static void DetectBase64DecodeRegisterTests(void);
@ -168,7 +168,7 @@ error:
}
static int DetectBase64DecodeSetup(DetectEngineCtx *de_ctx, Signature *s,
char *str)
const char *str)
{
uint32_t bytes = 0;
uint32_t offset = 0;

@ -36,6 +36,7 @@
#include "detect-engine-mpm.h"
#include "detect-engine-state.h"
#include "detect-engine-sigorder.h"
#include "detect-bypass.h"
#include "flow.h"
#include "flow-var.h"
@ -51,7 +52,7 @@
static int DetectBypassMatch(ThreadVars *, DetectEngineThreadCtx *, Packet *,
const Signature *, const SigMatchCtx *);
static int DetectBypassSetup(DetectEngineCtx *, Signature *, char *);
static int DetectBypassSetup(DetectEngineCtx *, Signature *, const char *);
static void DetectBypassRegisterTests(void);
/**
@ -69,7 +70,7 @@ void DetectBypassRegister(void)
sigmatch_table[DETECT_BYPASS].flags = SIGMATCH_NOOPT;
}
static int DetectBypassSetup(DetectEngineCtx *de_ctx, Signature *s, char *str)
static int DetectBypassSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str)
{
SigMatch *sm = NULL;
@ -102,13 +103,13 @@ static int DetectBypassMatch(ThreadVars *tv, DetectEngineThreadCtx *det_ctx, Pac
#ifdef UNITTESTS
static int callback_var = 0;
static int BypassCallback()
static int BypassCallback(Packet *p)
{
callback_var = 1;
return 1;
}
static void ResetCallbackVar()
static void ResetCallbackVar(void)
{
callback_var = 0;
}
@ -177,7 +178,7 @@ static int DetectBypassTestSig01(void)
de_ctx->flags |= DE_QUIET;
char *sigs[3];
const char *sigs[3];
sigs[0] = "alert tcp any any -> any any (bypass; content:\"GET \"; sid:1;)";
sigs[1] = "alert http any any -> any any "
"(bypass; content:\"message\"; http_server_body; "

@ -89,7 +89,7 @@
static pcre *parse_regex;
static pcre_extra *parse_regex_study;
static int DetectByteExtractSetup(DetectEngineCtx *, Signature *, char *);
static int DetectByteExtractSetup(DetectEngineCtx *, Signature *, const char *);
static void DetectByteExtractRegisterTests(void);
static void DetectByteExtractFree(void *);
@ -206,7 +206,7 @@ int DetectByteExtractDoMatch(DetectEngineThreadCtx *det_ctx, const SigMatchData
* \param bed On success an instance containing the parsed data.
* On failure, NULL.
*/
static inline DetectByteExtractData *DetectByteExtractParse(char *arg)
static inline DetectByteExtractData *DetectByteExtractParse(const char *arg)
{
DetectByteExtractData *bed = NULL;
#define MAX_SUBSTRINGS 100
@ -504,7 +504,7 @@ static inline DetectByteExtractData *DetectByteExtractParse(char *arg)
* \retval 0 On success.
* \retval -1 On failure.
*/
static int DetectByteExtractSetup(DetectEngineCtx *de_ctx, Signature *s, char *arg)
static int DetectByteExtractSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg)
{
SigMatch *sm = NULL;
SigMatch *prev_pm = NULL;

@ -62,8 +62,8 @@ static pcre_extra *parse_regex_study;
static int DetectBytejumpMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx,
Packet *p, const Signature *s, const SigMatchCtx *ctx);
static DetectBytejumpData *DetectBytejumpParse(char *optstr, char **offset);
static int DetectBytejumpSetup(DetectEngineCtx *de_ctx, Signature *s, char *optstr);
static DetectBytejumpData *DetectBytejumpParse(const char *optstr, char **offset);
static int DetectBytejumpSetup(DetectEngineCtx *de_ctx, Signature *s, const char *optstr);
static void DetectBytejumpFree(void *ptr);
static void DetectBytejumpRegisterTests(void);
@ -309,7 +309,7 @@ static int DetectBytejumpMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx,
return 1;
}
static DetectBytejumpData *DetectBytejumpParse(char *optstr, char **offset)
static DetectBytejumpData *DetectBytejumpParse(const char *optstr, char **offset)
{
DetectBytejumpData *data = NULL;
char args[10][64];
@ -503,7 +503,7 @@ error:
return NULL;
}
static int DetectBytejumpSetup(DetectEngineCtx *de_ctx, Signature *s, char *optstr)
static int DetectBytejumpSetup(DetectEngineCtx *de_ctx, Signature *s, const char *optstr)
{
SigMatch *sm = NULL;
SigMatch *prev_pm = NULL;

@ -64,7 +64,7 @@ static pcre_extra *parse_regex_study;
static int DetectBytetestMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx,
Packet *p, const Signature *s, const SigMatchCtx *ctx);
static int DetectBytetestSetup(DetectEngineCtx *de_ctx, Signature *s, char *optstr);
static int DetectBytetestSetup(DetectEngineCtx *de_ctx, Signature *s, const char *optstr);
static void DetectBytetestFree(void *ptr);
static void DetectBytetestRegisterTests(void);
@ -241,7 +241,7 @@ static int DetectBytetestMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx,
((DetectBytetestData *)ctx)->flags, 0, 0);
}
static DetectBytetestData *DetectBytetestParse(char *optstr, char **value, char **offset)
static DetectBytetestData *DetectBytetestParse(const char *optstr, char **value, char **offset)
{
DetectBytetestData *data = NULL;
char *args[9] = {
@ -429,7 +429,7 @@ error:
return NULL;
}
static int DetectBytetestSetup(DetectEngineCtx *de_ctx, Signature *s, char *optstr)
static int DetectBytetestSetup(DetectEngineCtx *de_ctx, Signature *s, const char *optstr)
{
SigMatch *sm = NULL;
SigMatch *prev_pm = NULL;

@ -39,7 +39,7 @@
/**
* \brief CIP Service Detect Prototypes
*/
static int DetectCipServiceSetup(DetectEngineCtx *, Signature *, char *);
static int DetectCipServiceSetup(DetectEngineCtx *, Signature *, const char *);
static void DetectCipServiceFree(void *);
static void DetectCipServiceRegisterTests(void);
static int g_cip_buffer_id = 0;
@ -200,7 +200,7 @@ error:
* \retval -1 on Failure
*/
static int DetectCipServiceSetup(DetectEngineCtx *de_ctx, Signature *s,
char *rulestr)
const char *rulestr)
{
SCEnter();
@ -293,7 +293,7 @@ static void DetectCipServiceRegisterTests(void)
/**
* \brief ENIP Commond Detect Prototypes
*/
static int DetectEnipCommandSetup(DetectEngineCtx *, Signature *, char *);
static int DetectEnipCommandSetup(DetectEngineCtx *, Signature *, const char *);
static void DetectEnipCommandFree(void *);
static void DetectEnipCommandRegisterTests(void);
static int g_enip_buffer_id = 0;
@ -372,7 +372,7 @@ error:
* \retval -1 on Failure
*/
static int DetectEnipCommandSetup(DetectEngineCtx *de_ctx, Signature *s,
char *rulestr)
const char *rulestr)
{
DetectEnipCommandData *enipcmdd = NULL;
SigMatch *sm = NULL;

@ -42,7 +42,7 @@
static pcre *regex = NULL;
static pcre_extra *regex_study = NULL;
static int DetectClasstypeSetup(DetectEngineCtx *, Signature *, char *);
static int DetectClasstypeSetup(DetectEngineCtx *, Signature *, const char *);
static void DetectClasstypeRegisterTests(void);
/**
@ -68,20 +68,13 @@ void DetectClasstypeRegister(void)
*
* \retval bool success or failure.
*/
static int DetectClasstypeParseRawString(char *rawstr, char *out, size_t outsize)
static int DetectClasstypeParseRawString(const char *rawstr, char *out, size_t outsize)
{
#define MAX_SUBSTRINGS 30
int ret = 0;
int ov[MAX_SUBSTRINGS];
size_t len = strlen(rawstr);
/* get rid of the double quotes if present */
if (rawstr[0] == '\"' && rawstr[strlen(rawstr) - 1] == '\"') {
rawstr++;
rawstr[strlen(rawstr) - 1] = '\0';
len -= 2;
}
ret = pcre_exec(regex, regex_study, rawstr, len, 0, 0, ov, 30);
if (ret < 0) {
SCLogError(SC_ERR_PCRE_MATCH, "Invalid Classtype in Signature");
@ -110,7 +103,7 @@ static int DetectClasstypeParseRawString(char *rawstr, char *out, size_t outsize
* \retval 0 On success
* \retval -1 On failure
*/
static int DetectClasstypeSetup(DetectEngineCtx *de_ctx, Signature *s, char *rawstr)
static int DetectClasstypeSetup(DetectEngineCtx *de_ctx, Signature *s, const char *rawstr)
{
char parsed_ct_name[1024] = "";
SCClassConfClasstype *ct = NULL;
@ -153,7 +146,7 @@ static int DetectClasstypeSetup(DetectEngineCtx *de_ctx, Signature *s, char *raw
* \test Check that supplying an invalid classtype in the rule, results in the
* rule being invalidated.
*/
static int DetectClasstypeTest01()
static int DetectClasstypeTest01(void)
{
int result = 0;
@ -182,7 +175,7 @@ end:
* properly, with rules containing invalid classtypes being rejected
* and the ones containing valid classtypes parsed and returned.
*/
static int DetectClasstypeTest02()
static int DetectClasstypeTest02(void)
{
int result = 0;
Signature *last = NULL;
@ -248,7 +241,7 @@ end:
* \test Check that the signatures are assigned priority based on classtype they
* are given.
*/
static int DetectClasstypeTest03()
static int DetectClasstypeTest03(void)
{
int result = 0;
Signature *last = NULL;

@ -303,33 +303,6 @@ void DetectContentPrint(DetectContentData *cd)
SCLogDebug("-----------");
}
/**
* \brief Print list of DETECT_CONTENT SigMatch's allocated in a
* SigMatch list, from the current sm to the end
* \param sm pointer to the current SigMatch to start printing from
*/
void DetectContentPrintAll(SigMatch *sm)
{
#ifdef DEBUG
if (SCLogDebugEnabled()) {
int i = 0;
if (sm == NULL)
return;
SigMatch *first_sm = sm;
/* Print all of them */
for (; first_sm != NULL; first_sm = first_sm->next) {
if (first_sm->type == DETECT_CONTENT) {
SCLogDebug("Printing SigMatch DETECT_CONTENT %d", ++i);
DetectContentPrint((DetectContentData*)first_sm->ctx);
}
}
}
#endif /* DEBUG */
}
/**
* \brief Function to setup a content pattern.
*
@ -340,7 +313,7 @@ void DetectContentPrintAll(SigMatch *sm)
* \retval -1 if error
* \retval 0 if all was ok
*/
int DetectContentSetup(DetectEngineCtx *de_ctx, Signature *s, char *contentstr)
int DetectContentSetup(DetectEngineCtx *de_ctx, Signature *s, const char *contentstr)
{
DetectContentData *cd = NULL;
SigMatch *sm = NULL;
@ -393,6 +366,33 @@ void DetectContentFree(void *ptr)
}
#ifdef UNITTESTS /* UNITTESTS */
/**
* \brief Print list of DETECT_CONTENT SigMatch's allocated in a
* SigMatch list, from the current sm to the end
* \param sm pointer to the current SigMatch to start printing from
*/
static void DetectContentPrintAll(SigMatch *sm)
{
#ifdef DEBUG
if (SCLogDebugEnabled()) {
int i = 0;
if (sm == NULL)
return;
SigMatch *first_sm = sm;
/* Print all of them */
for (; first_sm != NULL; first_sm = first_sm->next) {
if (first_sm->type == DETECT_CONTENT) {
SCLogDebug("Printing SigMatch DETECT_CONTENT %d", ++i);
DetectContentPrint((DetectContentData*)first_sm->ctx);
}
}
}
#endif /* DEBUG */
}
static int g_file_data_buffer_id = 0;
static int g_dce_stub_data_buffer_id = 0;
@ -633,7 +633,7 @@ static int DetectContentParseTest08 (void)
* \retval return 1 if match
* \retval return 0 if not
*/
static int DetectContentLongPatternMatchTest(uint8_t *raw_eth_pkt, uint16_t pktsize, char *sig,
static int DetectContentLongPatternMatchTest(uint8_t *raw_eth_pkt, uint16_t pktsize, const char *sig,
uint32_t sid)
{
int result = 0;
@ -705,7 +705,7 @@ end:
/**
* \brief Wrapper for DetectContentLongPatternMatchTest
*/
static int DetectContentLongPatternMatchTestWrp(char *sig, uint32_t sid)
static int DetectContentLongPatternMatchTestWrp(const char *sig, uint32_t sid)
{
/** Real packet with the following tcp data:
* "Hi, this is a big test to check content matches of splitted"
@ -740,9 +740,9 @@ static int DetectContentLongPatternMatchTestWrp(char *sig, uint32_t sid)
/**
* \test Check if we match a normal pattern (not splitted)
*/
static int DetectContentLongPatternMatchTest01()
static int DetectContentLongPatternMatchTest01(void)
{
char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";"
const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";"
" content:\"Hi, this is a big test\"; sid:1;)";
return DetectContentLongPatternMatchTestWrp(sig, 1);
}
@ -750,9 +750,9 @@ static int DetectContentLongPatternMatchTest01()
/**
* \test Check if we match a splitted pattern
*/
static int DetectContentLongPatternMatchTest02()
static int DetectContentLongPatternMatchTest02(void)
{
char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";"
const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";"
" content:\"Hi, this is a big test to check content matches of"
" splitted patterns between multiple chunks!\"; sid:1;)";
return DetectContentLongPatternMatchTestWrp(sig, 1);
@ -762,10 +762,10 @@ static int DetectContentLongPatternMatchTest02()
* \test Check that we don't match the signature if one of the splitted
* chunks doesn't match the packet
*/
static int DetectContentLongPatternMatchTest03()
static int DetectContentLongPatternMatchTest03(void)
{
/** The last chunk of the content should not match */
char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";"
const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\";"
" content:\"Hi, this is a big test to check content matches of"
" splitted patterns between multiple splitted chunks!\"; sid:1;)";
return (DetectContentLongPatternMatchTestWrp(sig, 1) == 0) ? 1: 0;
@ -774,9 +774,9 @@ static int DetectContentLongPatternMatchTest03()
/**
* \test Check if we match multiple content (not splitted)
*/
static int DetectContentLongPatternMatchTest04()
static int DetectContentLongPatternMatchTest04(void)
{
char *sig = "alert tcp any any -> any any (msg:\"Nothing..\"; "
const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\"; "
" content:\"Hi, this is\"; depth:15 ;content:\"a big test\"; "
" within:15; content:\"to check content matches of\"; "
" within:30; content:\"splitted patterns\"; distance:1; "
@ -790,9 +790,9 @@ static int DetectContentLongPatternMatchTest04()
* Here we should specify only contents that fit in 32 bytes
* Each of them with their modifier values
*/
static int DetectContentLongPatternMatchTest05()
static int DetectContentLongPatternMatchTest05(void)
{
char *sig = "alert tcp any any -> any any (msg:\"Nothing..\"; "
const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\"; "
" content:\"Hi, this is a big\"; depth:17; "
" isdataat:30, relative; "
" content:\"test\"; within: 5; distance:1; "
@ -810,9 +810,9 @@ static int DetectContentLongPatternMatchTest05()
* Here we should specify contents that fit and contents that must be splitted
* Each of them with their modifier values
*/
static int DetectContentLongPatternMatchTest06()
static int DetectContentLongPatternMatchTest06(void)
{
char *sig = "alert tcp any any -> any any (msg:\"Nothing..\"; "
const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\"; "
" content:\"Hi, this is a big test to check cont\"; depth:36;"
" content:\"ent matches\"; within:11; distance:0; "
" content:\"of splitted patterns between multiple\"; "
@ -826,9 +826,9 @@ static int DetectContentLongPatternMatchTest06()
* \test Check if we match contents that are in the payload
* but not in the same order as specified in the signature
*/
static int DetectContentLongPatternMatchTest07()
static int DetectContentLongPatternMatchTest07(void)
{
char *sig = "alert tcp any any -> any any (msg:\"Nothing..\"; "
const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\"; "
" content:\"chunks!\"; "
" content:\"content matches\"; offset:32; depth:47; "
" content:\"of splitted patterns between multiple\"; "
@ -841,9 +841,9 @@ static int DetectContentLongPatternMatchTest07()
* \test Check if we match contents that are in the payload
* but not in the same order as specified in the signature
*/
static int DetectContentLongPatternMatchTest08()
static int DetectContentLongPatternMatchTest08(void)
{
char *sig = "alert tcp any any -> any any (msg:\"Nothing..\"; "
const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\"; "
" content:\"ent matches\"; "
" content:\"of splitted patterns between multiple\"; "
" within:38; distance:1; "
@ -857,9 +857,9 @@ static int DetectContentLongPatternMatchTest08()
* \test Check if we match contents that are in the payload
* but not in the same order as specified in the signature
*/
static int DetectContentLongPatternMatchTest09()
static int DetectContentLongPatternMatchTest09(void)
{
char *sig = "alert tcp any any -> any any (msg:\"Nothing..\"; "
const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\"; "
" content:\"ent matches\"; "
" content:\"of splitted patterns between multiple\"; "
" offset:47; depth:85; "
@ -873,9 +873,9 @@ static int DetectContentLongPatternMatchTest09()
/**
* \test Check if we match two consecutive simple contents
*/
static int DetectContentLongPatternMatchTest10()
static int DetectContentLongPatternMatchTest10(void)
{
char *sig = "alert tcp any any -> any any (msg:\"Nothing..\"; "
const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\"; "
" content:\"Hi, this is a big test to check \"; "
" content:\"con\"; "
" sid:1;)";
@ -885,9 +885,9 @@ static int DetectContentLongPatternMatchTest10()
/**
* \test Check if we match two contents of length 1
*/
static int DetectContentLongPatternMatchTest11()
static int DetectContentLongPatternMatchTest11(void)
{
char *sig = "alert tcp any any -> any any (msg:\"Nothing..\"; "
const char *sig = "alert tcp any any -> any any (msg:\"Nothing..\"; "
" content:\"H\"; "
" content:\"i\"; "
" sid:1;)";
@ -917,7 +917,7 @@ static int DetectContentParseTest09(void)
static int DetectContentParseTest17(void)
{
int result = 0;
char *sigstr = "alert tcp any any -> any any (msg:\"Dummy\"; "
const char *sigstr = "alert tcp any any -> any any (msg:\"Dummy\"; "
"content:\"one\"; content:\"two\"; within:2; sid:1;)";
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
@ -1857,7 +1857,7 @@ end:
return result;
}
static int SigTestPositiveTestContent(char *rule, uint8_t *buf)
static int SigTestPositiveTestContent(const char *rule, uint8_t *buf)
{
uint16_t buflen = strlen((char *)buf);
Packet *p = NULL;
@ -2136,7 +2136,7 @@ static int DetectContentParseTest45(void)
PASS;
}
static int SigTestNegativeTestContent(char *rule, uint8_t *buf)
static int SigTestNegativeTestContent(const char *rule, uint8_t *buf)
{
uint16_t buflen = strlen((char *)buf);
Packet *p = NULL;
@ -2525,7 +2525,7 @@ end:
return result;
}
static int DetectLongContentTestCommon(char *sig, uint32_t sid)
static int DetectLongContentTestCommon(const char *sig, uint32_t sid)
{
/* Packet with 512 A's in it for testing long content. */
static uint8_t pkt[739] = {
@ -2631,7 +2631,7 @@ static int DetectLongContentTestCommon(char *sig, uint32_t sid)
static int DetectLongContentTest1(void)
{
/* Signature with 256 A's. */
char *sig = "alert tcp any any -> any any (msg:\"Test Rule\"; content:\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"; sid:1;)";
const char *sig = "alert tcp any any -> any any (msg:\"Test Rule\"; content:\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"; sid:1;)";
return DetectLongContentTestCommon(sig, 1);
}
@ -2639,7 +2639,7 @@ static int DetectLongContentTest1(void)
static int DetectLongContentTest2(void)
{
/* Signature with 512 A's. */
char *sig = "alert tcp any any -> any any (msg:\"Test Rule\"; content:\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"; sid:1;)";
const char *sig = "alert tcp any any -> any any (msg:\"Test Rule\"; content:\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"; sid:1;)";
return DetectLongContentTestCommon(sig, 1);
}
@ -2647,7 +2647,7 @@ static int DetectLongContentTest2(void)
static int DetectLongContentTest3(void)
{
/* Signature with 513 A's. */
char *sig = "alert tcp any any -> any any (msg:\"Test Rule\"; content:\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"; sid:1;)";
const char *sig = "alert tcp any any -> any any (msg:\"Test Rule\"; content:\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"; sid:1;)";
return !DetectLongContentTestCommon(sig, 1);
}

@ -112,7 +112,7 @@ int DetectContentDataParse(const char *keyword, const char *contentstr,
DetectContentData *DetectContentParseEncloseQuotes(SpmGlobalThreadCtx *spm_global_thread_ctx,
const char *contentstr);
int DetectContentSetup(DetectEngineCtx *de_ctx, Signature *s, char *contentstr);
int DetectContentSetup(DetectEngineCtx *de_ctx, Signature *s, const char *contentstr);
void DetectContentPrint(DetectContentData *);
void DetectContentFree(void *);

@ -42,43 +42,43 @@
/* prototypes for the "ipv4-csum" rule keyword */
static int DetectIPV4CsumMatch(ThreadVars *, DetectEngineThreadCtx *,
Packet *, const Signature *, const SigMatchCtx *);
static int DetectIPV4CsumSetup(DetectEngineCtx *, Signature *, char *);
static int DetectIPV4CsumSetup(DetectEngineCtx *, Signature *, const char *);
static void DetectIPV4CsumFree(void *);
/* prototypes for the "tcpv4-csum" rule keyword */
static int DetectTCPV4CsumMatch(ThreadVars *, DetectEngineThreadCtx *,
Packet *, const Signature *, const SigMatchCtx *);
static int DetectTCPV4CsumSetup(DetectEngineCtx *, Signature *, char *);
static int DetectTCPV4CsumSetup(DetectEngineCtx *, Signature *, const char *);
static void DetectTCPV4CsumFree(void *);
/* prototypes for the "tcpv6-csum" rule keyword */
static int DetectTCPV6CsumMatch(ThreadVars *, DetectEngineThreadCtx *,
Packet *, const Signature *, const SigMatchCtx *);
static int DetectTCPV6CsumSetup(DetectEngineCtx *, Signature *, char *);
static int DetectTCPV6CsumSetup(DetectEngineCtx *, Signature *, const char *);
static void DetectTCPV6CsumFree(void *);
/* prototypes for the "udpv4-csum" rule keyword */
static int DetectUDPV4CsumMatch(ThreadVars *, DetectEngineThreadCtx *,
Packet *, const Signature *, const SigMatchCtx *);
static int DetectUDPV4CsumSetup(DetectEngineCtx *, Signature *, char *);
static int DetectUDPV4CsumSetup(DetectEngineCtx *, Signature *, const char *);
static void DetectUDPV4CsumFree(void *);
/* prototypes for the "udpv6-csum" rule keyword */
static int DetectUDPV6CsumMatch(ThreadVars *, DetectEngineThreadCtx *,
Packet *, const Signature *, const SigMatchCtx *);
static int DetectUDPV6CsumSetup(DetectEngineCtx *, Signature *, char *);
static int DetectUDPV6CsumSetup(DetectEngineCtx *, Signature *, const char *);
static void DetectUDPV6CsumFree(void *);
/* prototypes for the "icmpv4-csum" rule keyword */
static int DetectICMPV4CsumMatch(ThreadVars *, DetectEngineThreadCtx *,
Packet *, const Signature *, const SigMatchCtx *);
static int DetectICMPV4CsumSetup(DetectEngineCtx *, Signature *, char *);
static int DetectICMPV4CsumSetup(DetectEngineCtx *, Signature *, const char *);
static void DetectICMPV4CsumFree(void *);
/* prototypes for the "icmpv6-csum" rule keyword */
static int DetectICMPV6CsumMatch(ThreadVars *, DetectEngineThreadCtx *,
Packet *, const Signature *, const SigMatchCtx *);
static int DetectICMPV6CsumSetup(DetectEngineCtx *, Signature *, char *);
static int DetectICMPV6CsumSetup(DetectEngineCtx *, Signature *, const char *);
static void DetectICMPV6CsumFree(void *);
static void DetectCsumRegisterTests(void);
@ -266,7 +266,7 @@ static int DetectIPV4CsumMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx,
*
* \retval 0 on success, -1 on failure
*/
static int DetectIPV4CsumSetup(DetectEngineCtx *de_ctx, Signature *s, char *csum_str)
static int DetectIPV4CsumSetup(DetectEngineCtx *de_ctx, Signature *s, const char *csum_str)
{
DetectCsumData *cd = NULL;
SigMatch *sm = NULL;
@ -363,7 +363,7 @@ static int DetectTCPV4CsumMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx,
*
* \retval 0 on success, -1 on failure
*/
static int DetectTCPV4CsumSetup(DetectEngineCtx *de_ctx, Signature *s, char *csum_str)
static int DetectTCPV4CsumSetup(DetectEngineCtx *de_ctx, Signature *s, const char *csum_str)
{
DetectCsumData *cd = NULL;
SigMatch *sm = NULL;
@ -460,7 +460,7 @@ static int DetectTCPV6CsumMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx,
*
* \retval 0 on success, -1 on failure
*/
static int DetectTCPV6CsumSetup(DetectEngineCtx *de_ctx, Signature *s, char *csum_str)
static int DetectTCPV6CsumSetup(DetectEngineCtx *de_ctx, Signature *s, const char *csum_str)
{
DetectCsumData *cd = NULL;
SigMatch *sm = NULL;
@ -557,7 +557,7 @@ static int DetectUDPV4CsumMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx,
*
* \retval 0 on success, -1 on failure
*/
static int DetectUDPV4CsumSetup(DetectEngineCtx *de_ctx, Signature *s, char *csum_str)
static int DetectUDPV4CsumSetup(DetectEngineCtx *de_ctx, Signature *s, const char *csum_str)
{
DetectCsumData *cd = NULL;
SigMatch *sm = NULL;
@ -654,7 +654,7 @@ static int DetectUDPV6CsumMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx,
*
* \retval 0 on success, -1 on failure
*/
static int DetectUDPV6CsumSetup(DetectEngineCtx *de_ctx, Signature *s, char *csum_str)
static int DetectUDPV6CsumSetup(DetectEngineCtx *de_ctx, Signature *s, const char *csum_str)
{
DetectCsumData *cd = NULL;
SigMatch *sm = NULL;
@ -749,7 +749,7 @@ static int DetectICMPV4CsumMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx,
*
* \retval 0 on success, -1 on failure
*/
static int DetectICMPV4CsumSetup(DetectEngineCtx *de_ctx, Signature *s, char *csum_str)
static int DetectICMPV4CsumSetup(DetectEngineCtx *de_ctx, Signature *s, const char *csum_str)
{
DetectCsumData *cd = NULL;
SigMatch *sm = NULL;
@ -849,7 +849,7 @@ static int DetectICMPV6CsumMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx,
*
* \retval 0 on success, -1 on failure
*/
static int DetectICMPV6CsumSetup(DetectEngineCtx *de_ctx, Signature *s, char *csum_str)
static int DetectICMPV6CsumSetup(DetectEngineCtx *de_ctx, Signature *s, const char *csum_str)
{
DetectCsumData *cd = NULL;
SigMatch *sm = NULL;
@ -944,7 +944,7 @@ static int DetectCsumValidArgsTestParse01(void)
DetectEngineCtxFree(de_ctx);\
}
int DetectCsumInvalidArgsTestParse02(void)
static int DetectCsumInvalidArgsTestParse02(void)
{
TEST2(ipv4);
TEST2(tcpv4);
@ -975,7 +975,7 @@ int DetectCsumInvalidArgsTestParse02(void)
DetectEngineCtxFree(de_ctx);\
}
int DetectCsumValidArgsTestParse03(void)
static int DetectCsumValidArgsTestParse03(void)
{
TEST3(ipv4, DETECT_IPV4_CSUM);
TEST3(tcpv4, DETECT_TCPV4_CSUM);

@ -55,7 +55,7 @@ static pcre_extra *parse_regex_study = NULL;
static int DetectDceIfaceMatch(ThreadVars *, DetectEngineThreadCtx *,
Flow *, uint8_t, void *, void *,
const Signature *, const SigMatchCtx *);
static int DetectDceIfaceSetup(DetectEngineCtx *, Signature *, char *);
static int DetectDceIfaceSetup(DetectEngineCtx *, Signature *, const char *);
static void DetectDceIfaceFree(void *);
static void DetectDceIfaceRegisterTests(void);
static int g_dce_generic_list_id = 0;
@ -365,7 +365,7 @@ end:
* \retval 0 on success, -1 on failure.
*/
static int DetectDceIfaceSetup(DetectEngineCtx *de_ctx, Signature *s, char *arg)
static int DetectDceIfaceSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg)
{
DetectDceIfaceData *did = NULL;
SigMatch *sm = NULL;

@ -56,7 +56,7 @@ static pcre_extra *parse_regex_study = NULL;
static int DetectDceOpnumMatch(ThreadVars *, DetectEngineThreadCtx *,
Flow *, uint8_t, void *, void *,
const Signature *, const SigMatchCtx *);
static int DetectDceOpnumSetup(DetectEngineCtx *, Signature *, char *);
static int DetectDceOpnumSetup(DetectEngineCtx *, Signature *, const char *);
static void DetectDceOpnumFree(void *);
static void DetectDceOpnumRegisterTests(void);
static int g_dce_generic_list_id = 0;
@ -285,7 +285,7 @@ static int DetectDceOpnumMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx,
* \retval 0 on success, -1 on failure
*/
static int DetectDceOpnumSetup(DetectEngineCtx *de_ctx, Signature *s, char *arg)
static int DetectDceOpnumSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg)
{
DetectDceOpnumData *dod = NULL;
SigMatch *sm = NULL;

@ -57,7 +57,7 @@
#define BUFFER_NAME "dce_stub_data"
#define KEYWORD_NAME "dce_stub_data"
static int DetectDceStubDataSetup(DetectEngineCtx *, Signature *, char *);
static int DetectDceStubDataSetup(DetectEngineCtx *, Signature *, const char *);
static void DetectDceStubDataRegisterTests(void);
static int g_dce_stub_data_buffer_id = 0;
@ -235,7 +235,7 @@ void DetectDceStubDataRegister(void)
* \retval 0 on success, -1 on failure
*/
static int DetectDceStubDataSetup(DetectEngineCtx *de_ctx, Signature *s, char *arg)
static int DetectDceStubDataSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg)
{
if (DetectSignatureSetAppProto(s, ALPROTO_DCERPC) != 0)
return -1;

@ -33,6 +33,7 @@
#include "detect-content.h"
#include "detect-uricontent.h"
#include "detect-byte-extract.h"
#include "detect-depth.h"
#include "flow-var.h"
#include "app-layer.h"
@ -40,7 +41,7 @@
#include "util-byte.h"
#include "util-debug.h"
static int DetectDepthSetup (DetectEngineCtx *, Signature *, char *);
static int DetectDepthSetup (DetectEngineCtx *, Signature *, const char *);
void DetectDepthRegister (void)
{
@ -53,24 +54,12 @@ void DetectDepthRegister (void)
sigmatch_table[DETECT_DEPTH].RegisterTests = NULL;
}
static int DetectDepthSetup (DetectEngineCtx *de_ctx, Signature *s, char *depthstr)
static int DetectDepthSetup (DetectEngineCtx *de_ctx, Signature *s, const char *depthstr)
{
char *str = depthstr;
char dubbed = 0;
const char *str = depthstr;
SigMatch *pm = NULL;
int ret = -1;
/* Strip leading and trailing "s. */
if (depthstr[0] == '\"') {
str = SCStrdup(depthstr + 1);
if (unlikely(str == NULL))
goto end;
if (strlen(str) && str[strlen(str) - 1] == '\"') {
str[strlen(str) - 1] = '\0';
}
dubbed = 1;
}
/* retrive the sm to apply the depth against */
pm = DetectGetLastSMFromLists(s, DETECT_CONTENT, -1);
if (pm == NULL) {
@ -131,7 +120,5 @@ static int DetectDepthSetup (DetectEngineCtx *de_ctx, Signature *s, char *depths
ret = 0;
end:
if (dubbed)
SCFree(str);
return ret;
}

@ -53,7 +53,7 @@ static pcre_extra *parse_regex_study;
static int DetectDetectionFilterMatch(ThreadVars *, DetectEngineThreadCtx *,
Packet *, const Signature *, const SigMatchCtx *);
static int DetectDetectionFilterSetup(DetectEngineCtx *, Signature *, char *);
static int DetectDetectionFilterSetup(DetectEngineCtx *, Signature *, const char *);
static void DetectDetectionFilterRegisterTests(void);
static void DetectDetectionFilterFree(void *);
@ -90,7 +90,7 @@ static int DetectDetectionFilterMatch (ThreadVars *thv, DetectEngineThreadCtx *d
* \retval df pointer to DetectThresholdData on success
* \retval NULL on failure
*/
static DetectThresholdData *DetectDetectionFilterParse (char *rawstr)
static DetectThresholdData *DetectDetectionFilterParse (const char *rawstr)
{
DetectThresholdData *df = NULL;
#define MAX_SUBSTRINGS 30
@ -207,7 +207,7 @@ error:
* \retval 0 on Success
* \retval -1 on Failure
*/
static int DetectDetectionFilterSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr)
static int DetectDetectionFilterSetup (DetectEngineCtx *de_ctx, Signature *s, const char *rawstr)
{
SCEnter();
DetectThresholdData *df = NULL;

@ -37,6 +37,7 @@
#include "detect-uricontent.h"
#include "detect-pcre.h"
#include "detect-byte-extract.h"
#include "detect-distance.h"
#include "flow-var.h"
@ -45,7 +46,7 @@
#include "detect-bytejump.h"
#include "util-unittest-helper.h"
static int DetectDistanceSetup(DetectEngineCtx *, Signature *, char *);
static int DetectDistanceSetup(DetectEngineCtx *, Signature *, const char *);
static void DetectDistanceRegisterTests(void);
void DetectDistanceRegister(void)
@ -60,24 +61,12 @@ void DetectDistanceRegister(void)
}
static int DetectDistanceSetup (DetectEngineCtx *de_ctx, Signature *s,
char *distancestr)
const char *distancestr)
{
char *str = distancestr;
char dubbed = 0;
const char *str = distancestr;
SigMatch *pm = NULL;
int ret = -1;
/* Strip leading and trailing "s. */
if (distancestr[0] == '\"') {
str = SCStrdup(distancestr + 1);
if (unlikely(str == NULL))
goto end;
if (strlen(str) && str[strlen(str) - 1] == '\"') {
str[strlen(str) - 1] = '\0';
}
dubbed = 1;
}
/* retrieve the sm to apply the distance against */
pm = DetectGetLastSMFromLists(s, DETECT_CONTENT, -1);
if (pm == NULL) {
@ -154,8 +143,6 @@ static int DetectDistanceSetup (DetectEngineCtx *de_ctx, Signature *s,
ret = 0;
end:
if (dubbed)
SCFree(str);
return ret;
}

@ -184,7 +184,7 @@ static int DetectEngineInspectDNP3(ThreadVars *tv, DetectEngineCtx *de_ctx,
* \retval The function code as an integer if successul, -1 on
* failure.
*/
static int DetectDNP3FuncParseFunctionCode(char *str, uint8_t *fc)
static int DetectDNP3FuncParseFunctionCode(const char *str, uint8_t *fc)
{
if (ByteExtractStringUint8(fc, 10, strlen(str), str) >= 0) {
return 1;
@ -202,7 +202,7 @@ static int DetectDNP3FuncParseFunctionCode(char *str, uint8_t *fc)
return 0;
}
static int DetectDNP3FuncSetup(DetectEngineCtx *de_ctx, Signature *s, char *str)
static int DetectDNP3FuncSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str)
{
SCEnter();
DetectDNP3 *dnp3 = NULL;
@ -243,7 +243,7 @@ error:
SCReturnInt(-1);
}
static int DetectDNP3IndParseByName(char *str, uint16_t *flags)
static int DetectDNP3IndParseByName(const char *str, uint16_t *flags)
{
char tmp[strlen(str) + 1];
char *p, *last = NULL;
@ -273,7 +273,7 @@ static int DetectDNP3IndParseByName(char *str, uint16_t *flags)
return 1;
}
static int DetectDNP3IndParse(char *str, uint16_t *flags)
static int DetectDNP3IndParse(const char *str, uint16_t *flags)
{
*flags = 0;
@ -289,7 +289,7 @@ static int DetectDNP3IndParse(char *str, uint16_t *flags)
return 0;
}
static int DetectDNP3IndSetup(DetectEngineCtx *de_ctx, Signature *s, char *str)
static int DetectDNP3IndSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str)
{
SCEnter();
DetectDNP3 *detect = NULL;
@ -363,7 +363,7 @@ static int DetectDNP3ObjParse(const char *str, uint8_t *group, uint8_t *var)
return 1;
}
static int DetectDNP3ObjSetup(DetectEngineCtx *de_ctx, Signature *s, char *str)
static int DetectDNP3ObjSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str)
{
SCEnter();
uint8_t group;
@ -523,7 +523,7 @@ static void DetectDNP3ObjRegister(void)
SCReturn;
}
static int DetectDNP3DataSetup(DetectEngineCtx *de_ctx, Signature *s, char *str)
static int DetectDNP3DataSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str)
{
SCEnter();
s->init_data->list = g_dnp3_data_buffer_id;

@ -22,7 +22,7 @@
* Struct for mapping symbolic names to values.
*/
typedef struct DNP3Mapping_ {
char *name;
const char *name;
uint16_t value;
} DNP3Mapping;

@ -58,7 +58,7 @@
#include "util-unittest-helper.h"
static int DetectDnsQuerySetup (DetectEngineCtx *, Signature *, char *);
static int DetectDnsQuerySetup (DetectEngineCtx *, Signature *, const char *);
static void DetectDnsQueryRegisterTests(void);
static int g_dns_query_buffer_id = 0;
@ -114,7 +114,7 @@ void DetectDnsQueryRegister (void)
* \retval -1 On failure
*/
static int DetectDnsQuerySetup(DetectEngineCtx *de_ctx, Signature *s, char *str)
static int DetectDnsQuerySetup(DetectEngineCtx *de_ctx, Signature *s, const char *str)
{
s->init_data->list = g_dns_query_buffer_id;
s->alproto = ALPROTO_DNS;

@ -51,7 +51,7 @@ static pcre_extra *parse_regex_study;
static int DetectDsizeMatch (ThreadVars *, DetectEngineThreadCtx *, Packet *,
const Signature *, const SigMatchCtx *);
static int DetectDsizeSetup (DetectEngineCtx *, Signature *s, char *str);
static int DetectDsizeSetup (DetectEngineCtx *, Signature *s, const char *str);
static void DsizeRegisterTests(void);
static void DetectDsizeFree(void *);
@ -134,7 +134,7 @@ static int DetectDsizeMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Pack
* \retval dd pointer to DetectDsizeData on success
* \retval NULL on failure
*/
DetectDsizeData *DetectDsizeParse (char *rawstr)
static DetectDsizeData *DetectDsizeParse (const char *rawstr)
{
DetectDsizeData *dd = NULL;
#define MAX_SUBSTRINGS 30
@ -251,7 +251,7 @@ error:
* \retval 0 on Success
* \retval -1 on Failure
*/
static int DetectDsizeSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr)
static int DetectDsizeSetup (DetectEngineCtx *de_ctx, Signature *s, const char *rawstr)
{
DetectDsizeData *dd = NULL;
SigMatch *sm = NULL;
@ -386,7 +386,7 @@ static _Bool PrefilterDsizeIsPrefilterable(const Signature *s)
* \retval 1 on succces
* \retval 0 on failure
*/
int DsizeTestParse01 (void)
static int DsizeTestParse01 (void)
{
DetectDsizeData *dd = NULL;
dd = DetectDsizeParse("1");
@ -404,7 +404,7 @@ int DsizeTestParse01 (void)
* \retval 1 on succces
* \retval 0 on failure
*/
int DsizeTestParse02 (void)
static int DsizeTestParse02 (void)
{
DetectDsizeData *dd = NULL;
dd = DetectDsizeParse(">10");
@ -422,7 +422,7 @@ int DsizeTestParse02 (void)
* \retval 1 on succces
* \retval 0 on failure
*/
int DsizeTestParse03 (void)
static int DsizeTestParse03 (void)
{
DetectDsizeData *dd = NULL;
dd = DetectDsizeParse("<100");
@ -440,7 +440,7 @@ int DsizeTestParse03 (void)
* \retval 1 on succces
* \retval 0 on failure
*/
int DsizeTestParse04 (void)
static int DsizeTestParse04 (void)
{
DetectDsizeData *dd = NULL;
dd = DetectDsizeParse("1<>2");
@ -458,7 +458,7 @@ int DsizeTestParse04 (void)
* \retval 1 on succces
* \retval 0 on failure
*/
int DsizeTestParse05 (void)
static int DsizeTestParse05 (void)
{
int result = 0;
DetectDsizeData *dd = NULL;
@ -479,7 +479,7 @@ int DsizeTestParse05 (void)
* \retval 1 on succces
* \retval 0 on failure
*/
int DsizeTestParse06 (void)
static int DsizeTestParse06 (void)
{
int result = 0;
DetectDsizeData *dd = NULL;
@ -500,7 +500,7 @@ int DsizeTestParse06 (void)
* \retval 1 on succces
* \retval 0 on failure
*/
int DsizeTestParse07 (void)
static int DsizeTestParse07 (void)
{
int result = 0;
DetectDsizeData *dd = NULL;
@ -521,7 +521,7 @@ int DsizeTestParse07 (void)
* \retval 1 on succces
* \retval 0 on failure
*/
int DsizeTestParse08 (void)
static int DsizeTestParse08 (void)
{
int result = 0;
DetectDsizeData *dd = NULL;
@ -542,7 +542,7 @@ int DsizeTestParse08 (void)
* \retval 1 on succces
* \retval 0 on failure
*/
int DsizeTestParse09 (void)
static int DsizeTestParse09 (void)
{
DetectDsizeData *dd = NULL;
dd = DetectDsizeParse("A");
@ -560,7 +560,7 @@ int DsizeTestParse09 (void)
* \retval 1 on succces
* \retval 0 on failure
*/
int DsizeTestParse10 (void)
static int DsizeTestParse10 (void)
{
DetectDsizeData *dd = NULL;
dd = DetectDsizeParse(">10<>10");
@ -578,7 +578,7 @@ int DsizeTestParse10 (void)
* \retval 1 on succces
* \retval 0 on failure
*/
int DsizeTestParse11 (void)
static int DsizeTestParse11 (void)
{
DetectDsizeData *dd = NULL;
dd = DetectDsizeParse("<>10");
@ -596,7 +596,7 @@ int DsizeTestParse11 (void)
* \retval 1 on succces
* \retval 0 on failure
*/
int DsizeTestParse12 (void)
static int DsizeTestParse12 (void)
{
DetectDsizeData *dd = NULL;
dd = DetectDsizeParse("1<>");
@ -614,7 +614,7 @@ int DsizeTestParse12 (void)
* \retval 1 on succces
* \retval 0 on failure
*/
int DsizeTestParse13 (void)
static int DsizeTestParse13 (void)
{
int result = 0;
DetectDsizeData *dd = NULL;
@ -635,7 +635,7 @@ int DsizeTestParse13 (void)
* \retval 1 on succces
* \retval 0 on failure
*/
int DsizeTestParse14 (void)
static int DsizeTestParse14 (void)
{
DetectDsizeData *dd = NULL;
dd = DetectDsizeParse("");
@ -653,7 +653,7 @@ int DsizeTestParse14 (void)
* \retval 1 on succces
* \retval 0 on failure
*/
int DsizeTestParse15 (void)
static int DsizeTestParse15 (void)
{
DetectDsizeData *dd = NULL;
dd = DetectDsizeParse(" ");
@ -671,7 +671,7 @@ int DsizeTestParse15 (void)
* \retval 1 on succces
* \retval 0 on failure
*/
int DsizeTestParse16 (void)
static int DsizeTestParse16 (void)
{
DetectDsizeData *dd = NULL;
dd = DetectDsizeParse("2<>1");
@ -689,7 +689,7 @@ int DsizeTestParse16 (void)
* \retval 1 on succces
* \retval 0 on failure
*/
int DsizeTestParse17 (void)
static int DsizeTestParse17 (void)
{
int result = 0;
DetectDsizeData *dd = NULL;
@ -710,7 +710,7 @@ int DsizeTestParse17 (void)
* \retval 1 on succces
* \retval 0 on failure
*/
int DsizeTestParse18 (void)
static int DsizeTestParse18 (void)
{
int result = 0;
DetectDsizeData *dd = NULL;
@ -731,7 +731,7 @@ int DsizeTestParse18 (void)
* \retval 1 on succces
* \retval 0 on failure
*/
int DsizeTestParse19 (void)
static int DsizeTestParse19 (void)
{
int result = 0;
DetectDsizeData *dd = NULL;
@ -752,7 +752,7 @@ int DsizeTestParse19 (void)
* \retval 1 on succces
* \retval 0 on failure
*/
int DsizeTestParse20 (void)
static int DsizeTestParse20 (void)
{
int result = 0;
DetectDsizeData *dd = NULL;
@ -772,7 +772,7 @@ int DsizeTestParse20 (void)
* dsize keyword by creating 2 rules and matching a crafted packet
* against them. Only the first one shall trigger.
*/
int DetectDsizeIcmpv6Test01 (void)
static int DetectDsizeIcmpv6Test01 (void)
{
int result = 0;

@ -33,6 +33,7 @@
#include "util-unittest.h"
#include "detect-engine-address.h"
#include "detect-engine-address-ipv4.h"
#include "detect-engine-siggroup.h"
#include "detect-engine-port.h"

@ -33,6 +33,7 @@
#include "util-unittest.h"
#include "detect-engine-address.h"
#include "detect-engine-address-ipv6.h"
#include "detect-engine-siggroup.h"
#include "detect-engine-port.h"
@ -811,7 +812,7 @@ int DetectAddressJoinIPv6(DetectEngineCtx *de_ctx, DetectAddress *target,
#ifdef UNITTESTS
int AddressTestIPv6Gt01(void)
static int AddressTestIPv6Gt01(void)
{
int result = 0;
@ -824,7 +825,7 @@ int AddressTestIPv6Gt01(void)
return result;
}
int AddressTestIPv6Gt02(void)
static int AddressTestIPv6Gt02(void)
{
int result = 0;
@ -837,7 +838,7 @@ int AddressTestIPv6Gt02(void)
return result;
}
int AddressTestIPv6Gt03(void)
static int AddressTestIPv6Gt03(void)
{
int result = 0;
@ -850,7 +851,7 @@ int AddressTestIPv6Gt03(void)
return result;
}
int AddressTestIPv6Gt04(void)
static int AddressTestIPv6Gt04(void)
{
int result = 0;
@ -863,7 +864,7 @@ int AddressTestIPv6Gt04(void)
return result;
}
int AddressTestIPv6Lt01(void)
static int AddressTestIPv6Lt01(void)
{
int result = 0;
@ -876,7 +877,7 @@ int AddressTestIPv6Lt01(void)
return result;
}
int AddressTestIPv6Lt02(void)
static int AddressTestIPv6Lt02(void)
{
int result = 0;
@ -889,7 +890,7 @@ int AddressTestIPv6Lt02(void)
return result;
}
int AddressTestIPv6Lt03(void)
static int AddressTestIPv6Lt03(void)
{
int result = 0;
@ -902,7 +903,7 @@ int AddressTestIPv6Lt03(void)
return result;
}
int AddressTestIPv6Lt04(void)
static int AddressTestIPv6Lt04(void)
{
int result = 0;
@ -915,7 +916,7 @@ int AddressTestIPv6Lt04(void)
return result;
}
int AddressTestIPv6Eq01(void)
static int AddressTestIPv6Eq01(void)
{
int result = 0;
@ -928,7 +929,7 @@ int AddressTestIPv6Eq01(void)
return result;
}
int AddressTestIPv6Eq02(void)
static int AddressTestIPv6Eq02(void)
{
int result = 0;
@ -941,7 +942,7 @@ int AddressTestIPv6Eq02(void)
return result;
}
int AddressTestIPv6Eq03(void)
static int AddressTestIPv6Eq03(void)
{
int result = 0;
@ -954,7 +955,7 @@ int AddressTestIPv6Eq03(void)
return result;
}
int AddressTestIPv6Eq04(void)
static int AddressTestIPv6Eq04(void)
{
int result = 0;
@ -967,7 +968,7 @@ int AddressTestIPv6Eq04(void)
return result;
}
int AddressTestIPv6Le01(void)
static int AddressTestIPv6Le01(void)
{
int result = 0;
@ -980,7 +981,7 @@ int AddressTestIPv6Le01(void)
return result;
}
int AddressTestIPv6Le02(void)
static int AddressTestIPv6Le02(void)
{
int result = 0;
@ -993,7 +994,7 @@ int AddressTestIPv6Le02(void)
return result;
}
int AddressTestIPv6Le03(void)
static int AddressTestIPv6Le03(void)
{
int result = 0;
@ -1006,7 +1007,7 @@ int AddressTestIPv6Le03(void)
return result;
}
int AddressTestIPv6Le04(void)
static int AddressTestIPv6Le04(void)
{
int result = 0;
@ -1019,7 +1020,7 @@ int AddressTestIPv6Le04(void)
return result;
}
int AddressTestIPv6Le05(void)
static int AddressTestIPv6Le05(void)
{
int result = 0;
@ -1041,7 +1042,7 @@ int AddressTestIPv6Le05(void)
return result;
}
int AddressTestIPv6Ge01(void)
static int AddressTestIPv6Ge01(void)
{
int result = 0;
@ -1054,7 +1055,7 @@ int AddressTestIPv6Ge01(void)
return result;
}
int AddressTestIPv6Ge02(void)
static int AddressTestIPv6Ge02(void)
{
int result = 0;
@ -1067,7 +1068,7 @@ int AddressTestIPv6Ge02(void)
return result;
}
int AddressTestIPv6Ge03(void)
static int AddressTestIPv6Ge03(void)
{
int result = 0;
@ -1080,7 +1081,7 @@ int AddressTestIPv6Ge03(void)
return result;
}
int AddressTestIPv6Ge04(void)
static int AddressTestIPv6Ge04(void)
{
int result = 0;
@ -1093,7 +1094,7 @@ int AddressTestIPv6Ge04(void)
return result;
}
int AddressTestIPv6Ge05(void)
static int AddressTestIPv6Ge05(void)
{
int result = 0;
@ -1115,7 +1116,7 @@ int AddressTestIPv6Ge05(void)
return result;
}
int AddressTestIPv6SubOne01(void)
static int AddressTestIPv6SubOne01(void)
{
int result = 0;
@ -1144,7 +1145,7 @@ int AddressTestIPv6SubOne01(void)
return result;
}
int AddressTestIPv6SubOne02(void)
static int AddressTestIPv6SubOne02(void)
{
int result = 0;
@ -1173,7 +1174,7 @@ int AddressTestIPv6SubOne02(void)
return result;
}
int AddressTestIPv6AddOne01(void)
static int AddressTestIPv6AddOne01(void)
{
int result = 0;
@ -1202,7 +1203,7 @@ int AddressTestIPv6AddOne01(void)
return result;
}
int AddressTestIPv6AddOne02(void)
static int AddressTestIPv6AddOne02(void)
{
int result = 0;

@ -30,6 +30,12 @@ int AddressIPv6Eq(Address *, Address *);
int AddressIPv6Le(Address *, Address *);
int AddressIPv6Ge(Address *, Address *);
int AddressIPv6LeU32(uint32_t *a, uint32_t *b);
int AddressIPv6LtU32(uint32_t *a, uint32_t *b);
int AddressIPv6GtU32(uint32_t *a, uint32_t *b);
int AddressIPv6EqU32(uint32_t *a, uint32_t *b);
int AddressIPv6GeU32(uint32_t *a, uint32_t *b);
int DetectAddressCutNotIPv6(DetectAddress *, DetectAddress **);
int DetectAddressCmpIPv6(DetectAddress *a, DetectAddress *b);

File diff suppressed because it is too large Load Diff

@ -31,7 +31,7 @@ DetectAddressHead *DetectAddressHeadInit(void);
void DetectAddressHeadFree(DetectAddressHead *);
void DetectAddressHeadCleanup(DetectAddressHead *);
int DetectAddressParseString(DetectAddress *, char *);
int DetectAddressParseString(DetectAddress *, const char *);
int DetectAddressParse(const DetectEngineCtx *, DetectAddressHead *, const char *);
DetectAddress *DetectAddressInit(void);

@ -216,7 +216,7 @@ int SetupFPAnalyzer(void)
if (fp_engine_analysis_set == 0)
return 0;
char *log_dir;
const char *log_dir;
log_dir = ConfigGetLogDirectory();
snprintf(log_path, sizeof(log_path), "%s/%s", log_dir,
"rules_fast_pattern.txt");
@ -267,7 +267,7 @@ int SetupRuleAnalyzer(void)
rule_warnings_only = 1;
}
if (enabled) {
char *log_dir;
const char *log_dir;
log_dir = ConfigGetLogDirectory();
snprintf(log_path, sizeof(log_path), "%s/%s", log_dir, "rules_analysis.txt");
rule_engine_analysis_FD = fopen(log_path, "w");

@ -32,7 +32,7 @@ void CleanupFPAnalyzer(void);
int SetupRuleAnalyzer(void);
void CleanupRuleAnalyzer (void);
int PerCentEncodingSetup ();
int PerCentEncodingSetup (void);
int PerCentEncodingMatch (uint8_t *content, uint8_t content_len);
void EngineAnalysisFP(Signature *s, char *line);

@ -36,6 +36,7 @@
#include "detect-byte-extract.h"
#include "detect-content.h"
#include "detect-engine-content-inspection.h"
#include "detect-engine-dcepayload.h"
#include "stream-tcp.h"
@ -88,10 +89,10 @@ static int DcePayloadTest15(void)
Flow f;
int r;
char *sig1 = "alert tcp any any -> any any "
const char *sig1 = "alert tcp any any -> any any "
"(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; "
"byte_test:2,=,14080,0,relative,dce; sid:1;)";
char *sig2 = "alert tcp any any -> any any "
const char *sig2 = "alert tcp any any -> any any "
"(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; "
"byte_test:2,=,46,5,relative,dce; sid:2;)";
@ -205,10 +206,10 @@ static int DcePayloadTest16(void)
Flow f;
int r;
char *sig1 = "alert tcp any any -> any any "
const char *sig1 = "alert tcp any any -> any any "
"(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; "
"byte_test:2,=,55,0,relative; sid:1;)";
char *sig2 = "alert tcp any any -> any any "
const char *sig2 = "alert tcp any any -> any any "
"(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; "
"byte_test:2,=,11776,5,relative; sid:2;)";
@ -322,10 +323,10 @@ static int DcePayloadTest17(void)
Flow f;
int r;
char *sig1 = "alert tcp any any -> any any "
const char *sig1 = "alert tcp any any -> any any "
"(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; "
"byte_test:2,=,55,0,relative,big; sid:1;)";
char *sig2 = "alert tcp any any -> any any "
const char *sig2 = "alert tcp any any -> any any "
"(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; "
"byte_test:2,=,46,5,relative,little; sid:2;)";
@ -439,10 +440,10 @@ static int DcePayloadTest18(void)
Flow f;
int r;
char *sig1 = "alert tcp any any -> any any "
const char *sig1 = "alert tcp any any -> any any "
"(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; "
"byte_jump:2,0,relative,dce; byte_test:2,=,46,0,relative,dce; sid:1;)";
char *sig2 = "alert tcp any any -> any any "
const char *sig2 = "alert tcp any any -> any any "
"(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; "
"byte_jump:2,2,relative,dce; byte_test:2,=,14080,0,relative; sid:2;)";
@ -556,10 +557,10 @@ static int DcePayloadTest19(void)
Flow f;
int r;
char *sig1 = "alert tcp any any -> any any "
const char *sig1 = "alert tcp any any -> any any "
"(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; "
"byte_jump:2,0,relative; byte_test:2,=,46,0,relative,dce; sid:1;)";
char *sig2 = "alert tcp any any -> any any "
const char *sig2 = "alert tcp any any -> any any "
"(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; "
"byte_jump:2,2,relative; byte_test:2,=,14080,0,relative; sid:2;)";
@ -673,10 +674,10 @@ static int DcePayloadTest20(void)
Flow f;
int r;
char *sig1 = "alert tcp any any -> any any "
const char *sig1 = "alert tcp any any -> any any "
"(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; "
"byte_jump:2,0,relative,big; byte_test:2,=,46,0,relative,dce; sid:1;)";
char *sig2 = "alert tcp any any -> any any "
const char *sig2 = "alert tcp any any -> any any "
"(dce_stub_data; content:\"|5c 00 5c 00 31|\"; distance:0; "
"byte_jump:2,2,little,relative; byte_test:2,=,14080,0,relative; sid:2;)";
@ -784,7 +785,7 @@ static int DcePayloadTest21(void)
Flow f;
int r;
char *sig1 = "alert tcp any any -> any any "
const char *sig1 = "alert tcp any any -> any any "
"(msg:\"testing dce consecutive relative matches\"; dce_stub_data; "
"content:\"this\"; distance:0; content:\"is\"; within:6; content:\"big\"; within:8; "
"content:\"string\"; within:8; sid:1;)";
@ -886,7 +887,7 @@ static int DcePayloadTest22(void)
Flow f;
int r;
char *sig1 = "alert tcp any any -> any any "
const char *sig1 = "alert tcp any any -> any any "
"(msg:\"testing dce consecutive relative matches\"; dce_stub_data; "
"content:\"this\"; distance:0; content:\"is\"; within:9; content:\"big\"; within:12; "
"content:\"string\"; within:8; sid:1;)";
@ -988,7 +989,7 @@ static int DcePayloadTest23(void)
Flow f;
int r;
char *sig1 = "alert tcp any any -> any any "
const char *sig1 = "alert tcp any any -> any any "
"(msg:\"testing dce consecutive relative matches\"; dce_stub_data; "
"content:\"now\"; distance:0; content:\"this\"; distance:-20; "
"content:\"is\"; within:12; content:\"big\"; within:8; "
@ -3206,7 +3207,7 @@ static int DcePayloadTest42(void)
Flow f;
int r;
char *sig1 = "alert tcp any any -> any any "
const char *sig1 = "alert tcp any any -> any any "
"(msg:\"testing dce consecutive relative matches\"; dce_stub_data; "
"content:\"fix\"; distance:0; content:\"this\"; within:6; "
"content:!\"and\"; distance:0; sid:1;)";
@ -3310,7 +3311,7 @@ static int DcePayloadTest43(void)
Flow f;
int r;
char *sig1 = "alert tcp any any -> any any "
const char *sig1 = "alert tcp any any -> any any "
"(msg:\"testing dce consecutive relative matches\"; dce_stub_data; "
"pcre:/super/R; content:\"nova\"; within:7; sid:1;)";

@ -42,6 +42,7 @@
#include "app-layer-parser.h"
#include "app-layer-protos.h"
#include "app-layer-dns-common.h"
#include "detect-engine-dns.h"
#include "util-unittest.h"
#include "util-unittest-helper.h"

@ -72,7 +72,7 @@ void PrintENIPAL(ENIPTransaction *enip_data)
* @param svc - the CIP service entry
* * @param cipserviced - the CIP service rule
*/
int CIPPathMatch(CIPServiceEntry *svc, DetectCipServiceData *cipserviced)
static int CIPPathMatch(CIPServiceEntry *svc, DetectCipServiceData *cipserviced)
{
uint16_t class = 0;
uint16_t attrib = 0;
@ -161,7 +161,7 @@ int CIPPathMatch(CIPServiceEntry *svc, DetectCipServiceData *cipserviced)
* * @param cipserviced - the CIP service rule
*/
int CIPServiceMatch(ENIPTransaction *enip_data,
static int CIPServiceMatch(ENIPTransaction *enip_data,
DetectCipServiceData *cipserviced)
{
int count = 1;

@ -49,9 +49,9 @@ static pcre_extra *parse_regex_study;
static int DetectEngineEventMatch (ThreadVars *, DetectEngineThreadCtx *,
Packet *, const Signature *, const SigMatchCtx *);
static int DetectEngineEventSetup (DetectEngineCtx *, Signature *, char *);
static int DetectDecodeEventSetup (DetectEngineCtx *, Signature *, char *);
static int DetectStreamEventSetup (DetectEngineCtx *, Signature *, char *);
static int DetectEngineEventSetup (DetectEngineCtx *, Signature *, const char *);
static int DetectDecodeEventSetup (DetectEngineCtx *, Signature *, const char *);
static int DetectStreamEventSetup (DetectEngineCtx *, Signature *, const char *);
static void DetectEngineEventFree (void *);
void EngineEventRegisterTests(void);
@ -116,7 +116,7 @@ static int DetectEngineEventMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx
* \retval de pointer to DetectFlowData on success
* \retval NULL on failure
*/
DetectEngineEventData *DetectEngineEventParse (char *rawstr)
static DetectEngineEventData *DetectEngineEventParse (const char *rawstr)
{
int i;
DetectEngineEventData *de = NULL;
@ -180,7 +180,7 @@ error:
* \retval 0 on Success
* \retval -1 on Failure
*/
static int _DetectEngineEventSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr, int smtype)
static int DetectEngineEventSetupDo (DetectEngineCtx *de_ctx, Signature *s, const char *rawstr, int smtype)
{
DetectEngineEventData *de = NULL;
SigMatch *sm = NULL;
@ -208,9 +208,9 @@ error:
}
static int DetectEngineEventSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr)
static int DetectEngineEventSetup (DetectEngineCtx *de_ctx, Signature *s, const char *rawstr)
{
return _DetectEngineEventSetup (de_ctx, s, rawstr, DETECT_ENGINE_EVENT);
return DetectEngineEventSetupDo (de_ctx, s, rawstr, DETECT_ENGINE_EVENT);
}
/**
@ -230,20 +230,20 @@ static void DetectEngineEventFree(void *ptr)
* \brief this function Setup the 'decode-event' keyword by setting the correct
* signature type
*/
static int DetectDecodeEventSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr)
static int DetectDecodeEventSetup (DetectEngineCtx *de_ctx, Signature *s, const char *rawstr)
{
char drawstr[MAX_SUBSTRINGS * 2] = "decoder.";
/* decoder:$EVENT alias command develop as decode-event:decoder.$EVENT */
strlcat(drawstr, rawstr, 2 * MAX_SUBSTRINGS - strlen("decoder.") - 1);
return _DetectEngineEventSetup(de_ctx, s, drawstr, DETECT_DECODE_EVENT);
return DetectEngineEventSetupDo(de_ctx, s, drawstr, DETECT_DECODE_EVENT);
}
/**
* \brief this function Setup the 'stream-event' keyword by resolving the alias
*/
static int DetectStreamEventSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr)
static int DetectStreamEventSetup (DetectEngineCtx *de_ctx, Signature *s, const char *rawstr)
{
char srawstr[MAX_SUBSTRINGS * 2] = "stream.";
@ -261,7 +261,7 @@ static int DetectStreamEventSetup (DetectEngineCtx *de_ctx, Signature *s, char *
/**
* \test EngineEventTestParse01 is a test for a valid decode-event value
*/
int EngineEventTestParse01 (void)
static int EngineEventTestParse01 (void)
{
DetectEngineEventData *de = NULL;
de = DetectEngineEventParse("decoder.ipv4.pkt_too_small");
@ -277,7 +277,7 @@ int EngineEventTestParse01 (void)
/**
* \test EngineEventTestParse02 is a test for a valid upper + lower case decode-event value
*/
int EngineEventTestParse02 (void)
static int EngineEventTestParse02 (void)
{
DetectEngineEventData *de = NULL;
de = DetectEngineEventParse("decoder.PPP.pkt_too_small");
@ -292,7 +292,7 @@ int EngineEventTestParse02 (void)
/**
* \test EngineEventTestParse03 is a test for a valid upper case decode-event value
*/
int EngineEventTestParse03 (void)
static int EngineEventTestParse03 (void)
{
DetectEngineEventData *de = NULL;
de = DetectEngineEventParse("decoder.IPV6.PKT_TOO_SMALL");
@ -307,7 +307,7 @@ int EngineEventTestParse03 (void)
/**
* \test EngineEventTestParse04 is a test for an invalid upper case decode-event value
*/
int EngineEventTestParse04 (void)
static int EngineEventTestParse04 (void)
{
DetectEngineEventData *de = NULL;
de = DetectEngineEventParse("decoder.IPV6.INVALID_EVENT");
@ -322,7 +322,7 @@ int EngineEventTestParse04 (void)
/**
* \test EngineEventTestParse05 is a test for an invalid char into the decode-event value
*/
int EngineEventTestParse05 (void)
static int EngineEventTestParse05 (void)
{
DetectEngineEventData *de = NULL;
de = DetectEngineEventParse("decoder.IPV-6,INVALID_CHAR");
@ -337,7 +337,7 @@ int EngineEventTestParse05 (void)
/**
* \test EngineEventTestParse06 is a test for match function with valid decode-event value
*/
int EngineEventTestParse06 (void)
static int EngineEventTestParse06 (void)
{
Packet *p = SCMalloc(SIZE_OF_PACKET);
if (unlikely(p == NULL))

@ -39,6 +39,7 @@
#include "detect-engine-hcd.h"
#include "detect-engine-hrud.h"
#include "detect-engine-dcepayload.h"
#include "detect-engine-file.h"
#include "stream-tcp.h"
#include "stream-tcp-private.h"
@ -73,7 +74,7 @@
* \note flow is not locked at this time
*/
static int DetectFileInspect(ThreadVars *tv, DetectEngineThreadCtx *det_ctx,
Flow *f, Signature *s, const SigMatchData *smd,
Flow *f, const Signature *s, const SigMatchData *smd,
uint8_t flags, FileContainer *ffc)
{
int r = 0;
@ -230,7 +231,7 @@ static int DetectFileInspect(ThreadVars *tv, DetectEngineThreadCtx *det_ctx,
*/
int DetectFileInspectHttp(ThreadVars *tv,
DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
Signature *s, const SigMatchData *smd,
const Signature *s, const SigMatchData *smd,
Flow *f, uint8_t flags, void *alstate, void *tx, uint64_t tx_id)
{
int r = DETECT_ENGINE_INSPECT_SIG_NO_MATCH;
@ -275,7 +276,7 @@ int DetectFileInspectHttp(ThreadVars *tv,
*/
int DetectFileInspectSmtp(ThreadVars *tv,
DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
Signature *s, const SigMatchData *smd,
const Signature *s, const SigMatchData *smd,
Flow *f, uint8_t flags, void *alstate, void *tx, uint64_t tx_id)
{
SCEnter();

@ -34,6 +34,7 @@
#include "detect-engine-state.h"
#include "detect-engine-content-inspection.h"
#include "detect-engine-prefilter.h"
#include "detect-engine-filedata-smtp.h"
#include "flow-util.h"
#include "util-debug.h"
@ -175,7 +176,7 @@ end:
int DetectEngineInspectSMTPFiledata(ThreadVars *tv,
DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
Signature *s, const SigMatchData *smd,
const Signature *s, const SigMatchData *smd,
Flow *f, uint8_t flags, void *alstate, void *tx, uint64_t tx_id)
{
SMTPState *smtp_state = (SMTPState *)alstate;

@ -43,6 +43,7 @@
#include "detect-engine-state.h"
#include "detect-engine-content-inspection.h"
#include "detect-engine-prefilter.h"
#include "detect-engine-hcbd.h"
#include "flow-util.h"
#include "util-debug.h"
@ -258,7 +259,7 @@ int PrefilterTxHttpRequestBodyRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx)
int DetectEngineInspectHttpClientBody(ThreadVars *tv,
DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
Signature *s, const SigMatchData *smd,
const Signature *s, const SigMatchData *smd,
Flow *f, uint8_t flags, void *alstate, void *tx, uint64_t tx_id)
{
HtpState *htp_state = (HtpState *)alstate;

@ -43,6 +43,7 @@
#include "detect-engine-state.h"
#include "detect-engine-content-inspection.h"
#include "detect-engine-prefilter.h"
#include "detect-engine-hsbd.h"
#include "flow-util.h"
#include "util-debug.h"
@ -263,7 +264,7 @@ int PrefilterTxHttpResponseBodyRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx)
int DetectEngineInspectHttpServerBody(ThreadVars *tv,
DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
Signature *s, const SigMatchData *smd,
const Signature *s, const SigMatchData *smd,
Flow *f, uint8_t flags, void *alstate, void *tx, uint64_t tx_id)
{
HtpState *htp_state = (HtpState *)alstate;

@ -66,7 +66,7 @@
*
* \retval IPOnlyCIDRItem address of the new instance
*/
static IPOnlyCIDRItem *IPOnlyCIDRItemNew()
static IPOnlyCIDRItem *IPOnlyCIDRItemNew(void)
{
SCEnter();
IPOnlyCIDRItem *item = NULL;
@ -103,7 +103,7 @@ static uint8_t IPOnlyCIDRItemCompare(IPOnlyCIDRItem *head,
* \retval 0 On successfully parsing the address string.
* \retval -1 On failure.
*/
static int IPOnlyCIDRItemParseSingle(IPOnlyCIDRItem *dd, char *str)
static int IPOnlyCIDRItemParseSingle(IPOnlyCIDRItem *dd, const char *str)
{
char buf[256] = "";
char *ip = NULL, *ip2 = NULL;
@ -590,7 +590,7 @@ static IPOnlyCIDRItem *IPOnlyCIDRListParse2(const DetectEngineCtx *de_ctx,
int depth = 0;
size_t size = strlen(s);
char address[8196] = "";
char *rule_var_address = NULL;
const char *rule_var_address = NULL;
char *temp_rule_var_address = NULL;
IPOnlyCIDRItem *head;
IPOnlyCIDRItem *subhead;
@ -635,16 +635,19 @@ static IPOnlyCIDRItem *IPOnlyCIDRListParse2(const DetectEngineCtx *de_ctx,
if (rule_var_address == NULL)
goto error;
temp_rule_var_address = rule_var_address;
if ((negate + n_set) % 2) {
temp_rule_var_address = SCMalloc(strlen(rule_var_address) + 3);
if (unlikely(temp_rule_var_address == NULL)) {
goto error;
}
snprintf(temp_rule_var_address, strlen(rule_var_address) + 3,
"[%s]", rule_var_address);
} else {
temp_rule_var_address = SCStrdup(rule_var_address);
if (unlikely(temp_rule_var_address == NULL)) {
goto error;
}
}
subhead = IPOnlyCIDRListParse2(de_ctx, temp_rule_var_address,
@ -654,8 +657,7 @@ static IPOnlyCIDRItem *IPOnlyCIDRListParse2(const DetectEngineCtx *de_ctx,
d_set = 0;
n_set = 0;
if (temp_rule_var_address != rule_var_address)
SCFree(temp_rule_var_address);
SCFree(temp_rule_var_address);
} else {
address[x - 1] = '\0';
@ -695,7 +697,6 @@ static IPOnlyCIDRItem *IPOnlyCIDRListParse2(const DetectEngineCtx *de_ctx,
if (rule_var_address == NULL)
goto error;
temp_rule_var_address = rule_var_address;
if ((negate + n_set) % 2) {
temp_rule_var_address = SCMalloc(strlen(rule_var_address) + 3);
if (unlikely(temp_rule_var_address == NULL)) {
@ -703,6 +704,11 @@ static IPOnlyCIDRItem *IPOnlyCIDRListParse2(const DetectEngineCtx *de_ctx,
}
snprintf(temp_rule_var_address, strlen(rule_var_address) + 3,
"[%s]", rule_var_address);
} else {
temp_rule_var_address = SCStrdup(rule_var_address);
if (unlikely(temp_rule_var_address == NULL)) {
goto error;
}
}
subhead = IPOnlyCIDRListParse2(de_ctx, temp_rule_var_address,
(negate + n_set) % 2);
@ -710,8 +716,7 @@ static IPOnlyCIDRItem *IPOnlyCIDRListParse2(const DetectEngineCtx *de_ctx,
d_set = 0;
if (temp_rule_var_address != rule_var_address)
SCFree(temp_rule_var_address);
SCFree(temp_rule_var_address);
} else {
subhead = IPOnlyCIDRItemNew();
if (subhead == NULL)
@ -1810,7 +1815,7 @@ static int IPOnlyTestSig05(void)
p[0] = UTHBuildPacket((uint8_t *)buf, buflen, IPPROTO_TCP);
char *sigs[numsigs];
const char *sigs[numsigs];
sigs[0]= "alert tcp 192.168.1.5 any -> any any (msg:\"Testing src ip (sid 1)\"; sid:1;)";
sigs[1]= "alert tcp any any -> 192.168.1.1 any (msg:\"Testing dst ip (sid 2)\"; sid:2;)";
sigs[2]= "alert tcp 192.168.1.5 any -> 192.168.1.1 any (msg:\"Testing src/dst ip (sid 3)\"; sid:3;)";
@ -1847,7 +1852,7 @@ static int IPOnlyTestSig06(void)
p[0] = UTHBuildPacketSrcDst((uint8_t *)buf, buflen, IPPROTO_TCP, "80.58.0.33", "195.235.113.3");
char *sigs[numsigs];
const char *sigs[numsigs];
sigs[0]= "alert tcp 192.168.1.5 any -> any any (msg:\"Testing src ip (sid 1)\"; sid:1;)";
sigs[1]= "alert tcp any any -> 192.168.1.1 any (msg:\"Testing dst ip (sid 2)\"; sid:2;)";
sigs[2]= "alert tcp 192.168.1.5 any -> 192.168.1.1 any (msg:\"Testing src/dst ip (sid 3)\"; sid:3;)";
@ -1926,7 +1931,7 @@ static int IPOnlyTestSig08(void)
p[0] = UTHBuildPacketSrcDst((uint8_t *)buf, buflen, IPPROTO_TCP,"192.168.1.1","192.168.1.5");
char *sigs[numsigs];
const char *sigs[numsigs];
sigs[0]= "alert tcp 192.168.1.5 any -> 192.168.0.0/16 any (msg:\"Testing src/dst ip (sid 1)\"; sid:1;)";
sigs[1]= "alert tcp [192.168.1.2,192.168.1.5,192.168.1.4] any -> 192.168.1.1 any (msg:\"Testing src/dst ip (sid 2)\"; sid:2;)";
sigs[2]= "alert tcp [192.168.1.0/24,!192.168.1.1] any -> 192.168.1.1 any (msg:\"Testing src/dst ip (sid 3)\"; sid:3;)";
@ -1963,7 +1968,7 @@ static int IPOnlyTestSig09(void)
p[0] = UTHBuildPacketIPV6SrcDst((uint8_t *)buf, buflen, IPPROTO_TCP, "3FFE:FFFF:7654:FEDA:1245:BA98:3210:4565", "3FFE:FFFF:7654:FEDA:1245:BA98:3210:4562");
char *sigs[numsigs];
const char *sigs[numsigs];
sigs[0]= "alert tcp 3FFE:FFFF:7654:FEDA:1245:BA98:3210:4565 any -> any any (msg:\"Testing src ip (sid 1)\"; sid:1;)";
sigs[1]= "alert tcp any any -> 3FFE:FFFF:7654:FEDA:1245:BA98:3210:4562 any (msg:\"Testing dst ip (sid 2)\"; sid:2;)";
sigs[2]= "alert tcp 3FFE:FFFF:7654:FEDA:1245:BA98:3210:4565 any -> 3FFE:FFFF:7654:FEDA:1245:BA98:3210:4562 any (msg:\"Testing src/dst ip (sid 3)\"; sid:3;)";
@ -2000,7 +2005,7 @@ static int IPOnlyTestSig10(void)
p[0] = UTHBuildPacketIPV6SrcDst((uint8_t *)buf, buflen, IPPROTO_TCP, "3FFE:FFFF:7654:FEDA:1245:BA98:3210:4562", "3FFE:FFFF:7654:FEDA:1245:BA98:3210:4565");
char *sigs[numsigs];
const char *sigs[numsigs];
sigs[0]= "alert tcp 3FFE:FFFF:7654:FEDA:1245:BA98:3210:4565 any -> any any (msg:\"Testing src ip (sid 1)\"; sid:1;)";
sigs[1]= "alert tcp any any -> 3FFE:FFFF:7654:FEDA:1245:BA98:3210:4562 any (msg:\"Testing dst ip (sid 2)\"; sid:2;)";
sigs[2]= "alert tcp 3FFE:FFFF:7654:FEDA:1245:BA98:3210:4565 any -> 3FFE:FFFF:7654:FEDA:1245:BA98:3210:4562 any (msg:\"Testing src/dst ip (sid 3)\"; sid:3;)";
@ -2081,7 +2086,7 @@ static int IPOnlyTestSig12(void)
p[0] = UTHBuildPacketIPV6SrcDst((uint8_t *)buf, buflen, IPPROTO_TCP,"3FBE:FFFF:7654:FEDA:1245:BA98:3210:4562","3FBE:FFFF:7654:FEDA:1245:BA98:3210:4565");
p[1] = UTHBuildPacketSrcDst((uint8_t *)buf, buflen, IPPROTO_TCP,"195.85.1.1","80.198.1.5");
char *sigs[numsigs];
const char *sigs[numsigs];
sigs[0]= "alert tcp 3FFE:FFFF:7654:FEDA:1245:BA98:3210:4565,192.168.1.1 any -> 3FFE:FFFF:7654:FEDA:0:0:0:0/64,192.168.1.5 any (msg:\"Testing src/dst ip (sid 1)\"; sid:1;)";
sigs[1]= "alert tcp [192.168.1.1,3FFE:FFFF:7654:FEDA:1245:BA98:3210:4565,192.168.1.4,192.168.1.5,!192.168.1.0/24] any -> [3FFE:FFFF:7654:FEDA:1245:BA98:3210:4562,192.168.1.0/24] any (msg:\"Testing src/dst ip (sid 2)\"; sid:2;)";
sigs[2]= "alert tcp [3FFE:FFFF:7654:FEDA:0:0:0:0/64,!3FFE:FFFF:7654:FEDA:1245:BA98:3210:4562,192.168.1.1] any -> [3FFE:FFFF:7654:FEDA:1245:BA98:3210:4562,192.168.1.5] any (msg:\"Testing src/dst ip (sid 3)\"; sid:3;)";
@ -2158,7 +2163,7 @@ static int IPOnlyTestSig15(void)
p[0]->flags |= PKT_HAS_FLOW;
p[0]->flowflags |= FLOW_PKT_TOSERVER;
char *sigs[numsigs];
const char *sigs[numsigs];
sigs[0]= "alert tcp 192.168.1.5 any -> any any (msg:\"Testing src ip (sid 1)\"; "
"flowbits:set,one; sid:1;)";
sigs[1]= "alert tcp any any -> 192.168.1.1 any (msg:\"Testing dst ip (sid 2)\"; "
@ -2202,7 +2207,7 @@ static int IPOnlyTestSig16(void)
p[0] = UTHBuildPacketSrcDst((uint8_t *)buf, buflen, IPPROTO_TCP, "100.100.0.0", "50.0.0.0");
char *sigs[numsigs];
const char *sigs[numsigs];
sigs[0]= "alert tcp !100.100.0.1 any -> any any (msg:\"Testing src ip (sid 1)\"; sid:1;)";
sigs[1]= "alert tcp any any -> !50.0.0.1 any (msg:\"Testing dst ip (sid 2)\"; sid:2;)";
@ -2233,7 +2238,7 @@ static int IPOnlyTestSig17(void)
p[0] = UTHBuildPacketSrcDst((uint8_t *)buf, buflen, IPPROTO_ICMP, "100.100.0.0", "50.0.0.0");
char *sigs[numsigs];
const char *sigs[numsigs];
sigs[0]= "alert ip 100.100.0.0 80 -> any any (msg:\"Testing src ip (sid 1)\"; sid:1;)";
sigs[1]= "alert ip any any -> 50.0.0.0 123 (msg:\"Testing dst ip (sid 2)\"; sid:2;)";

@ -192,7 +192,7 @@ typedef struct DetectLoaderThreadData_ {
uint32_t instance;
} DetectLoaderThreadData;
static TmEcode DetectLoaderThreadInit(ThreadVars *t, void *initdata, void **data)
static TmEcode DetectLoaderThreadInit(ThreadVars *t, const void *initdata, void **data)
{
DetectLoaderThreadData *ftd = SCCalloc(1, sizeof(DetectLoaderThreadData));
if (ftd == NULL)
@ -263,7 +263,7 @@ static TmEcode DetectLoader(ThreadVars *th_v, void *thread_data)
}
/** \brief spawn the detect loader manager thread */
void DetectLoaderThreadSpawn()
void DetectLoaderThreadSpawn(void)
{
int i;
for (i = 0; i < num_loaders; i++) {

@ -50,8 +50,8 @@ int DetectLoaderQueueTask(int loader_id, LoaderFunc Func, void *func_ctx);
int DetectLoadersSync(void);
void DetectLoadersInit(void);
void TmThreadContinueDetectLoaderThreads();
void DetectLoaderThreadSpawn();
void TmThreadContinueDetectLoaderThreads(void);
void DetectLoaderThreadSpawn(void);
void TmModuleDetectLoaderRegister (void);
#endif /* __DETECT_ENGINE_LOADER_H__ */

@ -349,7 +349,7 @@ int SignatureHasStreamContent(const Signature *s)
*/
uint16_t PatternMatchDefaultMatcher(void)
{
char *mpm_algo;
const char *mpm_algo;
uint16_t mpm_algo_val = mpm_default_matcher;
/* Get the mpm algo defined in config file by the user */
@ -862,7 +862,7 @@ void MpmStoreReportStats(const DetectEngineCtx *de_ctx)
if (appstats[x] == 0)
continue;
const char *name = de_ctx->app_mpms[x].reg->name;
char *direction = de_ctx->app_mpms[x].reg->direction == SIG_FLAG_TOSERVER ? "toserver" : "toclient";
const char *direction = de_ctx->app_mpms[x].reg->direction == SIG_FLAG_TOSERVER ? "toserver" : "toclient";
SCLogPerf("AppLayer MPM \"%s %s\": %u", direction, name, appstats[x]);
}
}
@ -884,7 +884,7 @@ void MpmStoreFree(DetectEngineCtx *de_ctx)
return;
}
void MpmStoreSetup(const DetectEngineCtx *de_ctx, MpmStore *ms)
static void MpmStoreSetup(const DetectEngineCtx *de_ctx, MpmStore *ms)
{
const Signature *s = NULL;
uint32_t sig;

@ -57,8 +57,6 @@ void DetectEngineThreadCtxInfo(ThreadVars *, DetectEngineThreadCtx *);
TmEcode DetectEngineThreadCtxInit(ThreadVars *, void *, void **);
TmEcode DetectEngineThreadCtxDeinit(ThreadVars *, void *);
void DbgPrintSearchStats();
int SignatureHasPacketContent(const Signature *);
int SignatureHasStreamContent(const Signature *);

@ -34,6 +34,7 @@
#include "detect-engine-content-inspection.h"
#include "detect-engine-prefilter.h"
#include "detect-engine-state.h"
#include "detect-engine-payload.h"
#include "stream.h"
#include "stream-tcp.h"
@ -150,7 +151,7 @@ int PrefilterPktPayloadRegister(SigGroupHead *sgh, MpmCtx *mpm_ctx)
* \retval 1 match
*/
int DetectEngineInspectPacketPayload(DetectEngineCtx *de_ctx,
DetectEngineThreadCtx *det_ctx, Signature *s, Flow *f, Packet *p)
DetectEngineThreadCtx *det_ctx, const Signature *s, Flow *f, Packet *p)
{
SCEnter();
int r = 0;

@ -56,7 +56,7 @@
static int DetectPortCutNot(DetectPort *, DetectPort **);
static int DetectPortCut(DetectEngineCtx *, DetectPort *, DetectPort *,
DetectPort **);
DetectPort *PortParse(char *str);
DetectPort *PortParse(const char *str);
int DetectPortIsValidRange(char *);
/**
@ -65,7 +65,7 @@ int DetectPortIsValidRange(char *);
* \retval sgh Pointer to the newly created DetectPort on success; or NULL in
* case of error.
*/
DetectPort *DetectPortInit(void)
static DetectPort *DetectPortInit(void)
{
DetectPort *dp = SCMalloc(sizeof(DetectPort));
if (unlikely(dp == NULL))
@ -94,28 +94,6 @@ void DetectPortFree(DetectPort *dp)
SCFree(dp);
}
/**
* \brief Used to see if the exact same portrange exists in the list
*
* \param head Pointer to the DetectPort list head
* \param dp DetectPort to search in the DetectPort list
*
* \retval returns a ptr to the match, or NULL if no match
*/
DetectPort *DetectPortLookup(DetectPort *head, DetectPort *dp)
{
DetectPort *cur;
if (head != NULL) {
for (cur = head; cur != NULL; cur = cur->next) {
if (DetectPortCmp(cur, dp) == PORT_EQ)
return cur;
}
}
return NULL;
}
/**
* \brief Helper function used to print the list of ports
* present in this DetectPort list.
@ -158,50 +136,6 @@ void DetectPortCleanupList (DetectPort *head)
}
}
/**
* \brief Do a sorted insert, where the top of the list should be the biggest
* port range.
*
* \todo XXX current sorting only works for overlapping ranges
*
* \param head Pointer to the DetectPort list head
* \param dp Pointer to DetectPort to search in the DetectPort list
* \retval 0 if dp is added correctly
*/
int DetectPortAdd(DetectPort **head, DetectPort *dp)
{
DetectPort *cur, *prev_cur = NULL;
//SCLogDebug("DetectPortAdd: adding "); DetectPortPrint(ag); SCLogDebug("");
if (*head != NULL) {
for (cur = *head; cur != NULL; cur = cur->next) {
prev_cur = cur;
int r = DetectPortCmp(dp,cur);
if (r == PORT_EB) {
/* insert here */
dp->prev = cur->prev;
dp->next = cur;
cur->prev = dp;
if (*head == cur) {
*head = dp;
} else {
dp->prev->next = dp;
}
return 0;
}
}
dp->prev = prev_cur;
if (prev_cur != NULL)
prev_cur->next = dp;
} else {
*head = dp;
}
return 0;
}
/**
* \brief Copy and insert the new DetectPort, with a copy list of sigs
*
@ -762,7 +696,7 @@ error:
* \retval 1 if port is in the range (it match)
* \retval 0 if port is not in the range
* */
int DetectPortMatch(DetectPort *dp, uint16_t port)
static int DetectPortMatch(DetectPort *dp, uint16_t port)
{
if (port >= dp->port &&
port <= dp->port2) {
@ -871,7 +805,7 @@ static int DetectPortParseInsert(DetectPort **head, DetectPort *new)
* \retval 0 on success
* \retval -1 on error
*/
static int DetectPortParseInsertString(DetectPort **head, char *s)
static int DetectPortParseInsertString(DetectPort **head, const char *s)
{
DetectPort *ad = NULL, *ad_any = NULL;
int r = 0;
@ -960,7 +894,8 @@ error:
*/
static int DetectPortParseDo(const DetectEngineCtx *de_ctx,
DetectPort **head, DetectPort **nhead,
char *s, int negate, ResolvedVariablesList *var_list)
const char *s, int negate,
ResolvedVariablesList *var_list)
{
size_t u = 0;
size_t x = 0;
@ -969,7 +904,7 @@ static int DetectPortParseDo(const DetectEngineCtx *de_ctx,
int depth = 0;
size_t size = strlen(s);
char address[1024] = "";
char *rule_var_port = NULL;
const char *rule_var_port = NULL;
int r = 0;
SCLogDebug("head %p, *head %p, negate %d", head, *head, negate);
@ -1028,15 +963,18 @@ static int DetectPortParseDo(const DetectEngineCtx *de_ctx,
"\"!$HTTP_PORTS\" instead of !$HTTP_PORTS. See issue #295.", s);
goto error;
}
temp_rule_var_port = rule_var_port;
if (negate == 1 || n_set == 1) {
alloc_rule_var_port = SCMalloc(strlen(rule_var_port) + 3);
if (unlikely(alloc_rule_var_port == NULL))
goto error;
snprintf(alloc_rule_var_port, strlen(rule_var_port) + 3,
"[%s]", rule_var_port);
temp_rule_var_port = alloc_rule_var_port;
} else {
alloc_rule_var_port = SCStrdup(rule_var_port);
if (unlikely(alloc_rule_var_port == NULL))
goto error;
}
temp_rule_var_port = alloc_rule_var_port;
r = DetectPortParseDo(de_ctx, head, nhead, temp_rule_var_port,
(negate + n_set) % 2, var_list);//negate? negate: n_set);
if (r == -1)
@ -1044,8 +982,7 @@ static int DetectPortParseDo(const DetectEngineCtx *de_ctx,
d_set = 0;
n_set = 0;
if (alloc_rule_var_port != NULL)
SCFree(alloc_rule_var_port);
SCFree(alloc_rule_var_port);
} else {
address[x - 1] = '\0';
SCLogDebug("Parsed port from DetectPortParseDo - %s", address);
@ -1095,23 +1032,25 @@ static int DetectPortParseDo(const DetectEngineCtx *de_ctx,
"\"!$HTTP_PORTS\" instead of !$HTTP_PORTS. See issue #295.", s);
goto error;
}
temp_rule_var_port = rule_var_port;
if ((negate + n_set) % 2) {
alloc_rule_var_port = SCMalloc(strlen(rule_var_port) + 3);
if (unlikely(alloc_rule_var_port == NULL))
goto error;
snprintf(alloc_rule_var_port, strlen(rule_var_port) + 3,
"[%s]", rule_var_port);
temp_rule_var_port = alloc_rule_var_port;
} else {
alloc_rule_var_port = SCStrdup(rule_var_port);
if (unlikely(alloc_rule_var_port == NULL))
goto error;
}
temp_rule_var_port = alloc_rule_var_port;
r = DetectPortParseDo(de_ctx, head, nhead, temp_rule_var_port,
(negate + n_set) % 2, var_list);
if (r == -1)
goto error;
d_set = 0;
if (alloc_rule_var_port != NULL)
SCFree(alloc_rule_var_port);
SCFree(alloc_rule_var_port);
} else {
if (!((negate + n_set) % 2)) {
r = DetectPortParseInsertString(head,address);
@ -1149,7 +1088,7 @@ error:
* \retval 0 no
* \retval 1 yes
*/
int DetectPortIsCompletePortSpace(DetectPort *p)
static int DetectPortIsCompletePortSpace(DetectPort *p)
{
uint16_t next_port = 0;
@ -1189,7 +1128,7 @@ int DetectPortIsCompletePortSpace(DetectPort *p)
* \retval 0 on success
* \retval -1 on error
*/
int DetectPortParseMergeNotPorts(DetectPort **head, DetectPort **nhead)
static int DetectPortParseMergeNotPorts(DetectPort **head, DetectPort **nhead)
{
DetectPort *ad = NULL;
DetectPort *ag, *ag2;
@ -1352,7 +1291,7 @@ int DetectPortTestConfVars(void)
* \retval -1 on error
*/
int DetectPortParse(const DetectEngineCtx *de_ctx,
DetectPort **head, char *str)
DetectPort **head, const char *str)
{
int r;
@ -1388,7 +1327,7 @@ error:
* \retval DetectPort pointer of the parse string on success
* \retval NULL on error
*/
DetectPort *PortParse(char *str)
DetectPort *PortParse(const char *str)
{
char *port2 = NULL;
DetectPort *dp = NULL;
@ -1607,11 +1546,55 @@ void DetectPortHashFree(DetectEngineCtx *de_ctx)
/*---------------------- Unittests -------------------------*/
#ifdef UNITTESTS
/**
* \brief Do a sorted insert, where the top of the list should be the biggest
* port range.
*
* \todo XXX current sorting only works for overlapping ranges
*
* \param head Pointer to the DetectPort list head
* \param dp Pointer to DetectPort to search in the DetectPort list
* \retval 0 if dp is added correctly
*/
static int PortTestDetectPortAdd(DetectPort **head, DetectPort *dp)
{
DetectPort *cur, *prev_cur = NULL;
//SCLogDebug("DetectPortAdd: adding "); DetectPortPrint(ag); SCLogDebug("");
if (*head != NULL) {
for (cur = *head; cur != NULL; cur = cur->next) {
prev_cur = cur;
int r = DetectPortCmp(dp,cur);
if (r == PORT_EB) {
/* insert here */
dp->prev = cur->prev;
dp->next = cur;
cur->prev = dp;
if (*head == cur) {
*head = dp;
} else {
dp->prev->next = dp;
}
return 0;
}
}
dp->prev = prev_cur;
if (prev_cur != NULL)
prev_cur->next = dp;
} else {
*head = dp;
}
return 0;
}
/**
* \test Check if a DetectPort is properly allocated
*/
int PortTestParse01 (void)
static int PortTestParse01 (void)
{
DetectPort *dd = NULL;
@ -1627,7 +1610,7 @@ int PortTestParse01 (void)
/**
* \test Check if two ports are properly allocated in the DetectPort group
*/
int PortTestParse02 (void)
static int PortTestParse02 (void)
{
DetectPort *dd = NULL;
int result = 0;
@ -1649,7 +1632,7 @@ int PortTestParse02 (void)
/**
* \test Check if two port ranges are properly allocated in the DetectPort group
*/
int PortTestParse03 (void)
static int PortTestParse03 (void)
{
DetectPort *dd = NULL;
int result = 0;
@ -1672,7 +1655,7 @@ int PortTestParse03 (void)
/**
* \test Check if a negated port range is properly allocated in the DetectPort
*/
int PortTestParse04 (void)
static int PortTestParse04 (void)
{
DetectPort *dd = NULL;
@ -1689,7 +1672,7 @@ int PortTestParse04 (void)
* \test Check if a negated port range is properly fragmented in the allowed
* real groups, ex !80:81 should allow 0:79 and 82:65535
*/
int PortTestParse05 (void)
static int PortTestParse05 (void)
{
DetectPort *dd = NULL;
int result = 0;
@ -1716,7 +1699,7 @@ end:
/**
* \test Check if we copy a DetectPort correctly
*/
int PortTestParse06 (void)
static int PortTestParse06 (void)
{
DetectPort *dd = NULL, *copy = NULL;
int result = 0;
@ -1770,7 +1753,7 @@ end:
* \test Check if a negated port range is properly fragmented in the allowed
* real groups
*/
int PortTestParse07 (void)
static int PortTestParse07 (void)
{
DetectPort *dd = NULL;
int result = 0;
@ -1797,7 +1780,7 @@ end:
/**
* \test Check if we dont allow invalid port range specification
*/
int PortTestParse08 (void)
static int PortTestParse08 (void)
{
DetectPort *dd = NULL;
int result = 0;
@ -1815,7 +1798,7 @@ end:
/**
* \test Check if we autocomplete correctly an open range
*/
int PortTestParse09 (void)
static int PortTestParse09 (void)
{
DetectPort *dd = NULL;
int result = 0;
@ -1839,7 +1822,7 @@ end:
/**
* \test Test we don't allow a port that is too big
*/
int PortTestParse10 (void)
static int PortTestParse10 (void)
{
DetectPort *dd = NULL;
int result = 0;
@ -1859,7 +1842,7 @@ end:
/**
* \test Test second port of range being too big
*/
int PortTestParse11 (void)
static int PortTestParse11 (void)
{
DetectPort *dd = NULL;
int result = 0;
@ -1879,7 +1862,7 @@ end:
/**
* \test Test second port of range being just right
*/
int PortTestParse12 (void)
static int PortTestParse12 (void)
{
DetectPort *dd = NULL;
int result = 0;
@ -1899,7 +1882,7 @@ end:
/**
* \test Test first port of range being too big
*/
int PortTestParse13 (void)
static int PortTestParse13 (void)
{
DetectPort *dd = NULL;
int result = 0;
@ -1919,7 +1902,7 @@ end:
/**
* \test Test merging port groups
*/
int PortTestParse14 (void)
static int PortTestParse14 (void)
{
DetectPort *dd = NULL;
int result = 0;
@ -1946,7 +1929,7 @@ end:
/**
* \test Test merging negated port groups
*/
int PortTestParse15 (void)
static int PortTestParse15 (void)
{
DetectPort *dd = NULL;
int result = 0;
@ -1970,7 +1953,7 @@ end:
/**
* \test Test parse, copy and cmp functions
*/
int PortTestParse16 (void)
static int PortTestParse16 (void)
{
DetectPort *dd = NULL, *copy = NULL;
int result = 0;
@ -2025,7 +2008,7 @@ end:
/**
* \test Test general functions
*/
int PortTestFunctions01(void)
static int PortTestFunctions01(void)
{
DetectPort *head = NULL;
DetectPort *dp1= NULL;
@ -2053,7 +2036,7 @@ int PortTestFunctions01(void)
goto end;
/* Add */
r = DetectPortAdd(&head, dp1);
r = PortTestDetectPortAdd(&head, dp1);
if (r != 0 || head->next == NULL)
goto end;
if (!(head->port == 101))
@ -2087,7 +2070,7 @@ end:
/**
* \test Test general functions
*/
int PortTestFunctions02(void)
static int PortTestFunctions02(void)
{
DetectPort *head = NULL;
DetectPort *dp1= NULL;
@ -2137,7 +2120,7 @@ end:
/**
* \test Test general functions
*/
int PortTestFunctions03(void)
static int PortTestFunctions03(void)
{
DetectPort *dp1= NULL;
DetectPort *dp2= NULL;
@ -2203,7 +2186,7 @@ end:
/**
* \test Test general functions
*/
int PortTestFunctions04(void)
static int PortTestFunctions04(void)
{
DetectPort *dp1= NULL;
DetectPort *dp2= NULL;
@ -2431,7 +2414,7 @@ static int PortTestFunctions07(void)
* \retval return 1 if match
* \retval return 0 if not
*/
int PortTestMatchReal(uint8_t *raw_eth_pkt, uint16_t pktsize, char *sig,
static int PortTestMatchReal(uint8_t *raw_eth_pkt, uint16_t pktsize, const char *sig,
uint32_t sid)
{
int result = 0;
@ -2446,7 +2429,7 @@ int PortTestMatchReal(uint8_t *raw_eth_pkt, uint16_t pktsize, char *sig,
/**
* \brief Wrapper for PortTestMatchReal
*/
int PortTestMatchRealWrp(char *sig, uint32_t sid)
static int PortTestMatchRealWrp(const char *sig, uint32_t sid)
{
/* Real HTTP packeth doing a GET method
* tcp.sport=47370 tcp.dport=80
@ -2517,19 +2500,19 @@ int PortTestMatchRealWrp(char *sig, uint32_t sid)
/**
* \test Check if we match a dest port
*/
int PortTestMatchReal01()
static int PortTestMatchReal01(void)
{
/* tcp.sport=47370 tcp.dport=80 */
char *sig = "alert tcp any any -> any 80 (msg:\"Nothing..\"; content:\"GET\"; sid:1;)";
const char *sig = "alert tcp any any -> any 80 (msg:\"Nothing..\"; content:\"GET\"; sid:1;)";
return PortTestMatchRealWrp(sig, 1);
}
/**
* \test Check if we match a source port
*/
int PortTestMatchReal02()
static int PortTestMatchReal02(void)
{
char *sig = "alert tcp any 47370 -> any any (msg:\"Nothing..\";"
const char *sig = "alert tcp any 47370 -> any any (msg:\"Nothing..\";"
" content:\"GET\"; sid:1;)";
return PortTestMatchRealWrp(sig, 1);
}
@ -2537,9 +2520,9 @@ int PortTestMatchReal02()
/**
* \test Check if we match both of them
*/
int PortTestMatchReal03()
static int PortTestMatchReal03(void)
{
char *sig = "alert tcp any 47370 -> any 80 (msg:\"Nothing..\";"
const char *sig = "alert tcp any 47370 -> any 80 (msg:\"Nothing..\";"
" content:\"GET\"; sid:1;)";
return PortTestMatchRealWrp(sig, 1);
}
@ -2547,9 +2530,9 @@ int PortTestMatchReal03()
/**
* \test Check if we negate dest ports correctly
*/
int PortTestMatchReal04()
static int PortTestMatchReal04(void)
{
char *sig = "alert tcp any any -> any !80 (msg:\"Nothing..\";"
const char *sig = "alert tcp any any -> any !80 (msg:\"Nothing..\";"
" content:\"GET\"; sid:1;)";
return (PortTestMatchRealWrp(sig, 1) == 0)? 1 : 0;
}
@ -2557,9 +2540,9 @@ int PortTestMatchReal04()
/**
* \test Check if we negate source ports correctly
*/
int PortTestMatchReal05()
static int PortTestMatchReal05(void)
{
char *sig = "alert tcp any !47370 -> any any (msg:\"Nothing..\";"
const char *sig = "alert tcp any !47370 -> any any (msg:\"Nothing..\";"
" content:\"GET\"; sid:1;)";
return (PortTestMatchRealWrp(sig, 1) == 0)? 1 : 0;
}
@ -2567,9 +2550,9 @@ int PortTestMatchReal05()
/**
* \test Check if we negate both ports correctly
*/
int PortTestMatchReal06()
static int PortTestMatchReal06(void)
{
char *sig = "alert tcp any !47370 -> any !80 (msg:\"Nothing..\";"
const char *sig = "alert tcp any !47370 -> any !80 (msg:\"Nothing..\";"
" content:\"GET\"; sid:1;)";
return (PortTestMatchRealWrp(sig, 1) == 0)? 1 : 0;
}
@ -2577,9 +2560,9 @@ int PortTestMatchReal06()
/**
* \test Check if we match a dest port range
*/
int PortTestMatchReal07()
static int PortTestMatchReal07(void)
{
char *sig = "alert tcp any any -> any 70:100 (msg:\"Nothing..\";"
const char *sig = "alert tcp any any -> any 70:100 (msg:\"Nothing..\";"
" content:\"GET\"; sid:1;)";
return PortTestMatchRealWrp(sig, 1);
}
@ -2587,9 +2570,9 @@ int PortTestMatchReal07()
/**
* \test Check if we match a source port range
*/
int PortTestMatchReal08()
static int PortTestMatchReal08(void)
{
char *sig = "alert tcp any 47000:50000 -> any any (msg:\"Nothing..\";"
const char *sig = "alert tcp any 47000:50000 -> any any (msg:\"Nothing..\";"
" content:\"GET\"; sid:1;)";
return PortTestMatchRealWrp(sig, 1);
}
@ -2597,9 +2580,9 @@ int PortTestMatchReal08()
/**
* \test Check if we match both port ranges
*/
int PortTestMatchReal09()
static int PortTestMatchReal09(void)
{
char *sig = "alert tcp any 47000:50000 -> any 70:100 (msg:\"Nothing..\";"
const char *sig = "alert tcp any 47000:50000 -> any 70:100 (msg:\"Nothing..\";"
" content:\"GET\"; sid:1;)";
return PortTestMatchRealWrp(sig, 1);
}
@ -2607,9 +2590,9 @@ int PortTestMatchReal09()
/**
* \test Check if we negate a dest port range
*/
int PortTestMatchReal10()
static int PortTestMatchReal10(void)
{
char *sig = "alert tcp any any -> any !70:100 (msg:\"Nothing..\";"
const char *sig = "alert tcp any any -> any !70:100 (msg:\"Nothing..\";"
" content:\"GET\"; sid:1;)";
return (PortTestMatchRealWrp(sig, 1) == 0)? 1 : 0;
}
@ -2617,9 +2600,9 @@ int PortTestMatchReal10()
/**
* \test Check if we negate a source port range
*/
int PortTestMatchReal11()
static int PortTestMatchReal11(void)
{
char *sig = "alert tcp any !47000:50000 -> any any (msg:\"Nothing..\";"
const char *sig = "alert tcp any !47000:50000 -> any any (msg:\"Nothing..\";"
" content:\"GET\"; sid:1;)";
return (PortTestMatchRealWrp(sig, 1) == 0)? 1 : 0;
}
@ -2627,9 +2610,9 @@ int PortTestMatchReal11()
/**
* \test Check if we negate both port ranges
*/
int PortTestMatchReal12()
static int PortTestMatchReal12(void)
{
char *sig = "alert tcp any !47000:50000 -> any !70:100 (msg:\"Nothing..\";"
const char *sig = "alert tcp any !47000:50000 -> any !70:100 (msg:\"Nothing..\";"
" content:\"GET\"; sid:1;)";
return (PortTestMatchRealWrp(sig, 1) == 0)? 1 : 0;
}
@ -2637,9 +2620,9 @@ int PortTestMatchReal12()
/**
* \test Check if we autocomplete ranges correctly
*/
int PortTestMatchReal13()
static int PortTestMatchReal13(void)
{
char *sig = "alert tcp any 47000:50000 -> any !81: (msg:\"Nothing..\";"
const char *sig = "alert tcp any 47000:50000 -> any !81: (msg:\"Nothing..\";"
" content:\"GET\"; sid:1;)";
return PortTestMatchRealWrp(sig, 1);
}
@ -2647,9 +2630,9 @@ int PortTestMatchReal13()
/**
* \test Check if we autocomplete ranges correctly
*/
int PortTestMatchReal14()
static int PortTestMatchReal14(void)
{
char *sig = "alert tcp any !48000:50000 -> any :100 (msg:\"Nothing..\";"
const char *sig = "alert tcp any !48000:50000 -> any :100 (msg:\"Nothing..\";"
" content:\"GET\"; sid:1;)";
return PortTestMatchRealWrp(sig, 1);
}
@ -2657,9 +2640,9 @@ int PortTestMatchReal14()
/**
* \test Check if we autocomplete ranges correctly
*/
int PortTestMatchReal15()
static int PortTestMatchReal15(void)
{
char *sig = "alert tcp any :50000 -> any 81:100 (msg:\"Nothing..\";"
const char *sig = "alert tcp any :50000 -> any 81:100 (msg:\"Nothing..\";"
" content:\"GET\"; sid:1;)";
return (PortTestMatchRealWrp(sig, 1) == 0)? 1 : 0;
}
@ -2667,9 +2650,9 @@ int PortTestMatchReal15()
/**
* \test Check if we separate ranges correctly
*/
int PortTestMatchReal16()
static int PortTestMatchReal16(void)
{
char *sig = "alert tcp any 100: -> any ![0:79,81:65535] (msg:\"Nothing..\";"
const char *sig = "alert tcp any 100: -> any ![0:79,81:65535] (msg:\"Nothing..\";"
" content:\"GET\"; sid:1;)";
return PortTestMatchRealWrp(sig, 1);
}
@ -2677,9 +2660,9 @@ int PortTestMatchReal16()
/**
* \test Check if we separate ranges correctly
*/
int PortTestMatchReal17()
static int PortTestMatchReal17(void)
{
char *sig = "alert tcp any ![0:39999,48000:50000] -> any ![0:80,82:65535] "
const char *sig = "alert tcp any ![0:39999,48000:50000] -> any ![0:80,82:65535] "
"(msg:\"Nothing..\"; content:\"GET\"; sid:1;)";
return (PortTestMatchRealWrp(sig, 1) == 0)? 1 : 0;
}
@ -2687,9 +2670,9 @@ int PortTestMatchReal17()
/**
* \test Check if we separate ranges correctly
*/
int PortTestMatchReal18()
static int PortTestMatchReal18(void)
{
char *sig = "alert tcp any ![0:39999,48000:50000] -> any 80 (msg:\"Nothing"
const char *sig = "alert tcp any ![0:39999,48000:50000] -> any 80 (msg:\"Nothing"
" at all\"; content:\"GET\"; sid:1;)";
return PortTestMatchRealWrp(sig, 1);
}
@ -2697,9 +2680,9 @@ int PortTestMatchReal18()
/**
* \test Check if we separate ranges correctly
*/
int PortTestMatchReal19()
static int PortTestMatchReal19(void)
{
char *sig = "alert tcp any any -> any 80 (msg:\"Nothing..\";"
const char *sig = "alert tcp any any -> any 80 (msg:\"Nothing..\";"
" content:\"GET\"; sid:1;)";
return PortTestMatchRealWrp(sig, 1);
}

@ -25,7 +25,7 @@
#define __DETECT_PORT_H__
/* prototypes */
int DetectPortParse(const DetectEngineCtx *, DetectPort **head, char *str);
int DetectPortParse(const DetectEngineCtx *, DetectPort **head, const char *str);
DetectPort *DetectPortCopy(DetectEngineCtx *, DetectPort *);
DetectPort *DetectPortCopySingle(DetectEngineCtx *, DetectPort *);

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save