]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
eve/ftp: Move "get next line" into app-layer-ftp.c
authorJeff Lucovsky <jeff@lucovsky.org>
Sun, 21 Jul 2019 16:36:10 +0000 (12:36 -0400)
committerVictor Julien <victor@inliniac.net>
Mon, 26 Aug 2019 08:15:10 +0000 (10:15 +0200)
src/app-layer-ftp.c
src/app-layer-ftp.h
src/output-json-ftp.c

index 05a2bd65d5c78e5af9729cf49dcaa5417d80a4f9..a48facc150b92337305a8584312bd81ce66ff40d 100644 (file)
@@ -1364,6 +1364,32 @@ void FTPAtExitPrintStats(void)
 
 
 #ifdef HAVE_LIBJANSSON
+/*
+ * \brief Returns the ending offset of the next line from a multi-line buffer.
+ *
+ * "Buffer" refers to a FTP response in a single buffer containing multiple lines.
+ * Here, "next line" is defined as terminating on
+ * - Newline character
+ * - Null character
+ *
+ * \param buffer Contains zero or more characters.
+ * \param len Size, in bytes, of buffer.
+ *
+ * \retval Offset from the start of buffer indicating the where the
+ * next "line ends". The characters between the input buffer and this
+ * value comprise the line.
+ *
+ * NULL is found first or a newline isn't found, then
+ */
+uint16_t JsonGetNextLineFromBuffer(const char *buffer, const uint16_t len)
+{
+        if (!buffer || *buffer == '\0')
+                    return UINT16_MAX;
+
+            char *c = strchr(buffer, '\n');
+                return c == NULL ? len : c - buffer + 1;
+}
+
 json_t *JsonFTPDataAddMetadata(const Flow *f)
 {
     const FtpDataState *ftp_state = NULL;
index ec4a6ddd00681ecba0207fb68fd9012de15551f6..50b6082c9ae01a277f987c1e61b8c24368ac4540 100644 (file)
@@ -219,6 +219,7 @@ uint64_t FTPMemuseGlobalCounter(void);
 uint64_t FTPMemcapGlobalCounter(void);
 
 #ifdef HAVE_LIBJANSSON
+uint16_t JsonGetNextLineFromBuffer(const char *buffer, const uint16_t len);
 json_t *JsonFTPDataAddMetadata(const Flow *f);
 #endif
 
index 9f54c0e5e9d19bfdae4ef94f39fa290a307f0670..251d5f878d16f93fc61b64c1cb1476457b05e50a 100644 (file)
@@ -62,31 +62,6 @@ typedef struct LogFTPLogThread_ {
     MemBuffer          *buffer;
 } LogFTPLogThread;
 
-/*
- * \brief Returns the ending offset of the next line.
- *
- * Here, "next line" is defined as terminating on
- * - Newline character
- * - Null character
- *
- * \param buffer Contains zero or more characters.
- * \param len Size, in bytes, of buffer.
- *
- * \retval Offset from the start of buffer indicating the where the
- * next "line ends". The characters between the input buffer and this
- * value comprise the line.
- *
- * NULL is found first or a newline isn't found, then
- */
-static uint16_t JsonGetNextLineFromBuffer(const char *buffer, const uint16_t len)
-{
-    if (!buffer || *buffer == '\0')
-        return UINT16_MAX;
-
-    char *c = strchr(buffer, '\n');
-    return c == NULL ? len : c - buffer + 1;
-}
-
 static json_t *JsonFTPLogCommand(Flow *f, FTPTransaction *tx)
 {
     json_t *cjs = json_object();