#endif /* OS_WIN32 */
TmEcode OutputJson (ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *);
-TmEcode AlertJson(ThreadVars *, Packet *, void *);
TmEcode OutputJsonThreadInit(ThreadVars *, void *, void **);
TmEcode OutputJsonThreadDeinit(ThreadVars *, void *);
void OutputJsonExitPrintStats(ThreadVars *, void *);
/* Default Sensor ID value */
static int64_t sensor_id = -1; /* -1 = not defined */
-enum JsonOutput { ALERT_FILE,
- ALERT_SYSLOG,
- ALERT_UNIX_DGRAM,
- ALERT_UNIX_STREAM };
static enum JsonOutput json_out = ALERT_FILE;
-#define OUTPUT_ALERTS (1<<0)
-#define OUTPUT_DNS (1<<1)
-#define OUTPUT_DROP (1<<2)
-#define OUTPUT_FILES (1<<3)
-#define OUTPUT_HTTP (1<<4)
-#define OUTPUT_TLS (1<<5)
-
-enum JsonFormat { COMPACT, INDENT };
static enum JsonFormat format = COMPACT;
json_t *CreateJSONHeader(Packet *p, int direction_sensitive)
const char *output_s = ConfNodeLookupChildValue(conf, "type");
if (output_s != NULL) {
if (strcmp(output_s, "file") == 0) {
- json_out = ALERT_FILE;
+ json_ctx->json_out = ALERT_FILE;
} else if (strcmp(output_s, "syslog") == 0) {
- json_out = ALERT_SYSLOG;
+ json_ctx->json_out = ALERT_SYSLOG;
} else if (strcmp(output_s, "unix_dgram") == 0) {
- json_out = ALERT_UNIX_DGRAM;
+ json_ctx->json_out = ALERT_UNIX_DGRAM;
} else if (strcmp(output_s, "unix_stream") == 0) {
- json_out = ALERT_UNIX_STREAM;
+ json_ctx->json_out = ALERT_UNIX_STREAM;
} else {
SCLogError(SC_ERR_INVALID_ARGUMENT,
"Invalid JSON output option: %s", output_s);
}
}
- if (json_out == ALERT_FILE) {
+ if (json_ctx->json_out == ALERT_FILE) {
if (SCConfLogOpenGeneric(conf, json_ctx->file_ctx, DEFAULT_LOG_FILENAME) < 0) {
LogFileFreeCtx(json_ctx->file_ctx);
const char *format_s = ConfNodeLookupChildValue(conf, "format");
if (format_s != NULL) {
if (strcmp(format_s, "indent") == 0) {
- format = INDENT;
+ json_ctx->format = INDENT;
} else if (strcmp(format_s, "compact") == 0) {
- format = COMPACT;
+ json_ctx->format = COMPACT;
} else {
SCLogError(SC_ERR_INVALID_ARGUMENT,
"Invalid JSON format option: %s", format_s);
}
}
- ConfNode *outputs, *output;
- outputs = ConfNodeLookupChild(conf, "types");
- if (outputs) {
- /*
- * TODO: make this more general with some sort of
- * registration capability
- */
- TAILQ_FOREACH(output, &outputs->head, next) {
- }
- }
+ format = json_ctx->format;
+ json_out = json_ctx->json_out;
}
return output_ctx;
* \author Tom DeCanio <td@npulsetech.com>
*/
-#ifndef __ALERT_JSON_H__
-#define __ALERT_JSON_H__
+#ifndef __OUTPUT_JSON_H__
+#define __OUTPUT_JSON_H__
void TmModuleOutputJsonRegister (void);
json_t *CreateJSONHeader(Packet *p, int direction_sensative);
TmEcode OutputJSON(json_t *js, void *data, uint64_t *count);
int OutputJSONBuffer(json_t *js, LogFileCtx *file_ctx, MemBuffer *buffer);
-
OutputCtx *OutputJsonInitCtx(ConfNode *);
-/* TODO: I think the following structures can be made private again */
+enum JsonOutput { ALERT_FILE,
+ ALERT_SYSLOG,
+ ALERT_UNIX_DGRAM,
+ ALERT_UNIX_STREAM };
+enum JsonFormat { COMPACT, INDENT };
+
/*
* Global configuration context data
*/
typedef struct OutputJsonCtx_ {
LogFileCtx *file_ctx;
+ enum JsonOutput json_out;
+ enum JsonFormat format;
} OutputJsonCtx;
+
typedef struct AlertJsonThread_ {
/** LogFileCtx has the pointer to the file and a mutex to allow multithreading */
- LogFileCtx* file_ctx;
+ LogFileCtx *file_ctx;
} AlertJsonThread;
#endif /* HAVE_LIBJANSSON */
-#endif /* __ALERT_JSON_H__ */
+#endif /* __OUTPUT_JSON_H__ */