http: support per TX destate storage

pull/1375/head
Victor Julien 10 years ago
parent 1cf02560c8
commit 6279da0fbd

@ -2629,6 +2629,28 @@ static void HTPStateTruncate(void *state, uint8_t direction)
}
}
static DetectEngineState *HTPGetTxDetectState(void *vtx)
{
htp_tx_t *tx = (htp_tx_t *)vtx;
HtpTxUserData *tx_ud = htp_tx_get_user_data(tx);
return tx_ud ? tx_ud->de_state : NULL;
}
static int HTPSetTxDetectState(void *vtx, DetectEngineState *s)
{
htp_tx_t *tx = (htp_tx_t *)vtx;
HtpTxUserData *tx_ud = htp_tx_get_user_data(tx);
if (tx_ud == NULL) {
tx_ud = HTPMalloc(sizeof(*tx_ud));
if (unlikely(tx_ud == NULL))
return -ENOMEM;
memset(tx_ud, 0, sizeof(*tx_ud));
htp_tx_set_user_data(tx, tx_ud);
}
tx_ud->de_state = s;
return 0;
}
static int HTPRegisterPatternsForProtocolDetection(void)
{
/* toserver */
@ -2758,6 +2780,8 @@ void RegisterHTPParsers(void)
AppLayerParserRegisterGetEventInfo(IPPROTO_TCP, ALPROTO_HTTP, HTPStateGetEventInfo);
AppLayerParserRegisterTruncateFunc(IPPROTO_TCP, ALPROTO_HTTP, HTPStateTruncate);
AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_HTTP,
HTPGetTxDetectState, HTPSetTxDetectState);
AppLayerParserRegisterParser(IPPROTO_TCP, ALPROTO_HTTP, STREAM_TOSERVER,
HTPHandleRequestData);

@ -36,6 +36,7 @@
#include "util-radix-tree.h"
#include "util-file.h"
#include "app-layer-htp-mem.h"
#include "detect-engine-state.h"
#include <htp/htp.h>
@ -228,6 +229,7 @@ typedef struct HtpTxUserData_ {
uint8_t request_body_type;
uint8_t response_body_type;
DetectEngineState *de_state;
} HtpTxUserData;
typedef struct HtpState_ {

Loading…
Cancel
Save