suricata
|
#include "suricata-common.h"
#include "app-layer-htp-file.h"
#include "app-layer-htp-range.h"
#include "app-layer-events.h"
#include "util-validate.h"
#include "stream-tcp.h"
#include "app-layer-parser.h"
#include "util-unittest-helper.h"
#include "tests/app-layer-htp-file.c"
Go to the source code of this file.
Functions | |
int | HTPFileOpen (HtpState *s, HtpTxUserData *tx, const uint8_t *filename, uint16_t filename_len, const uint8_t *data, uint32_t data_len, uint8_t direction) |
Open the file with "filename" and pass the first chunk of data if any. More... | |
int | HTPParseContentRange (bstr *rawvalue, HTTPContentRange *range) |
int | HTPFileOpenWithRange (HtpState *s, HtpTxUserData *txud, const uint8_t *filename, uint16_t filename_len, const uint8_t *data, uint32_t data_len, htp_tx_t *tx, bstr *rawvalue, HtpTxUserData *htud) |
Sets range for a file. More... | |
int | HTPFileStoreChunk (HtpTxUserData *tx, const uint8_t *data, uint32_t data_len, uint8_t direction) |
Store a chunk of data in the flow. More... | |
bool | HTPFileCloseHandleRange (const StreamingBufferConfig *sbcfg, FileContainer *files, const uint16_t flags, HttpRangeContainerBlock *c, const uint8_t *data, uint32_t data_len) |
close range, add reassembled file if possible More... | |
int | HTPFileClose (HtpTxUserData *tx, const uint8_t *data, uint32_t data_len, uint8_t flags, uint8_t direction) |
Close the file in the flow. More... | |
void | AppLayerHtpFileRegisterTests (void) |
this function registers unit tests for AppLayerHtpFile More... | |
void | HTPFileParserRegisterTests (void) |
Variables | |
StreamingBufferConfig | htp_sbcfg |
This file provides HTTP protocol file handling support for the engine using the HTP library.
Definition in file app-layer-htp-file.c.
void AppLayerHtpFileRegisterTests | ( | void | ) |
this function registers unit tests for AppLayerHtpFile
Definition at line 86 of file app-layer-htp-file.c.
References UtRegisterTest().
int HTPFileClose | ( | HtpTxUserData * | tx, |
const uint8_t * | data, | ||
uint32_t | data_len, | ||
uint8_t | flags, | ||
uint8_t | direction | ||
) |
Close the file in the flow.
tx | HtpTxUserData |
data | data chunk if any |
data_len | length of the data portion |
flags | flags to indicate events |
direction | flow direction |
Currently on the FLOW_FILE_TRUNCATED flag is implemented, indicating that the file isn't complete but we're stopping storing it.
0 | ok |
-1 | error |
-2 | not storing files on this flow/tx |
Definition at line 309 of file app-layer-htp-file.c.
References HtpTxUserData_::file_range, FILE_TRUNCATED, FileCloseFile(), HtpTxUserData_::files_tc, HtpTxUserData_::files_ts, flags, htp_sbcfg, HTPFileCloseHandleRange(), HttpRangeFreeBlock(), SCEnter, SCLogDebug, SCReturnInt, and HtpTxUserData_::tx_data.
bool HTPFileCloseHandleRange | ( | const StreamingBufferConfig * | sbcfg, |
FileContainer * | files, | ||
const uint16_t | flags, | ||
HttpRangeContainerBlock * | c, | ||
const uint8_t * | data, | ||
uint32_t | data_len | ||
) |
close range, add reassembled file if possible
true | if reassembled file was added |
false | if no reassembled file was added |
Definition at line 267 of file app-layer-htp-file.c.
Referenced by HTPFileClose().
int HTPFileOpen | ( | HtpState * | s, |
HtpTxUserData * | tx, | ||
const uint8_t * | filename, | ||
uint16_t | filename_len, | ||
const uint8_t * | data, | ||
uint32_t | data_len, | ||
uint8_t | direction | ||
) |
Open the file with "filename" and pass the first chunk of data if any.
s | http state |
filename | name of the file |
filename_len | length of the name |
data | data chunk (if any) |
data_len | length of the data portion |
direction | flow direction |
0 | ok |
-1 | error |
-2 | not handling files on this flow |
Definition at line 50 of file app-layer-htp-file.c.
References HtpState_::cfg, DEBUG_VALIDATE_BUG_ON, HtpTxUserData_::file_range, HtpState_::file_track_id, FileFlowFlagsToFlags(), FileOpenFileWithId(), HtpTxUserData_::files_tc, HtpTxUserData_::files_ts, FileSetInspectSizes(), flags, htp_sbcfg, HTPCfgDir_::inspect_min_size, HTPCfgDir_::inspect_window, HTPCfgRec_::request, HTPCfgRec_::response, SCLogDebug, SCReturnInt, FileContainer_::tail, and HtpTxUserData_::tx_data.
int HTPFileOpenWithRange | ( | HtpState * | s, |
HtpTxUserData * | txud, | ||
const uint8_t * | filename, | ||
uint16_t | filename_len, | ||
const uint8_t * | data, | ||
uint32_t | data_len, | ||
htp_tx_t * | tx, | ||
bstr * | rawvalue, | ||
HtpTxUserData * | htud | ||
) |
Sets range for a file.
s | http state |
rawvalue | raw header value |
0 | ok |
-1 | error |
Definition at line 149 of file app-layer-htp-file.c.
References DEBUG_VALIDATE_BUG_ON, flags, and SCEnter.
void HTPFileParserRegisterTests | ( | void | ) |
Definition at line 1218 of file app-layer-htp-file.c.
References UtRegisterTest().
int HTPFileStoreChunk | ( | HtpTxUserData * | tx, |
const uint8_t * | data, | ||
uint32_t | data_len, | ||
uint8_t | direction | ||
) |
Store a chunk of data in the flow.
s | HtpState |
tx | HtpTxUserData |
data | data chunk (if any) |
data_len | length of the data portion |
direction | flow direction |
0 | ok |
-1 | error |
-2 | file doesn't need storing |
Definition at line 223 of file app-layer-htp-file.c.
References HtpTxUserData_::file_range, FileAppendData(), HtpTxUserData_::files_tc, HtpTxUserData_::files_ts, htp_sbcfg, HttpRangeAppendData(), SCEnter, SCLogDebug, and SCReturnInt.
int HTPParseContentRange | ( | bstr * | rawvalue, |
HTTPContentRange * | range | ||
) |
Performs parsing of the content-range value
[in] | rawvalue | |
[out] | range |
Definition at line 96 of file app-layer-htp-file.c.
References len.
StreamingBufferConfig htp_sbcfg |
Definition at line 92 of file app-layer-htp.c.
Referenced by HTPFileClose(), HTPFileOpen(), and HTPFileStoreChunk().