Go to the documentation of this file.
31 static int worker_id = 1;
57 static void ReleasePacket(
Packet *p)
72 static void *SimpleWorker(
void *arg)
89 assert(device != NULL);
91 int datalink = pcap_datalink(fp);
93 struct pcap_pkthdr pkthdr;
95 while ((packet = pcap_next(fp, &pkthdr)) != NULL) {
153 static uint8_t RateFilterCallback(
const Packet *p,
const uint32_t sid,
const uint32_t gid,
154 const uint32_t rev, uint8_t original_action, uint8_t new_action,
void *arg)
166 static int AppRunModeSetup(
void)
180 int main(
int argc,
char **argv)
190 bool end = strncmp(argv[0],
"--", 2) == 0;
198 fprintf(stderr,
"ERROR: No PCAP files provided\n");
238 RUNMODE_LIB,
"custom",
"Custom application run mode", AppRunModeSetup, NULL);
248 fprintf(stderr,
"LiveRegisterDevice failed");
262 .pcap_filename = argv[argc - 1],
264 if (pthread_create(&worker, NULL, SimpleWorker, &args) != 0) {
bool PacketCheckAction(const Packet *p, const uint8_t a)
bool SCTmThreadsSlotPacketLoopFinish(ThreadVars *tv)
void SuricataMainLoop(void)
int LiveRegisterDevice(const char *dev)
Add a pcap device for monitoring and create structure.
void SCEnableDefaultSignalHandlers(void)
Enable default signal handlers.
void PacketFreeOrRelease(Packet *p)
Return a packet to where it was allocated.
void SCPacketSetLiveDevice(Packet *p, LiveDevice *device)
Set a packets live device.
void SuricataPostInit(void)
TmEcode SCParseCommandLine(int argc, char **argv)
void SuricataShutdown(void)
void TmqhOutputPacketpool(ThreadVars *t, Packet *p)
void SCPacketSetSource(Packet *p, enum PktSrcEnum source)
Set packet source.
void SCRunmodeSet(SCRunMode run_mode)
Set the current run mode.
int main(int argc, char **argv)
struct TmSlot_ * tm_slots
LiveDevice * LiveGetDevice(const char *name)
Get a pointer to the device at idx.
Per thread variable structure.
#define SCTIME_FROM_TIMEVAL(tv)
int SCRunModeLibSpawnWorker(void *td)
start the "fake" worker.
void SCDetectEngineRegisterRateFilterCallback(SCDetectRateFilterFunc fn, void *arg)
Register a callback when a rate_filter has been applied to an alert.
void RunModeRegisterNewRunMode(enum SCRunModes runmode, const char *name, const char *description, int(*RunModeFunc)(void), int(*RunModeIsIPSEnabled)(void))
Registers a new runmode.
void SCPacketSetTime(Packet *p, SCTime_t ts)
Set the timestamp for a packet.
int SCConfSetFromString(const char *input, int final)
Set a configuration parameter from a string.
void TmThreadsInitThreadsTimestamp(const SCTime_t ts)
void TimeModeSetOffline(void)
int SCStartInternalRunMode(int argc, char **argv)
void SCPacketSetReleasePacket(Packet *p, void(*ReleasePacket)(Packet *p))
Set a packet release function.
void EngineStop(void)
make sure threads can stop the engine by calling this function. Purpose: pcap file mode needs to be a...
TmEcode SCLoadYamlConfig(void)
#define SCLogError(...)
Macro used to log ERROR messages.
ThreadVars * SCRunModeLibCreateThreadVars(int worker_id)
Create ThreadVars for use by a user provided thread.
int PacketSetData(Packet *p, const uint8_t *pktdata, uint32_t pktlen)
Set data for Packet and set length when zero copy is used.
void SCPacketSetDatalink(Packet *p, int datalink)
Set a packets data link type.
#define SCLogNotice(...)
Macro used to log NOTICE messages.
void SuricataPreInit(const char *progname)
Packet * PacketGetFromQueueOrAlloc(void)
Get a packet. We try to get a packet from the packetpool first, but if that is empty we alloc a packe...
int SCFinalizeRunMode(void)
void GlobalsDestroy(void)
volatile uint8_t suricata_ctl_flags
void LiveDevicePktsIncr(LiveDevice *dev)