Go to the documentation of this file.
59 #define DEFAULT_LOG_FILENAME "alert-debug.log"
61 #define MODULE_NAME "AlertDebugLog"
139 static int AlertDebugPrintStreamSegmentCallback(
140 const Packet *p,
TcpSegment *seg,
void *data,
const uint8_t *buf, uint32_t buflen)
158 const char *pkt_src_str = NULL;
163 MemBufferReset(aft->
buffer);
168 "TIME: %s\n", timebuf);
175 char srcip[46], dstip[46];
176 if (PacketIsIPv4(p)) {
187 "PROTO: %" PRIu32
"\n",
188 srcip, dstip, p->
proto);
189 if (PacketIsTCP(p) || PacketIsUDP(p)) {
191 "DST PORT: %" PRIu32
"\n",
193 if (PacketIsTCP(p)) {
194 const TCPHdr *tcph = PacketGetTCP(p);
196 "TCP SEQ: %" PRIu32
"\n"
197 "TCP ACK: %" PRIu32
"\n",
208 if (p->
flow != NULL) {
214 "FLOW PKTS TOSRC: %"PRIu32
"\n"
215 "FLOW Total Bytes: %"PRIu64
"\n",
219 "FLOW IPONLY SET: TOSERVER: %s, TOCLIENT: %s\n"
220 "FLOW ACTION: DROP: %s\n"
221 "FLOW NOINSPECTION: PACKET: %s, PAYLOAD: %s, APP_LAYER: %s\n"
222 "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);
335 "PCAP PKT NUM: %"PRIu64
"\n", p->
pcap_cnt);
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 AlertDebugLogLogger, AlertDebugLogCondition, AlertDebugLogThreadInit,
489 AlertDebugLogThreadDeinit);
#define TCP_GET_RAW_SEQ(tcph)
#define PACKET_ALERT_FLAG_STREAM_MATCH
union FlowVar_::@109 data
const struct Signature_ * s
#define STREAM_DUMP_TOSERVER
#define PACKET_ALERT_FLAG_TX
LogFileCtx * LogFileNewCtx(void)
LogFileNewCtx() Get a new LogFileCtx.
int StreamSegmentForEach(const Packet *p, uint8_t flag, StreamSegmentCallback CallbackFunc, void *data)
#define FLOW_NOPAYLOAD_INSPECTION
#define FLOW_PKT_TOSERVER
int(* Write)(const char *buffer, int buffer_len, struct LogFileCtx_ *fp)
void OutputRegisterPacketModule(LoggerId id, const char *name, const char *conf_name, OutputInitFunc InitFunc, PacketLogger PacketLogFunc, PacketLogCondition PacketConditionFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit)
Register a packet output module.
#define GET_IPV6_DST_ADDR(p)
PacketEngineEvents events
int SCConfLogOpenGeneric(ConfNode *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
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_TOSERVER_IPONLY_SET
#define FLOW_PKT_TOCLIENT
#define DEFAULT_LOG_FILENAME
#define GET_IPV4_SRC_ADDR_PTR(p)
#define FLOW_TOCLIENT_IPONLY_SET
void(* DeInit)(struct OutputCtx_ *)
const char * VarNameStoreLookupById(const uint32_t id, const enum VarTypes type)
find name for id+type at packet time.
void MemBufferFree(MemBuffer *buffer)
int LogFileFreeCtx(LogFileCtx *lf_ctx)
LogFileFreeCtx() Destroy a LogFileCtx (Close the file and free memory)
#define GET_IPV6_SRC_ADDR(p)
#define STREAM_DUMP_TOCLIENT
struct AlertDebugLogThread_ AlertDebugLogThread
void MemBufferWriteString(MemBuffer *dst, const char *fmt,...)
#define FLOW_NOPACKET_INSPECTION
#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 PACKET_ALERT_FLAG_STATE_MATCH
#define DEBUG_VALIDATE_BUG_ON(exp)
void CreateTimeString(const SCTime_t ts, char *str, size_t size)
MemBuffer * MemBufferCreateNew(uint32_t size)