Go to the documentation of this file.
60 #define DEFAULT_LOG_FILENAME "alert-debug.log"
62 #define MODULE_NAME "AlertDebugLog"
140 static int AlertDebugPrintStreamSegmentCallback(
141 const Packet *p,
TcpSegment *seg,
void *data,
const uint8_t *buf, uint32_t buflen)
159 const char *pkt_src_str = NULL;
164 MemBufferReset(aft->
buffer);
169 "TIME: %s\n", timebuf);
177 char srcip[46], dstip[46];
178 if (PacketIsIPv4(p)) {
191 "PROTO: %" PRIu32
"\n",
192 srcip, dstip, p->
proto);
193 if (PacketIsTCP(p) || PacketIsUDP(p)) {
195 "DST PORT: %" PRIu32
"\n",
197 if (PacketIsTCP(p)) {
198 const TCPHdr *tcph = PacketGetTCP(p);
200 "TCP SEQ: %" PRIu32
"\n"
201 "TCP ACK: %" PRIu32
"\n",
212 if (p->
flow != NULL) {
218 "FLOW PKTS TOSRC: %"PRIu32
"\n"
219 "FLOW Total Bytes: %"PRIu64
"\n",
223 "FLOW ACTION: DROP: %s\n"
224 "FLOW PAYLOAD: %s, APP_LAYER: %s\n"
225 "FLOW APP_LAYER: DETECTED: %s, PROTO %" PRIu16
"\n",
228 applayer ?
"TRUE" :
"FALSE",
230 AlertDebugLogFlowVars(aft, p);
233 AlertDebugLogPktVars(aft, p);
239 "PACKET LEN: %" PRIu32
"\n"
255 "ALERT MSG [%02d]: %s\n"
256 "ALERT GID [%02d]: %" PRIu32
"\n"
257 "ALERT SID [%02d]: %" PRIu32
"\n"
258 "ALERT REV [%02d]: %" PRIu32
"\n"
259 "ALERT CLASS [%02d]: %s\n"
260 "ALERT PRIO [%02d]: %" PRIu32
"\n"
261 "ALERT FOUND IN [%02d]: %s\n",
273 "ALERT IN TX [%02d]: %"PRIu64
"\n", i, pa->
tx_id);
276 "ALERT IN TX [%02d]: N/A\n", i);
280 "PAYLOAD LEN: %" PRIu32
"\n"
302 AlertDebugPrintStreamSegmentCallback,
321 const char *pkt_src_str = NULL;
326 MemBufferReset(aft->
buffer);
331 "+================\n"
332 "TIME: %s\n", timebuf);
340 "ALERT CNT: %" PRIu32
"\n", p->
alerts.
cnt);
349 "ALERT MSG [%02d]: %s\n"
350 "ALERT GID [%02d]: %" PRIu32
"\n"
351 "ALERT SID [%02d]: %" PRIu32
"\n"
352 "ALERT REV [%02d]: %" PRIu32
"\n"
353 "ALERT CLASS [%02d]: %s\n"
354 "ALERT PRIO [%02d]: %" PRIu32
"\n",
364 "PACKET LEN: %" PRIu32
"\n"
376 static TmEcode AlertDebugLogThreadInit(
ThreadVars *t,
const void *initdata,
void **data)
384 SCLogDebug(
"Error getting context for AlertDebugLog. \"initdata\" argument NULL");
393 if (aft->
buffer == NULL) {
417 static void AlertDebugLogDeInitCtx(
OutputCtx *output_ctx)
419 if (output_ctx != NULL) {
421 if (logfile_ctx != NULL) {
441 if (file_ctx == NULL) {
454 output_ctx->
data = file_ctx;
455 output_ctx->
DeInit = AlertDebugLogDeInitCtx;
457 SCLogDebug(
"Alert debug log output initialized");
458 result.
ctx = output_ctx;
463 if (file_ctx != NULL) {
470 static bool AlertDebugLogCondition(
ThreadVars *
tv,
void *thread_data,
const Packet *p)
477 if (PacketIsIPv4(p) || PacketIsIPv6(p)) {
478 return AlertDebugLogger(
tv, p, thread_data);
480 return AlertDebugLogDecoderEvent(
tv, p, thread_data);
488 .
LogFunc = AlertDebugLogLogger,
490 .ConditionFunc = AlertDebugLogCondition,
491 .ThreadInitFunc = AlertDebugLogThreadInit,
492 .ThreadDeinitFunc = AlertDebugLogThreadDeinit,
493 .ThreadExitPrintStatsFunc = NULL,
497 &output_logger_functions);
#define TCP_GET_RAW_SEQ(tcph)
const struct Signature_ * s
#define STREAM_DUMP_TOSERVER
#define PACKET_ALERT_FLAG_STATE_MATCH
LogFileCtx * LogFileNewCtx(void)
LogFileNewCtx() Get a new LogFileCtx.
uint64_t PcapPacketCntGet(const Packet *p)
int StreamSegmentForEach(const Packet *p, uint8_t flag, StreamSegmentCallback CallbackFunc, void *data)
const char * PrintInetIPv6(const void *src, char *dst, socklen_t size, bool compress_ipv6)
#define FLOW_NOPAYLOAD_INSPECTION
#define FLOW_PKT_TOSERVER
int(* Write)(const char *buffer, int buffer_len, struct LogFileCtx_ *fp)
#define GET_IPV6_DST_ADDR(p)
PacketEngineEvents events
int StreamTcpAppLayerIsDisabled(Flow *f)
struct GenericVar_ * next
void PrintRawDataToBuffer(uint8_t *dst_buf, uint32_t *dst_buf_offset_ptr, uint32_t dst_buf_size, const uint8_t *src_buf, uint32_t src_buf_len)
#define GET_IPV4_DST_ADDR_PTR(p)
Per thread variable structure.
const char * PrintInet(int af, const void *src, char *dst, socklen_t size)
const char * PktSrcToString(enum PktSrcEnum pkt_src)
#define FLOW_PKT_TOCLIENT
#define DEFAULT_LOG_FILENAME
#define PACKET_ALERT_FLAG_STREAM_MATCH
#define GET_IPV4_SRC_ADDR_PTR(p)
void(* DeInit)(struct OutputCtx_ *)
const char * VarNameStoreLookupById(const uint32_t id, const enum VarTypes type)
find name for id+type at packet time. As the active store won't be modified, we don't need locks.
void MemBufferFree(MemBuffer *buffer)
void OutputRegisterPacketModule(LoggerId id, const char *name, const char *conf_name, OutputInitFunc InitFunc, OutputPacketLoggerFunctions *output_module_functions)
Register a packet output module.
int LogFileFreeCtx(LogFileCtx *lf_ctx)
LogFileFreeCtx() Destroy a LogFileCtx (Close the file and free memory)
union FlowVar_::@116 data
int SCConfLogOpenGeneric(SCConfNode *conf, LogFileCtx *log_ctx, const char *default_filename, int rotate)
open a generic output "log file", which may be a regular file or a socket
#define GET_IPV6_SRC_ADDR(p)
#define STREAM_DUMP_TOCLIENT
#define PACKET_ALERT_FLAG_TX
struct AlertDebugLogThread_ AlertDebugLogThread
void MemBufferWriteString(MemBuffer *dst, const char *fmt,...)
#define MEMBUFFER_BUFFER(mem_buffer)
Get the MemBuffers underlying buffer.
void AlertDebugLogRegister(void)
#define MEMBUFFER_OFFSET(mem_buffer)
Get the MemBuffers current offset.
AppProto alproto
application level protocol
#define TCP_GET_RAW_ACK(tcph)
#define DEBUG_VALIDATE_BUG_ON(exp)
void CreateTimeString(const SCTime_t ts, char *str, size_t size)
MemBuffer * MemBufferCreateNew(uint32_t size)