Go to the documentation of this file.
33 #include <fuzz_pcap.h>
37 static int initialized = 0;
47 static void SigGenerateAware(
const uint8_t *data,
size_t size,
char *r,
size_t *
len)
49 *
len = snprintf(r, 511,
"alert ip any any -> any any (");
50 for (
size_t i = 0; i + 1 < size && *
len < 511; i++) {
52 size_t off = (data[i] & 0x7F + ((data[i + 1] & 0xF) << 7)) % (
DETECT_TBLSIZE);
66 *
len += snprintf(r + *
len, 511 - *
len,
")");
77 struct pcap_pkthdr header;
83 if (initialized == 0) {
85 setenv(
"SC_LOG_OP_IFACE",
"file", 0);
86 setenv(
"SC_LOG_FILE",
"/dev/null", 0);
99 remove(
"/tmp/fuzz.rules");
109 memset(&
tv, 0,
sizeof(
tv));
125 if (size < 1 + FPC0_HEADER_LEN) {
128 for (pos = 0; pos < size - FPC0_HEADER_LEN; pos++) {
129 if (data[pos] == 0) {
134 if (FPC_init(&pkts, data + pos + 1, size - pos - 1) < 0) {
141 SigGenerateAware(data, pos + 1, sigaware, &
len);
159 r = FPC_next(&pkts, &header, &pkt);
161 if (r <= 0 || header.ts.tv_sec >= INT_MAX - 3600) {
175 while (extra_p != NULL) {
181 while (extra_p != NULL) {
186 r = FPC_next(&pkts, &header, &pkt);
187 if (r <= 0 || header.ts.tv_sec >= INT_MAX - 3600) {
struct FlowQueue_ * flow_queue
DetectEngineThreadCtx * DetectEngineThreadCtxInitForReload(ThreadVars *tv, DetectEngineCtx *new_de_ctx, int mt)
int SCRunmodeGet(void)
Get the current run mode.
SigTableElmt * sigmatch_table
void PacketFreeOrRelease(Packet *p)
Return a packet to where it was allocated.
SC_ATOMIC_EXTERN(unsigned int, engine_stage)
int PacketCopyData(Packet *p, const uint8_t *pktdata, uint32_t pktlen)
Copy data to Packet payload and set packet length.
#define SC_ATOMIC_SET(name, val)
Set the value for the atomic variable.
void PacketRecycle(Packet *p)
void SCRunmodeSet(int run_mode)
Set the current run mode.
main detection engine ctx
DetectEngineCtx * DetectEngineGetCurrent(void)
int StatsSetupPrivate(ThreadVars *tv)
void GlobalsInitPreConfig(void)
void PacketPoolInit(void)
void DecodeRegisterPerfCounters(DecodeThreadVars *dtv, ThreadVars *tv)
const char * configNoChecksum
void PreRunPostPrivsDropInit(const int runmode)
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
Packet * PacketDequeueNoLock(PacketQueueNoLock *qnl)
Per thread variable structure.
#define SCTIME_FROM_TIMEVAL(tv)
TmEcode(* Func)(ThreadVars *, Packet *, void *)
void PacketFree(Packet *p)
Return a malloced packet.
FlowQueue * FlowQueueNew(void)
int TestHelperBufferToFile(const char *name, const uint8_t *data, size_t size)
writes the contents of a buffer into a file
int ConfYamlLoadString(const char *string, size_t len)
Load configuration from a YAML string.
int PostConfLoadedSetup(SCInstance *suri)
void PostConfLoadedDetectSetup(SCInstance *suri)
TmModule tmm_modules[TMM_SIZE]
void setenv(const char *name, const char *value, int overwrite)
uint32_t max_pending_packets
void * FlowWorkerGetDetectCtxPtr(void *flow_worker)
TmEcode DetectEngineThreadCtxDeinit(ThreadVars *tv, void *data)
TmEcode(* ThreadInit)(ThreadVars *, const void *, void **)
#define SIGMATCH_OPTIONAL_OPT
TmEcode ConfigSetLogDirectory(const char *name)
Packet * PacketGetFromAlloc(void)
Get a malloced packet.
Structure to hold thread specific data for all decode modules.
DecodeThreadVars * DecodeThreadVarsAlloc(ThreadVars *tv)
Alloc and setup DecodeThreadVars.
PacketQueueNoLock decode_pq
int DetectEngineReload(const SCInstance *suri)
Reload the detection engine.
int InitGlobal(void)
Global initialization common to all runmodes.
void FlowWorkerReplaceDetectCtx(void *flow_worker, void *detect_ctx)