From 612dd6a955e44d2c0fed1801fb8de585ca695c63 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Mon, 30 Jul 2018 12:45:07 +0200 Subject: CMake as an alternative to autotools (experimental) Change-Id: Ibc59323e849810531dd0963e85493efad3b86857 Signed-off-by: Damjan Marion --- src/CMakeLists.txt | 161 ++++++++++ src/plugins/CMakeLists.txt | 63 ++++ src/plugins/abf/CMakeLists.txt | 19 ++ src/plugins/acl/CMakeLists.txt | 21 ++ src/plugins/avf/CMakeLists.txt | 28 ++ src/plugins/cdp/CMakeLists.txt | 26 ++ src/plugins/dpdk/CMakeLists.txt | 100 +++++++ src/plugins/examples/gen-rules.py | 186 ------------ src/plugins/examples/health_check.c | 109 ------- src/plugins/examples/test_map.py | 141 --------- src/plugins/flowprobe/CMakeLists.txt | 24 ++ src/plugins/gbp/CMakeLists.txt | 27 ++ src/plugins/gtpu/CMakeLists.txt | 26 ++ src/plugins/igmp/CMakeLists.txt | 29 ++ src/plugins/ila/CMakeLists.txt | 15 + src/plugins/ioam/CMakeLists.txt | 99 +++++++ src/plugins/ixge/CMakeLists.txt | 16 + src/plugins/l2e/CMakeLists.txt | 18 ++ src/plugins/lacp/CMakeLists.txt | 32 ++ src/plugins/lb/CMakeLists.txt | 27 ++ src/plugins/mactime/CMakeLists.txt | 24 ++ src/plugins/map/CMakeLists.txt | 23 ++ src/plugins/map/examples/gen-rules.py | 186 ++++++++++++ src/plugins/map/examples/health_check.c | 109 +++++++ src/plugins/map/examples/test_map.py | 141 +++++++++ src/plugins/marvell/CMakeLists.txt | 32 ++ src/plugins/memif/CMakeLists.txt | 27 ++ src/plugins/nat/CMakeLists.txt | 41 +++ src/plugins/pppoe/CMakeLists.txt | 27 ++ src/plugins/srv6-ad/CMakeLists.txt | 17 ++ src/plugins/srv6-am/CMakeLists.txt | 17 ++ src/plugins/srv6-as/CMakeLists.txt | 17 ++ src/plugins/stn/CMakeLists.txt | 24 ++ src/plugins/tlsmbedtls/CMakeLists.txt | 30 ++ src/plugins/tlsopenssl/CMakeLists.txt | 18 ++ src/plugins/unittest/CMakeLists.txt | 18 ++ src/scripts/generate_version_h | 28 ++ src/svm/CMakeLists.txt | 62 ++++ src/vcl/CMakeLists.txt | 53 ++++ src/vlib/CMakeLists.txt | 98 +++++++ src/vlibmemory/CMakeLists.txt | 41 +++ src/vnet/CMakeLists.txt | 501 ++++++++++++++++++++++++++++++++ src/vpp/CMakeLists.txt | 87 ++++++ src/vppinfra/CMakeLists.txt | 235 +++++++++++++++ src/vppinfra/vector_sse42.h | 2 +- 45 files changed, 2588 insertions(+), 437 deletions(-) create mode 100644 src/CMakeLists.txt create mode 100644 src/plugins/CMakeLists.txt create mode 100644 src/plugins/abf/CMakeLists.txt create mode 100644 src/plugins/acl/CMakeLists.txt create mode 100644 src/plugins/avf/CMakeLists.txt create mode 100644 src/plugins/cdp/CMakeLists.txt create mode 100644 src/plugins/dpdk/CMakeLists.txt delete mode 100755 src/plugins/examples/gen-rules.py delete mode 100644 src/plugins/examples/health_check.c delete mode 100755 src/plugins/examples/test_map.py create mode 100644 src/plugins/flowprobe/CMakeLists.txt create mode 100644 src/plugins/gbp/CMakeLists.txt create mode 100644 src/plugins/gtpu/CMakeLists.txt create mode 100644 src/plugins/igmp/CMakeLists.txt create mode 100644 src/plugins/ila/CMakeLists.txt create mode 100644 src/plugins/ioam/CMakeLists.txt create mode 100644 src/plugins/ixge/CMakeLists.txt create mode 100644 src/plugins/l2e/CMakeLists.txt create mode 100644 src/plugins/lacp/CMakeLists.txt create mode 100644 src/plugins/lb/CMakeLists.txt create mode 100644 src/plugins/mactime/CMakeLists.txt create mode 100644 src/plugins/map/CMakeLists.txt create mode 100755 src/plugins/map/examples/gen-rules.py create mode 100644 src/plugins/map/examples/health_check.c create mode 100755 src/plugins/map/examples/test_map.py create mode 100644 src/plugins/marvell/CMakeLists.txt create mode 100644 src/plugins/memif/CMakeLists.txt create mode 100644 src/plugins/nat/CMakeLists.txt create mode 100644 src/plugins/pppoe/CMakeLists.txt create mode 100644 src/plugins/srv6-ad/CMakeLists.txt create mode 100644 src/plugins/srv6-am/CMakeLists.txt create mode 100644 src/plugins/srv6-as/CMakeLists.txt create mode 100644 src/plugins/stn/CMakeLists.txt create mode 100644 src/plugins/tlsmbedtls/CMakeLists.txt create mode 100644 src/plugins/tlsopenssl/CMakeLists.txt create mode 100644 src/plugins/unittest/CMakeLists.txt create mode 100755 src/scripts/generate_version_h create mode 100644 src/svm/CMakeLists.txt create mode 100644 src/vcl/CMakeLists.txt create mode 100644 src/vlib/CMakeLists.txt create mode 100644 src/vlibmemory/CMakeLists.txt create mode 100644 src/vnet/CMakeLists.txt create mode 100644 src/vpp/CMakeLists.txt create mode 100644 src/vppinfra/CMakeLists.txt (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 00000000000..13ae93d6e24 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,161 @@ +# Copyright (c) 2018 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. + +cmake_minimum_required(VERSION 3.5 FATAL_ERROR) + +project(vpp C) + +include(CheckCCompilerFlag) + +############################################################################## +# CPU optimizations and multiarch support +############################################################################## +if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*") + set(CMAKE_C_FLAGS "-march=corei7 -mtune=corei7-avx ${CMAKE_C_FLAGS}") + check_c_compiler_flag("-march=core-avx2" AVX2) + if(AVX2) + list(APPEND MARCH_VARIANTS "avx2\;-march=core-avx2 -mtune=core-avx2") + endif() + check_c_compiler_flag("-march=skylake-avx512" AVX512) + if(AVX512) + list(APPEND MARCH_VARIANTS "avx512\;-march=skylake-avx512 -mtune=skylake-avx512") + endif() +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*)") + set(CMAKE_C_FLAGS "-march=armv8-a+crc ${CMAKE_C_FLAGS}") +endif() + +macro(vpp_library_set_multiarch_sources lib) + foreach(V ${MARCH_VARIANTS}) + list(GET V 0 VARIANT) + list(GET V 1 VARIANT_FLAGS) + set(l ${lib}_${VARIANT}) + add_library(${l} OBJECT ${ARGN}) + set_target_properties(${l} PROPERTIES POSITION_INDEPENDENT_CODE ON) + target_compile_options(${l} PUBLIC "-DCLIB_MARCH_VARIANT=${VARIANT}") + separate_arguments(VARIANT_FLAGS) + target_compile_options(${l} PUBLIC ${VARIANT_FLAGS}) + target_sources(${lib} PRIVATE $) + endforeach() +endmacro() + +############################################################################## +# build config +############################################################################## +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +set(CMAKE_C_FLAGS_COMMON "-DFORTIFY_SOURCE=2 -fstack-protector-all -Werror") +set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${CMAKE_C_FLAGS_COMMON} -DCLIB_DEBUG") +set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${CMAKE_C_FLAGS_COMMON}") + +############################################################################## +# ccache +############################################################################## +option(VPP_USE_CCACHE "Use ccache compiler cache." ON) +if(VPP_USE_CCACHE) + find_program(CCACHE_FOUND ccache) + message(STATUS "Looking for ccache") + if(CCACHE_FOUND) + message(STATUS "Looking for ccache - found") + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) + set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) + else(CCACHE_FOUND) + message(STATUS "Looking for ccache - not found") + endif(CCACHE_FOUND) +endif(VPP_USE_CCACHE) + +############################################################################## +# install config +############################################################################## +set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") +set(CMAKE_INSTALL_MESSAGE NEVER) + +message(STATUS "CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}") +message(STATUS "We are on a ${CMAKE_SYSTEM_NAME} system") +message(STATUS "The host processor is ${CMAKE_HOST_SYSTEM_PROCESSOR}") + +include_directories ( + ${CMAKE_SOURCE_DIR} + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/include +) +set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "vpp") + +set(THREADS_PREFER_PTHREAD_FLAG ON) +find_package(Threads REQUIRED) +find_package(OpenSSL REQUIRED) +include_directories(${OPENSSL_INCLUDE_DIR}) + +add_definitions(-DHAVE_MEMFD_CREATE -DVPP_API_TEST_BUILTIN=1) + +############################################################################## +# API +############################################################################## +function(vpp_generate_api_header file) + set (output_name ${CMAKE_CURRENT_BINARY_DIR}/${file}.h) + get_filename_component(output_dir ${output_name} DIRECTORY) + add_custom_command (OUTPUT ${output_name} + COMMAND mkdir -p ${output_dir} + COMMAND ${CMAKE_SOURCE_DIR}/tools/vppapigen/vppapigen + ARGS --includedir ${CMAKE_SOURCE_DIR} --input ${CMAKE_CURRENT_SOURCE_DIR}/${file} --output ${output_name} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file} + COMMENT "Generating API header ${file}.h" + ) +endfunction() + +function(vpp_add_api_files target) + unset(header_files) + foreach(file ${ARGN}) + vpp_generate_api_header (${file}) + list (APPEND header_files ${file}.h) + endforeach() + add_custom_target(${target} DEPENDS ${header_files}) +endfunction() + +add_custom_target(api_headers + DEPENDS vlibmemory_api_headers vnet_api_headers vpp_api_headers +) + +############################################################################## +# header files +############################################################################## +function (vpp_add_header_files path) + foreach(file ${ARGN}) + get_filename_component(dir ${file} DIRECTORY) + install(FILES ${file} DESTINATION include/${path}/${dir}) + endforeach() +endfunction() + +############################################################################## +# subdirs +############################################################################## +foreach (DIR vppinfra svm vlib vlibmemory vnet vpp vcl plugins) + add_subdirectory(${DIR}) +endforeach () + +############################################################################## +# DEB Packaging +############################################################################## +set(CPACK_GENERATOR "DEB") +set(CPACK_DEBIAN_PACKAGE_MAINTAINER "VPP Team") +set(CPACK_PACKAGE_NAME "vpp") +set(CPACK_PACKAGE_VENDOR "fd.io") +set(CPACK_PACKAGE_VERSION "18.08") +set(CPACK_DEB_COMPONENT_INSTALL ON) +set(CPACK_COMPONENTS_IGNORE_GROUPS 1) +set(CPACK_DEBIAN_VPP_PACKAGE_NAME "vpp") +set(CPACK_DEBIAN_VPP_FILE_NAME "vpp.deb") +set(CPACK_DEBIAN_DEV_PACKAGE_NAME "vpp-dev") +set(CPACK_DEBIAN_DEV_FILE_NAME "vpp-dev.deb") +set(CPACK_DEBIAN_PLUGINS_PACKAGE_NAME "vpp-plugins") +set(CPACK_DEBIAN_PLUGINS_FILE_NAME "vpp-plugins.deb") +include(CPack) diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt new file mode 100644 index 00000000000..34d956d4f77 --- /dev/null +++ b/src/plugins/CMakeLists.txt @@ -0,0 +1,63 @@ +# Copyright (c) 2018 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. + +include_directories ( + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} +) + +macro(add_vpp_plugin plugin_name) + set(api_headers) + foreach(f ${ARGN}) + if(${f} MATCHES ".*\.api$") + vpp_generate_api_header(${f}) + list(APPEND api_headers ${f}.h) + endif() + endforeach() + add_library(${plugin_name} SHARED ${ARGN} ${api_headers}) + add_dependencies(${plugin_name} vpp_version_h api_headers) + set_target_properties(${plugin_name} PROPERTIES + PREFIX "" + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/vpp_plugins) + install(TARGETS ${plugin_name} DESTINATION lib/vpp_plugins COMPONENT plugins) +endmacro() + +macro(add_vpp_api_test_plugin plugin_name) + set(api_headers) + foreach(f ${ARGN}) + if(${f} MATCHES ".*\.api$") + vpp_generate_api_header(${f}) + list(APPEND api_headers ${f}.h) + endif() + endforeach() + add_library(${plugin_name} SHARED ${ARGN} ${api_headers}) + add_dependencies(${plugin_name} api_headers) + set_target_properties(${plugin_name} PROPERTIES PREFIX "") + set_target_properties(${plugin_name} PROPERTIES + PREFIX "" + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}//vpp_api_test_plugins) + install(TARGETS ${plugin_name} DESTINATION lib/vpp_api_test_plugins COMPONENT + plugins) +endmacro() + +############################################################################## +# find and add all plugin subdirs +############################################################################ +FILE(GLOB files RELATIVE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*/CMakeLists.txt +) +foreach (f ${files}) + get_filename_component(dir ${f} DIRECTORY) + add_subdirectory(${dir}) +endforeach() diff --git a/src/plugins/abf/CMakeLists.txt b/src/plugins/abf/CMakeLists.txt new file mode 100644 index 00000000000..2bb90e272ee --- /dev/null +++ b/src/plugins/abf/CMakeLists.txt @@ -0,0 +1,19 @@ +# Copyright (c) 2018 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. + +add_vpp_plugin(abf_plugin + abf.api + abf_api.c + abf_itf_attach.c + abf_policy.c +) diff --git a/src/plugins/acl/CMakeLists.txt b/src/plugins/acl/CMakeLists.txt new file mode 100644 index 00000000000..2040522affd --- /dev/null +++ b/src/plugins/acl/CMakeLists.txt @@ -0,0 +1,21 @@ +# Copyright (c) 2018 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. + +add_vpp_plugin(acl_plugin + acl.api + acl.c + hash_lookup.c + lookup_context.c + sess_mgmt_node.c + dataplane_node.c +) diff --git a/src/plugins/avf/CMakeLists.txt b/src/plugins/avf/CMakeLists.txt new file mode 100644 index 00000000000..8f8798bc8ed --- /dev/null +++ b/src/plugins/avf/CMakeLists.txt @@ -0,0 +1,28 @@ +# Copyright (c) 2018 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. + +add_vpp_plugin(avf_plugin + cli.c + device.c + format.c + input.c + output.c + plugin.c + avf_api.c + avf.api +) + +vpp_library_set_multiarch_sources(avf_plugin + input.c + output.c +) diff --git a/src/plugins/cdp/CMakeLists.txt b/src/plugins/cdp/CMakeLists.txt new file mode 100644 index 00000000000..036833f5315 --- /dev/null +++ b/src/plugins/cdp/CMakeLists.txt @@ -0,0 +1,26 @@ +# Copyright (c) 2018 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. + +add_vpp_plugin(cdp_plugin + cdp.api + cdp.c + cdp_input.c + cdp_node.c + cdp_periodic.c +) + +add_vpp_api_test_plugin(cdp_test_plugin + cdp.api + cdp_test.c +) + diff --git a/src/plugins/dpdk/CMakeLists.txt b/src/plugins/dpdk/CMakeLists.txt new file mode 100644 index 00000000000..e1494492628 --- /dev/null +++ b/src/plugins/dpdk/CMakeLists.txt @@ -0,0 +1,100 @@ +# Copyright (c) 2016 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. + +############################################################################## +# Find lib and include files +############################################################################## +find_path(DPDK_INCLUDE_DIR PATH_SUFFIXES dpdk NAMES rte_config.h HINTS + ${DPDK_INCLUDE_DIR_HINT}) +find_library(DPDK_LIB NAMES libdpdk.a HINTS ${DPDK_LIB_DIR_HINT}) + +############################################################################## +# Find DPDK Version +############################################################################## +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dpdk_version.c +" +#include +#include +int main() +{ + puts(strchr(rte_version(), ' ') + 1); + return 0; +} +") + +try_compile(DPDK_VERSION_COMPILED + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/dpdk_version.c + CMAKE_FLAGS + -DINCLUDE_DIRECTORIES=${DPDK_INCLUDE_DIR} + COPY_FILE ${CMAKE_CURRENT_BINARY_DIR}/dpdk_version.bin +) + +if(DPDK_VERSION_COMPILED) + execute_process( + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ./dpdk_version.bin + OUTPUT_VARIABLE DPDK_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE + ) +endif() + +file(REMOVE + ${CMAKE_CURRENT_BINARY_DIR}/dpdk_version.c + ${CMAKE_CURRENT_BINARY_DIR}/dpdk_version.bin +) + + +############################################################################## +# DPDK plugin +############################################################################## +if(DPDK_INCLUDE_DIR AND DPDK_LIB) + include_directories (${DPDK_INCLUDE_DIR}) + add_vpp_plugin(dpdk_plugin + buffer.c + main.c + thread.c + api/dpdk_api.c + api/dpdk_test.c + device/cli.c + device/common.c + device/device.c + device/flow.c + device/format.c + device/init.c + device/node.c + hqos/hqos.c + ipsec/cli.c + ipsec/crypto_node.c + ipsec/esp_decrypt.c + ipsec/esp_encrypt.c + ipsec/ipsec.c + api/dpdk.api + ) + + vpp_library_set_multiarch_sources(dpdk_plugin + buffer.c + device/device.c + device/node.c + ) + + get_filename_component(DPDK_LIB_DIR ${DPDK_LIB} DIRECTORY) + set(DPDK_LINK_FLAGS "-L${DPDK_LIB_DIR} -Wl,--whole-archive,${DPDK_LIB},--no-whole-archive") + set(DPDK_LINK_FLAGS "${DPDK_LINK_FLAGS} -Wl,--exclude-libs,libIPSec_MB.a,-l:libIPSec_MB.a") + set(DPDK_LINK_FLAGS "${DPDK_LINK_FLAGS} -Wl,-lnuma") + set_target_properties(dpdk_plugin PROPERTIES LINK_FLAGS "${DPDK_LINK_FLAGS}") + message("-- Found DPDK ${DPDK_VERSION}: ${DPDK_INCLUDE_DIR} ${DPDK_LIB}") +else() + message("-- DPDK not found - dpdk_plugin disabled") +endif() + diff --git a/src/plugins/examples/gen-rules.py b/src/plugins/examples/gen-rules.py deleted file mode 100755 index 7964aa9a359..00000000000 --- a/src/plugins/examples/gen-rules.py +++ /dev/null @@ -1,186 +0,0 @@ -#!/usr/bin/env python3 - -# Copyright (c) 2015 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. - -import ipaddress -import argparse -import sys - -# map add domain ip4-pfx ip6-pfx ::/0 ip6-src ea-bits-len 0 psid-offset 6 psid-len 6 -# map add rule index <0> psid ip6-dst - -def_ip4_pfx = '192.0.2.0/24' -def_ip6_pfx = '2001:db8::/32' -def_ip6_src = '2001:db8::1' -def_psid_offset = 6 -def_psid_len = 6 -def_ea_bits_len = 0 - -parser = argparse.ArgumentParser(description='MAP VPP configuration generator') -parser.add_argument('-t', action="store", dest="mapmode") -parser.add_argument('-f', action="store", dest="format", default="vpp") -parser.add_argument('--ip4-prefix', action="store", dest="ip4_pfx", default=def_ip4_pfx) -parser.add_argument('--ip6-prefix', action="store", dest="ip6_pfx", default=def_ip6_pfx) -parser.add_argument('--ip6-src', action="store", dest="ip6_src", default=def_ip6_src) -parser.add_argument('--psid-len', action="store", dest="psid_len", default=def_psid_len) -parser.add_argument('--psid-offset', action="store", dest="psid_offset", default=def_psid_offset) -parser.add_argument('--ea-bits-len', action="store", dest="ea_bits_len", default=def_ea_bits_len) -args = parser.parse_args() - -# -# Print domain -# -def domain_print(i, ip4_pfx, ip6_pfx, ip6_src, eabits_len, psid_offset, psid_len): - if format == 'vpp': - print("map add domain ip4-pfx " + ip4_pfx + " ip6-pfx", ip6_pfx, "ip6-src " + ip6_src + - " ea-bits-len", eabits_len, "psid-offset", psid_offset, "psid-len", psid_len) - if format == 'confd': - print("vpp softwire softwire-instances softwire-instance", i, "br-ipv6 " + ip6_src + - " ipv6-prefix " + ip6_pfx + " ipv4-prefix " + ip4_pfx + - " ea-bits-len", eabits_len, "psid-offset", psid_offset, "psid-len", psid_len) - if format == 'xml': - print("") - print("", i, ""); - print(" " + ip6_src + "") - print(" " + ip6_pfx + "") - print(" " + ip4_pfx + "") - print(" ", eabits_len, "") - print(" ", psid_len, "") - print(" ", psid_offset, "") - -def domain_print_end(): - if format == 'xml': - print("") - -def rule_print(i, psid, dst): - if format == 'vpp': - print("map add rule index", i, "psid", psid, "ip6-dst", dst) - if format == 'confd': - print("binding", psid, "ipv6-addr", dst) - if format == 'xml': - print(" ") - print(" ", psid, "") - print(" ", dst, "") - print(" ") - -# -# Algorithmic mapping Shared IPv4 address -# -def algo(ip4_pfx_str, ip6_pfx_str, ip6_src_str, ea_bits_len, psid_offset, psid_len, ip6_src_ecmp = False): - domain_print(0, ip4_pfx_str, ip6_pfx_str, ip6_src_str, ea_bits_len, psid_offset, psid_len) - domain_print_end() - -# -# 1:1 Full IPv4 address -# -def lw46(ip4_pfx_str, ip6_pfx_str, ip6_src_str, ea_bits_len, psid_offset, psid_len, ip6_src_ecmp = False): - ip4_pfx = ipaddress.ip_network(ip4_pfx_str) - ip6_src = ipaddress.ip_address(ip6_src_str) - ip6_dst = ipaddress.ip_network(ip6_pfx_str) - psid_len = 0 - mod = ip4_pfx.num_addresses / 1024 - - for i in range(ip4_pfx.num_addresses): - domain_print(i, str(ip4_pfx[i]) + "/32", str(ip6_dst[i]) + "/128", str(ip6_src), 0, 0, 0) - domain_print_end() - if ip6_src_ecmp and not i % mod: - ip6_src = ip6_src + 1 - -# -# 1:1 Shared IPv4 address, shared BR (16) VPP CLI -# -def lw46_shared(ip4_pfx_str, ip6_pfx_str, ip6_src_str, ea_bits_len, psid_offset, psid_len, ip6_src_ecmp = False): - ip4_pfx = ipaddress.ip_network(ip4_pfx_str) - ip6_src = ipaddress.ip_address(ip6_src_str) - ip6_dst = ipaddress.ip_network(ip6_pfx_str) - mod = ip4_pfx.num_addresses / 1024 - - for i in range(ip4_pfx.num_addresses): - domain_print(i, str(ip4_pfx[i]) + "/32", "::/0", str(ip6_src), 0, 0, psid_len) - for psid in range(0x1 << int(psid_len)): - rule_print(i, psid, str(ip6_dst[(i * (0x1< - - - urn:ietf:params:netconf:base:1.0 - - -]]>]]> - - - - - - - - - - - - - - ''') - -def xml_footer_print(): - print(''' - - - - - - - -]]>]]> - - - - - - -]]>]]> - ''') - - -format = args.format -if format == 'xml': - xml_header_print() -globals()[args.mapmode](args.ip4_pfx, args.ip6_pfx, args.ip6_src, args.ea_bits_len, args.psid_offset, args.psid_len) -if format == 'xml': - xml_footer_print() diff --git a/src/plugins/examples/health_check.c b/src/plugins/examples/health_check.c deleted file mode 100644 index 5f0d85fec08..00000000000 --- a/src/plugins/examples/health_check.c +++ /dev/null @@ -1,109 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static void -usage (void) { - fprintf(stderr, - "Usage: health_check" - " -d debug" - " -I interface" - "\n"); - exit(2); -} - -int -main (int argc, char **argv) -{ - int sd, ch; - uint8_t *opt, *pkt; - struct ifreq ifr; - char *interface = NULL; - bool debug = false; - - while ((ch = getopt(argc, argv, "h?" "I:" "d")) != EOF) { - switch(ch) { - case 'I': - interface = optarg; - break; - case 'd': - debug = true; - break; - default: - usage(); - break; - } - } - - argc -= optind; - argv += optind; - - if (!interface) - usage(); - - /* Request a socket descriptor sd. */ - if ((sd = socket (AF_INET6, SOCK_RAW, IPPROTO_IPIP)) < 0) { - perror ("Failed to get socket descriptor "); - exit (EXIT_FAILURE); - } - - memset(&ifr, 0, sizeof(ifr)); - snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s", interface); - - /* Bind socket to interface of this node. */ - if (setsockopt (sd, SOL_SOCKET, SO_BINDTODEVICE, (void *) &ifr, sizeof (ifr)) < 0) { - perror ("SO_BINDTODEVICE failed"); - exit (EXIT_FAILURE); - } - if (debug) printf("Binding to interface %s\n", interface); - - while (1) { - struct sockaddr_in6 src_addr; - socklen_t addrlen = sizeof(src_addr); - char source[INET6_ADDRSTRLEN+1]; - int len; - uint8_t inpack[IP_MAXPACKET]; - - if ((len = recvfrom(sd, inpack, sizeof(inpack), 0, (struct sockaddr *)&src_addr, &addrlen)) < 0) { - perror("recvfrom failed "); - } - if (inet_ntop(AF_INET6, &src_addr.sin6_addr, source, INET6_ADDRSTRLEN) == NULL) { - perror("inet_ntop() failed."); - exit(EXIT_FAILURE); - } - - /* Reply */ - struct iphdr *ip = (struct iphdr *)inpack; - uint32_t saddr; - struct icmphdr *icmp; - - saddr = ip->saddr; - ip->saddr = ip->daddr; - ip->daddr = saddr; - - switch (ip->protocol) { - case 1: - if (debug) printf ("ICMP Echo request from %s\n", source); - icmp = (struct icmphdr *)&ip[1]; - icmp->type = ICMP_ECHOREPLY; - break; - default: - fprintf(stderr, "Unsupported protocol %d", ip->protocol); - } - if (len = sendto(sd, inpack, len, 0, (struct sockaddr *)&src_addr, addrlen) < 0) { - perror("sendto failed "); - } - } - - close (sd); - - return (EXIT_SUCCESS); -} diff --git a/src/plugins/examples/test_map.py b/src/plugins/examples/test_map.py deleted file mode 100755 index 21388d49526..00000000000 --- a/src/plugins/examples/test_map.py +++ /dev/null @@ -1,141 +0,0 @@ -#!/usr/bin/env python - -import time,argparse,sys,cmd, unittest -from ipaddress import * - -parser = argparse.ArgumentParser(description='VPP MAP test') -parser.add_argument('-i', nargs='*', action="store", dest="inputdir") -args = parser.parse_args() - -for dir in args.inputdir: - sys.path.append(dir) -from vpp_papi import * - -# -# 1:1 Shared IPv4 address, shared BR (16) VPP CLI -# -def lw46_shared(ip4_pfx_str, ip6_pfx_str, ip6_src_str, ea_bits_len, psid_offset, psid_len, ip6_src_ecmp = False): - ip4_pfx = ip_network(ip4_pfx_str) - ip6_src = ip_address(ip6_src_str) - ip6_dst = ip_network(ip6_pfx_str) - ip6_nul = IPv6Address(u'0::0') - mod = ip4_pfx.num_addresses / 1024 - - for i in range(ip4_pfx.num_addresses): - a = time.clock() - t = map_add_domain(0, ip6_nul.packed, ip4_pfx[i].packed, ip6_src.packed, 0, 32, 128, ea_bits_len, psid_offset, psid_len, 0, 0) - #print "Return from map_add_domain", t - if t == None: - print "map_add_domain failed" - continue - if t.retval != 0: - print "map_add_domain failed", t - continue - for psid in range(0x1 << int(psid_len)): - r = map_add_del_rule(0, t.index, 1, (ip6_dst[(i * (0x1<H', msg[0:2]) - size = unpack('>H', msg[2:4]) - print "Received", id, "of size", size - i += 1 - #del msg - continue - - #time.sleep(0.001) - return - -# Create RX thread -rxthread = RXThread() -rxthread.setDaemon(True) - -print "Connect", connect_to_vpe("client124") -import timeit -rxthread.start() -print "After thread started" - -#pneum_kill_thread() -print "After thread killed" - -#t = show_version(0) -#print "Result from show version", t - -print timeit.timeit('t = show_version(0)', number=1000, setup="from __main__ import show_version") -time.sleep(10) -#print timeit.timeit('control_ping(0)', number=10, setup="from __main__ import control_ping") - - -disconnect_from_vpe() -sys.exit() - - -print t.program, t.version,t.builddate,t.builddirectory - -''' - -t = map_domain_dump(0) -if not t: - print('show map domain failed') - -for d in t: - print("IP6 prefix:",str(IPv6Address(d.ip6prefix))) - print( "IP4 prefix:",str(IPv4Address(d.ip4prefix))) -''' - -suite = unittest.TestLoader().loadTestsFromTestCase(TestMAP) -unittest.TextTestRunner(verbosity=2).run(suite) - -disconnect_from_vpe() - - diff --git a/src/plugins/flowprobe/CMakeLists.txt b/src/plugins/flowprobe/CMakeLists.txt new file mode 100644 index 00000000000..df803a8d668 --- /dev/null +++ b/src/plugins/flowprobe/CMakeLists.txt @@ -0,0 +1,24 @@ +# Copyright (c) 2018 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. + +add_vpp_plugin(flowprobe_plugin + flowprobe.api + flowprobe.c + node.c +) + +add_vpp_api_test_plugin(flowprobe_test_plugin + flowprobe.api + flowprobe_test.c +) + diff --git a/src/plugins/gbp/CMakeLists.txt b/src/plugins/gbp/CMakeLists.txt new file mode 100644 index 00000000000..a9e9bd62692 --- /dev/null +++ b/src/plugins/gbp/CMakeLists.txt @@ -0,0 +1,27 @@ +# Copyright (c) 2018 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. + +add_vpp_plugin(gbp_plugin + gbp.api + gbp_subnet.c + gbp_contract.c + gbp_endpoint.c + gbp_endpoint_group.c + gbp_classify.c + gbp_recirc.c + gbp_policy.c + gbp_policy_dpo.c + gbp_fwd.c + gbp_fwd_dpo.c + gbp_api.c +) diff --git a/src/plugins/gtpu/CMakeLists.txt b/src/plugins/gtpu/CMakeLists.txt new file mode 100644 index 00000000000..1633d43cc31 --- /dev/null +++ b/src/plugins/gtpu/CMakeLists.txt @@ -0,0 +1,26 @@ +# Copyright (c) 2018 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. + +add_vpp_plugin(gtpu_plugin + gtpu.api + gtpu.c + gtpu_api.c + gtpu_decap.c + gtpu_encap.c +) + +add_vpp_api_test_plugin(gtpu_test_plugin + gtpu.api + gtpu_test.c +) + diff --git a/src/plugins/igmp/CMakeLists.txt b/src/plugins/igmp/CMakeLists.txt new file mode 100644 index 00000000000..a3f976cbc57 --- /dev/null +++ b/src/plugins/igmp/CMakeLists.txt @@ -0,0 +1,29 @@ +# Copyright (c) 2018 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. + +add_vpp_plugin(igmp_plugin + igmp.api + igmp.c + igmp_query.c + igmp_report.c + igmp_group.c + igmp_src.c + igmp_config.c + igmp_cli.c + igmp_api.c + igmp_input.c + igmp_timer.c + igmp_pkt.c + igmp_ssm_range.c + igmp_format.c +) diff --git a/src/plugins/ila/CMakeLists.txt b/src/plugins/ila/CMakeLists.txt new file mode 100644 index 00000000000..2aa1892cf47 --- /dev/null +++ b/src/plugins/ila/CMakeLists.txt @@ -0,0 +1,15 @@ +# Copyright (c) 2018 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. + +add_vpp_plugin(ila_plugin ila.c) + diff --git a/src/plugins/ioam/CMakeLists.txt b/src/plugins/ioam/CMakeLists.txt new file mode 100644 index 00000000000..ed8bd196aba --- /dev/null +++ b/src/plugins/ioam/CMakeLists.txt @@ -0,0 +1,99 @@ +# Copyright (c) 2018 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. + +add_vpp_plugin(ioam_plugin + # iOAM Proof of Transit + lib-pot/pot.api + lib-pot/pot_util.c + encap/ip6_ioam_pot.c + lib-pot/pot_api.c + + # iOAM trace export for IPv6 + export/ioam_export.api + export/ioam_export.c + export/node.c + export/ioam_export_thread.c + + # iOAM Trace + lib-trace/trace.api + lib-trace/trace_util.c + encap/ip6_ioam_trace.c + lib-trace/trace_api.c + + # VxLAN-GPE + lib-vxlan-gpe/ioam_vxlan_gpe.api + lib-vxlan-gpe/ioam_encap.c + lib-vxlan-gpe/ioam_decap.c + lib-vxlan-gpe/ioam_transit.c + lib-vxlan-gpe/ioam_pop.c + lib-vxlan-gpe/vxlan_gpe_api.c + lib-vxlan-gpe/vxlan_gpe_ioam_trace.c + lib-vxlan-gpe/vxlan_gpe_ioam.c + export-vxlan-gpe/vxlan_gpe_ioam_export.api + export-vxlan-gpe/vxlan_gpe_ioam_export.c + export-vxlan-gpe/vxlan_gpe_node.c + export-vxlan-gpe/vxlan_gpe_ioam_export_thread.c + + # iOAM E2E + encap/ip6_ioam_e2e.c + encap/ip6_ioam_seqno.c + lib-e2e/ioam_seqno_lib.c + + # ipfix collector + ipfixcollector/ipfixcollector.c + ipfixcollector/node.c + + # iOAM Analyse + analyse/ip6/ip6_ioam_analyse.c + analyse/ip6/node.c + analyse/ioam_summary_export.c + + # iOAM record cache and rewrite + ip6/ioam_cache.api + ip6/ioam_cache.c + ip6/ioam_cache_node.c + ip6/ioam_cache_tunnel_select_node.c + + # udp ping + udp-ping/udp_ping.api + udp-ping/udp_ping_node.c + udp-ping/udp_ping_util.c + udp-ping/udp_ping_export.c + udp-ping/udp_ping_api.c +) + +add_vpp_api_test_plugin(ioam_pot_test_plugin + lib-pot/pot.api + lib-pot/pot_test.c +) + +add_vpp_api_test_plugin(ioam_export_test_plugin + export/ioam_export.api + export/ioam_export_test.c +) + +add_vpp_api_test_plugin(ioam_trace_test_plugin + lib-trace/trace.api + lib-trace/trace_test.c +) + +add_vpp_api_test_plugin(ioam_vxlan_gpe_test_plugin + lib-vxlan-gpe/ioam_vxlan_gpe.api + lib-vxlan-gpe/vxlan_gpe_test.c +) + +add_vpp_api_test_plugin(ioam_udp_ping_test_plugin + udp-ping/udp_ping.api + udp-ping/udp_ping_test.c +) + diff --git a/src/plugins/ixge/CMakeLists.txt b/src/plugins/ixge/CMakeLists.txt new file mode 100644 index 00000000000..bd3454d3de8 --- /dev/null +++ b/src/plugins/ixge/CMakeLists.txt @@ -0,0 +1,16 @@ +# Copyright (c) 2018 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. + +add_vpp_plugin(ixge_plugin + ixge.c +) diff --git a/src/plugins/l2e/CMakeLists.txt b/src/plugins/l2e/CMakeLists.txt new file mode 100644 index 00000000000..ba9cc6a5cbd --- /dev/null +++ b/src/plugins/l2e/CMakeLists.txt @@ -0,0 +1,18 @@ +# Copyright (c) 2018 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. + +add_vpp_plugin(l2e_plugin + l2e.api + l2e_api.c + l2e.c +) diff --git a/src/plugins/lacp/CMakeLists.txt b/src/plugins/lacp/CMakeLists.txt new file mode 100644 index 00000000000..0bd79e9800a --- /dev/null +++ b/src/plugins/lacp/CMakeLists.txt @@ -0,0 +1,32 @@ +# Copyright (c) 2018 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. + +add_vpp_plugin(lacp_plugin + lacp.api + lacp.c + lacp_api.c + selection.c + rx_machine.c + tx_machine.c + mux_machine.c + ptx_machine.c + cli.c + input.c + node.c +) + +add_vpp_api_test_plugin(lacp_test_plugin + lacp.api + lacp_test.c +) + diff --git a/src/plugins/lb/CMakeLists.txt b/src/plugins/lb/CMakeLists.txt new file mode 100644 index 00000000000..4df9dae4a08 --- /dev/null +++ b/src/plugins/lb/CMakeLists.txt @@ -0,0 +1,27 @@ +# Copyright (c) 2018 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. + +add_vpp_plugin(lb_plugin + lb.api + api.c + cli.c + lb.c + node.c + util.c +) + +add_vpp_api_test_plugin(lb_test_plugin + lb.api + lb_test.c +) + diff --git a/src/plugins/mactime/CMakeLists.txt b/src/plugins/mactime/CMakeLists.txt new file mode 100644 index 00000000000..5f82f4c0fb9 --- /dev/null +++ b/src/plugins/mactime/CMakeLists.txt @@ -0,0 +1,24 @@ +# Copyright (c) 2018 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. + +add_vpp_plugin(mactime_plugin + mactime.api + mactime.c + node.c +) + +add_vpp_api_test_plugin(mactime_test_plugin + mactime.api + mactime_test.c +) + diff --git a/src/plugins/map/CMakeLists.txt b/src/plugins/map/CMakeLists.txt new file mode 100644 index 00000000000..1dc1bedb51c --- /dev/null +++ b/src/plugins/map/CMakeLists.txt @@ -0,0 +1,23 @@ +# Copyright (c) 2018 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. + +add_vpp_plugin(map_plugin + map.api + ip4_map.c + ip4_map_t.c + ip6_map.c + ip6_map_t.c + map_api.c + map.c + map_dpo.c +) diff --git a/src/plugins/map/examples/gen-rules.py b/src/plugins/map/examples/gen-rules.py new file mode 100755 index 00000000000..7964aa9a359 --- /dev/null +++ b/src/plugins/map/examples/gen-rules.py @@ -0,0 +1,186 @@ +#!/usr/bin/env python3 + +# Copyright (c) 2015 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. + +import ipaddress +import argparse +import sys + +# map add domain ip4-pfx ip6-pfx ::/0 ip6-src ea-bits-len 0 psid-offset 6 psid-len 6 +# map add rule index <0> psid ip6-dst + +def_ip4_pfx = '192.0.2.0/24' +def_ip6_pfx = '2001:db8::/32' +def_ip6_src = '2001:db8::1' +def_psid_offset = 6 +def_psid_len = 6 +def_ea_bits_len = 0 + +parser = argparse.ArgumentParser(description='MAP VPP configuration generator') +parser.add_argument('-t', action="store", dest="mapmode") +parser.add_argument('-f', action="store", dest="format", default="vpp") +parser.add_argument('--ip4-prefix', action="store", dest="ip4_pfx", default=def_ip4_pfx) +parser.add_argument('--ip6-prefix', action="store", dest="ip6_pfx", default=def_ip6_pfx) +parser.add_argument('--ip6-src', action="store", dest="ip6_src", default=def_ip6_src) +parser.add_argument('--psid-len', action="store", dest="psid_len", default=def_psid_len) +parser.add_argument('--psid-offset', action="store", dest="psid_offset", default=def_psid_offset) +parser.add_argument('--ea-bits-len', action="store", dest="ea_bits_len", default=def_ea_bits_len) +args = parser.parse_args() + +# +# Print domain +# +def domain_print(i, ip4_pfx, ip6_pfx, ip6_src, eabits_len, psid_offset, psid_len): + if format == 'vpp': + print("map add domain ip4-pfx " + ip4_pfx + " ip6-pfx", ip6_pfx, "ip6-src " + ip6_src + + " ea-bits-len", eabits_len, "psid-offset", psid_offset, "psid-len", psid_len) + if format == 'confd': + print("vpp softwire softwire-instances softwire-instance", i, "br-ipv6 " + ip6_src + + " ipv6-prefix " + ip6_pfx + " ipv4-prefix " + ip4_pfx + + " ea-bits-len", eabits_len, "psid-offset", psid_offset, "psid-len", psid_len) + if format == 'xml': + print("") + print("", i, ""); + print(" " + ip6_src + "") + print(" " + ip6_pfx + "") + print(" " + ip4_pfx + "") + print(" ", eabits_len, "") + print(" ", psid_len, "") + print(" ", psid_offset, "") + +def domain_print_end(): + if format == 'xml': + print("") + +def rule_print(i, psid, dst): + if format == 'vpp': + print("map add rule index", i, "psid", psid, "ip6-dst", dst) + if format == 'confd': + print("binding", psid, "ipv6-addr", dst) + if format == 'xml': + print(" ") + print(" ", psid, "") + print(" ", dst, "") + print(" ") + +# +# Algorithmic mapping Shared IPv4 address +# +def algo(ip4_pfx_str, ip6_pfx_str, ip6_src_str, ea_bits_len, psid_offset, psid_len, ip6_src_ecmp = False): + domain_print(0, ip4_pfx_str, ip6_pfx_str, ip6_src_str, ea_bits_len, psid_offset, psid_len) + domain_print_end() + +# +# 1:1 Full IPv4 address +# +def lw46(ip4_pfx_str, ip6_pfx_str, ip6_src_str, ea_bits_len, psid_offset, psid_len, ip6_src_ecmp = False): + ip4_pfx = ipaddress.ip_network(ip4_pfx_str) + ip6_src = ipaddress.ip_address(ip6_src_str) + ip6_dst = ipaddress.ip_network(ip6_pfx_str) + psid_len = 0 + mod = ip4_pfx.num_addresses / 1024 + + for i in range(ip4_pfx.num_addresses): + domain_print(i, str(ip4_pfx[i]) + "/32", str(ip6_dst[i]) + "/128", str(ip6_src), 0, 0, 0) + domain_print_end() + if ip6_src_ecmp and not i % mod: + ip6_src = ip6_src + 1 + +# +# 1:1 Shared IPv4 address, shared BR (16) VPP CLI +# +def lw46_shared(ip4_pfx_str, ip6_pfx_str, ip6_src_str, ea_bits_len, psid_offset, psid_len, ip6_src_ecmp = False): + ip4_pfx = ipaddress.ip_network(ip4_pfx_str) + ip6_src = ipaddress.ip_address(ip6_src_str) + ip6_dst = ipaddress.ip_network(ip6_pfx_str) + mod = ip4_pfx.num_addresses / 1024 + + for i in range(ip4_pfx.num_addresses): + domain_print(i, str(ip4_pfx[i]) + "/32", "::/0", str(ip6_src), 0, 0, psid_len) + for psid in range(0x1 << int(psid_len)): + rule_print(i, psid, str(ip6_dst[(i * (0x1< + + + urn:ietf:params:netconf:base:1.0 + + +]]>]]> + + + + + + + + + + + + + + ''') + +def xml_footer_print(): + print(''' + + + + + + + +]]>]]> + + + + + + +]]>]]> + ''') + + +format = args.format +if format == 'xml': + xml_header_print() +globals()[args.mapmode](args.ip4_pfx, args.ip6_pfx, args.ip6_src, args.ea_bits_len, args.psid_offset, args.psid_len) +if format == 'xml': + xml_footer_print() diff --git a/src/plugins/map/examples/health_check.c b/src/plugins/map/examples/health_check.c new file mode 100644 index 00000000000..5f0d85fec08 --- /dev/null +++ b/src/plugins/map/examples/health_check.c @@ -0,0 +1,109 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static void +usage (void) { + fprintf(stderr, + "Usage: health_check" + " -d debug" + " -I interface" + "\n"); + exit(2); +} + +int +main (int argc, char **argv) +{ + int sd, ch; + uint8_t *opt, *pkt; + struct ifreq ifr; + char *interface = NULL; + bool debug = false; + + while ((ch = getopt(argc, argv, "h?" "I:" "d")) != EOF) { + switch(ch) { + case 'I': + interface = optarg; + break; + case 'd': + debug = true; + break; + default: + usage(); + break; + } + } + + argc -= optind; + argv += optind; + + if (!interface) + usage(); + + /* Request a socket descriptor sd. */ + if ((sd = socket (AF_INET6, SOCK_RAW, IPPROTO_IPIP)) < 0) { + perror ("Failed to get socket descriptor "); + exit (EXIT_FAILURE); + } + + memset(&ifr, 0, sizeof(ifr)); + snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s", interface); + + /* Bind socket to interface of this node. */ + if (setsockopt (sd, SOL_SOCKET, SO_BINDTODEVICE, (void *) &ifr, sizeof (ifr)) < 0) { + perror ("SO_BINDTODEVICE failed"); + exit (EXIT_FAILURE); + } + if (debug) printf("Binding to interface %s\n", interface); + + while (1) { + struct sockaddr_in6 src_addr; + socklen_t addrlen = sizeof(src_addr); + char source[INET6_ADDRSTRLEN+1]; + int len; + uint8_t inpack[IP_MAXPACKET]; + + if ((len = recvfrom(sd, inpack, sizeof(inpack), 0, (struct sockaddr *)&src_addr, &addrlen)) < 0) { + perror("recvfrom failed "); + } + if (inet_ntop(AF_INET6, &src_addr.sin6_addr, source, INET6_ADDRSTRLEN) == NULL) { + perror("inet_ntop() failed."); + exit(EXIT_FAILURE); + } + + /* Reply */ + struct iphdr *ip = (struct iphdr *)inpack; + uint32_t saddr; + struct icmphdr *icmp; + + saddr = ip->saddr; + ip->saddr = ip->daddr; + ip->daddr = saddr; + + switch (ip->protocol) { + case 1: + if (debug) printf ("ICMP Echo request from %s\n", source); + icmp = (struct icmphdr *)&ip[1]; + icmp->type = ICMP_ECHOREPLY; + break; + default: + fprintf(stderr, "Unsupported protocol %d", ip->protocol); + } + if (len = sendto(sd, inpack, len, 0, (struct sockaddr *)&src_addr, addrlen) < 0) { + perror("sendto failed "); + } + } + + close (sd); + + return (EXIT_SUCCESS); +} diff --git a/src/plugins/map/examples/test_map.py b/src/plugins/map/examples/test_map.py new file mode 100755 index 00000000000..21388d49526 --- /dev/null +++ b/src/plugins/map/examples/test_map.py @@ -0,0 +1,141 @@ +#!/usr/bin/env python + +import time,argparse,sys,cmd, unittest +from ipaddress import * + +parser = argparse.ArgumentParser(description='VPP MAP test') +parser.add_argument('-i', nargs='*', action="store", dest="inputdir") +args = parser.parse_args() + +for dir in args.inputdir: + sys.path.append(dir) +from vpp_papi import * + +# +# 1:1 Shared IPv4 address, shared BR (16) VPP CLI +# +def lw46_shared(ip4_pfx_str, ip6_pfx_str, ip6_src_str, ea_bits_len, psid_offset, psid_len, ip6_src_ecmp = False): + ip4_pfx = ip_network(ip4_pfx_str) + ip6_src = ip_address(ip6_src_str) + ip6_dst = ip_network(ip6_pfx_str) + ip6_nul = IPv6Address(u'0::0') + mod = ip4_pfx.num_addresses / 1024 + + for i in range(ip4_pfx.num_addresses): + a = time.clock() + t = map_add_domain(0, ip6_nul.packed, ip4_pfx[i].packed, ip6_src.packed, 0, 32, 128, ea_bits_len, psid_offset, psid_len, 0, 0) + #print "Return from map_add_domain", t + if t == None: + print "map_add_domain failed" + continue + if t.retval != 0: + print "map_add_domain failed", t + continue + for psid in range(0x1 << int(psid_len)): + r = map_add_del_rule(0, t.index, 1, (ip6_dst[(i * (0x1<H', msg[0:2]) + size = unpack('>H', msg[2:4]) + print "Received", id, "of size", size + i += 1 + #del msg + continue + + #time.sleep(0.001) + return + +# Create RX thread +rxthread = RXThread() +rxthread.setDaemon(True) + +print "Connect", connect_to_vpe("client124") +import timeit +rxthread.start() +print "After thread started" + +#pneum_kill_thread() +print "After thread killed" + +#t = show_version(0) +#print "Result from show version", t + +print timeit.timeit('t = show_version(0)', number=1000, setup="from __main__ import show_version") +time.sleep(10) +#print timeit.timeit('control_ping(0)', number=10, setup="from __main__ import control_ping") + + +disconnect_from_vpe() +sys.exit() + + +print t.program, t.version,t.builddate,t.builddirectory + +''' + +t = map_domain_dump(0) +if not t: + print('show map domain failed') + +for d in t: + print("IP6 prefix:",str(IPv6Address(d.ip6prefix))) + print( "IP4 prefix:",str(IPv4Address(d.ip4prefix))) +''' + +suite = unittest.TestLoader().loadTestsFromTestCase(TestMAP) +unittest.TextTestRunner(verbosity=2).run(suite) + +disconnect_from_vpe() + + diff --git a/src/plugins/marvell/CMakeLists.txt b/src/plugins/marvell/CMakeLists.txt new file mode 100644 index 00000000000..283a1aa000d --- /dev/null +++ b/src/plugins/marvell/CMakeLists.txt @@ -0,0 +1,32 @@ +# Copyright (c) 2018 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. + +message("-- Looking for Marvell musdk") +find_path(MUSDK_INCLUDE_DIR NAMES marvell/pp2/pp2.h) +find_library(MUSDK_LIB NAMES musdk) + +if(MUSDK_INCLUDE_DIR AND MUSDK_LIB) + add_vpp_plugin(marvell_plugin + marvell.api + plugin.c + pp2/cli.c + pp2/format.c + pp2/input.c + pp2/output.c + pp2/pp2.c + ) + include_directories(${MUSDK_INCLUDE_DIR}) + message("-- Looking for Marvell musdk - found") +else() + message("-- Looking for Marvell musdk - not found - marvell_plugin disabled") +endif() diff --git a/src/plugins/memif/CMakeLists.txt b/src/plugins/memif/CMakeLists.txt new file mode 100644 index 00000000000..54d0befe29e --- /dev/null +++ b/src/plugins/memif/CMakeLists.txt @@ -0,0 +1,27 @@ +# Copyright (c) 2018 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. + +add_vpp_plugin(memif_plugin + memif.api + memif.c + memif_api.c + cli.c + node.c + device.c + socket.c +) + +vpp_library_set_multiarch_sources(memif_plugin + device.c + node.c +) diff --git a/src/plugins/nat/CMakeLists.txt b/src/plugins/nat/CMakeLists.txt new file mode 100644 index 00000000000..931fa2c7984 --- /dev/null +++ b/src/plugins/nat/CMakeLists.txt @@ -0,0 +1,41 @@ +# Copyright (c) 2018 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. + +add_vpp_plugin(nat_plugin + nat.api + nat.c + nat_api.c + in2out.c + out2in.c + nat_ipfix_logging.c + nat_det.c + nat_reass.c + nat_dpo.c + nat44_cli.c + nat64.c + nat64_cli.c + nat64_in2out.c + nat64_out2in.c + nat64_db.c + dslite_dpo.c + dslite.c + dslite_in2out.c + dslite_out2in.c + dslite_cli.c + dslite_ce_encap.c + dslite_ce_decap.c + nat66.c + nat66_cli.c + nat66_in2out.c + nat66_out2in.c +) diff --git a/src/plugins/pppoe/CMakeLists.txt b/src/plugins/pppoe/CMakeLists.txt new file mode 100644 index 00000000000..fca210211db --- /dev/null +++ b/src/plugins/pppoe/CMakeLists.txt @@ -0,0 +1,27 @@ +# Copyright (c) 2018 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. + +add_vpp_plugin(pppoe_plugin + pppoe.api + pppoe_api.c + pppoe.c + pppoe_cp.c + pppoe_cp_node.c + pppoe_decap.c +) + +add_vpp_api_test_plugin(pppoe_test_plugin + pppoe.api + pppoe_test.c +) + diff --git a/src/plugins/srv6-ad/CMakeLists.txt b/src/plugins/srv6-ad/CMakeLists.txt new file mode 100644 index 00000000000..29959a150b4 --- /dev/null +++ b/src/plugins/srv6-ad/CMakeLists.txt @@ -0,0 +1,17 @@ +# Copyright (c) 2018 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. + +add_vpp_plugin(srv6ad_plugin + ad.c + node.c +) diff --git a/src/plugins/srv6-am/CMakeLists.txt b/src/plugins/srv6-am/CMakeLists.txt new file mode 100644 index 00000000000..995db98b47d --- /dev/null +++ b/src/plugins/srv6-am/CMakeLists.txt @@ -0,0 +1,17 @@ +# Copyright (c) 2018 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. + +add_vpp_plugin(srv6am_plugin + am.c + node.c +) diff --git a/src/plugins/srv6-as/CMakeLists.txt b/src/plugins/srv6-as/CMakeLists.txt new file mode 100644 index 00000000000..42b23f3ecf5 --- /dev/null +++ b/src/plugins/srv6-as/CMakeLists.txt @@ -0,0 +1,17 @@ +# Copyright (c) 2018 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. + +add_vpp_plugin(srv6as_plugin + as.c + node.c +) diff --git a/src/plugins/stn/CMakeLists.txt b/src/plugins/stn/CMakeLists.txt new file mode 100644 index 00000000000..c29cf5f0c5c --- /dev/null +++ b/src/plugins/stn/CMakeLists.txt @@ -0,0 +1,24 @@ +# Copyright (c) 2018 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. + +add_vpp_plugin(stn_plugin + stn.api + stn.c + stn_api.c +) + +add_vpp_api_test_plugin(stn_test_plugin + stn.api + stn_test.c +) + diff --git a/src/plugins/tlsmbedtls/CMakeLists.txt b/src/plugins/tlsmbedtls/CMakeLists.txt new file mode 100644 index 00000000000..af77c248cb3 --- /dev/null +++ b/src/plugins/tlsmbedtls/CMakeLists.txt @@ -0,0 +1,30 @@ +# Copyright (c) 2018 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. + +message("-- Looking for mbedTLS") +find_path(MBEDTLS_INCLUDE_DIR NAMES mbedtls/ssl.h) +find_library(MBEDTLS_LIB1 NAMES mbedtls) +find_library(MBEDTLS_LIB2 NAMES mbedx509) +find_library(MBEDTLS_LIB3 NAMES mbedcrypto) + +set (MBEDTLS_LIB ${MBEDTLS_LIB1} ${MBEDTLS_LIB2} ${MBEDTLS_LIB3}) + +if(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIB) + include_directories(${MBEDTLS_INCLUDE_DIR}) + add_vpp_plugin(tlsmbedtls_plugin tls_mbedtls.c) + target_link_libraries(tlsmbedtls_plugin ${MBEDTLS_LIB}) + message("-- Found mbedTLS: ${MBEDTLS_INCLUDE_DIR} ${MBEDTLS_LIB}") +else() + message("-- mbedTLS not found - tlsmbedtls_plugin disabled") +endif() + diff --git a/src/plugins/tlsopenssl/CMakeLists.txt b/src/plugins/tlsopenssl/CMakeLists.txt new file mode 100644 index 00000000000..7659cc0feaf --- /dev/null +++ b/src/plugins/tlsopenssl/CMakeLists.txt @@ -0,0 +1,18 @@ +# Copyright (c) 2018 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. + +if(OPENSSL_FOUND) + add_vpp_plugin(tlsopenssl_plugin tls_openssl.c tls_async.c) + target_link_libraries(tlsopenssl_plugin ${OPENSSL_LIBRARIES}) +endif() + diff --git a/src/plugins/unittest/CMakeLists.txt b/src/plugins/unittest/CMakeLists.txt new file mode 100644 index 00000000000..eba6e230d16 --- /dev/null +++ b/src/plugins/unittest/CMakeLists.txt @@ -0,0 +1,18 @@ +# Copyright (c) 2018 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. + +add_vpp_plugin(unittest_plugin + unittest.c + tcp_test.c + bihash_test.c +) diff --git a/src/scripts/generate_version_h b/src/scripts/generate_version_h new file mode 100755 index 00000000000..993a682954b --- /dev/null +++ b/src/scripts/generate_version_h @@ -0,0 +1,28 @@ +#!/bin/bash + +cat > ${1} << __EOF__ +/* + * Copyright (c) 2018 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. + */ + +#ifndef included_vpp_app_version_h +#define included_vpp_app_version_h + +#define VPP_BUILD_DATE "$(date)" +#define VPP_BUILD_USER "$(whoami)" +#define VPP_BUILD_HOST "$(hostname)" +#define VPP_BUILD_TOPDIR "$(git rev-parse --show-toplevel)" +#define VPP_BUILD_VER "$(scripts/version)" +#endif +__EOF__ diff --git a/src/svm/CMakeLists.txt b/src/svm/CMakeLists.txt new file mode 100644 index 00000000000..a3cca5a918a --- /dev/null +++ b/src/svm/CMakeLists.txt @@ -0,0 +1,62 @@ +# Copyright (c) 2018 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. + +############################################################################## +# svm shared library +############################################################################## +add_library(svm SHARED + svm.c + ssvm.c + svm_fifo.c + svm_fifo_segment.c + queue.c + message_queue.c +) +target_link_libraries(svm vppinfra rt pthread) +install(TARGETS svm DESTINATION lib) + +############################################################################## +# svmdb shared library +############################################################################## +add_library(svmdb SHARED svmdb.c) +target_link_libraries(svmdb svm vppinfra rt pthread) +install(TARGETS svmdb DESTINATION lib) + +############################################################################## +# svm headers +############################################################################## +vpp_add_header_files(svm + ssvm.h + svm_common.h + svmdb.h + svm_fifo.h + svm_fifo_segment.h + queue.h + message_queue.h + svm.h +) + +############################################################################## +# svm tools +############################################################################## + +add_executable (svmtool svmtool.c) +target_link_libraries (svmtool vppinfra svm) +add_executable (svmdbtool svmdbtool.c) +target_link_libraries (svmdbtool vppinfra svm svmdb) + +install( + TARGETS svmtool svmdbtool + DESTINATION bin +) + diff --git a/src/vcl/CMakeLists.txt b/src/vcl/CMakeLists.txt new file mode 100644 index 00000000000..e25d048d0c5 --- /dev/null +++ b/src/vcl/CMakeLists.txt @@ -0,0 +1,53 @@ +# Copyright (c) 2018 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. + +############################################################################## +# vppcom shared library +############################################################################## +add_library(vppcom SHARED + vppcom.c + vcl_bapi.c + vcl_cfg.c + vcl_event.c + vcl_private.c +) +target_link_libraries(vppcom vppinfra svm vlibmemoryclient rt pthread) +install(TARGETS vppcom DESTINATION lib) + +############################################################################## +# vcl headers +############################################################################## +vpp_add_header_files(vcl + vcl_event.h + vppcom.h +) + +############################################################################## +# vcl tests +############################################################################## +option(VPP_BUILD_VCL_TESTS "Build vcl tests." ON) +if(VPP_BUILD_VCL_TESTS) + set(VCL_TESTS + vcl_test_server + vcl_test_client + sock_test_server + sock_test_client + test_vcl_listener_server + test_vcl_listener_client + ) + foreach(test ${VCL_TESTS}) + add_executable(${test} ${test}.c) + target_link_libraries(${test} vppcom) + endforeach() +endif(VPP_BUILD_VCL_TESTS) + diff --git a/src/vlib/CMakeLists.txt b/src/vlib/CMakeLists.txt new file mode 100644 index 00000000000..dceb13e7ce4 --- /dev/null +++ b/src/vlib/CMakeLists.txt @@ -0,0 +1,98 @@ +# Copyright (c) 2018 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. + +############################################################################## +# Generate vlib/config.h +############################################################################## +set(PRE_DATA_SIZE 128 CACHE STRING "Buffer headroom size.") +configure_file( + ${CMAKE_SOURCE_DIR}/vlib/config.h.in + ${CMAKE_BINARY_DIR}/vlib/config.h +) +install(FILES ${CMAKE_BINARY_DIR}/vlib/config.h DESTINATION include/vlib) + +############################################################################## +# vlib shared library +############################################################################## +set(VLIB_SRCS + buffer.c + buffer_serialize.c + cli.c + counter.c + error.c + format.c + i2c.c + init.c + linux/pci.c + linux/physmem.c + linux/vfio.c + log.c + main.c + mc.c + node.c + node_cli.c + node_format.c + pci/pci.c + threads.c + threads_cli.c + trace.c + unix/cj.c + unix/cli.c + unix/input.c + unix/main.c + unix/mc_socket.c + unix/plugin.c + unix/util.c +) + +add_library(vlib SHARED ${VLIB_SRCS}) +target_link_libraries(vlib vppinfra svm ${CMAKE_DL_LIBS}) +install(TARGETS vlib DESTINATION lib) + +############################################################################## +# vlib headers +############################################################################## +vpp_add_header_files(vlib + buffer_funcs.h + buffer.h + buffer_node.h + cli_funcs.h + cli.h + counter.h + defs.h + error_funcs.h + error.h + format_funcs.h + global_funcs.h + i2c.h + init.h + linux/vfio.h + log.h + main.h + mc.h + node_funcs.h + node.h + pci/pci_config.h + pci/pci.h + physmem_funcs.h + physmem.h + threads.h + trace_funcs.h + trace.h + unix/cj.h + unix/mc_socket.h + unix/plugin.h + unix/unix.h + vlib.h +) + diff --git a/src/vlibmemory/CMakeLists.txt b/src/vlibmemory/CMakeLists.txt new file mode 100644 index 00000000000..3459f03db1b --- /dev/null +++ b/src/vlibmemory/CMakeLists.txt @@ -0,0 +1,41 @@ +# Copyright (c) 2018 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. + +vpp_generate_api_header(memclnt.api) +add_custom_target(vlibmemory_api_headers DEPENDS memclnt.api.h) + +add_library (vlibmemory SHARED + memory_api.c + memory_shared.c + memory_client.c + socket_api.c + vlib_api.c + vlib_api_cli.c + ../vlibapi/api_shared.c + ../vlibapi/node_serialize.c +) +target_link_libraries (vlibmemory vppinfra svm vlib) +add_dependencies(vlibmemory vlibmemory_api_headers) +install (TARGETS vlibmemory DESTINATION lib) + +add_library (vlibmemoryclient SHARED + memory_shared.c + memory_client.c + socket_client.c + ../vlibapi/api_shared.c + ../vlibapi/node_serialize.c +) + +target_link_libraries (vlibmemoryclient vppinfra svm vlib) +add_dependencies(vlibmemoryclient vlibmemory_api_headers) +install (TARGETS vlibmemoryclient DESTINATION lib) diff --git a/src/vnet/CMakeLists.txt b/src/vnet/CMakeLists.txt new file mode 100644 index 00000000000..1ae56183116 --- /dev/null +++ b/src/vnet/CMakeLists.txt @@ -0,0 +1,501 @@ +# Copyright (c) 2018 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. + +add_definitions (-DWITH_LIBSSL=1) +set(VNET_SRCS + adj/adj_bfd.c + adj/adj.c + adj/adj_delegate.c + adj/adj_glean.c + adj/adj_l2.c + adj/adj_mcast.c + adj/adj_midchain.c + adj/adj_nbr.c + adj/adj_nsh.c + adj/rewrite.c + bfd/bfd_api.c + bfd/bfd_cli.c + bfd/bfd_main.c + bfd/bfd_protocol.c + bfd/bfd_udp.c + bier/bier_api.c + bier/bier_bift_table.c + bier/bier_bit_string.c + bier/bier_disp_dispatch_node.c + bier/bier_disp_entry.c + bier/bier_disp_lookup_node.c + bier/bier_disp_table.c + bier/bier_drop.c + bier/bier_entry.c + bier/bier_fmask.c + bier/bier_fmask_db.c + bier/bier_imp.c + bier/bier_imp_node.c + bier/bier_input.c + bier/bier_lookup.c + bier/bier_output.c + bier/bier_table.c + bier/bier_test.c + bier/bier_types.c + bier/bier_update.c + bonding/bond_api.c + bonding/cli.c + bonding/device.c + bonding/node.c + buffer.c + classify/classify_api.c + classify/flow_classify.c + classify/flow_classify_node.c + classify/in_out_acl.c + classify/ip_classify.c + classify/policer_classify.c + classify/vnet_classify.c + config.c + cop/cop_api.c + cop/cop.c + cop/ip4_whitelist.c + cop/ip6_whitelist.c + cop/node1.c + devices/af_packet/af_packet_api.c + devices/af_packet/af_packet.c + devices/af_packet/cli.c + devices/af_packet/device.c + devices/af_packet/node.c + devices/devices.c + devices/netlink.c + devices/netmap/cli.c + devices/netmap/device.c + devices/netmap/netmap_api.c + devices/netmap/netmap.c + devices/netmap/node.c + devices/pipe/pipe_api.c + devices/pipe/pipe.c + devices/tap/cli.c + devices/tap/tap.c + devices/tap/tapv2_api.c + devices/virtio/device.c + devices/virtio/node.c + devices/virtio/vhost_user_api.c + devices/virtio/vhost_user.c + devices/virtio/vhost_user_input.c + devices/virtio/vhost_user_output.c + devices/virtio/virtio.c + dhcp/client.c + dhcp/dhcp4_proxy_node.c + dhcp/dhcp6_client_common_dp.c + dhcp/dhcp6_ia_na_client_cp.c + dhcp/dhcp6_ia_na_client_dp.c + dhcp/dhcp6_pd_client_cp.c + dhcp/dhcp6_pd_client_dp.c + dhcp/dhcp6_proxy_node.c + dhcp/dhcp_api.c + dhcp/dhcp_client_detect.c + dhcp/dhcp_proxy.c + dns/dns.c + dns/reply_node.c + dns/request_node.c + dns/resolver_process.c + dpo/classify_dpo.c + dpo/dpo.c + dpo/drop_dpo.c + dpo/dvr_dpo.c + dpo/interface_rx_dpo.c + dpo/interface_tx_dpo.c + dpo/ip6_ll_dpo.c + dpo/ip_null_dpo.c + dpo/l3_proxy_dpo.c + dpo/load_balance.c + dpo/load_balance_map.c + dpo/lookup_dpo.c + dpo/mpls_disposition.c + dpo/mpls_label_dpo.c + dpo/punt_dpo.c + dpo/receive_dpo.c + dpo/replicate_dpo.c + ethernet/arp.c + ethernet/format.c + ethernet/init.c + ethernet/interface.c + ethernet/node.c + ethernet/p2p_ethernet_api.c + ethernet/p2p_ethernet.c + ethernet/p2p_ethernet_input.c + ethernet/pg.c + ethernet/sfp.c + feature/feature_api.c + feature/feature.c + feature/registration.c + fib/fib_api.c + fib/fib_attached_export.c + fib/fib_bfd.c + fib/fib.c + fib/fib_entry.c + fib/fib_entry_cover.c + fib/fib_entry_delegate.c + fib/fib_entry_src_adj.c + fib/fib_entry_src_api.c + fib/fib_entry_src.c + fib/fib_entry_src_default_route.c + fib/fib_entry_src_interface.c + fib/fib_entry_src_interpose.c + fib/fib_entry_src_lisp.c + fib/fib_entry_src_mpls.c + fib/fib_entry_src_rr.c + fib/fib_entry_src_special.c + fib/fib_node.c + fib/fib_node_list.c + fib/fib_path.c + fib/fib_path_ext.c + fib/fib_path_list.c + fib/fib_table.c + fib/fib_test.c + fib/fib_types.c + fib/fib_urpf_list.c + fib/fib_walk.c + fib/ip4_fib.c + fib/ip6_fib.c + fib/mpls_fib.c + flow/flow.c + flow/flow_cli.c + geneve/decap.c + geneve/encap.c + geneve/geneve_api.c + geneve/geneve.c + gre/gre_api.c + gre/gre.c + gre/interface.c + gre/node.c + gre/pg.c + handoff.c + hdlc/hdlc.c + hdlc/node.c + hdlc/pg.c + interface_api.c + interface.c + interface_cli.c + interface_format.c + interface_output.c + interface_stats.c + ipfix-export/flow_api.c + ipfix-export/flow_report.c + ipfix-export/flow_report_classify.c + ip/format.c + ip/icmp4.c + ip/icmp6.c + ip/ip46_cli.c + ip/ip4_format.c + ip/ip4_forward.c + ip/ip4_input.c + ip/ip4_mtrie.c + ip/ip4_options.c + ip/ip4_pg.c + ip/ip4_punt_drop.c + ip/ip4_reassembly.c + ip/ip4_source_and_port_range_check.c + ip/ip4_source_check.c + ip/ip6_format.c + ip/ip6_forward.c + ip/ip6_hop_by_hop.c + ip/ip6_input.c + ip/ip6_ll_table.c + ip/ip6_ll_types.c + ip/ip6_neighbor.c + ip/ip6_pg.c + ip/ip6_punt_drop.c + ip/ip6_reassembly.c + ip/ip_api.c + ip/ip.c + ip/ip_checksum.c + ip/ip_frag.c + ip/ip_init.c + ip/ip_in_out_acl.c + ipip/ipip_api.c + ipip/ipip.c + ipip/ipip_cli.c + ip/ip_neighbor.c + ipip/node.c + ipip/sixrd.c + ip/ip_types_api.c + ip/lookup.c + ip/ping.c + ip/punt_api.c + ip/punt.c + ip/rd_cp.c + ipsec/ah_decrypt.c + ipsec/ah_encrypt.c + ipsec/esp_decrypt.c + ipsec/esp_encrypt.c + ipsec/esp_format.c + ipsec-gre/interface.c + ipsec-gre/ipsec_gre_api.c + ipsec-gre/ipsec_gre.c + ipsec-gre/node.c + ipsec/ikev2.c + ipsec/ikev2_cli.c + ipsec/ikev2_crypto.c + ipsec/ikev2_format.c + ipsec/ikev2_payload.c + ipsec/ipsec_api.c + ipsec/ipsec.c + ipsec/ipsec_cli.c + ipsec/ipsec_format.c + ipsec/ipsec_if.c + ipsec/ipsec_if_in.c + ipsec/ipsec_input.c + ipsec/ipsec_output.c + l2/feat_bitmap.c + l2/l2_api.c + l2/l2_bd.c + l2/l2_bvi.c + l2/l2_efp_filter.c + l2/l2_fib.c + l2/l2_flood.c + l2/l2_fwd.c + l2/l2_in_out_acl.c + l2/l2_input.c + l2/l2_input_classify.c + l2/l2_input_vtr.c + l2/l2_learn.c + l2/l2_output.c + l2/l2_output_classify.c + l2/l2_patch.c + l2/l2_rw.c + l2/l2_vtr.c + l2/l2_xcrw.c + l2tp/decap.c + l2tp/encap.c + l2tp/l2tp_api.c + l2tp/l2tp.c + l2tp/pg.c + lawful-intercept/lawful_intercept.c + lawful-intercept/node.c + lisp-cp/control.c + lisp-cp/gid_dictionary.c + lisp-cp/lisp_api.c + lisp-cp/lisp_cli.c + lisp-cp/lisp_cp_dpo.c + lisp-cp/lisp_msg_serdes.c + lisp-cp/lisp_types.c + lisp-cp/one_api.c + lisp-cp/one_cli.c + lisp-cp/packets.c + lisp-gpe/decap.c + lisp-gpe/interface.c + lisp-gpe/lisp_gpe_adjacency.c + lisp-gpe/lisp_gpe_api.c + lisp-gpe/lisp_gpe.c + lisp-gpe/lisp_gpe_fwd_entry.c + lisp-gpe/lisp_gpe_sub_interface.c + lisp-gpe/lisp_gpe_tenant.c + lisp-gpe/lisp_gpe_tunnel.c + llc/llc.c + llc/node.c + llc/pg.c + lldp/lldp_api.c + lldp/lldp_cli.c + lldp/lldp_input.c + lldp/lldp_node.c + lldp/lldp_output.c + mfib/ip4_mfib.c + mfib/ip6_mfib.c + mfib/mfib_entry.c + mfib/mfib_forward.c + mfib/mfib_itf.c + mfib/mfib_signal.c + mfib/mfib_table.c + mfib/mfib_test.c + mfib/mfib_types.c + misc.c + mpls/interface.c + mpls/mpls_api.c + mpls/mpls.c + mpls/mpls_features.c + mpls/mpls_input.c + mpls/mpls_lookup.c + mpls/mpls_output.c + mpls/mpls_tunnel.c + mpls/pg.c + osi/node.c + osi/osi.c + osi/pg.c + pg/cli.c + pg/edit.c + pg/init.c + pg/input.c + pg/output.c + pg/pg_api.c + pg/stream.c + policer/node_funcs.c + policer/policer_api.c + policer/policer.c + policer/xlate.c + ppp/node.c + ppp/pg.c + ppp/ppp.c + qos/qos_api.c + qos/qos_egress_map.c + qos/qos_mark.c + qos/qos_record.c + qos/qos_types.c + replication.c + sctp/sctp_api.c + sctp/sctp.c + sctp/sctp_format.c + sctp/sctp_input.c + sctp/sctp_output.c + sctp/sctp_pg.c + session/application.c + session/application_interface.c + session/application_namespace.c + session-apps/echo_client.c + session-apps/echo_server.c + session-apps/http_server.c + session-apps/proxy.c + session/segment_manager.c + session/session_api.c + session/session.c + session/session_cli.c + session/session_lookup.c + session/session_node.c + session/session_rules_table.c + session/session_table.c + session/session_test.c + session/transport.c + snap/node.c + snap/pg.c + snap/snap.c + span/node.c + span/span_api.c + span/span.c + srmpls/sr_mpls_api.c + srmpls/sr_mpls_policy.c + srmpls/sr_mpls_steering.c + srp/format.c + srp/interface.c + srp/node.c + srp/pg.c + srv6/sr_api.c + srv6/sr.c + srv6/sr_localsid.c + srv6/sr_policy_rewrite.c + srv6/sr_steering.c + tcp/tcp_api.c + tcp/tcp.c + tcp/tcp_format.c + tcp/tcp_input.c + tcp/tcp_newreno.c + tcp/tcp_output.c + tcp/tcp_pg.c + tcp/tcp_syn_filter4.c + tls/tls.c + udp/udp_api.c + udp/udp.c + udp/udp_encap.c + udp/udp_encap_node.c + udp/udp_format.c + udp/udp_input.c + udp/udp_local.c + udp/udp_pg.c + unix/gdb_funcs.c + unix/pcap.c + unix/tap_api.c + unix/tapcli.c + unix/tuntap.c + util/radix.c + util/refcount.c + util/trajectory.c + vxlan/decap.c + vxlan/encap.c + vxlan-gpe/decap.c + vxlan-gpe/encap.c + vxlan-gpe/vxlan_gpe_api.c + vxlan-gpe/vxlan_gpe.c + vxlan/vxlan_api.c + vxlan/vxlan.c +) + +set (VNET_API_FILES + vxlan-gpe/vxlan_gpe.api + ip/ip.api + ip/rd_cp.api + ip/ip_types.api + ip/punt.api + fib/fib_types.api + devices/virtio/vhost_user.api + devices/af_packet/af_packet.api + devices/tap/tapv2.api + devices/netmap/netmap.api + devices/pipe/pipe.api + l2tp/l2tp.api + bier/bier.api + ipsec-gre/ipsec_gre.api + cop/cop.api + ipsec/ipsec.api + lisp-gpe/lisp_gpe.api + lldp/lldp.api + vxlan/vxlan.api + srmpls/sr_mpls.api + pg/pg.api + bonding/bond.api + dns/dns.api + feature/feature.api + dhcp/dhcp.api + dhcp/dhcp6_pd_client_cp.api + dhcp/dhcp6_ia_na_client_cp.api + sctp/sctp.api + ipip/ipip.api + qos/qos.api + interface.api + udp/udp.api + lisp-cp/one.api + lisp-cp/lisp.api + mpls/mpls.api + l2/l2.api + geneve/geneve.api + tcp/tcp.api + unix/tap.api + srv6/sr.api + gre/gre.api + span/span.api + policer/policer.api + session/session.api + ethernet/p2p_ethernet.api + ipfix-export/ipfix_export.api + classify/classify.api + bfd/bfd.api +) + +set(VNET_API_HDRS) +foreach (file ${VNET_API_FILES}) + vpp_generate_api_header(${file}) + list(APPEND VNET_API_HDRS ${file}.h) +endforeach() +add_custom_target(vnet_api_headers DEPENDS ${VNET_API_HDRS}) + +add_library(vnet SHARED ${VNET_SRCS}) + +vpp_library_set_multiarch_sources(vnet + bonding/node.c + ip/ip4_forward.c + ip/ip4_input.c + l2/l2_output.c + devices/virtio/vhost_user_input.c + devices/virtio/vhost_user_output.c +) +target_link_libraries(vnet vlib ${OPENSSL_LIBRARIES}) +add_dependencies(vnet api_headers) + +# +# Install +# +install(TARGETS vnet DESTINATION lib) diff --git a/src/vpp/CMakeLists.txt b/src/vpp/CMakeLists.txt new file mode 100644 index 00000000000..9624ff7f761 --- /dev/null +++ b/src/vpp/CMakeLists.txt @@ -0,0 +1,87 @@ +# Copyright (c) 2018 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. + +############################################################################## +# Generate vpp/app/version.h +############################################################################## +add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/include/vpp/app/version.h + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMAND mkdir + ARGS -p ${CMAKE_BINARY_DIR}/include/vpp/app + COMMAND scripts/generate_version_h + ARGS ${CMAKE_BINARY_DIR}/include/vpp/app/version.h + COMMENT "Generating VPP version.h" +) + +add_custom_target(vpp_version_h + DEPENDS ${CMAKE_BINARY_DIR}/include/vpp/app/version.h +) + +############################################################################## +# vpp binary +############################################################################## + +vpp_add_api_files(vpp_api_headers + api/vpe.api + stats/stats.api + oam/oam.api +) + +add_executable (vpp + vnet/main.c + app/vpe_cli.c + app/version.c + oam/oam.c + oam/oam_api.c + stats/stats.c + stats/stat_segment.c + api/api.c + api/api_main.c + api/api_format.c + api/json_format.c + api/custom_dump.c + api/plugin.c +) +target_link_libraries(vpp svm vlib vppinfra vlibmemory vnet Threads::Threads + ${CMAKE_DL_LIBS}) +add_dependencies(vpp vpp_version_h api_headers) +set_target_properties(vpp PROPERTIES ENABLE_EXPORTS 1) +install(TARGETS vpp DESTINATION bin) + +############################################################################## +# vppctl binary +############################################################################## +add_executable(vppctl app/vppctl.c) +target_link_libraries(vppctl vppinfra) +install(TARGETS vppctl DESTINATION bin) + +############################################################################## +# vpp_get_metrics binary +############################################################################## +add_executable (vpp_get_metrics api/vpp_get_metrics.c ${VPP_API_HDRS}) +target_link_libraries (vpp_get_metrics vppinfra svm svmdb) +install(TARGETS vpp_get_metrics DESTINATION bin) + +############################################################################## +# stats binaries +############################################################################## +add_executable(summary_stats_client api/summary_stats_client.c) +add_executable(stat_client app/stat_client.c) +target_link_libraries(summary_stats_client vppinfra svm vlibmemoryclient) +target_link_libraries(stat_client vppinfra svm vlibmemoryclient) + +############################################################################## +# install +############################################################################## + diff --git a/src/vppinfra/CMakeLists.txt b/src/vppinfra/CMakeLists.txt new file mode 100644 index 00000000000..17daecd8ec1 --- /dev/null +++ b/src/vppinfra/CMakeLists.txt @@ -0,0 +1,235 @@ +# Copyright (c) 2018 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. + +enable_language(ASM) + +############################################################################## +# Generate vppinfra/config.h +############################################################################## +set(LOG2_CACHE_LINE_BYTES 6) +option(VPP_USE_DLMALLOC "Use dlmalloc memory allocator." ON) +if(VPP_USE_DLMALLOC) + set(DLMALLOC 1) +else(VPP_USE_DLMALLOC) + set(DLMALLOC 0) +endif(VPP_USE_DLMALLOC) + +configure_file( + ${CMAKE_SOURCE_DIR}/vppinfra/config.h.in + ${CMAKE_BINARY_DIR}/vppinfra/config.h +) + +install( + FILES ${CMAKE_BINARY_DIR}/vppinfra/config.h + DESTINATION include/vppinfra + COMPONENT dev +) + +############################################################################## +# vppinfra sources +############################################################################## +set(VPPINFRA_SRCS + asm_x86.c + backtrace.c + cpu.c + cuckoo_template.c + dlmalloc.c + elf.c + elf_clib.c + elog.c + error.c + fheap.c + fifo.c + format.c + graph.c + hash.c + heap.c + longjmp.S + macros.c + maplog.c + mem_dlmalloc.c + mhash.c + pool.c + ptclosure.c + qsort.c + random.c + random_buffer.c + random_isaac.c + serialize.c + slist.c + socket.c + std-formats.c + string.c + time.c + time_range.c + timer.c + timing_wheel.c + tw_timer_2t_1w_2048sl.c + tw_timer_16t_2w_512sl.c + tw_timer_16t_1w_2048sl.c + tw_timer_4t_3w_256sl.c + tw_timer_1t_3w_1024sl_ov.c + unformat.c + unix-formats.c + unix-misc.c + valloc.c + vec.c + vector.c + zvec.c + linux/mem.c + linux/sysfs.c +) + +add_library(vppinfra SHARED ${VPPINFRA_SRCS}) +target_link_libraries(vppinfra m) +install(TARGETS vppinfra DESTINATION lib) + +############################################################################## +# vppinfra headers +############################################################################## +vpp_add_header_files(vppinfra + asm_mips.h + asm_x86.h + bihash_16_8.h + bihash_24_8.h + bihash_40_8.h + bihash_48_8.h + bihash_8_8.h + bihash_template.c + bihash_template.h + bihash_vec8_8.h + bitmap.h + bitops.h + byte_order.h + cache.h + clib_error.h + clib.h + cpu.h + crc32.h + dlist.h + dlmalloc.h + elf_clib.h + elf.h + elog.h + error_bootstrap.h + error.h + fheap.h + fifo.h + file.h + flowhash_24_16.h + flowhash_8_8.h + flowhash_template.h + format.h + graph.h + hash.h + heap.h + lb_hash_hash.h + lock.h + longjmp.h + macros.h + maplog.h + math.h + memcpy_avx2.h + memcpy_avx512.h + memcpy_sse3.h + mem.h + mhash.h + mheap_bootstrap.h + mheap.h + os.h + pipeline.h + pool.h + ptclosure.h + random_buffer.h + random.h + random_isaac.h + serialize.h + slist.h + smp.h + socket.h + sparse_vec.h + string.h + time.h + time_range.h + timer.h + timing_wheel.h + tw_timer_16t_1w_2048sl.h + tw_timer_16t_2w_512sl.h + tw_timer_1t_3w_1024sl_ov.h + tw_timer_2t_1w_2048sl.h + tw_timer_4t_3w_256sl.h + tw_timer_template.c + tw_timer_template.h + types.h + unix.h + valgrind.h + valloc.h + vec_bootstrap.h + vec.h + vector_altivec.h + vector_avx2.h + vector_avx512.h + vector_funcs.h + vector.h + vector_neon.h + vector_sse42.h + xxhash.h + xy.h + zvec.h + linux/syscall.h + linux/sysfs.h +) + +option(VPP_BUILD_VPPINFRA_TESTS "Build vppinfra tests." OFF) +if(VPP_BUILD_VPPINFRA_TESTS) + set(VPPINFRA_TESTS + bihash_template + bihash_vec88 + cuckoo_bihash + cuckoo_template + dlist + elf + elog + fifo + flowhash_template + format + fpool + hash + heap + longjmp + macros + maplog + pool_iterate + ptclosure + random + random_isaac + serialize + slist + socket + time + time_range + timing_wheel + tw_timer + valloc + vec + vhash + zvec + ) + foreach(test ${VPPINFRA_TESTS}) + add_executable(test_${test} test_${test}.c) + target_link_libraries(test_${test} vppinfra) + endforeach() + + target_link_libraries(test_bihash_template Threads::Threads) + target_link_libraries(test_cuckoo_bihash Threads::Threads) +endif(VPP_BUILD_VPPINFRA_TESTS) diff --git a/src/vppinfra/vector_sse42.h b/src/vppinfra/vector_sse42.h index 381db37200e..2b6246e97f8 100644 --- a/src/vppinfra/vector_sse42.h +++ b/src/vppinfra/vector_sse42.h @@ -616,7 +616,7 @@ u8x16_shuffle (u8x16 v, u8x16 m) static_always_inline u32x4 u32x4_shuffle (u32x4 v, const int a, const int b, const int c, const int d) { -#if defined(__clang__) || CLIB_DEBUG > 0 +#if defined(__clang__) || !__OPTIMIZE__ u32x4 r = { v[a], v[b], v[c], v[d] }; return r; #else -- cgit 1.2.3-korg