aboutsummaryrefslogtreecommitdiff
path: root/example/ndpiReader.c
diff options
context:
space:
mode:
authorLuca Deri <deri@ntop.org>2016-05-07 18:45:18 +0200
committerLuca Deri <deri@ntop.org>2016-05-07 18:45:18 +0200
commit18901ca4d68d0c6ab4e56d3eaebf7ed5fb05264b (patch)
tree45b2dc2edd12fd90d586bc0dce768d379633f205 /example/ndpiReader.c
parentd5f77e92f7887ffc192c7df0ebb5a7bf93f37e41 (diff)
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()
Diffstat (limited to 'example/ndpiReader.c')
-rw-r--r--example/ndpiReader.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c
index 168bd7b15..618f10524 100644
--- a/example/ndpiReader.c
+++ b/example/ndpiReader.c
@@ -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));