flags: u16,
c: *mut HttpRangeContainerBlock,
data: *const u8,
- data_len: u32);
+ data_len: u32) -> bool;
pub type SCFileOpenFileWithId = extern "C" fn (
file_container: &FileContainer,
sbcfg: &StreamingBufferConfig,
decoder: decompression::HTTP2Decoder,
pub file_range: *mut HttpRangeContainerBlock,
- tx_data: AppLayerTxData,
+ pub tx_data: AppLayerTxData,
pub ft_tc: FileTransferTracker,
ft_ts: FileTransferTracker,
pub fn http2_range_close(
tx: &mut HTTP2Transaction, files: &mut FileContainer, flags: u16, data: &[u8],
) {
- match unsafe { SC } {
- None => panic!("BUG no suricata_config"),
- Some(c) => {
- (c.HTPFileCloseHandleRange)(
+ let added = if let Some(c) = unsafe { SC } {
+ let added = (c.HTPFileCloseHandleRange)(
files,
flags,
tx.file_range,
data.as_ptr(),
data.len() as u32,
- );
- (c.HttpRangeFreeBlock)(tx.file_range);
- }
- }
+ );
+ (c.HttpRangeFreeBlock)(tx.file_range);
+ added
+ } else {
+ false
+ };
tx.file_range = std::ptr::null_mut();
+ if added {
+ tx.tx_data.incr_files_opened();
+ }
}
// Defined in app-layer-htp-range.h
SCReturnInt(retval);
}
-void HTPFileCloseHandleRange(FileContainer *files, const uint16_t flags, HttpRangeContainerBlock *c,
+/** \brief close range, add reassembled file if possible
+ * \retval true if reassembled file was added
+ * \retval false if no reassembled file was added
+ */
+bool HTPFileCloseHandleRange(FileContainer *files, const uint16_t flags, HttpRangeContainerBlock *c,
const uint8_t *data, uint32_t data_len)
{
+ bool added = false;
if (HttpRangeAppendData(c, data, data_len) < 0) {
SCLogDebug("Failed to append data");
}
if (ranged && files) {
/* HtpState owns the constructed file now */
FileContainerAdd(files, ranged);
+ added = true;
}
DEBUG_VALIDATE_BUG_ON(ranged && !files);
THashDataUnlock(c->container->hdata);
}
+ return added;
}
/**
int HTPParseContentRange(bstr *rawvalue, HTTPContentRange *range);
int HTPFileOpenWithRange(HtpState *, HtpTxUserData *, const uint8_t *, uint16_t, const uint8_t *,
uint32_t, uint64_t, bstr *rawvalue, HtpTxUserData *htud);
-void HTPFileCloseHandleRange(
+bool HTPFileCloseHandleRange(
FileContainer *, const uint16_t, HttpRangeContainerBlock *, const uint8_t *, uint32_t);
int HTPFileStoreChunk(HtpState *, const uint8_t *, uint32_t, uint8_t);
int HTPFileClose(HtpState *, const uint8_t *, uint32_t, uint8_t, uint8_t);
void (*AppLayerParserTriggerRawStreamReassembly)(Flow *, int direction);
void (*HttpRangeFreeBlock)(HttpRangeContainerBlock *);
- void (*HTPFileCloseHandleRange)(
+ bool (*HTPFileCloseHandleRange)(
FileContainer *, const uint16_t, HttpRangeContainerBlock *, const uint8_t *, uint32_t);
int (*FileOpenFileWithId)(FileContainer *, const StreamingBufferConfig *,