Project

General

Profile

Feature #488 » 0001-Get-rid-of-AppLayerHtpRegisterExtraCallbacks.patch

Eric Leblond, 08/15/2012 07:07 AM

View differences:

src/app-layer-htp.c
1754 1754
{
1755 1755
    SCEnter();
1756 1756

  
1757
    if (need_htp_request_body == 0)
1758
        SCReturnInt(HOOK_OK);
1759

  
1757 1760
#ifdef PRINT
1758 1761
    printf("HTPBODY START: \n");
1759 1762
    PrintRawDataFp(stdout, (uint8_t *)d->data, d->len);
......
1874 1877
{
1875 1878
    SCEnter();
1876 1879

  
1880
    if (need_htp_response_body == 0)
1881
        SCReturnInt(HOOK_OK);
1882

  
1877 1883
    HtpState *hstate = (HtpState *)d->tx->connp->user_data;
1878 1884
    if (hstate == NULL) {
1879 1885
        SCReturnInt(HOOK_ERROR);
......
2230 2236
            htprec->response_body_limit = HTP_CONFIG_DEFAULT_REQUEST_BODY_LIMIT;
2231 2237
            htp_config_register_request(htp, HTPCallbackRequest);
2232 2238
            htp_config_register_response(htp, HTPCallbackResponse);
2239
            htp_config_register_request_body_data(htp,
2240
                                                  HTPCallbackRequestBodyData);
2241
            htp_config_register_response_body_data(htp,
2242
                                                   HTPCallbackResponseBodyData);
2233 2243
#ifdef HAVE_HTP_URI_NORMALIZE_HOOK
2234 2244
            htp_config_register_request_uri_normalize(htp,
2235 2245
                    HTPCallbackRequestUriNormalize);
......
2410 2420
    SCReturn;
2411 2421
}
2412 2422

  
2413
/**
2414
 * \brief This function is called at the end of SigLoadSignatures.  This function
2415
 *        enables the htp layer to register a callback for the http request body.
2416
 *        need_htp_request_body is a flag that informs the htp app layer that
2417
 *        a module in the engine needs the http request body.
2418
 */
2419
void AppLayerHtpRegisterExtraCallbacks(void) {
2420
    SCEnter();
2421
    SCLogDebug("Registering extra htp callbacks");
2422

  
2423
    HTPCfgRec *p_cfglist = &cfglist;
2424
    while (p_cfglist != NULL) {
2425
        if (need_htp_request_body == 1) {
2426
            SCLogDebug("Registering callback htp_config_register_request_body_data on htp");
2427
            htp_config_register_request_body_data(p_cfglist->cfg,
2428
                                                  HTPCallbackRequestBodyData);
2429
        }
2430
        if (need_htp_response_body == 1) {
2431
            SCLogDebug("Registering callback htp_config_register_response_body_data on htp");
2432
            htp_config_register_response_body_data(p_cfglist->cfg,
2433
                                                   HTPCallbackResponseBodyData);
2434
        }
2435
        p_cfglist = p_cfglist->next;
2436
    }
2437
    SCReturn;
2438
}
2439

  
2440

  
2441 2423
#ifdef UNITTESTS
2442 2424
static HTPCfgRec cfglist_backup;
2443 2425

  
src/app-layer-htp.h
224 224
int HtpTransactionGetLoggableId(Flow *);
225 225
void HtpBodyPrint(HtpBody *);
226 226
void HtpBodyFree(HtpBody *);
227
void AppLayerHtpRegisterExtraCallbacks(void);
228 227
/* To free the state from unittests using app-layer-htp */
229 228
void HTPStateFree(void *);
230 229
void AppLayerHtpEnableRequestBodyCallback(void);
src/suricata.c
1513 1513

  
1514 1514
        AppLayerHtpEnableRequestBodyCallback();
1515 1515
        AppLayerHtpNeedFileInspection();
1516
        AppLayerHtpRegisterExtraCallbacks();
1517 1516

  
1518 1517
        UtInitialize();
1519 1518
        UTHRegisterTests();
......
1745 1744
    SCCudaPBSetUpQueuesAndBuffers();
1746 1745
#endif /* __SC_CUDA_SUPPORT__ */
1747 1746

  
1748
    AppLayerHtpRegisterExtraCallbacks();
1749 1747
    SCThresholdConfInitContext(de_ctx,NULL);
1750 1748
    SCAsn1LoadConfig();
1751 1749

  
1752
- 
(2-2/4)