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 SCJbSetString(js,
"direction",
"to_server");
103 SCJbSetString(js,
"direction",
"to_client");
107 SCJbOpenObject(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 SCJbSetString(js,
"reason",
str);
172 for (
int i = 0; i < p->
alerts.
cnt; i++) {
197 static TmEcode JsonDropLogThreadInit(
ThreadVars *t,
const void *initdata,
void **data)
205 SCLogDebug(
"Error getting context for EveLogDrop. \"initdata\" argument NULL");
234 memset(aft, 0,
sizeof(*aft));
242 if (drop_ctx != NULL) {
247 static void JsonDropLogDeInitCtxSub(
OutputCtx *output_ctx)
253 SCLogDebug(
"cleaning up sub output_ctx %p", output_ctx);
269 if (drop_ctx == NULL)
274 JsonDropOutputCtxFree(drop_ctx);
280 if (extended != NULL) {
286 if (extended != NULL) {
287 if (strcasecmp(extended,
"start") == 0) {
288 g_droplog_flows_start = 1;
289 }
else if (strcasecmp(extended,
"all") == 0) {
290 g_droplog_flows_start = 0;
293 "'flow' are 'start' and 'all'");
301 }
else if (extended != NULL) {
310 output_ctx->
data = drop_ctx;
311 output_ctx->
DeInit = JsonDropLogDeInitCtxSub;
313 result.
ctx = output_ctx;
330 int r = DropLogJSON(
tv, td, p);
334 if (!g_droplog_flows_start)
359 SCLogDebug(
"engine is not running in inline mode, so returning");
363 SCLogDebug(
"drop log doesn't log pseudo packets");
371 if (g_droplog_flows_start && p->
flow != NULL) {
396 .ConditionFunc = JsonDropLogCondition,
397 .ThreadInitFunc = JsonDropLogThreadInit,
398 .ThreadDeinitFunc = JsonDropLogThreadDeinit,
399 .ThreadExitPrintStatsFunc = NULL,
403 JsonDropLogInitCtxSub, &output_logger_functions);
#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)
int SCConfValIsTrue(const char *val)
Check if a value is true.
#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
OutputJsonCommonSettings cfg
const char * PacketDropReasonToString(enum PacketDropReason r)
void FreeEveThreadCtx(OutputJsonThreadCtx *ctx)
SCJsonBuilder * CreateEveHeader(const Packet *p, enum SCOutputJsonLogDirection dir, const char *event_type, JsonAddrInfo *addr, OutputJsonCtx *eve_ctx)
#define ICMPV6_GET_SEQ(p)
#define IPV6_GET_RAW_CLASS(ip6h)
void JsonAddrInfoInit(const Packet *p, enum SCOutputJsonLogDirection dir, JsonAddrInfo *addr, OutputJsonCommonSettings *cfg)
struct JsonDropOutputCtx_ JsonDropOutputCtx
void AlertJsonHeader(const Packet *p, const PacketAlert *pa, SCJsonBuilder *js, uint16_t flags, JsonAddrInfo *addr, char *xff_buffer)
OutputJsonThreadCtx * CreateEveThreadCtx(ThreadVars *t, OutputJsonCtx *ctx)
const JsonAddrInfo json_addr_info_zero
#define FLOW_PKT_TOSERVER
#define IPV6_GET_L4PROTO(p)
void OutputJsonBuilderBuffer(ThreadVars *tv, const Packet *p, Flow *f, SCJsonBuilder *js, OutputJsonThreadCtx *ctx)
#define FLOW_TOSERVER_DROP_LOGGED
const char * SCConfNodeLookupChildValue(const SCConfNode *node, const char *name)
Lookup the value of a child configuration node by name.
bool EngineModeIsFirewall(void)
#define TCP_GET_RAW_WINDOW(tcph)
#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)
#define TCP_ISSET_FLAG_RAW_ACK(tcph)
OutputJsonThreadCtx * ctx
#define TCP_ISSET_FLAG_RAW_RST(tcph)
Per thread variable structure.
#define SCLogWarning(...)
Macro used to log WARNING messages.
#define IPV4_GET_RAW_IPTTL(ip4h)
#define TCP_ISSET_FLAG_RAW_FIN(tcph)
#define ACTION_REJECT_BOTH
void(* DeInit)(struct OutputCtx_ *)
#define IPV6_GET_RAW_FLOW(ip6h)
void OutputRegisterPacketSubModule(LoggerId id, const char *parent_name, const char *name, const char *conf_name, OutputInitSubFunc InitFunc, OutputPacketLoggerFunctions *output_logger_functions)
Register a packet output sub-module.
void EveAddVerdict(SCJsonBuilder *jb, const Packet *p, const uint8_t alert_action)
Build verdict object.
#define SCLogError(...)
Macro used to log ERROR messages.
struct JsonDropLogThread_ JsonDropLogThread
void JsonDropLogRegister(void)
#define FLOW_TOCLIENT_DROP_LOGGED
int EngineModeIsIPS(void)
#define IPV4_GET_RAW_IPLEN(ip4h)
#define TCP_ISSET_FLAG_RAW_SYN(tcph)
#define TCP_GET_RAW_URG_POINTER(tcph)
#define TCP_GET_RAW_ACK(tcph)
#define TCP_ISSET_FLAG_RAW_URG(tcph)
void OutputDropLoggerDisable(void)
#define TCP_ISSET_FLAG_RAW_PUSH(tcph)