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/examples/gen-rules.py | 186 ------------------------------------ src/plugins/examples/health_check.c | 109 --------------------- src/plugins/examples/test_map.py | 141 --------------------------- 3 files changed, 436 deletions(-) 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 (limited to 'src/plugins/examples') 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() - - -- cgit 1.2.3-korg