http: move from MpmIDs to DetectFlags API

pull/3182/head
Victor Julien 8 years ago
parent d0f19891b4
commit 00b0a41b55

@ -2748,26 +2748,37 @@ static int HTPSetTxDetectState(void *alstate, void *vtx, DetectEngineState *s)
return 0; return 0;
} }
static uint64_t HTPGetTxMpmIDs(void *vtx) static uint64_t HTPGetTxDetectFlags(void *vtx, uint8_t dir)
{ {
htp_tx_t *tx = (htp_tx_t *)vtx; htp_tx_t *tx = (htp_tx_t *)vtx;
HtpTxUserData *tx_ud = htp_tx_get_user_data(tx); HtpTxUserData *tx_ud = htp_tx_get_user_data(tx);
return tx_ud ? tx_ud->mpm_ids : 0; if (tx_ud) {
if (dir & STREAM_TOSERVER) {
return tx_ud->detect_flags_ts;
} else {
return tx_ud->detect_flags_tc;
}
}
return 0;
} }
static int HTPSetTxMpmIDs(void *vtx, uint64_t mpm_ids) static void HTPSetTxDetectFlags(void *vtx, uint8_t dir, uint64_t detect_flags)
{ {
htp_tx_t *tx = (htp_tx_t *)vtx; htp_tx_t *tx = (htp_tx_t *)vtx;
HtpTxUserData *tx_ud = htp_tx_get_user_data(tx); HtpTxUserData *tx_ud = htp_tx_get_user_data(tx);
if (tx_ud == NULL) { if (tx_ud == NULL) {
tx_ud = HTPMalloc(sizeof(*tx_ud)); tx_ud = HTPMalloc(sizeof(*tx_ud));
if (unlikely(tx_ud == NULL)) if (unlikely(tx_ud == NULL))
return -ENOMEM; return;
memset(tx_ud, 0, sizeof(*tx_ud)); memset(tx_ud, 0, sizeof(*tx_ud));
htp_tx_set_user_data(tx, tx_ud); htp_tx_set_user_data(tx, tx_ud);
} }
tx_ud->mpm_ids = mpm_ids; if (dir & STREAM_TOSERVER) {
return 0; tx_ud->detect_flags_ts = detect_flags;
} else {
tx_ud->detect_flags_tc = detect_flags;
}
return;
} }
static int HTPRegisterPatternsForProtocolDetection(void) static int HTPRegisterPatternsForProtocolDetection(void)
@ -2858,8 +2869,8 @@ void RegisterHTPParsers(void)
AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_HTTP, AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_HTTP,
HTPStateHasTxDetectState, HTPStateHasTxDetectState,
HTPGetTxDetectState, HTPSetTxDetectState); HTPGetTxDetectState, HTPSetTxDetectState);
AppLayerParserRegisterMpmIDsFuncs(IPPROTO_TCP, ALPROTO_HTTP, AppLayerParserRegisterDetectFlagsFuncs(IPPROTO_TCP, ALPROTO_HTTP,
HTPGetTxMpmIDs, HTPSetTxMpmIDs); HTPGetTxDetectFlags, HTPSetTxDetectFlags);
AppLayerParserRegisterParser(IPPROTO_TCP, ALPROTO_HTTP, STREAM_TOSERVER, AppLayerParserRegisterParser(IPPROTO_TCP, ALPROTO_HTTP, STREAM_TOSERVER,
HTPHandleRequestData); HTPHandleRequestData);

@ -188,8 +188,9 @@ typedef struct HtpBody_ {
/** Now the Body Chunks will be stored per transaction, at /** Now the Body Chunks will be stored per transaction, at
* the tx user data */ * the tx user data */
typedef struct HtpTxUserData_ { typedef struct HtpTxUserData_ {
/** flags to track which mpm has run */ /** detection engine flags */
uint64_t mpm_ids; uint64_t detect_flags_ts;
uint64_t detect_flags_tc;
/* Body of the request (if any) */ /* Body of the request (if any) */
uint8_t request_body_init; uint8_t request_body_init;

Loading…
Cancel
Save