Added wrappers for substring-search

ndpi_init_automa()
ndpi_free_automa()
ndpi_add_string_to_automa()
ndpi_finalize_automa()
ndpi_match_string()
set_ndpi_malloc()
set_ndpi_free()
This commit is contained in:
Luca Deri
2016-05-07 18:45:18 +02:00
parent d5f77e92f7
commit 18901ca4d6
7 changed files with 259 additions and 138 deletions
+16 -1
View File
@@ -2,6 +2,7 @@
* ndpiReader.c
*
* Copyright (C) 2011-16 - ntop.org
*
* nDPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -40,7 +41,7 @@
#include <signal.h>
#include <pthread.h>
#include <sys/socket.h>
#include <assert.h>
#include "../config.h"
#include "ndpi_api.h"
@@ -1302,6 +1303,18 @@ void test_lib() {
}
}
void automataUnitTest() {
void *automa;
set_ndpi_malloc(malloc_wrapper), set_ndpi_free(free_wrapper);
assert(automa = ndpi_init_automa());
assert(ndpi_add_string_to_automa(automa, "hello") == 0);
assert(ndpi_add_string_to_automa(automa, "world") == 0);
ndpi_finalize_automa(automa);
assert(ndpi_match_string(automa, "This is the wonderful world of nDPI") == 0);
ndpi_free_automa(automa);
}
/**
@brief MAIN FUNCTION
@@ -1310,6 +1323,8 @@ int main(int argc, char **argv) {
int i;
automataUnitTest();
memset(ndpi_thread_info, 0, sizeof(ndpi_thread_info));
memset(&pcap_start, 0, sizeof(pcap_start));
memset(&pcap_end, 0, sizeof(pcap_end));