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 #include "suricata.h"
26 
27 #include "detect.h"
28 #include "flow.h"
29 #include "conf.h"
30 #include "stream.h"
31 #include "app-layer-protos.h"
32 
33 #include "threads.h"
34 #include "threadvars.h"
35 #include "tm-threads.h"
36 
37 #include "util-print.h"
38 
39 #include "pkt-var.h"
40 
41 #include "util-unittest.h"
42 
43 #include "util-debug.h"
44 #include "util-validate.h"
45 #include "util-buffer.h"
46 
47 #include "output.h"
48 #include "alert-debuglog.h"
49 #include "util-privs.h"
50 #include "flow-var.h"
51 #include "flow-bit.h"
52 #include "util-var-name.h"
53 #include "util-optimize.h"
54 #include "util-logopenfile.h"
55 #include "util-time.h"
56 
57 #include "stream-tcp-reassemble.h"
58 
59 #define DEFAULT_LOG_FILENAME "alert-debug.log"
60 
61 #define MODULE_NAME "AlertDebugLog"
62 
63 typedef struct AlertDebugLogThread_ {
65  /** LogFileCtx has the pointer to the file and a mutex to allow multithreading */
68 
69 /**
70  * \brief Function to log the FlowVars into alert-debug.log
71  *
72  * \param aft Pointer to AlertDebugLog Thread
73  * \param p Pointer to the packet
74  *
75  */
76 static void AlertDebugLogFlowVars(AlertDebugLogThread *aft, const Packet *p)
77 {
78  const GenericVar *gv = p->flow->flowvar;
79  uint16_t i;
80  while (gv != NULL) {
81  if (gv->type == DETECT_FLOWBITS) {
82  FlowBit *fb = (FlowBit *)gv;
83  const char *fbname = VarNameStoreLookupById(fb->idx, VAR_TYPE_FLOW_BIT);
84  if (fbname) {
85  MemBufferWriteString(aft->buffer, "FLOWBIT: %s\n",
86  fbname);
87  }
88  } else if (gv->type == DETECT_FLOWVAR || gv->type == DETECT_FLOWINT) {
89  FlowVar *fv = (FlowVar *) gv;
90 
91  if (fv->datatype == FLOWVAR_TYPE_STR) {
92  const char *fvname = VarNameStoreLookupById(fv->idx,
94  MemBufferWriteString(aft->buffer, "FLOWVAR: \"%s\" => \"",
95  fvname);
96  for (i = 0; i < fv->data.fv_str.value_len; i++) {
97  if (isprint(fv->data.fv_str.value[i])) {
98  MemBufferWriteString(aft->buffer, "%c",
99  fv->data.fv_str.value[i]);
100  } else {
101  MemBufferWriteString(aft->buffer, "\\%02X",
102  fv->data.fv_str.value[i]);
103  }
104  }
105  MemBufferWriteString(aft->buffer, "\"\n");
106  } else if (fv->datatype == FLOWVAR_TYPE_INT) {
107  const char *fvname = VarNameStoreLookupById(fv->idx,
109  MemBufferWriteString(aft->buffer, "FLOWINT: \"%s\" =>"
110  " %"PRIu32"\n", fvname, fv->data.fv_int.value);
111  }
112  }
113  gv = gv->next;
114  }
115 }
116 
117 /**
118  * \brief Function to log the PktVars into alert-debug.log
119  *
120  * \param aft Pointer to AlertDebugLog Thread
121  * \param p Pointer to the packet
122  *
123  */
124 static void AlertDebugLogPktVars(AlertDebugLogThread *aft, const Packet *p)
125 {
126  const PktVar *pv = p->pktvar;
127 
128  while (pv != NULL) {
129  const char *varname = VarNameStoreLookupById(pv->id, VAR_TYPE_PKT_VAR);
130  MemBufferWriteString(aft->buffer, "PKTVAR: %s\n", varname);
132  pv->value, pv->value_len);
133  pv = pv->next;
134  }
135 }
136 
137 /** \todo doc
138  * assume we have aft lock */
139 static int AlertDebugPrintStreamSegmentCallback(
140  const Packet *p, TcpSegment *seg, void *data, const uint8_t *buf, uint32_t buflen)
141 {
143 
144  MemBufferWriteString(aft->buffer, "STREAM DATA LEN: %"PRIu32"\n", buflen);
145  MemBufferWriteString(aft->buffer, "STREAM DATA:\n");
146 
148  buf, buflen);
149 
150  return 1;
151 }
152 
153 static TmEcode AlertDebugLogger(ThreadVars *tv, const Packet *p, void *thread_data)
154 {
155  AlertDebugLogThread *aft = (AlertDebugLogThread *)thread_data;
156  int i;
157  char timebuf[64];
158  const char *pkt_src_str = NULL;
159 
160  if (p->alerts.cnt == 0)
161  return TM_ECODE_OK;
162 
163  MemBufferReset(aft->buffer);
164 
165  CreateTimeString(p->ts, timebuf, sizeof(timebuf));
166 
167  MemBufferWriteString(aft->buffer, "+================\n"
168  "TIME: %s\n", timebuf);
169  if (p->pcap_cnt > 0) {
170  MemBufferWriteString(aft->buffer, "PCAP PKT NUM: %"PRIu64"\n", p->pcap_cnt);
171  }
172  pkt_src_str = PktSrcToString(p->pkt_src);
173  MemBufferWriteString(aft->buffer, "PKT SRC: %s\n", pkt_src_str);
174 
175  char srcip[46], dstip[46];
176  if (PKT_IS_IPV4(p)) {
177  PrintInet(AF_INET, (const void *)GET_IPV4_SRC_ADDR_PTR(p), srcip, sizeof(srcip));
178  PrintInet(AF_INET, (const void *)GET_IPV4_DST_ADDR_PTR(p), dstip, sizeof(dstip));
179  } else {
181  PrintInet(AF_INET6, (const void *)GET_IPV6_SRC_ADDR(p), srcip, sizeof(srcip));
182  PrintInet(AF_INET6, (const void *)GET_IPV6_DST_ADDR(p), dstip, sizeof(dstip));
183  }
184 
185  MemBufferWriteString(aft->buffer, "SRC IP: %s\n"
186  "DST IP: %s\n"
187  "PROTO: %" PRIu32 "\n",
188  srcip, dstip, p->proto);
189  if (PKT_IS_TCP(p) || PKT_IS_UDP(p)) {
190  MemBufferWriteString(aft->buffer, "SRC PORT: %" PRIu32 "\n"
191  "DST PORT: %" PRIu32 "\n",
192  p->sp, p->dp);
193  if (PKT_IS_TCP(p)) {
194  MemBufferWriteString(aft->buffer, "TCP SEQ: %"PRIu32"\n"
195  "TCP ACK: %"PRIu32"\n",
196  TCP_GET_SEQ(p), TCP_GET_ACK(p));
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",
214  p->flow->todstpktcnt, p->flow->tosrcpktcnt,
215  p->flow->todstbytecnt + p->flow->tosrcbytecnt);
217  "FLOW IPONLY SET: TOSERVER: %s, TOCLIENT: %s\n"
218  "FLOW ACTION: DROP: %s\n"
219  "FLOW NOINSPECTION: PACKET: %s, PAYLOAD: %s, APP_LAYER: %s\n"
220  "FLOW APP_LAYER: DETECTED: %s, PROTO %"PRIu16"\n",
221  p->flow->flags & FLOW_TOSERVER_IPONLY_SET ? "TRUE" : "FALSE",
222  p->flow->flags & FLOW_TOCLIENT_IPONLY_SET ? "TRUE" : "FALSE",
223  p->flow->flags & FLOW_ACTION_DROP ? "TRUE" : "FALSE",
224  p->flow->flags & FLOW_NOPACKET_INSPECTION ? "TRUE" : "FALSE",
225  p->flow->flags & FLOW_NOPAYLOAD_INSPECTION ? "TRUE" : "FALSE",
226  applayer ? "TRUE" : "FALSE",
227  (p->flow->alproto != ALPROTO_UNKNOWN) ? "TRUE" : "FALSE", p->flow->alproto);
228  AlertDebugLogFlowVars(aft, p);
229  }
230 
231  AlertDebugLogPktVars(aft, p);
232 
233 /* any stuff */
234 /* Sig details? */
235 
237  "PACKET LEN: %" PRIu32 "\n"
238  "PACKET:\n",
239  GET_PKT_LEN(p));
241  GET_PKT_DATA(p), GET_PKT_LEN(p));
242 
243  MemBufferWriteString(aft->buffer, "ALERT CNT: %" PRIu32 "\n",
244  p->alerts.cnt);
245 
246  for (i = 0; i < p->alerts.cnt; i++) {
247  const PacketAlert *pa = &p->alerts.alerts[i];
248  if (unlikely(pa->s == NULL)) {
249  continue;
250  }
251 
253  "ALERT MSG [%02d]: %s\n"
254  "ALERT GID [%02d]: %" PRIu32 "\n"
255  "ALERT SID [%02d]: %" PRIu32 "\n"
256  "ALERT REV [%02d]: %" PRIu32 "\n"
257  "ALERT CLASS [%02d]: %s\n"
258  "ALERT PRIO [%02d]: %" PRIu32 "\n"
259  "ALERT FOUND IN [%02d]: %s\n",
260  i, pa->s->msg,
261  i, pa->s->gid,
262  i, pa->s->id,
263  i, pa->s->rev,
264  i, pa->s->class_msg ? pa->s->class_msg : "<none>",
265  i, pa->s->prio,
266  i,
267  pa->flags & PACKET_ALERT_FLAG_STREAM_MATCH ? "STREAM" :
268  (pa->flags & PACKET_ALERT_FLAG_STATE_MATCH ? "STATE" : "PACKET"));
269  if (pa->flags & PACKET_ALERT_FLAG_TX) {
271  "ALERT IN TX [%02d]: %"PRIu64"\n", i, pa->tx_id);
272  } else {
274  "ALERT IN TX [%02d]: N/A\n", i);
275  }
276  if (p->payload_len > 0) {
278  "PAYLOAD LEN: %" PRIu32 "\n"
279  "PAYLOAD:\n",
280  p->payload_len);
282  p->payload, p->payload_len);
283  }
284  if ((pa->flags & PACKET_ALERT_FLAG_STATE_MATCH) ||
286  /* This is an app layer or stream alert */
287  int ret;
288  uint8_t flag;
289  if (!(PKT_IS_TCP(p)) || p->flow == NULL ||
290  p->flow->protoctx == NULL) {
291  return TM_ECODE_OK;
292  }
293  /* IDS mode reverse the data */
294  /** \todo improve the order selection policy */
295  if (p->flowflags & FLOW_PKT_TOSERVER) {
296  flag = STREAM_DUMP_TOCLIENT;
297  } else {
298  flag = STREAM_DUMP_TOSERVER;
299  }
300  ret = StreamSegmentForEach((const Packet *)p, flag,
301  AlertDebugPrintStreamSegmentCallback,
302  (void *)aft);
303  if (ret < 0) {
304  return TM_ECODE_FAILED;
305  }
306  }
307  }
308 
309  aft->file_ctx->Write((const char *)MEMBUFFER_BUFFER(aft->buffer),
310  MEMBUFFER_OFFSET(aft->buffer), aft->file_ctx);
311 
312  return TM_ECODE_OK;
313 }
314 
315 static TmEcode AlertDebugLogDecoderEvent(ThreadVars *tv, const Packet *p, void *thread_data)
316 {
317  AlertDebugLogThread *aft = (AlertDebugLogThread *)thread_data;
318  int i;
319  char timebuf[64];
320  const char *pkt_src_str = NULL;
321 
322  if (p->alerts.cnt == 0)
323  return TM_ECODE_OK;
324 
325  MemBufferReset(aft->buffer);
326 
327  CreateTimeString(p->ts, timebuf, sizeof(timebuf));
328 
330  "+================\n"
331  "TIME: %s\n", timebuf);
332  if (p->pcap_cnt > 0) {
334  "PCAP PKT NUM: %"PRIu64"\n", p->pcap_cnt);
335  }
336  pkt_src_str = PktSrcToString(p->pkt_src);
337  MemBufferWriteString(aft->buffer, "PKT SRC: %s\n", pkt_src_str);
339  "ALERT CNT: %" PRIu32 "\n", p->alerts.cnt);
340 
341  for (i = 0; i < p->alerts.cnt; i++) {
342  const PacketAlert *pa = &p->alerts.alerts[i];
343  if (unlikely(pa->s == NULL)) {
344  continue;
345  }
346 
348  "ALERT MSG [%02d]: %s\n"
349  "ALERT GID [%02d]: %" PRIu32 "\n"
350  "ALERT SID [%02d]: %" PRIu32 "\n"
351  "ALERT REV [%02d]: %" PRIu32 "\n"
352  "ALERT CLASS [%02d]: %s\n"
353  "ALERT PRIO [%02d]: %" PRIu32 "\n",
354  i, pa->s->msg,
355  i, pa->s->gid,
356  i, pa->s->id,
357  i, pa->s->rev,
358  i, pa->s->class_msg,
359  i, pa->s->prio);
360  }
361 
363  "PACKET LEN: %" PRIu32 "\n"
364  "PACKET:\n",
365  GET_PKT_LEN(p));
367  GET_PKT_DATA(p), GET_PKT_LEN(p));
368 
369  aft->file_ctx->Write((const char *)MEMBUFFER_BUFFER(aft->buffer),
370  MEMBUFFER_OFFSET(aft->buffer), aft->file_ctx);
371 
372  return TM_ECODE_OK;
373 }
374 
375 static TmEcode AlertDebugLogThreadInit(ThreadVars *t, const void *initdata, void **data)
376 {
378  if (unlikely(aft == NULL))
379  return TM_ECODE_FAILED;
380 
381  if(initdata == NULL)
382  {
383  SCLogDebug("Error getting context for AlertDebugLog. \"initdata\" argument NULL");
384  SCFree(aft);
385  return TM_ECODE_FAILED;
386  }
387  /** Use the Output Context (file pointer and mutex) */
388  aft->file_ctx = ((OutputCtx *)initdata)->data;
389 
390  /* 1 mb seems sufficient enough */
391  aft->buffer = MemBufferCreateNew(1 * 1024 * 1024);
392  if (aft->buffer == NULL) {
393  SCFree(aft);
394  return TM_ECODE_FAILED;
395  }
396 
397  *data = (void *)aft;
398  return TM_ECODE_OK;
399 }
400 
401 static TmEcode AlertDebugLogThreadDeinit(ThreadVars *t, void *data)
402 {
404  if (aft == NULL) {
405  return TM_ECODE_OK;
406  }
407 
408  MemBufferFree(aft->buffer);
409  /* clear memory */
410  memset(aft, 0, sizeof(AlertDebugLogThread));
411 
412  SCFree(aft);
413  return TM_ECODE_OK;
414 }
415 
416 static void AlertDebugLogDeInitCtx(OutputCtx *output_ctx)
417 {
418  if (output_ctx != NULL) {
419  LogFileCtx *logfile_ctx = (LogFileCtx *)output_ctx->data;
420  if (logfile_ctx != NULL) {
421  LogFileFreeCtx(logfile_ctx);
422  }
423  SCFree(output_ctx);
424  }
425 }
426 
427 /**
428  * \brief Create a new LogFileCtx for alert debug logging.
429  *
430  * \param ConfNode containing configuration for this logger.
431  *
432  * \return output_ctx if succesful, NULL otherwise
433  */
434 static OutputInitResult AlertDebugLogInitCtx(ConfNode *conf)
435 {
436  OutputInitResult result = { NULL, false };
437  LogFileCtx *file_ctx = NULL;
438 
439  file_ctx = LogFileNewCtx();
440  if (file_ctx == NULL) {
441  SCLogDebug("couldn't create new file_ctx");
442  goto error;
443  }
444 
445  if (SCConfLogOpenGeneric(conf, file_ctx, DEFAULT_LOG_FILENAME, 1) < 0) {
446  goto error;
447  }
448 
449  OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
450  if (unlikely(output_ctx == NULL))
451  goto error;
452 
453  output_ctx->data = file_ctx;
454  output_ctx->DeInit = AlertDebugLogDeInitCtx;
455 
456  SCLogDebug("Alert debug log output initialized");
457  result.ctx = output_ctx;
458  result.ok = true;
459  return result;
460 
461 error:
462  if (file_ctx != NULL) {
463  LogFileFreeCtx(file_ctx);
464  }
465 
466  return result;
467 }
468 
469 static bool AlertDebugLogCondition(ThreadVars *tv, void *thread_data, const Packet *p)
470 {
471  return (p->alerts.cnt > 0);
472 }
473 
474 static int AlertDebugLogLogger(ThreadVars *tv, void *thread_data, const Packet *p)
475 {
476  if (PKT_IS_IPV4(p) || PKT_IS_IPV6(p)) {
477  return AlertDebugLogger(tv, p, thread_data);
478  } else if (p->events.cnt > 0) {
479  return AlertDebugLogDecoderEvent(tv, p, thread_data);
480  }
481  return TM_ECODE_OK;
482 }
483 
485 {
487  AlertDebugLogInitCtx, AlertDebugLogLogger, AlertDebugLogCondition,
488  AlertDebugLogThreadInit, AlertDebugLogThreadDeinit, NULL);
489 }
PKT_IS_UDP
#define PKT_IS_UDP(p)
Definition: decode.h:249
GenericVar_::type
uint8_t type
Definition: util-var.h:49
tm-threads.h
Packet_::proto
uint8_t proto
Definition: decode.h:459
PACKET_ALERT_FLAG_STREAM_MATCH
#define PACKET_ALERT_FLAG_STREAM_MATCH
Definition: decode.h:278
PacketAlert_::s
const struct Signature_ * s
Definition: decode.h:268
AlertDebugLogThread_::buffer
MemBuffer * buffer
Definition: alert-debuglog.c:66
MemBuffer_::buffer
uint8_t buffer[]
Definition: util-buffer.h:30
STREAM_DUMP_TOSERVER
#define STREAM_DUMP_TOSERVER
Definition: stream.h:33
alert-debuglog.h
PACKET_ALERT_FLAG_TX
#define PACKET_ALERT_FLAG_TX
Definition: decode.h:280
AlertDebugLogThread_
Definition: alert-debuglog.c:63
Flow_::startts
SCTime_t startts
Definition: flow.h:490
PKT_IS_IPV6
#define PKT_IS_IPV6(p)
Definition: decode.h:247
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
LogFileNewCtx
LogFileCtx * LogFileNewCtx(void)
LogFileNewCtx() Get a new LogFileCtx.
Definition: util-logopenfile.c:659
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:269
Packet_::pcap_cnt
uint64_t pcap_cnt
Definition: decode.h:607
FlowVar_::data
union FlowVar_::@112 data
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:586
PacketAlerts_::cnt
uint16_t cnt
Definition: decode.h:290
FlowVarTypeStr::value_len
uint16_t value_len
Definition: flow-var.h:39
FLOWVAR_TYPE_STR
#define FLOWVAR_TYPE_STR
Definition: flow-var.h:33
threads.h
LogFileCtx_
Definition: util-logopenfile.h:76
PktVar_::next
struct PktVar_ * next
Definition: decode.h:315
FlowVar_::fv_str
FlowVarTypeStr fv_str
Definition: flow-var.h:57
FLOW_NOPAYLOAD_INSPECTION
#define FLOW_NOPAYLOAD_INSPECTION
Definition: flow.h:64
PacketAlerts_::alerts
PacketAlert * alerts
Definition: decode.h:293
flow-bit.h
FLOW_PKT_TOSERVER
#define FLOW_PKT_TOSERVER
Definition: flow.h:223
util-var-name.h
util-privs.h
LogFileCtx_::Write
int(* Write)(const char *buffer, int buffer_len, struct LogFileCtx_ *fp)
Definition: util-logopenfile.h:91
stream-tcp-reassemble.h
FLOW_ACTION_DROP
#define FLOW_ACTION_DROP
Definition: flow.h:67
FLOWVAR_TYPE_INT
#define FLOWVAR_TYPE_INT
Definition: flow-var.h:34
Packet_::flowflags
uint8_t flowflags
Definition: decode.h:468
TM_ECODE_FAILED
@ TM_ECODE_FAILED
Definition: tm-threads-common.h:85
Flow_::protoctx
void * protoctx
Definition: flow.h:441
Packet_::payload_len
uint16_t payload_len
Definition: decode.h:587
GET_IPV6_DST_ADDR
#define GET_IPV6_DST_ADDR(p)
Definition: decode.h:216
Packet_::alerts
PacketAlerts alerts
Definition: decode.h:601
Packet_::events
PacketEngineEvents events
Definition: decode.h:611
util-unittest.h
MemBuffer_::offset
uint32_t offset
Definition: util-buffer.h:29
OutputCtx_::data
void * data
Definition: tm-modules.h:88
TM_ECODE_OK
@ TM_ECODE_OK
Definition: tm-threads-common.h:84
PacketAlert_::tx_id
uint64_t tx_id
Definition: decode.h:269
OutputCtx_
Definition: tm-modules.h:85
SCConfLogOpenGeneric
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
Definition: util-logopenfile.c:452
Signature_::gid
uint32_t gid
Definition: detect.h:632
FlowVar_::fv_int
FlowVarTypeInt fv_int
Definition: flow-var.h:58
MODULE_NAME
#define MODULE_NAME
Definition: alert-debuglog.c:61
Flow_::tosrcbytecnt
uint64_t tosrcbytecnt
Definition: flow.h:495
PKT_IS_TCP
#define PKT_IS_TCP(p)
Definition: decode.h:248
util-debug.h
StreamTcpAppLayerIsDisabled
int StreamTcpAppLayerIsDisabled(Flow *f)
Definition: stream-tcp-reassemble.c:462
Packet_::pktvar
PktVar * pktvar
Definition: decode.h:535
GenericVar_::next
struct GenericVar_ * next
Definition: util-var.h:52
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:151
GET_IPV4_DST_ADDR_PTR
#define GET_IPV4_DST_ADDR_PTR(p)
Definition: decode.h:211
DETECT_FLOWINT
@ DETECT_FLOWINT
Definition: detect-engine-register.h:87
OutputInitResult_::ctx
OutputCtx * ctx
Definition: output.h:47
DETECT_FLOWVAR
@ DETECT_FLOWVAR
Definition: detect-engine-register.h:85
Flow_::todstpktcnt
uint32_t todstpktcnt
Definition: flow.h:492
Packet_::ts
SCTime_t ts
Definition: decode.h:485
FlowVar_::idx
uint32_t idx
Definition: flow-var.h:52
PktVar_::value
uint8_t * value
Definition: decode.h:321
util-print.h
GET_PKT_DATA
#define GET_PKT_DATA(p)
Definition: decode.h:221
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:241
pkt-var.h
Packet_::sp
Port sp
Definition: decode.h:444
PktSrcToString
const char * PktSrcToString(enum PktSrcEnum pkt_src)
Definition: decode.c:820
util-time.h
OutputInitResult_::ok
bool ok
Definition: output.h:48
Flow_::todstbytecnt
uint64_t todstbytecnt
Definition: flow.h:494
TCP_GET_SEQ
#define TCP_GET_SEQ(p)
Definition: decode-tcp.h:114
stream.h
TcpSegment
Definition: stream-tcp-private.h:72
Packet_
Definition: decode.h:437
GET_PKT_LEN
#define GET_PKT_LEN(p)
Definition: decode.h:220
conf.h
FLOW_TOSERVER_IPONLY_SET
#define FLOW_TOSERVER_IPONLY_SET
Definition: flow.h:57
TmEcode
TmEcode
Definition: tm-threads-common.h:83
MemBuffer_
Definition: util-buffer.h:27
FLOW_PKT_TOCLIENT
#define FLOW_PKT_TOCLIENT
Definition: flow.h:224
DEFAULT_LOG_FILENAME
#define DEFAULT_LOG_FILENAME
Definition: alert-debuglog.c:59
FlowVarTypeInt_::value
uint32_t value
Definition: flow-var.h:44
Flow_::flowvar
GenericVar * flowvar
Definition: flow.h:486
Signature_::class_msg
char * class_msg
Definition: detect.h:657
PacketAlert_::flags
uint8_t flags
Definition: decode.h:267
OutputInitResult_
Definition: output.h:46
FlowVarTypeStr::value
uint8_t * value
Definition: flow-var.h:38
Packet_::flow
struct Flow_ * flow
Definition: decode.h:476
VAR_TYPE_FLOW_BIT
@ VAR_TYPE_FLOW_BIT
Definition: util-var.h:35
GET_IPV4_SRC_ADDR_PTR
#define GET_IPV4_SRC_ADDR_PTR(p)
Definition: decode.h:210
FLOW_TOCLIENT_IPONLY_SET
#define FLOW_TOCLIENT_IPONLY_SET
Definition: flow.h:59
suricata-common.h
OutputCtx_::DeInit
void(* DeInit)(struct OutputCtx_ *)
Definition: tm-modules.h:91
VarNameStoreLookupById
const char * VarNameStoreLookupById(const uint32_t id, const enum VarTypes type)
find name for id+type at packet time.
Definition: util-var-name.c:305
GenericVar_
Definition: util-var.h:48
MemBufferFree
void MemBufferFree(MemBuffer *buffer)
Definition: util-buffer.c:81
Signature_::rev
uint32_t rev
Definition: detect.h:633
LogFileFreeCtx
int LogFileFreeCtx(LogFileCtx *lf_ctx)
LogFileFreeCtx() Destroy a LogFileCtx (Close the file and free memory)
Definition: util-logopenfile.c:868
LOGGER_ALERT_DEBUG
@ LOGGER_ALERT_DEBUG
Definition: suricata-common.h:476
FlowBit_::idx
uint32_t idx
Definition: flow-bit.h:33
AlertDebugLogThread_::file_ctx
LogFileCtx * file_ctx
Definition: alert-debuglog.c:64
DETECT_FLOWBITS
@ DETECT_FLOWBITS
Definition: detect-engine-register.h:90
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:32
Signature_::prio
int prio
Definition: detect.h:634
util-optimize.h
OutputRegisterPacketModule
void OutputRegisterPacketModule(LoggerId id, const char *name, const char *conf_name, OutputInitFunc InitFunc, PacketLogger PacketLogFunc, PacketLogCondition PacketConditionFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
Register a packet output module.
Definition: output.c:169
threadvars.h
util-validate.h
FlowBit_
Definition: flow-bit.h:30
GET_IPV6_SRC_ADDR
#define GET_IPV6_SRC_ADDR(p)
Definition: decode.h:215
SCFree
#define SCFree(p)
Definition: util-mem.h:61
Packet_::pkt_src
uint8_t pkt_src
Definition: decode.h:592
ConfNode_
Definition: conf.h:32
util-logopenfile.h
Signature_::id
uint32_t id
Definition: detect.h:631
Flow_::flags
uint32_t flags
Definition: flow.h:421
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:37
VAR_TYPE_FLOW_INT
@ VAR_TYPE_FLOW_INT
Definition: util-var.h:36
ALPROTO_UNKNOWN
@ ALPROTO_UNKNOWN
Definition: app-layer-protos.h:29
PktVar_::value_len
uint16_t value_len
Definition: decode.h:319
AlertDebugLogThread
struct AlertDebugLogThread_ AlertDebugLogThread
app-layer-protos.h
suricata.h
PacketAlert_
Definition: decode.h:264
MemBufferWriteString
void MemBufferWriteString(MemBuffer *dst, const char *fmt,...)
Definition: util-buffer.c:127
PktVar_
Definition: decode.h:313
MemBuffer_::size
uint32_t size
Definition: util-buffer.h:28
TCP_GET_ACK
#define TCP_GET_ACK(p)
Definition: decode-tcp.h:115
FLOW_NOPACKET_INSPECTION
#define FLOW_NOPACKET_INSPECTION
Definition: flow.h:62
MEMBUFFER_BUFFER
#define MEMBUFFER_BUFFER(mem_buffer)
Get the MemBuffers underlying buffer.
Definition: util-buffer.h:51
Signature_::msg
char * msg
Definition: detect.h:654
flow.h
AlertDebugLogRegister
void AlertDebugLogRegister(void)
Definition: alert-debuglog.c:484
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:450
Packet_::dp
Port dp
Definition: decode.h:452
SCCalloc
#define SCCalloc(nm, sz)
Definition: util-mem.h:53
flow-var.h
PKT_IS_IPV4
#define PKT_IS_IPV4(p)
Definition: decode.h:246
PACKET_ALERT_FLAG_STATE_MATCH
#define PACKET_ALERT_FLAG_STATE_MATCH
Definition: decode.h:276
FlowVar_
Definition: flow-var.h:48
DEBUG_VALIDATE_BUG_ON
#define DEBUG_VALIDATE_BUG_ON(exp)
Definition: util-validate.h:103
VAR_TYPE_PKT_VAR
@ VAR_TYPE_PKT_VAR
Definition: util-var.h:32
Flow_::tosrcpktcnt
uint32_t tosrcpktcnt
Definition: flow.h:493
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:50
output.h
PktVar_::id
uint32_t id
Definition: decode.h:314
PacketEngineEvents_::cnt
uint8_t cnt
Definition: decode.h:309