Esempio n. 1
0
END_TEST

START_TEST(test_store_empty)
{
    ip_set_t  set;
    ip_set_t  *read_set;

    ipset_init(&set);

    GOutputStream  *ostream =
        g_memory_output_stream_new(NULL, 0, g_realloc, g_free);
    GMemoryOutputStream  *mostream =
        G_MEMORY_OUTPUT_STREAM(ostream);

    fail_unless(ipset_save(ostream, &set, NULL),
                "Could not save set");

    GInputStream  *istream =
        g_memory_input_stream_new_from_data
        (g_memory_output_stream_get_data(mostream),
         g_memory_output_stream_get_data_size(mostream),
         NULL);

    read_set = ipset_load(istream, NULL);
    fail_if(read_set == NULL,
            "Could not read set");

    fail_unless(ipset_is_equal(&set, read_set),
                "Set not same after saving/loading");

    g_object_unref(ostream);
    g_object_unref(istream);
    ipset_done(&set);
    ipset_free(read_set);
}
Esempio n. 2
0
int server_stats_destroy(SERVER_STATS *ssp)
{
    if(!ssp)
    {
        return FLOW_ENULL;
    }
    
    sfxhash_delete(ssp->ipv4_table);
    ipset_free(ssp->ipv4_watch);

    return FLOW_SUCCESS;
}
Esempio n. 3
0
File: ipobj.c Progetto: sdnnfv/snort
void test_ip4set_parsing(void)
{
    char **curip;
    int ret;
    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",
        NULL
    };

    for(curip = ips; curip[0] != NULL; curip++)
    {
        IPSET *ipset = ipset_new(IPV4_FAMILY);

        /* network byte order stuff */
        if((ret = ip4_setparse(ipset, curip[0])) != 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 ");
        }
    }

    return;
}
Esempio n. 4
0
ip_set_t *
ipset_load(GInputStream *stream,
           GError **err)
{
    ip_set_t  *set;
    ipset_node_id_t  node;

    set = ipset_new();
    if (set == NULL) return NULL;

    GError  *suberror = NULL;

    node = ipset_node_cache_load
           (stream, ipset_cache, &suberror);
    if (suberror != NULL)
    {
        g_propagate_error(err, suberror);
        ipset_free(set);
        return NULL;
    }

    set->set_bdd = node;
    return set;
}