From fc48eef0ef72c8fd7ebd55f9692b6a83695ec405 Mon Sep 17 00:00:00 2001 From: Junfeng Wang Date: Mon, 9 Sep 2019 08:13:54 -0400 Subject: modify source code 1. add CMakeList for udpi 2. modify code to make it can be compiled without vpp source code Change-Id: Iabb7337a0db95d981f4ecc4e3e0cc3a3545dd5cf Signed-off-by: Junfeng Wang --- src/CMakeLists.txt | 44 -------------------------------------------- src/dpi.c | 8 ++++---- src/dpi_api.c | 14 +++++++------- src/dpi_cli.c | 4 ++-- src/dpi_node.c | 10 ++-------- src/protocols/dpi_ssl.c | 2 +- 6 files changed, 16 insertions(+), 66 deletions(-) delete mode 100644 src/CMakeLists.txt (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt deleted file mode 100644 index 5eb40d3..0000000 --- a/src/CMakeLists.txt +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright (c) 2018 Intel and/or its affiliates. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -message(STATUS "Looking for Hyperscan") -find_path(HYPERSCAN_INCLUDE_DIR NAMES hs/hs.h) -find_library(HYPERSCAN_LIB1 NAMES hs) -find_library(HYPERSCAN_LIB2 NAMES hs_runtime) -set (HYPERSCAN_LIB ${HYPERSCAN_LIB1} ${HYPERSCAN_LIB2}) - -if(HYPERSCAN_INCLUDE_DIR AND HYPERSCAN_LIB) - include_directories(${HYPERSCAN_INCLUDE_DIR}) - add_vpp_plugin(dpi - SOURCES - dpi.c - dpi_api.c - dpi_cli.c - dpi_node.c - protocols/dpi_ssl.c - - API_FILES - dpi.api - - INSTALL_HEADERS - dpi_app_match.h - dpi.h - - LINK_LIBRARIES - ${HYPERSCAN_LIB} - ) - message(STATUS "Found Hyperscan in ${HYPERSCAN_INCLUDE_DIR}") -else() - message(WARNING "-- Hyperscan not found - dpi_plugin disabled") -endif() - diff --git a/src/dpi.c b/src/dpi.c index 1cb482e..6423f3a 100644 --- a/src/dpi.c +++ b/src/dpi.c @@ -27,13 +27,13 @@ #include #include #include -#include +//#include #include #include -#include +//#include #include -#include +#include "dpi.h" dpi_main_t dpi_main; dpi_entry_t *dpi_dbs = NULL; @@ -709,7 +709,7 @@ VLIB_INIT_FUNCTION (dpi_init); /* *INDENT-OFF* */ VLIB_PLUGIN_REGISTER () = { - .version = VPP_BUILD_VER, +// .version = VPP_BUILD_VER, .description = "Deep Packet Inspection", }; /* *INDENT-ON* */ diff --git a/src/dpi_api.c b/src/dpi_api.c index 540d1a2..d8fa690 100644 --- a/src/dpi_api.c +++ b/src/dpi_api.c @@ -24,13 +24,13 @@ #include #include -#include +#include "dpi.h" #define vl_msg_id(n,h) n, typedef enum { -#include +#include "dpi.api.h" /* We'll want to know how many messages IDs we need... */ VL_MSG_FIRST_AVAILABLE, } vl_msg_id_t; @@ -38,27 +38,27 @@ typedef enum /* define message structures */ #define vl_typedefs -#include +#include "dpi.api.h" #undef vl_typedefs /* define generated endian-swappers */ #define vl_endianfun -#include +#include "dpi.api.h" #undef vl_endianfun /* instantiate all the print functions we know about */ #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) #define vl_printfun -#include +#include "dpi.api.h" #undef vl_printfun /* Get the API version number */ #define vl_api_version(n,v) static u32 api_version=(v); -#include +#include "dpi.api.h" #undef vl_api_version #define vl_msg_name_crc_list -#include +#include "dpi.api.h" #undef vl_msg_name_crc_list #define REPLY_MSG_ID_BASE dm->msg_id_base diff --git a/src/dpi_cli.c b/src/dpi_cli.c index 6b3afc7..4fbc760 100644 --- a/src/dpi_cli.c +++ b/src/dpi_cli.c @@ -26,8 +26,8 @@ #include #include #include -#include -#include +//#include +#include "dpi.h" extern dpi_main_t dpi_main; diff --git a/src/dpi_node.c b/src/dpi_node.c index 2e86c65..33774e9 100644 --- a/src/dpi_node.c +++ b/src/dpi_node.c @@ -22,11 +22,11 @@ #include #include #include -#include +//#include #include #include -#include +#include "dpi.h" vlib_node_registration_t dpi4_input_node; vlib_node_registration_t dpi6_input_node; @@ -535,7 +535,6 @@ dpi_input_inline (vlib_main_t * vm, u16 dst_port = 0; segment *seg = 0; segment *prev_seg = 0; - int rv; bi0 = to_next[0] = from[0]; b0 = vlib_get_buffer (vm, bi0); @@ -547,7 +546,6 @@ dpi_input_inline (vlib_main_t * vm, ip4_main_t *im4 = &ip4_main; fib_index0 = vec_elt (im4->fib_index_by_sw_if_index, vnet_buffer(b0)->sw_if_index[VLIB_RX]); - rv = parse_ip4_packet_and_lookup(ip40, fib_index0, &key40, ¬_found0, &flow_id0); } @@ -557,14 +555,10 @@ dpi_input_inline (vlib_main_t * vm, ip6_main_t *im6 = &ip6_main; fib_index0 = vec_elt (im6->fib_index_by_sw_if_index, vnet_buffer(b0)->sw_if_index[VLIB_RX]); - rv = parse_ip6_packet_and_lookup(ip60, fib_index0, &key60, ¬_found0, &flow_id0); } - if (!rv) - goto enqueue0; - is_reverse0 = (u8)((flow_id0 >> 63) & 0x1); flow_index0 = (u32)(flow_id0 & (u32)(~0)); flow0 = pool_elt_at_index (dm->dpi_flows, flow_index0); diff --git a/src/protocols/dpi_ssl.c b/src/protocols/dpi_ssl.c index 7257ca5..f15a19c 100644 --- a/src/protocols/dpi_ssl.c +++ b/src/protocols/dpi_ssl.c @@ -22,7 +22,7 @@ #include #include -#include +#include "../dpi.h" typedef enum { -- cgit 1.2.3-korg