Go to the documentation of this file.
54 #define DEFAULT_LOG_FILENAME "alert-debug.log"
56 #define MODULE_NAME "AlertDebugLog"
134 static int AlertDebugPrintStreamSegmentCallback(
135 const Packet *
p,
TcpSegment *seg,
void *data,
const uint8_t *buf, uint32_t buflen)
153 const char *pkt_src_str = NULL;
158 MemBufferReset(aft->
buffer);
163 "TIME: %s\n", timebuf);
171 char srcip[46], dstip[46];
172 if (PacketIsIPv4(
p)) {
185 "PROTO: %" PRIu32
"\n",
187 if (PacketIsTCP(
p) || PacketIsUDP(
p)) {
189 "DST PORT: %" PRIu32
"\n",
191 if (PacketIsTCP(
p)) {
192 const TCPHdr *tcph = PacketGetTCP(
p);
194 "TCP SEQ: %" PRIu32
"\n"
195 "TCP ACK: %" PRIu32
"\n",
206 if (
p->
flow != NULL) {
212 "FLOW PKTS TOSRC: %"PRIu32
"\n"
213 "FLOW Total Bytes: %"PRIu64
"\n",
217 "FLOW ACTION: DROP: %s\n"
218 "FLOW PAYLOAD: %s, APP_LAYER: %s\n"
219 "FLOW APP_LAYER: DETECTED: %s, PROTO %" PRIu16
"\n",
222 applayer ?
"TRUE" :
"FALSE",
224 AlertDebugLogFlowVars(aft,
p);
227 AlertDebugLogPktVars(aft,
p);
233 "PACKET LEN: %" PRIu32
"\n"
249 "ALERT MSG [%02d]: %s\n"
250 "ALERT GID [%02d]: %" PRIu32
"\n"
251 "ALERT SID [%02d]: %" PRIu32
"\n"
252 "ALERT REV [%02d]: %" PRIu32
"\n"
253 "ALERT CLASS [%02d]: %s\n"
254 "ALERT PRIO [%02d]: %" PRIu32
"\n"
255 "ALERT FOUND IN [%02d]: %s\n",
267 "ALERT IN TX [%02d]: %"PRIu64
"\n", i, pa->
tx_id);
270 "ALERT IN TX [%02d]: N/A\n", i);
274 "PAYLOAD LEN: %" PRIu32
"\n"
296 AlertDebugPrintStreamSegmentCallback,
315 const char *pkt_src_str = NULL;
320 MemBufferReset(aft->
buffer);
325 "+================\n"
326 "TIME: %s\n", timebuf);
343 "ALERT MSG [%02d]: %s\n"
344 "ALERT GID [%02d]: %" PRIu32
"\n"
345 "ALERT SID [%02d]: %" PRIu32
"\n"
346 "ALERT REV [%02d]: %" PRIu32
"\n"
347 "ALERT CLASS [%02d]: %s\n"
348 "ALERT PRIO [%02d]: %" PRIu32
"\n",
358 "PACKET LEN: %" PRIu32
"\n"
370 static TmEcode AlertDebugLogThreadInit(
ThreadVars *t,
const void *initdata,
void **data)
378 SCLogDebug(
"Error getting context for AlertDebugLog. \"initdata\" argument NULL");
387 if (aft->
buffer == NULL) {
411 static void AlertDebugLogDeInitCtx(
OutputCtx *output_ctx)
413 if (output_ctx != NULL) {
415 if (logfile_ctx != NULL) {
435 if (file_ctx == NULL) {
448 output_ctx->
data = file_ctx;
449 output_ctx->
DeInit = AlertDebugLogDeInitCtx;
451 SCLogDebug(
"Alert debug log output initialized");
452 result.
ctx = output_ctx;
457 if (file_ctx != NULL) {
471 if (PacketIsIPv4(
p) || PacketIsIPv6(
p)) {
472 return AlertDebugLogger(
tv,
p, thread_data);
474 return AlertDebugLogDecoderEvent(
tv,
p, thread_data);
482 .
LogFunc = AlertDebugLogLogger,
483 .ConditionFunc = AlertDebugLogCondition,
484 .ThreadInitFunc = AlertDebugLogThreadInit,
485 .ThreadDeinitFunc = AlertDebugLogThreadDeinit,
486 .ThreadExitPrintStatsFunc = NULL,
490 &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.
union FlowVar_::@121 data
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)
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)