]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect: remove unused dport sgh hash
authorVictor Julien <victor@inliniac.net>
Mon, 12 Oct 2015 19:33:44 +0000 (21:33 +0200)
committerVictor Julien <victor@inliniac.net>
Tue, 5 Apr 2016 07:30:11 +0000 (09:30 +0200)
src/detect-engine-port.h
src/detect-engine-siggroup.c
src/detect-engine.c
src/detect.c
src/detect.h

index e23c1e476e63e899aaba14357d5ee24e146aa4bd..1c089e9f9648ffe782a941605a8fde9d7fa8ee08 100644 (file)
@@ -33,26 +33,10 @@ int DetectPortInsertCopy(DetectEngineCtx *,DetectPort **, DetectPort *);
 int DetectPortInsert(DetectEngineCtx *,DetectPort **, DetectPort *);
 void DetectPortCleanupList (DetectPort *head);
 
-DetectPort *DetectPortLookup(DetectPort *head, DetectPort *dp);
-int DetectPortAdd(DetectPort **head, DetectPort *dp);
-
 DetectPort *DetectPortLookupGroup(DetectPort *dp, uint16_t port);
 
 void DetectPortPrintMemory(void);
 
-DetectPort *DetectPortDpHashLookup(DetectEngineCtx *, DetectPort *);
-DetectPort *DetectPortDpHashGetListPtr(DetectEngineCtx *);
-int DetectPortDpHashInit(DetectEngineCtx *);
-void DetectPortDpHashFree(DetectEngineCtx *);
-int DetectPortDpHashAdd(DetectEngineCtx *, DetectPort *);
-void DetectPortDpHashReset(DetectEngineCtx *);
-
-DetectPort *DetectPortSpHashLookup(DetectEngineCtx *, DetectPort *);
-int DetectPortSpHashInit(DetectEngineCtx *);
-void DetectPortSpHashFree(DetectEngineCtx *);
-int DetectPortSpHashAdd(DetectEngineCtx *, DetectPort *);
-void DetectPortSpHashReset(DetectEngineCtx *);
-
 int DetectPortJoin(DetectEngineCtx *,DetectPort *target, DetectPort *source);
 
 void DetectPortPrint(DetectPort *);
index 544a32d29176c066f0cf26d0c88a94e2aca84a40..243cf6aeb7efb176a5fcbb4f4373a3abba9738b1 100644 (file)
@@ -344,185 +344,6 @@ void SigGroupHeadHashFree(DetectEngineCtx *de_ctx)
     return;
 }
 
-/**
- * \brief Initializes the dport based SigGroupHead hash table to hold the
- *        SigGroupHeads.  The hash table that would be initialized is
- *        DetectEngineCtx->sgh_dport_hash_table.
- *
- * \param de_ctx Pointer to the detection engine context.
- *
- * \retval  0 On success.
- * \retval -1 On failure.
- */
-int SigGroupHeadDPortHashInit(DetectEngineCtx *de_ctx)
-{
-    de_ctx->sgh_dport_hash_table = HashListTableInit(4096, SigGroupHeadHashFunc,
-                                                     SigGroupHeadCompareFunc,
-                                                     NULL);
-    if (de_ctx->sgh_dport_hash_table == NULL)
-        goto error;
-
-    return 0;
-
-error:
-    return -1;
-}
-
-/**
- * \brief Adds a SigGroupHead to the detection engine context dport based
- *        SigGroupHead hash table(DetectEngineCtx->sgh_dport_hash_table).
- *
- * \param de_ctx Pointer to the detection engine context.
- * \param sgh    Pointer to the SigGroupHead.
- *
- * \retval ret 0 on Successfully adding the argument sgh and -1 on failure.
- */
-int SigGroupHeadDPortHashAdd(DetectEngineCtx *de_ctx, SigGroupHead *sgh)
-{
-    int ret = HashListTableAdd(de_ctx->sgh_dport_hash_table, (void *)sgh, 0);
-
-    return ret;
-}
-
-/**
- * \brief Used to lookup a SigGroupHead hash from the detection engine ctx dport
- *        based SigGroupHead hash table(DetectEngineCtx->sgh_dport_hash_table).
- *
- * \param de_ctx Pointer to the detection engine context.
- * \param sgh    Pointer to the SigGroupHead.
- *
- * \retval rsgh On success a pointer to the SigGroupHead if the SigGroupHead is
- *              found in the hash table; NULL on failure.
- */
-SigGroupHead *SigGroupHeadDPortHashLookup(DetectEngineCtx *de_ctx,
-                                          SigGroupHead *sgh)
-{
-    SCEnter();
-
-    SigGroupHead *rsgh = HashListTableLookup(de_ctx->sgh_dport_hash_table,
-                                             (void *)sgh, 0);
-
-    SCReturnPtr(rsgh,"SigGroupHead");
-}
-
-/**
- * \brief Frees the hash table - DetectEngineCtx->sgh_dport_hash_table,
- *        allocated by the SigGroupHeadDPortHashInit() function.
- *
- * \param de_ctx Pointer to the detection engine context.
- */
-void SigGroupHeadDPortHashFree(DetectEngineCtx *de_ctx)
-{
-    if (de_ctx->sgh_dport_hash_table == NULL)
-        return;
-
-    HashListTableFree(de_ctx->sgh_dport_hash_table);
-    de_ctx->sgh_dport_hash_table = NULL;
-
-    return;
-}
-
-/**
- * \brief Used to free the signature array, content_array and uri_content_array
- *        members from the SigGroupHeads in the HashListTable.
- *
- * \param de_ctx Pointer to the detection engine context.
- * \param ht     Pointer to the HashListTable
- */
-static void SigGroupHeadFreeSigArraysHash2(DetectEngineCtx *de_ctx,
-                                           HashListTable *ht)
-{
-    HashListTableBucket *htb = NULL;
-    SigGroupHead *sgh = NULL;
-
-    for (htb = HashListTableGetListHead(ht);
-         htb != NULL;
-         htb = HashListTableGetListNext(htb))
-    {
-        sgh = (SigGroupHead *)HashListTableGetListData(htb);
-        if (sgh == NULL) {
-            continue;
-        }
-
-        if (sgh->init->sig_array != NULL) {
-            detect_siggroup_sigarray_free_cnt++;
-            detect_siggroup_sigarray_memory -= sgh->init->sig_size;
-
-            SCFree(sgh->init->sig_array);
-            sgh->init->sig_array = NULL;
-            sgh->init->sig_size = 0;
-        }
-
-        SigGroupHeadInitDataFree(sgh->init);
-        sgh->init = NULL;
-    }
-
-    return;
-}
-
-/**
- * \brief Used to free the sig_array member of the SigGroupHeads present
- *        in the HashListTable.
- *
- * \param de_ctx Pointer to the detection engine context.
- * \param ht     Pointer to the HashListTable
- */
-static void SigGroupHeadFreeSigArraysHash(DetectEngineCtx *de_ctx,
-                                          HashListTable *ht)
-{
-    HashListTableBucket *htb = NULL;
-    SigGroupHead *sgh = NULL;
-
-    for (htb = HashListTableGetListHead(ht);
-         htb != NULL;
-         htb = HashListTableGetListNext(htb)) {
-        sgh = (SigGroupHead *)HashListTableGetListData(htb);
-
-        if (sgh->init != NULL) {
-            SigGroupHeadInitDataFree(sgh->init);
-            sgh->init = NULL;
-        }
-    }
-
-    return;
-}
-
-/**
- * \brief Free the sigarrays in the sgh's. Those are only used during the init
- *        stage.
- *
- * \param de_ctx Pointer to the detection engine context whose sigarrays have to
- *               be freed.
- */
-void SigGroupHeadFreeSigArrays(DetectEngineCtx *de_ctx)
-{
-    SigGroupHeadFreeSigArraysHash2(de_ctx, de_ctx->sgh_hash_table);
-    SigGroupHeadFreeSigArraysHash(de_ctx, de_ctx->sgh_dport_hash_table);
-
-    return;
-}
-
-/**
- * \brief Free the mpm arrays that are only used during the init stage.
- *
- * \param de_ctx Pointer to the detection engine context.
- */
-void SigGroupHeadFreeMpmArrays(DetectEngineCtx *de_ctx)
-{
-    HashListTableBucket *htb = NULL;
-    SigGroupHead *sgh = NULL;
-
-    for (htb = HashListTableGetListHead(de_ctx->sgh_dport_hash_table); htb != NULL; htb = HashListTableGetListNext(htb)) {
-        sgh = (SigGroupHead *)HashListTableGetListData(htb);
-        if (sgh->init != NULL) {
-            SigGroupHeadInitDataFree(sgh->init);
-            sgh->init = NULL;
-        }
-    }
-
-    return;
-}
-
 static uint16_t SignatureGetMpmPatternLen(const Signature *s, const int list)
 {
     if (s->sm_lists[list] != NULL && s->mpm_sm != NULL &&
@@ -1106,28 +927,6 @@ static int SigGroupHeadTest03(void)
     return result;
 }
 
-/**
- * \test Check if a SigGroupHead dport hash table is properly allocated and
- *       deallocated when calling SigGroupHeadDPortHashInit() and
- *       SigGroupHeadDportHashFree() respectively.
- */
-static int SigGroupHeadTest04(void)
-{
-    int result = 1;
-
-    DetectEngineCtx de_ctx;
-
-    SigGroupHeadDPortHashInit(&de_ctx);
-
-    result &= (de_ctx.sgh_dport_hash_table != NULL);
-
-    SigGroupHeadDPortHashFree(&de_ctx);
-
-    result &= (de_ctx.sgh_dport_hash_table == NULL);
-
-    return result;
-}
-
 /**
  * \test Check if a SigGroupHeadAppendSig() correctly appends a sid to a
  *       SigGroupHead() and SigGroupHeadContainsSigId() correctly indicates
@@ -1591,7 +1390,6 @@ void SigGroupHeadRegisterTests(void)
 {
 #ifdef UNITTESTS
     UtRegisterTest("SigGroupHeadTest03", SigGroupHeadTest03, 1);
-    UtRegisterTest("SigGroupHeadTest04", SigGroupHeadTest04, 1);
     UtRegisterTest("SigGroupHeadTest06", SigGroupHeadTest06, 1);
     UtRegisterTest("SigGroupHeadTest07", SigGroupHeadTest07, 1);
     UtRegisterTest("SigGroupHeadTest08", SigGroupHeadTest08, 1);
index deecae489535426ab6a49e1865e1a6a1630be123..842e8db261256ca5afdb5d3a2b2b3c75988e87c3 100644 (file)
@@ -872,7 +872,6 @@ static DetectEngineCtx *DetectEngineCtxInitReal(int minimal, const char *prefix)
 
     SigGroupHeadHashInit(de_ctx);
     MpmStoreInit(de_ctx);
-    SigGroupHeadDPortHashInit(de_ctx);
     ThresholdHashInit(de_ctx);
     VariableNameInitHash(de_ctx);
     DetectParseDupSigHashInit(de_ctx);
@@ -957,7 +956,6 @@ void DetectEngineCtxFree(DetectEngineCtx *de_ctx)
      */
     SigGroupHeadHashFree(de_ctx);
     MpmStoreFree(de_ctx);
-    SigGroupHeadDPortHashFree(de_ctx);
     DetectParseDupSigHashFree(de_ctx);
     SCSigSignatureOrderingModuleCleanup(de_ctx);
     ThresholdContextDestroy(de_ctx);
index 475bbbb5a46e45a5c3fef141a9dce430e1787335..9189b4612ff89e159fd9aff6dde891e9e19561a7 100644 (file)
@@ -4056,15 +4056,9 @@ int SigAddressPrepareStage4(DetectEngineCtx *de_ctx)
          * signature not decode event only. */
     }
 
-    /* cleanup group head (uri)content_array's */
-    SigGroupHeadFreeMpmArrays(de_ctx);
-    /* cleanup group head sig arrays */
-    SigGroupHeadFreeSigArrays(de_ctx);
-
     /* cleanup the hashes now since we won't need them
      * after the initialization phase. */
     SigGroupHeadHashFree(de_ctx);
-    SigGroupHeadDPortHashFree(de_ctx);
 
     RulesDumpGrouping(de_ctx);
 
index 41ca8412d41d7a6fa94a72846dbd00c545c64d16..9ef5f18dd94de57c3eae4b3f2d0039897b21a495 100644 (file)
@@ -611,8 +611,6 @@ typedef struct DetectEngineCtx_ {
 
     HashListTable *mpm_hash_table;
 
-    HashListTable *sgh_dport_hash_table;
-
     HashListTable *variable_names;
     HashListTable *variable_idxs;
     uint16_t variable_names_idx;