smtp: implement DetectFlags API

pull/3182/head
Victor Julien 8 years ago
parent 1bed6e9cae
commit 73b59bda53

@ -1631,6 +1631,26 @@ static int SMTPSetTxDetectState(void *state, void *vtx, DetectEngineState *s)
return 0; return 0;
} }
static uint64_t SMTPGetTxDetectFlags(void *vtx, uint8_t dir)
{
SMTPTransaction *tx = (SMTPTransaction *)vtx;
if (dir & STREAM_TOSERVER) {
return tx->detect_flags_ts;
} else {
return tx->detect_flags_tc;
}
}
static void SMTPSetTxDetectFlags(void *vtx, uint8_t dir, uint64_t flags)
{
SMTPTransaction *tx = (SMTPTransaction *)vtx;
if (dir & STREAM_TOSERVER) {
tx->detect_flags_ts = flags;
} else {
tx->detect_flags_tc = flags;
}
}
/** /**
* \brief Register the SMTP Protocol parser. * \brief Register the SMTP Protocol parser.
*/ */
@ -1660,6 +1680,9 @@ void RegisterSMTPParsers(void)
AppLayerParserRegisterGetEventsFunc(IPPROTO_TCP, ALPROTO_SMTP, SMTPGetEvents); AppLayerParserRegisterGetEventsFunc(IPPROTO_TCP, ALPROTO_SMTP, SMTPGetEvents);
AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_SMTP, NULL, AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_SMTP, NULL,
SMTPGetTxDetectState, SMTPSetTxDetectState); SMTPGetTxDetectState, SMTPSetTxDetectState);
AppLayerParserRegisterDetectFlagsFuncs(IPPROTO_TCP, ALPROTO_SMTP,
SMTPGetTxDetectFlags, SMTPSetTxDetectFlags);
AppLayerParserRegisterLocalStorageFunc(IPPROTO_TCP, ALPROTO_SMTP, SMTPLocalStorageAlloc, AppLayerParserRegisterLocalStorageFunc(IPPROTO_TCP, ALPROTO_SMTP, SMTPLocalStorageAlloc,
SMTPLocalStorageFree); SMTPLocalStorageFree);

@ -66,6 +66,10 @@ typedef struct SMTPString_ {
typedef struct SMTPTransaction_ { typedef struct SMTPTransaction_ {
/** id of this tx, starting at 0 */ /** id of this tx, starting at 0 */
uint64_t tx_id; uint64_t tx_id;
uint64_t detect_flags_ts;
uint64_t detect_flags_tc;
int done; int done;
/** indicates loggers done logging */ /** indicates loggers done logging */
uint32_t logged; uint32_t logged;

Loading…
Cancel
Save