Go to the documentation of this file.
27 #include <fuzz_pcap.h>
31 static int initialized = 0;
40 static void SigGenereateAware(
const uint8_t *data,
size_t size,
char *r,
size_t *
len)
42 *
len = snprintf(r, 511,
"alert ip any any -> any any (");
43 for (
size_t i = 0; i + 1 < size && *
len < 511; i++) {
45 size_t off = (data[i] & 0x7F + ((data[i + 1] & 0xF) << 7)) %
60 *
len += snprintf(r + *
len, 511 - *
len,
")");
71 struct pcap_pkthdr header;
77 if (initialized == 0) {
79 setenv(
"SC_LOG_OP_IFACE",
"file", 0);
80 setenv(
"SC_LOG_FILE",
"/dev/null", 0);
93 remove(
"/tmp/fuzz.rules");
103 memset(&
tv, 0,
sizeof(
tv));
118 if (size < 1 + FPC0_HEADER_LEN) {
121 for (pos = 0; pos < size - FPC0_HEADER_LEN; pos++) {
122 if (data[pos] == 0) {
127 if (FPC_init(&pkts, data + pos + 1, size - pos - 1) < 0) {
134 SigGenereateAware(data, pos + 1, sigaware, &
len);
152 r = FPC_next(&pkts, &header, &pkt);
155 p->
ts.tv_sec = header.ts.tv_sec;
156 p->
ts.tv_usec = header.ts.tv_usec % 1000000;
166 while (extra_p != NULL) {
172 while (extra_p != NULL) {
177 r = FPC_next(&pkts, &header, &pkt);
180 p->
ts.tv_sec = header.ts.tv_sec;
181 p->
ts.tv_usec = header.ts.tv_usec % 1000000;
struct FlowQueue_ * flow_queue
DetectEngineThreadCtx * DetectEngineThreadCtxInitForReload(ThreadVars *tv, DetectEngineCtx *new_de_ctx, int mt)
void PacketFreeOrRelease(Packet *p)
Return a packet to where it was allocated.
int PacketCopyData(Packet *p, const uint8_t *pktdata, uint32_t pktlen)
Copy data to Packet payload and set packet length.
main detection engine ctx
DetectEngineCtx * DetectEngineGetCurrent(void)
int StatsSetupPrivate(ThreadVars *tv)
void GlobalsInitPreConfig(void)
void PacketPoolInit(void)
void DecodeRegisterPerfCounters(DecodeThreadVars *dtv, ThreadVars *tv)
void PreRunPostPrivsDropInit(const int runmode)
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
Packet * PacketDequeueNoLock(PacketQueueNoLock *qnl)
Per thread variable structure.
TmEcode(* Func)(ThreadVars *, Packet *, void *)
struct SigTableElmt_ SigTableElmt
element in sigmatch type table.
void PacketFree(Packet *p)
Return a malloced packet.
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)
void * FlowWorkerGetDetectCtxPtr(void *flow_worker)
TmEcode DetectEngineThreadCtxDeinit(ThreadVars *, void *)
const char configNoChecksum[]
SigTableElmt sigmatch_table[DETECT_TBLSIZE]
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
FlowQueue * FlowQueueNew()
int DetectEngineReload(const SCInstance *suri)
Reload the detection engine.
int InitGlobal(void)
Global initialization common to all runmodes.
#define PACKET_RECYCLE(p)
void FlowWorkerReplaceDetectCtx(void *flow_worker, void *detect_ctx)