suricata
output-json.h
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 
24 #ifndef __OUTPUT_JSON_H__
25 #define __OUTPUT_JSON_H__
26 
27 #include "suricata-common.h"
28 #include "util-buffer.h"
29 #include "util-logopenfile.h"
30 #include "output.h"
31 
32 #include "app-layer-htp-xff.h"
33 
34 void OutputJsonRegister(void);
35 
41 };
42 
43 /* Suggested output buffer size */
44 #define JSON_OUTPUT_BUFFER_SIZE 65535
45 
46 /* helper struct for OutputJSONMemBufferCallback */
48  MemBuffer **buffer; /**< buffer to use & expand as needed */
49  size_t expand_by; /**< expand by this size */
51 
52 int OutputJSONMemBufferCallback(const char *str, size_t size, void *data);
53 
54 void CreateJSONFlowId(json_t *js, const Flow *f);
55 void JsonTcpFlags(uint8_t flags, json_t *js);
56 void JsonPacket(const Packet *p, json_t *js, unsigned long max_length);
57 void JsonFiveTuple(const Packet *, enum OutputJsonLogDirection, json_t *);
58 json_t *CreateJSONHeader(const Packet *p,
59  enum OutputJsonLogDirection dir, const char *event_type);
60 json_t *CreateJSONHeaderWithTxId(const Packet *p,
61  enum OutputJsonLogDirection dir, const char *event_type, uint64_t tx_id);
62 int OutputJSONBuffer(json_t *js, LogFileCtx *file_ctx, MemBuffer **buffer);
64 
66 TmEcode JsonLogThreadInit(ThreadVars *t, const void *initdata, void **data);
67 TmEcode JsonLogThreadDeinit(ThreadVars *t, void *data);
68 
69 typedef struct OutputJsonCommonSettings_ {
74 
75 /*
76  * Global configuration context data
77  */
78 typedef struct OutputJsonCtx_ {
80  enum LogFileType json_out;
84 
85 typedef struct OutputJsonThreadCtx_ {
89 
90 json_t *SCJsonBool(int val);
91 json_t *SCJsonString(const char *val);
92 json_t *JsonAddStringN(const char *string, size_t size);
93 void SCJsonDecref(json_t *js);
94 
96  const Packet *p, const Flow *f, json_t *js);
97 
98 #endif /* __OUTPUT_JSON_H__ */
uint16_t flags
OutputJsonCtx * ctx
Definition: output-json.h:86
int OutputJSONBuffer(json_t *js, LogFileCtx *file_ctx, MemBuffer **buffer)
Definition: output-json.c:809
uint32_t event_type
void JsonAddCommonOptions(const OutputJsonCommonSettings *cfg, const Packet *p, const Flow *f, json_t *js)
Definition: output-json.c:390
LogFileType
void SCJsonDecref(json_t *js)
Definition: output-json.c:102
OutputInitResult OutputJsonInitCtx(ConfNode *)
Create a new LogFileCtx for "fast" output style.
Definition: output-json.c:843
json_t * SCJsonString(const char *val)
Definition: output-json.c:107
HttpXFFCfg * xff_cfg
Definition: output-json.h:82
json_t * CreateJSONHeaderWithTxId(const Packet *p, enum OutputJsonLogDirection dir, const char *event_type, uint64_t tx_id)
Definition: output-json.c:783
#define str(s)
void OutputJsonRegister(void)
Definition: output-json.c:85
OutputInitResult OutputJsonLogInitSub(ConfNode *conf, OutputCtx *parent_ctx)
OutputJsonCommonSettings cfg
Definition: output-json.h:81
LogFileCtx * file_ctx
Definition: output-json.h:79
Definition: conf.h:32
struct OutputJSONMemBufferWrapper_ OutputJSONMemBufferWrapper
uint16_t tx_id
json_t * SCJsonBool(int val)
Definition: output-json.c:93
int OutputJSONMemBufferCallback(const char *str, size_t size, void *data)
Definition: output-json.c:796
TmEcode JsonLogThreadInit(ThreadVars *t, const void *initdata, void **data)
MemBuffer * buffer
Definition: output-json.h:87
struct OutputJsonCtx_ OutputJsonCtx
void JsonTcpFlags(uint8_t flags, json_t *js)
jsonify tcp flags field Only add &#39;true&#39; fields in an attempt to keep things reasonably compact...
Definition: output-json.c:428
json_t * CreateJSONHeader(const Packet *p, enum OutputJsonLogDirection dir, const char *event_type)
Definition: output-json.c:710
struct OutputJsonThreadCtx_ OutputJsonThreadCtx
void JsonFiveTuple(const Packet *, enum OutputJsonLogDirection, json_t *)
Add five tuple from packet to JSON object.
Definition: output-json.c:455
TmEcode JsonLogThreadDeinit(ThreadVars *t, void *data)
void CreateJSONFlowId(json_t *js, const Flow *f)
Definition: output-json.c:699
Per thread variable structure.
Definition: threadvars.h:57
json_t * JsonAddStringN(const char *string, size_t size)
Create a JSON string from a character sequence.
Definition: output-json.c:142
OutputJsonLogDirection
Definition: output-json.h:36
Flow data structure.
Definition: flow.h:325
struct OutputJsonCommonSettings_ OutputJsonCommonSettings
void JsonPacket(const Packet *p, json_t *js, unsigned long max_length)
Jsonify a packet.
Definition: output-json.c:408