52 #include "app-layer-template.h"
53 #include "output-json-template.h"
65 static int JsonTemplateLogger(
ThreadVars *
tv,
void *thread_data,
66 const Packet *p,
Flow *f,
void *state,
void *tx, uint64_t tx_id)
68 TemplateTransaction *templatetx = tx;
71 SCLogNotice(
"Logging template transaction %"PRIu64
".", templatetx->tx_id);
79 jb_open_object(js,
"template");
82 if (templatetx->request_buffer != NULL) {
83 jb_set_string_from_bytes(js,
"request", templatetx->request_buffer,
84 templatetx->request_buffer_len);
88 if (templatetx->response_buffer != NULL) {
89 jb_set_string_from_bytes(js,
"response", templatetx->response_buffer,
90 templatetx->response_buffer_len);
102 static void OutputTemplateLogDeInitCtxSub(
OutputCtx *output_ctx)
116 if (
unlikely(templatelog_ctx == NULL)) {
119 templatelog_ctx->
eve_ctx = ajt;
126 output_ctx->
data = templatelog_ctx;
127 output_ctx->
DeInit = OutputTemplateLogDeInitCtxSub;
129 SCLogNotice(
"Template log sub-module initialized.");
133 result.
ctx = output_ctx;
138 static TmEcode JsonTemplateLogThreadInit(
ThreadVars *t,
const void *initdata,
void **data)
145 if (initdata == NULL) {
146 SCLogDebug(
"Error getting context for EveLogTemplate. \"initdata\" is NULL.");
155 *data = (
void *)thread;
167 if (thread == NULL) {
178 if (
ConfGetNode(
"app-layer.protocols.template") == NULL) {
185 JsonTemplateLogThreadInit, JsonTemplateLogThreadDeinit, NULL);