}
}
+static void HTPStateTruncate(void *state, uint8_t flags) {
+ FileContainer *fc = HTPStateGetFiles(state, flags);
+ if (fc != NULL) {
+ FileTruncateAllOpenFiles(fc);
+ }
+}
+
/**
* \brief Register the HTTP protocol and state handling functions to APP layer
* of the engine.
AppLayerDecoderEventsModuleRegister(ALPROTO_HTTP, http_decoder_event_table);
+ AppLayerRegisterTruncateFunc(ALPROTO_HTTP, HTPStateTruncate);
+
AppLayerRegisterProto(proto_name, ALPROTO_HTTP, STREAM_TOSERVER,
HTPHandleRequestData);
AppLayerRegisterProto(proto_name, ALPROTO_HTTP, STREAM_TOCLIENT,
return;
}
+void AppLayerRegisterTruncateFunc(uint16_t proto, void (*Truncate)(void *, uint8_t))
+{
+ al_proto_table[proto].Truncate = Truncate;
+
+ return;
+}
+
+void AppLayerStreamTruncated(uint16_t proto, void *state, uint8_t flags) {
+ if (al_proto_table[proto].Truncate != NULL) {
+ al_proto_table[proto].Truncate(state, flags);
+ }
+}
+
void *AppLayerGetProtocolParserLocalStorage(uint16_t proto)
{
if (al_proto_table[proto].LocalStorageAlloc != NULL) {
parser_state_store->id_flags |= APP_LAYER_TRANSACTION_EOF;
}
+ /* stream truncated, inform app layer */
+ if (flags & STREAM_DEPTH) {
+ AppLayerStreamTruncated(proto, app_layer_state, flags);
+ }
+
SCReturnInt(0);
error:
void (*StateTransactionFree)(void *, uint16_t);
void *(*LocalStorageAlloc)(void);
void (*LocalStorageFree)(void *);
+
+ /** truncate state after a gap/depth event */
+ void (*Truncate)(void *, uint8_t);
FileContainer *(*StateGetFiles)(void *, uint8_t);
} AppLayerProto;
FileContainer *(*StateGetFile)(void *, uint8_t));
void AppLayerRegisterLogger(uint16_t proto);
uint16_t AppLayerGetProtoByName(const char *);
+void AppLayerRegisterTruncateFunc(uint16_t proto, void (*Truncate)(void *, uint8_t));
int AppLayerParse(void *, Flow *, uint8_t,
uint8_t, uint8_t *, uint32_t);
} else { \
flag |= STREAM_TOSERVER; \
} \
+ if (stream->flags & STREAMTCP_STREAM_FLAG_DEPTH_REACHED) { \
+ flag |= STREAM_DEPTH; \
+ } \
}
#define STREAM_SET_INLINE_FLAGS(ssn, stream, p, flag) { \
} else { \
flag |= STREAM_TOCLIENT; \
} \
+ if (stream->flags & STREAMTCP_STREAM_FLAG_DEPTH_REACHED) { \
+ flag |= STREAM_DEPTH; \
+ } \
}
static void StreamTcpSetupMsg(TcpSession *ssn, TcpStream *stream, Packet *p,
#define STREAM_EOF 0x02
#define STREAM_TOSERVER 0x04
#define STREAM_TOCLIENT 0x08
-#define STREAM_GAP 0x10
+#define STREAM_GAP 0x10 /* data gap encountered */
+#define STREAM_DEPTH 0x20 /* depth reached */
/** size of the data chunks sent to the app layer parser. */
#define MSG_DATA_SIZE 4024 /* 4096 - 72 (size of rest of the struct) */
}
}
+void FileTruncateAllOpenFiles(FileContainer *fc) {
+ File *ptr = NULL;
+
+ SCEnter();
+
+ if (fc != NULL) {
+ for (ptr = fc->head; ptr != NULL; ptr = ptr->next) {
+ if (ptr->state == FILE_STATE_OPENED) {
+ FileCloseFilePtr(ptr, NULL, 0, FILE_TRUNCATED);
+ }
+ }
+ }
+}
void FileStoreAllFilesForTx(FileContainer *, uint16_t);
void FileStoreFileById(FileContainer *fc, uint16_t);
+void FileTruncateAllOpenFiles(FileContainer *);
+
#endif /* __UTIL_FILE_H__ */