]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
output/json: clean up CreateJSONHeader calls
authorVictor Julien <victor@inliniac.net>
Fri, 2 Mar 2018 10:36:36 +0000 (11:36 +0100)
committerVictor Julien <victor@inliniac.net>
Fri, 2 Mar 2018 10:36:36 +0000 (11:36 +0100)
15 files changed:
src/output-json-alert.c
src/output-json-dnp3.c
src/output-json-dns.c
src/output-json-drop.c
src/output-json-file.c
src/output-json-flow.c
src/output-json-http.c
src/output-json-metadata.c
src/output-json-netflow.c
src/output-json-nfs.c
src/output-json-smtp.c
src/output-json-ssh.c
src/output-json-template.c
src/output-json-tftp.c
src/output-json-tls.c

index adffedcdb4010e323ac6aadffce8a7fa980aeeb9..b494823decaeaae96684de5b75f384039ba4e35c 100644 (file)
@@ -389,7 +389,7 @@ static int AlertJson(ThreadVars *tv, JsonAlertLogThread *aft, const Packet *p)
     if (p->alerts.cnt == 0 && !(p->flags & PKT_HAS_TAG))
         return TM_ECODE_OK;
 
-    json_t *js = CreateJSONHeader((Packet *)p, 0, "alert");
+    json_t *js = CreateJSONHeader(p, 0, "alert");
     if (unlikely(js == NULL))
         return TM_ECODE_OK;
 
@@ -589,7 +589,7 @@ static int AlertJson(ThreadVars *tv, JsonAlertLogThread *aft, const Packet *p)
     if ((p->flags & PKT_HAS_TAG) && (json_output_ctx->flags &
             LOG_JSON_TAGGED_PACKETS)) {
         MemBufferReset(aft->json_buffer);
-        json_t *packetjs = CreateJSONHeader((Packet *)p, 0, "packet");
+        json_t *packetjs = CreateJSONHeader(p, 0, "packet");
         if (unlikely(packetjs != NULL)) {
             AlertJsonPacket(p, packetjs);
             OutputJSONBuffer(packetjs, aft->file_ctx, &aft->json_buffer);
index 1fe73d3495c05362847f83d0bac36688e493f0b7..a405dcc890991e8da00d2a53e5f3d0428445a1ec 100644 (file)
@@ -312,7 +312,7 @@ static int JsonDNP3LoggerToServer(ThreadVars *tv, void *thread_data,
 
     MemBufferReset(buffer);
     if (tx->has_request && tx->request_done) {
-        json_t *js = CreateJSONHeader((Packet *)p, 1, "dnp3");
+        json_t *js = CreateJSONHeader(p, 1, "dnp3");
         if (unlikely(js == NULL)) {
             return TM_ECODE_OK;
         }
@@ -341,7 +341,7 @@ static int JsonDNP3LoggerToClient(ThreadVars *tv, void *thread_data,
 
     MemBufferReset(buffer);
     if (tx->has_response && tx->response_done) {
-        json_t *js = CreateJSONHeader((Packet *)p, 1, "dnp3");
+        json_t *js = CreateJSONHeader(p, 1, "dnp3");
         if (unlikely(js == NULL)) {
             return TM_ECODE_OK;
         }
index 4ec5d8588bad2f579537da8413a5536437458856..58d34b64e7dd3b0d081af874e9f2d64374629ab0 100644 (file)
@@ -663,7 +663,7 @@ static int JsonDnsLoggerToServer(ThreadVars *tv, void *thread_data,
 
 #ifdef HAVE_RUST
     for (uint16_t i = 0; i < 0xffff; i++) {
-        js = CreateJSONHeader((Packet *)p, 1, "dns");
+        js = CreateJSONHeader(p, 1, "dns");
         if (unlikely(js == NULL)) {
             return TM_ECODE_OK;
         }
@@ -684,7 +684,7 @@ static int JsonDnsLoggerToServer(ThreadVars *tv, void *thread_data,
     DNSTransaction *tx = txptr;
     DNSQueryEntry *query = NULL;
     TAILQ_FOREACH(query, &tx->query_list, next) {
-        js = CreateJSONHeader((Packet *)p, 1, "dns");
+        js = CreateJSONHeader(p, 1, "dns");
         if (unlikely(js == NULL))
             return TM_ECODE_OK;
         if (dnslog_ctx->include_metadata) {
@@ -713,7 +713,7 @@ static int JsonDnsLoggerToClient(ThreadVars *tv, void *thread_data,
         return TM_ECODE_OK;
     }
 
-    js = CreateJSONHeader((Packet *)p, 0, "dns");
+    js = CreateJSONHeader(p, 0, "dns");
 
     if (dnslog_ctx->include_metadata) {
         JsonAddMetadata(p, f, js);
index 209d7aa013360c85646c49ea46cea1779e779ef6..a84c9d6efc99bbd6a16db5c55c6794ac6a3dbe72 100644 (file)
@@ -89,7 +89,7 @@ static int DropLogJSON (JsonDropLogThread *aft, const Packet *p)
 {
     JsonDropOutputCtx *drop_ctx = aft->drop_ctx;
     uint16_t proto = 0;
-    json_t *js = CreateJSONHeader((Packet *)p, 0, "drop");//TODO const
+    json_t *js = CreateJSONHeader(p, 0, "drop");
     if (unlikely(js == NULL))
         return TM_ECODE_OK;
 
index b295ea5baaf620e092f9a156500edf11fd85a151..f00471adf8bbacba3d3bdc07119aa25d94350dcf 100644 (file)
@@ -81,7 +81,7 @@ typedef struct JsonFileLogThread_ {
 json_t *JsonBuildFileInfoRecord(const Packet *p, const File *ff,
         const bool stored)
 {
-    json_t *js = CreateJSONHeader((Packet *)p, 0, "fileinfo"); //TODO const
+    json_t *js = CreateJSONHeader(p, 0, "fileinfo");
     json_t *hjs = NULL;
     if (unlikely(js == NULL))
         return NULL;
index 47516d6413d8e0997cb26463c003ee1d7cf106b7..2a963622e36237840c0c154167228f60d3797957 100644 (file)
@@ -63,7 +63,7 @@ typedef struct JsonFlowLogThread_ {
     MemBuffer *buffer;
 } JsonFlowLogThread;
 
-static json_t *CreateJSONHeaderFromFlow(Flow *f, const char *event_type)
+static json_t *CreateJSONHeaderFromFlow(const Flow *f, const char *event_type)
 {
     char timebuf[64];
     char srcip[46], dstip[46];
@@ -354,7 +354,7 @@ static int JsonFlowLogger(ThreadVars *tv, void *thread_data, Flow *f)
     /* reset */
     MemBufferReset(jhl->buffer);
 
-    json_t *js = CreateJSONHeaderFromFlow(f, "flow"); //TODO const
+    json_t *js = CreateJSONHeaderFromFlow(f, "flow");
     if (unlikely(js == NULL))
         return TM_ECODE_OK;
 
index 453e2011f466e56784b4f026611c5ff4fd654491..ac8a9f34c988a690c5f31f39c767fb17a76891a2 100644 (file)
@@ -452,7 +452,7 @@ static int JsonHttpLogger(ThreadVars *tv, void *thread_data, const Packet *p, Fl
     htp_tx_t *tx = txptr;
     JsonHttpLogThread *jhl = (JsonHttpLogThread *)thread_data;
 
-    json_t *js = CreateJSONHeaderWithTxId((Packet *)p, 1, "http", tx_id); //TODO const
+    json_t *js = CreateJSONHeaderWithTxId(p, 1, "http", tx_id);
     if (unlikely(js == NULL))
         return TM_ECODE_OK;
 
index 478c3286f08afaacf42fee055615cb3c37e4999c..370609b178d999d62d52b6c75308bec24707f146 100644 (file)
@@ -82,7 +82,7 @@ typedef struct JsonMetadataLogThread_ {
 
 static int MetadataJson(ThreadVars *tv, JsonMetadataLogThread *aft, const Packet *p)
 {
-    json_t *js = CreateJSONHeader((Packet *)p, 0, "metadata");
+    json_t *js = CreateJSONHeader(p, 0, "metadata");
     if (unlikely(js == NULL))
         return TM_ECODE_OK;
 
index 0b9b2009641644dd7b0ebda25a4cc3ae8b3b762e..097fea567e1aee55733390f17e9efd7e9c6ee62a 100644 (file)
@@ -64,7 +64,7 @@ typedef struct JsonNetFlowLogThread_ {
 } JsonNetFlowLogThread;
 
 
-static json_t *CreateJSONHeaderFromFlow(Flow *f, const char *event_type, int dir)
+static json_t *CreateJSONHeaderFromFlow(const Flow *f, const char *event_type, int dir)
 {
     char timebuf[64];
     char srcip[46], dstip[46];
@@ -303,7 +303,7 @@ static int JsonNetFlowLogger(ThreadVars *tv, void *thread_data, Flow *f)
 
     /* reset */
     MemBufferReset(jhl->buffer);
-    json_t *js = CreateJSONHeaderFromFlow(f, "netflow", 0); //TODO const
+    json_t *js = CreateJSONHeaderFromFlow(f, "netflow", 0);
     if (unlikely(js == NULL))
         return TM_ECODE_OK;
     JsonNetFlowLogJSONToServer(jhl, js, f);
@@ -317,7 +317,7 @@ static int JsonNetFlowLogger(ThreadVars *tv, void *thread_data, Flow *f)
 
     /* reset */
     MemBufferReset(jhl->buffer);
-    js = CreateJSONHeaderFromFlow(f, "netflow", 1); //TODO const
+    js = CreateJSONHeaderFromFlow(f, "netflow", 1);
     if (unlikely(js == NULL))
         return TM_ECODE_OK;
     JsonNetFlowLogJSONToClient(jhl, js, f);
index 0e44c18967d763f86bd359e920e8a3e92826d7a0..df614dc47286b6eef8aae9296f47ba7f4d2572a7 100644 (file)
@@ -99,7 +99,7 @@ static int JsonNFSLogger(ThreadVars *tv, void *thread_data,
     if (rs_nfs_tx_logging_is_filtered(nfstx))
         return TM_ECODE_OK;
 
-    js = CreateJSONHeader((Packet *)p, 0, "nfs");
+    js = CreateJSONHeader(p, 0, "nfs");
     if (unlikely(js == NULL)) {
         return TM_ECODE_FAILED;
     }
index 8e6fcc45d8c3dc93121279516b9a0f0e32326510..264420b8747880708a1c58c6c6fd0d6a6b2662f1 100644 (file)
@@ -88,8 +88,7 @@ static int JsonSmtpLogger(ThreadVars *tv, void *thread_data, const Packet *p, Fl
     SCEnter();
     JsonEmailLogThread *jhl = (JsonEmailLogThread *)thread_data;
 
-    json_t *sjs;
-    json_t *js = CreateJSONHeaderWithTxId((Packet *)p, 1, "smtp", tx_id);
+    json_t *js = CreateJSONHeaderWithTxId(p, 1, "smtp", tx_id);
     if (unlikely(js == NULL))
         return TM_ECODE_OK;
 
@@ -100,7 +99,7 @@ static int JsonSmtpLogger(ThreadVars *tv, void *thread_data, const Packet *p, Fl
         JsonAddMetadata(p, f, js);
     }
 
-    sjs = JsonSmtpDataLogger(f, state, tx, tx_id);
+    json_t *sjs = JsonSmtpDataLogger(f, state, tx, tx_id);
     if (sjs) {
         json_object_set_new(js, "smtp", sjs);
     }
index 658777e4f7c06d6dba8c286c80fe0708bac74874..2bbe4acd97f810596226fbe654de9d74b8534ebe 100644 (file)
@@ -103,10 +103,10 @@ static int JsonSshLogger(ThreadVars *tv, void *thread_data, const Packet *p,
     }
 
     if (ssh_state->cli_hdr.software_version == NULL ||
-            ssh_state->srv_hdr.software_version == NULL)
+        ssh_state->srv_hdr.software_version == NULL)
         return 0;
 
-    json_t *js = CreateJSONHeader((Packet *)p, 1, "ssh");//TODO
+    json_t *js = CreateJSONHeader(p, 1, "ssh");
     if (unlikely(js == NULL))
         return 0;
 
index 7a390527583362d45ad517cfe5350a977a004f9c..f59ec2baf4b33e1cb3bd3d6173cfbf56d64bf00b 100644 (file)
@@ -71,16 +71,15 @@ static int JsonTemplateLogger(ThreadVars *tv, void *thread_data,
 {
     TemplateTransaction *templatetx = tx;
     LogTemplateLogThread *thread = thread_data;
-    json_t *js, *templatejs;
 
     SCLogNotice("Logging template transaction %"PRIu64".", templatetx->tx_id);
-    
-    js = CreateJSONHeader((Packet *)p, 0, "template");
+
+    json_t *js = CreateJSONHeader(p, 0, "template");
     if (unlikely(js == NULL)) {
         return TM_ECODE_FAILED;
     }
 
-    templatejs = json_object();
+    json_t *templatejs = json_object();
     if (unlikely(templatejs == NULL)) {
         goto error;
     }
index 6c79a992ccc8d57e22166fe6013c063e471dde02..6953917c1180c79c4be3f9476ceb72853d620dfe 100644 (file)
@@ -70,14 +70,13 @@ static int JsonTFTPLogger(ThreadVars *tv, void *thread_data,
     const Packet *p, Flow *f, void *state, void *tx, uint64_t tx_id)
 {
     LogTFTPLogThread *thread = thread_data;
-    json_t *js, *tftpjs;
 
-    js = CreateJSONHeader((Packet *)p, 0, "tftp");
+    json_t *js = CreateJSONHeader(p, 0, "tftp");
     if (unlikely(js == NULL)) {
         return TM_ECODE_FAILED;
     }
 
-    tftpjs = rs_tftp_log_json_request(tx);
+    json_t *tftpjs = rs_tftp_log_json_request(tx);
     if (unlikely(tftpjs == NULL)) {
         goto error;
     }
index 375c8a6973e9f52f57b0da50bf8d292435ccd240..95a5f1f3dc53f4d1aa200fc368b12ff3e13df0fc 100644 (file)
@@ -357,7 +357,7 @@ static int JsonTlsLogger(ThreadVars *tv, void *thread_data, const Packet *p,
         return 0;
     }
 
-    json_t *js = CreateJSONHeader((Packet *)p, 1, "tls");
+    json_t *js = CreateJSONHeader(p, 1, "tls");
     if (unlikely(js == NULL)) {
         return 0;
     }