Applayer: remove obsolete StateUpdateTransactionId

Also, update StateTransactionFree to take an u64 tx id, so it's
consistant with the rest of the engine.

To reflect these changes, AppLayerRegisterTransactionIdFuncs has
been renamed to AppLayerRegisterTxFreeFunc.

HTP, DNS, SMB, DCERPC parsers updated.
pull/418/merge
Victor Julien 12 years ago
parent ebab9aee83
commit f59f90331d

@ -1866,20 +1866,6 @@ static void DCERPCStateFree(void *s) {
}
}
/**
* \brief Update the transaction id based on the DCERPC state
*/
void DCERPCUpdateTransactionId(void *state, uint16_t *id) {
SCEnter();
DCERPCState *s = (DCERPCState *)state;
SCLogDebug("original id %"PRIu16, *id);
(*id) = s->dcerpc.transaction_id;
SCLogDebug("updated id %"PRIu16, *id);
SCReturn;
}
void RegisterDCERPCParsers(void) {
char *proto_name = "dcerpc";
@ -1892,8 +1878,6 @@ void RegisterDCERPCParsers(void) {
DCERPCParseResponse);
AppLayerRegisterStateFuncs(ALPROTO_DCERPC, DCERPCStateAlloc,
DCERPCStateFree);
AppLayerRegisterTransactionIdFuncs(ALPROTO_DCERPC,
DCERPCUpdateTransactionId, NULL);
}
/* UNITTESTS */

@ -598,12 +598,12 @@ void DNSStateUpdateTransactionId(void *state, uint16_t *id) {
/**
* \brief dns transaction cleanup callback
*/
void DNSStateTransactionFree(void *state, uint16_t id) {
void DNSStateTransactionFree(void *state, uint64_t id) {
SCEnter();
DNSState *s = state;
SCLogDebug("state %p, id %"PRIu16, s, id);
SCLogDebug("state %p, id %"PRIu64, s, id);
/* we can't remove the actual transactions here */
@ -621,8 +621,8 @@ void RegisterDNSTCPParsers(void) {
DNSTCPResponseParse);
AppLayerRegisterStateFuncs(ALPROTO_DNS_TCP, DNSStateAlloc,
DNSStateFree);
AppLayerRegisterTransactionIdFuncs(ALPROTO_DNS_TCP,
DNSStateUpdateTransactionId, DNSStateTransactionFree);
AppLayerRegisterTxFreeFunc(ALPROTO_DNS_TCP,
DNSStateTransactionFree);
AppLayerRegisterGetEventsFunc(ALPROTO_DNS_TCP, DNSGetEvents);
AppLayerRegisterHasEventsFunc(ALPROTO_DNS_TCP, DNSHasEvents);

@ -293,38 +293,15 @@ static uint16_t DNSUdpProbingParser(uint8_t *input, uint32_t ilen)
return ALPROTO_DNS_UDP;
}
/**
* \brief Update the transaction id based on the dns state
*/
static void DNSStateUpdateTransactionId(void *state, uint16_t *id) {
SCEnter();
DNSState *s = state;
SCLogDebug("original id %"PRIu16", s->transaction_max %"PRIu64,
*id, (s->transaction_max));
if ((s->transaction_max) > (*id)) {
SCLogDebug("original id %"PRIu16", updating with s->transaction_max %"PRIu64,
*id, (s->transaction_max));
(*id) = (s->transaction_max);
SCLogDebug("updated id %"PRIu16, *id);
}
SCReturn;
}
/**
* \brief dns transaction cleanup callback
*/
static void DNSStateTransactionFree(void *state, uint16_t id) {
static void DNSStateTransactionFree(void *state, uint64_t id) {
SCEnter();
DNSState *s = state;
SCLogDebug("state %p, id %"PRIu16, s, id);
SCLogDebug("state %p, id %"PRIu64, s, id);
/* we can't remove the actual transactions here */
@ -342,8 +319,8 @@ void RegisterDNSUDPParsers(void) {
DNSUDPResponseParse);
AppLayerRegisterStateFuncs(ALPROTO_DNS_UDP, DNSStateAlloc,
DNSStateFree);
AppLayerRegisterTransactionIdFuncs(ALPROTO_DNS_UDP,
DNSStateUpdateTransactionId, DNSStateTransactionFree);
AppLayerRegisterTxFreeFunc(ALPROTO_DNS_UDP,
DNSStateTransactionFree);
AppLayerRegisterGetEventsFunc(ALPROTO_DNS_UDP, DNSGetEvents);
AppLayerRegisterHasEventsFunc(ALPROTO_DNS_UDP, DNSHasEvents);

@ -303,13 +303,13 @@ void HTPStateFree(void *state)
* \warning We cannot actually free the transactions here. It seems that
* HTP only accepts freeing of transactions in the response callback.
*/
void HTPStateTransactionFree(void *state, uint16_t id) {
void HTPStateTransactionFree(void *state, uint64_t id) {
SCEnter();
HtpState *s = (HtpState *)state;
s->transaction_done = id;
SCLogDebug("state %p, id %"PRIu16, s, id);
SCLogDebug("state %p, id %"PRIu64, s, id);
/* we can't remove the actual transactions here */
@ -2439,7 +2439,7 @@ void RegisterHTPParsers(void)
AlpProtoAdd(&alp_proto_ctx, proto_name, IPPROTO_TCP, ALPROTO_HTTP, "CONNECT|09|", 8, 0, STREAM_TOSERVER);
AppLayerRegisterStateFuncs(ALPROTO_HTTP, HTPStateAlloc, HTPStateFree);
AppLayerRegisterTransactionIdFuncs(ALPROTO_HTTP, NULL, HTPStateTransactionFree);
AppLayerRegisterTxFreeFunc(ALPROTO_HTTP, HTPStateTransactionFree);
AppLayerRegisterGetFilesFunc(ALPROTO_HTTP, HTPStateGetFiles);
AppLayerRegisterGetAlstateProgressFunc(ALPROTO_HTTP, HTPStateGetAlstateProgress);
AppLayerRegisterGetTxCnt(ALPROTO_HTTP, HTPStateGetTxCnt);

@ -734,10 +734,9 @@ void AppLayerRegisterStateFuncs(uint16_t proto, void *(*StateAlloc)(void),
al_proto_table[proto].StateFree = StateFree;
}
void AppLayerRegisterTransactionIdFuncs(uint16_t proto,
void (*StateUpdateTransactionId)(void *state, uint16_t *), void (*StateTransactionFree)(void *, uint16_t))
void AppLayerRegisterTxFreeFunc(uint16_t proto,
void (*StateTransactionFree)(void *, uint64_t))
{
al_proto_table[proto].StateUpdateTransactionId = StateUpdateTransactionId;
al_proto_table[proto].StateTransactionFree = StateTransactionFree;
}

@ -50,8 +50,7 @@ typedef struct AppLayerProto_ {
void *(*StateAlloc)(void);
void (*StateFree)(void *);
void (*StateUpdateTransactionId)(void *, uint16_t *);
void (*StateTransactionFree)(void *, uint16_t);
void (*StateTransactionFree)(void *, uint64_t);
void *(*LocalStorageAlloc)(void);
void (*LocalStorageFree)(void *);
@ -252,9 +251,6 @@ void AppLayerRegisterProbingParser(struct AlpProtoDetectCtx_ *, uint16_t, uint16
uint16_t (*ProbingParser)(uint8_t *, uint32_t));
void AppLayerRegisterStateFuncs(uint16_t proto, void *(*StateAlloc)(void),
void (*StateFree)(void *));
void AppLayerRegisterTransactionIdFuncs(uint16_t proto,
void (*StateTransactionId)(void *, uint16_t *),
void (*StateTransactionFree)(void *, uint16_t id));
void AppLayerRegisterLocalStorageFunc(uint16_t proto,
void *(*LocalStorageAlloc)(void),
void (*LocalStorageFree)(void *));
@ -272,6 +268,8 @@ const char *AppLayerGetProtoString(int proto);
void AppLayerRegisterTruncateFunc(uint16_t proto, void (*Truncate)(void *, uint8_t));
void AppLayerRegisterGetAlstateProgressFunc(uint16_t alproto,
int (*StateGetAlstateProgress)(void *alstate, uint8_t direction));
void AppLayerRegisterTxFreeFunc(uint16_t proto,
void (*StateTransactionFree)(void *, uint64_t));
void AppLayerRegisterGetTxCnt(uint16_t alproto,
uint64_t (*StateGetTxCnt)(void *alstate));
void AppLayerRegisterGetTx(uint16_t alproto,

@ -1354,20 +1354,6 @@ static void SMBStateFree(void *s) {
SCReturn;
}
/**
* \brief Update the transaction id based on the SMB state
*/
void SMBUpdateTransactionId(void *state, uint16_t *id) {
SCEnter();
SMBState *s = (SMBState *)state;
SCLogDebug("original id %"PRIu16, *id);
(*id) = s->transaction_id;
SCLogDebug("updated id %"PRIu16, *id);
SCReturn;
}
#define SMB_PROBING_PARSER_MIN_DEPTH 8
static uint16_t SMBProbingParser(uint8_t *input, uint32_t ilen)
@ -1423,8 +1409,6 @@ void RegisterSMBParsers(void) {
AppLayerRegisterProto(proto_name, ALPROTO_SMB, STREAM_TOSERVER, SMBParseRequest);
AppLayerRegisterProto(proto_name, ALPROTO_SMB, STREAM_TOCLIENT, SMBParseResponse);
AppLayerRegisterStateFuncs(ALPROTO_SMB, SMBStateAlloc, SMBStateFree);
AppLayerRegisterTransactionIdFuncs(ALPROTO_SMB,
SMBUpdateTransactionId, NULL);
AppLayerRegisterProbingParser(&alp_proto_ctx,
139,

Loading…
Cancel
Save