Feature #488 » 0001-Get-rid-of-AppLayerHtpRegisterExtraCallbacks.patch
src/app-layer-htp.c | ||
---|---|---|
{
|
||
SCEnter();
|
||
if (need_htp_request_body == 0)
|
||
SCReturnInt(HOOK_OK);
|
||
#ifdef PRINT
|
||
printf("HTPBODY START: \n");
|
||
PrintRawDataFp(stdout, (uint8_t *)d->data, d->len);
|
||
... | ... | |
{
|
||
SCEnter();
|
||
if (need_htp_response_body == 0)
|
||
SCReturnInt(HOOK_OK);
|
||
HtpState *hstate = (HtpState *)d->tx->connp->user_data;
|
||
if (hstate == NULL) {
|
||
SCReturnInt(HOOK_ERROR);
|
||
... | ... | |
HTPCallbackRequestUriNormalize);
|
||
#endif
|
||
htp_config_set_generate_request_uri_normalized(cfglist.cfg, 1);
|
||
htp_config_register_request_body_data(cfglist.cfg,
|
||
HTPCallbackRequestBodyData);
|
||
htp_config_register_response_body_data(cfglist.cfg,
|
||
HTPCallbackResponseBodyData);
|
||
default_config = ConfGetNode("libhtp.default-config");
|
||
if (NULL != default_config) {
|
||
... | ... | |
htprec->response_body_limit = HTP_CONFIG_DEFAULT_REQUEST_BODY_LIMIT;
|
||
htp_config_register_request(htp, HTPCallbackRequest);
|
||
htp_config_register_response(htp, HTPCallbackResponse);
|
||
htp_config_register_request_body_data(htp,
|
||
HTPCallbackRequestBodyData);
|
||
htp_config_register_response_body_data(htp,
|
||
HTPCallbackResponseBodyData);
|
||
#ifdef HAVE_HTP_URI_NORMALIZE_HOOK
|
||
htp_config_register_request_uri_normalize(htp,
|
||
HTPCallbackRequestUriNormalize);
|
||
... | ... | |
SCReturn;
|
||
}
|
||
/**
|
||
* \brief This function is called at the end of SigLoadSignatures. This function
|
||
* enables the htp layer to register a callback for the http request body.
|
||
* need_htp_request_body is a flag that informs the htp app layer that
|
||
* a module in the engine needs the http request body.
|
||
*/
|
||
void AppLayerHtpRegisterExtraCallbacks(void) {
|
||
SCEnter();
|
||
SCLogDebug("Registering extra htp callbacks");
|
||
HTPCfgRec *p_cfglist = &cfglist;
|
||
while (p_cfglist != NULL) {
|
||
if (need_htp_request_body == 1) {
|
||
SCLogDebug("Registering callback htp_config_register_request_body_data on htp");
|
||
htp_config_register_request_body_data(p_cfglist->cfg,
|
||
HTPCallbackRequestBodyData);
|
||
}
|
||
if (need_htp_response_body == 1) {
|
||
SCLogDebug("Registering callback htp_config_register_response_body_data on htp");
|
||
htp_config_register_response_body_data(p_cfglist->cfg,
|
||
HTPCallbackResponseBodyData);
|
||
}
|
||
p_cfglist = p_cfglist->next;
|
||
}
|
||
SCReturn;
|
||
}
|
||
#ifdef UNITTESTS
|
||
static HTPCfgRec cfglist_backup;
|
||
src/app-layer-htp.h | ||
---|---|---|
int HtpTransactionGetLoggableId(Flow *);
|
||
void HtpBodyPrint(HtpBody *);
|
||
void HtpBodyFree(HtpBody *);
|
||
void AppLayerHtpRegisterExtraCallbacks(void);
|
||
/* To free the state from unittests using app-layer-htp */
|
||
void HTPStateFree(void *);
|
||
void AppLayerHtpEnableRequestBodyCallback(void);
|
src/suricata.c | ||
---|---|---|
AppLayerHtpEnableRequestBodyCallback();
|
||
AppLayerHtpNeedFileInspection();
|
||
AppLayerHtpRegisterExtraCallbacks();
|
||
UtInitialize();
|
||
UTHRegisterTests();
|
||
... | ... | |
SCCudaPBSetUpQueuesAndBuffers();
|
||
#endif /* __SC_CUDA_SUPPORT__ */
|
||
AppLayerHtpRegisterExtraCallbacks();
|
||
SCThresholdConfInitContext(de_ctx,NULL);
|
||
SCAsn1LoadConfig();
|
||