suricata
app-layer-ftp.h
Go to the documentation of this file.
1/* Copyright (C) 2007-2025 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 Pablo Rincon Crespo <pablo.rincon.crespo@gmail.com>
22 * \author Jeff Lucovsky <jeff@lucovsky.org>
23 */
24
25#ifndef SURICATA_APP_LAYER_FTP_H
26#define SURICATA_APP_LAYER_FTP_H
27
28#include "rust.h"
29
30struct FtpCommand;
31
32typedef uint32_t FtpRequestCommandArgOfs;
33
34/** used to hold the line state when we have fragmentation. */
35typedef struct FtpLineState_ {
36 /** used to indicate if the current_line buffer is a malloced buffer. We
37 * use a malloced buffer, if a line is fragmented */
38 const uint8_t *buf;
39 uint32_t len;
40 uint8_t delim_len;
43
48
49/*
50 * These are the values for the table index value and the FTP command
51 * enum value. These *should* be the same if the enum and command insertion
52 * order remain the same. However, we store each value to protect against
53 * drift between enum and insertion order.
54 */
55typedef struct FtpCommandInfo_ {
57 FtpRequestCommand command_code;
59
60typedef struct FTPTransaction_ {
61 /** id of this tx, starting at 0 */
62 uint64_t tx_id;
63
65
66 /* for the request */
68 uint8_t *request;
70
71 /* for the command description */
73
74 uint16_t dyn_port; /* dynamic port, if applicable */
75 bool done; /* transaction complete? */
76 bool active; /* active or passive mode */
77
78 uint8_t direction;
79
80 /* Handle multiple responses */
82
85
86/** FTP State for app layer parser */
107
108/** FTP Data State for app layer parser */
121
122void RegisterFTPParsers(void);
123void FTPParserRegisterTests(void);
124void FTPParserCleanup(void);
125int FTPSetMemcap(uint64_t size);
126uint64_t FTPMemuseGlobalCounter(void);
127uint64_t FTPMemcapGlobalCounter(void);
128
129uint16_t JsonGetNextLineFromBuffer(const char *buffer, const uint16_t len);
130bool EveFTPDataAddMetadata(void *vtx, SCJsonBuilder *jb);
131
132#endif /* SURICATA_APP_LAYER_FTP_H */
uint8_t len
uint64_t FTPMemcapGlobalCounter(void)
bool EveFTPDataAddMetadata(void *vtx, SCJsonBuilder *jb)
struct FTPResponseWrapper_ FTPResponseWrapper
struct FtpLineState_ FtpLineState
struct FtpDataState_ FtpDataState
struct FtpState_ FtpState
int FTPSetMemcap(uint64_t size)
uint64_t FTPMemuseGlobalCounter(void)
void FTPParserRegisterTests(void)
void RegisterFTPParsers(void)
struct FTPTransaction_ FTPTransaction
uint16_t JsonGetNextLineFromBuffer(const char *buffer, const uint16_t len)
void FTPParserCleanup(void)
Free memory allocated for global FTP parser state.
uint32_t FtpRequestCommandArgOfs
struct FtpCommandInfo_ FtpCommandInfo
struct HtpBodyChunk_ * next
struct AppLayerTxData AppLayerTxData
struct AppLayerStateData AppLayerStateData
FTPResponseLine * response
TAILQ_ENTRY(FTPResponseWrapper_) next
FtpCommandInfo command_descriptor
TAILQ_HEAD(, FTPResponseWrapper_) response_list
uint8_t * request
AppLayerTxData tx_data
uint32_t request_length
TAILQ_ENTRY(FTPTransaction_) next
uint8_t command_index
FtpRequestCommand command_code
uint8_t * input
FtpRequestCommand command
FileContainer * files
AppLayerStateData state_data
uint8_t * file_name
AppLayerTxData tx_data
uint8_t delim_len
const uint8_t * buf
FtpRequestCommandArgOfs arg_offset
uint32_t port_line_size
uint16_t dyn_port
uint32_t port_line_len
uint64_t tx_cnt
TAILQ_HEAD(, FTPTransaction_) tx_list
AppLayerStateData state_data
bool current_line_truncated_tc
FTPTransaction * curr_tx
FtpRequestCommand command
bool current_line_truncated_ts
uint8_t * port_line