From: Eric Leblond Date: Fri, 6 Mar 2015 20:05:51 +0000 (+0100) Subject: json-ssh: export logging function X-Git-Tag: suricata-2.1beta4~176 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c1970a3655360ef603288d50451a6547becdaf3a;p=thirdparty%2Fsuricata.git json-ssh: export logging function It will be use in alert logging to display SSH information. --- diff --git a/src/output-json-ssh.c b/src/output-json-ssh.c index 0a6ea46230..d8494d5e35 100644 --- a/src/output-json-ssh.c +++ b/src/output-json-ssh.c @@ -65,6 +65,31 @@ typedef struct JsonSshLogThread_ { MemBuffer *buffer; } JsonSshLogThread; + +void JsonSshLogJSON(json_t *tjs, SshState *ssh_state) +{ + json_t *cjs = json_object(); + if (cjs != NULL) { + json_object_set_new(cjs, "proto_version", + json_string((char *)ssh_state->cli_hdr.proto_version)); + + json_object_set_new(cjs, "software_version", + json_string((char *)ssh_state->cli_hdr.software_version)); + } + json_object_set_new(tjs, "client", cjs); + + json_t *sjs = json_object(); + if (sjs != NULL) { + json_object_set_new(sjs, "proto_version", + json_string((char *)ssh_state->srv_hdr.proto_version)); + + json_object_set_new(sjs, "software_version", + json_string((char *)ssh_state->srv_hdr.software_version)); + } + json_object_set_new(tjs, "server", sjs); + +} + static int JsonSshLogger(ThreadVars *tv, void *thread_data, const Packet *p) { JsonSshLogThread *aft = (JsonSshLogThread *)thread_data; @@ -102,25 +127,7 @@ static int JsonSshLogger(ThreadVars *tv, void *thread_data, const Packet *p) /* reset */ MemBufferReset(buffer); - json_t *cjs = json_object(); - if (cjs != NULL) { - json_object_set_new(cjs, "proto_version", - json_string((char *)ssh_state->cli_hdr.proto_version)); - - json_object_set_new(cjs, "software_version", - json_string((char *)ssh_state->cli_hdr.software_version)); - } - json_object_set_new(tjs, "client", cjs); - - json_t *sjs = json_object(); - if (sjs != NULL) { - json_object_set_new(sjs, "proto_version", - json_string((char *)ssh_state->srv_hdr.proto_version)); - - json_object_set_new(sjs, "software_version", - json_string((char *)ssh_state->srv_hdr.software_version)); - } - json_object_set_new(tjs, "server", sjs); + JsonSshLogJSON(tjs, ssh_state); json_object_set_new(js, "ssh", tjs); diff --git a/src/output-json-ssh.h b/src/output-json-ssh.h index af0711c711..5d0752bf2a 100644 --- a/src/output-json-ssh.h +++ b/src/output-json-ssh.h @@ -26,4 +26,10 @@ void TmModuleJsonSshLogRegister (void); +#ifdef HAVE_LIBJANSSON +#include "app-layer-ssh.h" + +void JsonSshLogJSON(json_t *js, SshState *tx); +#endif + #endif /* __OUTPUT_JSON_SSH_H__ */