Go to the documentation of this file.
61 #define MODULE_NAME "JsonDropLog"
63 #define LOG_DROP_ALERTS BIT_U8(1)
64 #define LOG_DROP_VERDICT BIT_U8(2)
77 static int g_droplog_flows_start = 1;
99 if (p->
flow != NULL) {
101 jb_set_string(js,
"direction",
"to_server");
103 jb_set_string(js,
"direction",
"to_client");
107 jb_open_object(js,
"drop");
110 if (PacketIsIPv4(p)) {
111 const IPV4Hdr *ip4h = PacketGetIPv4(p);
117 }
else if (PacketIsIPv6(p)) {
118 const IPV6Hdr *ip6h = PacketGetIPv6(p);
127 if (PacketIsTCP(p)) {
128 const TCPHdr *tcph = PacketGetTCP(p);
143 if (PacketIsUDP(p)) {
144 const UDPHdr *udph = PacketGetUDP(p);
149 if (PacketIsICMPv4(p)) {
152 }
else if (PacketIsICMPv6(p)) {
160 jb_set_string(js,
"reason",
str);
200 static TmEcode JsonDropLogThreadInit(
ThreadVars *t,
const void *initdata,
void **data)
208 SCLogDebug(
"Error getting context for EveLogDrop. \"initdata\" argument NULL");
237 memset(aft, 0,
sizeof(*aft));
245 if (drop_ctx != NULL) {
250 static void JsonDropLogDeInitCtxSub(
OutputCtx *output_ctx)
256 SCLogDebug(
"cleaning up sub output_ctx %p", output_ctx);
272 if (drop_ctx == NULL)
277 JsonDropOutputCtxFree(drop_ctx);
283 if (extended != NULL) {
289 if (extended != NULL) {
290 if (strcasecmp(extended,
"start") == 0) {
291 g_droplog_flows_start = 1;
292 }
else if (strcasecmp(extended,
"all") == 0) {
293 g_droplog_flows_start = 0;
296 "'flow' are 'start' and 'all'");
300 if (extended != NULL) {
309 output_ctx->
data = drop_ctx;
310 output_ctx->
DeInit = JsonDropLogDeInitCtxSub;
312 result.
ctx = output_ctx;
329 int r = DropLogJSON(
tv, td, p);
333 if (!g_droplog_flows_start)
358 SCLogDebug(
"engine is not running in inline mode, so returning");
362 SCLogDebug(
"drop log doesn't log pseudo packets");
370 if (g_droplog_flows_start && p->
flow != NULL) {
394 JsonDropLogInitCtxSub, JsonDropLogger, JsonDropLogCondition, JsonDropLogThreadInit,
395 JsonDropLogThreadDeinit);
#define PKT_IS_TOCLIENT(p)
#define TCP_GET_RAW_SEQ(tcph)
bool PacketCheckAction(const Packet *p, const uint8_t a)
#define IPV4_GET_RAW_IPID(ip4h)
#define TCP_GET_RAW_X2(tcph)
int OutputDropLoggerEnable(void)
#define IPV6_GET_RAW_PLEN(ip6h)
const struct Signature_ * s
JsonDropOutputCtx * drop_ctx
#define IPV6_GET_RAW_HLIM(ip6h)
#define IPV4_GET_RAW_IPPROTO(ip4h)
#define PKT_IS_PSEUDOPKT(p)
return 1 if the packet is a pseudo packet
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)
Register a packet output sub-module.
const char * PacketDropReasonToString(enum PacketDropReason r)
void FreeEveThreadCtx(OutputJsonThreadCtx *ctx)
#define ICMPV6_GET_SEQ(p)
#define IPV6_GET_RAW_CLASS(ip6h)
struct JsonDropOutputCtx_ JsonDropOutputCtx
OutputJsonThreadCtx * CreateEveThreadCtx(ThreadVars *t, OutputJsonCtx *ctx)
const JsonAddrInfo json_addr_info_zero
#define FLOW_PKT_TOSERVER
#define IPV6_GET_L4PROTO(p)
#define FLOW_TOSERVER_DROP_LOGGED
#define TCP_GET_RAW_WINDOW(tcph)
int ConfValIsTrue(const char *val)
Check if a value is true.
#define ICMPV4_GET_SEQ(p)
#define ACTION_REJECT_DST
#define UDP_GET_RAW_LEN(udph)
#define IPV4_GET_RAW_IPTOS(ip4h)
#define PKT_IS_TOSERVER(p)
OutputJsonThreadCtx * ctx
JsonBuilder * CreateEveHeader(const Packet *p, enum OutputJsonLogDirection dir, const char *event_type, JsonAddrInfo *addr, OutputJsonCtx *eve_ctx)
#define TCP_ISSET_FLAG_RAW_URG(p)
Per thread variable structure.
#define SCLogWarning(...)
Macro used to log WARNING messages.
#define TCP_ISSET_FLAG_RAW_ACK(p)
#define IPV4_GET_RAW_IPTTL(ip4h)
void AlertJsonHeader(const Packet *p, const PacketAlert *pa, JsonBuilder *js, uint16_t flags, JsonAddrInfo *addr, char *xff_buffer)
#define TCP_ISSET_FLAG_RAW_FIN(p)
#define ACTION_REJECT_BOTH
void(* DeInit)(struct OutputCtx_ *)
void EveAddVerdict(JsonBuilder *jb, const Packet *p)
Build verdict object.
#define TCP_ISSET_FLAG_RAW_PUSH(p)
int OutputJsonBuilderBuffer(ThreadVars *tv, const Packet *p, Flow *f, JsonBuilder *js, OutputJsonThreadCtx *ctx)
#define IPV6_GET_RAW_FLOW(ip6h)
#define SCLogError(...)
Macro used to log ERROR messages.
struct JsonDropLogThread_ JsonDropLogThread
void JsonDropLogRegister(void)
#define TCP_ISSET_FLAG_RAW_SYN(p)
#define TCP_ISSET_FLAG_RAW_RST(p)
#define FLOW_TOCLIENT_DROP_LOGGED
int EngineModeIsIPS(void)
void JsonAddrInfoInit(const Packet *p, enum OutputJsonLogDirection dir, JsonAddrInfo *addr)
#define IPV4_GET_RAW_IPLEN(ip4h)
#define TCP_GET_RAW_URG_POINTER(tcph)
#define TCP_GET_RAW_ACK(tcph)
void OutputDropLoggerDisable(void)
const char * ConfNodeLookupChildValue(const ConfNode *node, const char *name)
Lookup the value of a child configuration node by name.