]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1585 in SNORT/snort3 from ~RUCOMBS/snort3:mainz to master
authorRuss Combs (rucombs) <rucombs@cisco.com>
Fri, 19 Apr 2019 18:36:03 +0000 (14:36 -0400)
committerRuss Combs (rucombs) <rucombs@cisco.com>
Fri, 19 Apr 2019 18:36:03 +0000 (14:36 -0400)
Squashed commit of the following:

commit 908ec9dc090b12b4d788385fe82c3d866d5c4f50
Author: russ <rucombs@cisco.com>
Date:   Fri Apr 19 11:51:28 2019 -0400

    test: remove cruft

src/events/sfeventq.cc
src/hash/xhash.cc
src/ips_options/asn1_util.cc
src/ips_options/extract.cc
src/network_inspectors/port_scan/ipobj.cc
src/search_engines/acsmx.cc
src/search_engines/acsmx2.cc
src/search_engines/bnfa_search.cc
src/sfrt/sfrt.cc
src/utils/kmap.cc
src/utils/util_jsnorm.cc

index eb31ae364aa0460b272036418e48c50c38919a83..3cf79e4414639ba71b1938165645dc3eaeff2b31 100644 (file)
@@ -263,110 +263,3 @@ int sfeventq_action(SF_EVENTQ* eq, int (* action_func)(void*, void*), void* user
     return 1;
 }
 
-//#define I_WANT_MY_MAIN
-#ifdef  I_WANT_MY_MAIN
-
-#include <stdio.h>
-#include <time.h>
-
-int myaction(void* event, void* user)
-{
-    int* e;
-
-    if (!event)
-        return 1;
-
-    e = (int*)event;
-
-    printf("-- EVENT: %d\n", *e);
-
-    return 0;
-}
-
-int main(int argc, char** argv)
-{
-    int max_events;
-    int log_events;
-    int add_events;
-    int* event;
-    int iCtr;
-    SF_EVENTQ* eq;
-
-    if (argc < 4)
-    {
-        printf("-- Not enough args\n");
-        return 1;
-    }
-
-    max_events = atoi(argv[1]);
-    if (max_events <= 0)
-    {
-        printf("-- max_events invalid.\n");
-        return 1;
-    }
-
-    log_events = atoi(argv[2]);
-    if (log_events <= 0)
-    {
-        printf("-- log_events invalid.\n");
-        return 1;
-    }
-
-    add_events = atoi(argv[3]);
-    if (add_events <= 0)
-    {
-        printf("-- add_events invalid.\n");
-        return 1;
-    }
-
-    if (max_events < log_events)
-    {
-        printf("-- log_events greater than max_events\n");
-        return 1;
-    }
-
-    srandom(time(NULL));
-
-    eq = sfeventq_new(max_events, log_events, sizeof(int));
-    if (eq == NULL)
-    {
-        printf("Couldn't allocate the event queue\n");
-        return 1;
-    }
-
-    do
-    {
-        printf("-- Event Queue Test --\n\n");
-
-        for (iCtr = 0; iCtr < add_events; iCtr++)
-        {
-            event  = (int*)sfeventq_event_alloc(eq);
-            if (!event)
-            {
-                printf("-- event allocation failed\n");
-                return 1;
-            }
-
-            *event = (int)(random()%3);
-
-            sfeventq_add(eq, event);
-            printf("-- added %d\n", *event);
-        }
-
-        printf("\n-- Logging\n\n");
-
-        if (sfeventq_action(eq, myaction, NULL))
-        {
-            printf("-- There was a problem.\n");
-            return 1;
-        }
-
-        sfeventq_reset(eq);
-    }
-    while (getc(stdin) < 14);
-
-    return 0;
-}
-
-#endif
-
index 41b248e04495ab2e8b8c9015da6083ab68ff95d9..e3e74b438493df815cb7bfb4920602864b5fc2ca 100644 (file)
@@ -1029,143 +1029,3 @@ void xhash_set_keyops(XHash* h, hash_func hash_fcn, keycmp_func keycmp_fcn)
 }
 } // namespace snort
 
-/*
- * -----------------------------------------------------------------------------------------
- *   Test Driver for Hashing
- * -----------------------------------------------------------------------------------------
- */
-#ifdef XHash_MAIN
-
-/*
-   This is called when the user releases a node or kills the table
-*/
-int usrfree(void* key, void* data)
-{
-    /* Release any data you need to */
-    return 0;
-}
-
-/*
-   Auto Node Recovery Callback - optional
-
-   This is called to ask the user to kill a node, if it returns !0 than the hash
-   library does not kill this node.  If the user os willing to let the node die,
-   the user must do any freeing or clean up on the node during this call.
-*/
-int anrfree(void* key, void* data)
-{
-    static int bx = 0;  // test only
-
-    /* Decide if we can free this node. */
-
-    bx++; if(bx == 4 )bx=0;       /* for testing */
-
-    /* if we are allowing the node to die, kill it */
-    if ( !bx )
-        usrfree(key, data);
-
-    return bx;  /* Allow the caller to  kill this nodes data + key */
-}
-
-/*
- *       Hash test program : use 'sfxhash 1000 50000' to stress the Auto_NodeRecover feature
- */
-int main(int argc, char** argv)
-{
-    int i;
-    XHash* t;
-    XHashNode* n;
-    char strkey[256], strdata[256];
-    int num = 100;
-    int mem = 0;
-
-    memset(strkey,0,20);
-    memset(strdata,0,20);
-
-    if ( argc > 1 )
-    {
-        num = atoi(argv[1]);
-    }
-
-    if ( argc > 2 )
-    {
-        mem = atoi(argv[2]);
-    }
-
-    /* Create a Hash Table */
-    t = xhash_new(100,         /* one row per element in table, when possible */
-        20,                     /* key size :  padded with zeros */
-        20,                     /* data size:  padded with zeros */
-        mem,                    /* max bytes,  0=no max */
-        1,                      /* enable AutoNodeRecovery */
-        anrfree,                /* provide a function to let user know we want to kill a node */
-        usrfree,              /* provide a function to release user memory */
-        1);                   /* Recycle nodes */
-    if (!t)
-    {
-        printf("Low Memory\n");
-        exit(0);
-    }
-    /* Add Nodes to the Hash Table */
-    for (i=0; i<num; i++)
-    {
-        snprintf(strkey, sizeof(strkey), "KeyWord%5.5d",i+1);
-        strkey[sizeof(strkey) - 1] = '\0';
-        snprintf(strdata, sizeof(strdata), "KeyWord%5.5d",i+1);
-        strdata[sizeof(strdata) - 1] = '\0';
-        //strupr(strdata);
-        xhash_add(t, strkey /* user key */,  strdata /* user data */);
-    }
-
-    /* Find and Display Nodes in the Hash Table */
-    printf("\n** FIND KEY TEST\n");
-    for (i=0; i<num; i++)
-    {
-        snprintf(strkey, sizeof(strkey) - 1, "KeyWord%5.5d",i+1);
-        strkey[sizeof(strkey) - 1] = '\0';
-
-        if ( char* p = (char*)xhash_find(t, strkey) )
-            printf("Hash-key=%*s, data=%*s\n", strlen(strkey),strkey, strlen(strkey), p);
-    }
-
-    /* Show memcap memory */
-    printf("\n...******\n");
-    sfmemcap_showmem(&t->mc);
-    printf("...******\n");
-
-    /* Display All Nodes in the Hash Table findfirst/findnext */
-    printf("\n...FINDFIRST / FINDNEXT TEST\n");
-    for ( n  = xhash_findfirst(t);
-        n != 0;
-        n  = xhash_findnext(t) )
-    {
-        printf("hash-findfirst/next: n=%p, key=%s, data=%s\n", n, n->key, n->data);
-
-        /*
-          remove node we are looking at, this is first/next safe.
-        */
-        if ( xhash_remove(t,n->key) )
-        {
-            printf("...ERROR: Could not remove the key node\n");
-        }
-        else
-        {
-            printf("...key node removed\n");
-        }
-    }
-
-    printf("...Auto-Node-Recovery: %u recycle attempts, %u completions.\n",t->anr_tries,
-        t->anr_count);
-
-    /* Free the table and it's user data */
-    printf("...xhash_delete\n");
-
-    xhash_delete(t);
-
-    printf("\nnormal pgm finish\n\n");
-
-    return 0;
-}
-
-#endif
-
index 9fab0ccb74360a5c4d76573119a3d45647b29bb5..414b68e11325349d4e6fb8c00e63a7ef705a6157 100644 (file)
@@ -1006,94 +1006,3 @@ int asn1_print_types(ASN1_TYPE* asn1_type, void* user)
     return 0;
 }
 
-#ifdef I_WANT_MAIN_DAMMIT
-static int BitStringOverflow(ASN1_TYPE* asn1_type)
-{
-    if (!asn1_type)
-        return 0;
-
-    if (asn1_type->ident.tag == SF_ASN1_TAG_BIT_STR && !asn1_type->ident.flag)
-    {
-        if (((asn1_type->len.size - 1)*8) < (u_int)asn1_type->data[0])
-        {
-            return 1;
-        }
-    }
-
-    return 0;
-}
-
-/*
-**  Program reads from stdin and decodes the hexadecimal ASN.1 stream
-**  into identifier,len,data.
-*/
-int main(int argc, char** argv)
-{
-    ASN1_TYPE* asn1_type;
-    char line[10000];
-    u_int ctmp;
-    char* buf;
-    int buf_size;
-    int iCtr;
-    int iRet;
-
-    fgets(line, sizeof(line), stdin);
-    buf_size = strlen(line);
-
-    while (buf_size && line[buf_size-1] <= 0x20)
-    {
-        buf_size--;
-        line[buf_size] = 0x00;
-    }
-
-    if (!buf_size)
-    {
-        printf("** No valid characters in data string.\n");
-        return 1;
-    }
-
-    if (buf_size % 2)
-    {
-        printf("** Data must be represent in hex, meaning that there is an "
-            "odd number of characters in the data string.\n");
-        return 1;
-    }
-
-    buf_size >>= 1;
-
-    buf = snort_calloc(buf_size + 1);
-
-    for (iCtr = 0; iCtr < buf_size; iCtr++)
-    {
-        if (!(isxdigit(line[iCtr*2]) && isxdigit(line[(iCtr*2)+1])))
-        {
-            printf("** Data stream is not all hex digits.\n");
-            return 1;
-        }
-
-        sscanf(&line[iCtr*2], "%2x", &ctmp);
-        buf[iCtr] = (char)ctmp;
-    }
-
-    buf[iCtr] = 0x00;
-
-    asn1_init_mem(256);
-
-    iRet = asn1_decode(buf, buf_size, &asn1_type);
-    if (iRet && !asn1_type)
-    {
-        printf("** FAILED\n");
-        return 1;
-    }
-
-    printf("** iRet = %d\n", iRet);
-
-    asn1_print_types(asn1_type, 0);
-
-    snort_free(buf);
-
-    return 0;
-}
-
-#endif
-
index e1add9d4d410148dec3ce911c42b382583b9d880..dd7e2001b5e5da20b554cc47fdacd62223553eb3 100644 (file)
@@ -347,177 +347,5 @@ TEST_CASE("ips options vars")
     REQUIRE((GetVarValueByIndex(&dst, NUM_IPS_OPTIONS_VARS) == IPS_OPTIONS_NO_VAR));
     REQUIRE((SetVarValueByIndex(0, NUM_IPS_OPTIONS_VARS) == IPS_OPTIONS_NO_VAR));
 }
-
 #endif
 
-#ifdef TEST_BYTE_EXTRACT
-#include <stdio.h>
-
-void test_extract()
-{
-    int i;
-    uint32_t ret;
-
-    uint8_t value1[2];
-    uint8_t value2[2];
-    uint8_t value3[4];
-
-    value1[0] = 0;
-    value1[1] = 0xff;
-
-    value2[0] = 0xff;
-    value2[1] = 0x01;
-
-    value3[0] = 0xff;
-    value3[1] = 0xff;
-    value3[2] = 0x00;
-    value3[3] = 0x00;
-
-    if (byte_extract(ENDIAN_BIG, 2, value1, value1, value1 + 2, &ret))
-    {
-        printf("test 1 failed\n");
-    }
-    else
-    {
-        printf("test 1: value: %x %u\n", ret, ret);
-    }
-
-    if (byte_extract(ENDIAN_LITTLE, 2, value1, value1, value1 + 2, &ret))
-    {
-        printf("test 2 failed\n");
-    }
-    else
-    {
-        printf("test 2: value: %x %u\n", ret, ret);
-    }
-
-    if (byte_extract(ENDIAN_LITTLE, 2, value1 + 2, value1, value1 + 2, &ret))
-    {
-        printf("test 3 failed correctly\n");
-    }
-    else
-    {
-        printf("test 3: value: %x %u\n", ret, ret);
-    }
-
-    if (byte_extract(ENDIAN_BIG, 2, value2, value2, value2 + 2, &ret))
-    {
-        printf("test 1 failed\n");
-    }
-    else
-    {
-        printf("test 1: value: %x %u\n", ret, ret);
-    }
-
-    if (byte_extract(ENDIAN_LITTLE, 2, value2, value2, value2 + 2, &ret))
-    {
-        printf("test 2 failed\n");
-    }
-    else
-    {
-        printf("test 2: value: %x %u\n", ret, ret);
-    }
-
-    if (byte_extract(ENDIAN_LITTLE, 2, value2 + 2, value2, value2 + 2, &ret))
-    {
-        printf("test 3 failed correctly\n");
-    }
-    else
-    {
-        printf("test 3: value: %x %u\n", ret, ret);
-    }
-
-    if (byte_extract(ENDIAN_BIG, 4, value3, value3, value3 + 4, &ret))
-    {
-        printf("test 1 failed\n");
-    }
-    else
-    {
-        printf("test 1: value: %x %u\n", ret, ret);
-    }
-
-    if (byte_extract(ENDIAN_LITTLE, 4, value3, value3, value3 + 4, &ret))
-    {
-        printf("test 2 failed\n");
-    }
-    else
-    {
-        printf("test 2: value: %x %u\n", ret, ret);
-    }
-
-    if (byte_extract(ENDIAN_LITTLE, 4, value3 + 2, value3, value3 + 4, &ret))
-    {
-        printf("test 3 failed correctly\n");
-    }
-    else
-    {
-        printf("test 3: value: %x %u\n", ret, ret);
-    }
-
-    printf("-----------------------------\n");
-
-    for (i=0; i<10; i++)
-    {
-        if (byte_extract(ENDIAN_LITTLE, 4, value3 + i, value3, value3 + 4, &ret))
-        {
-            printf("[loop] %d failed correctly\n", i);
-        }
-        else
-        {
-            printf("[loop] value: %x %x\n", ret, *(uint32_t*)&value3);
-        }
-    }
-}
-
-void test_string()
-{
-    char* stringdata = "21212312412";
-    int datalen = strlen(stringdata);
-    uint32_t ret;
-
-    if (string_extract(4, 10, stringdata,  stringdata, stringdata + datalen,  &ret) < 0)
-    {
-        printf("TS1: Failed\n");
-    }
-    else
-    {
-        printf("TS1: value %x %u\n", ret, ret);
-    }
-
-    if (string_extract(10, 10, stringdata,  stringdata, stringdata + datalen,  &ret) < 0)
-    {
-        printf("TS2: Failed\n");
-    }
-    else
-    {
-        printf("TS2: value %x %u\n", ret, ret);
-    }
-
-    if (string_extract(9, 10, stringdata,  stringdata, stringdata + datalen,  &ret) < 0)
-    {
-        printf("TS3: Failed\n");
-    }
-    else
-    {
-        printf("TS3: value %x %u\n", ret, ret);
-    }
-
-    if (string_extract(19, 10, stringdata,  stringdata, stringdata + datalen,  &ret) < 0)
-    {
-        printf("TS4: Failed Normally\n");
-    }
-    else
-    {
-        printf("TS4: value %x %u\n", ret, ret);
-    }
-}
-
-int main()
-{
-    test_extract();
-    test_string();
-    return 0;
-}
-
-#endif /* TEST_BYTE_EXTRACT */
-
index c610ea7c03ee30aa4ac1fe333af299192799e957..cc947b326b211e8f4026740b488d5891d0b96591 100644 (file)
@@ -424,254 +424,3 @@ int ipset_parse(IPSET* ipset, const char* ipstr)
     return 0;
 }
 
-#ifdef MAIN_IP
-#include <time.h>
-
-#define rand   random
-#define srand srandom
-
-#define MAXIP 100
-
-#include "sflsq.c"
-
-void test_ip4_parsing()
-{
-    unsigned host, mask, not_flag;
-    PORTSET portset;
-    char** curip;
-    IPADDRESS* adp;
-    char* ips[] =
-    {
-        "138.26.1.24:25",
-        "1.1.1.1/255.255.255.0:444",
-        "1.1.1.1/16:25-28",
-        "1.1.1.1/255.255.255.255:25 27-29",
-        "z/24",
-        "0/0",
-        "0.0.0.0/0.0.0.0:25-26 28-29 31",
-        "0.0.0.0/0.0.2.0",
-        nullptr
-    };
-
-    for (curip = ips; curip[0]; curip++)
-    {
-        portset_init(&portset);
-
-        /* network byte order stuff */
-        if (int ret = ip4_parse(curip[0], 1, &not_flag, &host, &mask, &portset))
-        {
-            fprintf(stderr, "Unable to parse %s with ret %d\n", curip[0], ret);
-        }
-        else
-        {
-            printf("%c", not_flag ? '!' : ' ');
-            printf("%s/", inet_ntoa(*(struct in_addr*)&host));
-            printf("%s", inet_ntoa(*(struct in_addr*)&mask));
-            printf(" parsed successfully\n");
-        }
-
-        /* host byte order stuff */
-        if (int ret = ip4_parse(curip[0], 0, &not_flag, &host, &mask, &portset))
-        {
-            fprintf(stderr, "Unable to parse %s with ret %d\n", curip[0], ret);
-        }
-        else
-        {
-            adp = ip_new(IPV4_FAMILY);
-            ip_set(adp, &host, IPV4_FAMILY);
-            ip_fprint(stdout, adp);
-            fprintf(stdout, "*****************\n");
-            ip_free(adp);
-        }
-    }
-}
-
-void test_ip4set_parsing()
-{
-    char** curip;
-    char* ips[] =
-    {
-        "12.24.24.1/32,!24.24.24.1",
-        "[0.0.0.0/0.0.2.0,241.242.241.22]",
-        "138.26.1.24",
-        "1.1.1.1",
-        "1.1.1.1/16",
-        "1.1.1.1/255.255.255.255",
-        "z/24",
-        "0/0",
-        "0.0.0.0/0.0.0.0",
-        "0.0.0.0/0.0.2.0",
-        nullptr
-    };
-
-    for (curip = ips; curip[0]; curip++)
-    {
-        IPSET* ipset = ipset_new(IPV4_FAMILY);
-
-        /* network byte order stuff */
-        if (int ret = ip4_setparse(ipset, curip[0]))
-        {
-            ipset_free(ipset);
-            fprintf(stderr, "Unable to parse %s with ret %d\n", curip[0], ret);
-        }
-        else
-        {
-            printf("-[%s]\n ", curip[0]);
-            ipset_print(ipset);
-            printf("---------------------\n ");
-        }
-    }
-}
-
-//  -----------------------------
-void test_ip()
-{
-    int i,k;
-    IPADDRESS* ipa[MAXIP];
-    unsigned ipaddress,ipx;
-    unsigned short ipaddress6[8], ipx6[8];
-
-    printf("IPADDRESS testing\n");
-
-    srand(time(0) );
-
-    for (i=0; i<MAXIP; i++)
-    {
-        if ( i % 2 )
-        {
-            ipa[i]= ip_new(IPV4_FAMILY);
-            ipaddress = rand() * rand();
-            ip_set(ipa[i], &ipaddress, IPV4_FAMILY);
-
-            if ( !ip_equal(ipa[i],&ipaddress, IPV4_FAMILY) )
-                printf("error with ip_equal\n");
-
-            ip_get(ipa[i], &ipx, IPV4_FAMILY);
-            if ( ipx != ipaddress )
-                printf("error with ip_get\n");
-        }
-        else
-        {
-            ipa[i]= ip_new(IPV6_FAMILY);
-
-            for (k=0; k<8; k++)
-                ipaddress6[k] = (char)(rand() % (1<<16));
-
-            ip_set(ipa[i], ipaddress6, IPV6_FAMILY);
-
-            if ( !ip_equal(ipa[i],&ipaddress6, IPV6_FAMILY) )
-                printf("error with ip6_equal\n");
-
-            ip_get(ipa[i], ipx6, IPV6_FAMILY);
-
-            for (k=0; k<8; k++)
-                if ( ipx6[k] != ipaddress6[k] )
-                    printf("error with ip6_get\n");
-        }
-
-        printf("[%d] ",i);
-        ip_fprint(stdout,ipa[i]);
-        printf("\n");
-    }
-
-    printf("IP testing completed\n");
-}
-
-//  -----------------------------
-void test_ipset()
-{
-    int i,k;
-    IPSET* ipset, * ipset6;
-    IPSET* ipset_copyp, * ipset6_copyp;
-
-    unsigned ipaddress, mask;
-    unsigned short mask6[8];
-    unsigned short ipaddress6[8];
-    unsigned port_lo, port_hi;
-    PORTSET portset;
-
-    printf("IPSET testing\n");
-
-    ipset  = ipset_new(IPV4_FAMILY);
-    ipset6 = ipset_new(IPV6_FAMILY);
-
-    srand(time(0) );
-
-    for (i=0; i<MAXIP; i++)
-    {
-        if ( i % 2 )
-        {
-            ipaddress = rand() * rand();
-            mask = 0xffffff00;
-            port_lo = rand();
-            port_hi = rand() % 5 + port_lo;
-            portset_init(&portset);
-            portset_add(&portset, port_lo, port_hi);
-
-            ipset_add(ipset, &ipaddress, &mask, &portset, 0, IPV4_FAMILY);   //class C cidr blocks
-
-            if ( !ipset_contains(ipset, &ipaddress, &port_lo, IPV4_FAMILY) )
-                printf("error with ipset_contains\n");
-        }
-        else
-        {
-            for (k=0; k<8; k++)
-                ipaddress6[k] = (char)(rand() % (1<<16));
-
-            for (k=0; k<8; k++)
-                mask6[k] = 0xffff;
-
-            port_lo = rand();
-            port_hi = rand() % 5 + port_lo;
-            portset_init(&portset);
-            portset_add(&portset, port_lo, port_hi);
-
-            ipset_add(ipset6, ipaddress6, mask6, &portset, 0, IPV6_FAMILY);
-
-            if ( !ipset_contains(ipset6, &ipaddress6, &port_lo, IPV6_FAMILY) )
-                printf("error with ipset6_contains\n");
-        }
-    }
-
-    ipset_copyp = ipset_copy(ipset);
-    ipset6_copyp = ipset_copy(ipset6);
-
-    printf("-----IP SET-----\n");
-    ipset_print(ipset);
-    printf("\n");
-
-    printf("-----IP SET6-----\n");
-    ipset_print(ipset6);
-    printf("\n");
-
-    printf("-----IP SET COPY -----\n");
-    ipset_print(ipset_copyp);
-    printf("\n");
-
-    printf("-----IP SET6 COPY -----\n");
-    ipset_print(ipset6_copyp);
-    printf("\n");
-
-    printf("IP set testing completed\n");
-}
-
-//  -----------------------------
-int main(int argc, char** argv)
-{
-    printf("ipobj \n");
-
-    test_ip();
-
-    test_ipset();
-
-    test_ip4_parsing();
-
-    test_ip4set_parsing();
-
-    printf("normal pgm completion\n");
-
-    return 0;
-}
-
-#endif
-
index 60663b728b37b83599c037f2f3e6c00074f5f36a..777885f774fcd94075f80f64cada2840c200a520 100644 (file)
@@ -560,53 +560,3 @@ int acsmPrintSummaryInfo()
     return 0;
 }
 
-#ifdef ACSMX_MAIN
-
-/*
-*  Text Data Buffer
-*/
-uint8_t text[512];
-
-/*
-*    A Match is found
-*/
-int MatchFound(unsigned id, int index, void* data)
-{
-    fprintf (stdout, "%s\n", (char*)id);
-    return 0;
-}
-
-/*
-*
-*/
-int main(int argc, char** argv)
-{
-    int i, nocase = 0;
-    ACSM_STRUCT* acsm;
-    if (argc < 3)
-    {
-        fprintf (stderr,
-            "Usage: acsmx pattern word-1 word-2 ... word-n  -nocase\n");
-        exit (0);
-    }
-    acsm = acsmNew ();
-    strncpy(text, argv[1], sizeof(text));
-    for (i = 1; i < argc; i++)
-        if (strcmp (argv[i], "-nocase") == 0)
-            nocase = 1;
-    for (i = 2; i < argc; i++)
-    {
-        if (argv[i][0] == '-')
-            continue;
-        acsmAddPattern (acsm, (uint8_t*)argv[i], strlen (argv[i]), nocase, 0, 0,
-            argv[i], i - 2);
-    }
-    acsmCompile (acsm);
-    acsmSearch (acsm, text, strlen (text), MatchFound, (void*)0);
-    acsmFree (acsm);
-    printf ("normal pgm end\n");
-    return (0);
-}
-
-#endif /*  */
-
index 5987a728311f87aac642d9703c4b290dc2e354f1..d98dfab7b940abec8c1f61f115ce9500861faea5 100644 (file)
@@ -2199,209 +2199,3 @@ int acsmPrintSummaryInfo2()
     return 0;
 }
 
-#ifdef ACSMX2S_MAIN
-// Write a state table to disk
-static void Write_DFA(ACSM_STRUCT2* acsm, char* f)
-{
-    acstate_t** NextState = acsm->acsmNextState;
-    printf("Dump DFA - %d active states\n",acsm->acsmNumStates);
-
-    FILE* fp = fopen(f,"wb");
-
-    if (!fp)
-    {
-        printf("WARNING: could not write dfa to file - %s.\n",f);
-        return;
-    }
-
-    fwrite( &acsm->acsmNumStates, 4, 1, fp);
-
-    for (int k=0; k<acsm->acsmNumStates; k++)
-    {
-        acstate_t* p = NextState[k];
-
-        if ( !p )
-            continue;
-
-        acstate_t fmt = *p++;
-        acstate_t bmatch = *p++;
-
-        fwrite(&fmt,    sizeof(acstate_t), 1, fp);
-        fwrite(&bmatch, sizeof(acstate_t), 1, fp);
-
-        if ( fmt == ACF_SPARSE )
-        {
-            acstate_t n = *p++;
-            fwrite(&n, sizeof(acstate_t), 1, fp);
-            fwrite(p, n*2*sizeof(acstate_t), 1, fp);
-        }
-        else if ( fmt ==ACF_BANDED )
-        {
-            acstate_t n = *p++;
-            fwrite(&n, sizeof(acstate_t), 1, fp);
-
-            acstate_t index = *p++;
-            fwrite(&index, sizeof(acstate_t), 1, fp);
-
-            fwrite(p, sizeof(acstate_t), n, fp);
-        }
-        else if ( fmt ==ACF_SPARSE_BANDS )
-        {
-            acstate_t nb = *p++;
-            fwrite(&nb, sizeof(acstate_t), 1, fp);
-
-            for (int i=0; i<nb; i++)
-            {
-                acstate_t n = *p++;
-                fwrite(&n, sizeof(acstate_t), 1, fp);
-
-                acstate_t index = *p++;
-                fwrite(&index,sizeof(acstate_t), 1, fp);
-
-                fwrite(p, sizeof(acstate_t), 1, fp);
-            }
-        }
-        else if ( fmt == ACF_FULL )
-        {
-            fwrite(p, sizeof(acstate_t), acsm->acsmAlphabetSize,  fp);
-        }
-
-        //Print_DFA_MatchList( acsm, k);
-    }
-
-    fclose(fp);
-}
-
-static int acsmSearch2(
-    ACSM_STRUCT2* acsm, uint8_t* Tx, int n, MpseMatch match,
-    void* context, int* current_state)
-{
-    if ( !acsm->dfa )
-        return acsm_search_nfa(acsm, Tx, n, match, context, current_state);
-
-    switch ( acsm->acsmFormat )
-    {
-    case ACF_FULL:
-        return acsm_search_dfa_full(acsm, Tx, n, match, context, current_state);
-
-    case ACF_BANDED:
-        return acsm_search_dfa_banded(acsm, Tx, n, match, context, current_state);
-
-    case ACF_SPARSE:
-    case ACF_SPARSE_BANDS:
-        return acsm_search_dfa_sparse(acsm, Tx, n, match, context, current_state);
-    }
-    return 0;
-}
-
-/*
-*  Text Data Buffer
-*/
-uint8_t text[512];
-
-/*
-*    A Match is found
-*/
-int MatchFound(void* id, int index, void* data)
-{
-    fprintf (stdout, "%s\n", (char*)id);
-    return 0;
-}
-
-int main(int argc, char** argv)
-{
-    int i, nc, nocase = 0;
-    ACSM_STRUCT2* acsm;
-    char* p;
-
-    if (argc < 3)
-    {
-        fprintf (stderr,"Usage: %s search-text pattern +pattern... [flags]\n",argv[0]);
-        fprintf (stderr, "  flags: -nfa -nocase -full -sparse -bands -sparsebands "
-            "-z zcnt (sparsebands) -sparsetree -v\n");
-        exit (0);
-    }
-
-    acsm = acsmNew2 ();
-
-    if ( !acsm )
-    {
-        printf("acsm-no memory\n");
-        exit(0);
-    }
-
-    strncpy (text, argv[1], sizeof(text) - 1);
-    text[sizeof(text) - 1] = '\0';
-
-    acsm->acsmFormat = ACF_FULL;
-
-    for (i = 1; i < argc; i++)
-    {
-        if (strcmp (argv[i], "-nocase") == 0)
-        {
-            nocase = 1;
-        }
-        if (strcmp (argv[i], "-full") == 0)
-        {
-            acsm->acsmFormat = ACF_FULL;
-        }
-        if (strcmp (argv[i], "-sparse") == 0)
-        {
-            acsm->acsmFormat = ACF_SPARSE;
-            acsm->acsmSparseMaxRowNodes = 10;
-        }
-        if (strcmp (argv[i], "-bands") == 0)
-        {
-            acsm->acsmFormat = ACF_BANDED;
-        }
-
-        if (strcmp (argv[i], "-sparsebands") == 0)
-        {
-            acsm->acsmFormat = ACF_SPARSE_BANDS;
-            acsm->acsmSparseMaxZcnt = 10;
-        }
-        if (strcmp (argv[i], "-z") == 0)
-        {
-            acsm->acsmSparseMaxZcnt = atoi(argv[++i]);
-        }
-    }
-
-    for (i = 2; i < argc; i++)
-    {
-        if (argv[i][0] == '-')
-            continue;
-
-        p = argv[i];
-
-        if ( *p == '+')
-        {
-            nc=1;
-            p++;
-        }
-        else
-        {
-            nc = nocase;
-        }
-
-        acsmAddPattern2 (acsm, (uint8_t*)p, strlen(p), nc, 0, 0,(void*)p, i - 2);
-    }
-
-    Print_DFA (acsm);
-
-    acsmCompile2 (acsm);
-
-    Write_DFA(acsm, "acsmx2-snort.dfa");
-
-    acsmPrintSummaryInfo2(acsm);
-
-    acsmSearch2 (acsm, text, strlen (text), MatchFound, (void*)0);
-
-    acsmFree2 (acsm);
-
-    printf ("normal pgm end\n");
-
-    return 0;
-}
-
-#endif
-
index 3662191199a214df0fa494c72506516df526906d..8d100de660527574e1c6b36fff590daa904df340 100644 (file)
@@ -2084,257 +2084,3 @@ void bnfaAccumInfo(bnfa_struct_t* p)
     px->failstate_memory += p->failstate_memory;
 }
 
-#ifdef BNFA_MAIN
-#include <stdarg.h>
-/*
-*  BNFA Search Function
-*
-*  bnfa   - state machine
-*  Tx     - text buffer to search
-*  n      - number of bytes in Tx
-*  Match  - function to call when a match is found
-*  data   - user supplied data that is passed to the Match function
-*  sindex - state tracker, set value to zero to reset the state machine,
-*            zero should be the value passed in on the 1st buffer or each buffer
-*           that is to be analyzed on its own, the state machine updates this
-*            during searches. This allows for sequential buffer searches without
-*            resetting the state machine. Save this value as returned from the
-*            previous search for the next search.
-*
-*  returns
-*    The state or sindex of the state machine. This can than be passed back
-*   in on the next search, if desired.
-*/
-
-static unsigned bnfaSearch(
-    bnfa_struct_t* bnfa, uint8_t* Tx, int n, MpseMatch match,
-    void* context, unsigned sindex, int* current_state)
-{
-    assert(current_state);
-    int ret = 0;
-
-    if (current_state)
-    {
-        sindex = (unsigned)*current_state;
-    }
-
-#ifdef ALLOW_NFA_FULL
-    if ( bnfa->bnfaFormat == BNFA_SPARSE )
-    {
-        if ( bnfa->bnfaCaseMode == BNFA_PER_PAT_CASE )
-        {
-            if (bnfa->bnfaMethod)
-            {
-                ret = _bnfa_search_csparse_nfa(
-                    bnfa, Tx, n, match, context, sindex, current_state);
-            }
-            else
-            {
-                ret = _bnfa_search_csparse_nfa_q(
-                    bnfa, Tx, n, match, context, sindex, current_state);
-            }
-        }
-        else if ( bnfa->bnfaCaseMode == BNFA_CASE )
-        {
-            ret = _bnfa_search_csparse_nfa_case(
-                bnfa, Tx, n, match, context, sindex, current_state);
-        }
-        else     /* NOCASE */
-        {
-            ret = _bnfa_search_csparse_nfa_nocase(
-                bnfa, Tx, n, match, context, sindex, current_state);
-        }
-    }
-    else if ( bnfa->bnfaFormat == BNFA_FULL )
-    {
-        if ( bnfa->bnfaCaseMode == BNFA_PER_PAT_CASE  )
-        {
-            ret = _bnfa_search_full_nfa(
-                bnfa, Tx, n, match, context, (bnfa_state_t)sindex, current_state);
-        }
-        else if ( bnfa->bnfaCaseMode == BNFA_CASE  )
-        {
-            ret = _bnfa_search_full_nfa_case(
-                bnfa, Tx, n, match, context, (bnfa_state_t)sindex, current_state);
-        }
-        else
-        {
-            ret = _bnfa_search_full_nfa_nocase(
-                bnfa, Tx, n, match, context, (bnfa_state_t)sindex, current_state);
-        }
-    }
-#else
-    if ( bnfa->bnfaCaseMode == BNFA_PER_PAT_CASE )
-    {
-        if (bnfa->bnfaMethod)
-        {
-            ret = _bnfa_search_csparse_nfa(
-                bnfa, Tx, n, match, context, sindex, current_state);
-        }
-        else
-        {
-            ret = _bnfa_search_csparse_nfa_q(
-                bnfa, Tx, n, match, context, sindex, current_state);
-        }
-    }
-    else if ( bnfa->bnfaCaseMode == BNFA_CASE )
-    {
-        ret = _bnfa_search_csparse_nfa_case(
-            bnfa, Tx, n, match, context, sindex, current_state);
-    }
-    else     /* NOCASE */
-    {
-        ret = _bnfa_search_csparse_nfa_nocase(
-            bnfa, Tx, n, match, context, sindex, current_state);
-    }
-#endif
-    return ret;
-}
-
-/*
-*  Text Data Buffer
-*/
-static uint8_t text[512];
-static uint8_t text2[512];
-static int s_verbose=0;
-
-/*
-*    A Match is found
-*/
-static int MatchFound(void* id, void* tree, int index, void* data, void* neglist)
-{
-    fprintf (stdout, "%s\n", (char*)data);
-    return 0;
-}
-
-static void objfree(void** obj)
-{
-}
-
-static int buildtree(void* id, void** existing)
-{
-    return 1;
-}
-
-static int neglist(void* id, void** list)
-{
-    return 1;
-}
-
-static void LogMessage(const char* format,...)
-{
-    va_list ap;
-    va_start(ap, format);
-    vfprintf(stderr, format, ap);
-    va_end(ap);
-}
-
-static SnortConfig sc;
-static SnortConfig* snort_conf;
-
-/*
-*
-*/
-int main(int argc, char** argv)
-{
-    int i, nc, nocase = 0;
-    bnfa_struct_t* bnfa;
-    int current_state = 0;
-    bool split_search = false;
-    char* p;
-
-    if (argc < 3)
-    {
-        fprintf (stderr,"Usage: %s search-text pattern +pattern... [flags]\n",argv[0]);
-        fprintf (stderr,"  flags: -q -nocase -splitsearch -v\n");
-        exit (0);
-    }
-
-    memset(&sc, 0, sizeof(SnortConfig));
-    snort_conf = &sc;
-
-    bnfa = bnfaNew(free, objfree, objfree);
-    if ( !bnfa )
-    {
-        printf("bnfa-no memory\n");
-        exit(0);
-    }
-
-    strncpy (text, argv[1], sizeof(text) - 1);
-    text[sizeof(text) - 1] = '\0';
-
-    bnfa->bnfaMethod = 1;
-
-    for (i = 1; i < argc; i++)
-    {
-        if (strcmp (argv[i], "-nocase") == 0)
-        {
-            nocase = 1;
-        }
-        if (strcmp (argv[i], "-v") == 0)
-        {
-            s_verbose=1;
-        }
-        if (strcmp (argv[i], "-splitsearch") == 0)
-        {
-            int len2 = strlen(text)/2;
-            split_search =true;
-            strncpy(text2, &text[len2], sizeof(text2) -1);
-            text[len2] = '\0';
-            text2[len2] = '\0';
-        }
-
-        if (strcmp (argv[i], "-q") == 0)
-        {
-            bnfa->bnfaMethod = 0;
-        }
-    }
-
-    for (i = 2; i < argc; i++)
-    {
-        if (argv[i][0] == '-')
-            continue;
-
-        p = argv[i];
-
-        if ( *p == '+')
-        {
-            nc=1;
-            p++;
-        }
-        else
-        {
-            nc = nocase;
-        }
-
-        bnfaAddPattern (bnfa, (uint8_t*)p, strlen(p), nc, 0, (void*)NULL);
-    }
-
-    if (s_verbose)
-        printf("Patterns added\n");
-
-    //Print_DFA (acsm);
-
-    bnfaCompile (bnfa, buildtree, neglist);
-
-    //Write_DFA(acsm, "bnfa-snort.dfa") ;
-
-    if (s_verbose)
-        printf("Patterns compiled--written to file.\n");
-
-    bnfaPrintInfo (bnfa);
-    bnfaPrintSummary ( );
-
-    bnfaSearch (bnfa, text, strlen (text), MatchFound, NULL, current_state, &current_state);
-
-    if (split_search)
-        bnfaSearch (bnfa, text2, strlen (text2), MatchFound, NULL, current_state, &current_state);
-
-    bnfaFree (bnfa);
-
-    printf ("normal pgm end\n");
-
-    return (0);
-}
-#endif
-
index 7afb4d4c0b234a434084510848bb86c5f867daa6..b4d5fce1761ee2a78e02858db4939b948a599138 100644 (file)
@@ -598,55 +598,3 @@ static inline int allocateTableIndex(table_t* table)
     return 0;
 }
 
-#ifdef DEBUG_SFRT
-
-#define NUM_IPS 32
-#define NUM_DATA 4
-
-int main()
-{
-    uint32_t ip_list[NUM_IPS];  /* entirely arbitrary */
-    char data[NUM_DATA];     /* also entirely arbitrary */
-
-    for (uint32_t index=0; index<NUM_IPS; index++)
-    {
-        ip_list[index] = (uint32_t)rand()%NUM_IPS;
-        data[index%NUM_DATA] = index%26 + 65;    /* Random letter */
-    }
-
-    table_t* dir = sfrt_new(DIR_16x2, IPv4, NUM_IPS, 20);
-
-    if (!dir)
-    {
-        printf("Failed to create DIR\n");
-        return 1;
-    }
-
-    for (uint32_t index=0; index < NUM_IPS; index++)
-    {
-        if (sfrt_insert(&ip_list[index], 32, &data[index%NUM_DATA],
-            RT_FAVOR_SPECIFIC, dir) != RT_SUCCESS)
-        {
-            printf("DIR Insertion failure\n");
-            return 1;
-        }
-
-        printf("%u\t %x: %c -> %c\n", index, ip_list[index],
-            data[index%NUM_DATA], *(uint32_t*)sfrt_lookup(&ip_list[index], dir));
-    }
-
-    for (uint32_t index=0; index < NUM_IPS; index++)
-    {
-        uint32_t val = *(uint32_t*)sfrt_lookup(&ip_list[index], dir);
-        printf("\t@%u\t%x: %c.  originally:\t%c\n",
-            index, ip_list[index], val, data[index%NUM_DATA]);
-    }
-
-    printf("Usage: %d bytes\n", ((dir_table_t*)(dir->rt))->allocated);
-
-    sfrt_free(dir);
-    return 0;
-}
-
-#endif /* DEBUG_SFRT */
-
index 0502aebf9c8debb86b1a8c86dee910699afaf32c..f25481a9244dcbd1b182b1117fbbbbb8f8187f07 100644 (file)
@@ -408,74 +408,3 @@ void* KMapFindNext(KMAP* km)
 
 } //namespace snort
 
-#ifdef KMAP_MAIN
-/*
-*
-*/
-using namespace snort;
-int main(int argc, char** argv)
-{
-    int i,n=10;
-    KMAP* km;
-    char* p;
-    char str[80];
-
-    printf("usage: kmap nkeys (default=10)\n\n");
-
-    km = KMapNew(free);    /* use 'free' to free 'userdata' */
-
-    KMapSetNoCase(km,1);  //need to add xlat....
-
-    if ( argc > 1 )
-    {
-        n = atoi(argv[1]);
-    }
-
-    for (i=1; i<=n; i++)
-    {
-        SnortSnprintf(str, sizeof(str), "KeyWord%d",i);
-        KMapAdd(km, str, 0 /* strlen(str) */, strupr(snort_strdup(str)) );
-        printf("Adding Key=%s\n",str);
-    }
-    printf("xmem: %u bytes, %d chars\n",xmalloc_bytes(),km->nchars);
-
-    printf("\nKey Find test...\n");
-    for (i=1; i<=n; i++)
-    {
-        SnortSnprintf(str, sizeof(str), "KeyWord%d",i);
-        p = (char*)KMapFind(km, str,  0 /*strlen(str) */);
-        if (p)
-            printf("key=%s, data=%*s\n",str,strlen(str),p);
-        else
-            printf("'%s' NOT found.\n",str);
-    }
-
-    KMapSetNoCase(km,0);  // this should fail all key searches
-    printf("\nKey Find test2...\n");
-    for (i=1; i<=n; i++)
-    {
-        SnortSnprintf(str, sizeof(str), "KeyWord%d",i);
-        p = (char*)KMapFind(km, str,  0 /*strlen(str) */);
-        if (p)
-            printf("key=%s, data=%*s\n",str,strlen(str),p);
-        else
-            printf("'%s' NOT found.\n",str);
-    }
-
-    printf("\nKey FindFirst/Next test...\n");
-    for (p = (char*)KMapFindFirst(km); p; p=(char*)KMapFindNext(km) )
-        printf("data=%s\n",p);
-
-    printf("\nKey FindFirst/Next test done.\n");
-
-    KMapDelete(km);
-
-    printf("xmem: %u bytes\n",xmalloc_bytes());
-
-    printf("normal pgm finish.\n");
-
-    return 0;
-}
-
-#endif
-
index 90fbf10f893986ebf2dcdfcf307b135dd49d1e72..7d3cbceb6778d06cc65302bc7d00261b0bfdd648 100644 (file)
@@ -1280,54 +1280,6 @@ int JSNormalizeDecode(const char* src, uint16_t srclen, char* dst, uint16_t dest
 
     return RET_OK;
 }
+}
 
-/*
-int main(int argc, char *argv[])
-{
-    FILE *iFile = NULL;
-    FILE *oFile = NULL;
-    char input[65535];
-    char output[65535];
-    int bytes_copied = 0;
-    int bytes_read = 0;
-    int ret = 0;
-    char *ptr = input;
-    JSState js;
-
-    if( argc == 3 )
-    {
-        iFile = fopen(argv[1], "r");
-        oFile = fopen(argv[2], "w");
-    }
-
-    if(!oFile || !iFile)
-    {
-        fprintf(stderr, "usage: %s <in_file> <out_file>\n", argv[0]);
-        return -1;
-    }
-
-    bytes_read = fread(input, 1, sizeof(input), iFile);
-    js.allowed_spaces = 3;
-    js.allowed_levels = 1;
-    js.alerts = 0;
-
-    ret = JSNormalizeDecode(input, bytes_read, output, sizeof(output),&ptr, &bytes_copied, &js, NULL);
-    if( ret == RET_OK)
-    {
-        fwrite( output, 1, bytes_copied, oFile);
-        printf("OUTPUT IS %.*s\n",bytes_copied,output);
-        printf("REMAINING is %s\n",ptr);
-        if( js.alerts & ALERT_MIXED_ENCODINGS )
-            printf("ALERT MIXED ENCODINGS\n");
-        if(js.alerts & ALERT_SPACES_EXCEEDED)
-            printf("ALERT SPACES EXCEEDED\n");
-        if(js.alerts & ALERT_LEVELS_EXCEEDED)
-            printf("ALERT LEVELS EXCEEDED\n");
-    }
-    fclose(iFile);
-    fclose(oFile);
-    return 0;
-
-}*/
 
-}