app-layer: Use opaque pointers instead of void

For AppLayerThreadCtx, AppLayerParserState, AppLayerParserThreadCtx
and AppLayerProtoDetectThreadCtx, use opaque pointers instead of
void pointers.

AppLayerParserState is declared in flow.h as it's part of the Flow
structure.

AppLayerThreadCtx is declared in decode.h, as it's part of the
DecodeThreadVars structure.
pull/753/head
Victor Julien 13 years ago
parent c7ae662d26
commit 9634e60e7a

@ -46,7 +46,8 @@ enum {
};
static uint32_t FragmentDataParser(Flow *f, void *dcerpcudp_state,
void *pstate, uint8_t *input, uint32_t input_len)
AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len)
{
SCEnter();
DCERPCUDPState *sstate = (DCERPCUDPState *) dcerpcudp_state;
@ -120,7 +121,8 @@ end:
* fragmented packets.
*/
static int DCERPCUDPParseHeader(Flow *f, void *dcerpcudp_state,
void *pstate, uint8_t *input, uint32_t input_len)
AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len)
{
SCEnter();
uint8_t *p = input;
@ -702,7 +704,7 @@ static int DCERPCUDPParseHeader(Flow *f, void *dcerpcudp_state,
}
static int DCERPCUDPParse(Flow *f, void *dcerpc_state,
void *pstate,
AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len,
void *local_data)
{

@ -1891,7 +1891,7 @@ int32_t DCERPCParser(DCERPC *dcerpc, uint8_t *input, uint32_t input_len) {
}
static int DCERPCParse(Flow *f, void *dcerpc_state,
void *pstate,
AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len,
void *local_data, int dir) {
SCEnter();
@ -1917,7 +1917,7 @@ static int DCERPCParse(Flow *f, void *dcerpc_state,
}
static int DCERPCParseRequest(Flow *f, void *dcerpc_state,
void *pstate,
AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len,
void *local_data)
{
@ -1926,7 +1926,7 @@ static int DCERPCParseRequest(Flow *f, void *dcerpc_state,
}
static int DCERPCParseResponse(Flow *f, void *dcerpc_state,
void *pstate,
AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len,
void *local_data)
{

@ -25,6 +25,8 @@
#ifndef __APP_LAYER_DETECT_PROTO__H__
#define __APP_LAYER_DETECT_PROTO__H__
typedef struct AppLayerProtoDetectThreadCtx_ AppLayerProtoDetectThreadCtx;
typedef uint16_t (*ProbingParserFPtr)(uint8_t *input, uint32_t input_len,
uint32_t *offset);

@ -266,7 +266,7 @@ insufficient_data:
* \brief Parse DNS request packet
*/
static int DNSTCPRequestParse(Flow *f, void *dstate,
void *pstate,
AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len,
void *local_data)
{
@ -455,7 +455,7 @@ insufficient_data:
*
*/
static int DNSTCPResponseParse(Flow *f, void *dstate,
void *pstate,
AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len,
void *local_data)
{

@ -54,7 +54,7 @@
* \brief Parse DNS request packet
*/
static int DNSUDPRequestParse(Flow *f, void *dstate,
void *pstate,
AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len,
void *local_data)
{
@ -160,7 +160,7 @@ insufficient_data:
*
*/
static int DNSUDPResponseParse(Flow *f, void *dstate,
void *pstate,
AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len,
void *local_data)
{

@ -208,7 +208,7 @@ static int FTPParseRequestCommand(void *ftp_state, uint8_t *input,
* \retval 1 when the command is parsed, 0 otherwise
*/
static int FTPParseRequest(Flow *f, void *ftp_state,
void *pstate,
AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len,
void *local_data)
{
@ -257,7 +257,7 @@ static int FTPParseRequest(Flow *f, void *ftp_state,
*
* \retval 1 when the command is parsed, 0 otherwise
*/
static int FTPParseResponse(Flow *f, void *ftp_state, void *pstate,
static int FTPParseResponse(Flow *f, void *ftp_state, AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len,
void *local_data)
{

@ -613,7 +613,7 @@ static inline void HTPErrorCheckTxRequestFlags(HtpState *s, htp_tx_t *tx)
* \retval On success returns 1 or on failure returns -1.
*/
static int HTPHandleRequestData(Flow *f, void *htp_state,
void *pstate,
AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len,
void *local_data)
{
@ -749,7 +749,7 @@ error:
* \retval On success returns 1 or on failure returns -1
*/
static int HTPHandleResponseData(Flow *f, void *htp_state,
void *pstate,
AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len,
void *local_data)
{
@ -5517,7 +5517,7 @@ static int HTPBodyReassemblyTest01(void)
memset(&hstate, 0x00, sizeof(hstate));
Flow flow;
memset(&flow, 0x00, sizeof(flow));
void *parser = AppLayerParserStateAlloc();
AppLayerParserState *parser = AppLayerParserStateAlloc();
htp_tx_t tx;
memset(&tx, 0, sizeof(tx));

@ -80,7 +80,7 @@ typedef struct AppLayerParserProtoCtx_
{
/* 0 - to_server, 1 - to_client. */
int (*Parser[2])(Flow *f, void *protocol_state,
void *pstate,
AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len,
void *local_storage);
char logger;
@ -139,11 +139,10 @@ typedef struct AppLayerParserState_ {
static AppLayerParserCtx alp_ctx;
static void AppLayerParserTransactionsCleanup(uint8_t ipproto, AppProto alproto,
void *alstate, void *pstate)
void *alstate, AppLayerParserState *parser_state_store)
{
SCEnter();
AppLayerParserState *parser_state_store = pstate;
uint64_t inspect = 0, log = 0;
uint64_t min;
AppLayerParserProtoCtx *ctx = &alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto];
@ -170,7 +169,7 @@ static void AppLayerParserTransactionsCleanup(uint8_t ipproto, AppProto alproto,
SCReturn;
}
void *AppLayerParserStateAlloc(void)
AppLayerParserState *AppLayerParserStateAlloc(void)
{
SCEnter();
@ -180,15 +179,15 @@ void *AppLayerParserStateAlloc(void)
memset(pstate, 0, sizeof(*pstate));
end:
SCReturnPtr(pstate, "pstate");
SCReturnPtr(pstate, "AppLayerParserState");
}
void AppLayerParserStateFree(void *pstate)
void AppLayerParserStateFree(AppLayerParserState *pstate)
{
SCEnter();
if (((AppLayerParserState *)pstate)->decoder_events != NULL)
AppLayerDecoderEventsFreeEvents(((AppLayerParserState *)pstate)->decoder_events);
if (pstate->decoder_events != NULL)
AppLayerDecoderEventsFreeEvents(pstate->decoder_events);
SCFree(pstate);
SCReturn;
@ -210,7 +209,7 @@ int AppLayerParserDeSetup(void)
SCReturnInt(0);
}
void *AppLayerParserThreadCtxAlloc(void)
AppLayerParserThreadCtx *AppLayerParserThreadCtxAlloc(void)
{
SCEnter();
@ -234,13 +233,12 @@ void *AppLayerParserThreadCtxAlloc(void)
SCReturnPtr(tctx, "void *");
}
void AppLayerParserThreadCtxFree(void *alpd_tctx)
void AppLayerParserThreadCtxFree(AppLayerParserThreadCtx *tctx)
{
SCEnter();
AppProto i = 0;
int j = 0;
AppLayerParserThreadCtx *tctx = (AppLayerParserThreadCtx *)alpd_tctx;
for (i = 0; i < FLOW_PROTO_DEFAULT; i++) {
for (j = 0; j < ALPROTO_MAX; j++) {
@ -319,7 +317,7 @@ int AppLayerParserConfParserEnabled(const char *ipproto,
int AppLayerParserRegisterParser(uint8_t ipproto, AppProto alproto,
uint8_t direction,
int (*Parser)(Flow *f, void *protocol_state,
void *pstate,
AppLayerParserState *pstate,
uint8_t *buf, uint32_t buf_len,
void *local_storage))
{
@ -521,31 +519,30 @@ void AppLayerParserDestroyProtocolParserLocalStorage(uint8_t ipproto, AppProto a
SCReturn;
}
uint64_t AppLayerParserGetTransactionLogId(void *pstate)
uint64_t AppLayerParserGetTransactionLogId(AppLayerParserState *pstate)
{
SCEnter();
SCReturnCT(((AppLayerParserState *)pstate)->log_id, "uint64_t");
SCReturnCT(pstate->log_id, "uint64_t");
}
void AppLayerParserSetTransactionLogId(void *pstate)
void AppLayerParserSetTransactionLogId(AppLayerParserState *pstate)
{
SCEnter();
((AppLayerParserState *)pstate)->log_id++;
pstate->log_id++;
SCReturn;
}
uint64_t AppLayerParserGetTransactionInspectId(void *pstate, uint8_t direction)
uint64_t AppLayerParserGetTransactionInspectId(AppLayerParserState *pstate, uint8_t direction)
{
SCEnter();
SCReturnCT(((AppLayerParserState *)pstate)->
inspect_id[direction & STREAM_TOSERVER ? 0 : 1], "uint64_t");
SCReturnCT(pstate->inspect_id[direction & STREAM_TOSERVER ? 0 : 1], "uint64_t");
}
void AppLayerParserSetTransactionInspectId(void *pstate,
void AppLayerParserSetTransactionInspectId(AppLayerParserState *pstate,
uint8_t ipproto, AppProto alproto, void *alstate,
uint8_t direction)
{
@ -568,22 +565,22 @@ void AppLayerParserSetTransactionInspectId(void *pstate,
else
break;
}
((AppLayerParserState *)pstate)->inspect_id[dir] = idx;
pstate->inspect_id[dir] = idx;
SCReturn;
}
AppLayerDecoderEvents *AppLayerParserGetDecoderEvents(void *pstate)
AppLayerDecoderEvents *AppLayerParserGetDecoderEvents(AppLayerParserState *pstate)
{
SCEnter();
SCReturnPtr(((AppLayerParserState *)pstate)->decoder_events,
SCReturnPtr(pstate->decoder_events,
"AppLayerDecoderEvents *");
}
void AppLayerParserSetDecoderEvents(void *pstate, AppLayerDecoderEvents *devents)
void AppLayerParserSetDecoderEvents(AppLayerParserState *pstate, AppLayerDecoderEvents *devents)
{
(((AppLayerParserState *)pstate)->decoder_events) = devents;
pstate->decoder_events = devents;
}
AppLayerDecoderEvents *AppLayerParserGetEventsByTx(uint8_t ipproto, AppProto alproto,
@ -603,11 +600,10 @@ AppLayerDecoderEvents *AppLayerParserGetEventsByTx(uint8_t ipproto, AppProto alp
SCReturnPtr(ptr, "AppLayerDecoderEvents *");
}
uint16_t AppLayerParserGetStateVersion(void *pstate)
uint16_t AppLayerParserGetStateVersion(AppLayerParserState *pstate)
{
SCEnter();
SCReturnCT((pstate == NULL) ? 0 : ((AppLayerParserState *)pstate)->version,
"uint16_t");
SCReturnCT((pstate == NULL) ? 0 : pstate->version, "uint16_t");
}
FileContainer *AppLayerParserGetFiles(uint8_t ipproto, AppProto alproto,
@ -675,15 +671,15 @@ uint8_t AppLayerParserGetFirstDataDir(uint8_t ipproto, AppProto alproto)
first_data_dir, "uint8_t");
}
uint64_t AppLayerParserGetTransactionActive(uint8_t ipproto, AppProto alproto, void *pstate, uint8_t direction)
uint64_t AppLayerParserGetTransactionActive(uint8_t ipproto, AppProto alproto,
AppLayerParserState *pstate, uint8_t direction)
{
SCEnter();
AppLayerParserState *state = (AppLayerParserState *)pstate;
uint64_t active_id;
uint64_t log_id = state->log_id;
uint64_t inspect_id = state->inspect_id[direction & STREAM_TOSERVER ? 0 : 1];
uint64_t log_id = pstate->log_id;
uint64_t inspect_id = pstate->inspect_id[direction & STREAM_TOSERVER ? 0 : 1];
if (alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].logger == TRUE) {
active_id = (log_id < inspect_id) ? log_id : inspect_id;
} else {
@ -695,7 +691,7 @@ uint64_t AppLayerParserGetTransactionActive(uint8_t ipproto, AppProto alproto, v
/***** General *****/
int AppLayerParserParse(void *tctx, Flow *f, AppProto alproto,
int AppLayerParserParse(AppLayerParserThreadCtx *alp_tctx, Flow *f, AppProto alproto,
uint8_t flags, uint8_t *input, uint32_t input_len)
{
SCEnter();
@ -704,7 +700,6 @@ int AppLayerParserParse(void *tctx, Flow *f, AppProto alproto,
AppLayerParserProtoCtx *p = &alp_ctx.ctxs[FlowGetProtoMapping(f->proto)][alproto];
TcpSession *ssn = NULL;
void *alstate = NULL;
AppLayerParserThreadCtx *alp_tctx = (AppLayerParserThreadCtx *)tctx;
/* we don't have the parser registered for this protocol */
if (p->StateAlloc == NULL)
@ -796,7 +791,7 @@ int AppLayerParserParse(void *tctx, Flow *f, AppProto alproto,
SCReturnInt(-1);
}
void AppLayerParserSetEOF(void *pstate)
void AppLayerParserSetEOF(AppLayerParserState *pstate)
{
SCEnter();
@ -806,14 +801,14 @@ void AppLayerParserSetEOF(void *pstate)
AppLayerParserStateSetFlag(pstate, APP_LAYER_PARSER_EOF);
/* increase version so we will inspect it one more time
* with the EOF flags now set */
((AppLayerParserState *)pstate)->version++;
pstate->version++;
end:
SCReturn;
}
int AppLayerParserHasDecoderEvents(uint8_t ipproto, AppProto alproto,
void *alstate, void *pstate,
void *alstate, AppLayerParserState *pstate,
uint8_t flags)
{
SCEnter();
@ -884,7 +879,8 @@ void AppLayerParserTriggerRawStreamReassembly(Flow *f)
/***** Cleanup *****/
void AppLayerParserStateCleanup(uint8_t ipproto, AppProto alproto, void *alstate, void *pstate)
void AppLayerParserStateCleanup(uint8_t ipproto, AppProto alproto, void *alstate,
AppLayerParserState *pstate)
{
SCEnter();
@ -956,17 +952,17 @@ void AppLayerParserRegisterProtocolParsers(void)
}
void AppLayerParserStateSetFlag(void *pstate, uint8_t flag)
void AppLayerParserStateSetFlag(AppLayerParserState *pstate, uint8_t flag)
{
SCEnter();
((AppLayerParserState *)pstate)->flags |= flag;
pstate->flags |= flag;
SCReturn;
}
int AppLayerParserStateIssetFlag(void *pstate, uint8_t flag)
int AppLayerParserStateIssetFlag(AppLayerParserState *pstate, uint8_t flag)
{
SCEnter();
SCReturnInt(((AppLayerParserState *)pstate)->flags & flag);
SCReturnInt(pstate->flags & flag);
}
@ -983,14 +979,14 @@ void AppLayerParserStreamTruncated(uint8_t ipproto, AppProto alproto, void *alst
}
#ifdef DEBUG
void AppLayerParserStatePrintDetails(void *pstate)
void AppLayerParserStatePrintDetails(AppLayerParserState *pstate)
{
SCEnter();
if (pstate == NULL)
SCReturn;
AppLayerParserState *p = (AppLayerParserState *)pstate;
AppLayerParserState *p = pstate;
SCLogDebug("AppLayerParser parser state information for parser state p(%p). "
"p->inspect_id[0](%"PRIu64"), "
"p->inspect_id[1](%"PRIu64"), "
@ -1019,7 +1015,7 @@ typedef struct TestState_ {
* \brief Test parser function to test the memory deallocation of app layer
* parser of occurence of an error.
*/
static int TestProtocolParser(Flow *f, void *test_state, void *pstate,
static int TestProtocolParser(Flow *f, void *test_state, AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len,
void *local_data)
{

@ -36,13 +36,15 @@ int AppLayerParserSetup(void);
int AppLayerParserDeSetup(void);
typedef struct AppLayerParserThreadCtx_ AppLayerParserThreadCtx;
/**
* \brief Gets a new app layer protocol's parser thread context.
*
* \retval Non-NULL pointer on success.
* NULL pointer on failure.
*/
void *AppLayerParserThreadCtxAlloc(void);
AppLayerParserThreadCtx *AppLayerParserThreadCtxAlloc(void);
/**
* \brief Destroys the app layer parser thread context obtained
@ -50,7 +52,7 @@ void *AppLayerParserThreadCtxAlloc(void);
*
* \param tctx Pointer to the thread context to be destroyed.
*/
void AppLayerParserThreadCtxFree(void *tctx);
void AppLayerParserThreadCtxFree(AppLayerParserThreadCtx *tctx);
/**
* \brief Given a protocol name, checks if the parser is enabled in
@ -75,7 +77,7 @@ int AppLayerParserConfParserEnabled(const char *ipproto,
int AppLayerParserRegisterParser(uint8_t ipproto, AppProto alproto,
uint8_t direction,
int (*Parser)(Flow *f, void *protocol_state,
void *pstate,
AppLayerParserState *pstate,
uint8_t *buf, uint32_t buf_len,
void *local_storage));
void AppLayerParserRegisterParserAcceptableDataDirection(uint8_t ipproto,
@ -118,17 +120,17 @@ void AppLayerParserDestroyProtocolParserLocalStorage(uint8_t ipproto, AppProto a
void *local_data);
uint64_t AppLayerParserGetTransactionLogId(void *pstate);
void AppLayerParserSetTransactionLogId(void *pstate);
uint64_t AppLayerParserGetTransactionInspectId(void *pstate, uint8_t direction);
void AppLayerParserSetTransactionInspectId(void *pstate,
uint64_t AppLayerParserGetTransactionLogId(AppLayerParserState *pstate);
void AppLayerParserSetTransactionLogId(AppLayerParserState *pstate);
uint64_t AppLayerParserGetTransactionInspectId(AppLayerParserState *pstate, uint8_t direction);
void AppLayerParserSetTransactionInspectId(AppLayerParserState *pstate,
uint8_t ipproto, AppProto alproto, void *alstate,
uint8_t direction);
AppLayerDecoderEvents *AppLayerParserGetDecoderEvents(void *pstate);
void AppLayerParserSetDecoderEvents(void *pstate, AppLayerDecoderEvents *devents);
AppLayerDecoderEvents *AppLayerParserGetDecoderEvents(AppLayerParserState *pstate);
void AppLayerParserSetDecoderEvents(AppLayerParserState *pstate, AppLayerDecoderEvents *devents);
AppLayerDecoderEvents *AppLayerParserGetEventsByTx(uint8_t ipproto, AppProto alproto, void *alstate,
uint64_t tx_id);
uint16_t AppLayerParserGetStateVersion(void *pstate);
uint16_t AppLayerParserGetStateVersion(AppLayerParserState *pstate);
FileContainer *AppLayerParserGetFiles(uint8_t ipproto, AppProto alproto,
void *alstate, uint8_t direction);
int AppLayerParserGetStateProgress(uint8_t ipproto, AppProto alproto,
@ -140,16 +142,16 @@ int AppLayerParserGetStateProgressCompletionStatus(uint8_t ipproto, AppProto alp
int AppLayerParserGetEventInfo(uint8_t ipproto, AppProto alproto, const char *event_name,
int *event_id, AppLayerEventType *event_type);
uint64_t AppLayerParserGetTransactionActive(uint8_t ipproto, AppProto alproto, void *pstate, uint8_t direction);
uint64_t AppLayerParserGetTransactionActive(uint8_t ipproto, AppProto alproto, AppLayerParserState *pstate, uint8_t direction);
uint8_t AppLayerParserGetFirstDataDir(uint8_t ipproto, AppProto alproto);
/***** General *****/
int AppLayerParserParse(void *tctx, Flow *f, AppProto alproto,
int AppLayerParserParse(AppLayerParserThreadCtx *tctx, Flow *f, AppProto alproto,
uint8_t flags, uint8_t *input, uint32_t input_len);
void AppLayerParserSetEOF(void *pstate);
int AppLayerParserHasDecoderEvents(uint8_t ipproto, AppProto alproto, void *alstate, void *pstate,
void AppLayerParserSetEOF(AppLayerParserState *pstate);
int AppLayerParserHasDecoderEvents(uint8_t ipproto, AppProto alproto, void *alstate, AppLayerParserState *pstate,
uint8_t flags);
int AppLayerParserProtocolIsTxEventAware(uint8_t ipproto, AppProto alproto);
int AppLayerParserProtocolSupportsTxs(uint8_t ipproto, AppProto alproto);
@ -157,26 +159,26 @@ void AppLayerParserTriggerRawStreamReassembly(Flow *f);
/***** Cleanup *****/
void AppLayerParserStateCleanup(uint8_t ipproto, AppProto alproto, void *alstate, void *pstate);
void AppLayerParserStateCleanup(uint8_t ipproto, AppProto alproto, void *alstate, AppLayerParserState *pstate);
void AppLayerParserRegisterProtocolParsers(void);
void AppLayerParserStateSetFlag(void *pstate, uint8_t flag);
int AppLayerParserStateIssetFlag(void *pstate, uint8_t flag);
void AppLayerParserStateSetFlag(AppLayerParserState *pstate, uint8_t flag);
int AppLayerParserStateIssetFlag(AppLayerParserState *pstate, uint8_t flag);
void AppLayerParserStreamTruncated(uint8_t ipproto, AppProto alproto, void *alstate,
uint8_t direction);
void *AppLayerParserStateAlloc(void);
void AppLayerParserStateFree(void *pstate);
AppLayerParserState *AppLayerParserStateAlloc(void);
void AppLayerParserStateFree(AppLayerParserState *pstate);
#ifdef DEBUG
void AppLayerParserStatePrintDetails(void *pstate);
void AppLayerParserStatePrintDetails(AppLayerParserState *pstate);
#endif
/***** Unittests *****/

@ -66,7 +66,7 @@ enum {
*/
/* For WriteAndX we need to get writeandxdataoffset */
static uint32_t SMBParseWriteAndX(Flow *f, void *smb_state,
void *pstate, uint8_t *input, uint32_t input_len)
AppLayerParserState *pstate, uint8_t *input, uint32_t input_len)
{
SCEnter();
@ -264,7 +264,7 @@ static uint32_t SMBParseWriteAndX(Flow *f, void *smb_state,
* \brief SMB Read AndX Response Parsing
*/
static uint32_t SMBParseReadAndX(Flow *f, void *smb_state,
void *pstate, uint8_t *input, uint32_t input_len)
AppLayerParserState *pstate, uint8_t *input, uint32_t input_len)
{
SCEnter();
@ -403,7 +403,7 @@ static uint32_t SMBParseReadAndX(Flow *f, void *smb_state,
}
static uint32_t SMBParseTransact(Flow *f, void *smb_state,
void *pstate, uint8_t *input, uint32_t input_len)
AppLayerParserState *pstate, uint8_t *input, uint32_t input_len)
{
SCEnter();
@ -628,7 +628,7 @@ static uint32_t SMBParseTransact(Flow *f, void *smb_state,
/**
* Handle variable length padding for WriteAndX and ReadAndX
*/
static uint32_t PaddingParser(void *smb_state, void *pstate,
static uint32_t PaddingParser(void *smb_state, AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len)
{
SCEnter();
@ -660,7 +660,7 @@ static uint32_t PaddingParser(void *smb_state, void *pstate,
* \retval -1 f DCERPCParser does not validate
* \retval Number of bytes processed
*/
static int32_t DataParser(void *smb_state, void *pstate,
static int32_t DataParser(void *smb_state, AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len)
{
SCEnter();
@ -688,7 +688,7 @@ static int32_t DataParser(void *smb_state, void *pstate,
* Determine if this is an SMB AndX Command
*/
static uint32_t SMBGetWordCount(Flow *f, void *smb_state,
void *pstate, uint8_t *input, uint32_t input_len)
AppLayerParserState *pstate, uint8_t *input, uint32_t input_len)
{
SCEnter();
@ -712,7 +712,7 @@ static uint32_t SMBGetWordCount(Flow *f, void *smb_state,
*/
static uint32_t SMBGetByteCount(Flow *f, void *smb_state,
void *pstate, uint8_t *input, uint32_t input_len)
AppLayerParserState *pstate, uint8_t *input, uint32_t input_len)
{
SCEnter();
@ -743,7 +743,7 @@ static uint32_t SMBGetByteCount(Flow *f, void *smb_state,
* until sstate->wordcount.wordcount bytes are parsed.
*/
static uint32_t SMBParseWordCount(Flow *f, void *smb_state,
void *pstate, uint8_t *input, uint32_t input_len)
AppLayerParserState *pstate, uint8_t *input, uint32_t input_len)
{
SCEnter();
@ -800,7 +800,7 @@ static uint32_t SMBParseWordCount(Flow *f, void *smb_state,
* until sstate->bytecount.bytecount bytes are parsed.
*/
static uint32_t SMBParseByteCount(Flow *f, void *smb_state,
void *pstate, uint8_t *input, uint32_t input_len)
AppLayerParserState *pstate, uint8_t *input, uint32_t input_len)
{
SCEnter();
@ -868,7 +868,7 @@ static uint32_t SMBParseByteCount(Flow *f, void *smb_state,
* \retval 0 no input or already done
*/
static uint32_t NBSSParseHeader(Flow *f, void *smb_state,
void *pstate, uint8_t *input, uint32_t input_len)
AppLayerParserState *pstate, uint8_t *input, uint32_t input_len)
{
SCEnter();
@ -926,7 +926,7 @@ static uint32_t NBSSParseHeader(Flow *f, void *smb_state,
* \retval -1 error
*/
static int SMBParseHeader(Flow *f, void *smb_state,
void *pstate, uint8_t *input, uint32_t input_len)
AppLayerParserState *pstate, uint8_t *input, uint32_t input_len)
{
SCEnter();
@ -1155,7 +1155,7 @@ static int SMBParseHeader(Flow *f, void *smb_state,
SCReturnInt((p - input));
}
static int SMBParse(Flow *f, void *smb_state, void *pstate,
static int SMBParse(Flow *f, void *smb_state, AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len,
void *local_data, uint8_t dir)
{
@ -1372,14 +1372,14 @@ static int SMBParse(Flow *f, void *smb_state, void *pstate,
SCReturnInt(1);
}
static int SMBParseRequest(Flow *f, void *smb_state, void *pstate,
static int SMBParseRequest(Flow *f, void *smb_state, AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len,
void *local_data)
{
return SMBParse(f, smb_state, pstate, input, input_len, local_data, 0);
}
static int SMBParseResponse(Flow *f, void *smb_state, void *pstate,
static int SMBParseResponse(Flow *f, void *smb_state, AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len,
void *local_data)
{

@ -57,7 +57,7 @@ enum {
SMB_FIELD_MAX,
};
static uint32_t NBSSParseHeader(void *smb2_state, void *pstate,
static uint32_t NBSSParseHeader(void *smb2_state, AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len)
{
SCEnter();
@ -101,7 +101,7 @@ static uint32_t NBSSParseHeader(void *smb2_state, void *pstate,
SCReturnUInt((uint32_t)(p - input));
}
static uint32_t SMB2ParseHeader(void *smb2_state, void *pstate,
static uint32_t SMB2ParseHeader(void *smb2_state, AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len)
{
SCEnter();
@ -520,7 +520,7 @@ static uint32_t SMB2ParseHeader(void *smb2_state, void *pstate,
SCReturnUInt((uint32_t)(p - input));
}
static int SMB2Parse(Flow *f, void *smb2_state, void *pstate,
static int SMB2Parse(Flow *f, void *smb2_state, AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len,
void *local_data)
{

@ -460,7 +460,7 @@ static int SMTPInsertCommandIntoCommandBuffer(uint8_t command, SMTPState *state,
}
static int SMTPProcessCommandBDAT(SMTPState *state, Flow *f,
void *pstate)
AppLayerParserState *pstate)
{
SCEnter();
@ -480,7 +480,7 @@ static int SMTPProcessCommandBDAT(SMTPState *state, Flow *f,
}
static int SMTPProcessCommandDATA(SMTPState *state, Flow *f,
void *pstate)
AppLayerParserState *pstate)
{
SCEnter();
@ -502,13 +502,13 @@ static int SMTPProcessCommandDATA(SMTPState *state, Flow *f,
}
static int SMTPProcessCommandSTARTTLS(SMTPState *state, Flow *f,
void *pstate)
AppLayerParserState *pstate)
{
return 0;
}
static int SMTPProcessReply(SMTPState *state, Flow *f,
void *pstate)
AppLayerParserState *pstate)
{
SCEnter();
@ -644,7 +644,7 @@ static int SMTPParseCommandBDAT(SMTPState *state)
}
static int SMTPProcessRequest(SMTPState *state, Flow *f,
void *pstate)
AppLayerParserState *pstate)
{
SCEnter();
@ -703,7 +703,7 @@ static int SMTPProcessRequest(SMTPState *state, Flow *f,
}
static int SMTPParse(int direction, Flow *f, SMTPState *state,
void *pstate, uint8_t *input,
AppLayerParserState *pstate, uint8_t *input,
uint32_t input_len,
PatternMatcherQueue *local_data)
{
@ -733,7 +733,7 @@ static int SMTPParse(int direction, Flow *f, SMTPState *state,
}
static int SMTPParseClientRecord(Flow *f, void *alstate,
void *pstate,
AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len,
void *local_data)
{
@ -744,7 +744,7 @@ static int SMTPParseClientRecord(Flow *f, void *alstate,
}
static int SMTPParseServerRecord(Flow *f, void *alstate,
void *pstate,
AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len,
void *local_data)
{

@ -451,7 +451,7 @@ static int SSLv2ParseRecord(uint8_t direction, SSLState *ssl_state,
}
static int SSLv2Decode(uint8_t direction, SSLState *ssl_state,
void *pstate, uint8_t *input,
AppLayerParserState *pstate, uint8_t *input,
uint32_t input_len)
{
int retval = 0;
@ -679,7 +679,7 @@ static int SSLv2Decode(uint8_t direction, SSLState *ssl_state,
}
static int SSLv3Decode(uint8_t direction, SSLState *ssl_state,
void *pstate, uint8_t *input,
AppLayerParserState *pstate, uint8_t *input,
uint32_t input_len)
{
int retval = 0;
@ -807,7 +807,7 @@ static int SSLv3Decode(uint8_t direction, SSLState *ssl_state,
*
* \retval >=0 On success.
*/
static int SSLDecode(Flow *f, uint8_t direction, void *alstate, void *pstate,
static int SSLDecode(Flow *f, uint8_t direction, void *alstate, AppLayerParserState *pstate,
uint8_t *input, uint32_t ilen)
{
SSLState *ssl_state = (SSLState *)alstate;
@ -931,14 +931,14 @@ static int SSLDecode(Flow *f, uint8_t direction, void *alstate, void *pstate,
return 1;
}
int SSLParseClientRecord(Flow *f, void *alstate, void *pstate,
int SSLParseClientRecord(Flow *f, void *alstate, AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len,
void *local_data)
{
return SSLDecode(f, 0 /* toserver */, alstate, pstate, input, input_len);
}
int SSLParseServerRecord(Flow *f, void *alstate, void *pstate,
int SSLParseServerRecord(Flow *f, void *alstate, AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len,
void *local_data)
{

@ -48,9 +48,9 @@
*/
typedef struct AppLayerThreadCtx_ {
/* App layer protocol detection thread context, from AppLayerProtoDetectGetCtxThread(). */
void *alpd_tctx;
AppLayerProtoDetectThreadCtx *alpd_tctx;
/* App layer parser thread context, from AppLayerParserThreadCtxAlloc(). */
void *alp_tctx;
AppLayerParserThreadCtx *alp_tctx;
#ifdef PROFILING
uint64_t ticks_start;
@ -419,12 +419,10 @@ int AppLayerHandleTCPMsg(StreamMsg *smsg)
SCReturnInt(0);
}
int AppLayerHandleUdp(void *app_tctx, Packet *p, Flow *f)
int AppLayerHandleUdp(AppLayerThreadCtx *tctx, Packet *p, Flow *f)
{
SCEnter();
AppLayerThreadCtx *tctx = (AppLayerThreadCtx *)app_tctx;
int r = 0;
FLOWLOCK_WRLOCK(f);
@ -543,7 +541,7 @@ int AppLayerDeSetup(void)
SCReturnInt(0);
}
void *AppLayerGetCtxThread(void)
AppLayerThreadCtx *AppLayerGetCtxThread(void)
{
SCEnter();
@ -565,11 +563,10 @@ void *AppLayerGetCtxThread(void)
SCReturnPtr(app_tctx, "void *");
}
void AppLayerDestroyCtxThread(void *tctx)
void AppLayerDestroyCtxThread(AppLayerThreadCtx *app_tctx)
{
SCEnter();
AppLayerThreadCtx *app_tctx = (AppLayerThreadCtx *)tctx;
if (app_tctx == NULL)
SCReturn;
@ -584,16 +581,14 @@ void AppLayerDestroyCtxThread(void *tctx)
/* profiling */
void AppLayerProfilingReset(void *tctx) {
void AppLayerProfilingReset(AppLayerThreadCtx *app_tctx) {
#ifdef PROFILING
AppLayerThreadCtx *app_tctx = tctx;
PACKET_PROFILING_APP_RESET(app_tctx);
#endif
}
void AppLayerProfilingStore(void *tctx, Packet *p) {
void AppLayerProfilingStore(AppLayerThreadCtx *app_tctx, Packet *p) {
#ifdef PROFILING
AppLayerThreadCtx *app_tctx = tctx;
PACKET_PROFILING_APP_STORE(app_tctx, p);
#endif
}

@ -60,7 +60,7 @@ int AppLayerHandleTCPMsg(StreamMsg *smsg);
/**
* \brief Handles an udp chunk.
*/
int AppLayerHandleUdp(void *app_tctx, Packet *p, Flow *f);
int AppLayerHandleUdp(AppLayerThreadCtx *app_tctx, Packet *p, Flow *f);
/***** Utility *****/
@ -109,18 +109,18 @@ int AppLayerDeSetup(void);
* \retval Pointer to the newly create thread context, on success;
* NULL, on failure.
*/
void *AppLayerGetCtxThread(void);
AppLayerThreadCtx *AppLayerGetCtxThread(void);
/**
* \brief Destroys the context created by AppLayeGetCtxThread().
*
* \param tctx Pointer to the thread context to destroy.
*/
void AppLayerDestroyCtxThread(void *tctx);
void AppLayerDestroyCtxThread(AppLayerThreadCtx *tctx);
void AppLayerProfilingReset(void *tctx);
void AppLayerProfilingStore(void *tctx, Packet *p);
void AppLayerProfilingReset(AppLayerThreadCtx *tctx);
void AppLayerProfilingStore(AppLayerThreadCtx *tctx, Packet *p);
/***** Unittests *****/

@ -83,6 +83,8 @@ enum PktSrcEnum {
#include "app-layer-protos.h"
typedef struct AppLayerThreadCtx_ AppLayerThreadCtx;
/* forward declaration */
struct DetectionEngineThreadCtx_;
@ -552,7 +554,7 @@ typedef struct PacketQueue_ {
typedef struct DecodeThreadVars_
{
/** Specific context for udp protocol detection (here atm) */
void *app_tctx;
AppLayerThreadCtx *app_tctx;
int vlan_disabled;

@ -30,6 +30,10 @@
#include "detect-tag.h"
#include "util-optimize.h"
/* Part of the flow structure, so we declare it here.
* The actual declaration is in app-layer-parser.c */
typedef struct AppLayerParserState_ AppLayerParserState;
#define FLOW_QUIET TRUE
#define FLOW_VERBOSE FALSE
@ -346,7 +350,7 @@ typedef struct Flow_
/** application level storage ptrs.
*
*/
void *alparser; /**< parser internal state */
AppLayerParserState *alparser; /**< parser internal state */
void *alstate; /**< application layer state */
/** detection engine state */

Loading…
Cancel
Save