suricata
output-json-drop.c
Go to the documentation of this file.
1 /* Copyright (C) 2007-2013 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 Tom DeCanio <td@npulsetech.com>
22  *
23  * JSON Drop log module to log the dropped packet information
24  *
25  */
26 
27 #include "suricata-common.h"
28 #include "debug.h"
29 #include "detect.h"
30 #include "flow.h"
31 #include "conf.h"
32 
33 #include "threads.h"
34 #include "tm-threads.h"
35 #include "threadvars.h"
36 #include "util-debug.h"
37 
38 #include "decode-ipv4.h"
39 #include "detect-parse.h"
40 #include "detect-engine.h"
41 #include "detect-engine-mpm.h"
42 #include "detect-reference.h"
43 
44 #include "output.h"
45 #include "output-json.h"
46 #include "output-json-alert.h"
47 #include "output-json-drop.h"
48 
49 #include "util-unittest.h"
50 #include "util-unittest-helper.h"
52 #include "util-privs.h"
53 #include "util-print.h"
54 #include "util-proto-name.h"
55 #include "util-logopenfile.h"
56 #include "util-time.h"
57 #include "util-buffer.h"
58 
59 #define MODULE_NAME "JsonDropLog"
60 
61 #define LOG_DROP_ALERTS 1
62 
63 typedef struct JsonDropOutputCtx_ {
65  uint8_t flags;
68 
69 typedef struct JsonDropLogThread_ {
73 
74 /* default to true as this has been the default behavior for a long time */
75 static int g_droplog_flows_start = 1;
76 
77 /**
78  * \brief Log the dropped packets in netfilter format when engine is running
79  * in inline mode
80  *
81  * \param tv Pointer the current thread variables
82  * \param p Pointer the packet which is being logged
83  *
84  * \return return TM_EODE_OK on success
85  */
86 static int DropLogJSON (JsonDropLogThread *aft, const Packet *p)
87 {
88  JsonDropOutputCtx *drop_ctx = aft->drop_ctx;
89 
92 
93  JsonBuilder *js = CreateEveHeader(p, LOG_DIR_PACKET, "drop", &addr);
94  if (unlikely(js == NULL))
95  return TM_ECODE_OK;
96 
97  EveAddCommonOptions(&drop_ctx->cfg, p, p->flow, js);
98 
99  jb_open_object(js, "drop");
100 
101  /* reset */
102  MemBufferReset(aft->buffer);
103 
104  uint16_t proto = 0;
105  if (PKT_IS_IPV4(p)) {
106  jb_set_uint(js, "len", IPV4_GET_IPLEN(p));
107  jb_set_uint(js, "tos", IPV4_GET_IPTOS(p));
108  jb_set_uint(js, "ttl", IPV4_GET_IPTTL(p));
109  jb_set_uint(js, "ipid", IPV4_GET_IPID(p));
110  proto = IPV4_GET_IPPROTO(p);
111  } else if (PKT_IS_IPV6(p)) {
112  jb_set_uint(js, "len", IPV6_GET_PLEN(p));
113  jb_set_uint(js, "tc", IPV6_GET_CLASS(p));
114  jb_set_uint(js, "hoplimit", IPV6_GET_HLIM(p));
115  jb_set_uint(js, "flowlbl", IPV6_GET_FLOW(p));
116  proto = IPV6_GET_L4PROTO(p);
117  }
118  switch (proto) {
119  case IPPROTO_TCP:
120  if (PKT_IS_TCP(p)) {
121  jb_set_uint(js, "tcpseq", TCP_GET_SEQ(p));
122  jb_set_uint(js, "tcpack", TCP_GET_ACK(p));
123  jb_set_uint(js, "tcpwin", TCP_GET_WINDOW(p));
124  jb_set_bool(js, "syn", TCP_ISSET_FLAG_SYN(p) ? true : false);
125  jb_set_bool(js, "ack", TCP_ISSET_FLAG_ACK(p) ? true : false);
126  jb_set_bool(js, "psh", TCP_ISSET_FLAG_PUSH(p) ? true : false);
127  jb_set_bool(js, "rst", TCP_ISSET_FLAG_RST(p) ? true : false);
128  jb_set_bool(js, "urg", TCP_ISSET_FLAG_URG(p) ? true : false);
129  jb_set_bool(js, "fin", TCP_ISSET_FLAG_FIN(p) ? true : false);
130  jb_set_uint(js, "tcpres", TCP_GET_RAW_X2(p->tcph));
131  jb_set_uint(js, "tcpurgp", TCP_GET_URG_POINTER(p));
132  }
133  break;
134  case IPPROTO_UDP:
135  if (PKT_IS_UDP(p)) {
136  jb_set_uint(js, "udplen", UDP_GET_LEN(p));
137  }
138  break;
139  case IPPROTO_ICMP:
140  if (PKT_IS_ICMPV4(p)) {
141  jb_set_uint(js, "icmp_id", ICMPV4_GET_ID(p));
142  jb_set_uint(js, "icmp_seq", ICMPV4_GET_SEQ(p));
143  } else if(PKT_IS_ICMPV6(p)) {
144  jb_set_uint(js, "icmp_id", ICMPV6_GET_ID(p));
145  jb_set_uint(js, "icmp_seq", ICMPV6_GET_SEQ(p));
146  }
147  break;
148  }
149 
150  /* Close drop. */
151  jb_close(js);
152 
153  if (aft->drop_ctx->flags & LOG_DROP_ALERTS) {
154  int logged = 0;
155  int i;
156  for (i = 0; i < p->alerts.cnt; i++) {
157  const PacketAlert *pa = &p->alerts.alerts[i];
158  if (unlikely(pa->s == NULL)) {
159  continue;
160  }
162  ((pa->action & ACTION_DROP) && EngineModeIsIPS()))
163  {
164  AlertJsonHeader(NULL, p, pa, js, 0, &addr);
165  logged = 1;
166  }
167  }
168  if (logged == 0) {
169  if (p->alerts.drop.action != 0) {
170  const PacketAlert *pa = &p->alerts.drop;
171  AlertJsonHeader(NULL, p, pa, js, 0, &addr);
172  }
173  }
174  }
175 
177  jb_free(js);
178 
179  return TM_ECODE_OK;
180 }
181 
182 static TmEcode JsonDropLogThreadInit(ThreadVars *t, const void *initdata, void **data)
183 {
185  if (unlikely(aft == NULL))
186  return TM_ECODE_FAILED;
187  memset(aft, 0, sizeof(*aft));
188 
189  if(initdata == NULL)
190  {
191  SCLogDebug("Error getting context for EveLogDrop. \"initdata\" argument NULL");
192  SCFree(aft);
193  return TM_ECODE_FAILED;
194  }
195 
197  if (aft->buffer == NULL) {
198  SCFree(aft);
199  return TM_ECODE_FAILED;
200  }
201 
202  /** Use the Ouptut Context (file pointer and mutex) */
203  aft->drop_ctx = ((OutputCtx *)initdata)->data;
204 
205  *data = (void *)aft;
206  return TM_ECODE_OK;
207 }
208 
209 static TmEcode JsonDropLogThreadDeinit(ThreadVars *t, void *data)
210 {
211  JsonDropLogThread *aft = (JsonDropLogThread *)data;
212  if (aft == NULL) {
213  return TM_ECODE_OK;
214  }
215 
216  MemBufferFree(aft->buffer);
217 
218  /* clear memory */
219  memset(aft, 0, sizeof(*aft));
220 
221  SCFree(aft);
222  return TM_ECODE_OK;
223 }
224 
225 static void JsonDropOutputCtxFree(JsonDropOutputCtx *drop_ctx)
226 {
227  if (drop_ctx != NULL) {
228  if (drop_ctx->file_ctx != NULL)
229  LogFileFreeCtx(drop_ctx->file_ctx);
230  SCFree(drop_ctx);
231  }
232 }
233 
234 static void JsonDropLogDeInitCtx(OutputCtx *output_ctx)
235 {
237 
238  JsonDropOutputCtx *drop_ctx = output_ctx->data;
239  JsonDropOutputCtxFree(drop_ctx);
240  SCFree(output_ctx);
241 }
242 
243 static void JsonDropLogDeInitCtxSub(OutputCtx *output_ctx)
244 {
246 
247  JsonDropOutputCtx *drop_ctx = output_ctx->data;
248  SCFree(drop_ctx);
249  SCLogDebug("cleaning up sub output_ctx %p", output_ctx);
250  SCFree(output_ctx);
251 }
252 
253 #define DEFAULT_LOG_FILENAME "drop.json"
254 static OutputInitResult JsonDropLogInitCtx(ConfNode *conf)
255 {
256  OutputInitResult result = { NULL, false };
257  if (OutputDropLoggerEnable() != 0) {
258  SCLogError(SC_ERR_CONF_YAML_ERROR, "only one 'drop' logger "
259  "can be enabled");
260  return result;
261  }
262 
263  JsonDropOutputCtx *drop_ctx = SCCalloc(1, sizeof(*drop_ctx));
264  if (drop_ctx == NULL)
265  return result;
266 
267  drop_ctx->file_ctx = LogFileNewCtx();
268  if (drop_ctx->file_ctx == NULL) {
269  JsonDropOutputCtxFree(drop_ctx);
270  return result;
271  }
272 
273  if (SCConfLogOpenGeneric(conf, drop_ctx->file_ctx, DEFAULT_LOG_FILENAME, 1) < 0) {
274  JsonDropOutputCtxFree(drop_ctx);
275  return result;
276  }
277 
278  OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
279  if (unlikely(output_ctx == NULL)) {
280  JsonDropOutputCtxFree(drop_ctx);
281  return result;
282  }
283 
284  if (conf) {
285  const char *extended = ConfNodeLookupChildValue(conf, "alerts");
286  if (extended != NULL) {
287  if (ConfValIsTrue(extended)) {
288  drop_ctx->flags = LOG_DROP_ALERTS;
289  }
290  }
291  extended = ConfNodeLookupChildValue(conf, "flows");
292  if (extended != NULL) {
293  if (strcasecmp(extended, "start") == 0) {
294  g_droplog_flows_start = 1;
295  } else if (strcasecmp(extended, "all") == 0) {
296  g_droplog_flows_start = 0;
297  } else {
298  SCLogWarning(SC_ERR_CONF_YAML_ERROR, "valid options for "
299  "'flow' are 'start' and 'all'");
300  }
301  }
302  }
303 
304  output_ctx->data = drop_ctx;
305  output_ctx->DeInit = JsonDropLogDeInitCtx;
306 
307  result.ctx = output_ctx;
308  result.ok = true;
309  return result;
310 }
311 
312 static OutputInitResult JsonDropLogInitCtxSub(ConfNode *conf, OutputCtx *parent_ctx)
313 {
314  OutputInitResult result = { NULL, false };
315  if (OutputDropLoggerEnable() != 0) {
316  SCLogError(SC_ERR_CONF_YAML_ERROR, "only one 'drop' logger "
317  "can be enabled");
318  return result;
319  }
320 
321  OutputJsonCtx *ajt = parent_ctx->data;
322 
323  JsonDropOutputCtx *drop_ctx = SCCalloc(1, sizeof(*drop_ctx));
324  if (drop_ctx == NULL)
325  return result;
326 
327  OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
328  if (unlikely(output_ctx == NULL)) {
329  JsonDropOutputCtxFree(drop_ctx);
330  return result;
331  }
332 
333  if (conf) {
334  const char *extended = ConfNodeLookupChildValue(conf, "alerts");
335  if (extended != NULL) {
336  if (ConfValIsTrue(extended)) {
337  drop_ctx->flags = LOG_DROP_ALERTS;
338  }
339  }
340  extended = ConfNodeLookupChildValue(conf, "flows");
341  if (extended != NULL) {
342  if (strcasecmp(extended, "start") == 0) {
343  g_droplog_flows_start = 1;
344  } else if (strcasecmp(extended, "all") == 0) {
345  g_droplog_flows_start = 0;
346  } else {
347  SCLogWarning(SC_ERR_CONF_YAML_ERROR, "valid options for "
348  "'flow' are 'start' and 'all'");
349  }
350  }
351  }
352 
353  drop_ctx->file_ctx = ajt->file_ctx;
354  drop_ctx->cfg = ajt->cfg;
355 
356  output_ctx->data = drop_ctx;
357  output_ctx->DeInit = JsonDropLogDeInitCtxSub;
358 
359  result.ctx = output_ctx;
360  result.ok = true;
361  return result;
362 }
363 
364 /**
365  * \brief Log the dropped packets when engine is running in inline mode
366  *
367  * \param tv Pointer the current thread variables
368  * \param data Pointer to the droplog struct
369  * \param p Pointer the packet which is being logged
370  *
371  * \retval 0 on succes
372  */
373 static int JsonDropLogger(ThreadVars *tv, void *thread_data, const Packet *p)
374 {
375  JsonDropLogThread *td = thread_data;
376  int r = DropLogJSON(td, p);
377  if (r < 0)
378  return -1;
379 
380  if (!g_droplog_flows_start)
381  return 0;
382 
383  if (p->flow) {
384  if (p->flow->flags & FLOW_ACTION_DROP) {
387  else if (PKT_IS_TOCLIENT(p) && !(p->flow->flags & FLOW_TOCLIENT_DROP_LOGGED))
389  }
390  }
391  return 0;
392 }
393 
394 
395 /**
396  * \brief Check if we need to drop-log this packet
397  *
398  * \param tv Pointer the current thread variables
399  * \param p Pointer the packet which is tested
400  *
401  * \retval bool TRUE or FALSE
402  */
403 static int JsonDropLogCondition(ThreadVars *tv, const Packet *p)
404 {
405  if (!EngineModeIsIPS()) {
406  SCLogDebug("engine is not running in inline mode, so returning");
407  return FALSE;
408  }
409  if (PKT_IS_PSEUDOPKT(p)) {
410  SCLogDebug("drop log doesn't log pseudo packets");
411  return FALSE;
412  }
413 
414  if (g_droplog_flows_start && p->flow != NULL) {
415  int ret = FALSE;
416 
417  /* for a flow that will be dropped fully, log just once per direction */
418  if (p->flow->flags & FLOW_ACTION_DROP) {
420  ret = TRUE;
421  else if (PKT_IS_TOCLIENT(p) && !(p->flow->flags & FLOW_TOCLIENT_DROP_LOGGED))
422  ret = TRUE;
423  }
424 
425  /* if drop is caused by signature, log anyway */
426  if (p->alerts.drop.action != 0)
427  ret = TRUE;
428 
429  return ret;
430  } else if (PACKET_TEST_ACTION(p, ACTION_DROP)) {
431  return TRUE;
432  }
433 
434  return FALSE;
435 }
436 
438 {
440  JsonDropLogInitCtx, JsonDropLogger, JsonDropLogCondition,
441  JsonDropLogThreadInit, JsonDropLogThreadDeinit, NULL);
443  "eve-log.drop", JsonDropLogInitCtxSub, JsonDropLogger,
444  JsonDropLogCondition, JsonDropLogThreadInit, JsonDropLogThreadDeinit,
445  NULL);
446 }
PKT_IS_TOCLIENT
#define PKT_IS_TOCLIENT(p)
Definition: decode.h:261
PKT_IS_UDP
#define PKT_IS_UDP(p)
Definition: decode.h:257
tm-threads.h
TCP_GET_RAW_X2
#define TCP_GET_RAW_X2(tcph)
Definition: decode-tcp.h:70
detect-engine.h
OutputDropLoggerEnable
int OutputDropLoggerEnable(void)
Definition: output.c:845
PacketAlert_::s
const struct Signature_ * s
Definition: decode.h:276
JsonDropLogThread_::drop_ctx
JsonDropOutputCtx * drop_ctx
Definition: output-json-drop.c:70
PKT_IS_PSEUDOPKT
#define PKT_IS_PSEUDOPKT(p)
return 1 if the packet is a pseudo packet
Definition: decode.h:1125
PKT_IS_IPV6
#define PKT_IS_IPV6(p)
Definition: decode.h:255
OutputJsonCtx_::cfg
OutputJsonCommonSettings cfg
Definition: output-json.h:111
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
JsonDropOutputCtx_::file_ctx
LogFileCtx * file_ctx
Definition: output-json-drop.c:64
ACTION_REJECT
#define ACTION_REJECT
Definition: action-globals.h:31
JsonDropLogThread_
Definition: output-json-drop.c:69
LogFileNewCtx
LogFileCtx * LogFileNewCtx(void)
LogFileNewCtx() Get a new LogFileCtx.
Definition: util-logopenfile.c:516
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:298
PacketAlerts_::alerts
PacketAlert alerts[PACKET_ALERT_MAX]
Definition: decode.h:297
PacketAlerts_::cnt
uint16_t cnt
Definition: decode.h:296
JSON_OUTPUT_BUFFER_SIZE
#define JSON_OUTPUT_BUFFER_SIZE
Definition: output-json.h:62
threads.h
OutputJsonCtx_
Definition: output-json.h:108
AlertJsonHeader
void AlertJsonHeader(void *ctx, const Packet *p, const PacketAlert *pa, JsonBuilder *js, uint16_t flags, JsonAddrInfo *addr)
Definition: output-json-alert.c:311
ICMPV6_GET_SEQ
#define ICMPV6_GET_SEQ(p)
Definition: decode-icmpv6.h:113
OutputJsonCommonSettings_
Definition: output-json.h:99
logged
int logged
Definition: app-layer-htp.h:1
LogFileCtx_
Definition: util-logopenfile.h:52
JsonDropOutputCtx
struct JsonDropOutputCtx_ JsonDropOutputCtx
json_addr_info_zero
const JsonAddrInfo json_addr_info_zero
Definition: output-json.c:86
OutputJsonBuilderBuffer
int OutputJsonBuilderBuffer(JsonBuilder *js, LogFileCtx *file_ctx, MemBuffer **buffer)
Definition: output-json.c:1429
JsonDropOutputCtx_::cfg
OutputJsonCommonSettings cfg
Definition: output-json-drop.c:66
IPV6_GET_L4PROTO
#define IPV6_GET_L4PROTO(p)
Definition: decode-ipv6.h:93
ICMPV6_GET_ID
#define ICMPV6_GET_ID(p)
Definition: decode-icmpv6.h:111
PacketAlerts_::drop
PacketAlert drop
Definition: decode.h:300
util-privs.h
FLOW_ACTION_DROP
#define FLOW_ACTION_DROP
Definition: flow.h:64
EveAddCommonOptions
void EveAddCommonOptions(const OutputJsonCommonSettings *cfg, const Packet *p, const Flow *f, JsonBuilder *js)
Definition: output-json.c:673
FLOW_TOSERVER_DROP_LOGGED
#define FLOW_TOSERVER_DROP_LOGGED
Definition: flow.h:72
proto
uint8_t proto
Definition: decode-template.h:0
TM_ECODE_FAILED
@ TM_ECODE_FAILED
Definition: tm-threads-common.h:79
Packet_::alerts
PacketAlerts alerts
Definition: decode.h:558
util-unittest.h
ConfValIsTrue
int ConfValIsTrue(const char *val)
Check if a value is true.
Definition: conf.c:565
util-unittest-helper.h
OutputCtx_::data
void * data
Definition: tm-modules.h:81
TM_ECODE_OK
@ TM_ECODE_OK
Definition: tm-threads-common.h:78
OutputCtx_
Definition: tm-modules.h:78
IPV6_GET_PLEN
#define IPV6_GET_PLEN(p)
Definition: decode-ipv6.h:88
TCP_GET_WINDOW
#define TCP_GET_WINDOW(p)
Definition: decode-tcp.h:114
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:305
PacketAlert_::action
uint8_t action
Definition: decode.h:274
detect-reference.h
TCP_ISSET_FLAG_SYN
#define TCP_ISSET_FLAG_SYN(p)
Definition: decode-tcp.h:120
ICMPV4_GET_SEQ
#define ICMPV4_GET_SEQ(p)
Definition: decode-icmpv4.h:227
ACTION_REJECT_DST
#define ACTION_REJECT_DST
Definition: action-globals.h:32
PKT_IS_TCP
#define PKT_IS_TCP(p)
Definition: decode.h:256
IPV4_GET_IPPROTO
#define IPV4_GET_IPPROTO(p)
Definition: decode-ipv4.h:148
util-debug.h
SC_ERR_CONF_YAML_ERROR
@ SC_ERR_CONF_YAML_ERROR
Definition: util-error.h:274
LOG_DROP_ALERTS
#define LOG_DROP_ALERTS
Definition: output-json-drop.c:61
PKT_IS_TOSERVER
#define PKT_IS_TOSERVER(p)
Definition: decode.h:260
OutputInitResult_::ctx
OutputCtx * ctx
Definition: output.h:44
CreateEveHeader
JsonBuilder * CreateEveHeader(const Packet *p, enum OutputJsonLogDirection dir, const char *event_type, JsonAddrInfo *addr)
Definition: output-json.c:1284
output-json.h
util-print.h
detect-engine-mpm.h
detect.h
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:58
IPV4_GET_IPLEN
#define IPV4_GET_IPLEN(p)
Definition: decode-ipv4.h:127
TCP_ISSET_FLAG_URG
#define TCP_ISSET_FLAG_URG(p)
Definition: decode-tcp.h:124
util-time.h
OutputInitResult_::ok
bool ok
Definition: output.h:45
IPV4_GET_IPID
#define IPV4_GET_IPID(p)
Definition: decode-ipv4.h:129
JsonDropLogThread_::buffer
MemBuffer * buffer
Definition: output-json-drop.c:71
TRUE
#define TRUE
Definition: suricata-common.h:33
PKT_IS_ICMPV6
#define PKT_IS_ICMPV6(p)
Definition: decode.h:259
TCP_GET_SEQ
#define TCP_GET_SEQ(p)
Definition: decode-tcp.h:112
FALSE
#define FALSE
Definition: suricata-common.h:34
JsonAddrInfo_
Definition: output-json.h:48
Packet_
Definition: decode.h:411
conf.h
TmEcode
TmEcode
Definition: tm-threads-common.h:77
DEFAULT_LOG_FILENAME
#define DEFAULT_LOG_FILENAME
Definition: output-json-drop.c:253
util-proto-name.h
MemBuffer_
Definition: util-buffer.h:27
JsonDropOutputCtx_::flags
uint8_t flags
Definition: output-json-drop.c:65
ACTION_REJECT_BOTH
#define ACTION_REJECT_BOTH
Definition: action-globals.h:33
decode-ipv4.h
ICMPV4_GET_ID
#define ICMPV4_GET_ID(p)
Definition: decode-icmpv4.h:225
IPV6_GET_FLOW
#define IPV6_GET_FLOW(p)
Definition: decode-ipv6.h:84
MemBufferReset
#define MemBufferReset(mem_buffer)
Reset the mem buffer.
Definition: util-buffer.h:42
OutputInitResult_
Definition: output.h:43
Packet_::flow
struct Flow_ * flow
Definition: decode.h:448
UDP_GET_LEN
#define UDP_GET_LEN(p)
Definition: decode-udp.h:35
LOG_DIR_PACKET
@ LOG_DIR_PACKET
Definition: output-json.h:38
IPV6_GET_CLASS
#define IPV6_GET_CLASS(p)
Definition: decode-ipv6.h:82
suricata-common.h
OutputCtx_::DeInit
void(* DeInit)(struct OutputCtx_ *)
Definition: tm-modules.h:84
OutputRegisterPacketSubModule
void OutputRegisterPacketSubModule(LoggerId id, const char *parent_name, const char *name, const char *conf_name, OutputInitSubFunc InitFunc, PacketLogger PacketLogFunc, PacketLogCondition PacketConditionFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
Register a packet output sub-module.
Definition: output.c:211
Packet_::tcph
TCPHdr * tcph
Definition: decode.h:525
MODULE_NAME
#define MODULE_NAME
Definition: output-json-drop.c:59
MemBufferFree
void MemBufferFree(MemBuffer *buffer)
Definition: util-buffer.c:82
ACTION_DROP
#define ACTION_DROP
Definition: action-globals.h:30
LOGGER_JSON_DROP
@ LOGGER_JSON_DROP
Definition: suricata-common.h:477
SCLogError
#define SCLogError(err_code,...)
Macro used to log ERROR messages.
Definition: util-debug.h:257
TCP_ISSET_FLAG_ACK
#define TCP_ISSET_FLAG_ACK(p)
Definition: decode-tcp.h:123
LogFileFreeCtx
int LogFileFreeCtx(LogFileCtx *lf_ctx)
LogFileFreeCtx() Destroy a LogFileCtx (Close the file and free memory)
Definition: util-logopenfile.c:538
util-classification-config.h
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:29
output-json-alert.h
PKT_IS_ICMPV4
#define PKT_IS_ICMPV4(p)
Definition: decode.h:258
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:171
threadvars.h
SCMalloc
#define SCMalloc(sz)
Definition: util-mem.h:47
TCP_ISSET_FLAG_RST
#define TCP_ISSET_FLAG_RST(p)
Definition: decode-tcp.h:121
IPV4_GET_IPTOS
#define IPV4_GET_IPTOS(p)
Definition: decode-ipv4.h:125
JsonDropLogThread
struct JsonDropLogThread_ JsonDropLogThread
SCLogWarning
#define SCLogWarning(err_code,...)
Macro used to log WARNING messages.
Definition: util-debug.h:244
SCFree
#define SCFree(p)
Definition: util-mem.h:61
ConfNode_
Definition: conf.h:32
util-logopenfile.h
JsonDropOutputCtx_
Definition: output-json-drop.c:63
TCP_ISSET_FLAG_FIN
#define TCP_ISSET_FLAG_FIN(p)
Definition: decode-tcp.h:119
Flow_::flags
uint32_t flags
Definition: flow.h:396
JsonDropLogRegister
void JsonDropLogRegister(void)
Definition: output-json-drop.c:437
detect-parse.h
util-buffer.h
FLOW_TOCLIENT_DROP_LOGGED
#define FLOW_TOCLIENT_DROP_LOGGED
Definition: flow.h:74
IPV6_GET_HLIM
#define IPV6_GET_HLIM(p)
Definition: decode-ipv6.h:90
OutputJsonCtx_::file_ctx
LogFileCtx * file_ctx
Definition: output-json.h:109
EngineModeIsIPS
int EngineModeIsIPS(void)
Definition: suricata.c:243
TCP_GET_URG_POINTER
#define TCP_GET_URG_POINTER(p)
Definition: decode-tcp.h:115
PacketAlert_
Definition: decode.h:272
JsonAddrInfoInit
void JsonAddrInfoInit(const Packet *p, enum OutputJsonLogDirection dir, JsonAddrInfo *addr)
Definition: output-json.c:780
TCP_GET_ACK
#define TCP_GET_ACK(p)
Definition: decode-tcp.h:113
flow.h
SCCalloc
#define SCCalloc(nm, sz)
Definition: util-mem.h:53
PKT_IS_IPV4
#define PKT_IS_IPV4(p)
Definition: decode.h:254
MemBufferCreateNew
MemBuffer * MemBufferCreateNew(uint32_t size)
Definition: util-buffer.c:32
debug.h
output.h
IPV4_GET_IPTTL
#define IPV4_GET_IPTTL(p)
Definition: decode-ipv4.h:146
OutputDropLoggerDisable
void OutputDropLoggerDisable(void)
Definition: output.c:853
TCP_ISSET_FLAG_PUSH
#define TCP_ISSET_FLAG_PUSH(p)
Definition: decode-tcp.h:122
PACKET_TEST_ACTION
#define PACKET_TEST_ACTION(p, a)
Definition: decode.h:850
output-json-drop.h
ConfNodeLookupChildValue
const char * ConfNodeLookupChildValue(const ConfNode *node, const char *name)
Lookup the value of a child configuration node by name.
Definition: conf.c:842