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/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 ++++ 35 files changed, 1321 insertions(+), 436 deletions(-) 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 (limited to 'src/plugins') 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 +) -- cgit 1.2.3-korg