aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHongjun Ni <hongjun.ni@intel.com>2019-09-09 05:29:43 +0000
committerGerrit Code Review <gerrit@fd.io>2019-09-09 05:29:43 +0000
commit29a4db4f00c86af1da59a66920741459125bc875 (patch)
treebc42d45e5a8396821f097a35edeec487d3f34305
parentf0cd428b88e9d8e4e42021ea35fc47c41e018899 (diff)
parentfc48eef0ef72c8fd7ebd55f9692b6a83695ec405 (diff)
Merge "modify source code"
-rw-r--r--CMakeLists.txt173
-rw-r--r--README.md179
-rw-r--r--cmake/FindVPP.cmake209
-rw-r--r--cmake/Packager.cmake151
-rw-r--r--src/CMakeLists.txt44
-rw-r--r--src/dpi.c8
-rw-r--r--src/dpi_api.c14
-rw-r--r--src/dpi_cli.c4
-rw-r--r--src/dpi_node.c10
-rw-r--r--src/protocols/dpi_ssl.c2
10 files changed, 723 insertions, 71 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..c7cbc43
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,173 @@
+# Copyright (c) 2017-2019 Cisco, 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.
+
+cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
+project(udpi-plugin)
+
+include(GNUInstallDirs)
+
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake/"
+)
+
+set (CMAKE_CXX_STANDARD 11)
+set (CMAKE_C_STANDARD 11)
+
+# Check for memfd_create syscall
+include(CheckSymbolExists)
+CHECK_SYMBOL_EXISTS ( "__NR_memfd_create" "sys/syscall.h" HAVE_MEMFD_CREATE )
+if ( HAVE_MEMFD_CREATE )
+ add_definitions ( -DHAVE_MEMFD_CREATE )
+endif()
+
+if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
+ set(UDPI_PLUGIN udpi-plugin)
+endif()
+
+include (Packager)
+
+# Dependencies
+
+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})
+ message(STATUS "Found Hyperscan in ${HYPERSCAN_INCLUDE_DIR}")
+else()
+ message(WARNING "-- Hyperscan not found - dpi_plugin disabled")
+endif()
+
+find_package(VPP REQUIRED)
+
+include_directories(${VPP_INCLUDE_DIR})
+
+set(UDPI_PLUGIN_FILES
+ src/dpi.c
+ src/dpi_api.c
+ src/dpi_cli.c
+ src/dpi_node.c
+ src/protocols/dpi_ssl.c
+)
+
+set(UDPI_PLUGIN_HEADER_FILES
+ src/dpi_app_match.h
+ src/dpi.h
+ )
+
+set(UDPI_API_TEST_SOURCE_FILES
+ )
+
+set(UDPI_API_GENERATED_FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/vpp_plugins/udpi/dpi.api.h)
+
+set(UDPI_VAPI_GENERATED_FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/vpp_plugins/udpi/dpi.api.vapi.h
+ ${CMAKE_CURRENT_BINARY_DIR}/vpp_plugins/udpi/dpi.api.vapi.hpp)
+
+if (NOT VPP_HOME)
+ set(VPP_HOME /usr)
+endif()
+
+if (NOT CMAKE_BUILD_TYPE)
+ set (CMAKE_BUILD_TYPE "Release")
+endif (NOT CMAKE_BUILD_TYPE)
+
+SET(UDPI_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} CACHE STRING "udpi_install_prefix")
+
+if (CMAKE_BUILD_TYPE STREQUAL "Release")
+ set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Wall -march=native -O3 -g")
+elseif (CMAKE_BUILD_TYPE STREQUAL "Debug")
+ set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -march=native -O0 -g")
+ add_definitions(-DCLIB_DEBUG -fPIC -fstack-protector-all)
+endif()
+
+execute_process(
+ COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/vpp_plugins/udpi
+ )
+# These files are missing from vpp binary distribution
+execute_process(
+ COMMAND curl https://git.fd.io/vpp/plain/src/vpp-api/vapi/vapi_json_parser.py?h=stable/1908 -o ${CMAKE_BINARY_DIR}/vapi_json_parser.py
+ COMMAND curl https://git.fd.io/vpp/plain/src/vpp-api/vapi/vapi_c_gen.py?h=stable/1908 -o ${CMAKE_BINARY_DIR}/vapi_c_gen.py
+ COMMAND curl https://git.fd.io/vpp/plain/src/vpp-api/vapi/vapi_cpp_gen.py?h=stable/1908 -o ${CMAKE_BINARY_DIR}/vapi_cpp_gen.py
+ )
+
+add_custom_command(
+ COMMAND chmod +x ${CMAKE_BINARY_DIR}/vapi_json_parser.py ${CMAKE_BINARY_DIR}/vapi_c_gen.py ${CMAKE_BINARY_DIR}/vapi_cpp_gen.py
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/vpp_plugins/udpi/dpi.api.h
+ COMMAND ${VPP_HOME}/bin/vppapigen --input ${CMAKE_CURRENT_SOURCE_DIR}/src/dpi.api --output ${CMAKE_CURRENT_BINARY_DIR}/vpp_plugins/udpi/dpi.api.h
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/dpi.api
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/vpp_plugins/udpi/dpi.api.json
+ COMMAND ${VPP_HOME}/bin/vppapigen JSON --input ${CMAKE_CURRENT_SOURCE_DIR}/src/dpi.api --output ${CMAKE_CURRENT_BINARY_DIR}/vpp_plugins/udpi/dpi.api.json
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/vpp_plugins/udpi/dpi.api.vapi.h
+ COMMAND ${CMAKE_BINARY_DIR}/vapi_c_gen.py ${CMAKE_CURRENT_BINARY_DIR}/vpp_plugins/udpi/dpi.api.json
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/vpp_plugins/udpi/dpi.api.vapi.hpp
+ COMMAND ${CMAKE_BINARY_DIR}/vapi_cpp_gen.py ${CMAKE_CURRENT_BINARY_DIR}/vpp_plugins/udpi/dpi.api.json
+ )
+
+include_directories(SYSTEM)
+include_directories(${CMAKE_CURRENT_BINARY_DIR})
+
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUDPI_VPP_PLUGIN=1")
+add_library(udpi_plugin SHARED
+ ${UDPI_PLUGIN_FILES}
+ ${UDPI_API_GENERATED_FILES}
+ ${UDPI_VAPI_GENERATED_FILES})
+target_link_libraries(udpi_plugin ${HYPERSCAN_LIB})
+
+file(COPY ${UDPI_API_GENERATED_FILES} DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/src )
+file(COPY ${UDPI_PLUGIN_HEADER_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/vpp_plugins/udpi)
+include_directories(${CMAKE_CURRENT_BINARY_DIR}/vpp_plugins)
+
+add_library(udpi_api_test_plugin SHARED
+ ${UDPI_API_TEST_SOURCE_FILES}
+ ${UDPI_API_GENERATED_FILES})
+
+set(VPP_INSTALL_PLUGIN ${UDPI_INSTALL_PREFIX}/vpp_plugins)
+set(VPP_INSTALL_API_TEST_PLUGIN ${UDPI_INSTALL_PREFIX}/vpp_api_test_plugins CACHE STRING "vpp_install_api_test_plugin")
+
+set_target_properties(udpi_plugin
+ PROPERTIES
+ LINKER_LANGUAGE C
+ INSTALL_RPATH ${VPP_INSTALL_PLUGIN}
+ PREFIX "")
+set_target_properties(udpi_api_test_plugin
+ PROPERTIES
+ LINKER_LANGUAGE C
+ PREFIX "")
+
+install(DIRECTORY
+ DESTINATION ${VPP_INSTALL_PLUGIN}
+ COMPONENT ${UDPI_PLUGIN})
+install(TARGETS udpi_plugin
+ DESTINATION ${VPP_INSTALL_PLUGIN}
+ COMPONENT ${UDPI_PLUGIN})
+
+#install(DIRECTORY
+# DESTINATION ${VPP_INSTALL_API_TEST_PLUGIN}
+# COMPONENT ${UDPI_PLUGIN})
+#install(TARGETS udpi_api_test_plugin
+# DESTINATION ${VPP_INSTALL_API_TEST_PLUGIN}
+# COMPONENT ${UDPI_PLUGIN})
+
+install(FILES ${UDPI_API_HEADER_FILES} ${UDPI_API_GENERATED_FILES}
+ DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/vpp_plugins/udpi
+ COMPONENT ${UDPI_PLUGIN}-dev)
+
+install(FILES ${UDPI_VAPI_GENERATED_FILES}
+ DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/vapi
+ COMPONENT ${UDPI_PLUGIN}-dev)
+
+make_packages()
diff --git a/README.md b/README.md
index bb6f9b0..a34460b 100644
--- a/README.md
+++ b/README.md
@@ -17,12 +17,181 @@ For more information on UDPI and its features please visit the
Details of the changes leading up to this version of UDPI can be found under
@ref release notes.
+## Quick Start ##(in CentOS cmake = cmake3, gcc = devtoolset-7, follow vpp)
+```
+From the code tree root
-## Getting started
+(VPP installed with DEB or RPM pkg)
+$ cd udpi-plugin
+$ mkdir -p build
+$ cd build
+$ cmake .. -DCMAKE_INSTALL_PREFIX=/usr #(add "-DCMKAE_INSTALL_LIBDIR=lib" on centos and it's releated)
+$ make package
-Make sure you have added FD.io repository using https://packagecloud.io/fdio/release/
-installation script.
-You should have a sight on the release package, the package name may be different depending on the distribution.
-(ex: vpp-plugins.deb for VPP 19.01 and vpp-plugin-core.deb and vpp-plugin-dpdk.deb in 19.04)
+(VPP source code -- build type RELEASE)
+$ cd udpi-plugin
+$ mkdir -p build
+$ cd build
+$ cmake .. -DVPP_HOME=<vpp dir>/build-root/install-vpp-native/vpp -DCMAKE_INSTALL_PREFIX=<vpp src>/build-root/install-vpp-native/vpp #(add "-DCMKAE_INSTALL_LIBDIR=lib" on centos and it's releated)
+$ make
+$ sudo make install
+(VPP source code -- build type DEBUG)
+$ cd udpi-plugin
+$ mkdir -p build
+$ cd build
+$ cmake .. -DCMAKE_BUILD_TYPE=DEBUG -DVPP_HOME=<vpp dir>/build-root/install-vpp_debug-native/vpp -DCMAKE_INSTALL_PREFIX=<vpp src>/build-root/install-vpp_debug-native/vpp #(add "-DCMKAE_INSTALL_LIBDIR=lib" on centos and it's releated)
+$ make
+$ sudo make install
+CMAKE variables:
+- CMKAE_INSTALL_LIBDIR -- set the library directory. In CentOS, it is lib or lib64, in debian and it's releated, it is lib/x86_64-linux-gnu
+- CMAKE_INSTALL_PREFIX -- set the install directory for the udpi-plugin. This is the common path to the lib folder containing vpp_plugins and vpp_api_test_plugins folders. Default is /usr/local.
+- VPP_HOME -- set the directory containing the include and lib directories of vpp.
+```
+
+## Using udpi plugin ##
+
+### Platforms ###
+
+udpi-plugin has been tested in:
+
+- Ubuntu 16.04 LTS (x86_64)
+- Ubuntu 18.04 LTS (x86_64)
+- Debian Stable/Testing
+- Red Hat Enterprise Linux 7
+- CentOS 7
+
+
+### Dependencies ###
+
+Build dependencies:
+
+- Hyperscan
+
+- VPP 19.08
+ - DEB packages (can be found https://packagecloud.io/fdio/release/install):
+ - libvppinfra-dev
+ - vpp-dev
+
+Running dependencies:
+
+- VPP 19.08
+ - DEB packages (can be found https://packagecloud.io/fdio/release/install):
+ - vpp
+ - vpp-plugin-core
+ - vpp-plugin-dpdk (only to use DPDK compatible nics)
+
+Hardware support (not mandatory):
+
+- [DPDK](http://DPDK.org/) compatible nics
+
+## Getting started ##
+In order to start, the udpi plugin requires a running instance of VPP
+The steps required to successfully start udpi are:
+
+- Setup the host to run VPP
+- Configure VPP to use DPDK compatible nics
+- Start VPP
+- Configure VPP interfaces
+- Configure and start udpi
+
+Detailed information for configuring VPP can be found at [https://wiki.fd.io/view/VPP](https://wiki.fd.io/view/VPP).
+
+### Setup the host for VPP ###
+
+Hugepages must be enabled in the system
+
+```
+$ sudo sysctl -w vm.nr_hugepages=1024
+```
+
+In order to use a DPDK interface, the `uio` and `uio_pci_generic` or `vfio_pci` modules need to be loaded in the kernel
+
+```
+$ sudo modprobe uio
+$ sudo modprobe uio_pci_generic
+$ sudo modprobe vfio_pci
+```
+
+If the DPDK interface we want to assign to VPP is up, we must bring it down
+
+```
+$ sudo ifconfig <interface_name> down
+```
+or
+```
+$ sudo ip link set <interface_name> down
+```
+
+### Configure VPP ###
+The file /etc/VPP/startup.conf contains a set of parameters to setup VPP at startup.
+The following example sets up VPP to use a DPDK interfaces:
+
+``` shell
+unix {
+ nodaemon
+ log /tmp/vpp.log
+ full-coredump
+}
+
+api-trace {
+ on
+}
+
+api-segment {
+ gid vpp
+}
+
+dpdk {
+ dev 0000:08:00.0
+}
+
+plugins {
+ ## Disable all plugins by default and then selectively enable specific plugins
+
+ ## Enable all plugins by default and then selectively disable specific plugins
+}
+```
+Where `0000:08:00.0` must be replaced with the actual PCI address of the DPDK interface
+
+### Start VPP ###
+
+VPP can be started as a process or a service:
+
+``` shell
+Start VPP as a service in Ubuntu 16.04
+$ sudo systemctl start vpp
+
+Start VPP as a process in both 16.04
+$ sudo vpp -c /etc/vpp/startup.conf
+
+```
+
+### Configure udpi plugin ###
+The udpi plugin can be configured either using the VPP command-line interface (CLI), through a configuration file or through the VPP binary api
+
+#### udpi plugin CLI ####
+
+The CLI commands for the udpi plugin start all with the udpi keyword. To see the full list of command available type:
+...(to be added)
+
+## License ##
+
+This software is distributed under the following license:
+
+```
+Copyright (c) 2018-2019 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.
+
+```
diff --git a/cmake/FindVPP.cmake b/cmake/FindVPP.cmake
new file mode 100644
index 0000000..56ab482
--- /dev/null
+++ b/cmake/FindVPP.cmake
@@ -0,0 +1,209 @@
+#
+# Copyright (c) 2018 PANTHEON.tech.
+#
+# 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.
+
+
+# - Try to find LibVPP
+# Once done this will define
+#
+# VPP_FOUND - system has VPP
+# VPP_INCLUDE_DIRS - the VPP include directory
+# VPP_LIBRARIES - Link these to use LibSSH
+
+
+if (VPP_LIBRARIES AND VPP_INCLUDE_DIRS)
+ # in cache already
+ set(VPP_FOUND TRUE)
+else (VPP_LIBRARIES AND VPP_INCLUDE_DIRS)
+
+ set(VPP_INCLUDE_PATH
+ /usr/include
+ /usr/local/include
+ /opt/local/include
+ /sw/include
+ )
+
+ set(VPP_LIBRARY_PATH
+ /usr/lib
+ /usr/lib64
+ /usr/local/lib
+ /usr/local/lib64
+ /opt/local/lib
+ /sw/lib
+ )
+
+ find_path(VNET_INCLUDE_DIR
+ NAMES
+ vnet/vnet.h
+ PATHS
+ ${VPP_INCLUDE_PATH}
+ ${CMAKE_INCLUDE_PATH}
+ ${CMAKE_INSTALL_PREFIX}/include
+
+ )
+
+ find_path(VLIB_API_INCLUDE_DIR
+ NAMES
+ vlibapi/api.h
+ PATHS
+ ${VPP_INCLUDE_PATH}
+ ${CMAKE_INCLUDE_PATH}
+ ${CMAKE_INSTALL_PREFIX}/include
+ )
+
+ find_path(VLIBMEMORY_INCLUDE_DIR
+ NAMES
+ vlibmemory/api.h
+ PATHS
+ ${VPP_INCLUDE_PATH}
+ ${CMAKE_INCLUDE_PATH}
+ ${CMAKE_INSTALL_PREFIX}/include
+ )
+
+ find_path(VPP_MSG_INCLUDE_DIR
+ NAMES
+ vpp/api/vpe_msg_enum.h
+ PATHS
+ ${VPP_INCLUDE_PATH}
+ ${CMAKE_INCLUDE_PATH}
+ ${CMAKE_INSTALL_PREFIX}/include
+ )
+
+ find_path(VPP_ALL_INCLUDE_DIR
+ NAMES
+ vpp/api/vpe_all_api_h.h
+ PATHS
+ ${VPP_INCLUDE_PATH}
+ ${CMAKE_INCLUDE_PATH}
+ ${CMAKE_INSTALL_PREFIX}/include
+ )
+
+ find_path(VAPI_INCLUDE_DIR
+ NAMES
+ vapi/interface.api.vapi.h
+ PATHS
+ ${VPP_INCLUDE_PATH}
+ ${CMAKE_INCLUDE_PATH}
+ ${CMAKE_INSTALL_PREFIX}/include
+ )
+
+ find_path(VOM_INCLUDE_DIR
+ NAMES
+ vom/om.hpp
+ PATHS
+ ${VPP_INCLUDE_PATH}
+ ${CMAKE_INCLUDE_PATH}
+ ${CMAKE_INSTALL_PREFIX}/include
+ )
+
+ find_library(VLIBMEMORYCLIENT_LIBRARY
+ NAMES
+ vlibmemoryclient
+ libvlibmemoryclient
+ PATHS
+ ${VPP_LIBARY_PATH}
+ ${CMAKE_LIBRARY_PATH}
+ ${CMAKE_INSTALL_PREFIX}/lib
+ )
+
+ find_library(SVM_LIBRARY
+ NAMES
+ svm
+ libsvm
+ PATHS
+ ${VPP_LIBRARY_PATH}
+ ${CMAKE_LIBRARY_PATH}
+ ${CMAKE_INSTALL_PREFIX}/lib
+ )
+
+ find_library(VPPINFRA_LIBRARY
+ NAMES
+ vppinfra
+ libvppinfra
+ PATHS
+ ${VPP_LIBRARY_PATH}
+ ${CMAKE_LIBRARY_PATH}
+ ${CMAKE_INSTALL_PREFIX}/lib
+ )
+
+ find_library(VLIB_LIBRARY
+ NAMES
+ vlib
+ libvlib
+ PATHS
+ ${VPP_LIBRARY_PATH}
+ ${CMAKE_LIBRARY_PATH}
+ ${CMAKE_INSTALL_PREFIX}/lib
+ )
+
+ find_library(VATPLUGIN_LIBRARY
+ NAMES
+ vatplugin
+ libvatplugin
+ PATHS
+ ${VPP_LIBRARY_PATH}
+ ${CMAKE_LIBRARY_PATH}
+ ${CMAKE_INSTALL_PREFIX}/lib
+ )
+
+ find_library(VAPI_LIBRARY
+ NAMES
+ vapiclient
+ libvapiclient
+ PATHS
+ ${VPP_LIBRARY_PATH}
+ ${CMAKE_LIBRARY_PATH}
+ ${CMAKE_INSTALL_PREFIX}/lib
+ )
+
+ find_library(VOM_LIBRARY
+ NAMES
+ vom
+ libvom
+ PATHS
+ ${VPP_LIBRARY_PATH}
+ ${CMAKE_LIBRARY_PATH}
+ ${CMAKE_INSTALL_PREFIX}/lib
+ )
+
+ if (VPP_INCLUDE_DIR AND VPP_LIBRARY)
+ set(VPP_FOUND TRUE)
+ else (VPP_INCLUDE_DIR AND VPP_LIBRARY)
+ set(VPP_FOUND FALSE)
+ endif (VPP_INCLUDE_DIR AND VPP_LIBRARY)
+
+ set(VPP_INCLUDE_DIRS
+ ${VNET_INCLUDE_DIR}
+ ${VLIB_API_INCLUDE_DIR}
+ ${VLIB_MEMORY_INCLUDE_DIR}
+ ${VPP_MSG_INCLUDE_DIR}
+ ${VPP_ALL_INCLUDE_DIR}
+ ${VAPI_INCLUDE_DIR}
+ ${VOM_INCLUDE_DIR}
+ )
+
+ set(VPP_LIBRARIES
+ ${VLIBMEMORYCLIENT_LIBRARY}
+ ${SVM_LIBRARY}
+ ${VPPINFRA_LIBRARY}
+ ${VLIB_LIBRARY}
+ ${VATPLUGIN_LIBRARY}
+ ${VAPI_LIBRARY}
+ ${VOM_LIBRARY}
+ )
+
+ # show the VPP_INCLUDE_DIRS and VPP_LIBRARIES variables only in the advanced view
+ mark_as_advanced(VPP_INCLUDE_DIRS VPP_LIBRARIES)
+
+endif (VPP_LIBRARIES AND VPP_INCLUDE_DIRS)
diff --git a/cmake/Packager.cmake b/cmake/Packager.cmake
new file mode 100644
index 0000000..b049819
--- /dev/null
+++ b/cmake/Packager.cmake
@@ -0,0 +1,151 @@
+# Copyright (c) 2017-2019 Cisco 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.
+
+#############
+# RPM/DEB/TGZ Packaging utils
+#
+
+set(CONTACT "udpi-dev@lists.fd.io" CACHE STRING "Contact")
+set(PACKAGE_MAINTAINER "Udpi Team" CACHE STRING "Maintainer")
+set(PACKAGE_VENDOR "fd.io" CACHE STRING "Vendor")
+
+# macro(set)
+
+macro(make_packages)
+ if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
+ # parse /etc/os-release
+ file(READ "/etc/os-release" os_version)
+ string(REPLACE "\n" ";" os_version ${os_version})
+ foreach(_ver ${os_version})
+ string(REPLACE "=" ";" _ver ${_ver})
+ list(GET _ver 0 _name)
+ list(GET _ver 1 _value)
+ set(OS_${_name} ${_value})
+ endforeach()
+
+ #extract version from git
+ execute_process(
+ COMMAND git describe --long --tags
+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+ OUTPUT_VARIABLE VER
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+
+ if (NOT VER)
+ set(VER "v1.0")
+ endif()
+
+ string(REGEX REPLACE "v(.*)-([0-9]+)-(g[0-9a-f]+)" "\\1;\\2;\\3" VER ${VER})
+ list(GET VER 0 tag)
+ string(REPLACE "-" "~" tag ${tag})
+ list(GET VER 1 commit_num)
+ list(GET VER 2 commit_name)
+
+ message("${tag}")
+
+ if (NOT DEFINED ENV{BUILD_NUMBER})
+ set(bld "b1")
+ else()
+ set(bld "b$ENV{BUILD_NUMBER}")
+ endif()
+
+ message("Build number is: ${bld}")
+
+ #define DEB and RPM version numbers
+ if(${commit_num} EQUAL 0)
+ set(deb_ver "${tag}")
+ set(rpm_ver "${tag}")
+ else()
+ set(deb_ver "${tag}-${commit_num}-${commit_name}")
+ set(rpm_ver "${tag}-${commit_num}-${commit_name}")
+ endif()
+
+ get_cmake_property(components COMPONENTS)
+
+ if(OS_ID_LIKE MATCHES "debian")
+ set(CPACK_GENERATOR "DEB")
+ set(type "DEBIAN")
+
+ execute_process(
+ COMMAND dpkg --print-architecture
+ OUTPUT_VARIABLE arch
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+
+ set(CPACK_PACKAGE_VERSION "${deb_ver}")
+ foreach(lc ${components})
+ if (${lc} MATCHES ".*Unspecified.*")
+ continue()
+ endif()
+
+ string(TOUPPER ${lc} uc)
+ set(CPACK_${type}_${uc}_FILE_NAME "${lc}_${deb_ver}_${arch}.deb")
+
+ set(DEB_DEPS)
+ if (NOT ${${lc}_DEB_DEPENDENCIES} STREQUAL "")
+ string(REPLACE "stable_version" ${tag} DEB_DEPS ${${lc}_DEB_DEPENDENCIES})
+ endif()
+
+ set(CPACK_${type}_${uc}_PACKAGE_DEPENDS "${DEB_DEPS}")
+ set(CPACK_${type}_${uc}_PACKAGE_NAME "${lc}")
+ set(CPACK_COMPONENT_${uc}_DESCRIPTION "${${lc}_DESCRIPTION}")
+ endforeach()
+ elseif(OS_ID_LIKE MATCHES "rhel")
+ set(CPACK_GENERATOR "RPM")
+ set(type "RPM")
+
+ execute_process(
+ COMMAND uname -m
+ OUTPUT_VARIABLE arch
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+
+ set(CPACK_PACKAGE_VERSION "${rpm_ver}")
+ foreach(lc ${components})
+ if (${lc} MATCHES ".*Unspecified.*")
+ continue()
+ endif()
+
+ string(TOUPPER ${lc} uc)
+ set(CPACK_${type}_${uc}_DESCRIPTION "${${lc}_DESCRIPTION}")
+
+ set(RPM_DEPS)
+ if (NOT ${${lc}_DEB_DEPENDENCIES} STREQUAL "")
+ string(REPLACE "stable_version" ${tag} RPM_DEPS ${${lc}_RPM_DEPENDENCIES})
+ endif()
+
+ set(CPACK_${type}_${uc}_PACKAGE_REQUIRES "${RPM_DEPS}")
+
+ if(${lc} MATCHES ".*-dev")
+ set(package_name ${lc}el)
+ else()
+ set(package_name ${lc})
+ endif()
+
+ set(CPACK_RPM_${uc}_PACKAGE_NAME "${package_name}")
+ set(CPACK_${type}_${uc}_FILE_NAME "${package_name}-${rpm_ver}.${arch}.rpm")
+ endforeach()
+ endif()
+
+ if(CPACK_GENERATOR)
+ set(CPACK_PACKAGE_NAME ${ARG_NAME})
+ set(CPACK_STRIP_FILES OFF)
+ set(CPACK_PACKAGE_VENDOR "${PACKAGE_VENDOR}")
+ set(CPACK_COMPONENTS_IGNORE_GROUPS 1)
+ set(CPACK_${CPACK_GENERATOR}_COMPONENT_INSTALL ON)
+ set(CPACK_${type}_PACKAGE_MAINTAINER "Udpi Team")
+ set(CPACK_${type}_PACKAGE_RELEASE 1)
+ include(CPack)
+ endif()
+ endif()
+endmacro()
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 d5f37f6..c91a78a 100644
--- a/src/dpi.c
+++ b/src/dpi.c
@@ -27,13 +27,13 @@
#include <vnet/fib/fib_entry.h>
#include <vnet/fib/fib_table.h>
#include <vnet/mfib/mfib_table.h>
-#include <vnet/adj/adj_mcast.h>
+//#include <vnet/adj/adj_mcast.h>
#include <vnet/dpo/dpo.h>
#include <vnet/plugin/plugin.h>
-#include <vpp/app/version.h>
+//#include <vpp/app/version.h>
#include <vnet/flow/flow.h>
-#include <dpi/dpi.h>
+#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 <vppinfra/byte_order.h>
#include <vlibmemory/api.h>
-#include <dpi/dpi.h>
+#include "dpi.h"
#define vl_msg_id(n,h) n,
typedef enum
{
-#include <dpi/dpi.api.h>
+#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 <dpi/dpi.api.h>
+#include "dpi.api.h"
#undef vl_typedefs
/* define generated endian-swappers */
#define vl_endianfun
-#include <dpi/dpi.api.h>
+#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 <dpi/dpi.api.h>
+#include "dpi.api.h"
#undef vl_printfun
/* Get the API version number */
#define vl_api_version(n,v) static u32 api_version=(v);
-#include <dpi/dpi.api.h>
+#include "dpi.api.h"
#undef vl_api_version
#define vl_msg_name_crc_list
-#include <dpi/dpi.api.h>
+#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 <vnet/plugin/plugin.h>
#include <vnet/fib/fib_entry.h>
#include <vnet/fib/fib_table.h>
-#include <vpp/app/version.h>
-#include <dpi/dpi.h>
+//#include <vpp/app/version.h>
+#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 <vppinfra/pool.h>
#include <vppinfra/vec.h>
#include <vnet/plugin/plugin.h>
-#include <vpp/app/version.h>
+//#include <vpp/app/version.h>
#include <vnet/flow/flow.h>
#include <vnet/tcp/tcp_packet.h>
-#include <dpi/dpi.h>
+#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,
&not_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,
&not_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 <vlib/vlib.h>
#include <vlib/unix/unix.h>
-#include <dpi/dpi.h>
+#include "../dpi.h"
typedef enum
{