suricata
alert-debuglog.c
Go to the documentation of this file.
1 /* Copyright (C) 2007-2014 Open Information Security Foundation
2  *
3  * You can copy, redistribute or modify this Program under the terms of
4  * the GNU General Public License version 2 as published by the Free
5  * Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * version 2 along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15  * 02110-1301, USA.
16  */
17 
18 /**
19  * \file
20  *
21  * \author Victor Julien <victor@inliniac.net>
22  */
23 
24 #include "suricata-common.h"
25 
26 #include "action-globals.h"
27 #include "detect.h"
28 #include "flow.h"
29 #include "conf.h"
30 #include "stream.h"
31 #include "app-layer-protos.h"
32 #include "decode-tcp.h"
33 #include "detect-engine-register.h"
34 
35 #include "threadvars.h"
36 #include "tm-modules.h"
37 
38 #include "util-print.h"
39 #include "util-var.h"
40 
41 #include "util-debug.h"
42 #include "util-validate.h"
43 #include "util-buffer.h"
44 
45 #include "output.h"
46 #include "alert-debuglog.h"
47 #include "flow-var.h"
48 #include "flow-bit.h"
49 #include "util-var-name.h"
50 #include "util-logopenfile.h"
51 
52 #include "stream-tcp-reassemble.h"
53 
54 #define DEFAULT_LOG_FILENAME "alert-debug.log"
55 
56 #define MODULE_NAME "AlertDebugLog"
57 
58 typedef struct AlertDebugLogThread_ {
60  /** LogFileCtx has the pointer to the file and a mutex to allow multithreading */
63 
64 /**
65  * \brief Function to log the FlowVars into alert-debug.log
66  *
67  * \param aft Pointer to AlertDebugLog Thread
68  * \param p Pointer to the packet
69  *
70  */
71 static void AlertDebugLogFlowVars(AlertDebugLogThread *aft, const Packet *p)
72 {
73  const GenericVar *gv = p->flow->flowvar;
74  uint16_t i;
75  while (gv != NULL) {
76  if (gv->type == DETECT_FLOWBITS) {
77  FlowBit *fb = (FlowBit *)gv;
78  const char *fbname = VarNameStoreLookupById(fb->idx, VAR_TYPE_FLOW_BIT);
79  if (fbname) {
80  MemBufferWriteString(aft->buffer, "FLOWBIT: %s\n",
81  fbname);
82  }
83  } else if (gv->type == DETECT_FLOWVAR || gv->type == DETECT_FLOWINT) {
84  FlowVar *fv = (FlowVar *) gv;
85 
86  if (fv->datatype == FLOWVAR_TYPE_STR) {
87  const char *fvname = VarNameStoreLookupById(fv->idx,
89  MemBufferWriteString(aft->buffer, "FLOWVAR: \"%s\" => \"",
90  fvname);
91  for (i = 0; i < fv->data.fv_str.value_len; i++) {
92  if (isprint(fv->data.fv_str.value[i])) {
93  MemBufferWriteString(aft->buffer, "%c",
94  fv->data.fv_str.value[i]);
95  } else {
96  MemBufferWriteString(aft->buffer, "\\%02X",
97  fv->data.fv_str.value[i]);
98  }
99  }
100  MemBufferWriteString(aft->buffer, "\"\n");
101  } else if (fv->datatype == FLOWVAR_TYPE_INT) {
102  const char *fvname = VarNameStoreLookupById(fv->idx,
104  MemBufferWriteString(aft->buffer, "FLOWINT: \"%s\" =>"
105  " %"PRIu32"\n", fvname, fv->data.fv_int.value);
106  }
107  }
108  gv = gv->next;
109  }
110 }
111 
112 /**
113  * \brief Function to log the PktVars into alert-debug.log
114  *
115  * \param aft Pointer to AlertDebugLog Thread
116  * \param p Pointer to the packet
117  *
118  */
119 static void AlertDebugLogPktVars(AlertDebugLogThread *aft, const Packet *p)
120 {
121  const PktVar *pv = p->pktvar;
122 
123  while (pv != NULL) {
124  const char *varname = VarNameStoreLookupById(pv->id, VAR_TYPE_PKT_VAR);
125  MemBufferWriteString(aft->buffer, "PKTVAR: %s\n", varname);
127  pv->value, pv->value_len);
128  pv = pv->next;
129  }
130 }
131 
132 /** \todo doc
133  * assume we have aft lock */
134 static int AlertDebugPrintStreamSegmentCallback(
135  const Packet *p, TcpSegment *seg, void *data, const uint8_t *buf, uint32_t buflen)
136 {
138 
139  MemBufferWriteString(aft->buffer, "STREAM DATA LEN: %"PRIu32"\n", buflen);
140  MemBufferWriteString(aft->buffer, "STREAM DATA:\n");
141 
143  buf, buflen);
144 
145  return 1;
146 }
147 
148 static TmEcode AlertDebugLogger(ThreadVars *tv, const Packet *p, void *thread_data)
149 {
150  AlertDebugLogThread *aft = (AlertDebugLogThread *)thread_data;
151  int i;
152  char timebuf[64];
153  const char *pkt_src_str = NULL;
154 
155  if (p->alerts.cnt == 0)
156  return TM_ECODE_OK;
157 
158  MemBufferReset(aft->buffer);
159 
160  CreateTimeString(p->ts, timebuf, sizeof(timebuf));
161 
162  MemBufferWriteString(aft->buffer, "+================\n"
163  "TIME: %s\n", timebuf);
164  uint64_t pcap_cnt = PcapPacketCntGet(p);
165  if (pcap_cnt > 0) {
166  MemBufferWriteString(aft->buffer, "PCAP PKT NUM: %" PRIu64 "\n", pcap_cnt);
167  }
168  pkt_src_str = PktSrcToString(p->pkt_src);
169  MemBufferWriteString(aft->buffer, "PKT SRC: %s\n", pkt_src_str);
170 
171  char srcip[46], dstip[46];
172  if (PacketIsIPv4(p)) {
173  PrintInet(AF_INET, (const void *)GET_IPV4_SRC_ADDR_PTR(p), srcip, sizeof(srcip));
174  PrintInet(AF_INET, (const void *)GET_IPV4_DST_ADDR_PTR(p), dstip, sizeof(dstip));
175  } else {
176  DEBUG_VALIDATE_BUG_ON(!(PacketIsIPv6(p)));
177  PrintInetIPv6((const void *)GET_IPV6_SRC_ADDR(p), srcip, sizeof(srcip),
178  aft->file_ctx->compress_ipv6);
179  PrintInetIPv6((const void *)GET_IPV6_DST_ADDR(p), dstip, sizeof(dstip),
180  aft->file_ctx->compress_ipv6);
181  }
182 
183  MemBufferWriteString(aft->buffer, "SRC IP: %s\n"
184  "DST IP: %s\n"
185  "PROTO: %" PRIu32 "\n",
186  srcip, dstip, p->proto);
187  if (PacketIsTCP(p) || PacketIsUDP(p)) {
188  MemBufferWriteString(aft->buffer, "SRC PORT: %" PRIu32 "\n"
189  "DST PORT: %" PRIu32 "\n",
190  p->sp, p->dp);
191  if (PacketIsTCP(p)) {
192  const TCPHdr *tcph = PacketGetTCP(p);
194  "TCP SEQ: %" PRIu32 "\n"
195  "TCP ACK: %" PRIu32 "\n",
196  TCP_GET_RAW_SEQ(tcph), TCP_GET_RAW_ACK(tcph));
197  }
198  }
199 
200  /* flow stuff */
201  MemBufferWriteString(aft->buffer, "FLOW: to_server: %s, "
202  "to_client: %s\n",
203  p->flowflags & FLOW_PKT_TOSERVER ? "TRUE" : "FALSE",
204  p->flowflags & FLOW_PKT_TOCLIENT ? "TRUE" : "FALSE");
205 
206  if (p->flow != NULL) {
207  int applayer = 0;
208  applayer = StreamTcpAppLayerIsDisabled(p->flow);
209  CreateTimeString(p->flow->startts, timebuf, sizeof(timebuf));
210  MemBufferWriteString(aft->buffer, "FLOW Start TS: %s\n", timebuf);
211  MemBufferWriteString(aft->buffer, "FLOW PKTS TODST: %"PRIu32"\n"
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",
220  p->flow->flags & FLOW_ACTION_DROP ? "TRUE" : "FALSE",
221  p->flow->flags & FLOW_NOPAYLOAD_INSPECTION ? "TRUE" : "FALSE",
222  applayer ? "TRUE" : "FALSE",
223  (p->flow->alproto != ALPROTO_UNKNOWN) ? "TRUE" : "FALSE", p->flow->alproto);
224  AlertDebugLogFlowVars(aft, p);
225  }
226 
227  AlertDebugLogPktVars(aft, p);
228 
229 /* any stuff */
230 /* Sig details? */
231 
233  "PACKET LEN: %" PRIu32 "\n"
234  "PACKET:\n",
235  GET_PKT_LEN(p));
238 
239  MemBufferWriteString(aft->buffer, "ALERT CNT: %" PRIu32 "\n",
240  p->alerts.cnt);
241 
242  for (i = 0; i < p->alerts.cnt; i++) {
243  const PacketAlert *pa = &p->alerts.alerts[i];
244  if (unlikely(pa->s == NULL || (pa->action & ACTION_ALERT) == 0)) {
245  continue;
246  }
247 
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",
256  i, pa->s->msg,
257  i, pa->s->gid,
258  i, pa->s->id,
259  i, pa->s->rev,
260  i, pa->s->class_msg ? pa->s->class_msg : "<none>",
261  i, pa->s->prio,
262  i,
263  pa->flags & PACKET_ALERT_FLAG_STREAM_MATCH ? "STREAM" :
264  (pa->flags & PACKET_ALERT_FLAG_STATE_MATCH ? "STATE" : "PACKET"));
265  if (pa->flags & PACKET_ALERT_FLAG_TX) {
267  "ALERT IN TX [%02d]: %"PRIu64"\n", i, pa->tx_id);
268  } else {
270  "ALERT IN TX [%02d]: N/A\n", i);
271  }
272  if (p->payload_len > 0) {
274  "PAYLOAD LEN: %" PRIu32 "\n"
275  "PAYLOAD:\n",
276  p->payload_len);
278  p->payload, p->payload_len);
279  }
280  if ((pa->flags & PACKET_ALERT_FLAG_STATE_MATCH) ||
282  /* This is an app layer or stream alert */
283  int ret;
284  uint8_t flag;
285  if (!(PacketIsTCP(p)) || p->flow == NULL || p->flow->protoctx == NULL) {
286  continue;
287  }
288  /* IDS mode reverse the data */
289  /** \todo improve the order selection policy */
290  if (p->flowflags & FLOW_PKT_TOSERVER) {
291  flag = STREAM_DUMP_TOCLIENT;
292  } else {
293  flag = STREAM_DUMP_TOSERVER;
294  }
295  ret = StreamSegmentForEach((const Packet *)p, flag,
296  AlertDebugPrintStreamSegmentCallback,
297  (void *)aft);
298  if (ret < 0) {
299  return TM_ECODE_FAILED;
300  }
301  }
302  }
303 
304  aft->file_ctx->Write((const char *)MEMBUFFER_BUFFER(aft->buffer),
305  MEMBUFFER_OFFSET(aft->buffer), aft->file_ctx);
306 
307  return TM_ECODE_OK;
308 }
309 
310 static TmEcode AlertDebugLogDecoderEvent(ThreadVars *tv, const Packet *p, void *thread_data)
311 {
312  AlertDebugLogThread *aft = (AlertDebugLogThread *)thread_data;
313  int i;
314  char timebuf[64];
315  const char *pkt_src_str = NULL;
316 
317  if (p->alerts.cnt == 0)
318  return TM_ECODE_OK;
319 
320  MemBufferReset(aft->buffer);
321 
322  CreateTimeString(p->ts, timebuf, sizeof(timebuf));
323 
325  "+================\n"
326  "TIME: %s\n", timebuf);
327  uint64_t pcap_cnt = PcapPacketCntGet(p);
328  if (pcap_cnt > 0) {
329  MemBufferWriteString(aft->buffer, "PCAP PKT NUM: %" PRIu64 "\n", pcap_cnt);
330  }
331  pkt_src_str = PktSrcToString(p->pkt_src);
332  MemBufferWriteString(aft->buffer, "PKT SRC: %s\n", pkt_src_str);
334  "ALERT CNT: %" PRIu32 "\n", p->alerts.cnt);
335 
336  for (i = 0; i < p->alerts.cnt; i++) {
337  const PacketAlert *pa = &p->alerts.alerts[i];
338  if (unlikely(pa->s == NULL || (pa->action & ACTION_ALERT) == 0)) {
339  continue;
340  }
341 
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",
349  i, pa->s->msg,
350  i, pa->s->gid,
351  i, pa->s->id,
352  i, pa->s->rev,
353  i, pa->s->class_msg,
354  i, pa->s->prio);
355  }
356 
358  "PACKET LEN: %" PRIu32 "\n"
359  "PACKET:\n",
360  GET_PKT_LEN(p));
363 
364  aft->file_ctx->Write((const char *)MEMBUFFER_BUFFER(aft->buffer),
365  MEMBUFFER_OFFSET(aft->buffer), aft->file_ctx);
366 
367  return TM_ECODE_OK;
368 }
369 
370 static TmEcode AlertDebugLogThreadInit(ThreadVars *t, const void *initdata, void **data)
371 {
373  if (unlikely(aft == NULL))
374  return TM_ECODE_FAILED;
375 
376  if(initdata == NULL)
377  {
378  SCLogDebug("Error getting context for AlertDebugLog. \"initdata\" argument NULL");
379  SCFree(aft);
380  return TM_ECODE_FAILED;
381  }
382  /** Use the Output Context (file pointer and mutex) */
383  aft->file_ctx = ((OutputCtx *)initdata)->data;
384 
385  /* 1 mb seems sufficient enough */
386  aft->buffer = MemBufferCreateNew(1 * 1024 * 1024);
387  if (aft->buffer == NULL) {
388  SCFree(aft);
389  return TM_ECODE_FAILED;
390  }
391 
392  *data = (void *)aft;
393  return TM_ECODE_OK;
394 }
395 
396 static TmEcode AlertDebugLogThreadDeinit(ThreadVars *t, void *data)
397 {
399  if (aft == NULL) {
400  return TM_ECODE_OK;
401  }
402 
403  MemBufferFree(aft->buffer);
404  /* clear memory */
405  memset(aft, 0, sizeof(AlertDebugLogThread));
406 
407  SCFree(aft);
408  return TM_ECODE_OK;
409 }
410 
411 static void AlertDebugLogDeInitCtx(OutputCtx *output_ctx)
412 {
413  if (output_ctx != NULL) {
414  LogFileCtx *logfile_ctx = (LogFileCtx *)output_ctx->data;
415  if (logfile_ctx != NULL) {
416  LogFileFreeCtx(logfile_ctx);
417  }
418  SCFree(output_ctx);
419  }
420 }
421 
422 /**
423  * \brief Create a new LogFileCtx for alert debug logging.
424  *
425  * \param SCConfNode containing configuration for this logger.
426  *
427  * \return output_ctx if succesful, NULL otherwise
428  */
429 static OutputInitResult AlertDebugLogInitCtx(SCConfNode *conf)
430 {
431  OutputInitResult result = { NULL, false };
432  LogFileCtx *file_ctx = NULL;
433 
434  file_ctx = LogFileNewCtx();
435  if (file_ctx == NULL) {
436  SCLogDebug("couldn't create new file_ctx");
437  goto error;
438  }
439 
440  if (SCConfLogOpenGeneric(conf, file_ctx, DEFAULT_LOG_FILENAME, 1) < 0) {
441  goto error;
442  }
443 
444  OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
445  if (unlikely(output_ctx == NULL))
446  goto error;
447 
448  output_ctx->data = file_ctx;
449  output_ctx->DeInit = AlertDebugLogDeInitCtx;
450 
451  SCLogDebug("Alert debug log output initialized");
452  result.ctx = output_ctx;
453  result.ok = true;
454  return result;
455 
456 error:
457  if (file_ctx != NULL) {
458  LogFileFreeCtx(file_ctx);
459  }
460 
461  return result;
462 }
463 
464 static bool AlertDebugLogCondition(ThreadVars *tv, void *thread_data, const Packet *p)
465 {
466  return (p->alerts.cnt > 0);
467 }
468 
469 static int AlertDebugLogLogger(ThreadVars *tv, void *thread_data, const Packet *p)
470 {
471  if (PacketIsIPv4(p) || PacketIsIPv6(p)) {
472  return AlertDebugLogger(tv, p, thread_data);
473  } else if (p->events.cnt > 0) {
474  return AlertDebugLogDecoderEvent(tv, p, thread_data);
475  }
476  return TM_ECODE_OK;
477 }
478 
480 {
481  OutputPacketLoggerFunctions output_logger_functions = {
482  .LogFunc = AlertDebugLogLogger,
483  .ConditionFunc = AlertDebugLogCondition,
484  .ThreadInitFunc = AlertDebugLogThreadInit,
485  .ThreadDeinitFunc = AlertDebugLogThreadDeinit,
486  .ThreadExitPrintStatsFunc = NULL,
487  };
488 
489  OutputRegisterPacketModule(LOGGER_ALERT_DEBUG, MODULE_NAME, "alert-debug", AlertDebugLogInitCtx,
490  &output_logger_functions);
491 }
TCP_GET_RAW_SEQ
#define TCP_GET_RAW_SEQ(tcph)
Definition: decode-tcp.h:80
decode-tcp.h
Packet_::proto
uint8_t proto
Definition: decode.h:538
PacketAlert_::s
const struct Signature_ * s
Definition: decode.h:254
AlertDebugLogThread_::buffer
MemBuffer * buffer
Definition: alert-debuglog.c:61
MemBuffer_::buffer
uint8_t buffer[]
Definition: util-buffer.h:30
Flow_::flags
uint64_t flags
Definition: flow.h:408
STREAM_DUMP_TOSERVER
#define STREAM_DUMP_TOSERVER
Definition: stream.h:33
alert-debuglog.h
AlertDebugLogThread_
Definition: alert-debuglog.c:58
Flow_::startts
SCTime_t startts
Definition: flow.h:498
PACKET_ALERT_FLAG_STATE_MATCH
#define PACKET_ALERT_FLAG_STATE_MATCH
Definition: decode.h:270
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
LogFileNewCtx
LogFileCtx * LogFileNewCtx(void)
LogFileNewCtx() Get a new LogFileCtx.
Definition: util-logopenfile.c:734
PcapPacketCntGet
uint64_t PcapPacketCntGet(const Packet *p)
Definition: decode.c:1193
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:282
StreamSegmentForEach
int StreamSegmentForEach(const Packet *p, uint8_t flag, StreamSegmentCallback CallbackFunc, void *data)
Definition: stream.c:40
Packet_::payload
uint8_t * payload
Definition: decode.h:620
PacketAlerts_::cnt
uint16_t cnt
Definition: decode.h:289
FlowVarTypeStr::value_len
uint16_t value_len
Definition: flow-var.h:41
FLOWVAR_TYPE_STR
#define FLOWVAR_TYPE_STR
Definition: flow-var.h:33
action-globals.h
PrintInetIPv6
const char * PrintInetIPv6(const void *src, char *dst, socklen_t size, bool compress_ipv6)
Definition: util-print.c:209
LogFileCtx_
Definition: util-logopenfile.h:77
PktVar_::next
struct PktVar_ * next
Definition: decode.h:316
FlowVar_::fv_str
FlowVarTypeStr fv_str
Definition: flow-var.h:64
FLOW_NOPAYLOAD_INSPECTION
#define FLOW_NOPAYLOAD_INSPECTION
Definition: flow.h:66
detect-engine-register.h
PacketAlerts_::alerts
PacketAlert * alerts
Definition: decode.h:293
flow-bit.h
FLOW_PKT_TOSERVER
#define FLOW_PKT_TOSERVER
Definition: flow.h:236
util-var-name.h
tm-modules.h
LogFileCtx_::Write
int(* Write)(const char *buffer, int buffer_len, struct LogFileCtx_ *fp)
Definition: util-logopenfile.h:92
stream-tcp-reassemble.h
FLOW_ACTION_DROP
#define FLOW_ACTION_DROP
Definition: flow.h:69
p
Packet * p
Definition: fuzz_dataset.c:30
FLOWVAR_TYPE_INT
#define FLOWVAR_TYPE_INT
Definition: flow-var.h:34
Packet_::flowflags
uint8_t flowflags
Definition: decode.h:547
TM_ECODE_FAILED
@ TM_ECODE_FAILED
Definition: tm-threads-common.h:82
Flow_::protoctx
void * protoctx
Definition: flow.h:438
util-var.h
Packet_::payload_len
uint16_t payload_len
Definition: decode.h:621
GET_IPV6_DST_ADDR
#define GET_IPV6_DST_ADDR(p)
Definition: decode.h:205
Packet_::alerts
PacketAlerts alerts
Definition: decode.h:637
Packet_::events
PacketEngineEvents events
Definition: decode.h:643
MemBuffer_::offset
uint32_t offset
Definition: util-buffer.h:29
OutputCtx_::data
void * data
Definition: tm-modules.h:91
TM_ECODE_OK
@ TM_ECODE_OK
Definition: tm-threads-common.h:81
PacketAlert_::tx_id
uint64_t tx_id
Definition: decode.h:255
OutputCtx_
Definition: tm-modules.h:88
PacketAlert_::action
uint8_t action
Definition: decode.h:251
Signature_::gid
uint32_t gid
Definition: detect.h:742
FlowVar_::fv_int
FlowVarTypeInt fv_int
Definition: flow-var.h:65
MODULE_NAME
#define MODULE_NAME
Definition: alert-debuglog.c:56
Flow_::tosrcbytecnt
uint64_t tosrcbytecnt
Definition: flow.h:503
util-debug.h
StreamTcpAppLayerIsDisabled
int StreamTcpAppLayerIsDisabled(Flow *f)
Definition: stream-tcp-reassemble.c:470
Packet_::pktvar
PktVar * pktvar
Definition: decode.h:612
GenericVar_::next
struct GenericVar_ * next
Definition: util-var.h:57
PrintRawDataToBuffer
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)
Definition: util-print.c:149
GET_IPV4_DST_ADDR_PTR
#define GET_IPV4_DST_ADDR_PTR(p)
Definition: decode.h:200
DETECT_FLOWINT
@ DETECT_FLOWINT
Definition: detect-engine-register.h:71
OutputInitResult_::ctx
OutputCtx * ctx
Definition: output.h:47
DETECT_FLOWVAR
@ DETECT_FLOWVAR
Definition: detect-engine-register.h:69
Flow_::todstpktcnt
uint32_t todstpktcnt
Definition: flow.h:500
Packet_::ts
SCTime_t ts
Definition: decode.h:570
FlowVar_::idx
uint32_t idx
Definition: flow-var.h:59
PktVar_::value
uint8_t * value
Definition: decode.h:322
util-print.h
GET_PKT_DATA
#define GET_PKT_DATA(p)
Definition: decode.h:210
detect.h
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:57
PrintInet
const char * PrintInet(int af, const void *src, char *dst, socklen_t size)
Definition: util-print.c:238
Packet_::sp
Port sp
Definition: decode.h:523
PktSrcToString
const char * PktSrcToString(enum PktSrcEnum pkt_src)
Definition: decode.c:894
OutputInitResult_::ok
bool ok
Definition: output.h:48
Flow_::todstbytecnt
uint64_t todstbytecnt
Definition: flow.h:502
stream.h
TcpSegment
Definition: stream-tcp-private.h:72
ACTION_ALERT
#define ACTION_ALERT
Definition: action-globals.h:29
Packet_
Definition: decode.h:516
GET_PKT_LEN
#define GET_PKT_LEN(p)
Definition: decode.h:209
conf.h
TmEcode
TmEcode
Definition: tm-threads-common.h:80
LogFileCtx_::compress_ipv6
bool compress_ipv6
Definition: util-logopenfile.h:156
MemBuffer_
Definition: util-buffer.h:27
FLOW_PKT_TOCLIENT
#define FLOW_PKT_TOCLIENT
Definition: flow.h:237
DEFAULT_LOG_FILENAME
#define DEFAULT_LOG_FILENAME
Definition: alert-debuglog.c:54
FlowVarTypeInt_::value
uint32_t value
Definition: flow-var.h:46
PACKET_ALERT_FLAG_STREAM_MATCH
#define PACKET_ALERT_FLAG_STREAM_MATCH
Definition: decode.h:272
Flow_::flowvar
GenericVar * flowvar
Definition: flow.h:494
Signature_::class_msg
char * class_msg
Definition: detect.h:767
PacketAlert_::flags
uint8_t flags
Definition: decode.h:252
OutputInitResult_
Definition: output.h:46
FlowVarTypeStr::value
uint8_t * value
Definition: flow-var.h:40
Packet_::flow
struct Flow_ * flow
Definition: decode.h:564
VAR_TYPE_FLOW_BIT
@ VAR_TYPE_FLOW_BIT
Definition: util-var.h:36
GET_IPV4_SRC_ADDR_PTR
#define GET_IPV4_SRC_ADDR_PTR(p)
Definition: decode.h:199
suricata-common.h
OutputCtx_::DeInit
void(* DeInit)(struct OutputCtx_ *)
Definition: tm-modules.h:94
VarNameStoreLookupById
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.
Definition: util-var-name.c:307
FlowVar_::data
union FlowVar_::@121 data
GenericVar_
Definition: util-var.h:53
MemBufferFree
void MemBufferFree(MemBuffer *buffer)
Definition: util-buffer.c:86
OutputPacketLoggerFunctions_::LogFunc
PacketLogger LogFunc
Definition: output.h:87
OutputRegisterPacketModule
void OutputRegisterPacketModule(LoggerId id, const char *name, const char *conf_name, OutputInitFunc InitFunc, OutputPacketLoggerFunctions *output_module_functions)
Register a packet output module.
Definition: output.c:193
Signature_::rev
uint32_t rev
Definition: detect.h:743
LogFileFreeCtx
int LogFileFreeCtx(LogFileCtx *lf_ctx)
LogFileFreeCtx() Destroy a LogFileCtx (Close the file and free memory)
Definition: util-logopenfile.c:951
LOGGER_ALERT_DEBUG
@ LOGGER_ALERT_DEBUG
Definition: suricata-common.h:498
FlowBit_::idx
uint32_t idx
Definition: flow-bit.h:33
AlertDebugLogThread_::file_ctx
LogFileCtx * file_ctx
Definition: alert-debuglog.c:59
DETECT_FLOWBITS
@ DETECT_FLOWBITS
Definition: detect-engine-register.h:68
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:34
Signature_::prio
int prio
Definition: detect.h:744
threadvars.h
util-validate.h
FlowBit_
Definition: flow-bit.h:30
SCConfLogOpenGeneric
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
Definition: util-logopenfile.c:498
GET_IPV6_SRC_ADDR
#define GET_IPV6_SRC_ADDR(p)
Definition: decode.h:204
SCFree
#define SCFree(p)
Definition: util-mem.h:61
Packet_::pkt_src
uint8_t pkt_src
Definition: decode.h:626
util-logopenfile.h
Signature_::id
uint32_t id
Definition: detect.h:741
STREAM_DUMP_TOCLIENT
#define STREAM_DUMP_TOCLIENT
Definition: stream.h:32
util-buffer.h
VAR_TYPE_FLOW_VAR
@ VAR_TYPE_FLOW_VAR
Definition: util-var.h:39
PACKET_ALERT_FLAG_TX
#define PACKET_ALERT_FLAG_TX
Definition: decode.h:274
VAR_TYPE_FLOW_INT
@ VAR_TYPE_FLOW_INT
Definition: util-var.h:37
ALPROTO_UNKNOWN
@ ALPROTO_UNKNOWN
Definition: app-layer-protos.h:29
GenericVar_::type
uint16_t type
Definition: util-var.h:54
PktVar_::value_len
uint16_t value_len
Definition: decode.h:320
AlertDebugLogThread
struct AlertDebugLogThread_ AlertDebugLogThread
app-layer-protos.h
PacketAlert_
Definition: decode.h:249
MemBufferWriteString
void MemBufferWriteString(MemBuffer *dst, const char *fmt,...)
Definition: util-buffer.c:130
PktVar_
Definition: decode.h:314
MemBuffer_::size
uint32_t size
Definition: util-buffer.h:28
MEMBUFFER_BUFFER
#define MEMBUFFER_BUFFER(mem_buffer)
Get the MemBuffers underlying buffer.
Definition: util-buffer.h:51
Signature_::msg
char * msg
Definition: detect.h:764
flow.h
AlertDebugLogRegister
void AlertDebugLogRegister(void)
Definition: alert-debuglog.c:479
MEMBUFFER_OFFSET
#define MEMBUFFER_OFFSET(mem_buffer)
Get the MemBuffers current offset.
Definition: util-buffer.h:56
Flow_::alproto
AppProto alproto
application level protocol
Definition: flow.h:455
Packet_::dp
Port dp
Definition: decode.h:531
SCCalloc
#define SCCalloc(nm, sz)
Definition: util-mem.h:53
TCP_GET_RAW_ACK
#define TCP_GET_RAW_ACK(tcph)
Definition: decode-tcp.h:81
SCConfNode_
Definition: conf.h:37
OutputPacketLoggerFunctions_
Definition: output.h:86
flow-var.h
FlowVar_
Definition: flow-var.h:55
DEBUG_VALIDATE_BUG_ON
#define DEBUG_VALIDATE_BUG_ON(exp)
Definition: util-validate.h:109
TCPHdr_
Definition: decode-tcp.h:149
VAR_TYPE_PKT_VAR
@ VAR_TYPE_PKT_VAR
Definition: util-var.h:33
Flow_::tosrcpktcnt
uint32_t tosrcpktcnt
Definition: flow.h:501
CreateTimeString
void CreateTimeString(const SCTime_t ts, char *str, size_t size)
Definition: util-time.c:272
MemBufferCreateNew
MemBuffer * MemBufferCreateNew(uint32_t size)
Definition: util-buffer.c:32
FlowVar_::datatype
uint8_t datatype
Definition: flow-var.h:57
output.h
PktVar_::id
uint32_t id
Definition: decode.h:315
PacketEngineEvents_::cnt
uint8_t cnt
Definition: decode.h:310