From e727a01092e6b2afa3b06430ec0fd4d55bdf890b Mon Sep 17 00:00:00 2001 From: Mauricio Vasquez B Date: Mon, 18 Feb 2019 12:04:08 -0500 Subject: [PATCH] remove pcn-bridge The pcn-bridge code was generated with a very old version of the generation tools. This code is incompatible with the in daemon validation, hence remove this service. It will be reintroduced once it is ported to a recent version of the code generation. Signed-off-by: Mauricio Vasquez B --- src/services/CMakeLists.txt | 1 - src/services/pcn-bridge/CMakeLists.txt | 7 - src/services/pcn-bridge/datamodel/bridge.yang | 214 -- .../pcn-bridge/external/stp/CMakeLists.txt | 4 - .../pcn-bridge/external/stp/byte-order.h | 84 - .../pcn-bridge/external/stp/compiler.h | 230 -- .../pcn-bridge/external/stp/dependencies.c | 101 - .../pcn-bridge/external/stp/dependencies.h | 157 -- src/services/pcn-bridge/external/stp/log.cpp | 57 - src/services/pcn-bridge/external/stp/log.h | 29 - src/services/pcn-bridge/external/stp/stp.c | 1465 ---------- src/services/pcn-bridge/external/stp/stp.h | 181 -- src/services/pcn-bridge/external/stp/types.h | 98 - src/services/pcn-bridge/src/Bridge-lib.cpp | 23 - src/services/pcn-bridge/src/Bridge.cpp | 486 ---- src/services/pcn-bridge/src/Bridge.h | 289 -- src/services/pcn-bridge/src/BridgeApi.cpp | 1292 --------- src/services/pcn-bridge/src/BridgeSTP.cpp | 339 --- src/services/pcn-bridge/src/BridgeSTP.h | 100 - .../pcn-bridge/src/Bridge_dp_no_stp.c | 301 --- src/services/pcn-bridge/src/Bridge_dp_stp.c | 356 --- src/services/pcn-bridge/src/CMakeLists.txt | 39 - src/services/pcn-bridge/src/api/BridgeApi.cpp | 2355 ----------------- src/services/pcn-bridge/src/api/BridgeApi.h | 1041 -------- .../pcn-bridge/src/api/BridgeApiImpl.cpp | 1554 ----------- .../pcn-bridge/src/api/BridgeApiImpl.h | 160 -- .../pcn-bridge/src/model/BridgeSchema.cpp | 419 --- .../pcn-bridge/src/model/BridgeSchema.h | 138 - .../src/model/FilteringdatabaseSchema.cpp | 260 -- .../src/model/FilteringdatabaseSchema.h | 106 - .../pcn-bridge/src/model/ModelBase.cpp | 56 - src/services/pcn-bridge/src/model/ModelBase.h | 51 - .../src/model/PortsAccessSchema.cpp | 113 - .../pcn-bridge/src/model/PortsAccessSchema.h | 66 - .../pcn-bridge/src/model/PortsSchema.cpp | 446 ---- .../pcn-bridge/src/model/PortsSchema.h | 151 -- .../pcn-bridge/src/model/PortsStpSchema.cpp | 230 -- .../pcn-bridge/src/model/PortsStpSchema.h | 96 - .../src/model/PortsTrunkAllowedSchema.cpp | 96 - .../src/model/PortsTrunkAllowedSchema.h | 66 - .../pcn-bridge/src/model/PortsTrunkSchema.cpp | 161 -- .../pcn-bridge/src/model/PortsTrunkSchema.h | 78 - .../pcn-bridge/src/model/StpSchema.cpp | 330 --- src/services/pcn-bridge/src/model/StpSchema.h | 116 - src/services/pcn-bridge/test/README.md | 42 - .../pcn-bridge/test/connectivity/test1.sh | 60 - .../pcn-bridge/test/connectivity/test1_xdp.sh | 3 - src/services/pcn-bridge/test/helpers.bash | 248 -- .../pcn-bridge/test/stp/stp_pcn/test11.sh | 46 - .../pcn-bridge/test/stp/stp_pcn/test12.sh | 49 - .../pcn-bridge/test/stp/stp_pcn/test13.sh | 56 - .../pcn-bridge/test/stp/stp_pcn/test14.sh | 39 - .../pcn-bridge/test/stp/stp_pcn/test15.sh | 53 - .../pcn-bridge/test/stp/stp_pcn/test16.sh | 60 - .../pcn-bridge/test/stp/stp_pcn/test17.sh | 60 - .../pcn-bridge/test/stp/stp_pcn/test21.sh | 57 - .../pcn-bridge/test/stp/stp_pcn/test22.sh | 72 - .../pcn-bridge/test/stp/stp_pcn/test23.sh | 73 - .../pcn-bridge/test/stp/stp_pcn/test24.sh | 53 - .../pcn-bridge/test/stp/stp_pcn/test25.sh | 77 - .../pcn-bridge/test/stp/stp_pcn/test26.sh | 84 - .../pcn-bridge/test/stp/stp_pcn/test27.sh | 72 - .../pcn-bridge/test/stp/stp_pcn/test31.sh | 53 - .../pcn-bridge/test/stp/stp_pcn/test32.sh | 59 - .../pcn-bridge/test/stp/stp_pcn/test33.sh | 73 - .../pcn-bridge/test/stp/stp_pcn/test34.sh | 43 - .../pcn-bridge/test/stp/stp_pcn/test35.sh | 65 - .../pcn-bridge/test/stp/stp_pcn/test36.sh | 75 - .../pcn-bridge/test/stp/stp_pcn/test37.sh | 75 - .../pcn-bridge/test/stp/stp_pcn/test41.sh | 68 - .../pcn-bridge/test/stp/stp_pcn/test42.sh | 92 - .../pcn-bridge/test/stp/stp_pcn/test43.sh | 98 - .../pcn-bridge/test/stp/stp_pcn/test44.sh | 60 - .../pcn-bridge/test/stp/stp_pcn/test45.sh | 140 - .../pcn-bridge/test/stp/stp_pcn/test46.sh | 118 - .../pcn-bridge/test/stp/stp_pcn/test47.sh | 99 - .../pcn-bridge/test/stp/stp_pcn_lb/test51.sh | 48 - .../pcn-bridge/test/stp/stp_pcn_lb/test52.sh | 51 - .../pcn-bridge/test/stp/stp_pcn_lb/test53.sh | 58 - .../pcn-bridge/test/stp/stp_pcn_lb/test55.sh | 55 - .../pcn-bridge/test/stp/stp_pcn_lb/test56.sh | 63 - .../pcn-bridge/test/stp/stp_pcn_lb/test57.sh | 63 - .../pcn-bridge/test/stp/stp_pcn_lb/test61.sh | 58 - .../pcn-bridge/test/stp/stp_pcn_lb/test62.sh | 76 - .../pcn-bridge/test/stp/stp_pcn_lb/test63.sh | 75 - .../pcn-bridge/test/stp/stp_pcn_lb/test65.sh | 79 - .../pcn-bridge/test/stp/stp_pcn_lb/test66.sh | 86 - .../pcn-bridge/test/stp/stp_pcn_lb/test67.sh | 74 - .../pcn-bridge/test/stp/stp_pcn_lb/test71.sh | 55 - .../pcn-bridge/test/stp/stp_pcn_lb/test72.sh | 61 - .../pcn-bridge/test/stp/stp_pcn_lb/test73.sh | 74 - .../pcn-bridge/test/stp/stp_pcn_lb/test75.sh | 67 - .../pcn-bridge/test/stp/stp_pcn_lb/test76.sh | 77 - .../pcn-bridge/test/stp/stp_pcn_lb/test77.sh | 78 - .../pcn-bridge/test/stp/stp_pcn_lb/test81.sh | 71 - .../pcn-bridge/test/stp/stp_pcn_lb/test82.sh | 96 - .../pcn-bridge/test/stp/stp_pcn_lb/test83.sh | 102 - .../pcn-bridge/test/stp/stp_pcn_lb/test85.sh | 144 - .../pcn-bridge/test/stp/stp_pcn_lb/test86.sh | 122 - .../pcn-bridge/test/stp/stp_pcn_lb/test87.sh | 102 - src/services/pcn-bridge/test/test106.sh | 28 - src/services/pcn-bridge/test/test107.sh | 28 - src/services/pcn-bridge/test/vlan/test1.sh | 79 - src/services/pcn-bridge/test/vlan/test2.sh | 88 - src/services/pcn-bridge/test/vlan/test3.sh | 165 -- 105 files changed, 18487 deletions(-) delete mode 100755 src/services/pcn-bridge/CMakeLists.txt delete mode 100644 src/services/pcn-bridge/datamodel/bridge.yang delete mode 100755 src/services/pcn-bridge/external/stp/CMakeLists.txt delete mode 100644 src/services/pcn-bridge/external/stp/byte-order.h delete mode 100644 src/services/pcn-bridge/external/stp/compiler.h delete mode 100644 src/services/pcn-bridge/external/stp/dependencies.c delete mode 100644 src/services/pcn-bridge/external/stp/dependencies.h delete mode 100644 src/services/pcn-bridge/external/stp/log.cpp delete mode 100644 src/services/pcn-bridge/external/stp/log.h delete mode 100644 src/services/pcn-bridge/external/stp/stp.c delete mode 100644 src/services/pcn-bridge/external/stp/stp.h delete mode 100644 src/services/pcn-bridge/external/stp/types.h delete mode 100755 src/services/pcn-bridge/src/Bridge-lib.cpp delete mode 100644 src/services/pcn-bridge/src/Bridge.cpp delete mode 100644 src/services/pcn-bridge/src/Bridge.h delete mode 100644 src/services/pcn-bridge/src/BridgeApi.cpp delete mode 100644 src/services/pcn-bridge/src/BridgeSTP.cpp delete mode 100644 src/services/pcn-bridge/src/BridgeSTP.h delete mode 100644 src/services/pcn-bridge/src/Bridge_dp_no_stp.c delete mode 100644 src/services/pcn-bridge/src/Bridge_dp_stp.c delete mode 100755 src/services/pcn-bridge/src/CMakeLists.txt delete mode 100755 src/services/pcn-bridge/src/api/BridgeApi.cpp delete mode 100755 src/services/pcn-bridge/src/api/BridgeApi.h delete mode 100755 src/services/pcn-bridge/src/api/BridgeApiImpl.cpp delete mode 100755 src/services/pcn-bridge/src/api/BridgeApiImpl.h delete mode 100644 src/services/pcn-bridge/src/model/BridgeSchema.cpp delete mode 100644 src/services/pcn-bridge/src/model/BridgeSchema.h delete mode 100644 src/services/pcn-bridge/src/model/FilteringdatabaseSchema.cpp delete mode 100644 src/services/pcn-bridge/src/model/FilteringdatabaseSchema.h delete mode 100644 src/services/pcn-bridge/src/model/ModelBase.cpp delete mode 100644 src/services/pcn-bridge/src/model/ModelBase.h delete mode 100644 src/services/pcn-bridge/src/model/PortsAccessSchema.cpp delete mode 100644 src/services/pcn-bridge/src/model/PortsAccessSchema.h delete mode 100644 src/services/pcn-bridge/src/model/PortsSchema.cpp delete mode 100644 src/services/pcn-bridge/src/model/PortsSchema.h delete mode 100644 src/services/pcn-bridge/src/model/PortsStpSchema.cpp delete mode 100644 src/services/pcn-bridge/src/model/PortsStpSchema.h delete mode 100644 src/services/pcn-bridge/src/model/PortsTrunkAllowedSchema.cpp delete mode 100644 src/services/pcn-bridge/src/model/PortsTrunkAllowedSchema.h delete mode 100644 src/services/pcn-bridge/src/model/PortsTrunkSchema.cpp delete mode 100644 src/services/pcn-bridge/src/model/PortsTrunkSchema.h delete mode 100644 src/services/pcn-bridge/src/model/StpSchema.cpp delete mode 100644 src/services/pcn-bridge/src/model/StpSchema.h delete mode 100755 src/services/pcn-bridge/test/README.md delete mode 100755 src/services/pcn-bridge/test/connectivity/test1.sh delete mode 100755 src/services/pcn-bridge/test/connectivity/test1_xdp.sh delete mode 100755 src/services/pcn-bridge/test/helpers.bash delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn/test11.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn/test12.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn/test13.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn/test14.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn/test15.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn/test16.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn/test17.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn/test21.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn/test22.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn/test23.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn/test24.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn/test25.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn/test26.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn/test27.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn/test31.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn/test32.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn/test33.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn/test34.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn/test35.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn/test36.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn/test37.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn/test41.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn/test42.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn/test43.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn/test44.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn/test45.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn/test46.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn/test47.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn_lb/test51.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn_lb/test52.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn_lb/test53.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn_lb/test55.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn_lb/test56.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn_lb/test57.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn_lb/test61.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn_lb/test62.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn_lb/test63.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn_lb/test65.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn_lb/test66.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn_lb/test67.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn_lb/test71.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn_lb/test72.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn_lb/test73.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn_lb/test75.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn_lb/test76.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn_lb/test77.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn_lb/test81.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn_lb/test82.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn_lb/test83.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn_lb/test85.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn_lb/test86.sh delete mode 100755 src/services/pcn-bridge/test/stp/stp_pcn_lb/test87.sh delete mode 100755 src/services/pcn-bridge/test/test106.sh delete mode 100755 src/services/pcn-bridge/test/test107.sh delete mode 100755 src/services/pcn-bridge/test/vlan/test1.sh delete mode 100755 src/services/pcn-bridge/test/vlan/test2.sh delete mode 100755 src/services/pcn-bridge/test/vlan/test3.sh diff --git a/src/services/CMakeLists.txt b/src/services/CMakeLists.txt index 1f5297c34..04d78a732 100644 --- a/src/services/CMakeLists.txt +++ b/src/services/CMakeLists.txt @@ -16,7 +16,6 @@ endmacro() # first argument is the service name used in the rest API # second argument is the folder of the service -add_service(bridge pcn-bridge) add_service(ddosmitigator pcn-ddosmitigator) add_service(firewall pcn-firewall) add_service(helloworld pcn-helloworld) diff --git a/src/services/pcn-bridge/CMakeLists.txt b/src/services/pcn-bridge/CMakeLists.txt deleted file mode 100755 index ecd5ba64c..000000000 --- a/src/services/pcn-bridge/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required (VERSION 3.2) - -set (CMAKE_CXX_STANDARD 11) - -include_directories(external) -add_subdirectory(src) -add_subdirectory(external/stp) diff --git a/src/services/pcn-bridge/datamodel/bridge.yang b/src/services/pcn-bridge/datamodel/bridge.yang deleted file mode 100644 index 7435f9150..000000000 --- a/src/services/pcn-bridge/datamodel/bridge.yang +++ /dev/null @@ -1,214 +0,0 @@ -module bridge { - yang-version 1.1; - namespace "http://polycube.network/bridge"; - prefix "bridge"; - - import polycube-base { prefix "basemodel"; } - - organization "Polycube open source project"; - description "YANG data model for the Polycube Bridge service"; - - basemodel:service-description "Bridge Service"; - basemodel:service-version "2.0"; - basemodel:service-name "bridge"; - basemodel:service-min-kernel-version "4.14.0"; - - extension cli-example { - argument "value"; - description "A sample value used by the CLI generator"; - } - - leaf aging-time { - type uint32; - units seconds; - default 300; - description "Aging time of the filtering database"; - bridge:cli-example "300"; - } - - uses "basemodel:base-yang-module" { - augment ports { - leaf address { - type string; - description "MAC address of the port"; - bridge:cli-example "C5:13:2D:36:27:9B"; - } - - leaf mode { - type enumeration { - enum access; - enum trunk; - } - default access; - description "Type of bridge interface: access/trunk"; - bridge:cli-example "access"; - } - - container access { - description "vlan associated to a port in access mode"; - leaf vlanid { - type uint32; - default 1; - description "VLAN associated with this interface"; - bridge:cli-example "1"; - } - } - - container trunk { - list allowed { - description "Allowed vlans"; - key "vlanid"; - leaf vlanid { - type uint32; - description "Allowed vlan"; - bridge:cli-example "1"; - } - } - - leaf native-vlan { - type uint32; - default 1; - description "VLAN that is not tagged in this trunk port"; - bridge:cli-example "1"; - } - } - - list stp { - key "vlan"; - description "Per-vlan Spanning Tree Protocol Port Configuration"; - leaf vlan { - type uint32; - mandatory true; - description "VLAN identifier for this entry"; - bridge:cli-example "1"; - } - - leaf state { - type enumeration { - enum disabled; - enum blocking; - enum listening; - enum learning; - enum forwarding; - } - description "STP port state"; - config false; - } - - leaf path-cost { - type uint32; - default 4; - description "STP cost associated with this interface"; - bridge:cli-example "19"; - } - - leaf port-priority { - type uint32; - default 128; - description "Port priority of this interface"; - bridge:cli-example "128"; - } - } - } - } - - container filtering-database { - list entry { - key "vlan address"; - description "Entry associated with the filtering database"; - - leaf vlan { - type uint32; - mandatory true; - description "VLAN identifier"; - bridge:cli-example "1"; - } - - leaf address { - type string; - mandatory true; - description "Address of the filtering database entry"; - bridge:cli-example "C5:13:2D:36:27:9B"; - } - - leaf type { - type enumeration { - enum static; - enum dynamic; - } - default static; - description "Type of filtering entry"; - bridge:cli-example "static | dynamic"; - } - - leaf port { - type string; - mandatory true; - description "Output port name"; - bridge:cli-example "port2"; - } - - leaf age { - type uint32; - units seconds; - description "Age of the current filtering database entry"; - config false; - } - } - } - - leaf stp-enabled { - type boolean; - default false; - description "Enable/Disable the STP protocol of the bridge"; - bridge:cli-example "false"; - } - - list stp { - key "vlan"; - description "Per-vlan Spanning Tree Protocol Configuration"; - leaf vlan { - type uint32; - mandatory true; - description "VLAN identifier for this entry"; - bridge:cli-example "1"; - } - - leaf address { - type string; - description "Main MAC address used by the STP"; - bridge:cli-example "C5:13:2D:36:27:9B"; - } - - leaf priority { - type uint32; - default 32768; - description "Bridge priority for STP"; - bridge:cli-example "32768"; - } - - leaf forward-delay { - type uint32; - units seconds; - default 10; - description "Delay used by STP bridges for port state transition"; - bridge:cli-example "10"; - } - - leaf hello-time { - type uint32; - units seconds; - default 2; - description "Interval between transmissions of BPDU messages"; - bridge:cli-example "2"; - } - - leaf max-message-age { - type uint32; - units seconds; - default 20; - description "Maximum age of a BPDU"; - bridge:cli-example "20"; - } - } -} diff --git a/src/services/pcn-bridge/external/stp/CMakeLists.txt b/src/services/pcn-bridge/external/stp/CMakeLists.txt deleted file mode 100755 index 1de3a4b70..000000000 --- a/src/services/pcn-bridge/external/stp/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -include_directories(${CMAKE_SOURCE_DIR}/external/stp) -add_library(stp STATIC stp.c dependencies.c log.cpp) -target_link_libraries(stp pthread) -set_property(TARGET stp PROPERTY POSITION_INDEPENDENT_CODE ON) diff --git a/src/services/pcn-bridge/external/stp/byte-order.h b/src/services/pcn-bridge/external/stp/byte-order.h deleted file mode 100644 index b8c20e26f..000000000 --- a/src/services/pcn-bridge/external/stp/byte-order.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2008, 2010, 2011, 2013 Nicira, Inc. - * - * 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 BYTE_ORDER_H -#define BYTE_ORDER_H 1 - -#include -#include -#include -#include "types.h" - -#ifndef __CHECKER__ -#ifndef _WIN32 -static inline ovs_be64 htonll(uint64_t n) { - return htonl(1) == 1 ? n : ((uint64_t)htonl(n) << 32) | htonl(n >> 32); -} - -static inline uint64_t ntohll(ovs_be64 n) { - return htonl(1) == 1 ? n : ((uint64_t)ntohl(n) << 32) | ntohl(n >> 32); -} -#endif /* _WIN32 */ -#else -/* Making sparse happy with these functions also makes them unreadable, so - * don't bother to show it their implementations. */ -ovs_be64 htonll(uint64_t); -uint64_t ntohll(ovs_be64); -#endif - -static inline uint32_t uint32_byteswap(uint32_t crc) { - return (((crc & 0x000000ff) << 24) | ((crc & 0x0000ff00) << 8) | - ((crc & 0x00ff0000) >> 8) | ((crc & 0xff000000) >> 24)); -} - -/* These macros may substitute for htons(), htonl(), and htonll() in contexts - * where function calls are not allowed, such as case labels. They should not - * be used elsewhere because all of them evaluate their argument many times. */ -#if defined(WORDS_BIGENDIAN) || __CHECKER__ -#define CONSTANT_HTONS(VALUE) ((OVS_FORCE ovs_be16)((VALUE)&0xffff)) -#define CONSTANT_HTONL(VALUE) ((OVS_FORCE ovs_be32)((VALUE)&0xffffffff)) -#define CONSTANT_HTONLL(VALUE) \ - ((OVS_FORCE ovs_be64)((VALUE)&UINT64_C(0xffffffffffffffff))) -#else -#define CONSTANT_HTONS(VALUE) \ - (((((ovs_be16)(VALUE)) & 0xff00) >> 8) | \ - ((((ovs_be16)(VALUE)) & 0x00ff) << 8)) -#define CONSTANT_HTONL(VALUE) \ - (((((ovs_be32)(VALUE)) & 0x000000ff) << 24) | \ - ((((ovs_be32)(VALUE)) & 0x0000ff00) << 8) | \ - ((((ovs_be32)(VALUE)) & 0x00ff0000) >> 8) | \ - ((((ovs_be32)(VALUE)) & 0xff000000) >> 24)) -#define CONSTANT_HTONLL(VALUE) \ - (((((ovs_be64)(VALUE)) & UINT64_C(0x00000000000000ff)) << 56) | \ - ((((ovs_be64)(VALUE)) & UINT64_C(0x000000000000ff00)) << 40) | \ - ((((ovs_be64)(VALUE)) & UINT64_C(0x0000000000ff0000)) << 24) | \ - ((((ovs_be64)(VALUE)) & UINT64_C(0x00000000ff000000)) << 8) | \ - ((((ovs_be64)(VALUE)) & UINT64_C(0x000000ff00000000)) >> 8) | \ - ((((ovs_be64)(VALUE)) & UINT64_C(0x0000ff0000000000)) >> 24) | \ - ((((ovs_be64)(VALUE)) & UINT64_C(0x00ff000000000000)) >> 40) | \ - ((((ovs_be64)(VALUE)) & UINT64_C(0xff00000000000000)) >> 56)) -#endif - -#if WORDS_BIGENDIAN -#define BYTES_TO_BE32(B1, B2, B3, B4) \ - (OVS_FORCE ovs_be32)((uint32_t)(B1) << 24 | (B2) << 16 | (B3) << 8 | (B4)) -#define BE16S_TO_BE32(B1, B2) (OVS_FORCE ovs_be32)((uint32_t)(B1) << 16 | (B2)) -#else -#define BYTES_TO_BE32(B1, B2, B3, B4) \ - (OVS_FORCE ovs_be32)((uint32_t)(B1) | (B2) << 8 | (B3) << 16 | (B4) << 24) -#define BE16S_TO_BE32(B1, B2) (OVS_FORCE ovs_be32)((uint32_t)(B1) | (B2) << 16) -#endif - -#endif /* byte-order.h */ diff --git a/src/services/pcn-bridge/external/stp/compiler.h b/src/services/pcn-bridge/external/stp/compiler.h deleted file mode 100644 index dfc45fca0..000000000 --- a/src/services/pcn-bridge/external/stp/compiler.h +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc. - * - * 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 COMPILER_H -#define COMPILER_H 1 - -#ifndef __has_feature -#define __has_feature(x) 0 -#endif -#ifndef __has_extension -#define __has_extension(x) 0 -#endif - -#if __GNUC__ && !__CHECKER__ -#define NO_RETURN __attribute__((__noreturn__)) -#define OVS_UNUSED __attribute__((__unused__)) -#define PRINTF_FORMAT(FMT, ARG1) __attribute__((__format__(printf, FMT, ARG1))) -#define SCANF_FORMAT(FMT, ARG1) __attribute__((__format__(scanf, FMT, ARG1))) -#define STRFTIME_FORMAT(FMT) __attribute__((__format__(__strftime__, FMT, 0))) -#define MALLOC_LIKE __attribute__((__malloc__)) -#define ALWAYS_INLINE __attribute__((always_inline)) -#define WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) -#define SENTINEL(N) __attribute__((sentinel(N))) -#define OVS_LIKELY(CONDITION) __builtin_expect(!!(CONDITION), 1) -#define OVS_UNLIKELY(CONDITION) __builtin_expect(!!(CONDITION), 0) -#else -#define NO_RETURN -#define OVS_UNUSED -#define PRINTF_FORMAT(FMT, ARG1) -#define SCANF_FORMAT(FMT, ARG1) -#define STRFTIME_FORMAT(FMT) -#define MALLOC_LIKE -#define ALWAYS_INLINE -#define WARN_UNUSED_RESULT -#define SENTINEL(N) -#define OVS_LIKELY(CONDITION) (!!(CONDITION)) -#define OVS_UNLIKELY(CONDITION) (!!(CONDITION)) -#endif - -#if __has_feature(c_thread_safety_attributes) -/* "clang" annotations for thread safety check. - * - * OVS_LOCKABLE indicates that the struct contains mutex element - * which can be locked by functions like ovs_mutex_lock(). - * - * Below, the word MUTEX stands for the name of an object with an OVS_LOCKABLE - * struct type. It can also be a comma-separated list of multiple structs, - * e.g. to require a function to hold multiple locks while invoked. - * - * - * On a variable: - * - * - OVS_GUARDED indicates that the variable may only be accessed some mutex - * is held. - * - * - OVS_GUARDED_BY(MUTEX) indicates that the variable may only be accessed - * while the specific MUTEX is held. - * - * - * On a variable A of mutex type: - * - * - OVS_ACQ_BEFORE(B), where B is a mutex or a comma-separated list of - * mutexes, declare that if both A and B are acquired at the same time, - * then A must be acquired before B. That is, B nests inside A. - * - * - OVS_ACQ_AFTER(B) is the opposite of OVS_ACQ_BEFORE(B), that is, it - * declares that A nests inside B. - * - * - * On a function, the following attributes apply to mutexes: - * - * - OVS_ACQUIRES(MUTEX) indicate that the function must be called without - * holding MUTEX and that it returns holding MUTEX. - * - * - OVS_RELEASES(MUTEX) indicates that the function may only be called with - * MUTEX held and that it returns with MUTEX released. It can be used for - * all types of MUTEX. - * - * - OVS_TRY_LOCK(RETVAL, MUTEX) indicate that the function will try to - * acquire MUTEX. RETVAL is an integer or boolean value specifying the - * return value of a successful lock acquisition. - * - * - OVS_REQUIRES(MUTEX) indicate that the function may only be called with - * MUTEX held and that the function does not release MUTEX. - * - * - OVS_EXCLUDED(MUTEX) indicates that the function may only be called when - * MUTEX is not held. - * - * - * The following variants, with the same syntax, apply to reader-writer locks: - * - * mutex rwlock, for reading rwlock, for writing - * ------------------- ------------------- ------------------- - * OVS_ACQUIRES OVS_ACQ_RDLOCK OVS_ACQ_WRLOCK - * OVS_RELEASES OVS_RELEASES OVS_RELEASES - * OVS_TRY_LOCK OVS_TRY_RDLOCK OVS_TRY_WRLOCK - * OVS_REQUIRES OVS_REQ_RDLOCK OVS_REQ_WRLOCK - * OVS_EXCLUDED OVS_EXCLUDED OVS_EXCLUDED - */ -#define OVS_LOCKABLE __attribute__((lockable)) -#define OVS_REQ_RDLOCK(...) __attribute__((shared_locks_required(__VA_ARGS__))) -#define OVS_ACQ_RDLOCK(...) __attribute__((shared_lock_function(__VA_ARGS__))) -#define OVS_REQ_WRLOCK(...) \ - __attribute__((exclusive_locks_required(__VA_ARGS__))) -#define OVS_ACQ_WRLOCK(...) \ - __attribute__((exclusive_lock_function(__VA_ARGS__))) -#define OVS_REQUIRES(...) __attribute__((exclusive_locks_required(__VA_ARGS__))) -#define OVS_ACQUIRES(...) __attribute__((exclusive_lock_function(__VA_ARGS__))) -#define OVS_TRY_WRLOCK(RETVAL, ...) \ - __attribute__((exclusive_trylock_function(RETVAL, __VA_ARGS__))) -#define OVS_TRY_RDLOCK(RETVAL, ...) \ - __attribute__((shared_trylock_function(RETVAL, __VA_ARGS__))) -#define OVS_TRY_LOCK(RETVAL, ...) \ - __attribute__((exclusive_trylock_function(RETVAL, __VA_ARGS__))) -#define OVS_GUARDED __attribute__((guarded_var)) -#define OVS_GUARDED_BY(...) __attribute__((guarded_by(__VA_ARGS__))) -#define OVS_RELEASES(...) __attribute__((unlock_function(__VA_ARGS__))) -#define OVS_EXCLUDED(...) __attribute__((locks_excluded(__VA_ARGS__))) -#define OVS_ACQ_BEFORE(...) __attribute__((acquired_before(__VA_ARGS__))) -#define OVS_ACQ_AFTER(...) __attribute__((acquired_after(__VA_ARGS__))) -#define OVS_NO_THREAD_SAFETY_ANALYSIS __attribute__((no_thread_safety_analysis)) -#else /* not Clang */ -#define OVS_LOCKABLE -#define OVS_REQ_RDLOCK(...) -#define OVS_ACQ_RDLOCK(...) -#define OVS_REQ_WRLOCK(...) -#define OVS_ACQ_WRLOCK(...) -#define OVS_REQUIRES(...) -#define OVS_ACQUIRES(...) -#define OVS_TRY_WRLOCK(...) -#define OVS_TRY_RDLOCK(...) -#define OVS_TRY_LOCK(...) -#define OVS_GUARDED -#define OVS_GUARDED_BY(...) -#define OVS_EXCLUDED(...) -#define OVS_RELEASES(...) -#define OVS_ACQ_BEFORE(...) -#define OVS_ACQ_AFTER(...) -#define OVS_NO_THREAD_SAFETY_ANALYSIS -#endif - -/* ISO C says that a C implementation may choose any integer type for an enum - * that is sufficient to hold all of its values. Common ABIs (such as the - * System V ABI used on i386 GNU/Linux) always use a full-sized "int", even - * when a smaller type would suffice. - * - * In GNU C, "enum __attribute__((packed)) name { ... }" defines 'name' as an - * enum compatible with a type that is no bigger than necessary. This is the - * intended use of OVS_PACKED_ENUM. - * - * OVS_PACKED_ENUM is intended for use only as a space optimization, since it - * only works with GCC. That means that it must not be used in wire protocols - * or otherwise exposed outside of a single process. */ -#if __GNUC__ && !__CHECKER__ -#define OVS_PACKED_ENUM __attribute__((__packed__)) -#define HAVE_PACKED_ENUM -#else -#define OVS_PACKED_ENUM -#endif - -#ifndef _MSC_VER -#define OVS_PACKED(DECL) DECL __attribute__((__packed__)) -#else -#define OVS_PACKED(DECL) __pragma(pack(push, 1)) DECL __pragma(pack(pop)) -#endif - -/* For defining a structure whose instances should aligned on an N-byte - * boundary. - * - * e.g. The following: - * OVS_ALIGNED_STRUCT(64, mystruct) { ... }; - * is equivalent to the following except that it specifies 64-byte alignment: - * struct mystruct { ... }; - */ -#ifndef _MSC_VER -#define OVS_ALIGNED_STRUCT(N, TAG) struct __attribute__((aligned(N))) TAG -#else -#define OVS_ALIGNED_STRUCT(N, TAG) __declspec(align(N)) struct TAG -#endif - -#ifdef _MSC_VER -#define CCALL __cdecl -#pragma section(".CRT$XCU", read) -#define OVS_CONSTRUCTOR(f) \ - static void __cdecl f(void); \ - __declspec(allocate(".CRT$XCU")) void(__cdecl * f##_)(void) = f; \ - static void __cdecl f(void) -#else -#define OVS_CONSTRUCTOR(f) \ - static void f(void) __attribute__((constructor)); \ - static void f(void) -#endif - -/* OVS_PREFETCH() can be used to instruct the CPU to fetch the cache - * line containing the given address to a CPU cache. - * OVS_PREFETCH_WRITE() should be used when the memory is going to be - * written to. Depending on the target CPU, this can generate the same - * instruction as OVS_PREFETCH(), or bring the data into the cache in an - * exclusive state. */ -#if __GNUC__ -#define OVS_PREFETCH(addr) __builtin_prefetch((addr)) -#define OVS_PREFETCH_WRITE(addr) __builtin_prefetch((addr), 1) -#else -#define OVS_PREFETCH(addr) -#define OVS_PREFETCH_WRITE(addr) -#endif - -/* Output a message (not an error) while compiling without failing the - * compilation process */ -#if HAVE_PRAGMA_MESSAGE -#define DO_PRAGMA(x) _Pragma(#x) -#define BUILD_MESSAGE(x) DO_PRAGMA(message(x)) -#else -#define BUILD_MESSAGE(x) -#endif - -#endif /* compiler.h */ diff --git a/src/services/pcn-bridge/external/stp/dependencies.c b/src/services/pcn-bridge/external/stp/dependencies.c deleted file mode 100644 index 2e7369c32..000000000 --- a/src/services/pcn-bridge/external/stp/dependencies.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc. - * Copyright 2017 The Polycube Authors - * - * 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 "dependencies.h" -#include -#include - -/********** util.c **********/ -void out_of_memory() { - abort(); -} - -void *xcalloc(size_t count, size_t size) { - void *p = count && size ? calloc(count, size) : malloc(1); - // COVERAGE_INC(util_xalloc); - if (p == NULL) { - out_of_memory(); - } - return p; -} - -void *xmalloc(size_t size) { - void *p = malloc(size ? size : 1); - // COVERAGE_INC(util_xalloc); - if (p == NULL) { - out_of_memory(); - } - return p; -} - -void *xzalloc(size_t size) { - return xcalloc(1, size); -} - -char *xmemdup0(const char *p_, size_t length) { - char *p = xmalloc(length + 1); - memcpy(p, p_, length); - p[length] = '\0'; - return p; -} - -char *xstrdup(const char *s) { - return xmemdup0(s, strlen(s)); -} - -/********** ofpbuf.c **********/ - -struct ofpbuf { - void *base_; /* First byte of allocated space. */ - uint32_t size_; /* Number of allocated bytes. */ -}; - -struct ofpbuf *ofpbuf_new(size_t size) { - struct ofpbuf *p = xmalloc(sizeof(*p)); - p->base_ = xmalloc(size); - p->size_ = size; - return p; -} - -void ofpbuf_free(struct ofpbuf *p) { - free(p->base_); - free(p); -} - -void *ofpbuf_base(struct ofpbuf *p) { - return p->base_; -} - -ssize_t ofpbuf_size(struct ofpbuf *p) { - return p->size_; -} - -/********** ovs-thread.c **********/ -void ovs_mutex_init(pthread_mutex_t *m) { - pthread_mutexattr_t attr; - pthread_mutexattr_init(&attr); - pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(m, &attr); -} - -void ovs_mutex_lock(pthread_mutex_t *m) { - pthread_mutex_lock(m); -} - -void ovs_mutex_unlock(pthread_mutex_t *m) { - pthread_mutex_unlock(m); -} diff --git a/src/services/pcn-bridge/external/stp/dependencies.h b/src/services/pcn-bridge/external/stp/dependencies.h deleted file mode 100644 index 4868632b8..000000000 --- a/src/services/pcn-bridge/external/stp/dependencies.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc. - * Copyright 2017 The Polycube Authors - * - * 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. - */ - -/* - * this file contains the minimum set of dependencies that are requires by the - * stp module - */ - -#ifndef _DEPENDENCIES_H -#define _DEPENDENCIES_H - -#include -#include -#include -#include -#include - -#include "byte-order.h" -#include "compiler.h" -#include "types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/********** util.h **********/ -#define OVS_NOT_REACHED() abort() - -#define ovs_assert(CONDITION) \ - if (!OVS_LIKELY(CONDITION)) { \ - abort(); \ - } - -#ifndef MIN -#define MIN(X, Y) ((X) < (Y) ? (X) : (Y)) -#endif - -#ifndef MAX -#define MAX(X, Y) ((X) > (Y) ? (X) : (Y)) -#endif - -/* Use "%"PRIuSIZE to format size_t with printf(). */ -#ifdef _WIN32 -#define PRIdSIZE "Id" -#define PRIiSIZE "Ii" -#define PRIoSIZE "Io" -#define PRIuSIZE "Iu" -#define PRIxSIZE "Ix" -#define PRIXSIZE "IX" -#else -#define PRIdSIZE "zd" -#define PRIiSIZE "zi" -#define PRIoSIZE "zo" -#define PRIuSIZE "zu" -#define PRIxSIZE "zx" -#define PRIXSIZE "zX" -#endif - -/* Casts 'pointer' to 'type' and issues a compiler warning if the cast changes - * anything other than an outermost "const" or "volatile" qualifier. - * - * The cast to int is present only to suppress an "expression using sizeof - * bool" warning from "sparse" (see - * http://permalink.gmane.org/gmane.comp.parsers.sparse/2967). */ -#define CONST_CAST(TYPE, POINTER) \ - ((void)sizeof((int)((POINTER) == (TYPE)(POINTER))), (TYPE)(POINTER)) - -#define __ARRAY_SIZE_NOCHECK(ARRAY) (sizeof(ARRAY) / sizeof((ARRAY)[0])) -#ifdef __GNUC__ -/* return 0 for array types, 1 otherwise */ -#define __ARRAY_CHECK(ARRAY) \ - !__builtin_types_compatible_p(typeof(ARRAY), typeof(&ARRAY[0])) - -/* compile-time fail if not array */ -#define __ARRAY_FAIL(ARRAY) (sizeof(char[-2 * !__ARRAY_CHECK(ARRAY)])) -#define __ARRAY_SIZE(ARRAY) \ - __builtin_choose_expr(__ARRAY_CHECK(ARRAY), __ARRAY_SIZE_NOCHECK(ARRAY), \ - __ARRAY_FAIL(ARRAY)) -#else -#define __ARRAY_SIZE(ARRAY) __ARRAY_SIZE_NOCHECK(ARRAY) -#endif - -#ifdef __CHECKER__ -#define BUILD_ASSERT(EXPR) ((void)0) -#define BUILD_ASSERT_DECL(EXPR) extern int(*build_assert(void))[1] -#elif !defined(__cplusplus) -/* Build-time assertion building block. */ -#define BUILD_ASSERT__(EXPR) \ - sizeof(struct { unsigned int build_assert_failed : (EXPR) ? 1 : -1; }) - -/* Build-time assertion for use in a statement context. */ -#define BUILD_ASSERT(EXPR) (void)BUILD_ASSERT__(EXPR) - -/* Build-time assertion for use in a declaration context. */ -#define BUILD_ASSERT_DECL(EXPR) \ - extern int(*build_assert(void))[BUILD_ASSERT__(EXPR)] -#else /* __cplusplus */ -#define BUILD_ASSERT static_assert -#define BUILD_ASSERT_DECL static_assert -#endif /* __cplusplus */ - -/* Returns the number of elements in ARRAY. */ -#define ARRAY_SIZE(ARRAY) __ARRAY_SIZE(ARRAY) - -/* Expands to a string that looks like ":", e.g. "tmp.c:10". - * - * See http://c-faq.com/ansi/stringize.html for an explanation of STRINGIZE and - * STRINGIZE2. */ -#define SOURCE_LOCATOR __FILE__ ":" STRINGIZE(__LINE__) -#define STRINGIZE(ARG) STRINGIZE2(ARG) -#define STRINGIZE2(ARG) #ARG - -void *xzalloc(size_t) MALLOC_LIKE; -char *xstrdup(const char *) MALLOC_LIKE; -void out_of_memory(); -void *xcalloc(size_t count, size_t size); -void *xmalloc(size_t size); -void *xzalloc(size_t size); -char *xmemdup0(const char *p_, size_t length); -char *xstrdup(const char *s); - -/********** ofpbuf.h **********/ -struct ofpbuf; - -struct ofpbuf *ofpbuf_new(size_t size); -void ofpbuf_free(struct ofpbuf *p); -void *ofpbuf_base(struct ofpbuf *p); -ssize_t ofpbuf_size(struct ofpbuf *p); - -/********** log.h **********/ -// void VLOG_WARN(const char *format, ...); -// void VLOG_DBG(const char *format, ...); -// void VLOG_INFO(const char *format, ...); - -/********** ovs-thread.h **********/ -void ovs_mutex_init(pthread_mutex_t *m); -void ovs_mutex_lock(pthread_mutex_t *m); -void ovs_mutex_unlock(pthread_mutex_t *m); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/services/pcn-bridge/external/stp/log.cpp b/src/services/pcn-bridge/external/stp/log.cpp deleted file mode 100644 index 37ffe1127..000000000 --- a/src/services/pcn-bridge/external/stp/log.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2017 The Polycube Authors - * - * 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 "log.h" - -#include -#include -#include - -#include -#include - -static std::shared_ptr l = - spdlog::get("pcn-bridge") == nullptr - ? spdlog::stdout_logger_mt("pcn-bridge") - : spdlog::get("pcn-bridge"); - -/********** log.c **********/ -void VLOG_WARN(const char *format, ...) { - char buf[100]; - va_list arglist; - va_start(arglist, format); - vsnprintf(buf, sizeof(buf), format, arglist); - va_end(arglist); - l->warn(buf); -} - -void VLOG_DBG(const char *format, ...) { - char buf[100]; - va_list arglist; - va_start(arglist, format); - vsnprintf(buf, sizeof(buf), format, arglist); - va_end(arglist); - l->debug(buf); -} - -void VLOG_INFO(const char *format, ...) { - char buf[100]; - va_list arglist; - va_start(arglist, format); - vsnprintf(buf, sizeof(buf), format, arglist); - va_end(arglist); - l->info(buf); -} diff --git a/src/services/pcn-bridge/external/stp/log.h b/src/services/pcn-bridge/external/stp/log.h deleted file mode 100644 index 86d044a9b..000000000 --- a/src/services/pcn-bridge/external/stp/log.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2017 The Polycube Authors - * - * 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. - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -void VLOG_WARN(const char *format, ...); -void VLOG_DBG(const char *format, ...); -void VLOG_INFO(const char *format, ...); - -#ifdef __cplusplus -} -#endif diff --git a/src/services/pcn-bridge/external/stp/stp.c b/src/services/pcn-bridge/external/stp/stp.c deleted file mode 100644 index 918bfea30..000000000 --- a/src/services/pcn-bridge/external/stp/stp.c +++ /dev/null @@ -1,1465 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc. - * - * 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. - */ - -/* Based on sample implementation in 802.1D-1998. Above copyright and license - * applies to all modifications. */ - -#include "stp.h" -#include -#include -#include -#include -#include -#include -#include - -#define STP_PROTOCOL_ID 0x0000 -#define STP_PROTOCOL_VERSION 0x00 -#define STP_TYPE_CONFIG 0x00 -#define STP_TYPE_TCN 0x80 - -OVS_PACKED(struct eth_header { - uint8_t eth_dst[ETH_ADDR_LEN]; - uint8_t eth_src[ETH_ADDR_LEN]; - ovs_be16 eth_type; -}); -BUILD_ASSERT_DECL(ETH_HEADER_LEN == sizeof(struct eth_header)); - -OVS_PACKED(struct llc_header { - uint8_t llc_dsap; - uint8_t llc_ssap; - uint8_t llc_cntl; -}); - -static const uint8_t eth_addr_stp[ETH_ADDR_LEN] = {0x01, 0x80, 0xC2, - 0x00, 0x00, 0x00}; - -// TODO: is it ok to use a different mutex for each instance? -static pthread_mutex_t mutex; - -OVS_PACKED(struct stp_bpdu_header { - ovs_be16 protocol_id; /* STP_PROTOCOL_ID. */ - uint8_t protocol_version; /* STP_PROTOCOL_VERSION. */ - uint8_t bpdu_type; /* One of STP_TYPE_*. */ -}); -BUILD_ASSERT_DECL(sizeof(struct stp_bpdu_header) == 4); - -enum stp_config_bpdu_flags { - STP_CONFIG_TOPOLOGY_CHANGE_ACK = 0x80, - STP_CONFIG_TOPOLOGY_CHANGE = 0x01 -}; - -OVS_PACKED(struct stp_config_bpdu { - struct stp_bpdu_header header; /* Type STP_TYPE_CONFIG. */ - uint8_t flags; /* STP_CONFIG_* flags. */ - ovs_be64 root_id; /* 8.5.1.1: Bridge believed to be root. */ - ovs_be32 root_path_cost; /* 8.5.1.2: Cost of path to root. */ - ovs_be64 bridge_id; /* 8.5.1.3: ID of transmitting bridge. */ - ovs_be16 port_id; /* 8.5.1.4: Port transmitting the BPDU. */ - ovs_be16 message_age; /* 8.5.1.5: Age of BPDU at tx time. */ - ovs_be16 max_age; /* 8.5.1.6: Timeout for received data. */ - ovs_be16 hello_time; /* 8.5.1.7: Time between BPDU generation. */ - ovs_be16 forward_delay; /* 8.5.1.8: State progression delay. */ -}); -BUILD_ASSERT_DECL(sizeof(struct stp_config_bpdu) == 35); - -OVS_PACKED(struct stp_tcn_bpdu { - struct stp_bpdu_header header; /* Type STP_TYPE_TCN. */ -}); -BUILD_ASSERT_DECL(sizeof(struct stp_tcn_bpdu) == 4); - -struct stp_timer { - bool active; /* Timer in use? */ - int value; /* Current value of timer, counting up. */ -}; - -struct stp_port { - struct stp *stp; - char *port_name; /* Human-readable name for log messages. */ - void *aux; /* Auxiliary data the user may retrieve. */ - int port_id; /* 8.5.5.1: Unique port identifier. */ - enum stp_state state; /* 8.5.5.2: Current state. */ - int path_cost; /* 8.5.5.3: Cost of tx/rx on this port. */ - stp_identifier designated_root; /* 8.5.5.4. */ - int designated_cost; /* 8.5.5.5: Path cost to root on port. */ - stp_identifier designated_bridge; /* 8.5.5.6. */ - int designated_port; /* 8.5.5.7: Port to send config msgs on. */ - bool topology_change_ack; /* 8.5.5.8: Flag for next config BPDU. */ - bool config_pending; /* 8.5.5.9: Send BPDU when hold expires? */ - bool change_detection_enabled; /* 8.5.5.10: Detect topology changes? */ - - struct stp_timer message_age_timer; /* 8.5.6.1: Age of received info. */ - struct stp_timer forward_delay_timer; /* 8.5.6.2: State change timer. */ - struct stp_timer hold_timer; /* 8.5.6.3: BPDU rate limit timer. */ - - int tx_count; /* Number of BPDUs transmitted. */ - int rx_count; /* Number of valid BPDUs received. */ - int error_count; /* Number of bad BPDUs received. */ - - bool state_changed; -}; - -struct stp { - /* Static bridge data. */ - char *name; /* Human-readable name for log messages. */ - stp_identifier bridge_id; /* 8.5.3.7: This bridge. */ - int max_age; /* 8.5.3.4: Time to drop received data. */ - int hello_time; /* 8.5.3.5: Time between sending BPDUs. */ - int forward_delay; /* 8.5.3.6: Delay between state changes. */ - int bridge_max_age; /* 8.5.3.8: max_age when we're root. */ - int bridge_hello_time; /* 8.5.3.9: hello_time as root. */ - int bridge_forward_delay; /* 8.5.3.10: forward_delay as root. */ - int rq_max_age; /* User-requested max age, in ms. */ - int rq_hello_time; /* User-requested hello time, in ms. */ - int rq_forward_delay; /* User-requested forward delay, in ms. */ - int elapsed_remainder; /* Left-over msecs from last stp_tick(). */ - - /* Dynamic bridge data. */ - stp_identifier designated_root; /* 8.5.3.1: Bridge believed to be root. */ - unsigned int root_path_cost; /* 8.5.3.2: Cost of path to root. */ - struct stp_port *root_port; /* 8.5.3.3: Lowest cost port to root. */ - bool topology_change_detected; /* 8.5.3.11: Detected a topology change? */ - bool topology_change; /* 8.5.3.12: Received topology change? */ - - /* Bridge timers. */ - struct stp_timer hello_timer; /* 8.5.4.1: Hello timer. */ - struct stp_timer tcn_timer; /* 8.5.4.2: Topology change timer. */ - struct stp_timer topology_change_timer; /* 8.5.4.3. */ - - /* Ports. */ - struct stp_port ports[STP_MAX_PORTS]; - - /* Interface to client. */ - bool fdb_needs_flush; /* MAC learning tables needs flushing. */ - struct stp_port *first_changed_port; - void (*send_bpdu)(struct ofpbuf *bpdu, int port_no, void *aux); - void *aux; - - // struct ovs_refcount ref_cnt; -}; - -#define FOR_EACH_ENABLED_PORT(PORT, STP) \ - for ((PORT) = stp_next_enabled_port((STP), (STP)->ports); (PORT); \ - (PORT) = stp_next_enabled_port((STP), (PORT) + 1)) -static struct stp_port *stp_next_enabled_port(const struct stp *stp, - const struct stp_port *port) -/*OVS_REQUIRES(mutex)*/ -{ - for (; port < &stp->ports[ARRAY_SIZE(stp->ports)]; port++) { - if (port->state != STP_DISABLED) { - return CONST_CAST(struct stp_port *, port); - } - } - return NULL; -} - -#define MESSAGE_AGE_INCREMENT 1 - -static void stp_transmit_config(struct stp_port *) /*OVS_REQUIRES(mutex)*/; -static bool stp_supersedes_port_info(const struct stp_port *, - const struct stp_config_bpdu *) - /*OVS_REQUIRES(mutex)*/; -static void stp_record_config_information(struct stp_port *, - const struct stp_config_bpdu *) - /*OVS_REQUIRES(mutex)*/; -static void stp_record_config_timeout_values(struct stp *, - const struct stp_config_bpdu *) - /*OVS_REQUIRES(mutex)*/; -static bool stp_is_designated_port(const struct stp_port *) - /*OVS_REQUIRES(mutex)*/; -static void stp_config_bpdu_generation(struct stp *) /*OVS_REQUIRES(mutex)*/; -static void stp_transmit_tcn(struct stp *) /*OVS_REQUIRES(mutex)*/; -static void stp_configuration_update(struct stp *) /*OVS_REQUIRES(mutex)*/; -static bool stp_supersedes_root( - const struct stp_port *root, - const struct stp_port *) /*OVS_REQUIRES(mutex)*/; -static void stp_root_selection(struct stp *) /*OVS_REQUIRES(mutex)*/; -static void stp_designated_port_selection(struct stp *) /*OVS_REQUIRES(mutex)*/; -static void stp_become_designated_port(struct stp_port *) - /*OVS_REQUIRES(mutex)*/; -static void stp_port_state_selection(struct stp *) /*OVS_REQUIRES(mutex)*/; -static void stp_make_forwarding(struct stp_port *) /*OVS_REQUIRES(mutex)*/; -static void stp_make_blocking(struct stp_port *) /*OVS_REQUIRES(mutex)*/; -static void stp_set_port_state(struct stp_port *, enum stp_state) - /*OVS_REQUIRES(mutex)*/; -static void stp_topology_change_detection(struct stp *) /*OVS_REQUIRES(mutex)*/; -static void stp_topology_change_acknowledged(struct stp *) - /*OVS_REQUIRES(mutex)*/; -static void stp_acknowledge_topology_change(struct stp_port *) - /*OVS_REQUIRES(mutex)*/; -static void stp_received_config_bpdu(struct stp *, struct stp_port *, - const struct stp_config_bpdu *) - /*OVS_REQUIRES(mutex)*/; -static void stp_received_tcn_bpdu(struct stp *, struct stp_port *) - /*OVS_REQUIRES(mutex)*/; -static void stp_hello_timer_expiry(struct stp *) /*OVS_REQUIRES(mutex)*/; -static void stp_message_age_timer_expiry(struct stp_port *) - /*OVS_REQUIRES(mutex)*/; -static bool stp_is_designated_for_some_port(const struct stp *) - /*OVS_REQUIRES(mutex)*/; -static void stp_forward_delay_timer_expiry(struct stp_port *) - /*OVS_REQUIRES(mutex)*/; -static void stp_tcn_timer_expiry(struct stp *) /*OVS_REQUIRES(mutex)*/; -static void stp_topology_change_timer_expiry(struct stp *) - /*OVS_REQUIRES(mutex)*/; -static void stp_hold_timer_expiry(struct stp_port *) /*OVS_REQUIRES(mutex)*/; -static void stp_initialize_port(struct stp_port *, enum stp_state) - /*OVS_REQUIRES(mutex)*/; -static void stp_become_root_bridge(struct stp *) /*OVS_REQUIRES(mutex)*/; -static void stp_update_bridge_timers(struct stp *) /*OVS_REQUIRES(mutex)*/; - -static int clamp(int x, int min, int max); -static int ms_to_timer(int ms); -static int timer_to_ms(int timer); -static void stp_start_timer(struct stp_timer *, int value); -static void stp_stop_timer(struct stp_timer *); -static bool stp_timer_expired(struct stp_timer *, int elapsed, int timeout); - -static void stp_send_bpdu(struct stp_port *, const void *, size_t) - /*OVS_REQUIRES(mutex)*/; - -void stp_init(void) { - ovs_mutex_init(&mutex); -} - -/* Creates and returns a new STP instance that initially has no ports enabled. - * - * 'bridge_id' should be a 48-bit MAC address as returned by - * eth_addr_to_uint64(). 'bridge_id' may also have a priority value in its top - * 16 bits; if those bits are set to 0, STP_DEFAULT_BRIDGE_PRIORITY is used. - * (This priority may be changed with stp_set_bridge_priority().) - * - * When the bridge needs to send out a BPDU, it calls 'send_bpdu'. This - * callback may be called from stp_tick() or stp_received_bpdu(). The - * arguments to 'send_bpdu' are an STP BPDU encapsulated in 'bpdu', - * the spanning tree port number 'port_no' that should transmit the - * packet, and auxiliary data to be passed to the callback in 'aux'. - */ -struct stp *stp_create(const char *name, stp_identifier bridge_id, - void (*send_bpdu)(struct ofpbuf *bpdu, int port_no, - void *aux), - void *aux) { - static pthread_once_t once = PTHREAD_ONCE_INIT; - pthread_once(&once, stp_init); - - struct stp *stp; - struct stp_port *p; - - ovs_mutex_lock(&mutex); - stp = xzalloc(sizeof *stp); - stp->name = xstrdup(name); - stp->bridge_id = bridge_id; - if (!(stp->bridge_id >> 48)) { - stp->bridge_id |= (uint64_t)STP_DEFAULT_BRIDGE_PRIORITY << 48; - } - - stp->rq_max_age = STP_DEFAULT_MAX_AGE; - stp->rq_hello_time = STP_DEFAULT_HELLO_TIME; - stp->rq_forward_delay = STP_DEFAULT_FWD_DELAY; - stp_update_bridge_timers(stp); - stp->max_age = stp->bridge_max_age; - stp->hello_time = stp->bridge_hello_time; - stp->forward_delay = stp->bridge_forward_delay; - - stp->designated_root = stp->bridge_id; - stp->root_path_cost = 0; - stp->root_port = NULL; - stp->topology_change_detected = false; - stp->topology_change = false; - - stp_stop_timer(&stp->tcn_timer); - stp_stop_timer(&stp->topology_change_timer); - stp_start_timer(&stp->hello_timer, 0); - - stp->send_bpdu = send_bpdu; - stp->aux = aux; - - stp->first_changed_port = &stp->ports[ARRAY_SIZE(stp->ports)]; - for (p = stp->ports; p < &stp->ports[ARRAY_SIZE(stp->ports)]; p++) { - p->stp = stp; - p->port_id = (stp_port_no(p) + 1) | (STP_DEFAULT_PORT_PRIORITY << 8); - p->path_cost = 19; /* Recommended default for 100 Mb/s link. */ - stp_initialize_port(p, STP_DISABLED); - } - // ovs_refcount_init(&stp->ref_cnt); - - // list_push_back(all_stps, &stp->node); - ovs_mutex_unlock(&mutex); - return stp; -} - -struct stp *stp_ref(const struct stp *stp_) { - struct stp *stp = CONST_CAST(struct stp *, stp_); - if (stp) { - // ovs_refcount_ref(&stp->ref_cnt); - } - return stp; -} - -/* Destroys 'stp'. */ -void stp_unref(struct stp *stp) { - // if (stp && ovs_refcount_unref_relaxed(&stp->ref_cnt) == 1) { - // size_t i; - // - // ovs_mutex_lock(&mutex); - // //list_remove(&stp->node); - // ovs_mutex_unlock(&mutex); - // free(stp->name); - // - // for (i = 0; i < STP_MAX_PORTS; i++) { - // free(stp->ports[i].port_name); - // } - // free(stp); - //} - free(stp); -} - -/* Runs 'stp' given that 'ms' milliseconds have passed. */ -void stp_tick(struct stp *stp, int ms) { - struct stp_port *p; - int elapsed; - - ovs_mutex_lock(&mutex); - /* Convert 'ms' to STP timer ticks. Preserve any leftover milliseconds - * from previous stp_tick() calls so that we don't lose STP ticks when we - * are called too frequently. */ - ms = clamp(ms, 0, INT_MAX - 1000) + stp->elapsed_remainder; - elapsed = ms_to_timer(ms); - stp->elapsed_remainder = ms - timer_to_ms(elapsed); - if (!elapsed) { - goto out; - } - - if (stp_timer_expired(&stp->hello_timer, elapsed, stp->hello_time)) { - stp_hello_timer_expiry(stp); - } - if (stp_timer_expired(&stp->tcn_timer, elapsed, stp->bridge_hello_time)) { - stp_tcn_timer_expiry(stp); - } - if (stp_timer_expired(&stp->topology_change_timer, elapsed, - stp->max_age + stp->forward_delay)) { - stp_topology_change_timer_expiry(stp); - } - FOR_EACH_ENABLED_PORT(p, stp) { - if (stp_timer_expired(&p->message_age_timer, elapsed, stp->max_age)) { - stp_message_age_timer_expiry(p); - } - } - FOR_EACH_ENABLED_PORT(p, stp) { - if (stp_timer_expired(&p->forward_delay_timer, elapsed, - stp->forward_delay)) { - stp_forward_delay_timer_expiry(p); - } - if (stp_timer_expired(&p->hold_timer, elapsed, ms_to_timer(1000))) { - stp_hold_timer_expiry(p); - } - } - -out: - ovs_mutex_unlock(&mutex); -} - -static void set_bridge_id(struct stp *stp, stp_identifier new_bridge_id) -/*OVS_REQUIRES(mutex)*/ -{ - if (new_bridge_id != stp->bridge_id) { - bool root; - struct stp_port *p; - - root = stp_is_root_bridge(stp); - FOR_EACH_ENABLED_PORT(p, stp) { - if (stp_is_designated_port(p)) { - p->designated_bridge = new_bridge_id; - } - } - stp->bridge_id = new_bridge_id; - stp_configuration_update(stp); - stp_port_state_selection(stp); - if (stp_is_root_bridge(stp) && !root) { - stp_become_root_bridge(stp); - } - } -} - -void stp_set_bridge_id(struct stp *stp, stp_identifier bridge_id) { - const uint64_t mac_bits = (UINT64_C(1) << 48) - 1; - const uint64_t pri_bits = ~mac_bits; - ovs_mutex_lock(&mutex); - set_bridge_id(stp, (stp->bridge_id & pri_bits) | (bridge_id & mac_bits)); - ovs_mutex_unlock(&mutex); -} - -void stp_set_bridge_priority(struct stp *stp, uint16_t new_priority) { - const uint64_t mac_bits = (UINT64_C(1) << 48) - 1; - ovs_mutex_lock(&mutex); - set_bridge_id(stp, - ((stp->bridge_id & mac_bits) | ((uint64_t)new_priority << 48))); - ovs_mutex_unlock(&mutex); -} - -/* Sets the desired hello time for 'stp' to 'ms', in milliseconds. The actual - * hello time is clamped to the range of 1 to 10 seconds and subject to the - * relationship (bridge_max_age >= 2 * (bridge_hello_time + 1 s)). The bridge - * hello time is only used when 'stp' is the root bridge. */ -void stp_set_hello_time(struct stp *stp, int ms) { - ovs_mutex_lock(&mutex); - stp->rq_hello_time = ms; - stp_update_bridge_timers(stp); - ovs_mutex_unlock(&mutex); -} - -/* Sets the desired max age for 'stp' to 'ms', in milliseconds. The actual max - * age is clamped to the range of 6 to 40 seconds and subject to the - * relationships (2 * (bridge_forward_delay - 1 s) >= bridge_max_age) and - * (bridge_max_age >= 2 * (bridge_hello_time + 1 s)). The bridge max age is - * only used when 'stp' is the root bridge. */ -void stp_set_max_age(struct stp *stp, int ms) { - ovs_mutex_lock(&mutex); - stp->rq_max_age = ms; - stp_update_bridge_timers(stp); - ovs_mutex_unlock(&mutex); -} - -/* Sets the desired forward delay for 'stp' to 'ms', in milliseconds. The - * actual forward delay is clamped to the range of 4 to 30 seconds and subject - * to the relationship (2 * (bridge_forward_delay - 1 s) >= bridge_max_age). - * The bridge forward delay is only used when 'stp' is the root bridge. */ -void stp_set_forward_delay(struct stp *stp, int ms) { - ovs_mutex_lock(&mutex); - stp->rq_forward_delay = ms; - stp_update_bridge_timers(stp); - ovs_mutex_unlock(&mutex); -} - -/* Returns the name given to 'stp' in the call to stp_create(). */ -const char *stp_get_name(const struct stp *stp) { - char *name; - - ovs_mutex_lock(&mutex); - name = stp->name; - ovs_mutex_unlock(&mutex); - return name; -} - -/* Returns the bridge ID for 'stp'. */ -stp_identifier stp_get_bridge_id(const struct stp *stp) { - stp_identifier bridge_id; - - ovs_mutex_lock(&mutex); - bridge_id = stp->bridge_id; - ovs_mutex_unlock(&mutex); - return bridge_id; -} - -/* Returns the bridge ID of the bridge currently believed to be the root. */ -stp_identifier stp_get_designated_root(const struct stp *stp) { - stp_identifier designated_root; - - ovs_mutex_lock(&mutex); - designated_root = stp->designated_root; - ovs_mutex_unlock(&mutex); - return designated_root; -} - -/* Returns true if 'stp' believes itself to the be root of the spanning tree, - * false otherwise. */ -bool stp_is_root_bridge(const struct stp *stp) { - bool is_root; - - ovs_mutex_lock(&mutex); - is_root = stp->bridge_id == stp->designated_root; - ovs_mutex_unlock(&mutex); - return is_root; -} - -/* Returns the cost of the path from 'stp' to the root of the spanning tree. */ -int stp_get_root_path_cost(const struct stp *stp) { - int cost; - - ovs_mutex_lock(&mutex); - cost = stp->root_path_cost; - ovs_mutex_unlock(&mutex); - return cost; -} - -/* Returns the bridge hello time, in ms. The returned value is not necessarily - * the value passed to stp_set_hello_time(): it is clamped to the valid range - * and quantized to the STP timer resolution. */ -int stp_get_hello_time(const struct stp *stp) { - int time; - - ovs_mutex_lock(&mutex); - time = timer_to_ms(stp->bridge_hello_time); - ovs_mutex_unlock(&mutex); - return time; -} - -/* Returns the bridge max age, in ms. The returned value is not necessarily - * the value passed to stp_set_max_age(): it is clamped to the valid range, - * quantized to the STP timer resolution, and adjusted to match the constraints - * due to the hello time. */ -int stp_get_max_age(const struct stp *stp) { - int time; - - ovs_mutex_lock(&mutex); - time = timer_to_ms(stp->bridge_max_age); - ovs_mutex_unlock(&mutex); - return time; -} - -/* Returns the bridge forward delay, in ms. The returned value is not - * necessarily the value passed to stp_set_forward_delay(): it is clamped to - * the valid range, quantized to the STP timer resolution, and adjusted to - * match the constraints due to the forward delay. */ -int stp_get_forward_delay(const struct stp *stp) { - int time; - - ovs_mutex_lock(&mutex); - time = timer_to_ms(stp->bridge_forward_delay); - ovs_mutex_unlock(&mutex); - return time; -} - -/* Returns true if something has happened to 'stp' which necessitates flushing - * the client's MAC learning table. Calling this function resets 'stp' so that - * future calls will return false until flushing is required again. */ -bool stp_check_and_reset_fdb_flush(struct stp *stp) { - bool needs_flush; - - ovs_mutex_lock(&mutex); - needs_flush = stp->fdb_needs_flush; - stp->fdb_needs_flush = false; - ovs_mutex_unlock(&mutex); - return needs_flush; -} - -/* Returns the port in 'stp' with index 'port_no', which must be between 0 and - * STP_MAX_PORTS. */ -struct stp_port *stp_get_port(struct stp *stp, int port_no) { - struct stp_port *port; - - ovs_mutex_lock(&mutex); - ovs_assert(port_no >= 0 && port_no < ARRAY_SIZE(stp->ports)); - port = &stp->ports[port_no]; - ovs_mutex_unlock(&mutex); - return port; -} - -/* Returns the port connecting 'stp' to the root bridge, or a null pointer if - * there is no such port. */ -struct stp_port *stp_get_root_port(struct stp *stp) { - struct stp_port *port; - - ovs_mutex_lock(&mutex); - port = stp->root_port; - ovs_mutex_unlock(&mutex); - return port; -} - -/* Finds a port whose state has changed. If successful, stores the port whose - * state changed in '*portp' and returns true. If no port has changed, stores - * NULL in '*portp' and returns false. */ -bool stp_get_changed_port(struct stp *stp, struct stp_port **portp) { - struct stp_port *end, *p; - bool changed = false; - - ovs_mutex_lock(&mutex); - end = &stp->ports[ARRAY_SIZE(stp->ports)]; - for (p = stp->first_changed_port; p < end; p++) { - if (p->state_changed) { - p->state_changed = false; - stp->first_changed_port = p + 1; - *portp = p; - changed = true; - goto out; - } - } - stp->first_changed_port = end; - *portp = NULL; - -out: - ovs_mutex_unlock(&mutex); - return changed; -} - -/* Returns the name for the given 'state' (for use in debugging and log - * messages). */ -const char *stp_state_name(enum stp_state state) { - switch (state) { - case STP_DISABLED: - return "disabled"; - case STP_LISTENING: - return "listening"; - case STP_LEARNING: - return "learning"; - case STP_FORWARDING: - return "forwarding"; - case STP_BLOCKING: - return "blocking"; - default: - OVS_NOT_REACHED(); - } -} - -/* Returns true if 'state' is one in which packets received on a port should - * be forwarded, false otherwise. - * - * Returns true if 'state' is STP_DISABLED, since presumably in that case the - * port should still work, just not have STP applied to it. */ -bool stp_forward_in_state(enum stp_state state) { - return (state & (STP_DISABLED | STP_FORWARDING)) != 0; -} - -/* Returns true if 'state' is one in which MAC learning should be done on - * packets received on a port, false otherwise. - * - * Returns true if 'state' is STP_DISABLED, since presumably in that case the - * port should still work, just not have STP applied to it. */ -bool stp_learn_in_state(enum stp_state state) { - return (state & (STP_DISABLED | STP_LEARNING | STP_FORWARDING)) != 0; -} - -/* Returns true if 'state' is one in which bpdus should be forwarded on a - * port, false otherwise. - * - * Returns true if 'state' is STP_DISABLED, since in that case the port does - * not generate the bpdu and should just forward it (e.g. patch port on pif - * bridge). */ -bool stp_should_forward_bpdu(enum stp_state state) { - return (state & - (STP_DISABLED | STP_LISTENING | STP_LEARNING | STP_FORWARDING)) != 0; -} - -/* Returns the name for the given 'role' (for use in debugging and log - * messages). */ -const char *stp_role_name(enum stp_role role) { - switch (role) { - case STP_ROLE_ROOT: - return "root"; - case STP_ROLE_DESIGNATED: - return "designated"; - case STP_ROLE_ALTERNATE: - return "alternate"; - case STP_ROLE_DISABLED: - return "disabled"; - default: - OVS_NOT_REACHED(); - } -} - -/* Notifies the STP entity that bridge protocol data unit 'bpdu', which is - * 'bpdu_size' bytes in length, was received on port 'p'. - * - * This function may call the 'send_bpdu' function provided to stp_create(). */ -void stp_received_bpdu(struct stp_port *p, const void *bpdu, size_t bpdu_size) { - struct stp *stp = p->stp; - const struct stp_bpdu_header *header; - - ovs_mutex_lock(&mutex); - if (p->state == STP_DISABLED) { - goto out; - } - - if (bpdu_size < sizeof(struct stp_bpdu_header)) { - VLOG_WARN("[%s]: received runt %" PRIuSIZE "-byte BPDU", stp->name, - bpdu_size); - p->error_count++; - goto out; - } - - header = bpdu; - if (header->protocol_id != htons(STP_PROTOCOL_ID)) { - VLOG_WARN("[%s]: received BPDU with unexpected protocol ID %" PRIu16, - stp->name, ntohs(header->protocol_id)); - p->error_count++; - goto out; - } - if (header->protocol_version != STP_PROTOCOL_VERSION) { - VLOG_DBG("[%s]: received BPDU with unexpected protocol version %" PRIu8, - stp->name, header->protocol_version); - } - - switch (header->bpdu_type) { - case STP_TYPE_CONFIG: - if (bpdu_size < sizeof(struct stp_config_bpdu)) { - VLOG_WARN("[%s]: received config BPDU with invalid size %" PRIuSIZE, - stp->name, bpdu_size); - p->error_count++; - goto out; - } - stp_received_config_bpdu(stp, p, bpdu); - break; - - case STP_TYPE_TCN: - if (bpdu_size != sizeof(struct stp_tcn_bpdu)) { - VLOG_WARN("[%s]: received TCN BPDU with invalid size %" PRIuSIZE, - stp->name, bpdu_size); - p->error_count++; - goto out; - } - stp_received_tcn_bpdu(stp, p); - break; - - default: - VLOG_WARN("[%s]: received BPDU of unexpected type %" PRIu8, stp->name, - header->bpdu_type); - p->error_count++; - goto out; - } - p->rx_count++; - -out: - ovs_mutex_unlock(&mutex); -} - -/* Returns the STP entity in which 'p' is nested. */ -struct stp *stp_port_get_stp(struct stp_port *p) { - struct stp *stp; - - ovs_mutex_lock(&mutex); - stp = p->stp; - ovs_mutex_unlock(&mutex); - return stp; -} - -void stp_port_set_name(struct stp_port *p, const char *name) { - char *old; - - ovs_mutex_lock(&mutex); - old = p->port_name; - p->port_name = xstrdup(name); - free(old); - ovs_mutex_unlock(&mutex); -} - -/* Sets the 'aux' member of 'p'. - * - * The 'aux' member will be reset to NULL when stp_port_disable() is - * called or stp_port_enable() is called when the port is in a Disabled - * state. */ -void stp_port_set_aux(struct stp_port *p, void *aux) { - ovs_mutex_lock(&mutex); - p->aux = aux; - ovs_mutex_unlock(&mutex); -} - -/* Returns the 'aux' member of 'p'. */ -void *stp_port_get_aux(struct stp_port *p) { - void *aux; - - ovs_mutex_lock(&mutex); - aux = p->aux; - ovs_mutex_unlock(&mutex); - return aux; -} - -/* Returns the index of port 'p' within its bridge. */ -int stp_port_no(const struct stp_port *p) { - struct stp *stp; - int index; - - ovs_mutex_lock(&mutex); - stp = p->stp; - ovs_assert(p >= stp->ports && p < &stp->ports[ARRAY_SIZE(stp->ports)]); - index = p - p->stp->ports; - ovs_mutex_unlock(&mutex); - return index; -} - -/* Returns the port ID for 'p'. */ -int stp_port_get_id(const struct stp_port *p) { - int port_id; - - ovs_mutex_lock(&mutex); - port_id = p->port_id; - ovs_mutex_unlock(&mutex); - return port_id; -} - -/* Returns the state of port 'p'. */ -enum stp_state stp_port_get_state(const struct stp_port *p) { - enum stp_state state; - - ovs_mutex_lock(&mutex); - state = p->state; - ovs_mutex_unlock(&mutex); - return state; -} - -/* Returns the role of port 'p'. */ -enum stp_role stp_port_get_role(const struct stp_port *p) { - struct stp_port *root_port; - enum stp_role role; - - ovs_mutex_lock(&mutex); - root_port = p->stp->root_port; - if (root_port && root_port->port_id == p->port_id) { - role = STP_ROLE_ROOT; - } else if (stp_is_designated_port(p)) { - role = STP_ROLE_DESIGNATED; - } else if (p->state == STP_DISABLED) { - role = STP_ROLE_DISABLED; - } else { - role = STP_ROLE_ALTERNATE; - } - ovs_mutex_unlock(&mutex); - return role; -} - -/* Retrieves BPDU transmit and receive counts for 'p'. */ -void stp_port_get_counts(const struct stp_port *p, int *tx_count, int *rx_count, - int *error_count) { - ovs_mutex_lock(&mutex); - *tx_count = p->tx_count; - *rx_count = p->rx_count; - *error_count = p->error_count; - ovs_mutex_unlock(&mutex); -} - -/* Disables STP on port 'p'. */ -void stp_port_disable(struct stp_port *p) { - struct stp *stp; - - ovs_mutex_lock(&mutex); - stp = p->stp; - if (p->state != STP_DISABLED) { - bool root = stp_is_root_bridge(stp); - stp_become_designated_port(p); - stp_set_port_state(p, STP_DISABLED); - p->topology_change_ack = false; - p->config_pending = false; - stp_stop_timer(&p->message_age_timer); - stp_stop_timer(&p->forward_delay_timer); - stp_configuration_update(stp); - stp_port_state_selection(stp); - if (stp_is_root_bridge(stp) && !root) { - stp_become_root_bridge(stp); - } - p->aux = NULL; - } - ovs_mutex_unlock(&mutex); -} - -/* Enables STP on port 'p'. The port will initially be in "blocking" state. */ -void stp_port_enable(struct stp_port *p) { - ovs_mutex_lock(&mutex); - if (p->state == STP_DISABLED) { - stp_initialize_port(p, STP_BLOCKING); - stp_port_state_selection(p->stp); - } - ovs_mutex_unlock(&mutex); -} - -/* Sets the priority of port 'p' to 'new_priority'. Lower numerical values - * are interpreted as higher priorities. */ -void stp_port_set_priority(struct stp_port *p, uint8_t new_priority) { - uint16_t new_port_id; - - ovs_mutex_lock(&mutex); - new_port_id = (p->port_id & 0xff) | (new_priority << 8); - if (p->port_id != new_port_id) { - struct stp *stp = p->stp; - if (stp_is_designated_port(p)) { - p->designated_port = new_port_id; - } - p->port_id = new_port_id; - if (stp->bridge_id == p->designated_bridge && - p->port_id < p->designated_port) { - stp_become_designated_port(p); - stp_port_state_selection(stp); - } - } - ovs_mutex_unlock(&mutex); -} - -/* Convert 'speed' (measured in Mb/s) into the path cost. */ -uint16_t stp_convert_speed_to_cost(unsigned int speed) { - uint16_t ret; - - ovs_mutex_lock(&mutex); - ret = speed >= 10000 - ? 2 /* 10 Gb/s. */ - : speed >= 1000 - ? 4 /* 1 Gb/s. */ - : speed >= 100 - ? 19 /* 100 Mb/s. */ - : speed >= 16 - ? 62 /* 16 Mb/s. */ - : speed >= 10 - ? 100 /* 10 Mb/s. */ - : speed >= 4 ? 250 /* 4 Mb/s. */ - : 19; /* 100 Mb/s (guess). */ - ovs_mutex_unlock(&mutex); - return ret; -} - -/* Sets the path cost of port 'p' to 'path_cost'. Lower values are generally - * used to indicate faster links. Use stp_port_set_speed() to automatically - * generate a default path cost from a link speed. */ -void stp_port_set_path_cost(struct stp_port *p, uint16_t path_cost) { - ovs_mutex_lock(&mutex); - if (p->path_cost != path_cost) { - struct stp *stp = p->stp; - p->path_cost = path_cost; - stp_configuration_update(stp); - stp_port_state_selection(stp); - } - ovs_mutex_unlock(&mutex); -} - -/* Sets the path cost of port 'p' based on 'speed' (measured in Mb/s). */ -void stp_port_set_speed(struct stp_port *p, unsigned int speed) { - stp_port_set_path_cost(p, stp_convert_speed_to_cost(speed)); -} - -/* Enables topology change detection on port 'p'. */ -void stp_port_enable_change_detection(struct stp_port *p) { - p->change_detection_enabled = true; -} - -/* Disables topology change detection on port 'p'. */ -void stp_port_disable_change_detection(struct stp_port *p) { - p->change_detection_enabled = false; -} - -static void stp_transmit_config(struct stp_port *p) /*OVS_REQUIRES(mutex)*/ -{ - struct stp *stp = p->stp; - bool root = stp_is_root_bridge(stp); - if (!root && !stp->root_port) { - return; - } - if (p->hold_timer.active) { - VLOG_DBG("[%s], port: %s, transmit config bpdu pending", stp->name, - p->port_name); - p->config_pending = true; - } else { - struct stp_config_bpdu config; - memset(&config, 0, sizeof config); - config.header.protocol_id = htons(STP_PROTOCOL_ID); - config.header.protocol_version = STP_PROTOCOL_VERSION; - config.header.bpdu_type = STP_TYPE_CONFIG; - config.flags = 0; - if (p->topology_change_ack) { - config.flags |= STP_CONFIG_TOPOLOGY_CHANGE_ACK; - } - if (stp->topology_change) { - config.flags |= STP_CONFIG_TOPOLOGY_CHANGE; - } - config.root_id = htonll(stp->designated_root); - config.root_path_cost = htonl(stp->root_path_cost); - config.bridge_id = htonll(stp->bridge_id); - config.port_id = htons(p->port_id); - if (root) { - config.message_age = htons(0); - } else { - config.message_age = htons(stp->root_port->message_age_timer.value + - MESSAGE_AGE_INCREMENT); - } - config.max_age = htons(stp->max_age); - config.hello_time = htons(stp->hello_time); - config.forward_delay = htons(stp->forward_delay); - if (ntohs(config.message_age) < stp->max_age) { - p->topology_change_ack = false; - p->config_pending = false; - VLOG_DBG("[%s], port: %s, transmit config bpdu", stp->name, p->port_name); - stp_send_bpdu(p, &config, sizeof config); - stp_start_timer(&p->hold_timer, 0); - } - } -} - -static bool stp_supersedes_port_info(const struct stp_port *p, - const struct stp_config_bpdu *config) -/*OVS_REQUIRES(mutex)*/ -{ - if (ntohll(config->root_id) != p->designated_root) { - return ntohll(config->root_id) < p->designated_root; - } else if (ntohl(config->root_path_cost) != p->designated_cost) { - return ntohl(config->root_path_cost) < p->designated_cost; - } else if (ntohll(config->bridge_id) != p->designated_bridge) { - return ntohll(config->bridge_id) < p->designated_bridge; - } else { - return (ntohll(config->bridge_id) != p->stp->bridge_id || - ntohs(config->port_id) <= p->designated_port); - } -} - -static void stp_record_config_information(struct stp_port *p, - const struct stp_config_bpdu *config) -/*OVS_REQUIRES(mutex)*/ -{ - p->designated_root = ntohll(config->root_id); - p->designated_cost = ntohl(config->root_path_cost); - p->designated_bridge = ntohll(config->bridge_id); - p->designated_port = ntohs(config->port_id); - stp_start_timer(&p->message_age_timer, ntohs(config->message_age)); -} - -static void stp_record_config_timeout_values( - struct stp *stp, const struct stp_config_bpdu *config) -/*OVS_REQUIRES(mutex)*/ -{ - stp->max_age = ntohs(config->max_age); - stp->hello_time = ntohs(config->hello_time); - stp->forward_delay = ntohs(config->forward_delay); - stp->topology_change = config->flags & STP_CONFIG_TOPOLOGY_CHANGE; -} - -static bool stp_is_designated_port( - const struct stp_port *p) /*OVS_REQUIRES(mutex)*/ -{ - return (p->designated_bridge == p->stp->bridge_id && - p->designated_port == p->port_id); -} - -static void stp_config_bpdu_generation(struct stp *stp) /*OVS_REQUIRES(mutex)*/ -{ - struct stp_port *p; - - FOR_EACH_ENABLED_PORT(p, stp) { - if (stp_is_designated_port(p)) { - stp_transmit_config(p); - } - } -} - -static void stp_transmit_tcn(struct stp *stp) /*OVS_REQUIRES(mutex)*/ -{ - struct stp_port *p = stp->root_port; - struct stp_tcn_bpdu tcn_bpdu; - - if (!p) { - return; - } - VLOG_DBG("[%s], root port: %s, transmit tcn", stp->name, p->port_name); - tcn_bpdu.header.protocol_id = htons(STP_PROTOCOL_ID); - tcn_bpdu.header.protocol_version = STP_PROTOCOL_VERSION; - tcn_bpdu.header.bpdu_type = STP_TYPE_TCN; - stp_send_bpdu(p, &tcn_bpdu, sizeof tcn_bpdu); -} - -static void stp_configuration_update(struct stp *stp) /*OVS_REQUIRES(mutex)*/ -{ - stp_root_selection(stp); - stp_designated_port_selection(stp); - // seq_change(connectivity_seq_get()); -} - -static bool stp_supersedes_root(const struct stp_port *root, - const struct stp_port *p) -/*OVS_REQUIRES(mutex)*/ -{ - int p_cost = p->designated_cost + p->path_cost; - int root_cost = root->designated_cost + root->path_cost; - - if (p->designated_root != root->designated_root) { - return p->designated_root < root->designated_root; - } else if (p_cost != root_cost) { - return p_cost < root_cost; - } else if (p->designated_bridge != root->designated_bridge) { - return p->designated_bridge < root->designated_bridge; - } else if (p->designated_port != root->designated_port) { - return p->designated_port < root->designated_port; - } else { - return p->port_id < root->port_id; - } -} - -static void stp_root_selection(struct stp *stp) /*OVS_REQUIRES(mutex)*/ -{ - struct stp_port *p, *root; - - root = NULL; - FOR_EACH_ENABLED_PORT(p, stp) { - if (stp_is_designated_port(p) || p->designated_root >= stp->bridge_id) { - continue; - } - if (root && !stp_supersedes_root(root, p)) { - continue; - } - root = p; - } - stp->root_port = root; - if (!root) { - stp->designated_root = stp->bridge_id; - stp->root_path_cost = 0; - } else { - stp->designated_root = root->designated_root; - stp->root_path_cost = root->designated_cost + root->path_cost; - } -} - -static void stp_designated_port_selection( - struct stp *stp) /*OVS_REQUIRES(mutex)*/ -{ - struct stp_port *p; - - FOR_EACH_ENABLED_PORT(p, stp) { - if (stp_is_designated_port(p) || - p->designated_root != stp->designated_root || - stp->root_path_cost < p->designated_cost || - (stp->root_path_cost == p->designated_cost && - (stp->bridge_id < p->designated_bridge || - (stp->bridge_id == p->designated_bridge && - p->port_id <= p->designated_port)))) { - stp_become_designated_port(p); - } - } -} - -static void stp_become_designated_port( - struct stp_port *p) /*OVS_REQUIRES(mutex)*/ -{ - struct stp *stp = p->stp; - p->designated_root = stp->designated_root; - p->designated_cost = stp->root_path_cost; - p->designated_bridge = stp->bridge_id; - p->designated_port = p->port_id; -} - -static void stp_port_state_selection(struct stp *stp) /*OVS_REQUIRES(mutex)*/ -{ - struct stp_port *p; - - FOR_EACH_ENABLED_PORT(p, stp) { - if (p == stp->root_port) { - p->config_pending = false; - p->topology_change_ack = false; - stp_make_forwarding(p); - } else if (stp_is_designated_port(p)) { - stp_stop_timer(&p->message_age_timer); - stp_make_forwarding(p); - } else { - p->config_pending = false; - p->topology_change_ack = false; - stp_make_blocking(p); - } - } -} - -static void stp_make_forwarding(struct stp_port *p) /*OVS_REQUIRES(mutex)*/ -{ - if (p->state == STP_BLOCKING) { - stp_set_port_state(p, STP_LISTENING); - stp_start_timer(&p->forward_delay_timer, 0); - } -} - -static void stp_make_blocking(struct stp_port *p) /*OVS_REQUIRES(mutex)*/ -{ - if (!(p->state & (STP_DISABLED | STP_BLOCKING))) { - if (p->state & (STP_FORWARDING | STP_LEARNING)) { - if (p->change_detection_enabled) { - stp_topology_change_detection(p->stp); - } - } - stp_set_port_state(p, STP_BLOCKING); - stp_stop_timer(&p->forward_delay_timer); - } -} - -static void stp_set_port_state(struct stp_port *p, enum stp_state state) -/*OVS_REQUIRES(mutex)*/ -{ - if (state != p->state && !p->state_changed) { - p->state_changed = true; - if (p < p->stp->first_changed_port) { - p->stp->first_changed_port = p; - } - // seq_change(connectivity_seq_get()); - } - p->state = state; -} - -static void stp_topology_change_detection( - struct stp *stp) /*OVS_REQUIRES(mutex)*/ -{ - // static struct VLOG_rate_limit rl = //VLOG_RATE_LIMIT_INIT(1, 5); - - if (stp_is_root_bridge(stp)) { - stp->topology_change = true; - stp_start_timer(&stp->topology_change_timer, 0); - } else if (!stp->topology_change_detected) { - stp_transmit_tcn(stp); - stp_start_timer(&stp->tcn_timer, 0); - } - stp->fdb_needs_flush = true; - stp->topology_change_detected = true; - // seq_change(connectivity_seq_get()); - VLOG_INFO("[%s]: detected topology change.", stp->name); -} - -static void stp_topology_change_acknowledged( - struct stp *stp) /*OVS_REQUIRES(mutex)*/ -{ - stp->topology_change_detected = false; - stp_stop_timer(&stp->tcn_timer); -} - -static void stp_acknowledge_topology_change( - struct stp_port *p) /*OVS_REQUIRES(mutex)*/ -{ - p->topology_change_ack = true; - stp_transmit_config(p); -} - -static void stp_received_config_bpdu(struct stp *stp, struct stp_port *p, - const struct stp_config_bpdu *config) -/*OVS_REQUIRES(mutex)*/ -{ - if (ntohs(config->message_age) >= ntohs(config->max_age)) { - VLOG_WARN( - "[%s]: received config BPDU with message age (%u) greater " - "than max age (%u)", - stp->name, ntohs(config->message_age), ntohs(config->max_age)); - return; - } - if (p->state != STP_DISABLED) { - bool root = stp_is_root_bridge(stp); - if (stp_supersedes_port_info(p, config)) { - stp_record_config_information(p, config); - stp_configuration_update(stp); - stp_port_state_selection(stp); - if (!stp_is_root_bridge(stp) && root) { - stp_stop_timer(&stp->hello_timer); - if (stp->topology_change_detected) { - stp_stop_timer(&stp->topology_change_timer); - stp_transmit_tcn(stp); - stp_start_timer(&stp->tcn_timer, 0); - } - } - if (p == stp->root_port) { - stp_record_config_timeout_values(stp, config); - stp_config_bpdu_generation(stp); - if (config->flags & STP_CONFIG_TOPOLOGY_CHANGE_ACK) { - stp_topology_change_acknowledged(stp); - } - if (config->flags & STP_CONFIG_TOPOLOGY_CHANGE) { - stp->fdb_needs_flush = true; - } - } - } else if (stp_is_designated_port(p)) { - stp_transmit_config(p); - } - } -} - -static void stp_received_tcn_bpdu(struct stp *stp, struct stp_port *p) -/*OVS_REQUIRES(mutex)*/ -{ - if (p->state != STP_DISABLED) { - if (stp_is_designated_port(p)) { - stp_topology_change_detection(stp); - stp_acknowledge_topology_change(p); - } - } -} - -static void stp_hello_timer_expiry(struct stp *stp) /*OVS_REQUIRES(mutex)*/ -{ - stp_config_bpdu_generation(stp); - stp_start_timer(&stp->hello_timer, 0); -} - -static void stp_message_age_timer_expiry( - struct stp_port *p) /*OVS_REQUIRES(mutex)*/ -{ - struct stp *stp = p->stp; - bool root = stp_is_root_bridge(stp); - - VLOG_DBG("[%s], port: %s, message age timer expired", stp->name, - p->port_name); - stp_become_designated_port(p); - stp_configuration_update(stp); - stp_port_state_selection(stp); - if (stp_is_root_bridge(stp) && !root) { - stp->max_age = stp->bridge_max_age; - stp->hello_time = stp->bridge_hello_time; - stp->forward_delay = stp->bridge_forward_delay; - stp_topology_change_detection(stp); - stp_stop_timer(&stp->tcn_timer); - stp_config_bpdu_generation(stp); - stp_start_timer(&stp->hello_timer, 0); - } -} - -static bool stp_is_designated_for_some_port( - const struct stp *stp) /*OVS_REQUIRES(mutex)*/ -{ - const struct stp_port *p; - - FOR_EACH_ENABLED_PORT(p, stp) { - if (p->designated_bridge == stp->bridge_id) { - return true; - } - } - return false; -} - -static void stp_forward_delay_timer_expiry( - struct stp_port *p) /*OVS_REQUIRES(mutex)*/ -{ - if (p->state == STP_LISTENING) { - stp_set_port_state(p, STP_LEARNING); - stp_start_timer(&p->forward_delay_timer, 0); - } else if (p->state == STP_LEARNING) { - stp_set_port_state(p, STP_FORWARDING); - if (stp_is_designated_for_some_port(p->stp)) { - if (p->change_detection_enabled) { - stp_topology_change_detection(p->stp); - } - } - } -} - -static void stp_tcn_timer_expiry(struct stp *stp) /*OVS_REQUIRES(mutex)*/ -{ - stp_transmit_tcn(stp); - stp_start_timer(&stp->tcn_timer, 0); -} - -static void stp_topology_change_timer_expiry( - struct stp *stp) /*OVS_REQUIRES(mutex)*/ -{ - stp->topology_change_detected = false; - stp->topology_change = false; -} - -static void stp_hold_timer_expiry(struct stp_port *p) /*OVS_REQUIRES(mutex)*/ -{ - if (p->config_pending) { - stp_transmit_config(p); - } -} - -static void stp_initialize_port(struct stp_port *p, enum stp_state state) -/*OVS_REQUIRES(mutex)*/ -{ - ovs_assert(state & (STP_DISABLED | STP_BLOCKING)); - stp_become_designated_port(p); - stp_set_port_state(p, state); - p->topology_change_ack = false; - p->config_pending = false; - p->change_detection_enabled = true; - p->aux = NULL; - stp_stop_timer(&p->message_age_timer); - stp_stop_timer(&p->forward_delay_timer); - stp_stop_timer(&p->hold_timer); - p->tx_count = p->rx_count = p->error_count = 0; -} - -static void stp_become_root_bridge(struct stp *stp) /*OVS_REQUIRES(mutex)*/ -{ - stp->max_age = stp->bridge_max_age; - stp->hello_time = stp->bridge_hello_time; - stp->forward_delay = stp->bridge_forward_delay; - stp_topology_change_detection(stp); - stp_stop_timer(&stp->tcn_timer); - stp_config_bpdu_generation(stp); - stp_start_timer(&stp->hello_timer, 0); -} - -static void stp_start_timer(struct stp_timer *timer, - int value) /*OVS_REQUIRES(mutex)*/ -{ - timer->value = value; - timer->active = true; -} - -static void stp_stop_timer(struct stp_timer *timer) /*OVS_REQUIRES(mutex)*/ -{ - timer->active = false; -} - -static bool stp_timer_expired(struct stp_timer *timer, int elapsed, int timeout) -/*OVS_REQUIRES(mutex)*/ -{ - if (timer->active) { - timer->value += elapsed; - if (timer->value >= timeout) { - timer->active = false; - return true; - } - } - return false; -} - -/* Returns the number of whole STP timer ticks in 'ms' milliseconds. There - * are 256 STP timer ticks per second. */ -static int ms_to_timer(int ms) { - return ms * 0x100 / 1000; -} - -/* Returns the number of whole milliseconds in 'timer' STP timer ticks. There - * are 256 STP timer ticks per second. */ -static int timer_to_ms(int timer) { - return timer * 1000 / 0x100; -} - -static int clamp(int x, int min, int max) { - return x < min ? min : x > max ? max : x; -} - -static void stp_update_bridge_timers(struct stp *stp) /*OVS_REQUIRES(mutex)*/ -{ - int ht, ma, fd; - - ht = clamp(stp->rq_hello_time, 1000, 10000); - ma = clamp(stp->rq_max_age, MAX(2 * (ht + 1000), 6000), 40000); - fd = clamp(stp->rq_forward_delay, ma / 2 + 1000, 30000); - - stp->bridge_hello_time = ms_to_timer(ht); - stp->bridge_max_age = ms_to_timer(ma); - stp->bridge_forward_delay = ms_to_timer(fd); - - if (stp_is_root_bridge(stp)) { - stp->max_age = stp->bridge_max_age; - stp->hello_time = stp->bridge_hello_time; - stp->forward_delay = stp->bridge_forward_delay; - } -} - -static void stp_send_bpdu(struct stp_port *p, const void *bpdu, - size_t bpdu_size) -/*OVS_REQUIRES(mutex)*/ -{ - struct eth_header *eth; - struct llc_header *llc; - struct ofpbuf *pkt; - - /* Skeleton. */ - pkt = ofpbuf_new(ETH_HEADER_LEN + LLC_HEADER_LEN + bpdu_size); - eth = ofpbuf_base(pkt); - llc = ofpbuf_base(pkt) + sizeof(*eth); - - /* 802.2 header. */ - memcpy(eth->eth_dst, eth_addr_stp, ETH_ADDR_LEN); - /* p->stp->send_bpdu() must fill in source address. */ - eth->eth_type = htons(ofpbuf_size(pkt) - ETH_HEADER_LEN); - - /* LLC header. */ - llc->llc_dsap = STP_LLC_DSAP; - llc->llc_ssap = STP_LLC_SSAP; - llc->llc_cntl = STP_LLC_CNTL; - - /* BPDU */ - void *l3 = (char *)ofpbuf_base(pkt) + ETH_HEADER_LEN + LLC_HEADER_LEN; - memcpy(l3, bpdu, bpdu_size); - - p->stp->send_bpdu(pkt, stp_port_no(p), p->stp->aux); - p->tx_count++; -} diff --git a/src/services/pcn-bridge/external/stp/stp.h b/src/services/pcn-bridge/external/stp/stp.h deleted file mode 100644 index 890caeead..000000000 --- a/src/services/pcn-bridge/external/stp/stp.h +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (c) 2008, 2011 Nicira, Inc. - * - * 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 STP_H -#define STP_H 1 - -#ifdef __cplusplus -extern "C" { -#endif - -/* This is an implementation of Spanning Tree Protocol as described in IEEE - * 802.1D-1998, clauses 8 and 9. Section numbers refer to this standard. */ - -#include -#include -#include "compiler.h" -#include "types.h" - -#include "dependencies.h" -#include "log.h" - -struct ofpbuf; - -#define ETH_ADDR_LEN 6 -#define ETH_HEADER_LEN 14 -#define DOT1Q_HEADER_LEN 4 -#define LLC_HEADER_LEN 3 - -/* LLC field values used for STP frames. */ -#define STP_LLC_SSAP 0x42 -#define STP_LLC_DSAP 0x42 -#define STP_LLC_CNTL 0x03 - -/* Bridge and port priorities that should be used by default. */ -#define STP_DEFAULT_BRIDGE_PRIORITY 32768 -#define STP_DEFAULT_PORT_PRIORITY 128 - -/* Default time values. */ -#define STP_DEFAULT_MAX_AGE 20000 -#define STP_DEFAULT_HELLO_TIME 2000 -#define STP_DEFAULT_FWD_DELAY 15000 - -/* Bridge identifier. Top 16 bits are a priority value (numerically lower - * values are higher priorities). Bottom 48 bits are MAC address of bridge. */ -typedef uint64_t stp_identifier; - -#define STP_ID_FMT "%04" PRIx16 ".%012" PRIx64 -#define STP_ID_ARGS(stp_id) \ - (uint16_t)((stp_id) >> 48), (uint64_t)((stp_id)&0xffffffffffffULL) - -#define STP_PORT_ID_FMT "%04" PRIx16 - -/* Basic STP functionality. */ -#define STP_MAX_PORTS 255 -void stp_init(void); -struct stp *stp_create(const char *name, stp_identifier bridge_id, - void (*send_bpdu)(struct ofpbuf *bpdu, int port_no, - void *aux), - void *aux); -struct stp *stp_ref(const struct stp *); -void stp_unref(struct stp *); -void stp_tick(struct stp *, int ms); -void stp_set_bridge_id(struct stp *, stp_identifier bridge_id); -void stp_set_bridge_priority(struct stp *, uint16_t new_priority); -void stp_set_hello_time(struct stp *, int ms); -void stp_set_max_age(struct stp *, int ms); -void stp_set_forward_delay(struct stp *, int ms); - -/* STP properties. */ -const char *stp_get_name(const struct stp *); -stp_identifier stp_get_bridge_id(const struct stp *); -stp_identifier stp_get_designated_root(const struct stp *); -bool stp_is_root_bridge(const struct stp *); -int stp_get_root_path_cost(const struct stp *); -int stp_get_hello_time(const struct stp *); -int stp_get_max_age(const struct stp *); -int stp_get_forward_delay(const struct stp *); -bool stp_check_and_reset_fdb_flush(struct stp *); - -/* Obtaining STP ports. */ -struct stp_port *stp_get_port(struct stp *, int port_no); -struct stp_port *stp_get_root_port(struct stp *); -bool stp_get_changed_port(struct stp *, struct stp_port **portp); - -/* State of an STP port. - * - * A port is in exactly one state at any given time, but distinct bits are used - * for states to allow testing for more than one state with a bit mask. - * - * The STP_DISABLED state means that the port is disabled by management. - * In our implementation, this state means that the port does not - * participate in the spanning tree, but it still forwards traffic as if - * it were in the STP_FORWARDING state. This may be different from - * other implementations. - * - * The following diagram describes the various states and what they are - * allowed to do in OVS: - * - * FWD LRN TX_BPDU RX_BPDU FWD_BPDU - * --- --- ------- ------- -------- - * Disabled Y - - - Y - * Blocking - - - Y - - * Listening - - Y Y Y - * Learning - Y Y Y Y - * Forwarding Y Y Y Y Y - * - * - * FWD: the port should forward any incoming non-stp-BPDU - * packets. - * - * LRN: the port should conduct MAC learning on packets received. - * - * TX_BPDU/RX_BPDU: the port could generate/consume bpdus. - * - * FWD_BPDU: the port should should always forward the BPDUS, - * whether they are generated by the port or received - * as incoming packets. - * - * Once again, note that the disabled state forwards traffic, which is - * likely different than the spec would indicate. - */ -enum stp_state { - STP_DISABLED = 1 << 0, /* 8.4.5: See note above. */ - STP_LISTENING = 1 << 1, /* 8.4.2: Not learning or relaying frames. */ - STP_LEARNING = 1 << 2, /* 8.4.3: Learning but not relaying frames. */ - STP_FORWARDING = 1 << 3, /* 8.4.4: Learning and relaying frames. */ - STP_BLOCKING = 1 << 4 /* 8.4.1: Initial boot state. */ -}; -const char *stp_state_name(enum stp_state); -bool stp_forward_in_state(enum stp_state); -bool stp_learn_in_state(enum stp_state); -bool stp_should_forward_bpdu(enum stp_state); - -/* Role of an STP port. */ -enum stp_role { - STP_ROLE_ROOT, /* Path to root bridge. */ - STP_ROLE_DESIGNATED, /* Path to LAN segments. */ - STP_ROLE_ALTERNATE, /* Backup path to root bridge. */ - STP_ROLE_DISABLED /* Port does not participate in STP. */ -}; -const char *stp_role_name(enum stp_role); - -void stp_received_bpdu(struct stp_port *, const void *bpdu, size_t bpdu_size); - -struct stp *stp_port_get_stp(struct stp_port *); -void stp_port_set_name(struct stp_port *, const char *); -void stp_port_set_aux(struct stp_port *, void *); -void *stp_port_get_aux(struct stp_port *); -int stp_port_no(const struct stp_port *); -int stp_port_get_id(const struct stp_port *); -enum stp_state stp_port_get_state(const struct stp_port *); -enum stp_role stp_port_get_role(const struct stp_port *); -void stp_port_get_counts(const struct stp_port *, int *tx_count, int *rx_count, - int *error_count); -void stp_port_enable(struct stp_port *); -void stp_port_disable(struct stp_port *); -void stp_port_set_priority(struct stp_port *, uint8_t new_priority); -uint16_t stp_convert_speed_to_cost(unsigned int speed); -void stp_port_set_path_cost(struct stp_port *, uint16_t path_cost); -void stp_port_set_speed(struct stp_port *, unsigned int speed); -void stp_port_enable_change_detection(struct stp_port *); -void stp_port_disable_change_detection(struct stp_port *); - -#ifdef __cplusplus -} -#endif - -#endif /* stp.h */ diff --git a/src/services/pcn-bridge/external/stp/types.h b/src/services/pcn-bridge/external/stp/types.h deleted file mode 100644 index 579cdaa79..000000000 --- a/src/services/pcn-bridge/external/stp/types.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2010, 2011, 2013, 2014 Nicira, Inc. - * - * 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 OPENVSWITCH_TYPES_H -#define OPENVSWITCH_TYPES_H 1 - -#include -#include - -#ifdef __CHECKER__ -#define OVS_BITWISE __attribute__((bitwise)) -#define OVS_FORCE __attribute__((force)) -#else -#define OVS_BITWISE -#define OVS_FORCE -#endif - -/* The ovs_be types indicate that an object is in big-endian, not - * native-endian, byte order. They are otherwise equivalent to uint_t. */ -typedef uint16_t OVS_BITWISE ovs_be16; -typedef uint32_t OVS_BITWISE ovs_be32; -typedef uint64_t OVS_BITWISE ovs_be64; - -#define OVS_BE16_MAX ((OVS_FORCE ovs_be16)0xffff) -#define OVS_BE32_MAX ((OVS_FORCE ovs_be32)0xffffffff) -#define OVS_BE64_MAX ((OVS_FORCE ovs_be64)0xffffffffffffffffULL) - -/* These types help with a few funny situations: - * - * - The Ethernet header is 14 bytes long, which misaligns everything after - * that. One can put 2 "shim" bytes before the Ethernet header, but this - * helps only if there is exactly one Ethernet header. If there are two, - * as with GRE and VXLAN (and if the inner header doesn't use this - * trick--GRE and VXLAN don't) then you have the choice of aligning the - * inner data or the outer data. So it seems better to treat 32-bit fields - * in protocol headers as aligned only on 16-bit boundaries. - * - * - ARP headers contain misaligned 32-bit fields. - * - * - Netlink and OpenFlow contain 64-bit values that are only guaranteed to - * be aligned on 32-bit boundaries. - * - * lib/unaligned.h has helper functions for accessing these. */ - -/* A 32-bit value, in host byte order, that is only aligned on a 16-bit - * boundary. */ -typedef struct { -#ifdef WORDS_BIGENDIAN - uint16_t hi, lo; -#else - uint16_t lo, hi; -#endif -} ovs_16aligned_u32; - -/* A 32-bit value, in network byte order, that is only aligned on a 16-bit - * boundary. */ -typedef struct { ovs_be16 hi, lo; } ovs_16aligned_be32; - -/* A 64-bit value, in host byte order, that is only aligned on a 32-bit - * boundary. */ -typedef struct { -#ifdef WORDS_BIGENDIAN - uint32_t hi, lo; -#else - uint32_t lo, hi; -#endif -} ovs_32aligned_u64; - -/* A 64-bit value, in network byte order, that is only aligned on a 32-bit - * boundary. */ -typedef struct { ovs_be32 hi, lo; } ovs_32aligned_be64; - -/* ofp_port_t represents the port number of a OpenFlow switch. - * odp_port_t represents the port number on the datapath. - * ofp11_port_t represents the OpenFlow-1.1 port number. */ -typedef uint16_t OVS_BITWISE ofp_port_t; -typedef uint32_t OVS_BITWISE odp_port_t; -typedef uint32_t OVS_BITWISE ofp11_port_t; - -/* Macro functions that cast int types to ofp/odp/ofp11 types. */ -#define OFP_PORT_C(X) ((OVS_FORCE ofp_port_t)(X)) -#define ODP_PORT_C(X) ((OVS_FORCE odp_port_t)(X)) -#define OFP11_PORT_C(X) ((OVS_FORCE ofp11_port_t)(X)) - -#endif /* openvswitch/types.h */ diff --git a/src/services/pcn-bridge/src/Bridge-lib.cpp b/src/services/pcn-bridge/src/Bridge-lib.cpp deleted file mode 100755 index 440ee6b59..000000000 --- a/src/services/pcn-bridge/src/Bridge-lib.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2017 The Polycube Authors - * - * 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. - */ - -/* Do not edit this file manually */ - -#include "api/BridgeApiImpl.h" -#define MANAGER_TYPE io::swagger::server::api::BridgeApiImpl - -const std::string SERVICE_DATA_MODEL = R"POLYCUBE_DM()POLYCUBE_DM"; -#include diff --git a/src/services/pcn-bridge/src/Bridge.cpp b/src/services/pcn-bridge/src/Bridge.cpp deleted file mode 100644 index 1678fc8e9..000000000 --- a/src/services/pcn-bridge/src/Bridge.cpp +++ /dev/null @@ -1,486 +0,0 @@ -/* - * Copyright 2017 The Polycube Authors - * - * 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 "Bridge.h" - -#include - -const std::string mode_to_string(PortMode mode) { - switch (mode) { - case PortMode::ACCESS: - return "access"; - case PortMode::TRUNK: - return "trunk"; - default: - throw std::runtime_error("Bad port mode"); - } -} - -PortMode string_to_mode(const std::string &str) { - if (str == "access") - return PortMode::ACCESS; - else if (str == "trunk") - return PortMode::TRUNK; - else - throw std::runtime_error("Port mode is invalid"); -} - -Bridge::Bridge(const std::string &name, BridgeSchema &conf, CubeType type, - const std::string &code) - : aging_time_(300), - stp_enabled_(conf.stpenabledIsSet() ? conf.getStpenabled() : false), - Cube(name, {generate_code(conf.stpenabledIsSet() ? conf.getStpenabled() - : false)}, - {}, type, polycube::LogLevel::INFO) { - logger()->set_pattern("[%Y-%m-%d %H:%M:%S.%e] [bridge] [%n] [%l] %v"); - conf.setUuid(get_uuid().str()); - conf.setAgingtime(aging_time_); -} - -Bridge::~Bridge() { - Cube::dismount(); -} - -bool Bridge::isStpEnabled() { - return stp_enabled_; -} - -PortsSchema Bridge::add_port(const std::string &port_name, - const PortsSchema &port) { - std::lock_guard guard(ports_mutex_); - - // Add port to the cube - auto p = Cube::add_port(port_name, port); - PortsSchema portsSchema; - portsSchema.setName(port_name); - portsSchema.setUuid(p->uuid().str()); - - // TODO: :Fill other parameters in the portSchema object - - return portsSchema; -} - -void Bridge::remove_port(const std::string &port_name) { - std::lock_guard guard(ports_mutex_); - // remove port fro the Cube - Cube::remove_port(port_name); -} - -PortsSchema Bridge::read_bridge_ports_by_id(const std::string &portsName) { - auto &&p = get_bridge_port(portsName); - PortsSchema sch; - sch.setName(portsName); - // sch.setStatus(); TODO: what is status? - // sch.setAddress(); TODO: what is address? - sch.setMode(mode_to_string(p.mode())); - if (p.mode() == PortMode::ACCESS) { - PortsAccessSchema access_sch; - access_sch.setVlanid(p.access_vlan()); - sch.setAccess(access_sch); - } else if (p.mode() == PortMode::TRUNK) { - PortsTrunkSchema trunk_sch; - trunk_sch.setNativevlan(p.native_vlan()); - sch.setTrunk(trunk_sch); - // TODO: how to add allowed vlans? - } - - sch.setPeer(p.peer()); - sch.setUuid(p.uuid().str()); - return sch; -} - -std::string Bridge::generate_code(bool stp_enabled) { - std::string aging_time_str("#define AGING_TIME " + - std::to_string(aging_time_ ? aging_time_ : 300)); - return aging_time_str + (stp_enabled ? bridge_code : bridge_code_no_stp); -} - -void Bridge::packet_in(BridgePort &port, PacketInMetadata &md, - const std::vector &packet) { - try { - // logger()->debug("[{0}] packet from port: '{1}' id: '{2}' peer:'{3}'", - // get_name(), port.name(), port.index(), port.peer()); - - switch (static_cast(md.reason)) { - case SlowPathReason::BROADCAST: - logger()->trace("reason: BROADCAST"); - broadcast_packet(port, md, packet); - break; - case SlowPathReason::BPDU: - // logger()->debug("[{0}] reason: BPDU", get_name()); - // TODO: check that the bpdu is allowed - if (stp_enabled_) - process_bpdu(port, md, packet); - else - broadcast_packet(port, md, packet); - break; - default: - logger()->error("Not valid reason {0} received", md.reason); - } - } catch (const std::exception &e) { - logger()->error("exception during slowpath packet processing: '{0}'", - e.what()); - } -} - -void Bridge::broadcast_packet(Port &port, PacketInMetadata &md, - const std::vector &packet) { - bool tagged = md.metadata[1]; - uint16_t vlan = md.metadata[0]; - logger()->trace("metadata vlan:{0} tagged:{1}", vlan, tagged); - - // avoid adding or removing ports while flooding packet - std::lock_guard guard(ports_mutex_); - - for (auto &it : get_ports()) { - if (it->name() == port.name()) { - continue; - } - it->send_packet_out(packet, tagged, vlan); - } -} - -void Bridge::process_bpdu(Port &port, PacketInMetadata &md, - const std::vector &packet) { - bool tagged = md.metadata[1]; - unsigned int vlan = md.metadata[0]; - - int port_id = port.index(); - if (stps_.count(vlan) == 0) { - logger()->error("stp instance not present"); - return; - } - - size_t bpdusize = 0; - int start = ETH_HEADER_LEN + LLC_HEADER_LEN; - - // build an Ethernet packet to get the STP BPDU later on - EthernetII ether(&packet[0], packet.size()); - if (tagged) { - Dot1Q &dot1 = ether.rfind_pdu(); - bpdusize = dot1.payload_type() - LLC_HEADER_LEN; - start += DOT1Q_HEADER_LEN; - } else { - bpdusize = ether.payload_type() - LLC_HEADER_LEN; - } - - // take last part of vector - std::vector::const_iterator first = packet.begin() + start; - std::vector::const_iterator last = packet.begin() + start + bpdusize; - std::vector p(first, last); - get_stp_instance(vlan).process_bpdu(port_id, p); -} - -BridgePort &Bridge::get_bridge_port(const std::string &name) { - return *Cube::get_port(name); -} - -BridgePort &Bridge::get_bridge_port(int port_id) { - return *Cube::get_port(port_id); -} - -BridgeSTP &Bridge::get_stp_instance(uint16_t vlan_id, bool create) { - if (!stp_enabled_) { - throw std::runtime_error("STP is disabled"); - } - if (stps_.count(vlan_id) == 0) { - if (!create) { - throw std::runtime_error("STP instance does not exist"); - } - logger()->debug("creating stp instance for vlan {0}", vlan_id); - stps_.emplace(std::piecewise_construct, std::forward_as_tuple(vlan_id), - std::forward_as_tuple(*this, vlan_id)); - } - return stps_.at(vlan_id); -} - -BridgePort::BridgePort(polycube::service::Cube &parent_, - std::shared_ptr port_, - const PortsSchema &conf) - : Port(port_), - parent(static_cast(parent_)), - mode_(PortMode::ACCESS), - access_vlan_(0), - l(spdlog::get("pcn-bridge")) { - auto ports_table = parent.get_hash_table("ports"); - port value{ - .mode = static_cast(PortMode::ACCESS), .native_vlan = 0, - }; - ports_table.set(index(), value); - - set_access_vlan(1); -} - -BridgePort::~BridgePort() { - cleanup(); - auto ports_table = parent.get_hash_table("ports"); - ports_table.remove(index()); -} - -PortMode BridgePort::mode() const { - return mode_; -} - -void BridgePort::set_mode(PortMode mode) { - if (mode_ == mode) - return; - - cleanup(); - - auto ports_table = parent.get_hash_table("ports"); - - port value{ - .mode = static_cast(mode), .native_vlan = 0, - }; - - ports_table.set(index(), value); - - mode_ = mode; -} - -uint16_t BridgePort::access_vlan() const { - if (mode_ != PortMode::ACCESS) - throw std::runtime_error("Port is not in access mode"); - return access_vlan_; -} - -void BridgePort::set_access_vlan(uint16_t vlan) { - if (mode_ != PortMode::ACCESS) - throw std::runtime_error("Port is not in access mode"); - - if (access_vlan_ == vlan) - return; - - uint16_t port_id = index(); - if (parent.stp_enabled_ && access_vlan_ != 0) { - try { - parent.get_stp_instance(access_vlan_).remove_port(port_id); - } catch (...) { - }; - } - - port_vlan_key key{ - .port = port_id, .vlan = VLAN_WILDCARD, - }; - - port_vlan_value value{ - .vlan = vlan, .stp_state = STP_BLOCKING, - }; - - auto port_vlan_table = - parent.get_hash_table("port_vlan"); - port_vlan_table.set(key, value); - if (parent.stp_enabled_) - parent.get_stp_instance(vlan, true).add_port(port_id); - access_vlan_ = vlan; -} - -void BridgePort::add_trunk_vlan(uint16_t vlan) { - if (mode_ != PortMode::TRUNK) - throw std::runtime_error("Port is not in trunk mode"); - - if (trunk_vlans_.count(vlan) != 0) - return; // TODO: should an error be thrown? - - uint16_t port_id = index(); - - port_vlan_key key{ - .port = port_id, .vlan = vlan, - }; - - port_vlan_value value{ - .vlan = vlan, .stp_state = STP_BLOCKING, - }; - - auto port_vlan_table = - parent.get_hash_table("port_vlan"); - port_vlan_table.set(key, value); - - if (parent.isStpEnabled()) - parent.get_stp_instance(vlan, true).add_port(port_id); - - trunk_vlans_.insert(vlan); -} - -void BridgePort::remove_trunk_vlan(uint16_t vlan) { - if (mode_ != PortMode::TRUNK) - throw std::runtime_error("Port is not in trunk mode"); - if (trunk_vlans_.count(vlan) == 0) - return; // TODO: exeception? - - uint16_t port_id = index(); - - port_vlan_key key{ - .port = port_id, .vlan = vlan, - }; - - auto port_vlan_table = - parent.get_hash_table("port_vlan"); - port_vlan_table.remove(key); - - if (parent.stp_enabled_) - parent.get_stp_instance(vlan).remove_port(port_id); - // TODO: remove stp instance if needed - trunk_vlans_.erase(vlan); -} - -uint16_t BridgePort::native_vlan() const { - if (mode_ != PortMode::TRUNK) - throw std::runtime_error("Port is not in trunk mode"); - - return native_vlan_; -} - -void BridgePort::set_native_vlan(uint16_t vlan) { - if (mode_ != PortMode::TRUNK) - throw std::runtime_error("Port is not in trunk mode"); - - if (native_vlan_ == vlan) - return; - - if (trunk_vlans_.count(vlan) == 0) - throw std::runtime_error("Vlan is not allowed in port"); - - port value{ - .mode = static_cast(mode_), .native_vlan = vlan, - }; - auto ports_table = parent.get_hash_table("ports"); - ports_table.set(index(), value); - native_vlan_ = vlan; -} - -bool BridgePort::is_trunk_vlan_allowed(uint16_t vlan) { - if (mode_ != PortMode::TRUNK) - throw std::runtime_error("Port is not in trunk mode"); - return trunk_vlans_.count(vlan) != 0; -} - -void BridgePort::cleanup() { - switch (mode_) { - case PortMode::ACCESS: - cleanup_access_port(); - break; - case PortMode::TRUNK: - cleanup_trunk_port(); - break; - } -} - -void BridgePort::cleanup_trunk_port() { - uint16_t port_id = index(); - - auto port_vlan_table = - parent.get_hash_table("port_vlan"); - - for (auto vlan : trunk_vlans_) { - port_vlan_key key{ - .port = port_id, .vlan = vlan, - }; - - port_vlan_table.remove(key); - - if (parent.stp_enabled_) - parent.get_stp_instance(vlan).remove_port(port_id); - } - - trunk_vlans_.clear(); -} - -void BridgePort::cleanup_access_port() { - uint16_t port_id = index(); - if (parent.stp_enabled_) { - auto &stp_instance = parent.get_stp_instance(access_vlan_); - stp_instance.remove_port(port_id); - } - // TODO: remove stp instance if needed - port_vlan_key key{ - .port = port_id, .vlan = VLAN_WILDCARD, - }; - - auto port_vlan_table = - parent.get_hash_table("port_vlan"); - - try { - port_vlan_table.remove(key); - } catch (const std::exception &) { - } - - access_vlan_ = 0; -} - -void BridgePort::send_packet_out(const std::vector &packet, - bool tagged, uint16_t vlan) { - if (parent.stp_enabled_ && - !parent.get_stp_instance(vlan).port_should_forward(index())) { - return; - } - - EthernetII p(&packet[0], packet.size()); - - bool send_tagged; - - // vlan aware broadcast implementation - switch (mode_) { - case PortMode::ACCESS: - if (vlan != access_vlan()) { - parent.logger()->debug("port({0}) vlan({1}) != access_vlan({2})", name(), - vlan, access_vlan()); - return; - } - send_tagged = false; - break; - case PortMode::TRUNK: - if (!is_trunk_vlan_allowed(vlan)) { - parent.logger()->debug("port({0}) vlan({1}) not present in trunk_vlans", - name(), vlan); - return; - } - - if (vlan == native_vlan()) { - parent.logger()->debug("port({0}) vlan({1}) packet to native vlan", - name(), vlan); - send_tagged = false; - } else { - send_tagged = true; - } - break; - } - - if (tagged == send_tagged) { // send original - Port::send_packet_out(p); - } else if (!tagged && send_tagged) { // push vlan - EthernetII tagged_p = EthernetII(p.dst_addr(), p.src_addr()); - - Dot1Q dot1q(vlan); - dot1q.payload_type(p.payload_type()); - tagged_p /= dot1q; - - PDU *p_inner = p.inner_pdu(); - tagged_p /= *p_inner; - - Port::send_packet_out(tagged_p); - } else { // pop vlan - Dot1Q &p_dot1q = p.rfind_pdu(); - - EthernetII untagged_p = EthernetII(p.dst_addr(), p.src_addr()); - untagged_p.payload_type(p_dot1q.payload_type()); - - PDU *p_inner = p_dot1q.inner_pdu(); - untagged_p /= *p_inner; - - Port::send_packet_out(untagged_p); - } -} diff --git a/src/services/pcn-bridge/src/Bridge.h b/src/services/pcn-bridge/src/Bridge.h deleted file mode 100644 index 6361bc007..000000000 --- a/src/services/pcn-bridge/src/Bridge.h +++ /dev/null @@ -1,289 +0,0 @@ -/* - * Copyright 2017 The Polycube Authors - * - * 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. - */ - -#pragma once - -#include "api/BridgeApi.h" -#include "polycube/services/cube.h" -#include "polycube/services/port.h" -#include "polycube/services/utils.h" - -#include "BridgeSTP.h" -#include "Bridge_dp_no_stp.h" -#include "Bridge_dp_stp.h" - -#include -#include -#include - -using namespace io::swagger::server::model; - -enum class SlowPathReason { BPDU = 1, BROADCAST }; -enum class PortMode { ACCESS, TRUNK }; - -const std::string mode_to_string(PortMode mode); -PortMode string_to_mode(const std::string &str); - -#define VLAN_WILDCARD 0x00 - -class Bridge; - -/* definitions copied from datapath */ -struct port_vlan_key { - // todo use u16 instead of u32 - uint32_t port; - uint32_t vlan; -} __attribute__((packed)); - -struct port_vlan_value { - uint16_t vlan; - uint16_t stp_state; -} __attribute__((packed)); - -struct port { - uint16_t mode; - uint16_t native_vlan; -} __attribute__((packed)); - -struct fwd_key { - uint32_t vlan; - uint64_t mac; -} __attribute__((packed)); - -struct fwd_entry { - uint64_t timestamp; - uint32_t port; -} __attribute__((packed)); - -class BridgePort : public polycube::service::Port { - public: - // BridgePort(Bridge &parent, Port &p); - BridgePort(polycube::service::Cube &parent, - std::shared_ptr port, - const PortsSchema &conf); - ~BridgePort(); - PortMode mode() const; - void set_mode(PortMode mode); - uint16_t access_vlan() const; - void set_access_vlan(uint16_t vlan); - void add_trunk_vlan(uint16_t vlan); - void remove_trunk_vlan(uint16_t vlan); - uint16_t native_vlan() const; - void set_native_vlan(uint16_t vlan); - bool is_trunk_vlan_allowed(uint16_t vlan); - void cleanup(); - - /* - * sends a packet through the port, the packet is automatically tagged or - * untagged if required. Packet is dropped is port status does not allow to - * send packets of if the vlan is not allowed. - */ - void send_packet_out(const std::vector &packet, bool tagged, - uint16_t vlan); - - BridgePort &operator=(const BridgePort &) = delete; - BridgePort(const BridgePort &) = delete; - - private: - Bridge &parent; - void cleanup_trunk_port(); - void cleanup_access_port(); - - PortMode mode_; - uint16_t access_vlan_; - uint16_t native_vlan_; - std::set trunk_vlans_; - std::shared_ptr l; -}; - -class Bridge : public polycube::service::Cube { - friend class BridgeSTP; - friend class BridgePort; - - public: - Bridge(const std::string &name, BridgeSchema &conf, - CubeType type = CubeType::TC, const std::string &code = bridge_code); - ~Bridge(); - - PortsSchema add_port(const std::string &port_name, const PortsSchema &port); - void remove_port(const std::string &port_name); - - void packet_in(BridgePort &port, PacketInMetadata &md, - const std::vector &packet) override; - - // TODO: comment about these functions - FilteringdatabaseSchema create_bridge_filteringdatabase_by_id( - const std::string &vlan, const std::string &address, - const FilteringdatabaseSchema &filteringdatabase); - std::vector - create_bridge_filteringdatabase_list_by_id( - const std::vector &filteringdatabase); - PortsAccessSchema create_bridge_ports_access_by_id( - const std::string &portsName, const PortsAccessSchema &access); - PortsStpSchema create_bridge_ports_stp_by_id(const std::string &portsName, - const std::string &vlan, - const PortsStpSchema &stp); - std::vector create_bridge_ports_stp_list_by_id( - const std::string &portsName, const std::vector &stp); - PortsTrunkAllowedSchema create_bridge_ports_trunk_allowed_by_id( - const std::string &portsName, const std::string &vlanid, - const PortsTrunkAllowedSchema &allowed); - std::vector - create_bridge_ports_trunk_allowed_list_by_id( - const std::string &portsName, - const std::vector &allowed); - PortsTrunkSchema create_bridge_ports_trunk_by_id( - const std::string &portsName, const PortsTrunkSchema &trunk); - StpSchema create_bridge_stp_by_id(const std::string &vlan, - const StpSchema &stp); - std::vector create_bridge_stp_list_by_id( - const std::vector &stp); - void delete_bridge_filteringdatabase_by_id(const std::string &vlan, - const std::string &address); - void delete_bridge_filteringdatabase_list_by_id(); - void delete_bridge_ports_access_by_id(const std::string &portsName); - void delete_bridge_ports_stp_by_id(const std::string &portsName, - const std::string &vlan); - void delete_bridge_ports_stp_list_by_id(const std::string &portsName); - void delete_bridge_ports_trunk_allowed_by_id(const std::string &portsName, - const std::string &vlanid); - void delete_bridge_ports_trunk_allowed_list_by_id( - const std::string &portsName); - void delete_bridge_ports_trunk_by_id(const std::string &portsName); - void delete_bridge_stp_by_id(const std::string &vlan); - void delete_bridge_stp_list_by_id(); - int32_t read_bridge_agingtime_by_id(); - BridgeSchema read_bridge_by_id(); - int32_t read_bridge_filteringdatabase_age_by_id(const std::string &vlan, - const std::string &address); - FilteringdatabaseSchema read_bridge_filteringdatabase_by_id( - const std::string &vlan, const std::string &address); - std::string read_bridge_filteringdatabase_entrytype_by_id( - const std::string &vlan, const std::string &address); - std::vector - read_bridge_filteringdatabase_list_by_id(); - std::string read_bridge_filteringdatabase_port_by_id( - const std::string &vlan, const std::string &address); - PortsAccessSchema read_bridge_ports_access_by_id( - const std::string &portsName); - int32_t read_bridge_ports_access_vlanid_by_id(const std::string &portsName); - std::string read_bridge_ports_address_by_id(const std::string &portsName); - PortsSchema read_bridge_ports_by_id(const std::string &portsName); - std::string read_bridge_ports_mode_by_id(const std::string &portsName); - PortsStpSchema read_bridge_ports_stp_by_id(const std::string &portsName, - const std::string &vlan); - std::vector read_bridge_ports_stp_list_by_id( - const std::string &portsName); - int32_t read_bridge_ports_stp_pathcost_by_id(const std::string &portsName, - const std::string &vlan); - int32_t read_bridge_ports_stp_portpriority_by_id(const std::string &portsName, - const std::string &vlan); - std::string read_bridge_ports_stp_state_by_id(const std::string &portsName, - const std::string &vlan); - PortsTrunkAllowedSchema read_bridge_ports_trunk_allowed_by_id( - const std::string &portsName, const std::string &vlanid); - std::vector - read_bridge_ports_trunk_allowed_list_by_id(const std::string &portsName); - PortsTrunkSchema read_bridge_ports_trunk_by_id(const std::string &portsName); - int32_t read_bridge_ports_trunk_nativevlan_by_id( - const std::string &portsName); - std::string read_bridge_stp_address_by_id(const std::string &vlan); - StpSchema read_bridge_stp_by_id(const std::string &vlan); - int32_t read_bridge_stp_forwarddelay_by_id(const std::string &vlan); - int32_t read_bridge_stp_hellotime_by_id(const std::string &vlan); - std::vector read_bridge_stp_list_by_id(); - int32_t read_bridge_stp_maxmessageage_by_id(const std::string &vlan); - int32_t read_bridge_stp_priority_by_id(const std::string &vlan); - bool read_bridge_stpenabled_by_id(); - std::string read_bridge_type_by_id(); - void update_bridge_agingtime_by_id(const int32_t &agingtime); - void update_bridge_by_id(const BridgeSchema &bridge); - void update_bridge_filteringdatabase_by_id( - const std::string &vlan, const std::string &address, - const FilteringdatabaseSchema &filteringdatabase); - void update_bridge_filteringdatabase_entrytype_by_id( - const std::string &vlan, const std::string &address, - const std::string &entrytype); - void update_bridge_filteringdatabase_list_by_id( - const std::vector &filteringdatabase); - void update_bridge_filteringdatabase_port_by_id(const std::string &vlan, - const std::string &address, - const std::string &port); - void update_bridge_ports_access_by_id(const std::string &portsName, - const PortsAccessSchema &access); - void update_bridge_ports_access_vlanid_by_id(const std::string &portsName, - const int32_t &vlanid); - void update_bridge_ports_address_by_id(const std::string &portsName, - const std::string &address); - void update_bridge_ports_mode_by_id(const std::string &portsName, - const std::string &mode); - void update_bridge_ports_stp_by_id(const std::string &portsName, - const std::string &vlan, - const PortsStpSchema &stp); - void update_bridge_ports_stp_list_by_id( - const std::string &portsName, const std::vector &stp); - void update_bridge_ports_stp_pathcost_by_id(const std::string &portsName, - const std::string &vlan, - const int32_t &pathcost); - void update_bridge_ports_stp_portpriority_by_id(const std::string &portsName, - const std::string &vlan, - const int32_t &portpriority); - void update_bridge_ports_trunk_allowed_by_id( - const std::string &portsName, const std::string &vlanid, - const PortsTrunkAllowedSchema &allowed); - void update_bridge_ports_trunk_allowed_list_by_id( - const std::string &portsName, - const std::vector &allowed); - void update_bridge_ports_trunk_by_id(const std::string &portsName, - const PortsTrunkSchema &trunk); - void update_bridge_ports_trunk_nativevlan_by_id(const std::string &portsName, - const int32_t &nativevlan); - void update_bridge_stp_address_by_id(const std::string &vlan, - const std::string &address); - void update_bridge_stp_by_id(const std::string &vlan, const StpSchema &stp); - void update_bridge_stp_forwarddelay_by_id(const std::string &vlan, - const int32_t &forwarddelay); - void update_bridge_stp_hellotime_by_id(const std::string &vlan, - const int32_t &hellotime); - void update_bridge_stp_list_by_id(const std::vector &stp); - void update_bridge_stp_maxmessageage_by_id(const std::string &vlan, - const int32_t &maxmessageage); - void update_bridge_stp_priority_by_id(const std::string &vlan, - const int32_t &priority); - void update_bridge_stpenabled_by_id(const bool &stpenabled); - void update_bridge_type_by_id(const std::string &type); - - bool isStpEnabled(); - - private: - std::string generate_code(bool stp_enabled); - // internal control API - - void broadcast_packet(Port &port, PacketInMetadata &md, - const std::vector &packet); - void process_bpdu(Port &port, PacketInMetadata &md, - const std::vector &packet); - BridgePort &get_bridge_port(const std::string &name); - BridgePort &get_bridge_port(int port_id); - BridgeSTP &get_stp_instance(uint16_t vlan_id, bool create = false); - - int module_index; - std::unordered_map stps_; - uint16_t aging_time_; - bool stp_enabled_; - - std::mutex ports_mutex_; -}; diff --git a/src/services/pcn-bridge/src/BridgeApi.cpp b/src/services/pcn-bridge/src/BridgeApi.cpp deleted file mode 100644 index 5ed3ab149..000000000 --- a/src/services/pcn-bridge/src/BridgeApi.cpp +++ /dev/null @@ -1,1292 +0,0 @@ -/* - * Copyright 2017 The Polycube Authors - * - * 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 "Bridge.h" -#include - -using namespace io::swagger::server::model; - -/* - * These functions do not include a default implementation and should be - * implemented by the user - */ - -/** -* @brief Create filteringdatabase by ID -* -* Create operation of resource: filteringdatabase* -* -* @param[in] vlan ID of vlan -* @param[in] address ID of address -* @param[in] filteringdatabase filteringdatabasebody object -* -* Responses: -* FilteringdatabaseSchema -*/ -FilteringdatabaseSchema Bridge::create_bridge_filteringdatabase_by_id( - const std::string &vlan, const std::string &address, - const FilteringdatabaseSchema &filteringdatabase) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Create filteringdatabase by ID -* -* Create operation of resource: filteringdatabase* -* -* @param[in] filteringdatabase filteringdatabasebody object -* -* Responses: -* std::vector -*/ -std::vector -Bridge::create_bridge_filteringdatabase_list_by_id( - const std::vector &filteringdatabase) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Create access by ID -* -* Create operation of resource: access* -* -* @param[in] portsName ID of ports_name -* @param[in] access accessbody object -* -* Responses: -* PortsAccessSchema -*/ -PortsAccessSchema Bridge::create_bridge_ports_access_by_id( - const std::string &portsName, const PortsAccessSchema &access) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Create stp by ID -* -* Create operation of resource: stp* -* -* @param[in] portsName ID of ports_name -* @param[in] vlan ID of vlan -* @param[in] stp stpbody object -* -* Responses: -* PortsStpSchema -*/ -PortsStpSchema Bridge::create_bridge_ports_stp_by_id( - const std::string &portsName, const std::string &vlan, - const PortsStpSchema &stp) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Create stp by ID -* -* Create operation of resource: stp* -* -* @param[in] portsName ID of ports_name -* @param[in] stp stpbody object -* -* Responses: -* std::vector -*/ -std::vector Bridge::create_bridge_ports_stp_list_by_id( - const std::string &portsName, const std::vector &stp) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Create allowed by ID -* -* Create operation of resource: allowed* -* -* @param[in] portsName ID of ports_name -* @param[in] vlanid ID of vlanid -* @param[in] allowed allowedbody object -* -* Responses: -* PortsTrunkAllowedSchema -*/ -PortsTrunkAllowedSchema Bridge::create_bridge_ports_trunk_allowed_by_id( - const std::string &portsName, const std::string &vlanid, - const PortsTrunkAllowedSchema &allowed) { - auto &&p = get_bridge_port(portsName); - p.add_trunk_vlan(std::stoul(vlanid)); - PortsTrunkAllowedSchema ports_trunk_allowed; - ports_trunk_allowed.setVlanid(std::stoul(vlanid)); - // TODO return fulfilled schema - return ports_trunk_allowed; -} - -/** -* @brief Create allowed by ID -* -* Create operation of resource: allowed* -* -* @param[in] portsName ID of ports_name -* @param[in] allowed allowedbody object -* -* Responses: -* std::vector -*/ -std::vector -Bridge::create_bridge_ports_trunk_allowed_list_by_id( - const std::string &portsName, - const std::vector &allowed) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Create trunk by ID -* -* Create operation of resource: trunk* -* -* @param[in] portsName ID of ports_name -* @param[in] trunk trunkbody object -* -* Responses: -* PortsTrunkSchema -*/ -PortsTrunkSchema Bridge::create_bridge_ports_trunk_by_id( - const std::string &portsName, const PortsTrunkSchema &trunk) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Create stp by ID -* -* Create operation of resource: stp* -* -* @param[in] vlan ID of vlan -* @param[in] stp stpbody object -* -* Responses: -* StpSchema -*/ -StpSchema Bridge::create_bridge_stp_by_id(const std::string &vlan, - const StpSchema &stp) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Create stp by ID -* -* Create operation of resource: stp* -* -* @param[in] stp stpbody object -* -* Responses: -* std::vector -*/ -std::vector Bridge::create_bridge_stp_list_by_id( - const std::vector &stp) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Delete filteringdatabase by ID -* -* Delete operation of resource: filteringdatabase* -* -* @param[in] vlan ID of vlan -* @param[in] address ID of address -* -* Responses: -* -*/ -void Bridge::delete_bridge_filteringdatabase_by_id(const std::string &vlan, - const std::string &address) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Delete filteringdatabase by ID -* -* Delete operation of resource: filteringdatabase* -* -* -* Responses: -* -*/ -void Bridge::delete_bridge_filteringdatabase_list_by_id() { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Delete access by ID -* -* Delete operation of resource: access* -* -* @param[in] portsName ID of ports_name -* -* Responses: -* -*/ -void Bridge::delete_bridge_ports_access_by_id(const std::string &portsName) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Delete stp by ID -* -* Delete operation of resource: stp* -* -* @param[in] portsName ID of ports_name -* @param[in] vlan ID of vlan -* -* Responses: -* -*/ -void Bridge::delete_bridge_ports_stp_by_id(const std::string &portsName, - const std::string &vlan) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Delete stp by ID -* -* Delete operation of resource: stp* -* -* @param[in] portsName ID of ports_name -* -* Responses: -* -*/ -void Bridge::delete_bridge_ports_stp_list_by_id(const std::string &portsName) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Delete allowed by ID -* -* Delete operation of resource: allowed* -* -* @param[in] portsName ID of ports_name -* @param[in] vlanid ID of vlanid -* -* Responses: -* -*/ -void Bridge::delete_bridge_ports_trunk_allowed_by_id( - const std::string &portsName, const std::string &vlanid) { - auto &&p = get_bridge_port(portsName); - p.remove_trunk_vlan(std::stoul(vlanid)); -} - -/** -* @brief Delete allowed by ID -* -* Delete operation of resource: allowed* -* -* @param[in] portsName ID of ports_name -* -* Responses: -* -*/ -void Bridge::delete_bridge_ports_trunk_allowed_list_by_id( - const std::string &portsName) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Delete trunk by ID -* -* Delete operation of resource: trunk* -* -* @param[in] portsName ID of ports_name -* -* Responses: -* -*/ -void Bridge::delete_bridge_ports_trunk_by_id(const std::string &portsName) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Delete stp by ID -* -* Delete operation of resource: stp* -* -* @param[in] vlan ID of vlan -* -* Responses: -* -*/ -void Bridge::delete_bridge_stp_by_id(const std::string &vlan) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Delete stp by ID -* -* Delete operation of resource: stp* -* -* -* Responses: -* -*/ -void Bridge::delete_bridge_stp_list_by_id() { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Read agingtime by ID -* -* Read operation of resource: agingtime* -* -* -* Responses: -* int32_t -*/ -int32_t Bridge::read_bridge_agingtime_by_id() { - return aging_time_; -} - -/** -* @brief Read bridge by ID -* -* Read operation of resource: bridge* -* -* -* Responses: -* BridgeSchema -*/ -BridgeSchema Bridge::read_bridge_by_id() { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Read age by ID -* -* Read operation of resource: age* -* -* @param[in] vlan ID of vlan -* @param[in] address ID of address -* -* Responses: -* int32_t -*/ -int32_t Bridge::read_bridge_filteringdatabase_age_by_id( - const std::string &vlan, const std::string &address) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Read filteringdatabase by ID -* -* Read operation of resource: filteringdatabase* -* -* @param[in] vlan ID of vlan -* @param[in] address ID of address -* -* Responses: -* FilteringdatabaseSchema -*/ -FilteringdatabaseSchema Bridge::read_bridge_filteringdatabase_by_id( - const std::string &vlan, const std::string &address) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Read entrytype by ID -* -* Read operation of resource: entrytype* -* -* @param[in] vlan ID of vlan -* @param[in] address ID of address -* -* Responses: -* std::string -*/ -std::string Bridge::read_bridge_filteringdatabase_entrytype_by_id( - const std::string &vlan, const std::string &address) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Read filteringdatabase by ID -* -* Read operation of resource: filteringdatabase* -* -* -* Responses: -* std::vector -*/ -std::vector -Bridge::read_bridge_filteringdatabase_list_by_id() { - std::vector res; - auto fwdtable = get_hash_table("fwdtable"); - auto entries = fwdtable.get_all(); - - struct timespec now_; - clock_gettime(CLOCK_MONOTONIC, &now_); - const uint64_t SEC2NANOSEC = 1000000000ULL; - uint64_t now = now_.tv_sec * SEC2NANOSEC + now_.tv_nsec; - for (auto &it : entries) { - FilteringdatabaseSchema fw; - auto key = it.first; - auto value = it.second; - - if ((now - value.timestamp) > aging_time_ * SEC2NANOSEC) { - logger()->debug("Ignoring old entry: now {0}, timestamp: {1}", now, - value.timestamp); - fwdtable.remove(key); - continue; - } - fw.setAge((now - value.timestamp) / SEC2NANOSEC); - - // get vlan - fw.setVlan(key.vlan); - - // get mac - fw.setAddress(utils::be_uint_to_mac_string(key.mac)); - - // get port - auto p = get_port(value.port); - fw.setPort(p->name()); - - res.emplace_back(fw); - } - - return res; -} - -/** -* @brief Read port by ID -* -* Read operation of resource: port* -* -* @param[in] vlan ID of vlan -* @param[in] address ID of address -* -* Responses: -* std::string -*/ -std::string Bridge::read_bridge_filteringdatabase_port_by_id( - const std::string &vlan, const std::string &address) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Read access by ID -* -* Read operation of resource: access* -* -* @param[in] portsName ID of ports_name -* -* Responses: -* PortsAccessSchema -*/ -PortsAccessSchema Bridge::read_bridge_ports_access_by_id( - const std::string &portsName) { - PortsAccessSchema ports_access; - auto &&p = get_bridge_port(portsName); - ports_access.setVlanid(p.access_vlan()); - return ports_access; -} - -/** -* @brief Read vlanid by ID -* -* Read operation of resource: vlanid* -* -* @param[in] portsName ID of ports_name -* -* Responses: -* int32_t -*/ -int32_t Bridge::read_bridge_ports_access_vlanid_by_id( - const std::string &portsName) { - auto &&p = get_bridge_port(portsName); - return p.access_vlan(); -} - -/** -* @brief Read address by ID -* -* Read operation of resource: address* -* -* @param[in] portsName ID of ports_name -* -* Responses: -* std::string -*/ -std::string Bridge::read_bridge_ports_address_by_id( - const std::string &portsName) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Read mode by ID -* -* Read operation of resource: mode* -* -* @param[in] portsName ID of ports_name -* -* Responses: -* std::string -*/ -std::string Bridge::read_bridge_ports_mode_by_id(const std::string &portsName) { - auto &&p = get_bridge_port(portsName); - return mode_to_string(p.mode()); -} - -/** -* @brief Read stp by ID -* -* Read operation of resource: stp* -* -* @param[in] portsName ID of ports_name -* @param[in] vlan ID of vlan -* -* Responses: -* PortsStpSchema -*/ -PortsStpSchema Bridge::read_bridge_ports_stp_by_id(const std::string &portsName, - const std::string &vlan) { - auto &&stp = get_stp_instance(std::stoul(vlan)); - auto &&p = get_bridge_port(portsName); - PortsStpSchema port; - port.setState(stp.get_port_state_str(p.index())); - port.setVlan(std::stoul(vlan)); - // TODO: pathcost and priority - return port; -} - -/** -* @brief Read stp by ID -* -* Read operation of resource: stp* -* -* @param[in] portsName ID of ports_name -* -* Responses: -* std::vector -*/ -std::vector Bridge::read_bridge_ports_stp_list_by_id( - const std::string &portsName) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Read pathcost by ID -* -* Read operation of resource: pathcost* -* -* @param[in] portsName ID of ports_name -* @param[in] vlan ID of vlan -* -* Responses: -* int32_t -*/ -int32_t Bridge::read_bridge_ports_stp_pathcost_by_id( - const std::string &portsName, const std::string &vlan) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Read portpriority by ID -* -* Read operation of resource: portpriority* -* -* @param[in] portsName ID of ports_name -* @param[in] vlan ID of vlan -* -* Responses: -* int32_t -*/ -int32_t Bridge::read_bridge_ports_stp_portpriority_by_id( - const std::string &portsName, const std::string &vlan) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Read state by ID -* -* Read operation of resource: state* -* -* @param[in] portsName ID of ports_name -* @param[in] vlan ID of vlan -* -* Responses: -* std::string -*/ -std::string Bridge::read_bridge_ports_stp_state_by_id( - const std::string &portsName, const std::string &vlan) { - auto &&stp = get_stp_instance(std::stoul(vlan)); - auto &&p = get_bridge_port(portsName); - return stp.get_port_state_str(p.index()); -} - -/** -* @brief Read allowed by ID -* -* Read operation of resource: allowed* -* -* @param[in] portsName ID of ports_name -* @param[in] vlanid ID of vlanid -* -* Responses: -* PortsTrunkAllowedSchema -*/ -PortsTrunkAllowedSchema Bridge::read_bridge_ports_trunk_allowed_by_id( - const std::string &portsName, const std::string &vlanid) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Read allowed by ID -* -* Read operation of resource: allowed* -* -* @param[in] portsName ID of ports_name -* -* Responses: -* std::vector -*/ -std::vector -Bridge::read_bridge_ports_trunk_allowed_list_by_id( - const std::string &portsName) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Read trunk by ID -* -* Read operation of resource: trunk* -* -* @param[in] portsName ID of ports_name -* -* Responses: -* PortsTrunkSchema -*/ -PortsTrunkSchema Bridge::read_bridge_ports_trunk_by_id( - const std::string &portsName) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Read nativevlan by ID -* -* Read operation of resource: nativevlan* -* -* @param[in] portsName ID of ports_name -* -* Responses: -* int32_t -*/ -int32_t Bridge::read_bridge_ports_trunk_nativevlan_by_id( - const std::string &portsName) { - auto &&p = get_bridge_port(portsName); - return p.native_vlan(); -} - -/** -* @brief Read address by ID -* -* Read operation of resource: address* -* -* @param[in] vlan ID of vlan -* -* Responses: -* std::string -*/ -std::string Bridge::read_bridge_stp_address_by_id(const std::string &vlan) { - auto &&stp = get_stp_instance(std::stoul(vlan)); - return stp.get_address(); -} - -/** -* @brief Read stp by ID -* -* Read operation of resource: stp* -* -* @param[in] vlan ID of vlan -* -* Responses: -* StpSchema -*/ -StpSchema Bridge::read_bridge_stp_by_id(const std::string &vlan) { - auto &&stp = get_stp_instance(std::stoul(vlan)); - StpSchema stpSchema; - stpSchema.setVlan(std::stoul(vlan)); - stpSchema.setHellotime(stp.get_hello_time()); - stpSchema.setForwarddelay(stp.get_forward_delay()); - stpSchema.setPriority(stp.get_priority()); - stpSchema.setMaxmessageage(stp.get_max_age()); - stpSchema.setAddress(stp.get_address()); - return stpSchema; -} - -/** -* @brief Read forwarddelay by ID -* -* Read operation of resource: forwarddelay* -* -* @param[in] vlan ID of vlan -* -* Responses: -* int32_t -*/ -int32_t Bridge::read_bridge_stp_forwarddelay_by_id(const std::string &vlan) { - auto &&stp = get_stp_instance(std::stoul(vlan)); - return stp.get_forward_delay(); -} - -/** -* @brief Read hellotime by ID -* -* Read operation of resource: hellotime* -* -* @param[in] vlan ID of vlan -* -* Responses: -* int32_t -*/ -int32_t Bridge::read_bridge_stp_hellotime_by_id(const std::string &vlan) { - auto &&stp = get_stp_instance(std::stoul(vlan)); - return stp.get_hello_time(); -} - -/** -* @brief Read stp by ID -* -* Read operation of resource: stp* -* -* -* Responses: -* std::vector -*/ -std::vector Bridge::read_bridge_stp_list_by_id() { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Read maxmessageage by ID -* -* Read operation of resource: maxmessageage* -* -* @param[in] vlan ID of vlan -* -* Responses: -* int32_t -*/ -int32_t Bridge::read_bridge_stp_maxmessageage_by_id(const std::string &vlan) { - auto &&stp = get_stp_instance(std::stoul(vlan)); - return stp.get_max_age(); -} - -/** -* @brief Read priority by ID -* -* Read operation of resource: priority* -* -* @param[in] vlan ID of vlan -* -* Responses: -* int32_t -*/ -int32_t Bridge::read_bridge_stp_priority_by_id(const std::string &vlan) { - auto &&stp = get_stp_instance(std::stoul(vlan)); - return stp.get_priority(); -} - -/** -* @brief Read type by ID -* -* Read operation of resource: type* -* -* -* Responses: -* std::string -*/ -std::string Bridge::read_bridge_type_by_id() { - CubeType type = get_type(); - - switch (type) { - case CubeType::TC: - return std::string("TC"); - case CubeType::XDP_SKB: - case CubeType::XDP_DRV: - return std::string("TYPE_XDP"); - } - - return std::string("TYPE_UNKNOWN"); -} - -/** -* @brief Read stpenabled by ID -* -* Read operation of resource: stpenabled* -* -* -* Responses: -* bool -*/ -bool Bridge::read_bridge_stpenabled_by_id() { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Update agingtime by ID -* -* Update operation of resource: agingtime* -* -* @param[in] agingtime Aging time of the filtering database -* -* Responses: -* -*/ -void Bridge::update_bridge_agingtime_by_id(const int32_t &agingtime) { - // avoid unnecessary updates - if (aging_time_ == agingtime) - return; - aging_time_ = agingtime; - reload(generate_code(stp_enabled_)); -} - -/** -* @brief Update bridge by ID -* -* Update operation of resource: bridge* -* -* @param[in] bridge bridgebody object -* -* Responses: -* -*/ -void Bridge::update_bridge_by_id(const BridgeSchema &bridge) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Update filteringdatabase by ID -* -* Update operation of resource: filteringdatabase* -* -* @param[in] vlan ID of vlan -* @param[in] address ID of address -* @param[in] filteringdatabase filteringdatabasebody object -* -* Responses: -* -*/ -void Bridge::update_bridge_filteringdatabase_by_id( - const std::string &vlan, const std::string &address, - const FilteringdatabaseSchema &filteringdatabase) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Update entrytype by ID -* -* Update operation of resource: entrytype* -* -* @param[in] vlan ID of vlan -* @param[in] address ID of address -* @param[in] entrytype Type of filtering entry -* -* Responses: -* -*/ -void Bridge::update_bridge_filteringdatabase_entrytype_by_id( - const std::string &vlan, const std::string &address, - const std::string &entrytype) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Update filteringdatabase by ID -* -* Update operation of resource: filteringdatabase* -* -* @param[in] filteringdatabase filteringdatabasebody object -* -* Responses: -* -*/ -void Bridge::update_bridge_filteringdatabase_list_by_id( - const std::vector &filteringdatabase) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Update port by ID -* -* Update operation of resource: port* -* -* @param[in] vlan ID of vlan -* @param[in] address ID of address -* @param[in] port Output port name -* -* Responses: -* -*/ -void Bridge::update_bridge_filteringdatabase_port_by_id( - const std::string &vlan, const std::string &address, - const std::string &port) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Update access by ID -* -* Update operation of resource: access* -* -* @param[in] portsName ID of ports_name -* @param[in] access accessbody object -* -* Responses: -* -*/ -void Bridge::update_bridge_ports_access_by_id(const std::string &portsName, - const PortsAccessSchema &access) { - auto &&p = get_bridge_port(portsName); - p.set_access_vlan(access.getVlanid()); -} - -/** -* @brief Update vlanid by ID -* -* Update operation of resource: vlanid* -* -* @param[in] portsName ID of ports_name -* @param[in] vlanid VLAN associated with this interface -* -* Responses: -* -*/ -void Bridge::update_bridge_ports_access_vlanid_by_id( - const std::string &portsName, const int32_t &vlanid) { - auto &&p = get_bridge_port(portsName); - p.set_access_vlan(vlanid); -} - -/** -* @brief Update address by ID -* -* Update operation of resource: address* -* -* @param[in] portsName ID of ports_name -* @param[in] address MAC address of the port -* -* Responses: -* -*/ -void Bridge::update_bridge_ports_address_by_id(const std::string &portsName, - const std::string &address) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Update mode by ID -* -* Update operation of resource: mode* -* -* @param[in] portsName ID of ports_name -* @param[in] mode Type of bridge interface: access/trunk -* -* Responses: -* -*/ -void Bridge::update_bridge_ports_mode_by_id(const std::string &portsName, - const std::string &mode) { - auto &&p = get_bridge_port(portsName); - PortMode requested_mode = string_to_mode(mode); - p.set_mode(requested_mode); -} - -/** -* @brief Update stp by ID -* -* Update operation of resource: stp* -* -* @param[in] portsName ID of ports_name -* @param[in] vlan ID of vlan -* @param[in] stp stpbody object -* -* Responses: -* -*/ -void Bridge::update_bridge_ports_stp_by_id(const std::string &portsName, - const std::string &vlan, - const PortsStpSchema &stp) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Update stp by ID -* -* Update operation of resource: stp* -* -* @param[in] portsName ID of ports_name -* @param[in] stp stpbody object -* -* Responses: -* -*/ -void Bridge::update_bridge_ports_stp_list_by_id( - const std::string &portsName, const std::vector &stp) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Update pathcost by ID -* -* Update operation of resource: pathcost* -* -* @param[in] portsName ID of ports_name -* @param[in] vlan ID of vlan -* @param[in] pathcost STP cost associated with this interface -* -* Responses: -* -*/ -void Bridge::update_bridge_ports_stp_pathcost_by_id( - const std::string &portsName, const std::string &vlan, - const int32_t &pathcost) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Update portpriority by ID -* -* Update operation of resource: portpriority* -* -* @param[in] portsName ID of ports_name -* @param[in] vlan ID of vlan -* @param[in] portpriority Port priority of this interface -* -* Responses: -* -*/ -void Bridge::update_bridge_ports_stp_portpriority_by_id( - const std::string &portsName, const std::string &vlan, - const int32_t &portpriority) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Update allowed by ID -* -* Update operation of resource: allowed* -* -* @param[in] portsName ID of ports_name -* @param[in] vlanid ID of vlanid -* @param[in] allowed allowedbody object -* -* Responses: -* -*/ -void Bridge::update_bridge_ports_trunk_allowed_by_id( - const std::string &portsName, const std::string &vlanid, - const PortsTrunkAllowedSchema &allowed) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Update allowed by ID -* -* Update operation of resource: allowed* -* -* @param[in] portsName ID of ports_name -* @param[in] allowed allowedbody object -* -* Responses: -* -*/ -void Bridge::update_bridge_ports_trunk_allowed_list_by_id( - const std::string &portsName, - const std::vector &allowed) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Update trunk by ID -* -* Update operation of resource: trunk* -* -* @param[in] portsName ID of ports_name -* @param[in] trunk trunkbody object -* -* Responses: -* -*/ -void Bridge::update_bridge_ports_trunk_by_id(const std::string &portsName, - const PortsTrunkSchema &trunk) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Update nativevlan by ID -* -* Update operation of resource: nativevlan* -* -* @param[in] portsName ID of ports_name -* @param[in] nativevlan VLAN that is not tagged in this trunk port -* -* Responses: -* -*/ -void Bridge::update_bridge_ports_trunk_nativevlan_by_id( - const std::string &portsName, const int32_t &nativevlan) { - logger()->info("Updating native vlan!"); - auto &&p = get_bridge_port(portsName); - p.set_native_vlan(nativevlan); - logger()->info("native vlan updated!"); -} - -/** -* @brief Update address by ID -* -* Update operation of resource: address* -* -* @param[in] vlan ID of vlan -* @param[in] address Main MAC address used by the STP -* -* Responses: -* -*/ -void Bridge::update_bridge_stp_address_by_id(const std::string &vlan, - const std::string &address) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Update stp by ID -* -* Update operation of resource: stp* -* -* @param[in] vlan ID of vlan -* @param[in] stp stpbody object -* -* Responses: -* -*/ -void Bridge::update_bridge_stp_by_id(const std::string &vlan, - const StpSchema &stp) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Update forwarddelay by ID -* -* Update operation of resource: forwarddelay* -* -* @param[in] vlan ID of vlan -* @param[in] forwarddelay Delay used by STP bridges for port state transition -* -* Responses: -* -*/ -void Bridge::update_bridge_stp_forwarddelay_by_id(const std::string &vlan, - const int32_t &forwarddelay) { - auto &&stp = get_stp_instance(std::stoul(vlan)); - stp.set_forward_delay(forwarddelay); -} - -/** -* @brief Update hellotime by ID -* -* Update operation of resource: hellotime* -* -* @param[in] vlan ID of vlan -* @param[in] hellotime Interval between transmissions of BPDU messages -* -* Responses: -* -*/ -void Bridge::update_bridge_stp_hellotime_by_id(const std::string &vlan, - const int32_t &hellotime) { - auto &&stp = get_stp_instance(std::stoul(vlan)); - stp.set_hello_time(hellotime); -} - -/** -* @brief Update stp by ID -* -* Update operation of resource: stp* -* -* @param[in] stp stpbody object -* -* Responses: -* -*/ -void Bridge::update_bridge_stp_list_by_id(const std::vector &stp) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Update maxmessageage by ID -* -* Update operation of resource: maxmessageage* -* -* @param[in] vlan ID of vlan -* @param[in] maxmessageage Maximum age of a BPDU -* -* Responses: -* -*/ -void Bridge::update_bridge_stp_maxmessageage_by_id( - const std::string &vlan, const int32_t &maxmessageage) { - auto &&stp = get_stp_instance(std::stoul(vlan)); - stp.set_max_age(maxmessageage); -} - -/** -* @brief Update priority by ID -* -* Update operation of resource: priority* -* -* @param[in] vlan ID of vlan -* @param[in] priority Bridge priority for STP -* -* Responses: -* -*/ -void Bridge::update_bridge_stp_priority_by_id(const std::string &vlan, - const int32_t &priority) { - auto &&stp = get_stp_instance(std::stoul(vlan)); - stp.set_priority(priority); -} - -/** -* @brief Update stpenabled by ID -* -* Update operation of resource: stpenabled* -* -* @param[in] stpenabled Enable/Disable the STP protocol of the bridge -* -* Responses: -* -*/ -void Bridge::update_bridge_stpenabled_by_id(const bool &stpenabled) { - throw std::runtime_error("Method not implemented"); -} - -/** -* @brief Update type by ID -* -* Update operation of resource: type* -* -* @param[in] type Type of the Cube (TC, XDP_SKB, XDP_DRV) -* -* Responses: -* -*/ -void Bridge::update_bridge_type_by_id(const std::string &type) { - throw std::runtime_error("You cannot change the CubeType at runtime"); -} diff --git a/src/services/pcn-bridge/src/BridgeSTP.cpp b/src/services/pcn-bridge/src/BridgeSTP.cpp deleted file mode 100644 index 5102563f7..000000000 --- a/src/services/pcn-bridge/src/BridgeSTP.cpp +++ /dev/null @@ -1,339 +0,0 @@ -/* - * Copyright 2017 The Polycube Authors - * - * 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 "Bridge.h" -#include "BridgeSTP.h" - -// Spanning tree related methods -BridgeSTP::BridgeSTP(Bridge &parent, uint16_t vlan_id) - : parent(parent), vlan_id(vlan_id), l(spdlog::get("pcn-bridge")) { - std::random_device rd; - std::mt19937 mt(rd()); - std::uniform_int_distribution dist(1, UINT64_MAX); - - uint64_t bridge_mac = dist(mt); - bridge_mac &= ~(1ULL << 40); // unicast - bridge_mac |= (1ULL << 41); // locally administrated - - // Copy mac to uint8_t array - uint64_t t = bridge_mac; - for (int i = 5; i >= 0; i--) { - mac[i] = t & 0xFF; - t >>= 8; - } - - l->info("{0} mac is {1}", parent.get_name(), mac_to_string(mac)); - stp = - stp_create(parent.get_name().c_str(), bridge_mac, send_bpdu_proxy, this); - if (!stp) { - throw std::runtime_error("failed to create stp instance"); - } - - stp_set_bridge_priority(stp, STP_DEFAULT_BRIDGE_PRIORITY); - - stop_ = false; - std::unique_ptr uptr( - new std::thread([&](void) -> void { stp_tick_function(); })); - stp_tick_thread = std::move(uptr); -} - -BridgeSTP::~BridgeSTP() { - stop_ = true; - if (stp_tick_thread) { - l->debug("Trying to join stp_tick thread"); - stp_tick_thread->join(); - } - stp_unref(stp); -} - -void BridgeSTP::add_port(int port_id) { - if (ports_.count(port_id) != 0) { - l->error("port {0} already exists on instance {1}", port_id, vlan_id); - return; - } - - struct stp_port *sp = stp_get_port(stp, port_id); - stp_port_enable(sp); - stp_port_set_speed(sp, 1000000); - auto p = parent.get_port(port_id); - stp_port_set_name(sp, p->name().c_str()); - ports_.insert(port_id); -} - -void BridgeSTP::remove_port(int port_id) { - if (ports_.count(port_id) == 0) { - l->error("port {0} does not exist on instance {1}", port_id, vlan_id); - return; - } - struct stp_port *sp = stp_get_port(stp, port_id); - stp_port_disable(sp); - ports_.erase(port_id); -} - -int BridgeSTP::ports_count() { - return ports_.size(); -} - -void BridgeSTP::process_bpdu(int port_id, const std::vector &packet) { - struct stp_port *sp = stp_get_port(stp, port_id); - if (!sp) { - l->warn("Stp port {0} not found", port_id); - return; - } - // Headers are already stripped - size_t s = packet.size(); - const void *p = &packet[0]; - stp_received_bpdu(sp, p, s); - std::lock_guard lock(stp_mutex); - update_ports_state(); - update_fwd_table(); -} - -void BridgeSTP::send_bpdu(struct ofpbuf *bpdu, int port_no, void *aux) { - // l->debug("Sending BPDU"); - struct stp_port *sp = stp_get_port(stp, port_no); - if (!stp_should_forward_bpdu(stp_port_get_state(sp))) { - l->debug("Port should not forward BDPU"); - return; - } - - auto &port = parent.get_bridge_port(port_no); - // is a peer on the port? - if (port.peer().empty()) - return; - - uint8_t *buf = (uint8_t *)ofpbuf_base(bpdu); - memcpy(buf + 6, mac, ETH_ADDR_LEN); // set source mac - - EthernetII packet(buf, ofpbuf_size(bpdu)); - ofpbuf_free(bpdu); - - switch (port.mode()) { - case PortMode::ACCESS: - if (port.access_vlan() != vlan_id) { - l->info("[{0}]: impossible to send bpdu on access port {0}", - parent.get_name(), port.name()); - return; - } - - port.Port::send_packet_out(packet); - break; - case PortMode::TRUNK: - if (!port.is_trunk_vlan_allowed(vlan_id)) { - l->info("[{0}]: impossible to send bpdu on trunk port {0}", - parent.get_name(), port.name()); - return; - } - - if (vlan_id == port.native_vlan()) { - port.Port::send_packet_out(packet); - } else { - HWAddress<6> sstp("01:00:0c:cc:cc:cd"); - packet.dst_addr(sstp); - EthernetII tagged_p = EthernetII(packet.dst_addr(), packet.src_addr()); - - Dot1Q dot1q(vlan_id); - dot1q.payload_type(packet.payload_type()); - tagged_p /= dot1q; - - PDU *p_inner = packet.inner_pdu(); - tagged_p /= *p_inner; - - port.Port::send_packet_out(tagged_p); - } - break; - } -} - -void BridgeSTP::send_bpdu_proxy(struct ofpbuf *bpdu, int port_no, void *aux) { - BridgeSTP *br_stp = static_cast(aux); - if (br_stp == nullptr) { - throw std::runtime_error("Bad BridgeSTP"); - } - - br_stp->send_bpdu(bpdu, port_no, aux); -} - -void BridgeSTP::update_ports_state() { - struct stp_port *sp = nullptr; - - while (stp_get_changed_port(stp, &sp)) { - uint32_t vlan; - enum stp_state state; - try { - state = stp_port_get_state(sp); - auto &bp = parent.get_bridge_port(stp_port_no(sp)); - l->info("[{0}]: port {1} has changed the state to {2}", parent.get_name(), - bp.name(), stp_state_name(state)); - - if (bp.mode() == PortMode::ACCESS) - vlan = VLAN_WILDCARD; - else if (bp.mode() == PortMode::TRUNK) - vlan = vlan_id; - } catch (...) { - continue; - } - - port_vlan_key key{ - .port = uint32_t(stp_port_no(sp)), .vlan = vlan, - }; - - port_vlan_value value{ - .vlan = vlan_id, .stp_state = state, - }; - - auto port_vlan_table = - parent.get_hash_table("port_vlan"); - port_vlan_table.set(key, value); - } -} - -void BridgeSTP::update_fwd_table() { - // should the fwd table be flushed? - if (stp_check_and_reset_fdb_flush(stp)) { - l->info("[{0}]: flushing forwarding table", parent.get_name()); - auto fwdtable = parent.get_hash_table("fwdtable"); - fwdtable.remove_all(); - // TODO: only entries regarding this vlan should be removed - } -} - -void BridgeSTP::stp_tick_function(void) { - const auto timeWindow = std::chrono::milliseconds(500); - - auto last = std::chrono::steady_clock::now(); - - while (!stop_) { - std::this_thread::sleep_for(timeWindow); - auto now = std::chrono::steady_clock::now(); - int ms = std::chrono::duration_cast(now - last) - .count(); - last = now; - stp_tick(stp, ms); - std::lock_guard lock(stp_mutex); - update_ports_state(); - update_fwd_table(); - } -} - -bool BridgeSTP::port_should_forward(int port_id) { - struct stp_port *sp = stp_get_port(stp, port_id); - return stp_forward_in_state(stp_port_get_state(sp)); -} - -void BridgeSTP::set_priority(uint16_t priority) { - stp_set_bridge_priority(stp, priority); -} - -void BridgeSTP::set_hello_time(int hello_time) { - stp_set_hello_time(stp, hello_time * 1000); -} - -void BridgeSTP::set_max_age(int max_age) { - stp_set_max_age(stp, max_age * 1000); -} - -void BridgeSTP::set_forward_delay(int forward_delay) { - stp_set_forward_delay(stp, forward_delay * 1000); -} - -uint16_t BridgeSTP::get_priority() const { - stp_identifier id = stp_get_bridge_id(stp); - return (id >> 48) & 0xffff; -} - -std::string BridgeSTP::get_address() const { - return mac_to_string(mac); -} - -std::string BridgeSTP::get_designated_root() const { - uint8_t mac[ETH_ADDR_LEN]; - uint64_t t = stp_get_designated_root(stp); - t &= 0xffffffffffffULL; - for (int i = 5; i >= 0; i--) { - mac[i] = t & 0xFF; - t >>= 8; - } - - return mac_to_string(mac); -} - -bool BridgeSTP::is_root_bridge() const { - return stp_is_root_bridge(stp); -} - -int BridgeSTP::get_root_path_cost() const { - return stp_get_root_path_cost(stp); -} - -int BridgeSTP::get_hello_time() const { - return stp_get_hello_time(stp) / 1000; -} - -int BridgeSTP::get_max_age() const { - return stp_get_max_age(stp) / 1000; -} - -int BridgeSTP::get_forward_delay() const { - return stp_get_forward_delay(stp) / 1000; -} - -bool BridgeSTP::check_and_reset_fdb_flush() const { - return stp_check_and_reset_fdb_flush(stp); -} - -enum stp_state BridgeSTP::get_port_state(int port_id) { - return stp_port_get_state(stp_get_port(stp, port_id)); -} - -std::string BridgeSTP::get_port_state_str(int port_id) { - return stp_state_name(get_port_state(port_id)); -} - -enum stp_role BridgeSTP::get_port_role(int port_id) { - return stp_port_get_role(stp_get_port(stp, port_id)); -} - -void BridgeSTP::set_port_priority(int port_id, uint8_t new_priority) { - stp_port_set_priority(stp_get_port(stp, port_id), new_priority); -} - -void BridgeSTP::set_port_path_cost(int port_id, uint16_t path_cost) { - stp_port_set_path_cost(stp_get_port(stp, port_id), path_cost); -} - -void BridgeSTP::set_port_speed(int port_id, unsigned int speed) { - stp_port_set_speed(stp_get_port(stp, port_id), speed); -} - -void BridgeSTP::enable_port_change_detection(int port_id) { - stp_port_enable_change_detection(stp_get_port(stp, port_id)); -} - -void BridgeSTP::disable_port_change_detection(int port_id) { - stp_port_disable_change_detection(stp_get_port(stp, port_id)); -} - -std::string BridgeSTP::mac_to_string(const uint8_t *mac) const { - std::stringstream ret; - ret << std::setfill('0') << std::setw(2) << std::hex << (int)mac[0] << ":"; - ret << std::setfill('0') << std::setw(2) << std::hex << (int)mac[1] << ":"; - ret << std::setfill('0') << std::setw(2) << std::hex << (int)mac[2] << ":"; - ret << std::setfill('0') << std::setw(2) << std::hex << (int)mac[3] << ":"; - ret << std::setfill('0') << std::setw(2) << std::hex << (int)mac[4] << ":"; - ret << std::setfill('0') << std::setw(2) << std::hex << (int)mac[5]; - return ret.str(); -} diff --git a/src/services/pcn-bridge/src/BridgeSTP.h b/src/services/pcn-bridge/src/BridgeSTP.h deleted file mode 100644 index 88efda8e8..000000000 --- a/src/services/pcn-bridge/src/BridgeSTP.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2017 The Polycube Authors - * - * 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. - */ - -#pragma once - -#include -#include -#include -#include -#include -#include -#include "stp/stp.h" - -#include "polycube/services/cube.h" -#include "polycube/services/port.h" -#include "polycube/services/utils.h" - -#include -#include -#include - -#include - -using namespace polycube::service; -using namespace Tins; - -class Bridge; - -class BridgeSTP { - public: - BridgeSTP(Bridge &parent, uint16_t vlan_id); - ~BridgeSTP(); - void add_port(int port_id); - void remove_port(int port_id); - int ports_count(); - - void process_bpdu(int port_id, const std::vector &packet); - void send_bpdu(struct ofpbuf *bpdu, int port_no, void *aux); - void update_ports_state(); - void update_fwd_table(); - - bool port_should_forward( - int port_id); // should this port forward packets for this vlan? - - /* STP management functions */ - void set_priority(uint16_t priority); - void set_hello_time(int hello_time); - void set_max_age(int max_age); - void set_forward_delay(int forward_delay); - void set_address(const std::string &address); - - uint16_t get_priority() const; - std::string get_address() const; - std::string get_designated_root() const; - bool is_root_bridge() const; - int get_root_path_cost() const; - int get_hello_time() const; - int get_max_age() const; - int get_forward_delay() const; - bool check_and_reset_fdb_flush() const; - - /* STP ports related funtions */ - enum stp_state get_port_state(int port_id); - std::string get_port_state_str(int port_id); - enum stp_role get_port_role(int port_id); - void set_port_priority(int port_id, uint8_t new_priority); - void set_port_path_cost(int port_id, uint16_t path_cost); - void set_port_speed(int port_id, unsigned int speed); - void enable_port_change_detection(int port_id); - void disable_port_change_detection(int port_id); - - private: - void stp_tick_function(); - static void send_bpdu_proxy(struct ofpbuf *bpdu, int port_no, void *aux); - - std::string mac_to_string(const uint8_t *mac) const; - - struct stp *stp; - std::mutex stp_mutex; - uint16_t vlan_id; - Bridge &parent; - uint8_t mac[ETH_ADDR_LEN]; - bool stop_; - std::unique_ptr stp_tick_thread; - std::shared_ptr l; - std::set ports_; -}; diff --git a/src/services/pcn-bridge/src/Bridge_dp_no_stp.c b/src/services/pcn-bridge/src/Bridge_dp_no_stp.c deleted file mode 100644 index ed5f15053..000000000 --- a/src/services/pcn-bridge/src/Bridge_dp_no_stp.c +++ /dev/null @@ -1,301 +0,0 @@ -/* - * Copyright 2017 The Polycube Authors - * - * 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 -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -enum { BPDU_REASON = 1, BROADCAST_REASON }; - -enum { PORT_MODE_ACCESS = 0, PORT_MODE_TRUNK }; - -#define VLAN_WILDCARD 0x00 - -/* - * Allowed Vlans table is used to set and verify vlans associated to a port - * in access or trunk mode. The usage is provided in the following example. -*/ -struct port_vlan_key { - // todo use u16 instead of u32 - u32 port; - u32 vlan; -} __attribute__((packed)); - -struct port_vlan_value { - u16 vlan; - u16 stp_state; -} __attribute__((packed)); - -BPF_TABLE("hash", struct port_vlan_key, struct port_vlan_value, port_vlan, - 1024); -/* - * port_vlan usage example: - * -> vlanid - * - * port 1 access vlan=10 - * 1 VLAN_WILDCARD -> 10 - * - * port 3 trunk vlan=30,40 - * 3 30 -> 30 - * 3 40 -> 40 - * - * port 4 trunk vlan=all - * 4 VLAN_WILDCARD -> VLAN_WILDCARD -*/ - -/* - * Fowarding Table: VLAN + MAC Address to port association. This table is - * filled - * in the learning phase and then is used in the forwarding phase to decide - * where to send a packet -*/ -struct fwd_key { - u32 vlan; - __be64 mac; -} __attribute__((packed)); - -struct fwd_entry { - u64 timestamp; - u32 port; -} __attribute__((packed)); - -BPF_TABLE("hash", struct fwd_key, struct fwd_entry, fwdtable, 1024); - -/* - * Port Table: Saves the state of the ports - * TODO: what is the best option in this case, hash vs array? -*/ -struct port { - u16 mode; - u16 native_vlan; -}; - -BPF_TABLE("hash", u32, struct port, ports, 256); - -struct eth_hdr { - __be64 dst : 48; - __be64 src : 48; - __be16 proto; -} __attribute__((packed)); - -static int handle_rx(struct CTXTYPE *ctx, struct pkt_metadata *md) { - void *data = (void *)(long)ctx->data; - void *data_end = (void *)(long)ctx->data_end; - struct eth_hdr *eth = data; - - if (data + sizeof(*eth) > data_end) - goto DROP; - - u32 in_ifc = md->in_port; - - pcn_log(ctx, LOG_DEBUG, "in_ifc=%d proto=0x%x", in_ifc, - bpf_ntohs(eth->proto)); - pcn_log(ctx, LOG_DEBUG, "mac src:%M dst:%M", eth->src, eth->dst); - - u32 vlanid = 0; -#ifdef POLYCUBE_XDP - bool tagged = pcn_is_vlan_present(ctx); - - if (tagged) { - u16 vlan_u16; - u16 eth_proto; - if (pcn_get_vlan_id(ctx, &vlan_u16, ð_proto) < 0) - goto DROP; - - vlanid = (u32)vlan_u16; - } -#else - bool tagged = ctx->vlan_present; - - if (tagged) - vlanid = ctx->vlan_tci & 0x0fff; -#endif - - struct port *in_port = ports.lookup(&in_ifc); - if (!in_port) { - pcn_log(ctx, LOG_ERR, "Port %u not found", in_ifc); - goto DROP; - } - - struct port_vlan_key vlan_key; - struct port_vlan_value *vlan_entry; - - vlan_key.port = in_ifc; - - if (in_port->mode == PORT_MODE_ACCESS) { - if (tagged) - goto DROP; - - vlan_key.vlan = VLAN_WILDCARD; - vlan_entry = port_vlan.lookup(&vlan_key); - if (!vlan_entry) - goto DROP; // TODO: is this code correct? - - vlanid = vlan_entry->vlan; - - pcn_log(ctx, LOG_TRACE, "port mode ACCESS vlan=%d, state=%d", vlanid, - vlan_entry->stp_state); - } else { - // TRUNK - if (!tagged) { - vlanid = in_port->native_vlan; - } else { - vlan_key.vlan = vlanid; - vlan_entry = port_vlan.lookup(&vlan_key); - if (!vlan_entry) { - // TODO manage case of all vlans allowed - goto DROP; - } - } - } - - // LEARNING PHASE - struct fwd_key src_key; - src_key.vlan = vlanid; - src_key.mac = eth->src; - struct fwd_entry e; // used below - e.timestamp = bpf_ktime_get_ns(); - e.port = in_ifc; - fwdtable.update(&src_key, &e); - - // FORWARDING PHASE: select interface(s) to send the packet - struct fwd_key dst_key; - dst_key.vlan = vlanid; - dst_key.mac = eth->dst; - - // lookup in forwarding table fwdtable - struct fwd_entry *entry = fwdtable.lookup(&dst_key); - if (!entry) { - // bpf_trace_printk("entry not found\n"); - goto DO_FLOODING; - } - - // check if the entry is too old - u64 now = bpf_ktime_get_ns(); - u64 timestamp = entry->timestamp; - if (now < timestamp) { - goto FORWARD; - } - if (now - timestamp > AGING_TIME * 1000000000ULL) { - // bpf_trace_printk("entry too old\n"); - fwdtable.delete(&dst_key); - goto DO_FLOODING; - } - entry->timestamp = now; - -FORWARD:; - u32 dst_interface = entry->port; // workaround for verifier - struct port *out_port = ports.lookup(&dst_interface); - if (!out_port) { - pcn_log(ctx, LOG_ERR, "Port %u not found", dst_interface); - goto DROP; - } - - // HIT in forwarding table - // redirect packet to dst_interface - - /* do not send packet back on the ingress interface */ - if (dst_interface == in_ifc) - goto DROP; - - // check output vlan - if (out_port->mode == PORT_MODE_ACCESS) { - vlan_key.port = dst_interface; - vlan_key.vlan = VLAN_WILDCARD; - vlan_entry = port_vlan.lookup(&vlan_key); - if (!vlan_entry) { - // bpf_trace_printk("dropping paket: no entry in allowed vlans\n"); - goto DROP; - } - - if (vlan_entry->vlan != vlanid) { - // bpf_trace_printk("dropping packet: vlan_entry %d vlanid %d\n", - // vlan_entry->vlan, vlanid); - goto DROP; - } - - if (tagged) { -#ifdef POLYCUBE_XDP - if (pcn_pop_vlan_tag(ctx) != 0) { - pcn_log(ctx, LOG_ERR, "error pcn_push_vlan_tag"); - goto DROP; - } -#else - uint8_t r = bpf_skb_vlan_pop(ctx); - if (r) - pcn_log(ctx, LOG_ERR, "error vlan_pop"); -#endif - } - } else if (out_port->mode == PORT_MODE_TRUNK) { - if (vlanid == out_port->native_vlan) { - if (tagged) { -#ifdef POLYCUBE_XDP - if (pcn_pop_vlan_tag(ctx) != 0) { - pcn_log(ctx, LOG_ERR, "error pcn_push_vlan_tag"); - goto DROP; - } -#else - uint8_t r = bpf_skb_vlan_pop(ctx); - if (r) - pcn_log(ctx, LOG_ERR, "error vlan_pop"); -#endif - } - } else { - vlan_key.port = dst_interface; - vlan_key.vlan = vlanid; - vlan_entry = port_vlan.lookup(&vlan_key); - if (!vlan_entry) { - // bpf_trace_printk("dropping packet: trunk vlan entry not present\n"); - goto DROP; - } - if (!tagged) { -// todo check tag correctness -#ifdef POLYCUBE_XDP - if (pcn_push_vlan_tag(ctx, eth->proto, vlanid) != 0) { - goto DROP; - } -#else - uint8_t r = bpf_skb_vlan_push(ctx, eth->proto, vlanid); - if (r) - pcn_log(ctx, LOG_ERR, "error pcn_push_vlan_tag"); -#endif - } - } - } - - pcn_log(ctx, LOG_TRACE, "redirect out_ifc=%d", dst_interface); - return pcn_pkt_redirect(ctx, md, dst_interface); - -DO_FLOODING:; - pcn_log(ctx, LOG_TRACE, "broadcast"); - u32 mdata[3]; - mdata[0] = vlanid; - mdata[1] = tagged; - return pcn_pkt_controller_with_metadata(ctx, md, BROADCAST_REASON, mdata); - -DROP: - pcn_log(ctx, LOG_TRACE, "drop"); - return RX_DROP; -} diff --git a/src/services/pcn-bridge/src/Bridge_dp_stp.c b/src/services/pcn-bridge/src/Bridge_dp_stp.c deleted file mode 100644 index fc73ac0ab..000000000 --- a/src/services/pcn-bridge/src/Bridge_dp_stp.c +++ /dev/null @@ -1,356 +0,0 @@ -/* - * Copyright 2017 The Polycube Authors - * - * 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. - */ - -#pragma once - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -enum { BPDU_REASON = 1, BROADCAST_REASON }; - -enum { PORT_MODE_ACCESS = 0, PORT_MODE_TRUNK }; - -#define VLAN_WILDCARD 0x00 - -enum stp_state { - STP_DISABLED = 1 << 0, /* 8.4.5: See note above. */ - STP_LISTENING = 1 << 1, /* 8.4.2: Not learning or relaying frames. */ - STP_LEARNING = 1 << 2, /* 8.4.3: Learning but not relaying frames. */ - STP_FORWARDING = 1 << 3, /* 8.4.4: Learning and relaying frames. */ - STP_BLOCKING = 1 << 4 /* 8.4.1: Initial boot state. */ -}; - -/* Returns true if 'state' is one in which packets received on a port should - * be forwarded, false otherwise. - * - * Returns true if 'state' is STP_DISABLED, since presumably in that case the - * port should still work, just not have STP applied to it. */ -static __always_inline u32 stp_forward_in_state(u32 state) { - return (state & (STP_DISABLED | STP_FORWARDING)) != 0; -} - -/* Returns true if 'state' is one in which MAC learning should be done on - * packets received on a port, false otherwise. - * - * Returns true if 'state' is STP_DISABLED, since presumably in that case the - * port should still work, just not have STP applied to it. */ -static __always_inline u32 stp_learn_in_state(u32 state) { - return (state & (STP_DISABLED | STP_LEARNING | STP_FORWARDING)) != 0; -} - -/* - * Allowed Vlans table is used to set and verify vlans associated to a port - * in access or trunk mode. The usage is provided in the following example. -*/ -struct port_vlan_key { - // todo use u16 instead of u32 - u32 port; - u32 vlan; -} __attribute__((packed)); - -struct port_vlan_value { - u16 vlan; - u16 stp_state; -} __attribute__((packed)); - -BPF_TABLE("hash", struct port_vlan_key, struct port_vlan_value, port_vlan, - 1024); -/* - * port_vlan usage example: - * -> vlanid - * - * port 1 access vlan=10 - * 1 VLAN_WILDCARD -> 10 - * - * port 3 trunk vlan=30,40 - * 3 30 -> 30 - * 3 40 -> 40 - * - * port 4 trunk vlan=all - * 4 VLAN_WILDCARD -> VLAN_WILDCARD -*/ - -/* - * Fowarding Table: VLAN + MAC Address to port association. This table is - * filled - * in the learning phase and then is used in the forwarding phase to decide - * where to send a packet -*/ -struct fwd_key { - u32 vlan; - __be64 mac; -} __attribute__((packed)); - -struct fwd_entry { - u64 timestamp; - u32 port; -} __attribute__((packed)); - -BPF_TABLE("hash", struct fwd_key, struct fwd_entry, fwdtable, 1024); - -/* - * Port Table: Saves the state of the ports - * TODO: what is the best option in this case, hash vs array? -*/ -struct port { - u16 mode; - u16 native_vlan; -}; - -BPF_TABLE("hash", u32, struct port, ports, 256); - -struct eth_hdr { - __be64 dst : 48; - __be64 src : 48; - __be16 proto; -} __attribute__((packed)); - -static __always_inline int handle_rx(struct CTXTYPE *ctx, - struct pkt_metadata *md) { - void *data = (void *)(long)ctx->data; - void *data_end = (void *)(long)ctx->data_end; - struct eth_hdr *eth = data; - - if (data + sizeof(*eth) > data_end) - goto DROP; - - u32 in_ifc = md->in_port; - - pcn_log(ctx, LOG_DEBUG, "in_ifc=%d proto=0x%x mac src:%M dst:%M", in_ifc, - bpf_ntohs(eth->proto), eth->src, eth->dst); - - u32 vlanid = 0; -#ifdef POLYCUBE_XDP - bool tagged = pcn_is_vlan_present(ctx); - - if (tagged) { - u16 vlan_u16; - u16 eth_proto; - if (pcn_get_vlan_id(ctx, &vlan_u16, ð_proto) < 0) - goto DROP; - - vlanid = (u32)vlan_u16; - } -#else - bool tagged = ctx->vlan_present; - - if (tagged) - vlanid = ctx->vlan_tci & 0x0fff; -#endif - - struct port *in_port = ports.lookup(&in_ifc); - if (!in_port) { - pcn_log(ctx, LOG_ERR, "Port %u not found", in_ifc); - goto DROP; - } - - struct port_vlan_key vlan_key; - struct port_vlan_value *vlan_entry; - - vlan_key.port = in_ifc; - - if (in_port->mode == PORT_MODE_ACCESS) { - if (tagged) - goto DROP; - - vlan_key.vlan = VLAN_WILDCARD; - vlan_entry = port_vlan.lookup(&vlan_key); - if (!vlan_entry) - goto DROP; // TODO: is this code correct? - - vlanid = vlan_entry->vlan; - pcn_log(ctx, LOG_TRACE, "port mode ACCESS vlan=%d, state=%d", vlanid, - vlan_entry->stp_state); - } else { - // TRUNK - if (!tagged) { - vlanid = in_port->native_vlan; - } else { - vlan_key.vlan = vlanid; - vlan_entry = port_vlan.lookup(&vlan_key); - if (!vlan_entry) { - // TODO manage case of all vlans allowed - goto DROP; - } - } - } - - // TODO: this is probably wrong or could done better, for example adding - // a fake entry on the forwarding table - // if the packet is a BPDU, send it to the slowpath - if (eth->dst == 0x000000C28001 || eth->dst == 0xCDCCCC0C0001) { - u32 mdata[3]; - mdata[0] = vlanid; - mdata[1] = tagged; - return pcn_pkt_controller_with_metadata(ctx, md, BPDU_REASON, mdata); - } - - // Should learning be performed? - if (!stp_learn_in_state(vlan_entry->stp_state)) { - pcn_log(ctx, LOG_TRACE, "port %d should not learn: state: %d", in_ifc, - vlan_entry->stp_state); - return RX_DROP; - } - - // LEARNING PHASE - struct fwd_key src_key; - src_key.vlan = vlanid; - src_key.mac = eth->src; - struct fwd_entry e; // used below - e.timestamp = bpf_ktime_get_ns(); - e.port = in_ifc; - fwdtable.update(&src_key, &e); - - // should forwarding be performed? - if (!stp_forward_in_state(vlan_entry->stp_state)) { - pcn_log(ctx, LOG_TRACE, "port %d should not forward\n", in_ifc); - return RX_DROP; - } - - // FORWARDING PHASE: select interface(s) to send the packet - struct fwd_key dst_key; - dst_key.vlan = vlanid; - dst_key.mac = eth->dst; - - // lookup in forwarding table fwdtable - struct fwd_entry *entry = fwdtable.lookup(&dst_key); - if (!entry) { - // bpf_trace_printk("entry not found\n"); - goto DO_FLOODING; - } - - // check if the entry is too old - u64 now = bpf_ktime_get_ns(); - u64 timestamp = entry->timestamp; - if (now < timestamp) { - goto FORWARD; - } - if (now - timestamp > AGING_TIME * 1000000000ULL) { - // bpf_trace_printk("entry too old\n"); - fwdtable.delete(&dst_key); - goto DO_FLOODING; - } - entry->timestamp = now; - -FORWARD:; - u32 dst_interface = entry->port; // workaround for verifier - struct port *out_port = ports.lookup(&dst_interface); - if (!out_port) { - pcn_log(ctx, LOG_ERR, "Port %u not found", dst_interface); - goto DROP; - } - - // HIT in forwarding table - // redirect packet to dst_interface - - /* do not send packet back on the ingress interface */ - if (dst_interface == in_ifc) - goto DROP; - - // check output vlan - if (out_port->mode == PORT_MODE_ACCESS) { - vlan_key.port = dst_interface; - vlan_key.vlan = VLAN_WILDCARD; - vlan_entry = port_vlan.lookup(&vlan_key); - if (!vlan_entry) { - // bpf_trace_printk("dropping paket: no entry in allowed vlans\n"); - goto DROP; - } - - if (vlan_entry->vlan != vlanid) { - // bpf_trace_printk("dropping packet: vlan_entry %d vlanid %d\n", - // vlan_entry->vlan, vlanid); - goto DROP; - } - - if (tagged) { -#ifdef POLYCUBE_XDP - if (pcn_pop_vlan_tag(ctx) != 0) { - pcn_log(ctx, LOG_ERR, "error pcn_push_vlan_tag"); - goto DROP; - } -#else - uint8_t r = bpf_skb_vlan_pop(ctx); - if (r) - pcn_log(ctx, LOG_ERR, "error vlan_pop"); -#endif - } - } else if (out_port->mode == PORT_MODE_TRUNK) { - if (vlanid == out_port->native_vlan) { - if (tagged) { -#ifdef POLYCUBE_XDP - if (pcn_pop_vlan_tag(ctx) != 0) { - pcn_log(ctx, LOG_ERR, "error pcn_push_vlan_tag"); - goto DROP; - } -#else - uint8_t r = bpf_skb_vlan_pop(ctx); - if (r) - pcn_log(ctx, LOG_ERR, "error vlan_pop"); -#endif - } - } else { - vlan_key.port = dst_interface; - vlan_key.vlan = vlanid; - vlan_entry = port_vlan.lookup(&vlan_key); - if (!vlan_entry) { - // bpf_trace_printk("dropping packet: trunk vlan entry not present\n"); - goto DROP; - } - if (!tagged) { -// todo check tag correctness -#ifdef POLYCUBE_XDP - if (pcn_push_vlan_tag(ctx, eth->proto, vlanid) != 0) { - goto DROP; - } -#else - uint8_t r = bpf_skb_vlan_push(ctx, eth->proto, vlanid); - if (r) - pcn_log(ctx, LOG_ERR, "error vlan_push"); -#endif - } - } - } - - if (!stp_forward_in_state(vlan_entry->stp_state)) { - pcn_log(ctx, LOG_TRACE, "port %d should not forward\n", dst_interface); - return RX_DROP; - } - - pcn_log(ctx, LOG_TRACE, "redirect out_ifc=%d", dst_interface); - return pcn_pkt_redirect(ctx, md, dst_interface); - -DO_FLOODING:; - pcn_log(ctx, LOG_TRACE, "broadcast"); - u32 mdata[3]; - mdata[0] = vlanid; - mdata[1] = tagged; - return pcn_pkt_controller_with_metadata(ctx, md, BROADCAST_REASON, mdata); - -DROP: - pcn_log(ctx, LOG_TRACE, "drop"); - return RX_DROP; -} diff --git a/src/services/pcn-bridge/src/CMakeLists.txt b/src/services/pcn-bridge/src/CMakeLists.txt deleted file mode 100755 index 9d66d281e..000000000 --- a/src/services/pcn-bridge/src/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -include(${PROJECT_SOURCE_DIR}/cmake/LoadFileAsVariable.cmake) - -aux_source_directory(model MODEL_SOURCES) -aux_source_directory(api API_SOURCES) - -include_directories(model) - -# Needed to load files as variables -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - -add_library(pcn-bridge SHARED - ${MODEL_SOURCES} - ${API_SOURCES} - Bridge.cpp - BridgeSTP.cpp - BridgeApi.cpp - Bridge-lib.cpp) - -# load ebpf datapath code in std::string variables -load_file_as_variable(pcn-bridge Bridge_dp_stp.c bridge_code) -load_file_as_variable(pcn-bridge Bridge_dp_no_stp.c bridge_code_no_stp) - -target_link_libraries(pcn-bridge - polycube - stp - uuid - tins - stp) - -# Specify shared library install directory - -set(CMAKE_INSTALL_LIBDIR /usr/lib) - -install( - TARGETS - pcn-bridge - DESTINATION - "${CMAKE_INSTALL_LIBDIR}" -) diff --git a/src/services/pcn-bridge/src/api/BridgeApi.cpp b/src/services/pcn-bridge/src/api/BridgeApi.cpp deleted file mode 100755 index 131225564..000000000 --- a/src/services/pcn-bridge/src/api/BridgeApi.cpp +++ /dev/null @@ -1,2355 +0,0 @@ -/** -* bridge API -* bridge API generated from bridge.yang -* -* OpenAPI spec version: 1.0.0 -* -* NOTE: This class is auto generated by the swagger code generator program. -* https://github.com/swagger-api/swagger-codegen.git -*/ - - -/* Do not edit this file manually */ - - -#include "BridgeApi.h" - -namespace io { -namespace swagger { -namespace server { -namespace api { - -using namespace io::swagger::server::model; - -BridgeApi::BridgeApi() { - setupRoutes(); -}; - -void BridgeApi::control_handler(const HttpHandleRequest &request, HttpHandleResponse &response) { - try { - auto s = router.route(request, response); - if (s == Rest::Router::Status::NotFound) { - response.send(Http::Code::Not_Found); - } - } catch (std::runtime_error &e) { - response.send(polycube::service::Http::Code::Bad_Request, e.what()); - } -} - -void BridgeApi::setupRoutes() { - using namespace polycube::service::Rest; - - Routes::Post(router, base + "/bridge/:name/", Routes::bind(&BridgeApi::create_bridge_by_id_handler, this)); - Routes::Post(router, base + "/bridge/:name/filteringdatabase/:vlan/:address/", Routes::bind(&BridgeApi::create_bridge_filteringdatabase_by_id_handler, this)); - Routes::Post(router, base + "/bridge/:name/filteringdatabase/", Routes::bind(&BridgeApi::create_bridge_filteringdatabase_list_by_id_handler, this)); - Routes::Post(router, base + "/bridge/:name/ports/:ports_name/access/", Routes::bind(&BridgeApi::create_bridge_ports_access_by_id_handler, this)); - Routes::Post(router, base + "/bridge/:name/ports/:ports_name/", Routes::bind(&BridgeApi::create_bridge_ports_by_id_handler, this)); - Routes::Post(router, base + "/bridge/:name/ports/", Routes::bind(&BridgeApi::create_bridge_ports_list_by_id_handler, this)); - Routes::Post(router, base + "/bridge/:name/ports/:ports_name/stp/:vlan/", Routes::bind(&BridgeApi::create_bridge_ports_stp_by_id_handler, this)); - Routes::Post(router, base + "/bridge/:name/ports/:ports_name/stp/", Routes::bind(&BridgeApi::create_bridge_ports_stp_list_by_id_handler, this)); - Routes::Post(router, base + "/bridge/:name/ports/:ports_name/trunk/allowed/:vlanid/", Routes::bind(&BridgeApi::create_bridge_ports_trunk_allowed_by_id_handler, this)); - Routes::Post(router, base + "/bridge/:name/ports/:ports_name/trunk/allowed/", Routes::bind(&BridgeApi::create_bridge_ports_trunk_allowed_list_by_id_handler, this)); - Routes::Post(router, base + "/bridge/:name/ports/:ports_name/trunk/", Routes::bind(&BridgeApi::create_bridge_ports_trunk_by_id_handler, this)); - Routes::Post(router, base + "/bridge/:name/stp/:vlan/", Routes::bind(&BridgeApi::create_bridge_stp_by_id_handler, this)); - Routes::Post(router, base + "/bridge/:name/stp/", Routes::bind(&BridgeApi::create_bridge_stp_list_by_id_handler, this)); - Routes::Delete(router, base + "/bridge/:name/", Routes::bind(&BridgeApi::delete_bridge_by_id_handler, this)); - Routes::Delete(router, base + "/bridge/:name/filteringdatabase/:vlan/:address/", Routes::bind(&BridgeApi::delete_bridge_filteringdatabase_by_id_handler, this)); - Routes::Delete(router, base + "/bridge/:name/filteringdatabase/", Routes::bind(&BridgeApi::delete_bridge_filteringdatabase_list_by_id_handler, this)); - Routes::Delete(router, base + "/bridge/:name/ports/:ports_name/access/", Routes::bind(&BridgeApi::delete_bridge_ports_access_by_id_handler, this)); - Routes::Delete(router, base + "/bridge/:name/ports/:ports_name/", Routes::bind(&BridgeApi::delete_bridge_ports_by_id_handler, this)); - Routes::Delete(router, base + "/bridge/:name/ports/", Routes::bind(&BridgeApi::delete_bridge_ports_list_by_id_handler, this)); - Routes::Delete(router, base + "/bridge/:name/ports/:ports_name/stp/:vlan/", Routes::bind(&BridgeApi::delete_bridge_ports_stp_by_id_handler, this)); - Routes::Delete(router, base + "/bridge/:name/ports/:ports_name/stp/", Routes::bind(&BridgeApi::delete_bridge_ports_stp_list_by_id_handler, this)); - Routes::Delete(router, base + "/bridge/:name/ports/:ports_name/trunk/allowed/:vlanid/", Routes::bind(&BridgeApi::delete_bridge_ports_trunk_allowed_by_id_handler, this)); - Routes::Delete(router, base + "/bridge/:name/ports/:ports_name/trunk/allowed/", Routes::bind(&BridgeApi::delete_bridge_ports_trunk_allowed_list_by_id_handler, this)); - Routes::Delete(router, base + "/bridge/:name/ports/:ports_name/trunk/", Routes::bind(&BridgeApi::delete_bridge_ports_trunk_by_id_handler, this)); - Routes::Delete(router, base + "/bridge/:name/stp/:vlan/", Routes::bind(&BridgeApi::delete_bridge_stp_by_id_handler, this)); - Routes::Delete(router, base + "/bridge/:name/stp/", Routes::bind(&BridgeApi::delete_bridge_stp_list_by_id_handler, this)); - Routes::Get(router, base + "/bridge/:name/agingtime/", Routes::bind(&BridgeApi::read_bridge_agingtime_by_id_handler, this)); - Routes::Get(router, base + "/bridge/:name/", Routes::bind(&BridgeApi::read_bridge_by_id_handler, this)); - Routes::Get(router, base + "/bridge/:name/filteringdatabase/:vlan/:address/age/", Routes::bind(&BridgeApi::read_bridge_filteringdatabase_age_by_id_handler, this)); - Routes::Get(router, base + "/bridge/:name/filteringdatabase/:vlan/:address/", Routes::bind(&BridgeApi::read_bridge_filteringdatabase_by_id_handler, this)); - Routes::Get(router, base + "/bridge/:name/filteringdatabase/:vlan/:address/entrytype/", Routes::bind(&BridgeApi::read_bridge_filteringdatabase_entrytype_by_id_handler, this)); - Routes::Get(router, base + "/bridge/:name/filteringdatabase/", Routes::bind(&BridgeApi::read_bridge_filteringdatabase_list_by_id_handler, this)); - Routes::Get(router, base + "/bridge/:name/filteringdatabase/:vlan/:address/port/", Routes::bind(&BridgeApi::read_bridge_filteringdatabase_port_by_id_handler, this)); - Routes::Get(router, base + "/bridge/", Routes::bind(&BridgeApi::read_bridge_list_by_id_handler, this)); - Routes::Get(router, base + "/bridge/:name/ports/:ports_name/access/", Routes::bind(&BridgeApi::read_bridge_ports_access_by_id_handler, this)); - Routes::Get(router, base + "/bridge/:name/ports/:ports_name/access/vlanid/", Routes::bind(&BridgeApi::read_bridge_ports_access_vlanid_by_id_handler, this)); - Routes::Get(router, base + "/bridge/:name/ports/:ports_name/address/", Routes::bind(&BridgeApi::read_bridge_ports_address_by_id_handler, this)); - Routes::Get(router, base + "/bridge/:name/ports/:ports_name/", Routes::bind(&BridgeApi::read_bridge_ports_by_id_handler, this)); - Routes::Get(router, base + "/bridge/:name/ports/", Routes::bind(&BridgeApi::read_bridge_ports_list_by_id_handler, this)); - Routes::Get(router, base + "/bridge/:name/ports/:ports_name/mode/", Routes::bind(&BridgeApi::read_bridge_ports_mode_by_id_handler, this)); - Routes::Get(router, base + "/bridge/:name/ports/:ports_name/peer/", Routes::bind(&BridgeApi::read_bridge_ports_peer_by_id_handler, this)); - Routes::Get(router, base + "/bridge/:name/ports/:ports_name/status/", Routes::bind(&BridgeApi::read_bridge_ports_status_by_id_handler, this)); - Routes::Get(router, base + "/bridge/:name/ports/:ports_name/stp/:vlan/", Routes::bind(&BridgeApi::read_bridge_ports_stp_by_id_handler, this)); - Routes::Get(router, base + "/bridge/:name/ports/:ports_name/stp/", Routes::bind(&BridgeApi::read_bridge_ports_stp_list_by_id_handler, this)); - Routes::Get(router, base + "/bridge/:name/ports/:ports_name/stp/:vlan/pathcost/", Routes::bind(&BridgeApi::read_bridge_ports_stp_pathcost_by_id_handler, this)); - Routes::Get(router, base + "/bridge/:name/ports/:ports_name/stp/:vlan/portpriority/", Routes::bind(&BridgeApi::read_bridge_ports_stp_portpriority_by_id_handler, this)); - Routes::Get(router, base + "/bridge/:name/ports/:ports_name/stp/:vlan/state/", Routes::bind(&BridgeApi::read_bridge_ports_stp_state_by_id_handler, this)); - Routes::Get(router, base + "/bridge/:name/ports/:ports_name/trunk/allowed/:vlanid/", Routes::bind(&BridgeApi::read_bridge_ports_trunk_allowed_by_id_handler, this)); - Routes::Get(router, base + "/bridge/:name/ports/:ports_name/trunk/allowed/", Routes::bind(&BridgeApi::read_bridge_ports_trunk_allowed_list_by_id_handler, this)); - Routes::Get(router, base + "/bridge/:name/ports/:ports_name/trunk/", Routes::bind(&BridgeApi::read_bridge_ports_trunk_by_id_handler, this)); - Routes::Get(router, base + "/bridge/:name/ports/:ports_name/trunk/nativevlan/", Routes::bind(&BridgeApi::read_bridge_ports_trunk_nativevlan_by_id_handler, this)); - Routes::Get(router, base + "/bridge/:name/ports/:ports_name/uuid/", Routes::bind(&BridgeApi::read_bridge_ports_uuid_by_id_handler, this)); - Routes::Get(router, base + "/bridge/:name/stp/:vlan/address/", Routes::bind(&BridgeApi::read_bridge_stp_address_by_id_handler, this)); - Routes::Get(router, base + "/bridge/:name/stp/:vlan/", Routes::bind(&BridgeApi::read_bridge_stp_by_id_handler, this)); - Routes::Get(router, base + "/bridge/:name/stp/:vlan/forwarddelay/", Routes::bind(&BridgeApi::read_bridge_stp_forwarddelay_by_id_handler, this)); - Routes::Get(router, base + "/bridge/:name/stp/:vlan/hellotime/", Routes::bind(&BridgeApi::read_bridge_stp_hellotime_by_id_handler, this)); - Routes::Get(router, base + "/bridge/:name/stp/", Routes::bind(&BridgeApi::read_bridge_stp_list_by_id_handler, this)); - Routes::Get(router, base + "/bridge/:name/stp/:vlan/maxmessageage/", Routes::bind(&BridgeApi::read_bridge_stp_maxmessageage_by_id_handler, this)); - Routes::Get(router, base + "/bridge/:name/stp/:vlan/priority/", Routes::bind(&BridgeApi::read_bridge_stp_priority_by_id_handler, this)); - Routes::Get(router, base + "/bridge/:name/stpenabled/", Routes::bind(&BridgeApi::read_bridge_stpenabled_by_id_handler, this)); - Routes::Get(router, base + "/bridge/:name/uuid/", Routes::bind(&BridgeApi::read_bridge_uuid_by_id_handler, this)); - Routes::Get(router, base + "/bridge/:name/type/", Routes::bind(&BridgeApi::read_bridge_type_by_id_handler, this)); - Routes::Put(router, base + "/bridge/:name/agingtime/", Routes::bind(&BridgeApi::update_bridge_agingtime_by_id_handler, this)); - Routes::Put(router, base + "/bridge/:name/", Routes::bind(&BridgeApi::update_bridge_by_id_handler, this)); - Routes::Put(router, base + "/bridge/:name/filteringdatabase/:vlan/:address/", Routes::bind(&BridgeApi::update_bridge_filteringdatabase_by_id_handler, this)); - Routes::Put(router, base + "/bridge/:name/filteringdatabase/:vlan/:address/entrytype/", Routes::bind(&BridgeApi::update_bridge_filteringdatabase_entrytype_by_id_handler, this)); - Routes::Put(router, base + "/bridge/:name/filteringdatabase/", Routes::bind(&BridgeApi::update_bridge_filteringdatabase_list_by_id_handler, this)); - Routes::Put(router, base + "/bridge/:name/filteringdatabase/:vlan/:address/port/", Routes::bind(&BridgeApi::update_bridge_filteringdatabase_port_by_id_handler, this)); - Routes::Put(router, base + "/bridge/:name/ports/:ports_name/access/", Routes::bind(&BridgeApi::update_bridge_ports_access_by_id_handler, this)); - Routes::Put(router, base + "/bridge/:name/ports/:ports_name/access/vlanid/", Routes::bind(&BridgeApi::update_bridge_ports_access_vlanid_by_id_handler, this)); - Routes::Put(router, base + "/bridge/:name/ports/:ports_name/address/", Routes::bind(&BridgeApi::update_bridge_ports_address_by_id_handler, this)); - Routes::Put(router, base + "/bridge/:name/ports/:ports_name/", Routes::bind(&BridgeApi::update_bridge_ports_by_id_handler, this)); - Routes::Put(router, base + "/bridge/:name/ports/", Routes::bind(&BridgeApi::update_bridge_ports_list_by_id_handler, this)); - Routes::Put(router, base + "/bridge/:name/ports/:ports_name/mode/", Routes::bind(&BridgeApi::update_bridge_ports_mode_by_id_handler, this)); - Routes::Put(router, base + "/bridge/:name/ports/:ports_name/peer/", Routes::bind(&BridgeApi::update_bridge_ports_peer_by_id_handler, this)); - Routes::Put(router, base + "/bridge/:name/ports/:ports_name/status/", Routes::bind(&BridgeApi::update_bridge_ports_status_by_id_handler, this)); - Routes::Put(router, base + "/bridge/:name/ports/:ports_name/stp/:vlan/", Routes::bind(&BridgeApi::update_bridge_ports_stp_by_id_handler, this)); - Routes::Put(router, base + "/bridge/:name/ports/:ports_name/stp/", Routes::bind(&BridgeApi::update_bridge_ports_stp_list_by_id_handler, this)); - Routes::Put(router, base + "/bridge/:name/ports/:ports_name/stp/:vlan/pathcost/", Routes::bind(&BridgeApi::update_bridge_ports_stp_pathcost_by_id_handler, this)); - Routes::Put(router, base + "/bridge/:name/ports/:ports_name/stp/:vlan/portpriority/", Routes::bind(&BridgeApi::update_bridge_ports_stp_portpriority_by_id_handler, this)); - Routes::Put(router, base + "/bridge/:name/ports/:ports_name/trunk/allowed/:vlanid/", Routes::bind(&BridgeApi::update_bridge_ports_trunk_allowed_by_id_handler, this)); - Routes::Put(router, base + "/bridge/:name/ports/:ports_name/trunk/allowed/", Routes::bind(&BridgeApi::update_bridge_ports_trunk_allowed_list_by_id_handler, this)); - Routes::Put(router, base + "/bridge/:name/ports/:ports_name/trunk/", Routes::bind(&BridgeApi::update_bridge_ports_trunk_by_id_handler, this)); - Routes::Put(router, base + "/bridge/:name/ports/:ports_name/trunk/nativevlan/", Routes::bind(&BridgeApi::update_bridge_ports_trunk_nativevlan_by_id_handler, this)); - Routes::Put(router, base + "/bridge/:name/stp/:vlan/address/", Routes::bind(&BridgeApi::update_bridge_stp_address_by_id_handler, this)); - Routes::Put(router, base + "/bridge/:name/stp/:vlan/", Routes::bind(&BridgeApi::update_bridge_stp_by_id_handler, this)); - Routes::Put(router, base + "/bridge/:name/stp/:vlan/forwarddelay/", Routes::bind(&BridgeApi::update_bridge_stp_forwarddelay_by_id_handler, this)); - Routes::Put(router, base + "/bridge/:name/stp/:vlan/hellotime/", Routes::bind(&BridgeApi::update_bridge_stp_hellotime_by_id_handler, this)); - Routes::Put(router, base + "/bridge/:name/stp/", Routes::bind(&BridgeApi::update_bridge_stp_list_by_id_handler, this)); - Routes::Put(router, base + "/bridge/:name/stp/:vlan/maxmessageage/", Routes::bind(&BridgeApi::update_bridge_stp_maxmessageage_by_id_handler, this)); - Routes::Put(router, base + "/bridge/:name/stp/:vlan/priority/", Routes::bind(&BridgeApi::update_bridge_stp_priority_by_id_handler, this)); - Routes::Put(router, base + "/bridge/:name/stpenabled/", Routes::bind(&BridgeApi::update_bridge_stpenabled_by_id_handler, this)); - Routes::Put(router, base + "/bridge/:name/type/", Routes::bind(&BridgeApi::update_bridge_type_by_id_handler, this)); -} - -void BridgeApi::create_bridge_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - - // Getting the body param - BridgeSchema bridge; - - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - bridge.fromJson(request_body); - auto x = create_bridge_by_id(name, bridge); - nlohmann::json response_body; - response_body = x.toJson(); - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::create_bridge_filteringdatabase_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto vlan = request.param(":vlan").as(); - auto address = request.param(":address").as(); - - // Getting the body param - FilteringdatabaseSchema filteringdatabase; - - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - filteringdatabase.fromJson(request_body); - auto x = create_bridge_filteringdatabase_by_id(name, vlan, address, filteringdatabase); - nlohmann::json response_body; - response_body = x.toJson(); - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::create_bridge_filteringdatabase_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - - // Getting the body param - std::vector filteringdatabase; - - #define NODE_IS_LIST_CONTAINER - #undef NODE_IS_LIST_CONTAINER - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - for (auto &j : request_body) { - FilteringdatabaseSchema a; - a.fromJson(j); - filteringdatabase.push_back(a); - } - auto x = create_bridge_filteringdatabase_list_by_id(name, filteringdatabase); - nlohmann::json response_body; - for (auto &i : x) { - response_body += i.toJson(); - } - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::create_bridge_ports_access_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - - // Getting the body param - PortsAccessSchema access; - - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - access.fromJson(request_body); - auto x = create_bridge_ports_access_by_id(name, portsName, access); - nlohmann::json response_body; - response_body = x.toJson(); - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::create_bridge_ports_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - - // Getting the body param - PortsSchema ports; - - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - ports.fromJson(request_body); - auto x = create_bridge_ports_by_id(name, portsName, ports); - nlohmann::json response_body; - response_body = x.toJson(); - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::create_bridge_ports_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - - // Getting the body param - std::vector ports; - - #define NODE_IS_LIST_CONTAINER - #undef NODE_IS_LIST_CONTAINER - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - for (auto &j : request_body) { - PortsSchema a; - a.fromJson(j); - ports.push_back(a); - } - auto x = create_bridge_ports_list_by_id(name, ports); - nlohmann::json response_body; - for (auto &i : x) { - response_body += i.toJson(); - } - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::create_bridge_ports_stp_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - auto vlan = request.param(":vlan").as(); - - // Getting the body param - PortsStpSchema stp; - - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - stp.fromJson(request_body); - auto x = create_bridge_ports_stp_by_id(name, portsName, vlan, stp); - nlohmann::json response_body; - response_body = x.toJson(); - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::create_bridge_ports_stp_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - - // Getting the body param - std::vector stp; - - #define NODE_IS_LIST_CONTAINER - #undef NODE_IS_LIST_CONTAINER - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - for (auto &j : request_body) { - PortsStpSchema a; - a.fromJson(j); - stp.push_back(a); - } - auto x = create_bridge_ports_stp_list_by_id(name, portsName, stp); - nlohmann::json response_body; - for (auto &i : x) { - response_body += i.toJson(); - } - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::create_bridge_ports_trunk_allowed_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - auto vlanid = request.param(":vlanid").as(); - - // Getting the body param - PortsTrunkAllowedSchema allowed; - - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - allowed.fromJson(request_body); - auto x = create_bridge_ports_trunk_allowed_by_id(name, portsName, vlanid, allowed); - nlohmann::json response_body; - response_body = x.toJson(); - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::create_bridge_ports_trunk_allowed_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - - // Getting the body param - std::vector allowed; - - #define NODE_IS_LIST_CONTAINER - #undef NODE_IS_LIST_CONTAINER - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - for (auto &j : request_body) { - PortsTrunkAllowedSchema a; - a.fromJson(j); - allowed.push_back(a); - } - auto x = create_bridge_ports_trunk_allowed_list_by_id(name, portsName, allowed); - nlohmann::json response_body; - for (auto &i : x) { - response_body += i.toJson(); - } - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::create_bridge_ports_trunk_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - - // Getting the body param - PortsTrunkSchema trunk; - - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - trunk.fromJson(request_body); - auto x = create_bridge_ports_trunk_by_id(name, portsName, trunk); - nlohmann::json response_body; - response_body = x.toJson(); - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::create_bridge_stp_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto vlan = request.param(":vlan").as(); - - // Getting the body param - StpSchema stp; - - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - stp.fromJson(request_body); - auto x = create_bridge_stp_by_id(name, vlan, stp); - nlohmann::json response_body; - response_body = x.toJson(); - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::create_bridge_stp_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - - // Getting the body param - std::vector stp; - - #define NODE_IS_LIST_CONTAINER - #undef NODE_IS_LIST_CONTAINER - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - for (auto &j : request_body) { - StpSchema a; - a.fromJson(j); - stp.push_back(a); - } - auto x = create_bridge_stp_list_by_id(name, stp); - nlohmann::json response_body; - for (auto &i : x) { - response_body += i.toJson(); - } - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::delete_bridge_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - - - - delete_bridge_by_id(name); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::delete_bridge_filteringdatabase_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto vlan = request.param(":vlan").as(); - auto address = request.param(":address").as(); - - - - delete_bridge_filteringdatabase_by_id(name, vlan, address); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::delete_bridge_filteringdatabase_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - - - #define NODE_IS_LIST_CONTAINER - #undef NODE_IS_LIST_CONTAINER - - delete_bridge_filteringdatabase_list_by_id(name); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::delete_bridge_ports_access_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - - - - delete_bridge_ports_access_by_id(name, portsName); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::delete_bridge_ports_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - - - - delete_bridge_ports_by_id(name, portsName); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::delete_bridge_ports_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - - - #define NODE_IS_LIST_CONTAINER - #undef NODE_IS_LIST_CONTAINER - - delete_bridge_ports_list_by_id(name); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::delete_bridge_ports_stp_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - auto vlan = request.param(":vlan").as(); - - - - delete_bridge_ports_stp_by_id(name, portsName, vlan); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::delete_bridge_ports_stp_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - - - #define NODE_IS_LIST_CONTAINER - #undef NODE_IS_LIST_CONTAINER - - delete_bridge_ports_stp_list_by_id(name, portsName); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::delete_bridge_ports_trunk_allowed_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - auto vlanid = request.param(":vlanid").as(); - - - - delete_bridge_ports_trunk_allowed_by_id(name, portsName, vlanid); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::delete_bridge_ports_trunk_allowed_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - - - #define NODE_IS_LIST_CONTAINER - #undef NODE_IS_LIST_CONTAINER - - delete_bridge_ports_trunk_allowed_list_by_id(name, portsName); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::delete_bridge_ports_trunk_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - - - - delete_bridge_ports_trunk_by_id(name, portsName); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::delete_bridge_stp_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto vlan = request.param(":vlan").as(); - - - - delete_bridge_stp_by_id(name, vlan); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::delete_bridge_stp_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - - - #define NODE_IS_LIST_CONTAINER - #undef NODE_IS_LIST_CONTAINER - - delete_bridge_stp_list_by_id(name); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::read_bridge_agingtime_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - - - - auto x = read_bridge_agingtime_by_id(name); - nlohmann::json response_body; - response_body = x; - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::read_bridge_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - - - using polycube::service::HelpType; - nlohmann::json val = nlohmann::json::object(); - if (request.help_type() != HelpType::NO_HELP) { - switch (request.help_type()) { - case HelpType::SHOW: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = BridgeSchema::getKeys(); - val["elements"] = read_bridge_by_id_get_list(); - #else // element is complex - val["params"] = BridgeSchema::getElements(); - #endif - break; - - case HelpType::ADD: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = BridgeSchema::getKeys(); - #else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::SET: - #ifndef NODE_IS_LIST_CONTAINER - val["params"] = BridgeSchema::getWritableLeafs(); - # else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::DEL: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = BridgeSchema::getKeys(); - val["elements"] = read_bridge_by_id_get_list(); - #else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::NONE: - #ifdef NODE_IS_LIST_CONTAINER - auto cmds = {"add", "del", "show"}; - val["commands"] = cmds; - val["params"] = BridgeSchema::getKeys(); - val["elements"] = read_bridge_by_id_get_list(); - #else // complex type - auto cmds = {"set", "show"}; - val["commands"] = cmds; - val["params"] = BridgeSchema::getComplexElements(); - #endif - break; - } - response.send(polycube::service::Http::Code::Ok, val.dump(4)); - return; - } - - auto x = read_bridge_by_id(name); - nlohmann::json response_body; - response_body = x.toJson(); - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::read_bridge_filteringdatabase_age_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto vlan = request.param(":vlan").as(); - auto address = request.param(":address").as(); - - - - auto x = read_bridge_filteringdatabase_age_by_id(name, vlan, address); - nlohmann::json response_body; - response_body = x; - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::read_bridge_filteringdatabase_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto vlan = request.param(":vlan").as(); - auto address = request.param(":address").as(); - - - using polycube::service::HelpType; - nlohmann::json val = nlohmann::json::object(); - if (request.help_type() != HelpType::NO_HELP) { - switch (request.help_type()) { - case HelpType::SHOW: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = FilteringdatabaseSchema::getKeys(); - val["elements"] = read_bridge_filteringdatabase_by_id_get_list(); - #else // element is complex - val["params"] = FilteringdatabaseSchema::getElements(); - #endif - break; - - case HelpType::ADD: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = FilteringdatabaseSchema::getKeys(); - #else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::SET: - #ifndef NODE_IS_LIST_CONTAINER - val["params"] = FilteringdatabaseSchema::getWritableLeafs(); - # else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::DEL: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = FilteringdatabaseSchema::getKeys(); - val["elements"] = read_bridge_filteringdatabase_by_id_get_list(); - #else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::NONE: - #ifdef NODE_IS_LIST_CONTAINER - auto cmds = {"add", "del", "show"}; - val["commands"] = cmds; - val["params"] = FilteringdatabaseSchema::getKeys(); - val["elements"] = read_bridge_filteringdatabase_by_id_get_list(); - #else // complex type - auto cmds = {"set", "show"}; - val["commands"] = cmds; - val["params"] = FilteringdatabaseSchema::getComplexElements(); - #endif - break; - } - response.send(polycube::service::Http::Code::Ok, val.dump(4)); - return; - } - - auto x = read_bridge_filteringdatabase_by_id(name, vlan, address); - nlohmann::json response_body; - response_body = x.toJson(); - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::read_bridge_filteringdatabase_entrytype_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto vlan = request.param(":vlan").as(); - auto address = request.param(":address").as(); - - - - auto x = read_bridge_filteringdatabase_entrytype_by_id(name, vlan, address); - nlohmann::json response_body; - response_body = x; - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::read_bridge_filteringdatabase_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - - - #define NODE_IS_LIST_CONTAINER - using polycube::service::HelpType; - nlohmann::json val = nlohmann::json::object(); - if (request.help_type() != HelpType::NO_HELP) { - switch (request.help_type()) { - case HelpType::SHOW: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = FilteringdatabaseSchema::getKeys(); - val["elements"] = read_bridge_filteringdatabase_list_by_id_get_list(); - #else // element is complex - val["params"] = FilteringdatabaseSchema::getElements(); - #endif - break; - - case HelpType::ADD: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = FilteringdatabaseSchema::getKeys(); - #else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::SET: - #ifndef NODE_IS_LIST_CONTAINER - val["params"] = FilteringdatabaseSchema::getWritableLeafs(); - # else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::DEL: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = FilteringdatabaseSchema::getKeys(); - val["elements"] = read_bridge_filteringdatabase_list_by_id_get_list(); - #else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::NONE: - #ifdef NODE_IS_LIST_CONTAINER - auto cmds = {"add", "del", "show"}; - val["commands"] = cmds; - val["params"] = FilteringdatabaseSchema::getKeys(); - val["elements"] = read_bridge_filteringdatabase_list_by_id_get_list(); - #else // complex type - auto cmds = {"set", "show"}; - val["commands"] = cmds; - val["params"] = FilteringdatabaseSchema::getComplexElements(); - #endif - break; - } - response.send(polycube::service::Http::Code::Ok, val.dump(4)); - return; - } - #undef NODE_IS_LIST_CONTAINER - - auto x = read_bridge_filteringdatabase_list_by_id(name); - nlohmann::json response_body; - for (auto &i : x) { - response_body += i.toJson(); - } - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::read_bridge_filteringdatabase_port_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto vlan = request.param(":vlan").as(); - auto address = request.param(":address").as(); - - - - auto x = read_bridge_filteringdatabase_port_by_id(name, vlan, address); - nlohmann::json response_body; - response_body = x; - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::read_bridge_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - - - #define NODE_IS_LIST_CONTAINER - using polycube::service::HelpType; - nlohmann::json val = nlohmann::json::object(); - if (request.help_type() != HelpType::NO_HELP) { - switch (request.help_type()) { - case HelpType::SHOW: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = BridgeSchema::getKeys(); - val["elements"] = read_bridge_list_by_id_get_list(); - #else // element is complex - val["params"] = BridgeSchema::getElements(); - #endif - break; - - case HelpType::ADD: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = BridgeSchema::getKeys(); - #else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::SET: - #ifndef NODE_IS_LIST_CONTAINER - val["params"] = BridgeSchema::getWritableLeafs(); - # else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::DEL: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = BridgeSchema::getKeys(); - val["elements"] = read_bridge_list_by_id_get_list(); - #else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::NONE: - #ifdef NODE_IS_LIST_CONTAINER - auto cmds = {"add", "del", "show"}; - val["commands"] = cmds; - val["params"] = BridgeSchema::getKeys(); - val["elements"] = read_bridge_list_by_id_get_list(); - #else // complex type - auto cmds = {"set", "show"}; - val["commands"] = cmds; - val["params"] = BridgeSchema::getComplexElements(); - #endif - break; - } - response.send(polycube::service::Http::Code::Ok, val.dump(4)); - return; - } - #undef NODE_IS_LIST_CONTAINER - - auto x = read_bridge_list_by_id(); - nlohmann::json response_body; - for (auto &i : x) { - response_body += i.toJson(); - } - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::read_bridge_ports_access_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - - - using polycube::service::HelpType; - nlohmann::json val = nlohmann::json::object(); - if (request.help_type() != HelpType::NO_HELP) { - switch (request.help_type()) { - case HelpType::SHOW: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = PortsAccessSchema::getKeys(); - val["elements"] = read_bridge_ports_access_by_id_get_list(); - #else // element is complex - val["params"] = PortsAccessSchema::getElements(); - #endif - break; - - case HelpType::ADD: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = PortsAccessSchema::getKeys(); - #else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::SET: - #ifndef NODE_IS_LIST_CONTAINER - val["params"] = PortsAccessSchema::getWritableLeafs(); - # else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::DEL: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = PortsAccessSchema::getKeys(); - val["elements"] = read_bridge_ports_access_by_id_get_list(); - #else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::NONE: - #ifdef NODE_IS_LIST_CONTAINER - auto cmds = {"add", "del", "show"}; - val["commands"] = cmds; - val["params"] = PortsAccessSchema::getKeys(); - val["elements"] = read_bridge_ports_access_by_id_get_list(); - #else // complex type - auto cmds = {"set", "show"}; - val["commands"] = cmds; - val["params"] = PortsAccessSchema::getComplexElements(); - #endif - break; - } - response.send(polycube::service::Http::Code::Ok, val.dump(4)); - return; - } - - auto x = read_bridge_ports_access_by_id(name, portsName); - nlohmann::json response_body; - response_body = x.toJson(); - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::read_bridge_ports_access_vlanid_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - - - - auto x = read_bridge_ports_access_vlanid_by_id(name, portsName); - nlohmann::json response_body; - response_body = x; - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::read_bridge_ports_address_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - - - - auto x = read_bridge_ports_address_by_id(name, portsName); - nlohmann::json response_body; - response_body = x; - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::read_bridge_ports_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - - - using polycube::service::HelpType; - nlohmann::json val = nlohmann::json::object(); - if (request.help_type() != HelpType::NO_HELP) { - switch (request.help_type()) { - case HelpType::SHOW: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = PortsSchema::getKeys(); - val["elements"] = read_bridge_ports_by_id_get_list(); - #else // element is complex - val["params"] = PortsSchema::getElements(); - #endif - break; - - case HelpType::ADD: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = PortsSchema::getKeys(); - #else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::SET: - #ifndef NODE_IS_LIST_CONTAINER - val["params"] = PortsSchema::getWritableLeafs(); - # else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::DEL: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = PortsSchema::getKeys(); - val["elements"] = read_bridge_ports_by_id_get_list(); - #else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::NONE: - #ifdef NODE_IS_LIST_CONTAINER - auto cmds = {"add", "del", "show"}; - val["commands"] = cmds; - val["params"] = PortsSchema::getKeys(); - val["elements"] = read_bridge_ports_by_id_get_list(); - #else // complex type - auto cmds = {"set", "show"}; - val["commands"] = cmds; - val["params"] = PortsSchema::getComplexElements(); - #endif - break; - } - response.send(polycube::service::Http::Code::Ok, val.dump(4)); - return; - } - - auto x = read_bridge_ports_by_id(name, portsName); - nlohmann::json response_body; - response_body = x.toJson(); - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::read_bridge_ports_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - - - #define NODE_IS_LIST_CONTAINER - using polycube::service::HelpType; - nlohmann::json val = nlohmann::json::object(); - if (request.help_type() != HelpType::NO_HELP) { - switch (request.help_type()) { - case HelpType::SHOW: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = PortsSchema::getKeys(); - val["elements"] = read_bridge_ports_list_by_id_get_list(); - #else // element is complex - val["params"] = PortsSchema::getElements(); - #endif - break; - - case HelpType::ADD: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = PortsSchema::getKeys(); - #else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::SET: - #ifndef NODE_IS_LIST_CONTAINER - val["params"] = PortsSchema::getWritableLeafs(); - # else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::DEL: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = PortsSchema::getKeys(); - val["elements"] = read_bridge_ports_list_by_id_get_list(); - #else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::NONE: - #ifdef NODE_IS_LIST_CONTAINER - auto cmds = {"add", "del", "show"}; - val["commands"] = cmds; - val["params"] = PortsSchema::getKeys(); - val["elements"] = read_bridge_ports_list_by_id_get_list(); - #else // complex type - auto cmds = {"set", "show"}; - val["commands"] = cmds; - val["params"] = PortsSchema::getComplexElements(); - #endif - break; - } - response.send(polycube::service::Http::Code::Ok, val.dump(4)); - return; - } - #undef NODE_IS_LIST_CONTAINER - - auto x = read_bridge_ports_list_by_id(name); - nlohmann::json response_body; - for (auto &i : x) { - response_body += i.toJson(); - } - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::read_bridge_ports_mode_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - - - - auto x = read_bridge_ports_mode_by_id(name, portsName); - nlohmann::json response_body; - response_body = x; - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::read_bridge_ports_peer_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - - - - auto x = read_bridge_ports_peer_by_id(name, portsName); - nlohmann::json response_body; - response_body = x; - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::read_bridge_ports_status_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - - - - auto x = read_bridge_ports_status_by_id(name, portsName); - nlohmann::json response_body; - response_body = x; - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::read_bridge_ports_stp_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - auto vlan = request.param(":vlan").as(); - - - using polycube::service::HelpType; - nlohmann::json val = nlohmann::json::object(); - if (request.help_type() != HelpType::NO_HELP) { - switch (request.help_type()) { - case HelpType::SHOW: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = PortsStpSchema::getKeys(); - val["elements"] = read_bridge_ports_stp_by_id_get_list(); - #else // element is complex - val["params"] = PortsStpSchema::getElements(); - #endif - break; - - case HelpType::ADD: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = PortsStpSchema::getKeys(); - #else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::SET: - #ifndef NODE_IS_LIST_CONTAINER - val["params"] = PortsStpSchema::getWritableLeafs(); - # else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::DEL: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = PortsStpSchema::getKeys(); - val["elements"] = read_bridge_ports_stp_by_id_get_list(); - #else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::NONE: - #ifdef NODE_IS_LIST_CONTAINER - auto cmds = {"add", "del", "show"}; - val["commands"] = cmds; - val["params"] = PortsStpSchema::getKeys(); - val["elements"] = read_bridge_ports_stp_by_id_get_list(); - #else // complex type - auto cmds = {"set", "show"}; - val["commands"] = cmds; - val["params"] = PortsStpSchema::getComplexElements(); - #endif - break; - } - response.send(polycube::service::Http::Code::Ok, val.dump(4)); - return; - } - - auto x = read_bridge_ports_stp_by_id(name, portsName, vlan); - nlohmann::json response_body; - response_body = x.toJson(); - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::read_bridge_ports_stp_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - - - #define NODE_IS_LIST_CONTAINER - using polycube::service::HelpType; - nlohmann::json val = nlohmann::json::object(); - if (request.help_type() != HelpType::NO_HELP) { - switch (request.help_type()) { - case HelpType::SHOW: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = PortsStpSchema::getKeys(); - val["elements"] = read_bridge_ports_stp_list_by_id_get_list(); - #else // element is complex - val["params"] = PortsStpSchema::getElements(); - #endif - break; - - case HelpType::ADD: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = PortsStpSchema::getKeys(); - #else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::SET: - #ifndef NODE_IS_LIST_CONTAINER - val["params"] = PortsStpSchema::getWritableLeafs(); - # else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::DEL: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = PortsStpSchema::getKeys(); - val["elements"] = read_bridge_ports_stp_list_by_id_get_list(); - #else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::NONE: - #ifdef NODE_IS_LIST_CONTAINER - auto cmds = {"add", "del", "show"}; - val["commands"] = cmds; - val["params"] = PortsStpSchema::getKeys(); - val["elements"] = read_bridge_ports_stp_list_by_id_get_list(); - #else // complex type - auto cmds = {"set", "show"}; - val["commands"] = cmds; - val["params"] = PortsStpSchema::getComplexElements(); - #endif - break; - } - response.send(polycube::service::Http::Code::Ok, val.dump(4)); - return; - } - #undef NODE_IS_LIST_CONTAINER - - auto x = read_bridge_ports_stp_list_by_id(name, portsName); - nlohmann::json response_body; - for (auto &i : x) { - response_body += i.toJson(); - } - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::read_bridge_ports_stp_pathcost_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - auto vlan = request.param(":vlan").as(); - - - - auto x = read_bridge_ports_stp_pathcost_by_id(name, portsName, vlan); - nlohmann::json response_body; - response_body = x; - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::read_bridge_ports_stp_portpriority_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - auto vlan = request.param(":vlan").as(); - - - - auto x = read_bridge_ports_stp_portpriority_by_id(name, portsName, vlan); - nlohmann::json response_body; - response_body = x; - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::read_bridge_ports_stp_state_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - auto vlan = request.param(":vlan").as(); - - - - auto x = read_bridge_ports_stp_state_by_id(name, portsName, vlan); - nlohmann::json response_body; - response_body = x; - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::read_bridge_ports_trunk_allowed_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - auto vlanid = request.param(":vlanid").as(); - - - using polycube::service::HelpType; - nlohmann::json val = nlohmann::json::object(); - if (request.help_type() != HelpType::NO_HELP) { - switch (request.help_type()) { - case HelpType::SHOW: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = PortsTrunkAllowedSchema::getKeys(); - val["elements"] = read_bridge_ports_trunk_allowed_by_id_get_list(); - #else // element is complex - val["params"] = PortsTrunkAllowedSchema::getElements(); - #endif - break; - - case HelpType::ADD: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = PortsTrunkAllowedSchema::getKeys(); - #else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::SET: - #ifndef NODE_IS_LIST_CONTAINER - val["params"] = PortsTrunkAllowedSchema::getWritableLeafs(); - # else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::DEL: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = PortsTrunkAllowedSchema::getKeys(); - val["elements"] = read_bridge_ports_trunk_allowed_by_id_get_list(); - #else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::NONE: - #ifdef NODE_IS_LIST_CONTAINER - auto cmds = {"add", "del", "show"}; - val["commands"] = cmds; - val["params"] = PortsTrunkAllowedSchema::getKeys(); - val["elements"] = read_bridge_ports_trunk_allowed_by_id_get_list(); - #else // complex type - auto cmds = {"set", "show"}; - val["commands"] = cmds; - val["params"] = PortsTrunkAllowedSchema::getComplexElements(); - #endif - break; - } - response.send(polycube::service::Http::Code::Ok, val.dump(4)); - return; - } - - auto x = read_bridge_ports_trunk_allowed_by_id(name, portsName, vlanid); - nlohmann::json response_body; - response_body = x.toJson(); - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::read_bridge_ports_trunk_allowed_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - - - #define NODE_IS_LIST_CONTAINER - using polycube::service::HelpType; - nlohmann::json val = nlohmann::json::object(); - if (request.help_type() != HelpType::NO_HELP) { - switch (request.help_type()) { - case HelpType::SHOW: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = PortsTrunkAllowedSchema::getKeys(); - val["elements"] = read_bridge_ports_trunk_allowed_list_by_id_get_list(); - #else // element is complex - val["params"] = PortsTrunkAllowedSchema::getElements(); - #endif - break; - - case HelpType::ADD: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = PortsTrunkAllowedSchema::getKeys(); - #else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::SET: - #ifndef NODE_IS_LIST_CONTAINER - val["params"] = PortsTrunkAllowedSchema::getWritableLeafs(); - # else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::DEL: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = PortsTrunkAllowedSchema::getKeys(); - val["elements"] = read_bridge_ports_trunk_allowed_list_by_id_get_list(); - #else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::NONE: - #ifdef NODE_IS_LIST_CONTAINER - auto cmds = {"add", "del", "show"}; - val["commands"] = cmds; - val["params"] = PortsTrunkAllowedSchema::getKeys(); - val["elements"] = read_bridge_ports_trunk_allowed_list_by_id_get_list(); - #else // complex type - auto cmds = {"set", "show"}; - val["commands"] = cmds; - val["params"] = PortsTrunkAllowedSchema::getComplexElements(); - #endif - break; - } - response.send(polycube::service::Http::Code::Ok, val.dump(4)); - return; - } - #undef NODE_IS_LIST_CONTAINER - - auto x = read_bridge_ports_trunk_allowed_list_by_id(name, portsName); - nlohmann::json response_body; - for (auto &i : x) { - response_body += i.toJson(); - } - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::read_bridge_ports_trunk_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - - - using polycube::service::HelpType; - nlohmann::json val = nlohmann::json::object(); - if (request.help_type() != HelpType::NO_HELP) { - switch (request.help_type()) { - case HelpType::SHOW: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = PortsTrunkSchema::getKeys(); - val["elements"] = read_bridge_ports_trunk_by_id_get_list(); - #else // element is complex - val["params"] = PortsTrunkSchema::getElements(); - #endif - break; - - case HelpType::ADD: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = PortsTrunkSchema::getKeys(); - #else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::SET: - #ifndef NODE_IS_LIST_CONTAINER - val["params"] = PortsTrunkSchema::getWritableLeafs(); - # else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::DEL: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = PortsTrunkSchema::getKeys(); - val["elements"] = read_bridge_ports_trunk_by_id_get_list(); - #else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::NONE: - #ifdef NODE_IS_LIST_CONTAINER - auto cmds = {"add", "del", "show"}; - val["commands"] = cmds; - val["params"] = PortsTrunkSchema::getKeys(); - val["elements"] = read_bridge_ports_trunk_by_id_get_list(); - #else // complex type - auto cmds = {"set", "show"}; - val["commands"] = cmds; - val["params"] = PortsTrunkSchema::getComplexElements(); - #endif - break; - } - response.send(polycube::service::Http::Code::Ok, val.dump(4)); - return; - } - - auto x = read_bridge_ports_trunk_by_id(name, portsName); - nlohmann::json response_body; - response_body = x.toJson(); - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::read_bridge_ports_trunk_nativevlan_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - - - - auto x = read_bridge_ports_trunk_nativevlan_by_id(name, portsName); - nlohmann::json response_body; - response_body = x; - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::read_bridge_ports_uuid_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - - - - auto x = read_bridge_ports_uuid_by_id(name, portsName); - nlohmann::json response_body; - response_body = x; - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::read_bridge_stp_address_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto vlan = request.param(":vlan").as(); - - - - auto x = read_bridge_stp_address_by_id(name, vlan); - nlohmann::json response_body; - response_body = x; - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::read_bridge_stp_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto vlan = request.param(":vlan").as(); - - - using polycube::service::HelpType; - nlohmann::json val = nlohmann::json::object(); - if (request.help_type() != HelpType::NO_HELP) { - switch (request.help_type()) { - case HelpType::SHOW: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = StpSchema::getKeys(); - val["elements"] = read_bridge_stp_by_id_get_list(); - #else // element is complex - val["params"] = StpSchema::getElements(); - #endif - break; - - case HelpType::ADD: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = StpSchema::getKeys(); - #else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::SET: - #ifndef NODE_IS_LIST_CONTAINER - val["params"] = StpSchema::getWritableLeafs(); - # else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::DEL: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = StpSchema::getKeys(); - val["elements"] = read_bridge_stp_by_id_get_list(); - #else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::NONE: - #ifdef NODE_IS_LIST_CONTAINER - auto cmds = {"add", "del", "show"}; - val["commands"] = cmds; - val["params"] = StpSchema::getKeys(); - val["elements"] = read_bridge_stp_by_id_get_list(); - #else // complex type - auto cmds = {"set", "show"}; - val["commands"] = cmds; - val["params"] = StpSchema::getComplexElements(); - #endif - break; - } - response.send(polycube::service::Http::Code::Ok, val.dump(4)); - return; - } - - auto x = read_bridge_stp_by_id(name, vlan); - nlohmann::json response_body; - response_body = x.toJson(); - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::read_bridge_stp_forwarddelay_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto vlan = request.param(":vlan").as(); - - - - auto x = read_bridge_stp_forwarddelay_by_id(name, vlan); - nlohmann::json response_body; - response_body = x; - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::read_bridge_stp_hellotime_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto vlan = request.param(":vlan").as(); - - - - auto x = read_bridge_stp_hellotime_by_id(name, vlan); - nlohmann::json response_body; - response_body = x; - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::read_bridge_stp_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - - - #define NODE_IS_LIST_CONTAINER - using polycube::service::HelpType; - nlohmann::json val = nlohmann::json::object(); - if (request.help_type() != HelpType::NO_HELP) { - switch (request.help_type()) { - case HelpType::SHOW: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = StpSchema::getKeys(); - val["elements"] = read_bridge_stp_list_by_id_get_list(); - #else // element is complex - val["params"] = StpSchema::getElements(); - #endif - break; - - case HelpType::ADD: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = StpSchema::getKeys(); - #else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::SET: - #ifndef NODE_IS_LIST_CONTAINER - val["params"] = StpSchema::getWritableLeafs(); - # else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::DEL: - #ifdef NODE_IS_LIST_CONTAINER - val["params"] = StpSchema::getKeys(); - val["elements"] = read_bridge_stp_list_by_id_get_list(); - #else - response.send(polycube::service::Http::Code::Bad_Request); - return; - #endif - break; - - case HelpType::NONE: - #ifdef NODE_IS_LIST_CONTAINER - auto cmds = {"add", "del", "show"}; - val["commands"] = cmds; - val["params"] = StpSchema::getKeys(); - val["elements"] = read_bridge_stp_list_by_id_get_list(); - #else // complex type - auto cmds = {"set", "show"}; - val["commands"] = cmds; - val["params"] = StpSchema::getComplexElements(); - #endif - break; - } - response.send(polycube::service::Http::Code::Ok, val.dump(4)); - return; - } - #undef NODE_IS_LIST_CONTAINER - - auto x = read_bridge_stp_list_by_id(name); - nlohmann::json response_body; - for (auto &i : x) { - response_body += i.toJson(); - } - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::read_bridge_stp_maxmessageage_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto vlan = request.param(":vlan").as(); - - - - auto x = read_bridge_stp_maxmessageage_by_id(name, vlan); - nlohmann::json response_body; - response_body = x; - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::read_bridge_stp_priority_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto vlan = request.param(":vlan").as(); - - - - auto x = read_bridge_stp_priority_by_id(name, vlan); - nlohmann::json response_body; - response_body = x; - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::read_bridge_stpenabled_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - - - - auto x = read_bridge_stpenabled_by_id(name); - nlohmann::json response_body; - response_body = x; - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::read_bridge_type_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - - - - auto x = read_bridge_type_by_id(name); - nlohmann::json response_body; - response_body = x; - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::read_bridge_uuid_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - - - - auto x = read_bridge_uuid_by_id(name); - nlohmann::json response_body; - response_body = x; - response.send(polycube::service::Http::Code::Ok, response_body.dump(4)); -} - -void BridgeApi::update_bridge_agingtime_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - - // Getting the body param - int32_t agingtime; - - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - // The conversion is done automatically by the json library - agingtime = request_body; - update_bridge_agingtime_by_id(name, agingtime); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::update_bridge_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - - // Getting the body param - BridgeSchema bridge; - - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - bridge.fromJson(request_body); - update_bridge_by_id(name, bridge); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::update_bridge_filteringdatabase_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto vlan = request.param(":vlan").as(); - auto address = request.param(":address").as(); - - // Getting the body param - FilteringdatabaseSchema filteringdatabase; - - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - filteringdatabase.fromJson(request_body); - update_bridge_filteringdatabase_by_id(name, vlan, address, filteringdatabase); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::update_bridge_filteringdatabase_entrytype_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto vlan = request.param(":vlan").as(); - auto address = request.param(":address").as(); - - // Getting the body param - std::string entrytype; - - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - // The conversion is done automatically by the json library - entrytype = request_body; - update_bridge_filteringdatabase_entrytype_by_id(name, vlan, address, entrytype); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::update_bridge_filteringdatabase_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - - // Getting the body param - std::vector filteringdatabase; - - #define NODE_IS_LIST_CONTAINER - #undef NODE_IS_LIST_CONTAINER - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - for (auto &j : request_body) { - FilteringdatabaseSchema a; - a.fromJson(j); - filteringdatabase.push_back(a); - } - update_bridge_filteringdatabase_list_by_id(name, filteringdatabase); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::update_bridge_filteringdatabase_port_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto vlan = request.param(":vlan").as(); - auto address = request.param(":address").as(); - - // Getting the body param - std::string port; - - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - // The conversion is done automatically by the json library - port = request_body; - update_bridge_filteringdatabase_port_by_id(name, vlan, address, port); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::update_bridge_ports_access_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - - // Getting the body param - PortsAccessSchema access; - - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - access.fromJson(request_body); - update_bridge_ports_access_by_id(name, portsName, access); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::update_bridge_ports_access_vlanid_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - - // Getting the body param - int32_t vlanid; - - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - // The conversion is done automatically by the json library - vlanid = request_body; - update_bridge_ports_access_vlanid_by_id(name, portsName, vlanid); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::update_bridge_ports_address_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - - // Getting the body param - std::string address; - - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - // The conversion is done automatically by the json library - address = request_body; - update_bridge_ports_address_by_id(name, portsName, address); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::update_bridge_ports_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - - // Getting the body param - PortsSchema ports; - - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - ports.fromJson(request_body); - update_bridge_ports_by_id(name, portsName, ports); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::update_bridge_ports_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - - // Getting the body param - std::vector ports; - - #define NODE_IS_LIST_CONTAINER - #undef NODE_IS_LIST_CONTAINER - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - for (auto &j : request_body) { - PortsSchema a; - a.fromJson(j); - ports.push_back(a); - } - update_bridge_ports_list_by_id(name, ports); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::update_bridge_ports_mode_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - - // Getting the body param - std::string mode; - - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - // The conversion is done automatically by the json library - mode = request_body; - update_bridge_ports_mode_by_id(name, portsName, mode); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::update_bridge_ports_peer_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - - // Getting the body param - std::string peer; - - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - // The conversion is done automatically by the json library - peer = request_body; - update_bridge_ports_peer_by_id(name, portsName, peer); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::update_bridge_ports_status_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - - // Getting the body param - std::string status; - - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - // The conversion is done automatically by the json library - status = request_body; - update_bridge_ports_status_by_id(name, portsName, status); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::update_bridge_ports_stp_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - auto vlan = request.param(":vlan").as(); - - // Getting the body param - PortsStpSchema stp; - - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - stp.fromJson(request_body); - update_bridge_ports_stp_by_id(name, portsName, vlan, stp); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::update_bridge_ports_stp_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - - // Getting the body param - std::vector stp; - - #define NODE_IS_LIST_CONTAINER - #undef NODE_IS_LIST_CONTAINER - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - for (auto &j : request_body) { - PortsStpSchema a; - a.fromJson(j); - stp.push_back(a); - } - update_bridge_ports_stp_list_by_id(name, portsName, stp); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::update_bridge_ports_stp_pathcost_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - auto vlan = request.param(":vlan").as(); - - // Getting the body param - int32_t pathcost; - - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - // The conversion is done automatically by the json library - pathcost = request_body; - update_bridge_ports_stp_pathcost_by_id(name, portsName, vlan, pathcost); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::update_bridge_ports_stp_portpriority_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - auto vlan = request.param(":vlan").as(); - - // Getting the body param - int32_t portpriority; - - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - // The conversion is done automatically by the json library - portpriority = request_body; - update_bridge_ports_stp_portpriority_by_id(name, portsName, vlan, portpriority); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::update_bridge_ports_trunk_allowed_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - auto vlanid = request.param(":vlanid").as(); - - // Getting the body param - PortsTrunkAllowedSchema allowed; - - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - allowed.fromJson(request_body); - update_bridge_ports_trunk_allowed_by_id(name, portsName, vlanid, allowed); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::update_bridge_ports_trunk_allowed_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - - // Getting the body param - std::vector allowed; - - #define NODE_IS_LIST_CONTAINER - #undef NODE_IS_LIST_CONTAINER - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - for (auto &j : request_body) { - PortsTrunkAllowedSchema a; - a.fromJson(j); - allowed.push_back(a); - } - update_bridge_ports_trunk_allowed_list_by_id(name, portsName, allowed); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::update_bridge_ports_trunk_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - - // Getting the body param - PortsTrunkSchema trunk; - - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - trunk.fromJson(request_body); - update_bridge_ports_trunk_by_id(name, portsName, trunk); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::update_bridge_ports_trunk_nativevlan_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto portsName = request.param(":ports_name").as(); - - // Getting the body param - int32_t nativevlan; - - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - // The conversion is done automatically by the json library - nativevlan = request_body; - update_bridge_ports_trunk_nativevlan_by_id(name, portsName, nativevlan); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::update_bridge_stp_address_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto vlan = request.param(":vlan").as(); - - // Getting the body param - std::string address; - - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - // The conversion is done automatically by the json library - address = request_body; - update_bridge_stp_address_by_id(name, vlan, address); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::update_bridge_stp_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto vlan = request.param(":vlan").as(); - - // Getting the body param - StpSchema stp; - - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - stp.fromJson(request_body); - update_bridge_stp_by_id(name, vlan, stp); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::update_bridge_stp_forwarddelay_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto vlan = request.param(":vlan").as(); - - // Getting the body param - int32_t forwarddelay; - - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - // The conversion is done automatically by the json library - forwarddelay = request_body; - update_bridge_stp_forwarddelay_by_id(name, vlan, forwarddelay); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::update_bridge_stp_hellotime_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto vlan = request.param(":vlan").as(); - - // Getting the body param - int32_t hellotime; - - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - // The conversion is done automatically by the json library - hellotime = request_body; - update_bridge_stp_hellotime_by_id(name, vlan, hellotime); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::update_bridge_stp_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - - // Getting the body param - std::vector stp; - - #define NODE_IS_LIST_CONTAINER - #undef NODE_IS_LIST_CONTAINER - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - for (auto &j : request_body) { - StpSchema a; - a.fromJson(j); - stp.push_back(a); - } - update_bridge_stp_list_by_id(name, stp); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::update_bridge_stp_maxmessageage_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto vlan = request.param(":vlan").as(); - - // Getting the body param - int32_t maxmessageage; - - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - // The conversion is done automatically by the json library - maxmessageage = request_body; - update_bridge_stp_maxmessageage_by_id(name, vlan, maxmessageage); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::update_bridge_stp_priority_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - auto vlan = request.param(":vlan").as(); - - // Getting the body param - int32_t priority; - - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - // The conversion is done automatically by the json library - priority = request_body; - update_bridge_stp_priority_by_id(name, vlan, priority); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::update_bridge_stpenabled_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - - // Getting the body param - bool stpenabled; - - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - // The conversion is done automatically by the json library - stpenabled = request_body; - update_bridge_stpenabled_by_id(name, stpenabled); - response.send(polycube::service::Http::Code::Ok); -} - -void BridgeApi::update_bridge_type_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response) { - // Getting the path params - auto name = request.param(":name").as(); - - // Getting the body param - std::string type; - - - nlohmann::json request_body = nlohmann::json::parse(request.body()); - // The conversion is done automatically by the json library - type = request_body; - update_bridge_type_by_id(name, type); - response.send(polycube::service::Http::Code::Ok); -} - - -} -} -} -} - diff --git a/src/services/pcn-bridge/src/api/BridgeApi.h b/src/services/pcn-bridge/src/api/BridgeApi.h deleted file mode 100755 index b183970b5..000000000 --- a/src/services/pcn-bridge/src/api/BridgeApi.h +++ /dev/null @@ -1,1041 +0,0 @@ -/** -* bridge API -* bridge API generated from bridge.yang -* -* OpenAPI spec version: 1.0.0 -* -* NOTE: This class is auto generated by the swagger code generator program. -* https://github.com/swagger-api/swagger-codegen.git -*/ - - -/* Do not edit this file manually */ - -/* - * BridgeApi.h - * - */ - -#pragma once - - -#include -#include -#include - -#include "BridgeSchema.h" -#include "FilteringdatabaseSchema.h" -#include "PortsAccessSchema.h" -#include "PortsSchema.h" -#include "PortsStpSchema.h" -#include "PortsTrunkAllowedSchema.h" -#include "PortsTrunkSchema.h" -#include "StpSchema.h" -#include - -namespace io { -namespace swagger { -namespace server { -namespace api { - -using namespace io::swagger::server::model; -using namespace polycube::service; - -class BridgeApi : public ManagementInterface { -public: - BridgeApi(); - virtual ~BridgeApi() {}; - - const std::string base = "/"; - -protected: - void setupRoutes(); - void control_handler(const HttpHandleRequest &request, HttpHandleResponse &response) override; - - void create_bridge_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void create_bridge_filteringdatabase_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void create_bridge_filteringdatabase_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void create_bridge_ports_access_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void create_bridge_ports_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void create_bridge_ports_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void create_bridge_ports_stp_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void create_bridge_ports_stp_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void create_bridge_ports_trunk_allowed_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void create_bridge_ports_trunk_allowed_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void create_bridge_ports_trunk_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void create_bridge_stp_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void create_bridge_stp_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void delete_bridge_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void delete_bridge_filteringdatabase_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void delete_bridge_filteringdatabase_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void delete_bridge_ports_access_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void delete_bridge_ports_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void delete_bridge_ports_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void delete_bridge_ports_stp_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void delete_bridge_ports_stp_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void delete_bridge_ports_trunk_allowed_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void delete_bridge_ports_trunk_allowed_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void delete_bridge_ports_trunk_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void delete_bridge_stp_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void delete_bridge_stp_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_agingtime_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_filteringdatabase_age_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_filteringdatabase_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_filteringdatabase_entrytype_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_filteringdatabase_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_filteringdatabase_port_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_ports_access_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_ports_access_vlanid_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_ports_address_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_ports_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_ports_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_ports_mode_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_ports_peer_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_ports_status_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_ports_stp_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_ports_stp_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_ports_stp_pathcost_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_ports_stp_portpriority_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_ports_stp_state_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_ports_trunk_allowed_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_ports_trunk_allowed_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_ports_trunk_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_ports_trunk_nativevlan_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_ports_uuid_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_stp_address_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_stp_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_stp_forwarddelay_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_stp_hellotime_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_stp_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_stp_maxmessageage_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_stp_priority_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_stpenabled_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_type_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void read_bridge_uuid_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void update_bridge_agingtime_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void update_bridge_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void update_bridge_filteringdatabase_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void update_bridge_filteringdatabase_entrytype_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void update_bridge_filteringdatabase_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void update_bridge_filteringdatabase_port_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void update_bridge_ports_access_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void update_bridge_ports_access_vlanid_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void update_bridge_ports_address_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void update_bridge_ports_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void update_bridge_ports_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void update_bridge_ports_mode_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void update_bridge_ports_peer_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void update_bridge_ports_status_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void update_bridge_ports_stp_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void update_bridge_ports_stp_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void update_bridge_ports_stp_pathcost_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void update_bridge_ports_stp_portpriority_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void update_bridge_ports_trunk_allowed_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void update_bridge_ports_trunk_allowed_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void update_bridge_ports_trunk_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void update_bridge_ports_trunk_nativevlan_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void update_bridge_stp_address_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void update_bridge_stp_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void update_bridge_stp_forwarddelay_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void update_bridge_stp_hellotime_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void update_bridge_stp_list_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void update_bridge_stp_maxmessageage_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void update_bridge_stp_priority_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void update_bridge_stpenabled_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - void update_bridge_type_by_id_handler(const polycube::service::Rest::Request &request, polycube::service::HttpHandleResponse &response); - - polycube::service::Rest::Router router; - - /// - /// Create bridge by ID - /// - /// - /// Create operation of resource: bridge - /// - /// ID of name - /// bridgebody object - virtual BridgeSchema create_bridge_by_id(const std::string &name, const BridgeSchema &bridge) = 0; - /// - /// Create filteringdatabase by ID - /// - /// - /// Create operation of resource: filteringdatabase - /// - /// ID of name - /// ID of vlan - /// ID of address - /// filteringdatabasebody object - virtual FilteringdatabaseSchema create_bridge_filteringdatabase_by_id(const std::string &name, const std::string &vlan, const std::string &address, const FilteringdatabaseSchema &filteringdatabase) = 0; - /// - /// Create filteringdatabase by ID - /// - /// - /// Create operation of resource: filteringdatabase - /// - /// ID of name - /// filteringdatabasebody object - virtual std::vector create_bridge_filteringdatabase_list_by_id(const std::string &name, const std::vector &filteringdatabase) = 0; - /// - /// Create access by ID - /// - /// - /// Create operation of resource: access - /// - /// ID of name - /// ID of ports_name - /// accessbody object - virtual PortsAccessSchema create_bridge_ports_access_by_id(const std::string &name, const std::string &portsName, const PortsAccessSchema &access) = 0; - /// - /// Create ports by ID - /// - /// - /// Create operation of resource: ports - /// - /// ID of name - /// ID of ports_name - /// portsbody object - virtual PortsSchema create_bridge_ports_by_id(const std::string &name, const std::string &portsName, const PortsSchema &ports) = 0; - /// - /// Create ports by ID - /// - /// - /// Create operation of resource: ports - /// - /// ID of name - /// portsbody object - virtual std::vector create_bridge_ports_list_by_id(const std::string &name, const std::vector &ports) = 0; - /// - /// Create stp by ID - /// - /// - /// Create operation of resource: stp - /// - /// ID of name - /// ID of ports_name - /// ID of vlan - /// stpbody object - virtual PortsStpSchema create_bridge_ports_stp_by_id(const std::string &name, const std::string &portsName, const std::string &vlan, const PortsStpSchema &stp) = 0; - /// - /// Create stp by ID - /// - /// - /// Create operation of resource: stp - /// - /// ID of name - /// ID of ports_name - /// stpbody object - virtual std::vector create_bridge_ports_stp_list_by_id(const std::string &name, const std::string &portsName, const std::vector &stp) = 0; - /// - /// Create allowed by ID - /// - /// - /// Create operation of resource: allowed - /// - /// ID of name - /// ID of ports_name - /// ID of vlanid - /// allowedbody object - virtual PortsTrunkAllowedSchema create_bridge_ports_trunk_allowed_by_id(const std::string &name, const std::string &portsName, const std::string &vlanid, const PortsTrunkAllowedSchema &allowed) = 0; - /// - /// Create allowed by ID - /// - /// - /// Create operation of resource: allowed - /// - /// ID of name - /// ID of ports_name - /// allowedbody object - virtual std::vector create_bridge_ports_trunk_allowed_list_by_id(const std::string &name, const std::string &portsName, const std::vector &allowed) = 0; - /// - /// Create trunk by ID - /// - /// - /// Create operation of resource: trunk - /// - /// ID of name - /// ID of ports_name - /// trunkbody object - virtual PortsTrunkSchema create_bridge_ports_trunk_by_id(const std::string &name, const std::string &portsName, const PortsTrunkSchema &trunk) = 0; - /// - /// Create stp by ID - /// - /// - /// Create operation of resource: stp - /// - /// ID of name - /// ID of vlan - /// stpbody object - virtual StpSchema create_bridge_stp_by_id(const std::string &name, const std::string &vlan, const StpSchema &stp) = 0; - /// - /// Create stp by ID - /// - /// - /// Create operation of resource: stp - /// - /// ID of name - /// stpbody object - virtual std::vector create_bridge_stp_list_by_id(const std::string &name, const std::vector &stp) = 0; - /// - /// Delete bridge by ID - /// - /// - /// Delete operation of resource: bridge - /// - /// ID of name - virtual void delete_bridge_by_id(const std::string &name) = 0; - /// - /// Delete filteringdatabase by ID - /// - /// - /// Delete operation of resource: filteringdatabase - /// - /// ID of name - /// ID of vlan - /// ID of address - virtual void delete_bridge_filteringdatabase_by_id(const std::string &name, const std::string &vlan, const std::string &address) = 0; - /// - /// Delete filteringdatabase by ID - /// - /// - /// Delete operation of resource: filteringdatabase - /// - /// ID of name - virtual void delete_bridge_filteringdatabase_list_by_id(const std::string &name) = 0; - /// - /// Delete access by ID - /// - /// - /// Delete operation of resource: access - /// - /// ID of name - /// ID of ports_name - virtual void delete_bridge_ports_access_by_id(const std::string &name, const std::string &portsName) = 0; - /// - /// Delete ports by ID - /// - /// - /// Delete operation of resource: ports - /// - /// ID of name - /// ID of ports_name - virtual void delete_bridge_ports_by_id(const std::string &name, const std::string &portsName) = 0; - /// - /// Delete ports by ID - /// - /// - /// Delete operation of resource: ports - /// - /// ID of name - virtual void delete_bridge_ports_list_by_id(const std::string &name) = 0; - /// - /// Delete stp by ID - /// - /// - /// Delete operation of resource: stp - /// - /// ID of name - /// ID of ports_name - /// ID of vlan - virtual void delete_bridge_ports_stp_by_id(const std::string &name, const std::string &portsName, const std::string &vlan) = 0; - /// - /// Delete stp by ID - /// - /// - /// Delete operation of resource: stp - /// - /// ID of name - /// ID of ports_name - virtual void delete_bridge_ports_stp_list_by_id(const std::string &name, const std::string &portsName) = 0; - /// - /// Delete allowed by ID - /// - /// - /// Delete operation of resource: allowed - /// - /// ID of name - /// ID of ports_name - /// ID of vlanid - virtual void delete_bridge_ports_trunk_allowed_by_id(const std::string &name, const std::string &portsName, const std::string &vlanid) = 0; - /// - /// Delete allowed by ID - /// - /// - /// Delete operation of resource: allowed - /// - /// ID of name - /// ID of ports_name - virtual void delete_bridge_ports_trunk_allowed_list_by_id(const std::string &name, const std::string &portsName) = 0; - /// - /// Delete trunk by ID - /// - /// - /// Delete operation of resource: trunk - /// - /// ID of name - /// ID of ports_name - virtual void delete_bridge_ports_trunk_by_id(const std::string &name, const std::string &portsName) = 0; - /// - /// Delete stp by ID - /// - /// - /// Delete operation of resource: stp - /// - /// ID of name - /// ID of vlan - virtual void delete_bridge_stp_by_id(const std::string &name, const std::string &vlan) = 0; - /// - /// Delete stp by ID - /// - /// - /// Delete operation of resource: stp - /// - /// ID of name - virtual void delete_bridge_stp_list_by_id(const std::string &name) = 0; - /// - /// Read agingtime by ID - /// - /// - /// Read operation of resource: agingtime - /// - /// ID of name - virtual int32_t read_bridge_agingtime_by_id(const std::string &name) = 0; - /// - /// Read bridge by ID - /// - /// - /// Read operation of resource: bridge - /// - /// ID of name - virtual BridgeSchema read_bridge_by_id(const std::string &name) = 0; - /// - /// Read age by ID - /// - /// - /// Read operation of resource: age - /// - /// ID of name - /// ID of vlan - /// ID of address - virtual int32_t read_bridge_filteringdatabase_age_by_id(const std::string &name, const std::string &vlan, const std::string &address) = 0; - /// - /// Read filteringdatabase by ID - /// - /// - /// Read operation of resource: filteringdatabase - /// - /// ID of name - /// ID of vlan - /// ID of address - virtual FilteringdatabaseSchema read_bridge_filteringdatabase_by_id(const std::string &name, const std::string &vlan, const std::string &address) = 0; - /// - /// Read entrytype by ID - /// - /// - /// Read operation of resource: entrytype - /// - /// ID of name - /// ID of vlan - /// ID of address - virtual std::string read_bridge_filteringdatabase_entrytype_by_id(const std::string &name, const std::string &vlan, const std::string &address) = 0; - /// - /// Read filteringdatabase by ID - /// - /// - /// Read operation of resource: filteringdatabase - /// - /// ID of name - virtual std::vector read_bridge_filteringdatabase_list_by_id(const std::string &name) = 0; - virtual std::vector read_bridge_filteringdatabase_list_by_id_get_list() = 0; - /// - /// Read port by ID - /// - /// - /// Read operation of resource: port - /// - /// ID of name - /// ID of vlan - /// ID of address - virtual std::string read_bridge_filteringdatabase_port_by_id(const std::string &name, const std::string &vlan, const std::string &address) = 0; - /// - /// Read bridge by ID - /// - /// - /// Read operation of resource: bridge - /// - virtual std::vector read_bridge_list_by_id() = 0; - virtual std::vector read_bridge_list_by_id_get_list() = 0; - /// - /// Read access by ID - /// - /// - /// Read operation of resource: access - /// - /// ID of name - /// ID of ports_name - virtual PortsAccessSchema read_bridge_ports_access_by_id(const std::string &name, const std::string &portsName) = 0; - /// - /// Read vlanid by ID - /// - /// - /// Read operation of resource: vlanid - /// - /// ID of name - /// ID of ports_name - virtual int32_t read_bridge_ports_access_vlanid_by_id(const std::string &name, const std::string &portsName) = 0; - /// - /// Read address by ID - /// - /// - /// Read operation of resource: address - /// - /// ID of name - /// ID of ports_name - virtual std::string read_bridge_ports_address_by_id(const std::string &name, const std::string &portsName) = 0; - /// - /// Read ports by ID - /// - /// - /// Read operation of resource: ports - /// - /// ID of name - /// ID of ports_name - virtual PortsSchema read_bridge_ports_by_id(const std::string &name, const std::string &portsName) = 0; - /// - /// Read ports by ID - /// - /// - /// Read operation of resource: ports - /// - /// ID of name - virtual std::vector read_bridge_ports_list_by_id(const std::string &name) = 0; - virtual std::vector read_bridge_ports_list_by_id_get_list() = 0; - /// - /// Read mode by ID - /// - /// - /// Read operation of resource: mode - /// - /// ID of name - /// ID of ports_name - virtual std::string read_bridge_ports_mode_by_id(const std::string &name, const std::string &portsName) = 0; - /// - /// Read peer by ID - /// - /// - /// Read operation of resource: peer - /// - /// ID of name - /// ID of ports_name - virtual std::string read_bridge_ports_peer_by_id(const std::string &name, const std::string &portsName) = 0; - /// - /// Read status by ID - /// - /// - /// Read operation of resource: status - /// - /// ID of name - /// ID of ports_name - virtual std::string read_bridge_ports_status_by_id(const std::string &name, const std::string &portsName) = 0; - /// - /// Read stp by ID - /// - /// - /// Read operation of resource: stp - /// - /// ID of name - /// ID of ports_name - /// ID of vlan - virtual PortsStpSchema read_bridge_ports_stp_by_id(const std::string &name, const std::string &portsName, const std::string &vlan) = 0; - /// - /// Read stp by ID - /// - /// - /// Read operation of resource: stp - /// - /// ID of name - /// ID of ports_name - virtual std::vector read_bridge_ports_stp_list_by_id(const std::string &name, const std::string &portsName) = 0; - virtual std::vector read_bridge_ports_stp_list_by_id_get_list() = 0; - /// - /// Read pathcost by ID - /// - /// - /// Read operation of resource: pathcost - /// - /// ID of name - /// ID of ports_name - /// ID of vlan - virtual int32_t read_bridge_ports_stp_pathcost_by_id(const std::string &name, const std::string &portsName, const std::string &vlan) = 0; - /// - /// Read portpriority by ID - /// - /// - /// Read operation of resource: portpriority - /// - /// ID of name - /// ID of ports_name - /// ID of vlan - virtual int32_t read_bridge_ports_stp_portpriority_by_id(const std::string &name, const std::string &portsName, const std::string &vlan) = 0; - /// - /// Read state by ID - /// - /// - /// Read operation of resource: state - /// - /// ID of name - /// ID of ports_name - /// ID of vlan - virtual std::string read_bridge_ports_stp_state_by_id(const std::string &name, const std::string &portsName, const std::string &vlan) = 0; - /// - /// Read allowed by ID - /// - /// - /// Read operation of resource: allowed - /// - /// ID of name - /// ID of ports_name - /// ID of vlanid - virtual PortsTrunkAllowedSchema read_bridge_ports_trunk_allowed_by_id(const std::string &name, const std::string &portsName, const std::string &vlanid) = 0; - /// - /// Read allowed by ID - /// - /// - /// Read operation of resource: allowed - /// - /// ID of name - /// ID of ports_name - virtual std::vector read_bridge_ports_trunk_allowed_list_by_id(const std::string &name, const std::string &portsName) = 0; - virtual std::vector read_bridge_ports_trunk_allowed_list_by_id_get_list() = 0; - /// - /// Read trunk by ID - /// - /// - /// Read operation of resource: trunk - /// - /// ID of name - /// ID of ports_name - virtual PortsTrunkSchema read_bridge_ports_trunk_by_id(const std::string &name, const std::string &portsName) = 0; - /// - /// Read nativevlan by ID - /// - /// - /// Read operation of resource: nativevlan - /// - /// ID of name - /// ID of ports_name - virtual int32_t read_bridge_ports_trunk_nativevlan_by_id(const std::string &name, const std::string &portsName) = 0; - /// - /// Read uuid by ID - /// - /// - /// Read operation of resource: uuid - /// - /// ID of name - /// ID of ports_name - virtual std::string read_bridge_ports_uuid_by_id(const std::string &name, const std::string &portsName) = 0; - /// - /// Read address by ID - /// - /// - /// Read operation of resource: address - /// - /// ID of name - /// ID of vlan - virtual std::string read_bridge_stp_address_by_id(const std::string &name, const std::string &vlan) = 0; - /// - /// Read stp by ID - /// - /// - /// Read operation of resource: stp - /// - /// ID of name - /// ID of vlan - virtual StpSchema read_bridge_stp_by_id(const std::string &name, const std::string &vlan) = 0; - /// - /// Read forwarddelay by ID - /// - /// - /// Read operation of resource: forwarddelay - /// - /// ID of name - /// ID of vlan - virtual int32_t read_bridge_stp_forwarddelay_by_id(const std::string &name, const std::string &vlan) = 0; - /// - /// Read hellotime by ID - /// - /// - /// Read operation of resource: hellotime - /// - /// ID of name - /// ID of vlan - virtual int32_t read_bridge_stp_hellotime_by_id(const std::string &name, const std::string &vlan) = 0; - /// - /// Read stp by ID - /// - /// - /// Read operation of resource: stp - /// - /// ID of name - virtual std::vector read_bridge_stp_list_by_id(const std::string &name) = 0; - virtual std::vector read_bridge_stp_list_by_id_get_list() = 0; - /// - /// Read maxmessageage by ID - /// - /// - /// Read operation of resource: maxmessageage - /// - /// ID of name - /// ID of vlan - virtual int32_t read_bridge_stp_maxmessageage_by_id(const std::string &name, const std::string &vlan) = 0; - /// - /// Read priority by ID - /// - /// - /// Read operation of resource: priority - /// - /// ID of name - /// ID of vlan - virtual int32_t read_bridge_stp_priority_by_id(const std::string &name, const std::string &vlan) = 0; - /// - /// Read stpenabled by ID - /// - /// - /// Read operation of resource: stpenabled - /// - /// ID of name - virtual bool read_bridge_stpenabled_by_id(const std::string &name) = 0; - /// - /// Read type by ID - /// - /// - /// Read operation of resource: type - /// - /// ID of name - virtual std::string read_bridge_type_by_id(const std::string &name) = 0; - /// - /// Read uuid by ID - /// - /// - /// Read operation of resource: uuid - /// - /// ID of name - virtual std::string read_bridge_uuid_by_id(const std::string &name) = 0; - /// - /// Update agingtime by ID - /// - /// - /// Update operation of resource: agingtime - /// - /// ID of name - /// Aging time of the filtering database - virtual void update_bridge_agingtime_by_id(const std::string &name, const int32_t &agingtime) = 0; - /// - /// Update bridge by ID - /// - /// - /// Update operation of resource: bridge - /// - /// ID of name - /// bridgebody object - virtual void update_bridge_by_id(const std::string &name, const BridgeSchema &bridge) = 0; - /// - /// Update filteringdatabase by ID - /// - /// - /// Update operation of resource: filteringdatabase - /// - /// ID of name - /// ID of vlan - /// ID of address - /// filteringdatabasebody object - virtual void update_bridge_filteringdatabase_by_id(const std::string &name, const std::string &vlan, const std::string &address, const FilteringdatabaseSchema &filteringdatabase) = 0; - /// - /// Update entrytype by ID - /// - /// - /// Update operation of resource: entrytype - /// - /// ID of name - /// ID of vlan - /// ID of address - /// Type of filtering entry - virtual void update_bridge_filteringdatabase_entrytype_by_id(const std::string &name, const std::string &vlan, const std::string &address, const std::string &entrytype) = 0; - /// - /// Update filteringdatabase by ID - /// - /// - /// Update operation of resource: filteringdatabase - /// - /// ID of name - /// filteringdatabasebody object - virtual void update_bridge_filteringdatabase_list_by_id(const std::string &name, const std::vector &filteringdatabase) = 0; - /// - /// Update port by ID - /// - /// - /// Update operation of resource: port - /// - /// ID of name - /// ID of vlan - /// ID of address - /// Output port name - virtual void update_bridge_filteringdatabase_port_by_id(const std::string &name, const std::string &vlan, const std::string &address, const std::string &port) = 0; - /// - /// Update access by ID - /// - /// - /// Update operation of resource: access - /// - /// ID of name - /// ID of ports_name - /// accessbody object - virtual void update_bridge_ports_access_by_id(const std::string &name, const std::string &portsName, const PortsAccessSchema &access) = 0; - /// - /// Update vlanid by ID - /// - /// - /// Update operation of resource: vlanid - /// - /// ID of name - /// ID of ports_name - /// VLAN associated with this interface - virtual void update_bridge_ports_access_vlanid_by_id(const std::string &name, const std::string &portsName, const int32_t &vlanid) = 0; - /// - /// Update address by ID - /// - /// - /// Update operation of resource: address - /// - /// ID of name - /// ID of ports_name - /// MAC address of the port - virtual void update_bridge_ports_address_by_id(const std::string &name, const std::string &portsName, const std::string &address) = 0; - /// - /// Update ports by ID - /// - /// - /// Update operation of resource: ports - /// - /// ID of name - /// ID of ports_name - /// portsbody object - virtual void update_bridge_ports_by_id(const std::string &name, const std::string &portsName, const PortsSchema &ports) = 0; - /// - /// Update ports by ID - /// - /// - /// Update operation of resource: ports - /// - /// ID of name - /// portsbody object - virtual void update_bridge_ports_list_by_id(const std::string &name, const std::vector &ports) = 0; - /// - /// Update mode by ID - /// - /// - /// Update operation of resource: mode - /// - /// ID of name - /// ID of ports_name - /// Type of bridge interface: access/trunk - virtual void update_bridge_ports_mode_by_id(const std::string &name, const std::string &portsName, const std::string &mode) = 0; - /// - /// Update peer by ID - /// - /// - /// Update operation of resource: peer - /// - /// ID of name - /// ID of ports_name - /// Peer name, such as a network interfaces (e.g., 'veth0') or another cube (e.g., 'br1:port2') - virtual void update_bridge_ports_peer_by_id(const std::string &name, const std::string &portsName, const std::string &peer) = 0; - /// - /// Update status by ID - /// - /// - /// Update operation of resource: status - /// - /// ID of name - /// ID of ports_name - /// Status of the port (UP or DOWN) - virtual void update_bridge_ports_status_by_id(const std::string &name, const std::string &portsName, const std::string &status) = 0; - /// - /// Update stp by ID - /// - /// - /// Update operation of resource: stp - /// - /// ID of name - /// ID of ports_name - /// ID of vlan - /// stpbody object - virtual void update_bridge_ports_stp_by_id(const std::string &name, const std::string &portsName, const std::string &vlan, const PortsStpSchema &stp) = 0; - /// - /// Update stp by ID - /// - /// - /// Update operation of resource: stp - /// - /// ID of name - /// ID of ports_name - /// stpbody object - virtual void update_bridge_ports_stp_list_by_id(const std::string &name, const std::string &portsName, const std::vector &stp) = 0; - /// - /// Update pathcost by ID - /// - /// - /// Update operation of resource: pathcost - /// - /// ID of name - /// ID of ports_name - /// ID of vlan - /// STP cost associated with this interface - virtual void update_bridge_ports_stp_pathcost_by_id(const std::string &name, const std::string &portsName, const std::string &vlan, const int32_t &pathcost) = 0; - /// - /// Update portpriority by ID - /// - /// - /// Update operation of resource: portpriority - /// - /// ID of name - /// ID of ports_name - /// ID of vlan - /// Port priority of this interface - virtual void update_bridge_ports_stp_portpriority_by_id(const std::string &name, const std::string &portsName, const std::string &vlan, const int32_t &portpriority) = 0; - /// - /// Update allowed by ID - /// - /// - /// Update operation of resource: allowed - /// - /// ID of name - /// ID of ports_name - /// ID of vlanid - /// allowedbody object - virtual void update_bridge_ports_trunk_allowed_by_id(const std::string &name, const std::string &portsName, const std::string &vlanid, const PortsTrunkAllowedSchema &allowed) = 0; - /// - /// Update allowed by ID - /// - /// - /// Update operation of resource: allowed - /// - /// ID of name - /// ID of ports_name - /// allowedbody object - virtual void update_bridge_ports_trunk_allowed_list_by_id(const std::string &name, const std::string &portsName, const std::vector &allowed) = 0; - /// - /// Update trunk by ID - /// - /// - /// Update operation of resource: trunk - /// - /// ID of name - /// ID of ports_name - /// trunkbody object - virtual void update_bridge_ports_trunk_by_id(const std::string &name, const std::string &portsName, const PortsTrunkSchema &trunk) = 0; - /// - /// Update nativevlan by ID - /// - /// - /// Update operation of resource: nativevlan - /// - /// ID of name - /// ID of ports_name - /// VLAN that is not tagged in this trunk port - virtual void update_bridge_ports_trunk_nativevlan_by_id(const std::string &name, const std::string &portsName, const int32_t &nativevlan) = 0; - /// - /// Update address by ID - /// - /// - /// Update operation of resource: address - /// - /// ID of name - /// ID of vlan - /// Main MAC address used by the STP - virtual void update_bridge_stp_address_by_id(const std::string &name, const std::string &vlan, const std::string &address) = 0; - /// - /// Update stp by ID - /// - /// - /// Update operation of resource: stp - /// - /// ID of name - /// ID of vlan - /// stpbody object - virtual void update_bridge_stp_by_id(const std::string &name, const std::string &vlan, const StpSchema &stp) = 0; - /// - /// Update forwarddelay by ID - /// - /// - /// Update operation of resource: forwarddelay - /// - /// ID of name - /// ID of vlan - /// Delay used by STP bridges for port state transition - virtual void update_bridge_stp_forwarddelay_by_id(const std::string &name, const std::string &vlan, const int32_t &forwarddelay) = 0; - /// - /// Update hellotime by ID - /// - /// - /// Update operation of resource: hellotime - /// - /// ID of name - /// ID of vlan - /// Interval between transmissions of BPDU messages - virtual void update_bridge_stp_hellotime_by_id(const std::string &name, const std::string &vlan, const int32_t &hellotime) = 0; - /// - /// Update stp by ID - /// - /// - /// Update operation of resource: stp - /// - /// ID of name - /// stpbody object - virtual void update_bridge_stp_list_by_id(const std::string &name, const std::vector &stp) = 0; - /// - /// Update maxmessageage by ID - /// - /// - /// Update operation of resource: maxmessageage - /// - /// ID of name - /// ID of vlan - /// Maximum age of a BPDU - virtual void update_bridge_stp_maxmessageage_by_id(const std::string &name, const std::string &vlan, const int32_t &maxmessageage) = 0; - /// - /// Update priority by ID - /// - /// - /// Update operation of resource: priority - /// - /// ID of name - /// ID of vlan - /// Bridge priority for STP - virtual void update_bridge_stp_priority_by_id(const std::string &name, const std::string &vlan, const int32_t &priority) = 0; - /// - /// Update stpenabled by ID - /// - /// - /// Update operation of resource: stpenabled - /// - /// ID of name - /// Enable/Disable the STP protocol of the bridge - virtual void update_bridge_stpenabled_by_id(const std::string &name, const bool &stpenabled) = 0; - /// - /// Update type by ID - /// - /// - /// Update operation of resource: type - /// - /// ID of name - /// Type of the Cube (TC, XDP_SKB, XDP_DRV) - virtual void update_bridge_type_by_id(const std::string &name, const std::string &type) = 0; -}; - -} -} -} -} - diff --git a/src/services/pcn-bridge/src/api/BridgeApiImpl.cpp b/src/services/pcn-bridge/src/api/BridgeApiImpl.cpp deleted file mode 100755 index c6c5f601b..000000000 --- a/src/services/pcn-bridge/src/api/BridgeApiImpl.cpp +++ /dev/null @@ -1,1554 +0,0 @@ -/** -* bridge API -* bridge API generated from bridge.yang -* -* OpenAPI spec version: 1.0.0 -* -* NOTE: This class is auto generated by the swagger code generator program. -* https://github.com/swagger-api/swagger-codegen.git -*/ - - -/* Do not edit this file manually */ - - -#include "BridgeApiImpl.h" - -namespace io { -namespace swagger { -namespace server { -namespace api { - -using namespace io::swagger::server::model; - -BridgeApiImpl::BridgeApiImpl() {} - -/* - * These functions include a default basic implementation. The user could - * extend adapt this implementation to his needs. - */ - -Bridge &BridgeApiImpl::get_cube(const std::string &name) { - try { - return cubes.at(name); - } catch (std::exception e) { - std::cout << e.what() << std::endl; - throw std::runtime_error("Cube " + name + " does not exist"); - } -} - -BridgeSchema BridgeApiImpl::create_bridge_by_id( - const std::string &name, const BridgeSchema &schema) { - if (cubes.count(name) != 0) { - throw std::runtime_error("There is already a cube with name " + name); - } - - BridgeSchema localSchema(schema); - std::unordered_map::iterator iter; - bool inserted; - - if(localSchema.typeIsSet() && !localSchema.getType().empty()) { - switch(BridgeApiImpl::string_to_type(localSchema.getType())){ - case CubeType::XDP_SKB: - std::tie(iter, inserted) = cubes.emplace(std::piecewise_construct, - std::forward_as_tuple(name), - std::forward_as_tuple(name, localSchema, CubeType::XDP_SKB)); - break; - case CubeType::XDP_DRV: - std::tie(iter, inserted) = cubes.emplace(std::piecewise_construct, - std::forward_as_tuple(name), - std::forward_as_tuple(name, localSchema, CubeType::XDP_DRV)); - break; - default: - std::tie(iter, inserted) = cubes.emplace(std::piecewise_construct, - std::forward_as_tuple(name), - std::forward_as_tuple(name, localSchema)); - break; - } - } else { - std::tie(iter, inserted) = cubes.emplace(std::piecewise_construct, - std::forward_as_tuple(name), - std::forward_as_tuple(name, localSchema)); - } - - Bridge &m = iter->second; - localSchema.setUuid(m.get_uuid().str()); - return localSchema; -} - -CubeType BridgeApiImpl::string_to_type(const std::string &type) { - if(type.compare("XDP_SKB") == 0) { - return CubeType::XDP_SKB; - } else if(type.compare("XDP_DRV") == 0) { - return CubeType::XDP_DRV; - } else { - return CubeType::TC; - } -} - -void BridgeApiImpl::delete_bridge_by_id(const std::string &name) { - if (cubes.count(name) == 0) { - throw std::runtime_error("Cube " + name + " does not exist"); - } - cubes.erase(name); -} - -std::string BridgeApiImpl::read_bridge_uuid_by_id( - const std::string &name) { - Bridge &m = get_cube(name); - return m.get_uuid().str(); -} - -std::vector BridgeApiImpl::read_bridge_list_by_id() { - throw std::runtime_error("Method not implemented"); -} - -std::vector BridgeApiImpl::read_bridge_list_by_id_get_list() { - std::vector modules; - for (auto &x : cubes) { - modules.push_back(x.first); - } - return modules; -} - -/* - * Ports list related functions - */ -std::vector BridgeApiImpl::create_bridge_ports_list_by_id( - const std::string &name, const std::vector &ports) { - throw std::runtime_error("Method not implemented"); -} - -std::vector BridgeApiImpl::read_bridge_ports_list_by_id( - const std::string &name) { - throw std::runtime_error("Method not implemented"); -} - -void BridgeApiImpl::update_bridge_ports_list_by_id( - const std::string &name, const std::vector &ports) { - throw std::runtime_error("Method not implemented"); -} - -void BridgeApiImpl::delete_bridge_ports_list_by_id( - const std::string &name) { - throw std::runtime_error("Method not implemented"); -} - -std::vector BridgeApiImpl::read_bridge_ports_list_by_id_get_list() { - return std::vector(); -} - -/* - * Ports related functions - */ -PortsSchema BridgeApiImpl::create_bridge_ports_by_id( - const std::string &name, const std::string &portsName, - const PortsSchema &ports) { - Bridge &m = get_cube(name); - return m.add_port(portsName, ports); -} - -PortsSchema BridgeApiImpl::read_bridge_ports_by_id( - const std::string &name, const std::string &portsName) { - throw std::runtime_error("Method not implemented"); -} - -void BridgeApiImpl::update_bridge_ports_by_id( - const std::string &name, const std::string &portsName, - const PortsSchema &ports) { - throw std::runtime_error("Method not implemented"); -} - -void BridgeApiImpl::delete_bridge_ports_by_id( - const std::string &name, const std::string &portsName) { - Bridge &m = get_cube(name); - m.remove_port(portsName); -} - -std::string BridgeApiImpl::read_bridge_ports_peer_by_id( - const std::string &name, const std::string &portsName) { - Bridge &m = get_cube(name); - auto p = m.get_port(portsName); - return p->peer(); -} - -std::string BridgeApiImpl::read_bridge_ports_status_by_id( - const std::string &name, const std::string &portsName) { - throw std::runtime_error("Method not implemented"); -} - -std::string BridgeApiImpl::read_bridge_ports_uuid_by_id( - const std::string &name, const std::string &portsName) { - Bridge &m = get_cube(name); - auto p = m.get_port(portsName); - return p->uuid().str(); -} - -void BridgeApiImpl::update_bridge_ports_peer_by_id( - const std::string &name, const std::string &portsName, - const std::string &peer) { - Bridge &m = get_cube(name); - auto p = m.get_port(portsName); - p->set_peer(peer); -} - -void BridgeApiImpl::update_bridge_ports_status_by_id( - const std::string &name, const std::string &portsName, - const std::string &status) { - throw std::runtime_error("Method not implemented"); -} - - -/** -* @brief Create filteringdatabase by ID -* -* Create operation of resource: filteringdatabase* -* -* @param[in] name ID of name -* @param[in] vlan ID of vlan -* @param[in] address ID of address -* @param[in] filteringdatabase filteringdatabasebody object -* -* Responses: -* FilteringdatabaseSchema -*/ -FilteringdatabaseSchema -BridgeApiImpl::create_bridge_filteringdatabase_by_id(const std::string &name, const std::string &vlan, const std::string &address, const FilteringdatabaseSchema &filteringdatabase) { - auto &m = get_cube(name); - return m.create_bridge_filteringdatabase_by_id(vlan, address, filteringdatabase); -} - -/** -* @brief Create filteringdatabase by ID -* -* Create operation of resource: filteringdatabase* -* -* @param[in] name ID of name -* @param[in] filteringdatabase filteringdatabasebody object -* -* Responses: -* std::vector -*/ -std::vector -BridgeApiImpl::create_bridge_filteringdatabase_list_by_id(const std::string &name, const std::vector &filteringdatabase) { - auto &m = get_cube(name); - return m.create_bridge_filteringdatabase_list_by_id(filteringdatabase); -} - -/** -* @brief Create access by ID -* -* Create operation of resource: access* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* @param[in] access accessbody object -* -* Responses: -* PortsAccessSchema -*/ -PortsAccessSchema -BridgeApiImpl::create_bridge_ports_access_by_id(const std::string &name, const std::string &portsName, const PortsAccessSchema &access) { - auto &m = get_cube(name); - return m.create_bridge_ports_access_by_id(portsName, access); -} - -/** -* @brief Create stp by ID -* -* Create operation of resource: stp* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* @param[in] vlan ID of vlan -* @param[in] stp stpbody object -* -* Responses: -* PortsStpSchema -*/ -PortsStpSchema -BridgeApiImpl::create_bridge_ports_stp_by_id(const std::string &name, const std::string &portsName, const std::string &vlan, const PortsStpSchema &stp) { - auto &m = get_cube(name); - return m.create_bridge_ports_stp_by_id(portsName, vlan, stp); -} - -/** -* @brief Create stp by ID -* -* Create operation of resource: stp* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* @param[in] stp stpbody object -* -* Responses: -* std::vector -*/ -std::vector -BridgeApiImpl::create_bridge_ports_stp_list_by_id(const std::string &name, const std::string &portsName, const std::vector &stp) { - auto &m = get_cube(name); - return m.create_bridge_ports_stp_list_by_id(portsName, stp); -} - -/** -* @brief Create allowed by ID -* -* Create operation of resource: allowed* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* @param[in] vlanid ID of vlanid -* @param[in] allowed allowedbody object -* -* Responses: -* PortsTrunkAllowedSchema -*/ -PortsTrunkAllowedSchema -BridgeApiImpl::create_bridge_ports_trunk_allowed_by_id(const std::string &name, const std::string &portsName, const std::string &vlanid, const PortsTrunkAllowedSchema &allowed) { - auto &m = get_cube(name); - return m.create_bridge_ports_trunk_allowed_by_id(portsName, vlanid, allowed); -} - -/** -* @brief Create allowed by ID -* -* Create operation of resource: allowed* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* @param[in] allowed allowedbody object -* -* Responses: -* std::vector -*/ -std::vector -BridgeApiImpl::create_bridge_ports_trunk_allowed_list_by_id(const std::string &name, const std::string &portsName, const std::vector &allowed) { - auto &m = get_cube(name); - return m.create_bridge_ports_trunk_allowed_list_by_id(portsName, allowed); -} - -/** -* @brief Create trunk by ID -* -* Create operation of resource: trunk* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* @param[in] trunk trunkbody object -* -* Responses: -* PortsTrunkSchema -*/ -PortsTrunkSchema -BridgeApiImpl::create_bridge_ports_trunk_by_id(const std::string &name, const std::string &portsName, const PortsTrunkSchema &trunk) { - auto &m = get_cube(name); - return m.create_bridge_ports_trunk_by_id(portsName, trunk); -} - -/** -* @brief Create stp by ID -* -* Create operation of resource: stp* -* -* @param[in] name ID of name -* @param[in] vlan ID of vlan -* @param[in] stp stpbody object -* -* Responses: -* StpSchema -*/ -StpSchema -BridgeApiImpl::create_bridge_stp_by_id(const std::string &name, const std::string &vlan, const StpSchema &stp) { - auto &m = get_cube(name); - return m.create_bridge_stp_by_id(vlan, stp); -} - -/** -* @brief Create stp by ID -* -* Create operation of resource: stp* -* -* @param[in] name ID of name -* @param[in] stp stpbody object -* -* Responses: -* std::vector -*/ -std::vector -BridgeApiImpl::create_bridge_stp_list_by_id(const std::string &name, const std::vector &stp) { - auto &m = get_cube(name); - return m.create_bridge_stp_list_by_id(stp); -} - -/** -* @brief Delete filteringdatabase by ID -* -* Delete operation of resource: filteringdatabase* -* -* @param[in] name ID of name -* @param[in] vlan ID of vlan -* @param[in] address ID of address -* -* Responses: -* -*/ -void -BridgeApiImpl::delete_bridge_filteringdatabase_by_id(const std::string &name, const std::string &vlan, const std::string &address) { - auto &m = get_cube(name); - return m.delete_bridge_filteringdatabase_by_id(vlan, address); -} - -/** -* @brief Delete filteringdatabase by ID -* -* Delete operation of resource: filteringdatabase* -* -* @param[in] name ID of name -* -* Responses: -* -*/ -void -BridgeApiImpl::delete_bridge_filteringdatabase_list_by_id(const std::string &name) { - auto &m = get_cube(name); - return m.delete_bridge_filteringdatabase_list_by_id(); -} - -/** -* @brief Delete access by ID -* -* Delete operation of resource: access* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* -* Responses: -* -*/ -void -BridgeApiImpl::delete_bridge_ports_access_by_id(const std::string &name, const std::string &portsName) { - auto &m = get_cube(name); - return m.delete_bridge_ports_access_by_id(portsName); -} - -/** -* @brief Delete stp by ID -* -* Delete operation of resource: stp* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* @param[in] vlan ID of vlan -* -* Responses: -* -*/ -void -BridgeApiImpl::delete_bridge_ports_stp_by_id(const std::string &name, const std::string &portsName, const std::string &vlan) { - auto &m = get_cube(name); - return m.delete_bridge_ports_stp_by_id(portsName, vlan); -} - -/** -* @brief Delete stp by ID -* -* Delete operation of resource: stp* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* -* Responses: -* -*/ -void -BridgeApiImpl::delete_bridge_ports_stp_list_by_id(const std::string &name, const std::string &portsName) { - auto &m = get_cube(name); - return m.delete_bridge_ports_stp_list_by_id(portsName); -} - -/** -* @brief Delete allowed by ID -* -* Delete operation of resource: allowed* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* @param[in] vlanid ID of vlanid -* -* Responses: -* -*/ -void -BridgeApiImpl::delete_bridge_ports_trunk_allowed_by_id(const std::string &name, const std::string &portsName, const std::string &vlanid) { - auto &m = get_cube(name); - return m.delete_bridge_ports_trunk_allowed_by_id(portsName, vlanid); -} - -/** -* @brief Delete allowed by ID -* -* Delete operation of resource: allowed* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* -* Responses: -* -*/ -void -BridgeApiImpl::delete_bridge_ports_trunk_allowed_list_by_id(const std::string &name, const std::string &portsName) { - auto &m = get_cube(name); - return m.delete_bridge_ports_trunk_allowed_list_by_id(portsName); -} - -/** -* @brief Delete trunk by ID -* -* Delete operation of resource: trunk* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* -* Responses: -* -*/ -void -BridgeApiImpl::delete_bridge_ports_trunk_by_id(const std::string &name, const std::string &portsName) { - auto &m = get_cube(name); - return m.delete_bridge_ports_trunk_by_id(portsName); -} - -/** -* @brief Delete stp by ID -* -* Delete operation of resource: stp* -* -* @param[in] name ID of name -* @param[in] vlan ID of vlan -* -* Responses: -* -*/ -void -BridgeApiImpl::delete_bridge_stp_by_id(const std::string &name, const std::string &vlan) { - auto &m = get_cube(name); - return m.delete_bridge_stp_by_id(vlan); -} - -/** -* @brief Delete stp by ID -* -* Delete operation of resource: stp* -* -* @param[in] name ID of name -* -* Responses: -* -*/ -void -BridgeApiImpl::delete_bridge_stp_list_by_id(const std::string &name) { - auto &m = get_cube(name); - return m.delete_bridge_stp_list_by_id(); -} - -/** -* @brief Read agingtime by ID -* -* Read operation of resource: agingtime* -* -* @param[in] name ID of name -* -* Responses: -* int32_t -*/ -int32_t -BridgeApiImpl::read_bridge_agingtime_by_id(const std::string &name) { - auto &m = get_cube(name); - return m.read_bridge_agingtime_by_id(); -} - -/** -* @brief Read bridge by ID -* -* Read operation of resource: bridge* -* -* @param[in] name ID of name -* -* Responses: -* BridgeSchema -*/ -BridgeSchema -BridgeApiImpl::read_bridge_by_id(const std::string &name) { - auto &m = get_cube(name); - return m.read_bridge_by_id(); -} - -/** -* @brief Read age by ID -* -* Read operation of resource: age* -* -* @param[in] name ID of name -* @param[in] vlan ID of vlan -* @param[in] address ID of address -* -* Responses: -* int32_t -*/ -int32_t -BridgeApiImpl::read_bridge_filteringdatabase_age_by_id(const std::string &name, const std::string &vlan, const std::string &address) { - auto &m = get_cube(name); - return m.read_bridge_filteringdatabase_age_by_id(vlan, address); -} - -/** -* @brief Read filteringdatabase by ID -* -* Read operation of resource: filteringdatabase* -* -* @param[in] name ID of name -* @param[in] vlan ID of vlan -* @param[in] address ID of address -* -* Responses: -* FilteringdatabaseSchema -*/ -FilteringdatabaseSchema -BridgeApiImpl::read_bridge_filteringdatabase_by_id(const std::string &name, const std::string &vlan, const std::string &address) { - auto &m = get_cube(name); - return m.read_bridge_filteringdatabase_by_id(vlan, address); -} - -/** -* @brief Read entrytype by ID -* -* Read operation of resource: entrytype* -* -* @param[in] name ID of name -* @param[in] vlan ID of vlan -* @param[in] address ID of address -* -* Responses: -* std::string -*/ -std::string -BridgeApiImpl::read_bridge_filteringdatabase_entrytype_by_id(const std::string &name, const std::string &vlan, const std::string &address) { - auto &m = get_cube(name); - return m.read_bridge_filteringdatabase_entrytype_by_id(vlan, address); -} - -/** -* @brief Read filteringdatabase by ID -* -* Read operation of resource: filteringdatabase* -* -* @param[in] name ID of name -* -* Responses: -* std::vector -*/ -std::vector -BridgeApiImpl::read_bridge_filteringdatabase_list_by_id(const std::string &name) { - auto &m = get_cube(name); - return m.read_bridge_filteringdatabase_list_by_id(); -} - -std::vector BridgeApiImpl::read_bridge_filteringdatabase_list_by_id_get_list() { - return std::vector(); -} -/** -* @brief Read port by ID -* -* Read operation of resource: port* -* -* @param[in] name ID of name -* @param[in] vlan ID of vlan -* @param[in] address ID of address -* -* Responses: -* std::string -*/ -std::string -BridgeApiImpl::read_bridge_filteringdatabase_port_by_id(const std::string &name, const std::string &vlan, const std::string &address) { - auto &m = get_cube(name); - return m.read_bridge_filteringdatabase_port_by_id(vlan, address); -} - -/** -* @brief Read access by ID -* -* Read operation of resource: access* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* -* Responses: -* PortsAccessSchema -*/ -PortsAccessSchema -BridgeApiImpl::read_bridge_ports_access_by_id(const std::string &name, const std::string &portsName) { - auto &m = get_cube(name); - return m.read_bridge_ports_access_by_id(portsName); -} - -/** -* @brief Read vlanid by ID -* -* Read operation of resource: vlanid* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* -* Responses: -* int32_t -*/ -int32_t -BridgeApiImpl::read_bridge_ports_access_vlanid_by_id(const std::string &name, const std::string &portsName) { - auto &m = get_cube(name); - return m.read_bridge_ports_access_vlanid_by_id(portsName); -} - -/** -* @brief Read address by ID -* -* Read operation of resource: address* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* -* Responses: -* std::string -*/ -std::string -BridgeApiImpl::read_bridge_ports_address_by_id(const std::string &name, const std::string &portsName) { - auto &m = get_cube(name); - return m.read_bridge_ports_address_by_id(portsName); -} - -/** -* @brief Read mode by ID -* -* Read operation of resource: mode* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* -* Responses: -* std::string -*/ -std::string -BridgeApiImpl::read_bridge_ports_mode_by_id(const std::string &name, const std::string &portsName) { - auto &m = get_cube(name); - return m.read_bridge_ports_mode_by_id(portsName); -} - -/** -* @brief Read stp by ID -* -* Read operation of resource: stp* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* @param[in] vlan ID of vlan -* -* Responses: -* PortsStpSchema -*/ -PortsStpSchema -BridgeApiImpl::read_bridge_ports_stp_by_id(const std::string &name, const std::string &portsName, const std::string &vlan) { - auto &m = get_cube(name); - return m.read_bridge_ports_stp_by_id(portsName, vlan); -} - -/** -* @brief Read stp by ID -* -* Read operation of resource: stp* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* -* Responses: -* std::vector -*/ -std::vector -BridgeApiImpl::read_bridge_ports_stp_list_by_id(const std::string &name, const std::string &portsName) { - auto &m = get_cube(name); - return m.read_bridge_ports_stp_list_by_id(portsName); -} - -std::vector BridgeApiImpl::read_bridge_ports_stp_list_by_id_get_list() { - return std::vector(); -} -/** -* @brief Read pathcost by ID -* -* Read operation of resource: pathcost* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* @param[in] vlan ID of vlan -* -* Responses: -* int32_t -*/ -int32_t -BridgeApiImpl::read_bridge_ports_stp_pathcost_by_id(const std::string &name, const std::string &portsName, const std::string &vlan) { - auto &m = get_cube(name); - return m.read_bridge_ports_stp_pathcost_by_id(portsName, vlan); -} - -/** -* @brief Read portpriority by ID -* -* Read operation of resource: portpriority* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* @param[in] vlan ID of vlan -* -* Responses: -* int32_t -*/ -int32_t -BridgeApiImpl::read_bridge_ports_stp_portpriority_by_id(const std::string &name, const std::string &portsName, const std::string &vlan) { - auto &m = get_cube(name); - return m.read_bridge_ports_stp_portpriority_by_id(portsName, vlan); -} - -/** -* @brief Read state by ID -* -* Read operation of resource: state* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* @param[in] vlan ID of vlan -* -* Responses: -* std::string -*/ -std::string -BridgeApiImpl::read_bridge_ports_stp_state_by_id(const std::string &name, const std::string &portsName, const std::string &vlan) { - auto &m = get_cube(name); - return m.read_bridge_ports_stp_state_by_id(portsName, vlan); -} - -/** -* @brief Read allowed by ID -* -* Read operation of resource: allowed* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* @param[in] vlanid ID of vlanid -* -* Responses: -* PortsTrunkAllowedSchema -*/ -PortsTrunkAllowedSchema -BridgeApiImpl::read_bridge_ports_trunk_allowed_by_id(const std::string &name, const std::string &portsName, const std::string &vlanid) { - auto &m = get_cube(name); - return m.read_bridge_ports_trunk_allowed_by_id(portsName, vlanid); -} - -/** -* @brief Read allowed by ID -* -* Read operation of resource: allowed* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* -* Responses: -* std::vector -*/ -std::vector -BridgeApiImpl::read_bridge_ports_trunk_allowed_list_by_id(const std::string &name, const std::string &portsName) { - auto &m = get_cube(name); - return m.read_bridge_ports_trunk_allowed_list_by_id(portsName); -} - -std::vector BridgeApiImpl::read_bridge_ports_trunk_allowed_list_by_id_get_list() { - return std::vector(); -} -/** -* @brief Read trunk by ID -* -* Read operation of resource: trunk* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* -* Responses: -* PortsTrunkSchema -*/ -PortsTrunkSchema -BridgeApiImpl::read_bridge_ports_trunk_by_id(const std::string &name, const std::string &portsName) { - auto &m = get_cube(name); - return m.read_bridge_ports_trunk_by_id(portsName); -} - -/** -* @brief Read nativevlan by ID -* -* Read operation of resource: nativevlan* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* -* Responses: -* int32_t -*/ -int32_t -BridgeApiImpl::read_bridge_ports_trunk_nativevlan_by_id(const std::string &name, const std::string &portsName) { - auto &m = get_cube(name); - return m.read_bridge_ports_trunk_nativevlan_by_id(portsName); -} - -/** -* @brief Read address by ID -* -* Read operation of resource: address* -* -* @param[in] name ID of name -* @param[in] vlan ID of vlan -* -* Responses: -* std::string -*/ -std::string -BridgeApiImpl::read_bridge_stp_address_by_id(const std::string &name, const std::string &vlan) { - auto &m = get_cube(name); - return m.read_bridge_stp_address_by_id(vlan); -} - -/** -* @brief Read stp by ID -* -* Read operation of resource: stp* -* -* @param[in] name ID of name -* @param[in] vlan ID of vlan -* -* Responses: -* StpSchema -*/ -StpSchema -BridgeApiImpl::read_bridge_stp_by_id(const std::string &name, const std::string &vlan) { - auto &m = get_cube(name); - return m.read_bridge_stp_by_id(vlan); -} - -/** -* @brief Read forwarddelay by ID -* -* Read operation of resource: forwarddelay* -* -* @param[in] name ID of name -* @param[in] vlan ID of vlan -* -* Responses: -* int32_t -*/ -int32_t -BridgeApiImpl::read_bridge_stp_forwarddelay_by_id(const std::string &name, const std::string &vlan) { - auto &m = get_cube(name); - return m.read_bridge_stp_forwarddelay_by_id(vlan); -} - -/** -* @brief Read hellotime by ID -* -* Read operation of resource: hellotime* -* -* @param[in] name ID of name -* @param[in] vlan ID of vlan -* -* Responses: -* int32_t -*/ -int32_t -BridgeApiImpl::read_bridge_stp_hellotime_by_id(const std::string &name, const std::string &vlan) { - auto &m = get_cube(name); - return m.read_bridge_stp_hellotime_by_id(vlan); -} - -/** -* @brief Read stp by ID -* -* Read operation of resource: stp* -* -* @param[in] name ID of name -* -* Responses: -* std::vector -*/ -std::vector -BridgeApiImpl::read_bridge_stp_list_by_id(const std::string &name) { - auto &m = get_cube(name); - return m.read_bridge_stp_list_by_id(); -} - -std::vector BridgeApiImpl::read_bridge_stp_list_by_id_get_list() { - return std::vector(); -} -/** -* @brief Read maxmessageage by ID -* -* Read operation of resource: maxmessageage* -* -* @param[in] name ID of name -* @param[in] vlan ID of vlan -* -* Responses: -* int32_t -*/ -int32_t -BridgeApiImpl::read_bridge_stp_maxmessageage_by_id(const std::string &name, const std::string &vlan) { - auto &m = get_cube(name); - return m.read_bridge_stp_maxmessageage_by_id(vlan); -} - -/** -* @brief Read priority by ID -* -* Read operation of resource: priority* -* -* @param[in] name ID of name -* @param[in] vlan ID of vlan -* -* Responses: -* int32_t -*/ -int32_t -BridgeApiImpl::read_bridge_stp_priority_by_id(const std::string &name, const std::string &vlan) { - auto &m = get_cube(name); - return m.read_bridge_stp_priority_by_id(vlan); -} - -/** -* @brief Read type by ID -* -* Read operation of resource: type* -* -* @param[in] name ID of name -* -* Responses: -* std::string -*/ -std::string -BridgeApiImpl::read_bridge_type_by_id(const std::string &name) { - auto &m = get_cube(name); - return m.read_bridge_type_by_id(); -} - -/** -* @brief Read stpenabled by ID -* -* Read operation of resource: stpenabled* -* -* @param[in] name ID of name -* -* Responses: -* bool -*/ -bool -BridgeApiImpl::read_bridge_stpenabled_by_id(const std::string &name) { - auto &m = get_cube(name); - return m.read_bridge_stpenabled_by_id(); -} - -/** -* @brief Update agingtime by ID -* -* Update operation of resource: agingtime* -* -* @param[in] name ID of name -* @param[in] agingtime Aging time of the filtering database -* -* Responses: -* -*/ -void -BridgeApiImpl::update_bridge_agingtime_by_id(const std::string &name, const int32_t &agingtime) { - auto &m = get_cube(name); - return m.update_bridge_agingtime_by_id(agingtime); -} - -/** -* @brief Update bridge by ID -* -* Update operation of resource: bridge* -* -* @param[in] name ID of name -* @param[in] bridge bridgebody object -* -* Responses: -* -*/ -void -BridgeApiImpl::update_bridge_by_id(const std::string &name, const BridgeSchema &bridge) { - auto &m = get_cube(name); - return m.update_bridge_by_id(bridge); -} - -/** -* @brief Update filteringdatabase by ID -* -* Update operation of resource: filteringdatabase* -* -* @param[in] name ID of name -* @param[in] vlan ID of vlan -* @param[in] address ID of address -* @param[in] filteringdatabase filteringdatabasebody object -* -* Responses: -* -*/ -void -BridgeApiImpl::update_bridge_filteringdatabase_by_id(const std::string &name, const std::string &vlan, const std::string &address, const FilteringdatabaseSchema &filteringdatabase) { - auto &m = get_cube(name); - return m.update_bridge_filteringdatabase_by_id(vlan, address, filteringdatabase); -} - -/** -* @brief Update entrytype by ID -* -* Update operation of resource: entrytype* -* -* @param[in] name ID of name -* @param[in] vlan ID of vlan -* @param[in] address ID of address -* @param[in] entrytype Type of filtering entry -* -* Responses: -* -*/ -void -BridgeApiImpl::update_bridge_filteringdatabase_entrytype_by_id(const std::string &name, const std::string &vlan, const std::string &address, const std::string &entrytype) { - auto &m = get_cube(name); - return m.update_bridge_filteringdatabase_entrytype_by_id(vlan, address, entrytype); -} - -/** -* @brief Update filteringdatabase by ID -* -* Update operation of resource: filteringdatabase* -* -* @param[in] name ID of name -* @param[in] filteringdatabase filteringdatabasebody object -* -* Responses: -* -*/ -void -BridgeApiImpl::update_bridge_filteringdatabase_list_by_id(const std::string &name, const std::vector &filteringdatabase) { - auto &m = get_cube(name); - return m.update_bridge_filteringdatabase_list_by_id(filteringdatabase); -} - -/** -* @brief Update port by ID -* -* Update operation of resource: port* -* -* @param[in] name ID of name -* @param[in] vlan ID of vlan -* @param[in] address ID of address -* @param[in] port Output port name -* -* Responses: -* -*/ -void -BridgeApiImpl::update_bridge_filteringdatabase_port_by_id(const std::string &name, const std::string &vlan, const std::string &address, const std::string &port) { - auto &m = get_cube(name); - return m.update_bridge_filteringdatabase_port_by_id(vlan, address, port); -} - -/** -* @brief Update access by ID -* -* Update operation of resource: access* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* @param[in] access accessbody object -* -* Responses: -* -*/ -void -BridgeApiImpl::update_bridge_ports_access_by_id(const std::string &name, const std::string &portsName, const PortsAccessSchema &access) { - auto &m = get_cube(name); - return m.update_bridge_ports_access_by_id(portsName, access); -} - -/** -* @brief Update vlanid by ID -* -* Update operation of resource: vlanid* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* @param[in] vlanid VLAN associated with this interface -* -* Responses: -* -*/ -void -BridgeApiImpl::update_bridge_ports_access_vlanid_by_id(const std::string &name, const std::string &portsName, const int32_t &vlanid) { - auto &m = get_cube(name); - return m.update_bridge_ports_access_vlanid_by_id(portsName, vlanid); -} - -/** -* @brief Update address by ID -* -* Update operation of resource: address* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* @param[in] address MAC address of the port -* -* Responses: -* -*/ -void -BridgeApiImpl::update_bridge_ports_address_by_id(const std::string &name, const std::string &portsName, const std::string &address) { - auto &m = get_cube(name); - return m.update_bridge_ports_address_by_id(portsName, address); -} - -/** -* @brief Update mode by ID -* -* Update operation of resource: mode* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* @param[in] mode Type of bridge interface: access/trunk -* -* Responses: -* -*/ -void -BridgeApiImpl::update_bridge_ports_mode_by_id(const std::string &name, const std::string &portsName, const std::string &mode) { - auto &m = get_cube(name); - return m.update_bridge_ports_mode_by_id(portsName, mode); -} - -/** -* @brief Update stp by ID -* -* Update operation of resource: stp* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* @param[in] vlan ID of vlan -* @param[in] stp stpbody object -* -* Responses: -* -*/ -void -BridgeApiImpl::update_bridge_ports_stp_by_id(const std::string &name, const std::string &portsName, const std::string &vlan, const PortsStpSchema &stp) { - auto &m = get_cube(name); - return m.update_bridge_ports_stp_by_id(portsName, vlan, stp); -} - -/** -* @brief Update stp by ID -* -* Update operation of resource: stp* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* @param[in] stp stpbody object -* -* Responses: -* -*/ -void -BridgeApiImpl::update_bridge_ports_stp_list_by_id(const std::string &name, const std::string &portsName, const std::vector &stp) { - auto &m = get_cube(name); - return m.update_bridge_ports_stp_list_by_id(portsName, stp); -} - -/** -* @brief Update pathcost by ID -* -* Update operation of resource: pathcost* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* @param[in] vlan ID of vlan -* @param[in] pathcost STP cost associated with this interface -* -* Responses: -* -*/ -void -BridgeApiImpl::update_bridge_ports_stp_pathcost_by_id(const std::string &name, const std::string &portsName, const std::string &vlan, const int32_t &pathcost) { - auto &m = get_cube(name); - return m.update_bridge_ports_stp_pathcost_by_id(portsName, vlan, pathcost); -} - -/** -* @brief Update portpriority by ID -* -* Update operation of resource: portpriority* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* @param[in] vlan ID of vlan -* @param[in] portpriority Port priority of this interface -* -* Responses: -* -*/ -void -BridgeApiImpl::update_bridge_ports_stp_portpriority_by_id(const std::string &name, const std::string &portsName, const std::string &vlan, const int32_t &portpriority) { - auto &m = get_cube(name); - return m.update_bridge_ports_stp_portpriority_by_id(portsName, vlan, portpriority); -} - -/** -* @brief Update allowed by ID -* -* Update operation of resource: allowed* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* @param[in] vlanid ID of vlanid -* @param[in] allowed allowedbody object -* -* Responses: -* -*/ -void -BridgeApiImpl::update_bridge_ports_trunk_allowed_by_id(const std::string &name, const std::string &portsName, const std::string &vlanid, const PortsTrunkAllowedSchema &allowed) { - auto &m = get_cube(name); - return m.update_bridge_ports_trunk_allowed_by_id(portsName, vlanid, allowed); -} - -/** -* @brief Update allowed by ID -* -* Update operation of resource: allowed* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* @param[in] allowed allowedbody object -* -* Responses: -* -*/ -void -BridgeApiImpl::update_bridge_ports_trunk_allowed_list_by_id(const std::string &name, const std::string &portsName, const std::vector &allowed) { - auto &m = get_cube(name); - return m.update_bridge_ports_trunk_allowed_list_by_id(portsName, allowed); -} - -/** -* @brief Update trunk by ID -* -* Update operation of resource: trunk* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* @param[in] trunk trunkbody object -* -* Responses: -* -*/ -void -BridgeApiImpl::update_bridge_ports_trunk_by_id(const std::string &name, const std::string &portsName, const PortsTrunkSchema &trunk) { - auto &m = get_cube(name); - return m.update_bridge_ports_trunk_by_id(portsName, trunk); -} - -/** -* @brief Update nativevlan by ID -* -* Update operation of resource: nativevlan* -* -* @param[in] name ID of name -* @param[in] portsName ID of ports_name -* @param[in] nativevlan VLAN that is not tagged in this trunk port -* -* Responses: -* -*/ -void -BridgeApiImpl::update_bridge_ports_trunk_nativevlan_by_id(const std::string &name, const std::string &portsName, const int32_t &nativevlan) { - auto &m = get_cube(name); - return m.update_bridge_ports_trunk_nativevlan_by_id(portsName, nativevlan); -} - -/** -* @brief Update address by ID -* -* Update operation of resource: address* -* -* @param[in] name ID of name -* @param[in] vlan ID of vlan -* @param[in] address Main MAC address used by the STP -* -* Responses: -* -*/ -void -BridgeApiImpl::update_bridge_stp_address_by_id(const std::string &name, const std::string &vlan, const std::string &address) { - auto &m = get_cube(name); - return m.update_bridge_stp_address_by_id(vlan, address); -} - -/** -* @brief Update stp by ID -* -* Update operation of resource: stp* -* -* @param[in] name ID of name -* @param[in] vlan ID of vlan -* @param[in] stp stpbody object -* -* Responses: -* -*/ -void -BridgeApiImpl::update_bridge_stp_by_id(const std::string &name, const std::string &vlan, const StpSchema &stp) { - auto &m = get_cube(name); - return m.update_bridge_stp_by_id(vlan, stp); -} - -/** -* @brief Update forwarddelay by ID -* -* Update operation of resource: forwarddelay* -* -* @param[in] name ID of name -* @param[in] vlan ID of vlan -* @param[in] forwarddelay Delay used by STP bridges for port state transition -* -* Responses: -* -*/ -void -BridgeApiImpl::update_bridge_stp_forwarddelay_by_id(const std::string &name, const std::string &vlan, const int32_t &forwarddelay) { - auto &m = get_cube(name); - return m.update_bridge_stp_forwarddelay_by_id(vlan, forwarddelay); -} - -/** -* @brief Update hellotime by ID -* -* Update operation of resource: hellotime* -* -* @param[in] name ID of name -* @param[in] vlan ID of vlan -* @param[in] hellotime Interval between transmissions of BPDU messages -* -* Responses: -* -*/ -void -BridgeApiImpl::update_bridge_stp_hellotime_by_id(const std::string &name, const std::string &vlan, const int32_t &hellotime) { - auto &m = get_cube(name); - return m.update_bridge_stp_hellotime_by_id(vlan, hellotime); -} - -/** -* @brief Update stp by ID -* -* Update operation of resource: stp* -* -* @param[in] name ID of name -* @param[in] stp stpbody object -* -* Responses: -* -*/ -void -BridgeApiImpl::update_bridge_stp_list_by_id(const std::string &name, const std::vector &stp) { - auto &m = get_cube(name); - return m.update_bridge_stp_list_by_id(stp); -} - -/** -* @brief Update maxmessageage by ID -* -* Update operation of resource: maxmessageage* -* -* @param[in] name ID of name -* @param[in] vlan ID of vlan -* @param[in] maxmessageage Maximum age of a BPDU -* -* Responses: -* -*/ -void -BridgeApiImpl::update_bridge_stp_maxmessageage_by_id(const std::string &name, const std::string &vlan, const int32_t &maxmessageage) { - auto &m = get_cube(name); - return m.update_bridge_stp_maxmessageage_by_id(vlan, maxmessageage); -} - -/** -* @brief Update priority by ID -* -* Update operation of resource: priority* -* -* @param[in] name ID of name -* @param[in] vlan ID of vlan -* @param[in] priority Bridge priority for STP -* -* Responses: -* -*/ -void -BridgeApiImpl::update_bridge_stp_priority_by_id(const std::string &name, const std::string &vlan, const int32_t &priority) { - auto &m = get_cube(name); - return m.update_bridge_stp_priority_by_id(vlan, priority); -} - -/** -* @brief Update stpenabled by ID -* -* Update operation of resource: stpenabled* -* -* @param[in] name ID of name -* @param[in] stpenabled Enable/Disable the STP protocol of the bridge -* -* Responses: -* -*/ -void -BridgeApiImpl::update_bridge_stpenabled_by_id(const std::string &name, const bool &stpenabled) { - auto &m = get_cube(name); - return m.update_bridge_stpenabled_by_id(stpenabled); -} - -/** -* @brief Update type by ID -* -* Update operation of resource: type* -* -* @param[in] name ID of name -* @param[in] type Type of the Cube (TC, XDP_SKB, XDP_DRV) -* -* Responses: -* -*/ -void -BridgeApiImpl::update_bridge_type_by_id(const std::string &name, const std::string &type) { - auto &m = get_cube(name); - return m.update_bridge_type_by_id(type); -} - - -} -} -} -} - diff --git a/src/services/pcn-bridge/src/api/BridgeApiImpl.h b/src/services/pcn-bridge/src/api/BridgeApiImpl.h deleted file mode 100755 index 2b5209629..000000000 --- a/src/services/pcn-bridge/src/api/BridgeApiImpl.h +++ /dev/null @@ -1,160 +0,0 @@ -/** -* bridge API -* bridge API generated from bridge.yang -* -* OpenAPI spec version: 1.0.0 -* -* NOTE: This class is auto generated by the swagger code generator program. -* https://github.com/swagger-api/swagger-codegen.git -*/ - - -/* Do not edit this file manually */ - -/* -* BridgeApiImpl.h -* -* -*/ - -#pragma once - -#include "BridgeApi.h" - - -#include -#include -#include "../Bridge.h" - -#include "BridgeSchema.h" -#include "FilteringdatabaseSchema.h" -#include "PortsAccessSchema.h" -#include "PortsSchema.h" -#include "PortsStpSchema.h" -#include "PortsTrunkAllowedSchema.h" -#include "PortsTrunkSchema.h" -#include "StpSchema.h" -#include - -namespace io { -namespace swagger { -namespace server { -namespace api { - -using namespace io::swagger::server::model; - -class BridgeApiImpl : public io::swagger::server::api::BridgeApi { -public: - BridgeApiImpl(); - ~BridgeApiImpl() { }; - - BridgeSchema create_bridge_by_id(const std::string &name, const BridgeSchema &bridge); - FilteringdatabaseSchema create_bridge_filteringdatabase_by_id(const std::string &name, const std::string &vlan, const std::string &address, const FilteringdatabaseSchema &filteringdatabase); - std::vector create_bridge_filteringdatabase_list_by_id(const std::string &name, const std::vector &filteringdatabase); - PortsAccessSchema create_bridge_ports_access_by_id(const std::string &name, const std::string &portsName, const PortsAccessSchema &access); - PortsSchema create_bridge_ports_by_id(const std::string &name, const std::string &portsName, const PortsSchema &ports); - std::vector create_bridge_ports_list_by_id(const std::string &name, const std::vector &ports); - PortsStpSchema create_bridge_ports_stp_by_id(const std::string &name, const std::string &portsName, const std::string &vlan, const PortsStpSchema &stp); - std::vector create_bridge_ports_stp_list_by_id(const std::string &name, const std::string &portsName, const std::vector &stp); - PortsTrunkAllowedSchema create_bridge_ports_trunk_allowed_by_id(const std::string &name, const std::string &portsName, const std::string &vlanid, const PortsTrunkAllowedSchema &allowed); - std::vector create_bridge_ports_trunk_allowed_list_by_id(const std::string &name, const std::string &portsName, const std::vector &allowed); - PortsTrunkSchema create_bridge_ports_trunk_by_id(const std::string &name, const std::string &portsName, const PortsTrunkSchema &trunk); - StpSchema create_bridge_stp_by_id(const std::string &name, const std::string &vlan, const StpSchema &stp); - std::vector create_bridge_stp_list_by_id(const std::string &name, const std::vector &stp); - void delete_bridge_by_id(const std::string &name); - void delete_bridge_filteringdatabase_by_id(const std::string &name, const std::string &vlan, const std::string &address); - void delete_bridge_filteringdatabase_list_by_id(const std::string &name); - void delete_bridge_ports_access_by_id(const std::string &name, const std::string &portsName); - void delete_bridge_ports_by_id(const std::string &name, const std::string &portsName); - void delete_bridge_ports_list_by_id(const std::string &name); - void delete_bridge_ports_stp_by_id(const std::string &name, const std::string &portsName, const std::string &vlan); - void delete_bridge_ports_stp_list_by_id(const std::string &name, const std::string &portsName); - void delete_bridge_ports_trunk_allowed_by_id(const std::string &name, const std::string &portsName, const std::string &vlanid); - void delete_bridge_ports_trunk_allowed_list_by_id(const std::string &name, const std::string &portsName); - void delete_bridge_ports_trunk_by_id(const std::string &name, const std::string &portsName); - void delete_bridge_stp_by_id(const std::string &name, const std::string &vlan); - void delete_bridge_stp_list_by_id(const std::string &name); - int32_t read_bridge_agingtime_by_id(const std::string &name); - BridgeSchema read_bridge_by_id(const std::string &name); - int32_t read_bridge_filteringdatabase_age_by_id(const std::string &name, const std::string &vlan, const std::string &address); - FilteringdatabaseSchema read_bridge_filteringdatabase_by_id(const std::string &name, const std::string &vlan, const std::string &address); - std::string read_bridge_filteringdatabase_entrytype_by_id(const std::string &name, const std::string &vlan, const std::string &address); - std::vector read_bridge_filteringdatabase_list_by_id(const std::string &name); - std::vector read_bridge_filteringdatabase_list_by_id_get_list(); - std::string read_bridge_filteringdatabase_port_by_id(const std::string &name, const std::string &vlan, const std::string &address); - std::vector read_bridge_list_by_id(); - std::vector read_bridge_list_by_id_get_list(); - PortsAccessSchema read_bridge_ports_access_by_id(const std::string &name, const std::string &portsName); - int32_t read_bridge_ports_access_vlanid_by_id(const std::string &name, const std::string &portsName); - std::string read_bridge_ports_address_by_id(const std::string &name, const std::string &portsName); - PortsSchema read_bridge_ports_by_id(const std::string &name, const std::string &portsName); - std::vector read_bridge_ports_list_by_id(const std::string &name); - std::vector read_bridge_ports_list_by_id_get_list(); - std::string read_bridge_ports_mode_by_id(const std::string &name, const std::string &portsName); - std::string read_bridge_ports_peer_by_id(const std::string &name, const std::string &portsName); - std::string read_bridge_ports_status_by_id(const std::string &name, const std::string &portsName); - PortsStpSchema read_bridge_ports_stp_by_id(const std::string &name, const std::string &portsName, const std::string &vlan); - std::vector read_bridge_ports_stp_list_by_id(const std::string &name, const std::string &portsName); - std::vector read_bridge_ports_stp_list_by_id_get_list(); - int32_t read_bridge_ports_stp_pathcost_by_id(const std::string &name, const std::string &portsName, const std::string &vlan); - int32_t read_bridge_ports_stp_portpriority_by_id(const std::string &name, const std::string &portsName, const std::string &vlan); - std::string read_bridge_ports_stp_state_by_id(const std::string &name, const std::string &portsName, const std::string &vlan); - PortsTrunkAllowedSchema read_bridge_ports_trunk_allowed_by_id(const std::string &name, const std::string &portsName, const std::string &vlanid); - std::vector read_bridge_ports_trunk_allowed_list_by_id(const std::string &name, const std::string &portsName); - std::vector read_bridge_ports_trunk_allowed_list_by_id_get_list(); - PortsTrunkSchema read_bridge_ports_trunk_by_id(const std::string &name, const std::string &portsName); - int32_t read_bridge_ports_trunk_nativevlan_by_id(const std::string &name, const std::string &portsName); - std::string read_bridge_ports_uuid_by_id(const std::string &name, const std::string &portsName); - std::string read_bridge_stp_address_by_id(const std::string &name, const std::string &vlan); - StpSchema read_bridge_stp_by_id(const std::string &name, const std::string &vlan); - int32_t read_bridge_stp_forwarddelay_by_id(const std::string &name, const std::string &vlan); - int32_t read_bridge_stp_hellotime_by_id(const std::string &name, const std::string &vlan); - std::vector read_bridge_stp_list_by_id(const std::string &name); - std::vector read_bridge_stp_list_by_id_get_list(); - int32_t read_bridge_stp_maxmessageage_by_id(const std::string &name, const std::string &vlan); - int32_t read_bridge_stp_priority_by_id(const std::string &name, const std::string &vlan); - std::string read_bridge_type_by_id(const std::string &name); - bool read_bridge_stpenabled_by_id(const std::string &name); - std::string read_bridge_uuid_by_id(const std::string &name); - void update_bridge_agingtime_by_id(const std::string &name, const int32_t &agingtime); - void update_bridge_by_id(const std::string &name, const BridgeSchema &bridge); - void update_bridge_filteringdatabase_by_id(const std::string &name, const std::string &vlan, const std::string &address, const FilteringdatabaseSchema &filteringdatabase); - void update_bridge_filteringdatabase_entrytype_by_id(const std::string &name, const std::string &vlan, const std::string &address, const std::string &entrytype); - void update_bridge_filteringdatabase_list_by_id(const std::string &name, const std::vector &filteringdatabase); - void update_bridge_filteringdatabase_port_by_id(const std::string &name, const std::string &vlan, const std::string &address, const std::string &port); - void update_bridge_ports_access_by_id(const std::string &name, const std::string &portsName, const PortsAccessSchema &access); - void update_bridge_ports_access_vlanid_by_id(const std::string &name, const std::string &portsName, const int32_t &vlanid); - void update_bridge_ports_address_by_id(const std::string &name, const std::string &portsName, const std::string &address); - void update_bridge_ports_by_id(const std::string &name, const std::string &portsName, const PortsSchema &ports); - void update_bridge_ports_list_by_id(const std::string &name, const std::vector &ports); - void update_bridge_ports_mode_by_id(const std::string &name, const std::string &portsName, const std::string &mode); - void update_bridge_ports_peer_by_id(const std::string &name, const std::string &portsName, const std::string &peer); - void update_bridge_ports_status_by_id(const std::string &name, const std::string &portsName, const std::string &status); - void update_bridge_ports_stp_by_id(const std::string &name, const std::string &portsName, const std::string &vlan, const PortsStpSchema &stp); - void update_bridge_ports_stp_list_by_id(const std::string &name, const std::string &portsName, const std::vector &stp); - void update_bridge_ports_stp_pathcost_by_id(const std::string &name, const std::string &portsName, const std::string &vlan, const int32_t &pathcost); - void update_bridge_ports_stp_portpriority_by_id(const std::string &name, const std::string &portsName, const std::string &vlan, const int32_t &portpriority); - void update_bridge_ports_trunk_allowed_by_id(const std::string &name, const std::string &portsName, const std::string &vlanid, const PortsTrunkAllowedSchema &allowed); - void update_bridge_ports_trunk_allowed_list_by_id(const std::string &name, const std::string &portsName, const std::vector &allowed); - void update_bridge_ports_trunk_by_id(const std::string &name, const std::string &portsName, const PortsTrunkSchema &trunk); - void update_bridge_ports_trunk_nativevlan_by_id(const std::string &name, const std::string &portsName, const int32_t &nativevlan); - void update_bridge_stp_address_by_id(const std::string &name, const std::string &vlan, const std::string &address); - void update_bridge_stp_by_id(const std::string &name, const std::string &vlan, const StpSchema &stp); - void update_bridge_stp_forwarddelay_by_id(const std::string &name, const std::string &vlan, const int32_t &forwarddelay); - void update_bridge_stp_hellotime_by_id(const std::string &name, const std::string &vlan, const int32_t &hellotime); - void update_bridge_stp_list_by_id(const std::string &name, const std::vector &stp); - void update_bridge_stp_maxmessageage_by_id(const std::string &name, const std::string &vlan, const int32_t &maxmessageage); - void update_bridge_stp_priority_by_id(const std::string &name, const std::string &vlan, const int32_t &priority); - void update_bridge_stpenabled_by_id(const std::string &name, const bool &stpenabled); - void update_bridge_type_by_id(const std::string &name, const std::string &type); - static CubeType string_to_type(const std::string &type); -private: - std::unordered_map cubes; - Bridge &get_cube(const std::string &name); -}; - -} -} -} -} - diff --git a/src/services/pcn-bridge/src/model/BridgeSchema.cpp b/src/services/pcn-bridge/src/model/BridgeSchema.cpp deleted file mode 100644 index 393f8ef1c..000000000 --- a/src/services/pcn-bridge/src/model/BridgeSchema.cpp +++ /dev/null @@ -1,419 +0,0 @@ -/** -* bridge API -* bridge API generated from bridge.yang -* -* OpenAPI spec version: 1.0.0 -* -* NOTE: This class is auto generated by the swagger code generator program. -* https://github.com/swagger-api/swagger-codegen.git -*/ - -/* Do not edit this file manually */ - -#include "BridgeSchema.h" - -namespace io { -namespace swagger { -namespace server { -namespace model { - -BridgeSchema::BridgeSchema() { - m_FilteringdatabaseIsSet = false; - m_Name = ""; - m_NameIsSet = false; - m_Agingtime = 0; - m_AgingtimeIsSet = false; - m_Stpenabled = false; - m_StpenabledIsSet = false; - m_StpIsSet = false; - m_Type = ""; - m_TypeIsSet = false; - m_PortsIsSet = false; - m_Uuid = ""; - m_UuidIsSet = false; -} - -BridgeSchema::~BridgeSchema() {} - -void BridgeSchema::validate() { - // TODO: implement validation -} - -nlohmann::json BridgeSchema::toJson() const { - nlohmann::json val = nlohmann::json::object(); - - { - nlohmann::json jsonArray; - for (auto &item : m_Filteringdatabase) { - jsonArray.push_back(ModelBase::toJson(item)); - } - - if (jsonArray.size() > 0) { - val["filteringdatabase"] = jsonArray; - } - } - if (m_NameIsSet) { - val["name"] = m_Name; - } - - if (m_AgingtimeIsSet) { - val["agingtime"] = m_Agingtime; - } - - if (m_StpenabledIsSet) { - val["stpenabled"] = m_Stpenabled; - } - - { - nlohmann::json jsonArray; - for (auto &item : m_Stp) { - jsonArray.push_back(ModelBase::toJson(item)); - } - - if (jsonArray.size() > 0) { - val["stp"] = jsonArray; - } - } - - if (m_TypeIsSet) { - val["type"] = m_Type; - } - - { - nlohmann::json jsonArray; - for (auto &item : m_Ports) { - jsonArray.push_back(ModelBase::toJson(item)); - } - - if (jsonArray.size() > 0) { - val["ports"] = jsonArray; - } - } - if (m_UuidIsSet) { - val["uuid"] = m_Uuid; - } - - return val; -} - -void BridgeSchema::fromJson(nlohmann::json &val) { - m_Filteringdatabase.clear(); - for (auto &item : val["filteringdatabase"]) { - FilteringdatabaseSchema newItem; - newItem.fromJson(item); - m_Filteringdatabase.push_back(newItem); - } - - if (val.find("name") != val.end()) { - setName(val.at("name")); - } - - if (val.find("agingtime") != val.end()) { - setAgingtime(val.at("agingtime")); - } - - if (val.find("stpenabled") != val.end()) { - setStpenabled(val.at("stpenabled")); - } - - m_Stp.clear(); - for (auto &item : val["stp"]) { - StpSchema newItem; - newItem.fromJson(item); - m_Stp.push_back(newItem); - } - - if (val.find("type") != val.end()) { - setType(val.at("type")); - } - - m_Ports.clear(); - for (auto &item : val["ports"]) { - PortsSchema newItem; - newItem.fromJson(item); - m_Ports.push_back(newItem); - } - - if (val.find("uuid") != val.end()) { - setUuid(val.at("uuid")); - } -} - -nlohmann::json BridgeSchema::getKeys() { - nlohmann::json val = nlohmann::json::object(); - - val["name"]["name"] = "name"; - val["name"]["type"] = "key"; - val["name"]["simpletype"] = "string"; - val["name"]["description"] = R"POLYCUBE(Name of the bridge service)POLYCUBE"; - val["name"]["example"] = R"POLYCUBE()POLYCUBE"; - - return val; -} - -nlohmann::json BridgeSchema::getElements() { - nlohmann::json val = nlohmann::json::object(); - - val["filteringdatabase"]["name"] = "filteringdatabase"; - val["filteringdatabase"]["type"] = "leaf"; // Suppose that type is leaf - val["filteringdatabase"]["type"] = "list"; - val["filteringdatabase"]["description"] = - R"POLYCUBE(Entry associated with the filtering database)POLYCUBE"; - val["filteringdatabase"]["example"] = R"POLYCUBE()POLYCUBE"; - val["filteringdatabase"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "array", - "description" : "Entry associated with the filtering database", - "items" : { - "$ref" : "#/definitions/FilteringdatabaseSchema" - }, - "x-key" : [ "vlan", "address" ] -})POLYCUBE"); - val["agingtime"]["name"] = "agingtime"; - val["agingtime"]["type"] = "leaf"; // Suppose that type is leaf - val["agingtime"]["simpletype"] = "integer"; - val["agingtime"]["description"] = - R"POLYCUBE(Aging time of the filtering database)POLYCUBE"; - val["agingtime"]["example"] = R"POLYCUBE()POLYCUBE"; - val["agingtime"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "integer", - "format" : "uint32", - "description" : "Aging time of the filtering database" -})POLYCUBE"); - val["stpenabled"]["name"] = "stpenabled"; - val["stpenabled"]["type"] = "leaf"; // Suppose that type is leaf - val["stpenabled"]["simpletype"] = "boolean"; - val["stpenabled"]["description"] = - R"POLYCUBE(Enable/Disable the STP protocol of the bridge)POLYCUBE"; - val["stpenabled"]["example"] = R"POLYCUBE()POLYCUBE"; - val["stpenabled"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "boolean", - "description" : "Enable/Disable the STP protocol of the bridge", - "default" : false -})POLYCUBE"); - val["stp"]["name"] = "stp"; - val["stp"]["type"] = "leaf"; // Suppose that type is leaf - val["stp"]["type"] = "list"; - val["stp"]["description"] = - R"POLYCUBE(Per-vlan Spanning Tree Protocol Configuration)POLYCUBE"; - val["stp"]["example"] = R"POLYCUBE()POLYCUBE"; - val["stp"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "array", - "description" : "Per-vlan Spanning Tree Protocol Configuration", - "items" : { - "$ref" : "#/definitions/StpSchema" - }, - "x-key" : [ "vlan" ] -})POLYCUBE"); - val["type"]["name"] = "type"; - val["type"]["type"] = "leaf"; // Suppose that type is leaf - val["type"]["simpletype"] = "string"; - val["type"]["description"] = - R"POLYCUBE(Type of the Cube (TC, XDP_SKB, XDP_DRV))POLYCUBE"; - val["type"]["example"] = R"POLYCUBE()POLYCUBE"; - val["type"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "string", - "description" : "Type of the Cube (TC, XDP_SKB, XDP_DRV)", - "enum" : [ "TC", "XDP_SKB", "XDP_DRV" ] -})POLYCUBE"); - val["ports"]["name"] = "ports"; - val["ports"]["type"] = "leaf"; // Suppose that type is leaf - val["ports"]["type"] = "list"; - val["ports"]["description"] = R"POLYCUBE(Entry of the ports table)POLYCUBE"; - val["ports"]["example"] = R"POLYCUBE()POLYCUBE"; - val["ports"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "array", - "description" : "Entry of the ports table", - "items" : { - "$ref" : "#/definitions/PortsSchema" - }, - "x-key" : [ "name" ] -})POLYCUBE"); - val["uuid"]["name"] = "uuid"; - val["uuid"]["type"] = "leaf"; // Suppose that type is leaf - val["uuid"]["simpletype"] = "string"; - val["uuid"]["description"] = R"POLYCUBE(UUID of the Cube)POLYCUBE"; - val["uuid"]["example"] = R"POLYCUBE()POLYCUBE"; - val["uuid"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "string", - "description" : "UUID of the Cube", - "readOnly" : true -})POLYCUBE"); - - return val; -} - -nlohmann::json BridgeSchema::getWritableLeafs() { - nlohmann::json val = nlohmann::json::object(); - - val["agingtime"]["name"] = "agingtime"; - val["agingtime"]["simpletype"] = "integer"; - val["agingtime"]["description"] = - R"POLYCUBE(Aging time of the filtering database)POLYCUBE"; - val["agingtime"]["example"] = R"POLYCUBE()POLYCUBE"; - val["agingtime"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "integer", - "format" : "uint32", - "description" : "Aging time of the filtering database" -})POLYCUBE"); - val["stpenabled"]["name"] = "stpenabled"; - val["stpenabled"]["simpletype"] = "boolean"; - val["stpenabled"]["description"] = - R"POLYCUBE(Enable/Disable the STP protocol of the bridge)POLYCUBE"; - val["stpenabled"]["example"] = R"POLYCUBE()POLYCUBE"; - val["stpenabled"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "boolean", - "description" : "Enable/Disable the STP protocol of the bridge", - "default" : false -})POLYCUBE"); - val["type"]["name"] = "type"; - val["type"]["simpletype"] = "string"; - val["type"]["description"] = - R"POLYCUBE(Type of the Cube (TC, XDP_SKB, XDP_DRV))POLYCUBE"; - val["type"]["example"] = R"POLYCUBE()POLYCUBE"; - val["type"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "string", - "description" : "Type of the Cube (TC, XDP_SKB, XDP_DRV)", - "enum" : [ "TC", "XDP_SKB", "XDP_DRV" ] -})POLYCUBE"); - - return val; -} - -nlohmann::json BridgeSchema::getComplexElements() { - nlohmann::json val = nlohmann::json::object(); - - val["filteringdatabase"]["name"] = "filteringdatabase"; - val["filteringdatabase"]["type"] = "list"; - val["filteringdatabase"]["description"] = - R"POLYCUBE(Entry associated with the filtering database)POLYCUBE"; - val["filteringdatabase"]["example"] = R"POLYCUBE()POLYCUBE"; - val["stp"]["name"] = "stp"; - val["stp"]["type"] = "list"; - val["stp"]["description"] = - R"POLYCUBE(Per-vlan Spanning Tree Protocol Configuration)POLYCUBE"; - val["stp"]["example"] = R"POLYCUBE()POLYCUBE"; - val["ports"]["name"] = "ports"; - val["ports"]["type"] = "list"; - val["ports"]["description"] = R"POLYCUBE(Entry of the ports table)POLYCUBE"; - val["ports"]["example"] = R"POLYCUBE()POLYCUBE"; - - return val; -} - -std::vector &BridgeSchema::getFilteringdatabase() { - return m_Filteringdatabase; -} - -bool BridgeSchema::filteringdatabaseIsSet() const { - return m_FilteringdatabaseIsSet; -} - -void BridgeSchema::unsetFilteringdatabase() { - m_FilteringdatabaseIsSet = false; -} -std::string BridgeSchema::getName() const { - return m_Name; -} - -void BridgeSchema::setName(std::string value) { - m_Name = value; - m_NameIsSet = true; -} - -bool BridgeSchema::nameIsSet() const { - return m_NameIsSet; -} - -void BridgeSchema::unsetName() { - m_NameIsSet = false; -} -int32_t BridgeSchema::getAgingtime() const { - return m_Agingtime; -} - -void BridgeSchema::setAgingtime(int32_t value) { - m_Agingtime = value; - m_AgingtimeIsSet = true; -} - -bool BridgeSchema::agingtimeIsSet() const { - return m_AgingtimeIsSet; -} - -void BridgeSchema::unsetAgingtime() { - m_AgingtimeIsSet = false; -} -bool BridgeSchema::getStpenabled() const { - return m_Stpenabled; -} - -void BridgeSchema::setStpenabled(bool value) { - m_Stpenabled = value; - m_StpenabledIsSet = true; -} - -bool BridgeSchema::stpenabledIsSet() const { - return m_StpenabledIsSet; -} - -void BridgeSchema::unsetStpenabled() { - m_StpenabledIsSet = false; -} -std::vector &BridgeSchema::getStp() { - return m_Stp; -} - -bool BridgeSchema::stpIsSet() const { - return m_StpIsSet; -} - -void BridgeSchema::unsetStp() { - m_StpIsSet = false; -} -std::string BridgeSchema::getType() const { - return m_Type; -} - -void BridgeSchema::setType(std::string value) { - m_Type = value; - m_TypeIsSet = true; -} - -bool BridgeSchema::typeIsSet() const { - return m_TypeIsSet; -} - -void BridgeSchema::unsetType() { - m_TypeIsSet = false; -} -std::vector &BridgeSchema::getPorts() { - return m_Ports; -} - -bool BridgeSchema::portsIsSet() const { - return m_PortsIsSet; -} - -void BridgeSchema::unsetPorts() { - m_PortsIsSet = false; -} -std::string BridgeSchema::getUuid() const { - return m_Uuid; -} - -void BridgeSchema::setUuid(std::string value) { - m_Uuid = value; - m_UuidIsSet = true; -} - -bool BridgeSchema::uuidIsSet() const { - return m_UuidIsSet; -} - -void BridgeSchema::unsetUuid() { - m_UuidIsSet = false; -} -} -} -} -} diff --git a/src/services/pcn-bridge/src/model/BridgeSchema.h b/src/services/pcn-bridge/src/model/BridgeSchema.h deleted file mode 100644 index 2b2119807..000000000 --- a/src/services/pcn-bridge/src/model/BridgeSchema.h +++ /dev/null @@ -1,138 +0,0 @@ -/** -* bridge API -* bridge API generated from bridge.yang -* -* OpenAPI spec version: 1.0.0 -* -* NOTE: This class is auto generated by the swagger code generator program. -* https://github.com/swagger-api/swagger-codegen.git -*/ - -/* Do not edit this file manually */ - -/* - * BridgeSchema.h - * - * - */ - -#pragma once - -#include "ModelBase.h" - -#include -#include "FilteringdatabaseSchema.h" -#include "PortsSchema.h" -#include "StpSchema.h" - -namespace io { -namespace swagger { -namespace server { -namespace model { - -/// -/// -/// -class BridgeSchema : public ModelBase { - public: - BridgeSchema(); - virtual ~BridgeSchema(); - - ///////////////////////////////////////////// - /// ModelBase overrides - - void validate() override; - - nlohmann::json toJson() const override; - void fromJson(nlohmann::json &json) override; - - static nlohmann::json getKeys(); - static nlohmann::json getElements(); - static nlohmann::json getWritableLeafs(); - static nlohmann::json getComplexElements(); - ///////////////////////////////////////////// - /// BridgeSchema members - - /// - /// Entry associated with the filtering database - /// - std::vector &getFilteringdatabase(); - bool filteringdatabaseIsSet() const; - void unsetFilteringdatabase(); - - /// - /// Name of the bridge service - /// - std::string getName() const; - void setName(std::string value); - bool nameIsSet() const; - void unsetName(); - - /// - /// Aging time of the filtering database - /// - int32_t getAgingtime() const; - void setAgingtime(int32_t value); - bool agingtimeIsSet() const; - void unsetAgingtime(); - - /// - /// Enable/Disable the STP protocol of the bridge - /// - bool getStpenabled() const; - void setStpenabled(bool value); - bool stpenabledIsSet() const; - void unsetStpenabled(); - - /// - /// Per-vlan Spanning Tree Protocol Configuration - /// - std::vector &getStp(); - bool stpIsSet() const; - void unsetStp(); - - /// - /// Type of the Cube (TC, XDP_SKB, XDP_DRV) - /// - std::string getType() const; - void setType(std::string value); - bool typeIsSet() const; - void unsetType(); - - /// - /// Entry of the ports table - /// - std::vector &getPorts(); - bool portsIsSet() const; - void unsetPorts(); - - /// - /// UUID of the Cube - /// - std::string getUuid() const; - void setUuid(std::string value); - bool uuidIsSet() const; - void unsetUuid(); - - protected: - std::vector m_Filteringdatabase; - bool m_FilteringdatabaseIsSet; - std::string m_Name; - bool m_NameIsSet; - int32_t m_Agingtime; - bool m_AgingtimeIsSet; - bool m_Stpenabled; - bool m_StpenabledIsSet; - std::vector m_Stp; - bool m_StpIsSet; - std::string m_Type; - bool m_TypeIsSet; - std::vector m_Ports; - bool m_PortsIsSet; - std::string m_Uuid; - bool m_UuidIsSet; -}; -} -} -} -} diff --git a/src/services/pcn-bridge/src/model/FilteringdatabaseSchema.cpp b/src/services/pcn-bridge/src/model/FilteringdatabaseSchema.cpp deleted file mode 100644 index 730d4b9b0..000000000 --- a/src/services/pcn-bridge/src/model/FilteringdatabaseSchema.cpp +++ /dev/null @@ -1,260 +0,0 @@ -/** -* bridge API -* bridge API generated from bridge.yang -* -* OpenAPI spec version: 1.0.0 -* -* NOTE: This class is auto generated by the swagger code generator program. -* https://github.com/swagger-api/swagger-codegen.git -*/ - -/* Do not edit this file manually */ - -#include "FilteringdatabaseSchema.h" - -namespace io { -namespace swagger { -namespace server { -namespace model { - -FilteringdatabaseSchema::FilteringdatabaseSchema() { - m_Age = 0; - m_AgeIsSet = false; - m_Vlan = 0; - m_VlanIsSet = false; - m_Port = ""; - m_PortIsSet = false; - m_Address = ""; - m_AddressIsSet = false; - m_Entrytype = ""; - m_EntrytypeIsSet = false; -} - -FilteringdatabaseSchema::~FilteringdatabaseSchema() {} - -void FilteringdatabaseSchema::validate() { - // TODO: implement validation -} - -nlohmann::json FilteringdatabaseSchema::toJson() const { - nlohmann::json val = nlohmann::json::object(); - - if (m_AgeIsSet) { - val["age"] = m_Age; - } - - if (m_VlanIsSet) { - val["vlan"] = m_Vlan; - } - - if (m_PortIsSet) { - val["port"] = m_Port; - } - - if (m_AddressIsSet) { - val["address"] = m_Address; - } - - if (m_EntrytypeIsSet) { - val["entrytype"] = m_Entrytype; - } - - return val; -} - -void FilteringdatabaseSchema::fromJson(nlohmann::json &val) { - if (val.find("age") != val.end()) { - setAge(val.at("age")); - } - - if (val.find("vlan") != val.end()) { - setVlan(val.at("vlan")); - } - - if (val.find("port") != val.end()) { - setPort(val.at("port")); - } - - if (val.find("address") != val.end()) { - setAddress(val.at("address")); - } - - if (val.find("entrytype") != val.end()) { - setEntrytype(val.at("entrytype")); - } -} - -nlohmann::json FilteringdatabaseSchema::getKeys() { - nlohmann::json val = nlohmann::json::object(); - - val["vlan"]["name"] = "vlan"; - val["vlan"]["type"] = "key"; - val["vlan"]["simpletype"] = "integer"; - val["vlan"]["description"] = R"POLYCUBE(VLAN identifier)POLYCUBE"; - val["vlan"]["example"] = R"POLYCUBE()POLYCUBE"; - val["address"]["name"] = "address"; - val["address"]["type"] = "key"; - val["address"]["simpletype"] = "string"; - val["address"]["description"] = - R"POLYCUBE(Address of the filtering database entry)POLYCUBE"; - val["address"]["example"] = R"POLYCUBE()POLYCUBE"; - - return val; -} - -nlohmann::json FilteringdatabaseSchema::getElements() { - nlohmann::json val = nlohmann::json::object(); - - val["age"]["name"] = "age"; - val["age"]["type"] = "leaf"; // Suppose that type is leaf - val["age"]["simpletype"] = "integer"; - val["age"]["description"] = - R"POLYCUBE(Age of the current filtering database entry)POLYCUBE"; - val["age"]["example"] = R"POLYCUBE()POLYCUBE"; - val["age"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "integer", - "format" : "uint32", - "description" : "Age of the current filtering database entry", - "readOnly" : true -})POLYCUBE"); - val["port"]["name"] = "port"; - val["port"]["type"] = "leaf"; // Suppose that type is leaf - val["port"]["simpletype"] = "string"; - val["port"]["description"] = R"POLYCUBE(Output port name)POLYCUBE"; - val["port"]["example"] = R"POLYCUBE()POLYCUBE"; - val["port"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "string", - "description" : "Output port name" -})POLYCUBE"); - val["entrytype"]["name"] = "entrytype"; - val["entrytype"]["type"] = "leaf"; // Suppose that type is leaf - val["entrytype"]["simpletype"] = "string"; - val["entrytype"]["description"] = - R"POLYCUBE(Type of filtering entry)POLYCUBE"; - val["entrytype"]["example"] = R"POLYCUBE()POLYCUBE"; - val["entrytype"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "string", - "description" : "Type of filtering entry", - "enum" : [ "static", "dynamic" ], - "default" : "static" -})POLYCUBE"); - - return val; -} - -nlohmann::json FilteringdatabaseSchema::getWritableLeafs() { - nlohmann::json val = nlohmann::json::object(); - - val["port"]["name"] = "port"; - val["port"]["simpletype"] = "string"; - val["port"]["description"] = R"POLYCUBE(Output port name)POLYCUBE"; - val["port"]["example"] = R"POLYCUBE()POLYCUBE"; - val["port"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "string", - "description" : "Output port name" -})POLYCUBE"); - val["entrytype"]["name"] = "entrytype"; - val["entrytype"]["simpletype"] = "string"; - val["entrytype"]["description"] = - R"POLYCUBE(Type of filtering entry)POLYCUBE"; - val["entrytype"]["example"] = R"POLYCUBE()POLYCUBE"; - val["entrytype"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "string", - "description" : "Type of filtering entry", - "enum" : [ "static", "dynamic" ], - "default" : "static" -})POLYCUBE"); - - return val; -} - -nlohmann::json FilteringdatabaseSchema::getComplexElements() { - nlohmann::json val = nlohmann::json::object(); - - return val; -} - -int32_t FilteringdatabaseSchema::getAge() const { - return m_Age; -} - -void FilteringdatabaseSchema::setAge(int32_t value) { - m_Age = value; - m_AgeIsSet = true; -} - -bool FilteringdatabaseSchema::ageIsSet() const { - return m_AgeIsSet; -} - -void FilteringdatabaseSchema::unsetAge() { - m_AgeIsSet = false; -} -int32_t FilteringdatabaseSchema::getVlan() const { - return m_Vlan; -} - -void FilteringdatabaseSchema::setVlan(int32_t value) { - m_Vlan = value; - m_VlanIsSet = true; -} - -bool FilteringdatabaseSchema::vlanIsSet() const { - return m_VlanIsSet; -} - -void FilteringdatabaseSchema::unsetVlan() { - m_VlanIsSet = false; -} -std::string FilteringdatabaseSchema::getPort() const { - return m_Port; -} - -void FilteringdatabaseSchema::setPort(std::string value) { - m_Port = value; - m_PortIsSet = true; -} - -bool FilteringdatabaseSchema::portIsSet() const { - return m_PortIsSet; -} - -void FilteringdatabaseSchema::unsetPort() { - m_PortIsSet = false; -} -std::string FilteringdatabaseSchema::getAddress() const { - return m_Address; -} - -void FilteringdatabaseSchema::setAddress(std::string value) { - m_Address = value; - m_AddressIsSet = true; -} - -bool FilteringdatabaseSchema::addressIsSet() const { - return m_AddressIsSet; -} - -void FilteringdatabaseSchema::unsetAddress() { - m_AddressIsSet = false; -} -std::string FilteringdatabaseSchema::getEntrytype() const { - return m_Entrytype; -} - -void FilteringdatabaseSchema::setEntrytype(std::string value) { - m_Entrytype = value; - m_EntrytypeIsSet = true; -} - -bool FilteringdatabaseSchema::entrytypeIsSet() const { - return m_EntrytypeIsSet; -} - -void FilteringdatabaseSchema::unsetEntrytype() { - m_EntrytypeIsSet = false; -} -} -} -} -} diff --git a/src/services/pcn-bridge/src/model/FilteringdatabaseSchema.h b/src/services/pcn-bridge/src/model/FilteringdatabaseSchema.h deleted file mode 100644 index 581a11037..000000000 --- a/src/services/pcn-bridge/src/model/FilteringdatabaseSchema.h +++ /dev/null @@ -1,106 +0,0 @@ -/** -* bridge API -* bridge API generated from bridge.yang -* -* OpenAPI spec version: 1.0.0 -* -* NOTE: This class is auto generated by the swagger code generator program. -* https://github.com/swagger-api/swagger-codegen.git -*/ - -/* Do not edit this file manually */ - -/* - * FilteringdatabaseSchema.h - * - * - */ - -#pragma once - -#include "ModelBase.h" - -namespace io { -namespace swagger { -namespace server { -namespace model { - -/// -/// -/// -class FilteringdatabaseSchema : public ModelBase { - public: - FilteringdatabaseSchema(); - virtual ~FilteringdatabaseSchema(); - - ///////////////////////////////////////////// - /// ModelBase overrides - - void validate() override; - - nlohmann::json toJson() const override; - void fromJson(nlohmann::json &json) override; - - static nlohmann::json getKeys(); - static nlohmann::json getElements(); - static nlohmann::json getWritableLeafs(); - static nlohmann::json getComplexElements(); - ///////////////////////////////////////////// - /// FilteringdatabaseSchema members - - /// - /// Age of the current filtering database entry - /// - int32_t getAge() const; - void setAge(int32_t value); - bool ageIsSet() const; - void unsetAge(); - - /// - /// VLAN identifier - /// - int32_t getVlan() const; - void setVlan(int32_t value); - bool vlanIsSet() const; - void unsetVlan(); - - /// - /// Output port name - /// - std::string getPort() const; - void setPort(std::string value); - bool portIsSet() const; - void unsetPort(); - - /// - /// Address of the filtering database entry - /// - std::string getAddress() const; - void setAddress(std::string value); - bool addressIsSet() const; - void unsetAddress(); - - /// - /// Type of filtering entry - /// - std::string getEntrytype() const; - void setEntrytype(std::string value); - bool entrytypeIsSet() const; - void unsetEntrytype(); - - protected: - int32_t m_Age; - bool m_AgeIsSet; - int32_t m_Vlan; - bool m_VlanIsSet; - std::string m_Port; - bool m_PortIsSet; - std::string m_Address; - bool m_AddressIsSet; - std::string m_Entrytype; - bool m_EntrytypeIsSet; -}; -} -} -} -} diff --git a/src/services/pcn-bridge/src/model/ModelBase.cpp b/src/services/pcn-bridge/src/model/ModelBase.cpp deleted file mode 100644 index 013734ab6..000000000 --- a/src/services/pcn-bridge/src/model/ModelBase.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/** -* bridge API -* bridge API generated from bridge.yang -* -* OpenAPI spec version: 1.0.0 -* -* NOTE: This class is auto generated by the swagger code generator program. -* https://github.com/swagger-api/swagger-codegen.git -*/ - -/* Do not edit this file manually */ - -#include "ModelBase.h" - -namespace io { -namespace swagger { -namespace server { -namespace model { - -ModelBase::ModelBase() {} - -ModelBase::~ModelBase() {} - -std::string ModelBase::toJson(const std::string &value) { - return value; -} - -std::string ModelBase::toJson(const std::time_t &value) { - char buf[sizeof "2011-10-08T07:07:09Z"]; - strftime(buf, sizeof buf, "%FT%TZ", gmtime(&value)); - return buf; -} - -int32_t ModelBase::toJson(int32_t value) { - return value; -} - -int64_t ModelBase::toJson(int64_t value) { - return value; -} - -double ModelBase::toJson(double value) { - return value; -} - -bool ModelBase::toJson(bool value) { - return value; -} - -nlohmann::json ModelBase::toJson(const ModelBase &content) { - return content.toJson(); -} -} -} -} -} diff --git a/src/services/pcn-bridge/src/model/ModelBase.h b/src/services/pcn-bridge/src/model/ModelBase.h deleted file mode 100644 index 207ca2e35..000000000 --- a/src/services/pcn-bridge/src/model/ModelBase.h +++ /dev/null @@ -1,51 +0,0 @@ -/** -* bridge API -* bridge API generated from bridge.yang -* -* OpenAPI spec version: 1.0.0 -* -* NOTE: This class is auto generated by the swagger code generator program. -* https://github.com/swagger-api/swagger-codegen.git -*/ - -/* Do not edit this file manually */ - -/* - * ModelBase.h - * - * This is the base class for all model classes - */ - -#pragma once - -#include -#include -#include "polycube/services/json.hpp" - -namespace io { -namespace swagger { -namespace server { -namespace model { - -class ModelBase { - public: - ModelBase(); - virtual ~ModelBase(); - - virtual void validate() = 0; - - virtual nlohmann::json toJson() const = 0; - virtual void fromJson(nlohmann::json &json) = 0; - - static std::string toJson(const std::string &value); - static std::string toJson(const std::time_t &value); - static int32_t toJson(int32_t value); - static int64_t toJson(int64_t value); - static double toJson(double value); - static bool toJson(bool value); - static nlohmann::json toJson(const ModelBase &content); -}; -} -} -} -} diff --git a/src/services/pcn-bridge/src/model/PortsAccessSchema.cpp b/src/services/pcn-bridge/src/model/PortsAccessSchema.cpp deleted file mode 100644 index dcdf0b03c..000000000 --- a/src/services/pcn-bridge/src/model/PortsAccessSchema.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/** -* bridge API -* bridge API generated from bridge.yang -* -* OpenAPI spec version: 1.0.0 -* -* NOTE: This class is auto generated by the swagger code generator program. -* https://github.com/swagger-api/swagger-codegen.git -*/ - -/* Do not edit this file manually */ - -#include "PortsAccessSchema.h" - -namespace io { -namespace swagger { -namespace server { -namespace model { - -PortsAccessSchema::PortsAccessSchema() { - m_Vlanid = 0; - m_VlanidIsSet = false; -} - -PortsAccessSchema::~PortsAccessSchema() {} - -void PortsAccessSchema::validate() { - // TODO: implement validation -} - -nlohmann::json PortsAccessSchema::toJson() const { - nlohmann::json val = nlohmann::json::object(); - - if (m_VlanidIsSet) { - val["vlanid"] = m_Vlanid; - } - - return val; -} - -void PortsAccessSchema::fromJson(nlohmann::json &val) { - if (val.find("vlanid") != val.end()) { - setVlanid(val.at("vlanid")); - } -} - -nlohmann::json PortsAccessSchema::getKeys() { - nlohmann::json val = nlohmann::json::object(); - - return val; -} - -nlohmann::json PortsAccessSchema::getElements() { - nlohmann::json val = nlohmann::json::object(); - - val["vlanid"]["name"] = "vlanid"; - val["vlanid"]["type"] = "leaf"; // Suppose that type is leaf - val["vlanid"]["simpletype"] = "integer"; - val["vlanid"]["description"] = - R"POLYCUBE(VLAN associated with this interface)POLYCUBE"; - val["vlanid"]["example"] = R"POLYCUBE()POLYCUBE"; - val["vlanid"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "integer", - "format" : "uint32", - "description" : "VLAN associated with this interface" -})POLYCUBE"); - - return val; -} - -nlohmann::json PortsAccessSchema::getWritableLeafs() { - nlohmann::json val = nlohmann::json::object(); - - val["vlanid"]["name"] = "vlanid"; - val["vlanid"]["simpletype"] = "integer"; - val["vlanid"]["description"] = - R"POLYCUBE(VLAN associated with this interface)POLYCUBE"; - val["vlanid"]["example"] = R"POLYCUBE()POLYCUBE"; - val["vlanid"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "integer", - "format" : "uint32", - "description" : "VLAN associated with this interface" -})POLYCUBE"); - - return val; -} - -nlohmann::json PortsAccessSchema::getComplexElements() { - nlohmann::json val = nlohmann::json::object(); - - return val; -} - -int32_t PortsAccessSchema::getVlanid() const { - return m_Vlanid; -} - -void PortsAccessSchema::setVlanid(int32_t value) { - m_Vlanid = value; - m_VlanidIsSet = true; -} - -bool PortsAccessSchema::vlanidIsSet() const { - return m_VlanidIsSet; -} - -void PortsAccessSchema::unsetVlanid() { - m_VlanidIsSet = false; -} -} -} -} -} diff --git a/src/services/pcn-bridge/src/model/PortsAccessSchema.h b/src/services/pcn-bridge/src/model/PortsAccessSchema.h deleted file mode 100644 index 4eaec9839..000000000 --- a/src/services/pcn-bridge/src/model/PortsAccessSchema.h +++ /dev/null @@ -1,66 +0,0 @@ -/** -* bridge API -* bridge API generated from bridge.yang -* -* OpenAPI spec version: 1.0.0 -* -* NOTE: This class is auto generated by the swagger code generator program. -* https://github.com/swagger-api/swagger-codegen.git -*/ - -/* Do not edit this file manually */ - -/* - * PortsAccessSchema.h - * - * vlan associated to a port in access mode - */ - -#pragma once - -#include "ModelBase.h" - -namespace io { -namespace swagger { -namespace server { -namespace model { - -/// -/// vlan associated to a port in access mode -/// -class PortsAccessSchema : public ModelBase { - public: - PortsAccessSchema(); - virtual ~PortsAccessSchema(); - - ///////////////////////////////////////////// - /// ModelBase overrides - - void validate() override; - - nlohmann::json toJson() const override; - void fromJson(nlohmann::json &json) override; - - static nlohmann::json getKeys(); - static nlohmann::json getElements(); - static nlohmann::json getWritableLeafs(); - static nlohmann::json getComplexElements(); - ///////////////////////////////////////////// - /// PortsAccessSchema members - - /// - /// VLAN associated with this interface - /// - int32_t getVlanid() const; - void setVlanid(int32_t value); - bool vlanidIsSet() const; - void unsetVlanid(); - - protected: - int32_t m_Vlanid; - bool m_VlanidIsSet; -}; -} -} -} -} diff --git a/src/services/pcn-bridge/src/model/PortsSchema.cpp b/src/services/pcn-bridge/src/model/PortsSchema.cpp deleted file mode 100644 index 69f91cc74..000000000 --- a/src/services/pcn-bridge/src/model/PortsSchema.cpp +++ /dev/null @@ -1,446 +0,0 @@ -/** -* bridge API -* bridge API generated from bridge.yang -* -* OpenAPI spec version: 1.0.0 -* -* NOTE: This class is auto generated by the swagger code generator program. -* https://github.com/swagger-api/swagger-codegen.git -*/ - -/* Do not edit this file manually */ - -#include "PortsSchema.h" - -namespace io { -namespace swagger { -namespace server { -namespace model { - -PortsSchema::PortsSchema() { - m_Status = ""; - m_StatusIsSet = false; - m_Name = ""; - m_NameIsSet = false; - m_Address = ""; - m_AddressIsSet = false; - m_AccessIsSet = false; - m_StpIsSet = false; - m_Mode = ""; - m_ModeIsSet = false; - m_TrunkIsSet = false; - m_Peer = ""; - m_PeerIsSet = false; - m_Uuid = ""; - m_UuidIsSet = false; -} - -PortsSchema::~PortsSchema() {} - -void PortsSchema::validate() { - // TODO: implement validation -} - -nlohmann::json PortsSchema::toJson() const { - nlohmann::json val = nlohmann::json::object(); - - if (m_StatusIsSet) { - val["status"] = m_Status; - } - - if (m_NameIsSet) { - val["name"] = m_Name; - } - - if (m_AddressIsSet) { - val["address"] = m_Address; - } - - if (m_AccessIsSet) { - val["access"] = ModelBase::toJson(m_Access); - } - - { - nlohmann::json jsonArray; - for (auto &item : m_Stp) { - jsonArray.push_back(ModelBase::toJson(item)); - } - - if (jsonArray.size() > 0) { - val["stp"] = jsonArray; - } - } - if (m_ModeIsSet) { - val["mode"] = m_Mode; - } - - if (m_TrunkIsSet) { - val["trunk"] = ModelBase::toJson(m_Trunk); - } - if (m_PeerIsSet) { - val["peer"] = m_Peer; - } - - if (m_UuidIsSet) { - val["uuid"] = m_Uuid; - } - - return val; -} - -void PortsSchema::fromJson(nlohmann::json &val) { - if (val.find("status") != val.end()) { - setStatus(val.at("status")); - } - - if (val.find("name") != val.end()) { - setName(val.at("name")); - } - - if (val.find("address") != val.end()) { - setAddress(val.at("address")); - } - - if (val.find("access") != val.end()) { - if (!val["access"].is_null()) { - PortsAccessSchema newItem; - newItem.fromJson(val["access"]); - setAccess(newItem); - } - } - - m_Stp.clear(); - for (auto &item : val["stp"]) { - PortsStpSchema newItem; - newItem.fromJson(item); - m_Stp.push_back(newItem); - } - - if (val.find("mode") != val.end()) { - setMode(val.at("mode")); - } - - if (val.find("trunk") != val.end()) { - if (!val["trunk"].is_null()) { - PortsTrunkSchema newItem; - newItem.fromJson(val["trunk"]); - setTrunk(newItem); - } - } - - if (val.find("peer") != val.end()) { - setPeer(val.at("peer")); - } - - if (val.find("uuid") != val.end()) { - setUuid(val.at("uuid")); - } -} - -nlohmann::json PortsSchema::getKeys() { - nlohmann::json val = nlohmann::json::object(); - - val["name"]["name"] = "name"; - val["name"]["type"] = "key"; - val["name"]["simpletype"] = "string"; - val["name"]["description"] = R"POLYCUBE(Port Name)POLYCUBE"; - val["name"]["example"] = R"POLYCUBE()POLYCUBE"; - - return val; -} - -nlohmann::json PortsSchema::getElements() { - nlohmann::json val = nlohmann::json::object(); - - val["status"]["name"] = "status"; - val["status"]["type"] = "leaf"; // Suppose that type is leaf - val["status"]["simpletype"] = "string"; - val["status"]["description"] = - R"POLYCUBE(Status of the port (UP or DOWN))POLYCUBE"; - val["status"]["example"] = R"POLYCUBE()POLYCUBE"; - val["status"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "string", - "description" : "Status of the port (UP or DOWN)", - "enum" : [ "UP", "DOWN" ] -})POLYCUBE"); - val["address"]["name"] = "address"; - val["address"]["type"] = "leaf"; // Suppose that type is leaf - val["address"]["simpletype"] = "string"; - val["address"]["description"] = R"POLYCUBE(MAC address of the port)POLYCUBE"; - val["address"]["example"] = R"POLYCUBE()POLYCUBE"; - val["address"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "string", - "description" : "MAC address of the port" -})POLYCUBE"); - val["access"]["name"] = "access"; - val["access"]["type"] = "leaf"; // Suppose that type is leaf - val["access"]["description"] = R"POLYCUBE()POLYCUBE"; - val["access"]["example"] = R"POLYCUBE()POLYCUBE"; - val["access"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "$ref" : "#/definitions/PortsAccessSchema" -})POLYCUBE"); - val["stp"]["name"] = "stp"; - val["stp"]["type"] = "leaf"; // Suppose that type is leaf - val["stp"]["type"] = "list"; - val["stp"]["description"] = - R"POLYCUBE(Per-vlan Spanning Tree Protocol Port Configuration)POLYCUBE"; - val["stp"]["example"] = R"POLYCUBE()POLYCUBE"; - val["stp"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "array", - "description" : "Per-vlan Spanning Tree Protocol Port Configuration", - "items" : { - "$ref" : "#/definitions/PortsStpSchema" - }, - "x-key" : [ "vlan" ] -})POLYCUBE"); - val["mode"]["name"] = "mode"; - val["mode"]["type"] = "leaf"; // Suppose that type is leaf - val["mode"]["simpletype"] = "string"; - val["mode"]["description"] = - R"POLYCUBE(Type of bridge interface: access/trunk)POLYCUBE"; - val["mode"]["example"] = R"POLYCUBE()POLYCUBE"; - val["mode"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "string", - "description" : "Type of bridge interface: access/trunk", - "enum" : [ "access", "trunk" ], - "default" : "access" -})POLYCUBE"); - val["trunk"]["name"] = "trunk"; - val["trunk"]["type"] = "leaf"; // Suppose that type is leaf - val["trunk"]["description"] = R"POLYCUBE()POLYCUBE"; - val["trunk"]["example"] = R"POLYCUBE()POLYCUBE"; - val["trunk"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "$ref" : "#/definitions/PortsTrunkSchema" -})POLYCUBE"); - val["peer"]["name"] = "peer"; - val["peer"]["type"] = "leaf"; // Suppose that type is leaf - val["peer"]["simpletype"] = "string"; - val["peer"]["description"] = - R"POLYCUBE(Peer name, such as a network interfaces (e.g., 'veth0') or another cube (e.g., 'br1:port2'))POLYCUBE"; - val["peer"]["example"] = R"POLYCUBE()POLYCUBE"; - val["peer"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "string", - "description" : "Peer name, such as a network interfaces (e.g., 'veth0') or another cube (e.g., 'br1:port2')" -})POLYCUBE"); - val["uuid"]["name"] = "uuid"; - val["uuid"]["type"] = "leaf"; // Suppose that type is leaf - val["uuid"]["simpletype"] = "string"; - val["uuid"]["description"] = R"POLYCUBE(UUID of the port)POLYCUBE"; - val["uuid"]["example"] = R"POLYCUBE()POLYCUBE"; - val["uuid"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "string", - "description" : "UUID of the port", - "readOnly" : true -})POLYCUBE"); - - return val; -} - -nlohmann::json PortsSchema::getWritableLeafs() { - nlohmann::json val = nlohmann::json::object(); - - val["status"]["name"] = "status"; - val["status"]["simpletype"] = "string"; - val["status"]["description"] = - R"POLYCUBE(Status of the port (UP or DOWN))POLYCUBE"; - val["status"]["example"] = R"POLYCUBE()POLYCUBE"; - val["status"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "string", - "description" : "Status of the port (UP or DOWN)", - "enum" : [ "UP", "DOWN" ] -})POLYCUBE"); - val["address"]["name"] = "address"; - val["address"]["simpletype"] = "string"; - val["address"]["description"] = R"POLYCUBE(MAC address of the port)POLYCUBE"; - val["address"]["example"] = R"POLYCUBE()POLYCUBE"; - val["address"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "string", - "description" : "MAC address of the port" -})POLYCUBE"); - val["mode"]["name"] = "mode"; - val["mode"]["simpletype"] = "string"; - val["mode"]["description"] = - R"POLYCUBE(Type of bridge interface: access/trunk)POLYCUBE"; - val["mode"]["example"] = R"POLYCUBE()POLYCUBE"; - val["mode"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "string", - "description" : "Type of bridge interface: access/trunk", - "enum" : [ "access", "trunk" ], - "default" : "access" -})POLYCUBE"); - val["peer"]["name"] = "peer"; - val["peer"]["simpletype"] = "string"; - val["peer"]["description"] = - R"POLYCUBE(Peer name, such as a network interfaces (e.g., 'veth0') or another cube (e.g., 'br1:port2'))POLYCUBE"; - val["peer"]["example"] = R"POLYCUBE()POLYCUBE"; - val["peer"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "string", - "description" : "Peer name, such as a network interfaces (e.g., 'veth0') or another cube (e.g., 'br1:port2')" -})POLYCUBE"); - - return val; -} - -nlohmann::json PortsSchema::getComplexElements() { - nlohmann::json val = nlohmann::json::object(); - - val["access"]["name"] = "access"; - val["access"]["type"] = "complex"; - val["access"]["description"] = R"POLYCUBE()POLYCUBE"; - val["access"]["example"] = R"POLYCUBE()POLYCUBE"; - val["stp"]["name"] = "stp"; - val["stp"]["type"] = "list"; - val["stp"]["description"] = - R"POLYCUBE(Per-vlan Spanning Tree Protocol Port Configuration)POLYCUBE"; - val["stp"]["example"] = R"POLYCUBE()POLYCUBE"; - val["trunk"]["name"] = "trunk"; - val["trunk"]["type"] = "complex"; - val["trunk"]["description"] = R"POLYCUBE()POLYCUBE"; - val["trunk"]["example"] = R"POLYCUBE()POLYCUBE"; - - return val; -} - -std::string PortsSchema::getStatus() const { - return m_Status; -} - -void PortsSchema::setStatus(std::string value) { - m_Status = value; - m_StatusIsSet = true; -} - -bool PortsSchema::statusIsSet() const { - return m_StatusIsSet; -} - -void PortsSchema::unsetStatus() { - m_StatusIsSet = false; -} -std::string PortsSchema::getName() const { - return m_Name; -} - -void PortsSchema::setName(std::string value) { - m_Name = value; - m_NameIsSet = true; -} - -bool PortsSchema::nameIsSet() const { - return m_NameIsSet; -} - -void PortsSchema::unsetName() { - m_NameIsSet = false; -} -std::string PortsSchema::getAddress() const { - return m_Address; -} - -void PortsSchema::setAddress(std::string value) { - m_Address = value; - m_AddressIsSet = true; -} - -bool PortsSchema::addressIsSet() const { - return m_AddressIsSet; -} - -void PortsSchema::unsetAddress() { - m_AddressIsSet = false; -} -PortsAccessSchema PortsSchema::getAccess() const { - return m_Access; -} - -void PortsSchema::setAccess(PortsAccessSchema value) { - m_Access = value; - m_AccessIsSet = true; -} - -bool PortsSchema::accessIsSet() const { - return m_AccessIsSet; -} - -void PortsSchema::unsetAccess() { - m_AccessIsSet = false; -} -std::vector &PortsSchema::getStp() { - return m_Stp; -} - -bool PortsSchema::stpIsSet() const { - return m_StpIsSet; -} - -void PortsSchema::unsetStp() { - m_StpIsSet = false; -} -std::string PortsSchema::getMode() const { - return m_Mode; -} - -void PortsSchema::setMode(std::string value) { - m_Mode = value; - m_ModeIsSet = true; -} - -bool PortsSchema::modeIsSet() const { - return m_ModeIsSet; -} - -void PortsSchema::unsetMode() { - m_ModeIsSet = false; -} -PortsTrunkSchema PortsSchema::getTrunk() const { - return m_Trunk; -} - -void PortsSchema::setTrunk(PortsTrunkSchema value) { - m_Trunk = value; - m_TrunkIsSet = true; -} - -bool PortsSchema::trunkIsSet() const { - return m_TrunkIsSet; -} - -void PortsSchema::unsetTrunk() { - m_TrunkIsSet = false; -} -std::string PortsSchema::getPeer() const { - return m_Peer; -} - -void PortsSchema::setPeer(std::string value) { - m_Peer = value; - m_PeerIsSet = true; -} - -bool PortsSchema::peerIsSet() const { - return m_PeerIsSet; -} - -void PortsSchema::unsetPeer() { - m_PeerIsSet = false; -} -std::string PortsSchema::getUuid() const { - return m_Uuid; -} - -void PortsSchema::setUuid(std::string value) { - m_Uuid = value; - m_UuidIsSet = true; -} - -bool PortsSchema::uuidIsSet() const { - return m_UuidIsSet; -} - -void PortsSchema::unsetUuid() { - m_UuidIsSet = false; -} -} -} -} -} diff --git a/src/services/pcn-bridge/src/model/PortsSchema.h b/src/services/pcn-bridge/src/model/PortsSchema.h deleted file mode 100644 index c63b6e982..000000000 --- a/src/services/pcn-bridge/src/model/PortsSchema.h +++ /dev/null @@ -1,151 +0,0 @@ -/** -* bridge API -* bridge API generated from bridge.yang -* -* OpenAPI spec version: 1.0.0 -* -* NOTE: This class is auto generated by the swagger code generator program. -* https://github.com/swagger-api/swagger-codegen.git -*/ - -/* Do not edit this file manually */ - -/* - * PortsSchema.h - * - * - */ - -#pragma once - -#include "ModelBase.h" - -#include -#include "PortsAccessSchema.h" -#include "PortsStpSchema.h" -#include "PortsTrunkSchema.h" - -namespace io { -namespace swagger { -namespace server { -namespace model { - -/// -/// -/// -class PortsSchema : public ModelBase { - public: - PortsSchema(); - virtual ~PortsSchema(); - - ///////////////////////////////////////////// - /// ModelBase overrides - - void validate() override; - - nlohmann::json toJson() const override; - void fromJson(nlohmann::json &json) override; - - static nlohmann::json getKeys(); - static nlohmann::json getElements(); - static nlohmann::json getWritableLeafs(); - static nlohmann::json getComplexElements(); - ///////////////////////////////////////////// - /// PortsSchema members - - /// - /// Status of the port (UP or DOWN) - /// - std::string getStatus() const; - void setStatus(std::string value); - bool statusIsSet() const; - void unsetStatus(); - - /// - /// Port Name - /// - std::string getName() const; - void setName(std::string value); - bool nameIsSet() const; - void unsetName(); - - /// - /// MAC address of the port - /// - std::string getAddress() const; - void setAddress(std::string value); - bool addressIsSet() const; - void unsetAddress(); - - /// - /// - /// - PortsAccessSchema getAccess() const; - void setAccess(PortsAccessSchema value); - bool accessIsSet() const; - void unsetAccess(); - - /// - /// Per-vlan Spanning Tree Protocol Port Configuration - /// - std::vector &getStp(); - bool stpIsSet() const; - void unsetStp(); - - /// - /// Type of bridge interface: access/trunk - /// - std::string getMode() const; - void setMode(std::string value); - bool modeIsSet() const; - void unsetMode(); - - /// - /// - /// - PortsTrunkSchema getTrunk() const; - void setTrunk(PortsTrunkSchema value); - bool trunkIsSet() const; - void unsetTrunk(); - - /// - /// Peer name, such as a network interfaces (e.g., 'veth0') or another - /// cube (e.g., 'br1:port2') - /// - std::string getPeer() const; - void setPeer(std::string value); - bool peerIsSet() const; - void unsetPeer(); - - /// - /// UUID of the port - /// - std::string getUuid() const; - void setUuid(std::string value); - bool uuidIsSet() const; - void unsetUuid(); - - protected: - std::string m_Status; - bool m_StatusIsSet; - std::string m_Name; - bool m_NameIsSet; - std::string m_Address; - bool m_AddressIsSet; - PortsAccessSchema m_Access; - bool m_AccessIsSet; - std::vector m_Stp; - bool m_StpIsSet; - std::string m_Mode; - bool m_ModeIsSet; - PortsTrunkSchema m_Trunk; - bool m_TrunkIsSet; - std::string m_Peer; - bool m_PeerIsSet; - std::string m_Uuid; - bool m_UuidIsSet; -}; -} -} -} -} diff --git a/src/services/pcn-bridge/src/model/PortsStpSchema.cpp b/src/services/pcn-bridge/src/model/PortsStpSchema.cpp deleted file mode 100644 index 145130636..000000000 --- a/src/services/pcn-bridge/src/model/PortsStpSchema.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/** -* bridge API -* bridge API generated from bridge.yang -* -* OpenAPI spec version: 1.0.0 -* -* NOTE: This class is auto generated by the swagger code generator program. -* https://github.com/swagger-api/swagger-codegen.git -*/ - -/* Do not edit this file manually */ - -#include "PortsStpSchema.h" - -namespace io { -namespace swagger { -namespace server { -namespace model { - -PortsStpSchema::PortsStpSchema() { - m_State = ""; - m_StateIsSet = false; - m_Vlan = 0; - m_VlanIsSet = false; - m_Pathcost = 0; - m_PathcostIsSet = false; - m_Portpriority = 0; - m_PortpriorityIsSet = false; -} - -PortsStpSchema::~PortsStpSchema() {} - -void PortsStpSchema::validate() { - // TODO: implement validation -} - -nlohmann::json PortsStpSchema::toJson() const { - nlohmann::json val = nlohmann::json::object(); - - if (m_StateIsSet) { - val["state"] = m_State; - } - - if (m_VlanIsSet) { - val["vlan"] = m_Vlan; - } - - if (m_PathcostIsSet) { - val["pathcost"] = m_Pathcost; - } - - if (m_PortpriorityIsSet) { - val["portpriority"] = m_Portpriority; - } - - return val; -} - -void PortsStpSchema::fromJson(nlohmann::json &val) { - if (val.find("state") != val.end()) { - setState(val.at("state")); - } - - if (val.find("vlan") != val.end()) { - setVlan(val.at("vlan")); - } - - if (val.find("pathcost") != val.end()) { - setPathcost(val.at("pathcost")); - } - - if (val.find("portpriority") != val.end()) { - setPortpriority(val.at("portpriority")); - } -} - -nlohmann::json PortsStpSchema::getKeys() { - nlohmann::json val = nlohmann::json::object(); - - val["vlan"]["name"] = "vlan"; - val["vlan"]["type"] = "key"; - val["vlan"]["simpletype"] = "integer"; - val["vlan"]["description"] = - R"POLYCUBE(VLAN identifier for this entry)POLYCUBE"; - val["vlan"]["example"] = R"POLYCUBE()POLYCUBE"; - - return val; -} - -nlohmann::json PortsStpSchema::getElements() { - nlohmann::json val = nlohmann::json::object(); - - val["state"]["name"] = "state"; - val["state"]["type"] = "leaf"; // Suppose that type is leaf - val["state"]["simpletype"] = "string"; - val["state"]["description"] = R"POLYCUBE(STP port state)POLYCUBE"; - val["state"]["example"] = R"POLYCUBE()POLYCUBE"; - val["state"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "string", - "description" : "STP port state", - "readOnly" : true, - "enum" : [ "disabled", "blocking", "listening", "learning", "forwarding" ] -})POLYCUBE"); - val["pathcost"]["name"] = "pathcost"; - val["pathcost"]["type"] = "leaf"; // Suppose that type is leaf - val["pathcost"]["simpletype"] = "integer"; - val["pathcost"]["description"] = - R"POLYCUBE(STP cost associated with this interface)POLYCUBE"; - val["pathcost"]["example"] = R"POLYCUBE()POLYCUBE"; - val["pathcost"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "integer", - "format" : "uint32", - "description" : "STP cost associated with this interface" -})POLYCUBE"); - val["portpriority"]["name"] = "portpriority"; - val["portpriority"]["type"] = "leaf"; // Suppose that type is leaf - val["portpriority"]["simpletype"] = "integer"; - val["portpriority"]["description"] = - R"POLYCUBE(Port priority of this interface)POLYCUBE"; - val["portpriority"]["example"] = R"POLYCUBE()POLYCUBE"; - val["portpriority"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "integer", - "format" : "uint32", - "description" : "Port priority of this interface" -})POLYCUBE"); - - return val; -} - -nlohmann::json PortsStpSchema::getWritableLeafs() { - nlohmann::json val = nlohmann::json::object(); - - val["pathcost"]["name"] = "pathcost"; - val["pathcost"]["simpletype"] = "integer"; - val["pathcost"]["description"] = - R"POLYCUBE(STP cost associated with this interface)POLYCUBE"; - val["pathcost"]["example"] = R"POLYCUBE()POLYCUBE"; - val["pathcost"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "integer", - "format" : "uint32", - "description" : "STP cost associated with this interface" -})POLYCUBE"); - val["portpriority"]["name"] = "portpriority"; - val["portpriority"]["simpletype"] = "integer"; - val["portpriority"]["description"] = - R"POLYCUBE(Port priority of this interface)POLYCUBE"; - val["portpriority"]["example"] = R"POLYCUBE()POLYCUBE"; - val["portpriority"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "integer", - "format" : "uint32", - "description" : "Port priority of this interface" -})POLYCUBE"); - - return val; -} - -nlohmann::json PortsStpSchema::getComplexElements() { - nlohmann::json val = nlohmann::json::object(); - - return val; -} - -std::string PortsStpSchema::getState() const { - return m_State; -} - -void PortsStpSchema::setState(std::string value) { - m_State = value; - m_StateIsSet = true; -} - -bool PortsStpSchema::stateIsSet() const { - return m_StateIsSet; -} - -void PortsStpSchema::unsetState() { - m_StateIsSet = false; -} -int32_t PortsStpSchema::getVlan() const { - return m_Vlan; -} - -void PortsStpSchema::setVlan(int32_t value) { - m_Vlan = value; - m_VlanIsSet = true; -} - -bool PortsStpSchema::vlanIsSet() const { - return m_VlanIsSet; -} - -void PortsStpSchema::unsetVlan() { - m_VlanIsSet = false; -} -int32_t PortsStpSchema::getPathcost() const { - return m_Pathcost; -} - -void PortsStpSchema::setPathcost(int32_t value) { - m_Pathcost = value; - m_PathcostIsSet = true; -} - -bool PortsStpSchema::pathcostIsSet() const { - return m_PathcostIsSet; -} - -void PortsStpSchema::unsetPathcost() { - m_PathcostIsSet = false; -} -int32_t PortsStpSchema::getPortpriority() const { - return m_Portpriority; -} - -void PortsStpSchema::setPortpriority(int32_t value) { - m_Portpriority = value; - m_PortpriorityIsSet = true; -} - -bool PortsStpSchema::portpriorityIsSet() const { - return m_PortpriorityIsSet; -} - -void PortsStpSchema::unsetPortpriority() { - m_PortpriorityIsSet = false; -} -} -} -} -} diff --git a/src/services/pcn-bridge/src/model/PortsStpSchema.h b/src/services/pcn-bridge/src/model/PortsStpSchema.h deleted file mode 100644 index a7a1351ee..000000000 --- a/src/services/pcn-bridge/src/model/PortsStpSchema.h +++ /dev/null @@ -1,96 +0,0 @@ -/** -* bridge API -* bridge API generated from bridge.yang -* -* OpenAPI spec version: 1.0.0 -* -* NOTE: This class is auto generated by the swagger code generator program. -* https://github.com/swagger-api/swagger-codegen.git -*/ - -/* Do not edit this file manually */ - -/* - * PortsStpSchema.h - * - * - */ - -#pragma once - -#include "ModelBase.h" - -namespace io { -namespace swagger { -namespace server { -namespace model { - -/// -/// -/// -class PortsStpSchema : public ModelBase { - public: - PortsStpSchema(); - virtual ~PortsStpSchema(); - - ///////////////////////////////////////////// - /// ModelBase overrides - - void validate() override; - - nlohmann::json toJson() const override; - void fromJson(nlohmann::json &json) override; - - static nlohmann::json getKeys(); - static nlohmann::json getElements(); - static nlohmann::json getWritableLeafs(); - static nlohmann::json getComplexElements(); - ///////////////////////////////////////////// - /// PortsStpSchema members - - /// - /// STP port state - /// - std::string getState() const; - void setState(std::string value); - bool stateIsSet() const; - void unsetState(); - - /// - /// VLAN identifier for this entry - /// - int32_t getVlan() const; - void setVlan(int32_t value); - bool vlanIsSet() const; - void unsetVlan(); - - /// - /// STP cost associated with this interface - /// - int32_t getPathcost() const; - void setPathcost(int32_t value); - bool pathcostIsSet() const; - void unsetPathcost(); - - /// - /// Port priority of this interface - /// - int32_t getPortpriority() const; - void setPortpriority(int32_t value); - bool portpriorityIsSet() const; - void unsetPortpriority(); - - protected: - std::string m_State; - bool m_StateIsSet; - int32_t m_Vlan; - bool m_VlanIsSet; - int32_t m_Pathcost; - bool m_PathcostIsSet; - int32_t m_Portpriority; - bool m_PortpriorityIsSet; -}; -} -} -} -} diff --git a/src/services/pcn-bridge/src/model/PortsTrunkAllowedSchema.cpp b/src/services/pcn-bridge/src/model/PortsTrunkAllowedSchema.cpp deleted file mode 100644 index 3d853896d..000000000 --- a/src/services/pcn-bridge/src/model/PortsTrunkAllowedSchema.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/** -* bridge API -* bridge API generated from bridge.yang -* -* OpenAPI spec version: 1.0.0 -* -* NOTE: This class is auto generated by the swagger code generator program. -* https://github.com/swagger-api/swagger-codegen.git -*/ - -/* Do not edit this file manually */ - -#include "PortsTrunkAllowedSchema.h" - -namespace io { -namespace swagger { -namespace server { -namespace model { - -PortsTrunkAllowedSchema::PortsTrunkAllowedSchema() { - m_Vlanid = 0; - m_VlanidIsSet = false; -} - -PortsTrunkAllowedSchema::~PortsTrunkAllowedSchema() {} - -void PortsTrunkAllowedSchema::validate() { - // TODO: implement validation -} - -nlohmann::json PortsTrunkAllowedSchema::toJson() const { - nlohmann::json val = nlohmann::json::object(); - - if (m_VlanidIsSet) { - val["vlanid"] = m_Vlanid; - } - - return val; -} - -void PortsTrunkAllowedSchema::fromJson(nlohmann::json &val) { - if (val.find("vlanid") != val.end()) { - setVlanid(val.at("vlanid")); - } -} - -nlohmann::json PortsTrunkAllowedSchema::getKeys() { - nlohmann::json val = nlohmann::json::object(); - - val["vlanid"]["name"] = "vlanid"; - val["vlanid"]["type"] = "key"; - val["vlanid"]["simpletype"] = "integer"; - val["vlanid"]["description"] = R"POLYCUBE(Allowed vlan)POLYCUBE"; - val["vlanid"]["example"] = R"POLYCUBE()POLYCUBE"; - - return val; -} - -nlohmann::json PortsTrunkAllowedSchema::getElements() { - nlohmann::json val = nlohmann::json::object(); - - return val; -} - -nlohmann::json PortsTrunkAllowedSchema::getWritableLeafs() { - nlohmann::json val = nlohmann::json::object(); - - return val; -} - -nlohmann::json PortsTrunkAllowedSchema::getComplexElements() { - nlohmann::json val = nlohmann::json::object(); - - return val; -} - -int32_t PortsTrunkAllowedSchema::getVlanid() const { - return m_Vlanid; -} - -void PortsTrunkAllowedSchema::setVlanid(int32_t value) { - m_Vlanid = value; - m_VlanidIsSet = true; -} - -bool PortsTrunkAllowedSchema::vlanidIsSet() const { - return m_VlanidIsSet; -} - -void PortsTrunkAllowedSchema::unsetVlanid() { - m_VlanidIsSet = false; -} -} -} -} -} diff --git a/src/services/pcn-bridge/src/model/PortsTrunkAllowedSchema.h b/src/services/pcn-bridge/src/model/PortsTrunkAllowedSchema.h deleted file mode 100644 index 4ea147bcd..000000000 --- a/src/services/pcn-bridge/src/model/PortsTrunkAllowedSchema.h +++ /dev/null @@ -1,66 +0,0 @@ -/** -* bridge API -* bridge API generated from bridge.yang -* -* OpenAPI spec version: 1.0.0 -* -* NOTE: This class is auto generated by the swagger code generator program. -* https://github.com/swagger-api/swagger-codegen.git -*/ - -/* Do not edit this file manually */ - -/* - * PortsTrunkAllowedSchema.h - * - * - */ - -#pragma once - -#include "ModelBase.h" - -namespace io { -namespace swagger { -namespace server { -namespace model { - -/// -/// -/// -class PortsTrunkAllowedSchema : public ModelBase { - public: - PortsTrunkAllowedSchema(); - virtual ~PortsTrunkAllowedSchema(); - - ///////////////////////////////////////////// - /// ModelBase overrides - - void validate() override; - - nlohmann::json toJson() const override; - void fromJson(nlohmann::json &json) override; - - static nlohmann::json getKeys(); - static nlohmann::json getElements(); - static nlohmann::json getWritableLeafs(); - static nlohmann::json getComplexElements(); - ///////////////////////////////////////////// - /// PortsTrunkAllowedSchema members - - /// - /// Allowed vlan - /// - int32_t getVlanid() const; - void setVlanid(int32_t value); - bool vlanidIsSet() const; - void unsetVlanid(); - - protected: - int32_t m_Vlanid; - bool m_VlanidIsSet; -}; -} -} -} -} diff --git a/src/services/pcn-bridge/src/model/PortsTrunkSchema.cpp b/src/services/pcn-bridge/src/model/PortsTrunkSchema.cpp deleted file mode 100644 index 42d0187fc..000000000 --- a/src/services/pcn-bridge/src/model/PortsTrunkSchema.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/** -* bridge API -* bridge API generated from bridge.yang -* -* OpenAPI spec version: 1.0.0 -* -* NOTE: This class is auto generated by the swagger code generator program. -* https://github.com/swagger-api/swagger-codegen.git -*/ - -/* Do not edit this file manually */ - -#include "PortsTrunkSchema.h" - -namespace io { -namespace swagger { -namespace server { -namespace model { - -PortsTrunkSchema::PortsTrunkSchema() { - m_Nativevlan = 0; - m_NativevlanIsSet = false; - m_AllowedIsSet = false; -} - -PortsTrunkSchema::~PortsTrunkSchema() {} - -void PortsTrunkSchema::validate() { - // TODO: implement validation -} - -nlohmann::json PortsTrunkSchema::toJson() const { - nlohmann::json val = nlohmann::json::object(); - - if (m_NativevlanIsSet) { - val["nativevlan"] = m_Nativevlan; - } - - { - nlohmann::json jsonArray; - for (auto &item : m_Allowed) { - jsonArray.push_back(ModelBase::toJson(item)); - } - - if (jsonArray.size() > 0) { - val["allowed"] = jsonArray; - } - } - - return val; -} - -void PortsTrunkSchema::fromJson(nlohmann::json &val) { - if (val.find("nativevlan") != val.end()) { - setNativevlan(val.at("nativevlan")); - } - - m_Allowed.clear(); - for (auto &item : val["allowed"]) { - PortsTrunkAllowedSchema newItem; - newItem.fromJson(item); - m_Allowed.push_back(newItem); - } -} - -nlohmann::json PortsTrunkSchema::getKeys() { - nlohmann::json val = nlohmann::json::object(); - - return val; -} - -nlohmann::json PortsTrunkSchema::getElements() { - nlohmann::json val = nlohmann::json::object(); - - val["nativevlan"]["name"] = "nativevlan"; - val["nativevlan"]["type"] = "leaf"; // Suppose that type is leaf - val["nativevlan"]["simpletype"] = "integer"; - val["nativevlan"]["description"] = - R"POLYCUBE(VLAN that is not tagged in this trunk port)POLYCUBE"; - val["nativevlan"]["example"] = R"POLYCUBE()POLYCUBE"; - val["nativevlan"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "integer", - "format" : "uint32", - "description" : "VLAN that is not tagged in this trunk port" -})POLYCUBE"); - val["allowed"]["name"] = "allowed"; - val["allowed"]["type"] = "leaf"; // Suppose that type is leaf - val["allowed"]["type"] = "list"; - val["allowed"]["description"] = R"POLYCUBE(Allowed vlans)POLYCUBE"; - val["allowed"]["example"] = R"POLYCUBE()POLYCUBE"; - val["allowed"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "array", - "description" : "Allowed vlans", - "items" : { - "$ref" : "#/definitions/PortsTrunkAllowedSchema" - }, - "x-key" : [ "vlanid" ] -})POLYCUBE"); - - return val; -} - -nlohmann::json PortsTrunkSchema::getWritableLeafs() { - nlohmann::json val = nlohmann::json::object(); - - val["nativevlan"]["name"] = "nativevlan"; - val["nativevlan"]["simpletype"] = "integer"; - val["nativevlan"]["description"] = - R"POLYCUBE(VLAN that is not tagged in this trunk port)POLYCUBE"; - val["nativevlan"]["example"] = R"POLYCUBE()POLYCUBE"; - val["nativevlan"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "integer", - "format" : "uint32", - "description" : "VLAN that is not tagged in this trunk port" -})POLYCUBE"); - - return val; -} - -nlohmann::json PortsTrunkSchema::getComplexElements() { - nlohmann::json val = nlohmann::json::object(); - - val["allowed"]["name"] = "allowed"; - val["allowed"]["type"] = "list"; - val["allowed"]["description"] = R"POLYCUBE(Allowed vlans)POLYCUBE"; - val["allowed"]["example"] = R"POLYCUBE()POLYCUBE"; - - return val; -} - -int32_t PortsTrunkSchema::getNativevlan() const { - return m_Nativevlan; -} - -void PortsTrunkSchema::setNativevlan(int32_t value) { - m_Nativevlan = value; - m_NativevlanIsSet = true; -} - -bool PortsTrunkSchema::nativevlanIsSet() const { - return m_NativevlanIsSet; -} - -void PortsTrunkSchema::unsetNativevlan() { - m_NativevlanIsSet = false; -} -std::vector &PortsTrunkSchema::getAllowed() { - return m_Allowed; -} - -bool PortsTrunkSchema::allowedIsSet() const { - return m_AllowedIsSet; -} - -void PortsTrunkSchema::unsetAllowed() { - m_AllowedIsSet = false; -} -} -} -} -} diff --git a/src/services/pcn-bridge/src/model/PortsTrunkSchema.h b/src/services/pcn-bridge/src/model/PortsTrunkSchema.h deleted file mode 100644 index 7fca363e5..000000000 --- a/src/services/pcn-bridge/src/model/PortsTrunkSchema.h +++ /dev/null @@ -1,78 +0,0 @@ -/** -* bridge API -* bridge API generated from bridge.yang -* -* OpenAPI spec version: 1.0.0 -* -* NOTE: This class is auto generated by the swagger code generator program. -* https://github.com/swagger-api/swagger-codegen.git -*/ - -/* Do not edit this file manually */ - -/* - * PortsTrunkSchema.h - * - * - */ - -#pragma once - -#include "ModelBase.h" - -#include -#include "PortsTrunkAllowedSchema.h" - -namespace io { -namespace swagger { -namespace server { -namespace model { - -/// -/// -/// -class PortsTrunkSchema : public ModelBase { - public: - PortsTrunkSchema(); - virtual ~PortsTrunkSchema(); - - ///////////////////////////////////////////// - /// ModelBase overrides - - void validate() override; - - nlohmann::json toJson() const override; - void fromJson(nlohmann::json &json) override; - - static nlohmann::json getKeys(); - static nlohmann::json getElements(); - static nlohmann::json getWritableLeafs(); - static nlohmann::json getComplexElements(); - ///////////////////////////////////////////// - /// PortsTrunkSchema members - - /// - /// VLAN that is not tagged in this trunk port - /// - int32_t getNativevlan() const; - void setNativevlan(int32_t value); - bool nativevlanIsSet() const; - void unsetNativevlan(); - - /// - /// Allowed vlans - /// - std::vector &getAllowed(); - bool allowedIsSet() const; - void unsetAllowed(); - - protected: - int32_t m_Nativevlan; - bool m_NativevlanIsSet; - std::vector m_Allowed; - bool m_AllowedIsSet; -}; -} -} -} -} diff --git a/src/services/pcn-bridge/src/model/StpSchema.cpp b/src/services/pcn-bridge/src/model/StpSchema.cpp deleted file mode 100644 index a77664e75..000000000 --- a/src/services/pcn-bridge/src/model/StpSchema.cpp +++ /dev/null @@ -1,330 +0,0 @@ -/** -* bridge API -* bridge API generated from bridge.yang -* -* OpenAPI spec version: 1.0.0 -* -* NOTE: This class is auto generated by the swagger code generator program. -* https://github.com/swagger-api/swagger-codegen.git -*/ - -/* Do not edit this file manually */ - -#include "StpSchema.h" - -namespace io { -namespace swagger { -namespace server { -namespace model { - -StpSchema::StpSchema() { - m_Hellotime = 0; - m_HellotimeIsSet = false; - m_Vlan = 0; - m_VlanIsSet = false; - m_Forwarddelay = 0; - m_ForwarddelayIsSet = false; - m_Priority = 0; - m_PriorityIsSet = false; - m_Maxmessageage = 0; - m_MaxmessageageIsSet = false; - m_Address = ""; - m_AddressIsSet = false; -} - -StpSchema::~StpSchema() {} - -void StpSchema::validate() { - // TODO: implement validation -} - -nlohmann::json StpSchema::toJson() const { - nlohmann::json val = nlohmann::json::object(); - - if (m_HellotimeIsSet) { - val["hellotime"] = m_Hellotime; - } - - if (m_VlanIsSet) { - val["vlan"] = m_Vlan; - } - - if (m_ForwarddelayIsSet) { - val["forwarddelay"] = m_Forwarddelay; - } - - if (m_PriorityIsSet) { - val["priority"] = m_Priority; - } - - if (m_MaxmessageageIsSet) { - val["maxmessageage"] = m_Maxmessageage; - } - - if (m_AddressIsSet) { - val["address"] = m_Address; - } - - return val; -} - -void StpSchema::fromJson(nlohmann::json &val) { - if (val.find("hellotime") != val.end()) { - setHellotime(val.at("hellotime")); - } - - if (val.find("vlan") != val.end()) { - setVlan(val.at("vlan")); - } - - if (val.find("forwarddelay") != val.end()) { - setForwarddelay(val.at("forwarddelay")); - } - - if (val.find("priority") != val.end()) { - setPriority(val.at("priority")); - } - - if (val.find("maxmessageage") != val.end()) { - setMaxmessageage(val.at("maxmessageage")); - } - - if (val.find("address") != val.end()) { - setAddress(val.at("address")); - } -} - -nlohmann::json StpSchema::getKeys() { - nlohmann::json val = nlohmann::json::object(); - - val["vlan"]["name"] = "vlan"; - val["vlan"]["type"] = "key"; - val["vlan"]["simpletype"] = "integer"; - val["vlan"]["description"] = - R"POLYCUBE(VLAN identifier for this entry)POLYCUBE"; - val["vlan"]["example"] = R"POLYCUBE()POLYCUBE"; - - return val; -} - -nlohmann::json StpSchema::getElements() { - nlohmann::json val = nlohmann::json::object(); - - val["hellotime"]["name"] = "hellotime"; - val["hellotime"]["type"] = "leaf"; // Suppose that type is leaf - val["hellotime"]["simpletype"] = "integer"; - val["hellotime"]["description"] = - R"POLYCUBE(Interval between transmissions of BPDU messages)POLYCUBE"; - val["hellotime"]["example"] = R"POLYCUBE()POLYCUBE"; - val["hellotime"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "integer", - "format" : "uint32", - "description" : "Interval between transmissions of BPDU messages" -})POLYCUBE"); - val["forwarddelay"]["name"] = "forwarddelay"; - val["forwarddelay"]["type"] = "leaf"; // Suppose that type is leaf - val["forwarddelay"]["simpletype"] = "integer"; - val["forwarddelay"]["description"] = - R"POLYCUBE(Delay used by STP bridges for port state transition)POLYCUBE"; - val["forwarddelay"]["example"] = R"POLYCUBE()POLYCUBE"; - val["forwarddelay"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "integer", - "format" : "uint32", - "description" : "Delay used by STP bridges for port state transition" -})POLYCUBE"); - val["priority"]["name"] = "priority"; - val["priority"]["type"] = "leaf"; // Suppose that type is leaf - val["priority"]["simpletype"] = "integer"; - val["priority"]["description"] = R"POLYCUBE(Bridge priority for STP)POLYCUBE"; - val["priority"]["example"] = R"POLYCUBE()POLYCUBE"; - val["priority"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "integer", - "format" : "uint32", - "description" : "Bridge priority for STP" -})POLYCUBE"); - val["maxmessageage"]["name"] = "maxmessageage"; - val["maxmessageage"]["type"] = "leaf"; // Suppose that type is leaf - val["maxmessageage"]["simpletype"] = "integer"; - val["maxmessageage"]["description"] = - R"POLYCUBE(Maximum age of a BPDU)POLYCUBE"; - val["maxmessageage"]["example"] = R"POLYCUBE()POLYCUBE"; - val["maxmessageage"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "integer", - "format" : "uint32", - "description" : "Maximum age of a BPDU" -})POLYCUBE"); - val["address"]["name"] = "address"; - val["address"]["type"] = "leaf"; // Suppose that type is leaf - val["address"]["simpletype"] = "string"; - val["address"]["description"] = - R"POLYCUBE(Main MAC address used by the STP)POLYCUBE"; - val["address"]["example"] = R"POLYCUBE()POLYCUBE"; - val["address"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "string", - "description" : "Main MAC address used by the STP" -})POLYCUBE"); - - return val; -} - -nlohmann::json StpSchema::getWritableLeafs() { - nlohmann::json val = nlohmann::json::object(); - - val["hellotime"]["name"] = "hellotime"; - val["hellotime"]["simpletype"] = "integer"; - val["hellotime"]["description"] = - R"POLYCUBE(Interval between transmissions of BPDU messages)POLYCUBE"; - val["hellotime"]["example"] = R"POLYCUBE()POLYCUBE"; - val["hellotime"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "integer", - "format" : "uint32", - "description" : "Interval between transmissions of BPDU messages" -})POLYCUBE"); - val["forwarddelay"]["name"] = "forwarddelay"; - val["forwarddelay"]["simpletype"] = "integer"; - val["forwarddelay"]["description"] = - R"POLYCUBE(Delay used by STP bridges for port state transition)POLYCUBE"; - val["forwarddelay"]["example"] = R"POLYCUBE()POLYCUBE"; - val["forwarddelay"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "integer", - "format" : "uint32", - "description" : "Delay used by STP bridges for port state transition" -})POLYCUBE"); - val["priority"]["name"] = "priority"; - val["priority"]["simpletype"] = "integer"; - val["priority"]["description"] = R"POLYCUBE(Bridge priority for STP)POLYCUBE"; - val["priority"]["example"] = R"POLYCUBE()POLYCUBE"; - val["priority"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "integer", - "format" : "uint32", - "description" : "Bridge priority for STP" -})POLYCUBE"); - val["maxmessageage"]["name"] = "maxmessageage"; - val["maxmessageage"]["simpletype"] = "integer"; - val["maxmessageage"]["description"] = - R"POLYCUBE(Maximum age of a BPDU)POLYCUBE"; - val["maxmessageage"]["example"] = R"POLYCUBE()POLYCUBE"; - val["maxmessageage"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "integer", - "format" : "uint32", - "description" : "Maximum age of a BPDU" -})POLYCUBE"); - val["address"]["name"] = "address"; - val["address"]["simpletype"] = "string"; - val["address"]["description"] = - R"POLYCUBE(Main MAC address used by the STP)POLYCUBE"; - val["address"]["example"] = R"POLYCUBE()POLYCUBE"; - val["address"]["jsonSchema"] = nlohmann::json::parse(R"POLYCUBE({ - "type" : "string", - "description" : "Main MAC address used by the STP" -})POLYCUBE"); - - return val; -} - -nlohmann::json StpSchema::getComplexElements() { - nlohmann::json val = nlohmann::json::object(); - - return val; -} - -int32_t StpSchema::getHellotime() const { - return m_Hellotime; -} - -void StpSchema::setHellotime(int32_t value) { - m_Hellotime = value; - m_HellotimeIsSet = true; -} - -bool StpSchema::hellotimeIsSet() const { - return m_HellotimeIsSet; -} - -void StpSchema::unsetHellotime() { - m_HellotimeIsSet = false; -} -int32_t StpSchema::getVlan() const { - return m_Vlan; -} - -void StpSchema::setVlan(int32_t value) { - m_Vlan = value; - m_VlanIsSet = true; -} - -bool StpSchema::vlanIsSet() const { - return m_VlanIsSet; -} - -void StpSchema::unsetVlan() { - m_VlanIsSet = false; -} -int32_t StpSchema::getForwarddelay() const { - return m_Forwarddelay; -} - -void StpSchema::setForwarddelay(int32_t value) { - m_Forwarddelay = value; - m_ForwarddelayIsSet = true; -} - -bool StpSchema::forwarddelayIsSet() const { - return m_ForwarddelayIsSet; -} - -void StpSchema::unsetForwarddelay() { - m_ForwarddelayIsSet = false; -} -int32_t StpSchema::getPriority() const { - return m_Priority; -} - -void StpSchema::setPriority(int32_t value) { - m_Priority = value; - m_PriorityIsSet = true; -} - -bool StpSchema::priorityIsSet() const { - return m_PriorityIsSet; -} - -void StpSchema::unsetPriority() { - m_PriorityIsSet = false; -} -int32_t StpSchema::getMaxmessageage() const { - return m_Maxmessageage; -} - -void StpSchema::setMaxmessageage(int32_t value) { - m_Maxmessageage = value; - m_MaxmessageageIsSet = true; -} - -bool StpSchema::maxmessageageIsSet() const { - return m_MaxmessageageIsSet; -} - -void StpSchema::unsetMaxmessageage() { - m_MaxmessageageIsSet = false; -} -std::string StpSchema::getAddress() const { - return m_Address; -} - -void StpSchema::setAddress(std::string value) { - m_Address = value; - m_AddressIsSet = true; -} - -bool StpSchema::addressIsSet() const { - return m_AddressIsSet; -} - -void StpSchema::unsetAddress() { - m_AddressIsSet = false; -} -} -} -} -} diff --git a/src/services/pcn-bridge/src/model/StpSchema.h b/src/services/pcn-bridge/src/model/StpSchema.h deleted file mode 100644 index a8bde6203..000000000 --- a/src/services/pcn-bridge/src/model/StpSchema.h +++ /dev/null @@ -1,116 +0,0 @@ -/** -* bridge API -* bridge API generated from bridge.yang -* -* OpenAPI spec version: 1.0.0 -* -* NOTE: This class is auto generated by the swagger code generator program. -* https://github.com/swagger-api/swagger-codegen.git -*/ - -/* Do not edit this file manually */ - -/* - * StpSchema.h - * - * - */ - -#pragma once - -#include "ModelBase.h" - -namespace io { -namespace swagger { -namespace server { -namespace model { - -/// -/// -/// -class StpSchema : public ModelBase { - public: - StpSchema(); - virtual ~StpSchema(); - - ///////////////////////////////////////////// - /// ModelBase overrides - - void validate() override; - - nlohmann::json toJson() const override; - void fromJson(nlohmann::json &json) override; - - static nlohmann::json getKeys(); - static nlohmann::json getElements(); - static nlohmann::json getWritableLeafs(); - static nlohmann::json getComplexElements(); - ///////////////////////////////////////////// - /// StpSchema members - - /// - /// Interval between transmissions of BPDU messages - /// - int32_t getHellotime() const; - void setHellotime(int32_t value); - bool hellotimeIsSet() const; - void unsetHellotime(); - - /// - /// VLAN identifier for this entry - /// - int32_t getVlan() const; - void setVlan(int32_t value); - bool vlanIsSet() const; - void unsetVlan(); - - /// - /// Delay used by STP bridges for port state transition - /// - int32_t getForwarddelay() const; - void setForwarddelay(int32_t value); - bool forwarddelayIsSet() const; - void unsetForwarddelay(); - - /// - /// Bridge priority for STP - /// - int32_t getPriority() const; - void setPriority(int32_t value); - bool priorityIsSet() const; - void unsetPriority(); - - /// - /// Maximum age of a BPDU - /// - int32_t getMaxmessageage() const; - void setMaxmessageage(int32_t value); - bool maxmessageageIsSet() const; - void unsetMaxmessageage(); - - /// - /// Main MAC address used by the STP - /// - std::string getAddress() const; - void setAddress(std::string value); - bool addressIsSet() const; - void unsetAddress(); - - protected: - int32_t m_Hellotime; - bool m_HellotimeIsSet; - int32_t m_Vlan; - bool m_VlanIsSet; - int32_t m_Forwarddelay; - bool m_ForwarddelayIsSet; - int32_t m_Priority; - bool m_PriorityIsSet; - int32_t m_Maxmessageage; - bool m_MaxmessageageIsSet; - std::string m_Address; - bool m_AddressIsSet; -}; -} -} -} -} diff --git a/src/services/pcn-bridge/test/README.md b/src/services/pcn-bridge/test/README.md deleted file mode 100755 index a4990addf..000000000 --- a/src/services/pcn-bridge/test/README.md +++ /dev/null @@ -1,42 +0,0 @@ - -## Tests vlan - -under `vlan` folder - - -## Tests connectivity - -under `connectivity` folder - - -## General testing using pcn-bridge - -under this folder - - -## Tests STP using pcn-bridge - -Under `stp_pcn` folder - -test1x: configure a topology; wait for convergence; test connectivity - -test2x: same as test1x plus make changes to topology, wait for convergence, retest connectivity - -test3x: configure a topology, wait for convergence, test stp ports status - -test4x: same as test 3x plus make changes to topology, wait for convergence, re-test ports stp status - - - -## Tests STP using pcn-bridge + linux bridge - - -Under `stp_pcn_lb` folder - -test5x same as test1x - -test6x same as test2x - -test7x same as test3x - -test8x same as test4x diff --git a/src/services/pcn-bridge/test/connectivity/test1.sh b/src/services/pcn-bridge/test/connectivity/test1.sh deleted file mode 100755 index 702e45cff..000000000 --- a/src/services/pcn-bridge/test/connectivity/test1.sh +++ /dev/null @@ -1,60 +0,0 @@ -#! /bin/bash - -#test 4 ports access mode - -source "${BASH_SOURCE%/*}/../helpers.bash" - -N=4 -FLAG="TC" - -function cleanup { - set +e - del_bridges 1 - delete_veth $N -} - -if [ $# -gt 2 ]; then - echo "Wrong number of arguments" - echo "-D for XDP DRIVER MODE" - echo "-S for XDP SKB MODE" - echo "Empty for TC MODE" - exit 1 -fi - -if [ -n "$1" ] && [ "$1" != "-D" ] && [ "$1" != "-S" ]; then - echo "Wrong arguments" - echo "-D for XDP DRIVER MODE" - echo "-S for XDP SKB MODE" - echo "Empty for TC MODE" - exit 1 -fi - -if [ "$1" == "-D" ]; then - FLAG="XDP_DRV" -fi - -if [ "$1" == "-S" ]; then - FLAG="XDP_SKB" -fi - -trap cleanup EXIT -set -x - -# setup -create_veth $N - -set -e - -add_bridges 1 $FLAG - -for i in `seq 1 $N`; -do - bridge_add_port br1 veth$i -done - -#sleeping -#sleep $CONVERGENCE_TIME -#sleep 40 - -#testing connectivity -ping_cycle $N diff --git a/src/services/pcn-bridge/test/connectivity/test1_xdp.sh b/src/services/pcn-bridge/test/connectivity/test1_xdp.sh deleted file mode 100755 index aa8face7d..000000000 --- a/src/services/pcn-bridge/test/connectivity/test1_xdp.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -"${BASH_SOURCE%/*}/test1.sh" -S diff --git a/src/services/pcn-bridge/test/helpers.bash b/src/services/pcn-bridge/test/helpers.bash deleted file mode 100755 index c6c774c21..000000000 --- a/src/services/pcn-bridge/test/helpers.bash +++ /dev/null @@ -1,248 +0,0 @@ -#!/usr/bin/env bash - -# default const value -CONVERGENCE_TIME="50" - -function test_fail { - set +e - res=$($@) - local status=$? - set -e - if [ $status -ne 0 ]; then - return 0 - else - return 1 - fi -} - -function get_bridge_mac_pcn { - address=$(polycubectl bridge $1 stp 1 show address) - echo $(echo $address | tr -d ':"') -} - -function get_bridge_mac_lb { - address=$(brctl showstp $1) - echo $(echo $stp | awk '{print $4}' | cut -d. -f2) -} - -function set_br_priority { - polycubectl bridge $1 stp 1 set priority=$2 -} - -function set_br_priority_lb { - sudo brctl setbridgeprio $1 $2 -} - -function set_br_priority_ovs { - sudo ovs-vsctl set Bridge $1 other_config:stp-priority=$2 -} - -function add_bridges_ovs { - for i in `seq $1 $2`; - do - sudo ovs-vsctl add-br br$i - sudo ovs-vsctl set Bridge br$i stp_enable=true - done -} - -function add_bridges_lb { - for i in `seq $1 $2`; - do - sudo brctl addbr br$i - sudo brctl stp br$i on - sudo ip link set br$i up - done -} - -function add_bridges { - for i in `seq 1 $1`; - do - if [ -n "$2" ]; then - polycubectl bridge add br$i type=$2 - else - polycubectl bridge add br$i - fi - done -} - -function add_bridges_stp { - for i in `seq 1 $1`; - do - polycubectl bridge add br$i stpenabled=true - done -} - -function del_bridges_ovs { - for i in `seq $1 $2`; - do - sudo ovs-vsctl del-br br$i - done -} - -function del_bridges_lb { - for i in `seq $1 $2`; - do - sudo ip link set br$i down - sudo brctl delbr br$i - done -} - -function del_bridges { - for i in `seq 1 $1`; - do - polycubectl bridge del br$i - done -} - -function bridge_add_port { - polycubectl bridge $1 ports add $2 - polycubectl bridge $1 ports $2 set peer=$2 -} - -function bridge_add_port_lb { - sudo brctl addif $1 $2 -} - -function bridge_add_port_ovs { - sudo ovs-vsctl add-port $1 $2 -} - -function ping_cycle { - for i in `seq 1 $1`; - do - for j in `seq 1 $1`; - do - if [ "$i" -ne "$j" ]; then - sudo ip netns exec ns$i ping 10.0.0.$j -c 2 -i 0.5 - fi - done - done -} - -function create_veth { - for i in `seq 1 $1`; - do - sudo ip netns add ns${i} - sudo ip link add veth${i}_ type veth peer name veth${i} - sudo ip link set veth${i}_ netns ns${i} - sudo ip netns exec ns${i} ip link set dev veth${i}_ up - sudo ip link set dev veth${i} up - sudo ip netns exec ns${i} ifconfig veth${i}_ 10.0.0.${i}/24 - done -} - -function create_link { - for i in `seq 1 $1`; - do - sudo ip link add link${i}1 type veth peer name link${i}2 - sudo ip link set dev link${i}1 up - sudo ip link set dev link${i}2 up - done -} - -function delete_veth { - for i in `seq 1 $1`; - do - sudo ip link del veth${i} - sudo ip netns del ns${i} - done -} - -function delete_link { - for i in `seq 1 $1`; - do - sudo ip link del link${i}1 - done -} - -function test_forwarding_ovs { - test_forward echo $(sudo ovs-ofctl show $1 | grep -A 2 $2 | grep state | awk '{print $2}') -} - -function test_forwarding_lb { - test_forwarding echo $(brctl showstp $1 | grep -A 1 $2 | grep state | awk '{print $5}') -} - -function test_forwarding_pcn { - test_forwarding polycubectl bridge $1 ports $2 stp 1 show state -} - -function test_forwarding { - res=$($@) - local status=$? - if [ $status -ne 0 ]; then - return $status - else - echo "$res" - if [[ "$res" == *"forwarding"* ]]; then - return $status - else - echo "expexted port state forwarding" - return 1 - fi - fi - return $status -} - -function test_forward { - res=$($@) - local status=$? - if [ $status -ne 0 ]; then - return $status - else - echo "$res" - if [[ "$res" == *"FORWARD"* ]]; then - return $status - else - echo "expexted port state forwarding" - return 1 - fi - fi - return $status -} - -function test_blocking_ovs { - test_block echo $(sudo ovs-ofctl show $1 | grep -A 2 $2 | grep state | awk '{print $2}') -} - -function test_blocking_lb { - test_blocking echo $(brctl showstp $1 | grep -A 1 $2 | grep state | awk '{print $5}') -} - -function test_blocking_pcn { - test_blocking polycubectl bridge $1 ports $2 stp 1 show state -} - -function test_blocking { - res=$($@) - local status=$? - if [ $status -ne 0 ]; then - return $status - else - echo "$res" - if [[ "$res" == *"blocking"* ]]; then - return $status - else - echo "expexted port state blocking" - return 1 - fi - fi - return $status -} - -function test_block { - res=$($@) - local status=$? - if [ $status -ne 0 ]; then - return $status - else - echo "$res" - if [[ "$res" == *"BLOCK"* ]]; then - return $status - else - echo "expexted port state blocking" - return 1 - fi - fi - return $status -} diff --git a/src/services/pcn-bridge/test/stp/stp_pcn/test11.sh b/src/services/pcn-bridge/test/stp/stp_pcn/test11.sh deleted file mode 100755 index 65a48ef74..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn/test11.sh +++ /dev/null @@ -1,46 +0,0 @@ -#! /bin/bash - -# 3 pcn-bridge; triangle topology -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 3 - delete_veth 3 - delete_link 3 -} -trap cleanup EXIT - -set -x - -# setup -create_veth 3 -create_link 3 - -set -e - -add_bridges_stp 3 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 24576 -bridge_add_port br1 link32 -bridge_add_port br1 veth1 - -bridge_add_port br2 link12 -set_br_priority br2 28672 -bridge_add_port br2 link21 -bridge_add_port br2 veth2 - -bridge_add_port br3 link22 -bridge_add_port br3 link31 -bridge_add_port br3 veth3 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 3 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn/test12.sh b/src/services/pcn-bridge/test/stp/stp_pcn/test12.sh deleted file mode 100755 index 315467a96..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn/test12.sh +++ /dev/null @@ -1,49 +0,0 @@ -#! /bin/bash - -# 3 pcn-bridge; triangle topology; connect one extra link br1-br2 -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 3 - delete_veth 3 - delete_link 4 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 3 -create_link 4 - -set -e - -add_bridges_stp 3 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 24576 -bridge_add_port br1 link32 -bridge_add_port br1 veth1 - -bridge_add_port br2 link12 -set_br_priority br2 28672 -bridge_add_port br2 link21 -bridge_add_port br2 veth2 - -bridge_add_port br3 link22 -bridge_add_port br3 link31 -bridge_add_port br3 veth3 - -bridge_add_port br1 link41 -bridge_add_port br2 link42 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 3 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn/test13.sh b/src/services/pcn-bridge/test/stp/stp_pcn/test13.sh deleted file mode 100755 index 59825fc3a..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn/test13.sh +++ /dev/null @@ -1,56 +0,0 @@ -#! /bin/bash - -# 3 pcn-bridge; triangle topology; -# connect extra links between bridges -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 3 - delete_veth 3 - delete_link 6 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 3 -create_link 6 - -set -e - -add_bridges_stp 3 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 24576 -bridge_add_port br1 link32 -bridge_add_port br1 veth1 - -bridge_add_port br2 link12 -set_br_priority br2 28672 -bridge_add_port br2 link21 -bridge_add_port br2 veth2 - -bridge_add_port br3 link22 -bridge_add_port br3 link31 -bridge_add_port br3 veth3 - -bridge_add_port br1 link41 -bridge_add_port br2 link42 - -bridge_add_port br2 link51 -bridge_add_port br3 link52 - -bridge_add_port br3 link61 -bridge_add_port br1 link62 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 3 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn/test14.sh b/src/services/pcn-bridge/test/stp/stp_pcn/test14.sh deleted file mode 100755 index fe3df8795..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn/test14.sh +++ /dev/null @@ -1,39 +0,0 @@ -#! /bin/bash - -# 1 pcn-bridge -# 1 loop link on the bridge -# 2 interfaces veth1 to forward traffic -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 1 - delete_veth 2 - delete_link 1 -} -trap cleanup EXIT - -set -x - -# setup -create_veth 2 -create_link 1 - -set -e - -add_bridges_stp 1 - -# create ports -bridge_add_port br1 link11 -bridge_add_port br1 link12 -bridge_add_port br1 veth1 -bridge_add_port br1 veth2 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 2 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn/test15.sh b/src/services/pcn-bridge/test/stp/stp_pcn/test15.sh deleted file mode 100755 index 8c78d77b8..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn/test15.sh +++ /dev/null @@ -1,53 +0,0 @@ -#! /bin/bash - -# 4 pcn-bridge; square topology; -# connect extra links between bridges 3-4 -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 4 - delete_veth 4 - delete_link 5 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 4 -create_link 5 - -set -e - -add_bridges_stp 4 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 28672 -bridge_add_port br1 link42 -bridge_add_port br1 veth1 - -bridge_add_port br2 link12 -set_br_priority br2 24576 -bridge_add_port br2 link21 -bridge_add_port br2 veth2 - -bridge_add_port br3 link22 -bridge_add_port br3 link31 -bridge_add_port br3 link51 -bridge_add_port br3 veth3 - -bridge_add_port br4 link32 -bridge_add_port br4 link41 -bridge_add_port br4 link52 -bridge_add_port br4 veth4 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 4 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn/test16.sh b/src/services/pcn-bridge/test/stp/stp_pcn/test16.sh deleted file mode 100755 index c3cf24066..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn/test16.sh +++ /dev/null @@ -1,60 +0,0 @@ -#! /bin/bash - -# 4 pcn-bridge; square topology; -# connect extra links between bridges 1-3 2-4 -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 4 - delete_veth 4 - delete_link 6 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 4 -create_link 6 - -set -e - -add_bridges_stp 4 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 28672 -bridge_add_port br1 link42 - -bridge_add_port br2 link12 -set_br_priority br2 24576 -bridge_add_port br2 link21 - -bridge_add_port br3 link22 -set_br_priority br3 32768 -bridge_add_port br3 link31 - -bridge_add_port br4 link32 -set_br_priority br4 36864 -bridge_add_port br4 link41 - - -bridge_add_port br1 link51 -bridge_add_port br3 link52 -bridge_add_port br2 link61 -bridge_add_port br4 link62 - -bridge_add_port br1 veth1 -bridge_add_port br2 veth2 -bridge_add_port br3 veth3 -bridge_add_port br4 veth4 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 4 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn/test17.sh b/src/services/pcn-bridge/test/stp/stp_pcn/test17.sh deleted file mode 100755 index 0027b8793..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn/test17.sh +++ /dev/null @@ -1,60 +0,0 @@ -#! /bin/bash - -# 5 pcn-bridge; square topology(1,2,3,4) + triangle(2,3,5) ; -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 5 - delete_veth 5 - delete_link 6 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 5 -create_link 6 - -set -e - -add_bridges_stp 5 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 28672 -bridge_add_port br1 link42 - -bridge_add_port br2 link12 -set_br_priority br2 24576 -bridge_add_port br2 link21 - -bridge_add_port br3 link22 -set_br_priority br3 32768 -bridge_add_port br3 link31 - -bridge_add_port br4 link32 -set_br_priority br4 36864 -bridge_add_port br4 link41 - -bridge_add_port br5 link52 -set_br_priority br5 36864 -bridge_add_port br5 link61 -bridge_add_port br2 link51 -bridge_add_port br3 link62 - -bridge_add_port br1 veth1 -bridge_add_port br2 veth2 -bridge_add_port br3 veth3 -bridge_add_port br4 veth4 -bridge_add_port br5 veth5 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 5 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn/test21.sh b/src/services/pcn-bridge/test/stp/stp_pcn/test21.sh deleted file mode 100755 index 57557d016..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn/test21.sh +++ /dev/null @@ -1,57 +0,0 @@ -#! /bin/bash - -# 3 pcn-bridge; triangle topology -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 3 - delete_veth 3 - delete_link 3 -} -trap cleanup EXIT - -set -x - -# setup -create_veth 3 -create_link 3 - -set -e - -add_bridges_stp 3 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 24576 -bridge_add_port br1 link32 -bridge_add_port br1 veth1 - -bridge_add_port br2 link12 -set_br_priority br2 28672 -bridge_add_port br2 link21 -bridge_add_port br2 veth2 - -bridge_add_port br3 link22 -bridge_add_port br3 link31 -bridge_add_port br3 veth3 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 3 - -# change topology -polycubectl bridge br1 ports del link32 -polycubectl bridge br3 ports del link31 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 3 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn/test22.sh b/src/services/pcn-bridge/test/stp/stp_pcn/test22.sh deleted file mode 100755 index a04e56ba8..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn/test22.sh +++ /dev/null @@ -1,72 +0,0 @@ -#! /bin/bash - -# 3 pcn-bridge; triangle topology; connect one extra link br1-br2 -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 3 - delete_veth 3 - delete_link 4 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 3 -create_link 4 - -set -e - -add_bridges_stp 3 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 24576 -bridge_add_port br1 link32 -bridge_add_port br1 veth1 - -bridge_add_port br2 link12 -set_br_priority br2 28672 -bridge_add_port br2 link21 -bridge_add_port br2 veth2 - -bridge_add_port br3 link22 -bridge_add_port br3 link31 -bridge_add_port br3 veth3 - -bridge_add_port br1 link41 -bridge_add_port br2 link42 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 3 - -# change topology -polycubectl bridge br1 ports del link11 -polycubectl bridge br2 ports del link12 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 3 - - -# change topology -polycubectl bridge br1 ports del link32 -polycubectl bridge br3 ports del link31 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 3 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn/test23.sh b/src/services/pcn-bridge/test/stp/stp_pcn/test23.sh deleted file mode 100755 index 56de8f701..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn/test23.sh +++ /dev/null @@ -1,73 +0,0 @@ -#! /bin/bash - -# 3 pcn-bridge; triangle topology; -# connect extra links between bridges -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 3 - delete_veth 3 - delete_link 6 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 3 -create_link 6 - -set -e - -add_bridges_stp 3 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 24576 -bridge_add_port br1 link32 -bridge_add_port br1 veth1 - -bridge_add_port br2 link12 -set_br_priority br2 28672 -bridge_add_port br2 link21 -bridge_add_port br2 veth2 - -bridge_add_port br3 link22 -bridge_add_port br3 link31 -bridge_add_port br3 veth3 - -bridge_add_port br1 link41 -bridge_add_port br2 link42 - -bridge_add_port br2 link51 -bridge_add_port br3 link52 - -bridge_add_port br3 link61 -bridge_add_port br1 link62 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 3 - -# change topology -polycubectl bridge br1 ports del link11 -polycubectl bridge br2 ports del link12 - -polycubectl bridge br2 ports del link21 -polycubectl bridge br3 ports del link22 - -polycubectl bridge br3 ports del link31 -polycubectl bridge br1 ports del link32 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 3 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn/test24.sh b/src/services/pcn-bridge/test/stp/stp_pcn/test24.sh deleted file mode 100755 index 55f29fd3f..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn/test24.sh +++ /dev/null @@ -1,53 +0,0 @@ -#! /bin/bash - -# 1 pcn-bridge -# 1 loop link on the bridge -# 2 interfaces veth1 to forward traffic -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 1 - delete_veth 2 - delete_link 1 -} -trap cleanup EXIT - -set -x - -# setup -create_veth 2 -create_link 1 - -set -e - -add_bridges_stp 1 - -# create ports -bridge_add_port br1 link11 -bridge_add_port br1 link12 -bridge_add_port br1 veth1 -bridge_add_port br1 veth2 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 2 - -# change topology -polycubectl bridge br1 ports del link11 -polycubectl bridge br1 ports del link12 - -bridge_add_port br1 link12 -bridge_add_port br1 link11 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 2 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn/test25.sh b/src/services/pcn-bridge/test/stp/stp_pcn/test25.sh deleted file mode 100755 index f299258dd..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn/test25.sh +++ /dev/null @@ -1,77 +0,0 @@ -#! /bin/bash - -# 4 pcn-bridge; square topology; -# connect extra links between bridges 3-4 -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 4 - delete_veth 4 - delete_link 5 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 4 -create_link 5 - -set -e - -add_bridges_stp 4 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 28672 -bridge_add_port br1 link42 -bridge_add_port br1 veth1 - -bridge_add_port br2 link12 -set_br_priority br2 24576 -bridge_add_port br2 link21 -bridge_add_port br2 veth2 - -bridge_add_port br3 link22 -bridge_add_port br3 link31 -bridge_add_port br3 link51 -bridge_add_port br3 veth3 - -bridge_add_port br4 link32 -bridge_add_port br4 link41 -bridge_add_port br4 link52 -bridge_add_port br4 veth4 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 4 - - -# change topology -polycubectl bridge br4 ports del link52 -polycubectl bridge br3 ports del link51 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 4 - - -# change topology -bridge_add_port br2 link51 -bridge_add_port br4 link52 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 4 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn/test26.sh b/src/services/pcn-bridge/test/stp/stp_pcn/test26.sh deleted file mode 100755 index 39ae1246d..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn/test26.sh +++ /dev/null @@ -1,84 +0,0 @@ -#! /bin/bash - -# 4 pcn-bridge; square topology; -# connect extra links between bridges 1-3 2-4 -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 4 - delete_veth 4 - delete_link 6 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 4 -create_link 6 - -set -e - -add_bridges_stp 4 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 28672 -bridge_add_port br1 link42 - -bridge_add_port br2 link12 -set_br_priority br2 24576 -bridge_add_port br2 link21 - -bridge_add_port br3 link22 -set_br_priority br3 32768 -bridge_add_port br3 link31 - -bridge_add_port br4 link32 -set_br_priority br4 36864 -bridge_add_port br4 link41 - - -bridge_add_port br1 link51 -bridge_add_port br3 link52 -bridge_add_port br2 link61 -bridge_add_port br4 link62 - -bridge_add_port br1 veth1 -bridge_add_port br2 veth2 -bridge_add_port br3 veth3 -bridge_add_port br4 veth4 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 4 - - -# change topology -polycubectl bridge br1 ports del link42 -polycubectl bridge br4 ports del link41 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 4 - - -# change topology -polycubectl bridge br2 ports del link21 -polycubectl bridge br3 ports del link22 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 4 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn/test27.sh b/src/services/pcn-bridge/test/stp/stp_pcn/test27.sh deleted file mode 100755 index 4be44c83c..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn/test27.sh +++ /dev/null @@ -1,72 +0,0 @@ -#! /bin/bash - -# 5 pcn-bridge; square topology(1,2,3,4) + triangle(2,3,5) ; -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 5 - delete_veth 5 - delete_link 6 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 5 -create_link 6 - -set -e - -add_bridges_stp 5 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 28672 -bridge_add_port br1 link42 - -bridge_add_port br2 link12 -set_br_priority br2 24576 -bridge_add_port br2 link21 - -bridge_add_port br3 link22 -set_br_priority br3 32768 -bridge_add_port br3 link31 - -bridge_add_port br4 link32 -set_br_priority br4 36864 -bridge_add_port br4 link41 - -bridge_add_port br5 link52 -set_br_priority br5 36864 -bridge_add_port br5 link61 -bridge_add_port br2 link51 -bridge_add_port br3 link62 - -bridge_add_port br1 veth1 -bridge_add_port br2 veth2 -bridge_add_port br3 veth3 -bridge_add_port br4 veth4 -bridge_add_port br5 veth5 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 5 - - -# change topology -polycubectl bridge br2 ports del link21 -polycubectl bridge br3 ports del link22 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 5 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn/test31.sh b/src/services/pcn-bridge/test/stp/stp_pcn/test31.sh deleted file mode 100755 index 7068c934f..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn/test31.sh +++ /dev/null @@ -1,53 +0,0 @@ -#! /bin/bash - -# 3 pcn-bridge; triangle topology -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 3 - delete_veth 3 - delete_link 3 -} -trap cleanup EXIT - -set -x - -# setup -create_veth 3 -create_link 3 - -set -e - -add_bridges_stp 3 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 24576 -bridge_add_port br1 link32 -bridge_add_port br1 veth1 - -bridge_add_port br2 link12 -set_br_priority br2 28672 -bridge_add_port br2 link21 -bridge_add_port br2 veth2 - -bridge_add_port br3 link22 -bridge_add_port br3 link31 -bridge_add_port br3 veth3 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link32 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link21 - -test_forwarding_pcn br3 link31 -test_blocking_pcn br3 link22 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn/test32.sh b/src/services/pcn-bridge/test/stp/stp_pcn/test32.sh deleted file mode 100755 index a73d74e73..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn/test32.sh +++ /dev/null @@ -1,59 +0,0 @@ -#! /bin/bash - -# 3 pcn-bridge; triangle topology; connect one extra link br1-br2 -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 3 - delete_veth 3 - delete_link 4 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 3 -create_link 4 - -set -e - -add_bridges_stp 3 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 24576 -bridge_add_port br1 link32 -bridge_add_port br1 veth1 - -bridge_add_port br2 link12 -set_br_priority br2 28672 -bridge_add_port br2 link21 -bridge_add_port br2 veth2 - -bridge_add_port br3 link22 -bridge_add_port br3 link31 -bridge_add_port br3 veth3 - -bridge_add_port br1 link41 -bridge_add_port br2 link42 - -#sleeping -sleep $CONVERGENCE_TIME - - -# testing ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link32 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link21 - -test_forwarding_pcn br3 link31 -test_blocking_pcn br3 link22 - -test_forwarding_pcn br1 link41 -test_blocking_pcn br2 link42 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn/test33.sh b/src/services/pcn-bridge/test/stp/stp_pcn/test33.sh deleted file mode 100755 index 3c8579560..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn/test33.sh +++ /dev/null @@ -1,73 +0,0 @@ -#! /bin/bash - -# 3 pcn-bridge; triangle topology; -# connect extra links between bridges -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 3 - delete_veth 3 - delete_link 6 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 3 -create_link 6 - -set -e - -add_bridges_stp 3 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 24576 -bridge_add_port br1 link32 -bridge_add_port br1 veth1 - -bridge_add_port br2 link12 -set_br_priority br2 28672 -bridge_add_port br2 link21 -bridge_add_port br2 veth2 - -bridge_add_port br3 link22 -bridge_add_port br3 link31 -bridge_add_port br3 veth3 - -bridge_add_port br1 link41 -bridge_add_port br2 link42 - -bridge_add_port br2 link51 -bridge_add_port br3 link52 - -bridge_add_port br3 link61 -bridge_add_port br1 link62 - -#sleeping -sleep $CONVERGENCE_TIME - - - -# testing ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link32 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link21 - -test_forwarding_pcn br3 link31 -test_blocking_pcn br3 link22 - -test_forwarding_pcn br1 link41 -test_forwarding_pcn br1 link62 - -test_blocking_pcn br2 link42 -test_forwarding_pcn br2 link51 - -test_blocking_pcn br3 link52 -test_blocking_pcn br3 link61 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn/test34.sh b/src/services/pcn-bridge/test/stp/stp_pcn/test34.sh deleted file mode 100755 index b88def68b..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn/test34.sh +++ /dev/null @@ -1,43 +0,0 @@ -#! /bin/bash - -# 1 pcn-bridge -# 1 loop link on the bridge -# 2 interfaces veth1 to forward traffic -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 1 - delete_veth 2 - delete_link 1 -} -trap cleanup EXIT - -set -x - -# setup -create_veth 2 -create_link 1 - -set -e - -add_bridges_stp 1 - -# create ports -bridge_add_port br1 link11 -bridge_add_port br1 link12 -bridge_add_port br1 veth1 -bridge_add_port br1 veth2 - -#sleeping -sleep $CONVERGENCE_TIME - - -# test ports state -test_forwarding_pcn br1 link11 -test_blocking_pcn br1 link12 - -test_forwarding_pcn br1 veth1 -test_forwarding_pcn br1 veth2 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn/test35.sh b/src/services/pcn-bridge/test/stp/stp_pcn/test35.sh deleted file mode 100755 index 2f02567b7..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn/test35.sh +++ /dev/null @@ -1,65 +0,0 @@ -#! /bin/bash - -# 4 pcn-bridge; square topology; -# connect extra links between bridges 3-4 -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 4 - delete_veth 4 - delete_link 5 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 4 -create_link 5 - -set -e - -add_bridges_stp 4 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 28672 -bridge_add_port br1 link42 -bridge_add_port br1 veth1 - -bridge_add_port br2 link12 -set_br_priority br2 24576 -bridge_add_port br2 link21 -bridge_add_port br2 veth2 - -bridge_add_port br3 link22 -bridge_add_port br3 link31 -bridge_add_port br3 link51 -bridge_add_port br3 veth3 - -bridge_add_port br4 link32 -bridge_add_port br4 link41 -bridge_add_port br4 link52 -bridge_add_port br4 veth4 - -#sleeping -sleep $CONVERGENCE_TIME - - -# test ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link42 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link21 - -test_forwarding_pcn br3 link22 -test_forwarding_pcn br3 link31 -test_forwarding_pcn br3 link51 - -test_blocking_pcn br4 link32 -test_forwarding_pcn br4 link41 -test_blocking_pcn br4 link52 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn/test36.sh b/src/services/pcn-bridge/test/stp/stp_pcn/test36.sh deleted file mode 100755 index a20ff3912..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn/test36.sh +++ /dev/null @@ -1,75 +0,0 @@ -#! /bin/bash - -# 4 pcn-bridge; square topology; -# connect extra links between bridges 1-3 2-4 -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 4 - delete_veth 4 - delete_link 6 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 4 -create_link 6 - -set -e - -add_bridges_stp 4 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 28672 -bridge_add_port br1 link42 - -bridge_add_port br2 link12 -set_br_priority br2 24576 -bridge_add_port br2 link21 - -bridge_add_port br3 link22 -set_br_priority br3 32768 -bridge_add_port br3 link31 - -bridge_add_port br4 link32 -set_br_priority br4 36864 -bridge_add_port br4 link41 - - -bridge_add_port br1 link51 -bridge_add_port br3 link52 -bridge_add_port br2 link61 -bridge_add_port br4 link62 - -bridge_add_port br1 veth1 -bridge_add_port br2 veth2 -bridge_add_port br3 veth3 -bridge_add_port br4 veth4 - - -#sleeping -sleep $CONVERGENCE_TIME - - -# test ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link42 -test_forwarding_pcn br1 link51 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link21 -test_forwarding_pcn br2 link61 - -test_forwarding_pcn br3 link22 -test_forwarding_pcn br3 link31 -test_blocking_pcn br3 link52 - -test_blocking_pcn br4 link32 -test_blocking_pcn br4 link41 -test_forwarding_pcn br4 link62 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn/test37.sh b/src/services/pcn-bridge/test/stp/stp_pcn/test37.sh deleted file mode 100755 index 820d67287..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn/test37.sh +++ /dev/null @@ -1,75 +0,0 @@ -#! /bin/bash - -# 5 pcn-bridge; square topology(1,2,3,4) + triangle(2,3,5) ; -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 5 - delete_veth 5 - delete_link 6 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 5 -create_link 6 - -set -e - -add_bridges_stp 5 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 28672 -bridge_add_port br1 link42 - -bridge_add_port br2 link12 -set_br_priority br2 24576 -bridge_add_port br2 link21 - -bridge_add_port br3 link22 -set_br_priority br3 32768 -bridge_add_port br3 link31 - -bridge_add_port br4 link32 -set_br_priority br4 36864 -bridge_add_port br4 link41 - -bridge_add_port br5 link52 -set_br_priority br5 36864 -bridge_add_port br5 link61 -bridge_add_port br2 link51 -bridge_add_port br3 link62 - -bridge_add_port br1 veth1 -bridge_add_port br2 veth2 -bridge_add_port br3 veth3 -bridge_add_port br4 veth4 -bridge_add_port br5 veth5 - -#sleeping -sleep $CONVERGENCE_TIME - - -# test ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link42 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link21 -test_forwarding_pcn br2 link51 - -test_forwarding_pcn br3 link22 -test_forwarding_pcn br3 link31 -test_forwarding_pcn br3 link62 - -test_blocking_pcn br4 link32 -test_forwarding_pcn br4 link41 - -test_blocking_pcn br5 link61 -test_forwarding_pcn br5 link52 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn/test41.sh b/src/services/pcn-bridge/test/stp/stp_pcn/test41.sh deleted file mode 100755 index 9844475ac..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn/test41.sh +++ /dev/null @@ -1,68 +0,0 @@ -#! /bin/bash - -# 3 pcn-bridge; triangle topology -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 3 - delete_veth 3 - delete_link 3 -} -trap cleanup EXIT - -set -x - -# setup -create_veth 3 -create_link 3 - -set -e - -add_bridges_stp 3 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 24576 -bridge_add_port br1 link32 -bridge_add_port br1 veth1 - -bridge_add_port br2 link12 -set_br_priority br2 28672 -bridge_add_port br2 link21 -bridge_add_port br2 veth2 - -bridge_add_port br3 link22 -bridge_add_port br3 link31 -bridge_add_port br3 veth3 - -#sleeping -sleep $CONVERGENCE_TIME - -#testing ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link32 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link21 - -test_forwarding_pcn br3 link31 -test_blocking_pcn br3 link22 - - -# change topology -polycubectl bridge br1 ports del link32 -polycubectl bridge br3 ports del link31 - -#sleeping -sleep $CONVERGENCE_TIME - -#testing ports state -test_forwarding_pcn br1 link11 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link21 - -test_forwarding_pcn br3 link22 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn/test42.sh b/src/services/pcn-bridge/test/stp/stp_pcn/test42.sh deleted file mode 100755 index 008deed1a..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn/test42.sh +++ /dev/null @@ -1,92 +0,0 @@ -#! /bin/bash - -# 3 pcn-bridge; triangle topology; connect one extra link br1-br2 -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 3 - delete_veth 3 - delete_link 4 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 3 -create_link 4 - -set -e - -add_bridges_stp 3 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 24576 -bridge_add_port br1 link32 -bridge_add_port br1 veth1 - -bridge_add_port br2 link12 -set_br_priority br2 28672 -bridge_add_port br2 link21 -bridge_add_port br2 veth2 - -bridge_add_port br3 link22 -bridge_add_port br3 link31 -bridge_add_port br3 veth3 - -bridge_add_port br1 link41 -bridge_add_port br2 link42 - -#sleeping -sleep $CONVERGENCE_TIME - -# testing ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link32 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link21 - -test_forwarding_pcn br3 link31 -test_blocking_pcn br3 link22 - -test_forwarding_pcn br1 link41 -test_blocking_pcn br2 link42 - - -# change topology -polycubectl bridge br1 ports del link11 -polycubectl bridge br2 ports del link12 - -#sleeping -sleep $CONVERGENCE_TIME - -# testing ports state -test_forwarding_pcn br1 link32 - -test_forwarding_pcn br2 link21 - -test_forwarding_pcn br3 link31 -test_blocking_pcn br3 link22 - -test_forwarding_pcn br1 link41 -test_forwarding_pcn br2 link42 - - -# change topology -polycubectl bridge br1 ports del link32 -polycubectl bridge br3 ports del link31 - -#sleeping -sleep $CONVERGENCE_TIME - -# testing ports state -test_forwarding_pcn br2 link21 -test_forwarding_pcn br3 link22 - -test_forwarding_pcn br1 link41 -test_forwarding_pcn br2 link42 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn/test43.sh b/src/services/pcn-bridge/test/stp/stp_pcn/test43.sh deleted file mode 100755 index ab8a65ccb..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn/test43.sh +++ /dev/null @@ -1,98 +0,0 @@ -#! /bin/bash - -# 3 pcn-bridge; triangle topology; -# connect extra links between bridges -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 3 - delete_veth 3 - delete_link 6 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 3 -create_link 6 - -set -e - -add_bridges_stp 3 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 24576 -bridge_add_port br1 link32 -bridge_add_port br1 veth1 - -bridge_add_port br2 link12 -set_br_priority br2 28672 -bridge_add_port br2 link21 -bridge_add_port br2 veth2 - -bridge_add_port br3 link22 -bridge_add_port br3 link31 -bridge_add_port br3 veth3 - -bridge_add_port br1 link41 -bridge_add_port br2 link42 - -bridge_add_port br2 link51 -bridge_add_port br3 link52 - -bridge_add_port br3 link61 -bridge_add_port br1 link62 - -#sleeping -sleep $CONVERGENCE_TIME - -# testing ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link32 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link21 - -test_forwarding_pcn br3 link31 -test_blocking_pcn br3 link22 - -test_forwarding_pcn br1 link41 -test_forwarding_pcn br1 link62 - -test_blocking_pcn br2 link42 -test_forwarding_pcn br2 link51 - -test_blocking_pcn br3 link52 -test_blocking_pcn br3 link61 - - -# change topology -polycubectl bridge br1 ports del link11 -polycubectl bridge br2 ports del link12 - -polycubectl bridge br2 ports del link21 -polycubectl bridge br3 ports del link22 - -polycubectl bridge br3 ports del link31 -polycubectl bridge br1 ports del link32 - -#sleeping -sleep $CONVERGENCE_TIME - -# testing ports state -test_forwarding_pcn br1 link41 -test_forwarding_pcn br1 link62 - -test_forwarding_pcn br2 link42 -test_forwarding_pcn br2 link51 - -test_blocking_pcn br3 link52 -test_forwarding_pcn br3 link61 - -#testing connectivity -ping_cycle 3 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn/test44.sh b/src/services/pcn-bridge/test/stp/stp_pcn/test44.sh deleted file mode 100755 index 96b384a52..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn/test44.sh +++ /dev/null @@ -1,60 +0,0 @@ -#! /bin/bash - -# 1 pcn-bridge -# 1 loop link on the bridge -# 2 interfaces veth1 to forward traffic -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 1 - delete_veth 2 - delete_link 1 -} -trap cleanup EXIT - -set -x - -# setup -create_veth 2 -create_link 1 - -set -e - -add_bridges_stp 1 - -# create ports -bridge_add_port br1 link11 -bridge_add_port br1 link12 -bridge_add_port br1 veth1 -bridge_add_port br1 veth2 - -#sleeping -sleep $CONVERGENCE_TIME - -# test ports state -test_forwarding_pcn br1 link11 -test_blocking_pcn br1 link12 - -test_forwarding_pcn br1 veth1 -test_forwarding_pcn br1 veth2 - - -# change topology -polycubectl bridge br1 ports del link11 -polycubectl bridge br1 ports del link12 - -bridge_add_port br1 link12 -bridge_add_port br1 link11 - -#sleeping -sleep $CONVERGENCE_TIME - -# test ports state -test_forwarding_pcn br1 link12 -test_blocking_pcn br1 link11 - -test_forwarding_pcn br1 veth1 -test_forwarding_pcn br1 veth2 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn/test45.sh b/src/services/pcn-bridge/test/stp/stp_pcn/test45.sh deleted file mode 100755 index 844aea8be..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn/test45.sh +++ /dev/null @@ -1,140 +0,0 @@ -#! /bin/bash - -# 4 pcn-bridge; square topology; -# connect extra links between bridges 3-4 -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 4 - delete_veth 4 - delete_link 5 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 4 -create_link 5 - -set -e - -add_bridges_stp 4 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 28672 -bridge_add_port br1 link42 -bridge_add_port br1 veth1 - -bridge_add_port br2 link12 -set_br_priority br2 24576 -bridge_add_port br2 link21 -bridge_add_port br2 veth2 - -bridge_add_port br3 link22 -bridge_add_port br3 link31 -bridge_add_port br3 link51 -bridge_add_port br3 veth3 - -bridge_add_port br4 link32 -bridge_add_port br4 link41 -bridge_add_port br4 link52 -bridge_add_port br4 veth4 - -#sleeping -sleep $CONVERGENCE_TIME - -# test ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link42 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link21 - -test_forwarding_pcn br3 link22 -test_forwarding_pcn br3 link31 -test_forwarding_pcn br3 link51 - -test_blocking_pcn br4 link32 -test_forwarding_pcn br4 link41 -test_blocking_pcn br4 link52 - - -# change topology -polycubectl bridge br4 ports del link52 -polycubectl bridge br3 ports del link51 - -#sleeping -sleep $CONVERGENCE_TIME - -# test ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link42 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link21 - -test_forwarding_pcn br3 link22 -test_forwarding_pcn br3 link31 - -test_blocking_pcn br4 link32 -test_forwarding_pcn br4 link41 - - -# change topology -bridge_add_port br2 link51 -bridge_add_port br4 link52 - -#sleeping -sleep $CONVERGENCE_TIME - -# test ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link42 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link21 -test_forwarding_pcn br2 link51 - -test_forwarding_pcn br3 link22 - -test_forwarding_pcn br4 link52 -test_blocking_pcn br4 link41 - -macbr4=$(get_bridge_mac_pcn br4) -macbr3=$(get_bridge_mac_pcn br3) - -if [[ $macbr4 < $macbr3 ]]; then - test_forwarding_pcn br4 link32 - test_blocking_pcn br3 link31 -else - test_blocking_pcn br4 link32 - test_forwarding_pcn br3 link31 -fi - - -# change topology -set_br_priority br4 36864 - -#sleeping -sleep $CONVERGENCE_TIME - -# test ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link42 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link21 -test_forwarding_pcn br2 link51 - -test_forwarding_pcn br3 link22 - -test_forwarding_pcn br4 link52 -test_blocking_pcn br4 link41 - -test_blocking_pcn br4 link32 -test_forwarding_pcn br3 link31 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn/test46.sh b/src/services/pcn-bridge/test/stp/stp_pcn/test46.sh deleted file mode 100755 index f1b6aa9f0..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn/test46.sh +++ /dev/null @@ -1,118 +0,0 @@ -#! /bin/bash - -# 4 pcn-bridge; square topology; -# connect extra links between bridges 1-3 2-4 -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 4 - delete_veth 4 - delete_link 6 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 4 -create_link 6 - -set -e - -add_bridges_stp 4 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 28672 -bridge_add_port br1 link42 - -bridge_add_port br2 link12 -set_br_priority br2 24576 -bridge_add_port br2 link21 - -bridge_add_port br3 link22 -set_br_priority br3 32768 -bridge_add_port br3 link31 - -bridge_add_port br4 link32 -set_br_priority br4 36864 -bridge_add_port br4 link41 - - -bridge_add_port br1 link51 -bridge_add_port br3 link52 -bridge_add_port br2 link61 -bridge_add_port br4 link62 - -bridge_add_port br1 veth1 -bridge_add_port br2 veth2 -bridge_add_port br3 veth3 -bridge_add_port br4 veth4 - -#sleeping -sleep $CONVERGENCE_TIME - -# test ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link42 -test_forwarding_pcn br1 link51 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link21 -test_forwarding_pcn br2 link61 - -test_forwarding_pcn br3 link22 -test_forwarding_pcn br3 link31 -test_blocking_pcn br3 link52 - -test_blocking_pcn br4 link32 -test_blocking_pcn br4 link41 -test_forwarding_pcn br4 link62 - - -# change topology -polycubectl bridge br1 ports del link42 -polycubectl bridge br4 ports del link41 - -#sleeping -sleep $CONVERGENCE_TIME - -# test ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link51 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link21 -test_forwarding_pcn br2 link61 - -test_forwarding_pcn br3 link22 -test_forwarding_pcn br3 link31 -test_blocking_pcn br3 link52 - -test_blocking_pcn br4 link32 -test_forwarding_pcn br4 link62 - - - -# change topology -polycubectl bridge br2 ports del link21 -polycubectl bridge br3 ports del link22 - -#sleeping -sleep $CONVERGENCE_TIME - -# test ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link51 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link61 - -test_blocking_pcn br3 link31 -test_forwarding_pcn br3 link52 - -test_forwarding_pcn br4 link32 -test_forwarding_pcn br4 link62 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn/test47.sh b/src/services/pcn-bridge/test/stp/stp_pcn/test47.sh deleted file mode 100755 index d2f782fa5..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn/test47.sh +++ /dev/null @@ -1,99 +0,0 @@ -#! /bin/bash - -# 5 pcn-bridge; square topology(1,2,3,4) + triangle(2,3,5) ; -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 5 - delete_veth 5 - delete_link 6 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 5 -create_link 6 - -set -e - -add_bridges_stp 5 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 28672 -bridge_add_port br1 link42 - -bridge_add_port br2 link12 -set_br_priority br2 24576 -bridge_add_port br2 link21 - -bridge_add_port br3 link22 -set_br_priority br3 32768 -bridge_add_port br3 link31 - -bridge_add_port br4 link32 -set_br_priority br4 36864 -bridge_add_port br4 link41 - -bridge_add_port br5 link52 -set_br_priority br5 36864 -bridge_add_port br5 link61 -bridge_add_port br2 link51 -bridge_add_port br3 link62 - -bridge_add_port br1 veth1 -bridge_add_port br2 veth2 -bridge_add_port br3 veth3 -bridge_add_port br4 veth4 -bridge_add_port br5 veth5 - -#sleeping -sleep $CONVERGENCE_TIME - -# test ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link42 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link21 -test_forwarding_pcn br2 link51 - -test_forwarding_pcn br3 link22 -test_forwarding_pcn br3 link31 -test_forwarding_pcn br3 link62 - -test_blocking_pcn br4 link32 -test_forwarding_pcn br4 link41 - -test_blocking_pcn br5 link61 -test_forwarding_pcn br5 link52 - - -# change topology -polycubectl bridge br2 ports del link21 -polycubectl bridge br3 ports del link22 -set_br_priority br4 32768 - -#sleeping -sleep $CONVERGENCE_TIME - -# test ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link42 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link51 - -test_blocking_pcn br3 link31 -test_forwarding_pcn br3 link62 - -test_forwarding_pcn br4 link32 -test_forwarding_pcn br4 link41 - -test_forwarding_pcn br5 link61 -test_forwarding_pcn br5 link52 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test51.sh b/src/services/pcn-bridge/test/stp/stp_pcn_lb/test51.sh deleted file mode 100755 index 64b116762..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test51.sh +++ /dev/null @@ -1,48 +0,0 @@ -#! /bin/bash - -# 3 pcn-bridge; triangle topology -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 2 - del_bridges_lb 3 3 - delete_veth 3 - delete_link 3 -} -trap cleanup EXIT - -set -x - -# setup -create_veth 3 -create_link 3 - -set -e - -add_bridges_stp 2 -add_bridges_lb 3 3 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 24576 -bridge_add_port br1 link32 -bridge_add_port br1 veth1 - -bridge_add_port br2 link12 -set_br_priority br2 28672 -bridge_add_port br2 link21 -bridge_add_port br2 veth2 - -bridge_add_port_lb br3 link22 -bridge_add_port_lb br3 link31 -bridge_add_port_lb br3 veth3 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 3 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test52.sh b/src/services/pcn-bridge/test/stp/stp_pcn_lb/test52.sh deleted file mode 100755 index 3b4c958a8..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test52.sh +++ /dev/null @@ -1,51 +0,0 @@ -#! /bin/bash - -# 3 pcn-bridge; triangle topology; connect one extra link br1-br2 -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 1 - del_bridges_lb 2 3 - delete_veth 3 - delete_link 4 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 3 -create_link 4 - -set -e - -add_bridges_stp 1 -add_bridges_lb 2 3 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 24576 -bridge_add_port br1 link32 -bridge_add_port br1 veth1 - -bridge_add_port_lb br2 link12 -set_br_priority_lb br2 28672 -bridge_add_port_lb br2 link21 -bridge_add_port_lb br2 veth2 - -bridge_add_port_lb br3 link22 -bridge_add_port_lb br3 link31 -bridge_add_port_lb br3 veth3 - -bridge_add_port br1 link41 -bridge_add_port_lb br2 link42 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 3 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test53.sh b/src/services/pcn-bridge/test/stp/stp_pcn_lb/test53.sh deleted file mode 100755 index 657bcd908..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test53.sh +++ /dev/null @@ -1,58 +0,0 @@ -#! /bin/bash - -# 3 pcn-bridge; triangle topology; -# connect extra links between bridges -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 2 - del_bridges_lb 3 3 - delete_veth 3 - delete_link 6 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 3 -create_link 6 - -set -e - -add_bridges_stp 2 -add_bridges_lb 3 3 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 24576 -bridge_add_port br1 link32 -bridge_add_port br1 veth1 - -bridge_add_port br2 link12 -set_br_priority br2 28672 -bridge_add_port br2 link21 -bridge_add_port br2 veth2 - -bridge_add_port_lb br3 link22 -bridge_add_port_lb br3 link31 -bridge_add_port_lb br3 veth3 - -bridge_add_port br1 link41 -bridge_add_port br2 link42 - -bridge_add_port br2 link51 -bridge_add_port_lb br3 link52 - -bridge_add_port_lb br3 link61 -bridge_add_port br1 link62 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 3 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test55.sh b/src/services/pcn-bridge/test/stp/stp_pcn_lb/test55.sh deleted file mode 100755 index 4c6e671f4..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test55.sh +++ /dev/null @@ -1,55 +0,0 @@ -#! /bin/bash - -# 4 pcn-bridge; square topology; -# connect extra links between bridges 3-4 -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 2 - del_bridges_lb 3 4 - delete_veth 4 - delete_link 5 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 4 -create_link 5 - -set -e - -add_bridges_stp 2 -add_bridges_lb 3 4 - -# create ports -bridge_add_port br1 link11 -polycubectl bridge br1 stp 1 set priority=28672 -bridge_add_port br1 link42 -bridge_add_port br1 veth1 - -bridge_add_port br2 link12 -polycubectl bridge br2 stp 1 set priority=24576 -bridge_add_port br2 link21 -bridge_add_port br2 veth2 - -bridge_add_port_lb br3 link22 -bridge_add_port_lb br3 link31 -bridge_add_port_lb br3 link51 -bridge_add_port_lb br3 veth3 - -bridge_add_port_lb br4 link32 -bridge_add_port_lb br4 link41 -bridge_add_port_lb br4 link52 -bridge_add_port_lb br4 veth4 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 4 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test56.sh b/src/services/pcn-bridge/test/stp/stp_pcn_lb/test56.sh deleted file mode 100755 index 9642511d1..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test56.sh +++ /dev/null @@ -1,63 +0,0 @@ -#! /bin/bash - -# 4 pcn-bridge; square topology; -# connect extra links between bridges 1-3 2-4 -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 2 - del_bridges_lb 3 4 - delete_veth 4 - delete_link 6 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 4 -create_link 6 - -set -e - -add_bridges_stp 2 -add_bridges_lb 3 4 - -set_br_priority_lb br3 32768 -set_br_priority_lb br4 36864 - -# create ports -bridge_add_port br1 link11 -polycubectl bridge br1 stp 1 set priority=28672 -bridge_add_port br1 link42 - -bridge_add_port br2 link12 -polycubectl bridge br2 stp 1 set priority=24576 -bridge_add_port br2 link21 - -bridge_add_port_lb br3 link22 -bridge_add_port_lb br3 link31 - -bridge_add_port_lb br4 link32 -bridge_add_port_lb br4 link41 - - -bridge_add_port br1 link51 -bridge_add_port_lb br3 link52 -bridge_add_port br2 link61 -bridge_add_port_lb br4 link62 - -bridge_add_port br1 veth1 -bridge_add_port br2 veth2 -bridge_add_port_lb br3 veth3 -bridge_add_port_lb br4 veth4 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 4 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test57.sh b/src/services/pcn-bridge/test/stp/stp_pcn_lb/test57.sh deleted file mode 100755 index fafc8594e..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test57.sh +++ /dev/null @@ -1,63 +0,0 @@ -#! /bin/bash - -# 5 pcn-bridge; square topology(1,2,3,4) + triangle(2,3,5) ; -# test connectivity, after convergence -# 1-3 polycube ; 4-5 lb - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 3 - del_bridges_lb 4 5 - delete_veth 5 - delete_link 6 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 5 -create_link 6 - -set -e - -add_bridges_stp 3 -add_bridges_lb 4 5 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 28672 -bridge_add_port br1 link42 - -bridge_add_port br2 link12 -set_br_priority br2 24576 -bridge_add_port br2 link21 - -bridge_add_port br3 link22 -set_br_priority br3 32768 -bridge_add_port br3 link31 - -bridge_add_port_lb br4 link32 -set_br_priority_lb br4 36864 -bridge_add_port_lb br4 link41 - -bridge_add_port_lb br5 link52 -set_br_priority_lb br5 36864 -bridge_add_port_lb br5 link61 -bridge_add_port br2 link51 -bridge_add_port br3 link62 - -bridge_add_port br1 veth1 -bridge_add_port br2 veth2 -bridge_add_port br3 veth3 -bridge_add_port_lb br4 veth4 -bridge_add_port_lb br5 veth5 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 5 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test61.sh b/src/services/pcn-bridge/test/stp/stp_pcn_lb/test61.sh deleted file mode 100755 index 8b735003c..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test61.sh +++ /dev/null @@ -1,58 +0,0 @@ -#! /bin/bash - -# 3 pcn-bridge; triangle topology -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 2 - del_bridges_lb 3 3 - delete_veth 3 - delete_link 3 -} -trap cleanup EXIT - -set -x - -# setup -create_veth 3 -create_link 3 - -set -e - -add_bridges_stp 2 -add_bridges_lb 3 3 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 24576 -bridge_add_port br1 link32 -bridge_add_port br1 veth1 - -bridge_add_port br2 link12 -set_br_priority br2 28672 -bridge_add_port br2 link21 -bridge_add_port br2 veth2 - -bridge_add_port_lb br3 link22 -bridge_add_port_lb br3 link31 -bridge_add_port_lb br3 veth3 - -#sleeping -sleep $CONVERGENCE_TIME - -#testing connectivity -ping_cycle 3 - - -# change topology -polycubectl bridge br1 ports del link32 -sudo brctl delif br3 link31 - -#sleeping -sleep $CONVERGENCE_TIME - -#testing connectivity -ping_cycle 3 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test62.sh b/src/services/pcn-bridge/test/stp/stp_pcn_lb/test62.sh deleted file mode 100755 index 566f36507..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test62.sh +++ /dev/null @@ -1,76 +0,0 @@ -#! /bin/bash - -# 3 pcn-bridge; triangle topology; connect one extra link br1-br2 -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 1 - del_bridges_lb 2 3 - delete_veth 3 - delete_link 4 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 3 -create_link 4 - -set -e - -add_bridges_stp 1 -add_bridges_lb 2 3 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 24576 -bridge_add_port br1 link32 -bridge_add_port br1 veth1 - -bridge_add_port_lb br2 link12 -set_br_priority_lb br2 28672 -bridge_add_port_lb br2 link21 -bridge_add_port_lb br2 veth2 - -bridge_add_port_lb br3 link22 -bridge_add_port_lb br3 link31 -bridge_add_port_lb br3 veth3 - -bridge_add_port br1 link41 -bridge_add_port_lb br2 link42 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 3 - -# change topology -polycubectl bridge br1 ports del link11 -sudo brctl delif br2 link12 -# polycubectl bridge br2 ports del link12 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 3 - - -# change topology -polycubectl bridge br1 ports del link32 -sudo brctl delif br3 link31 -# polycubectl bridge br3 ports del link31 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 3 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test63.sh b/src/services/pcn-bridge/test/stp/stp_pcn_lb/test63.sh deleted file mode 100755 index 3a2a0499d..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test63.sh +++ /dev/null @@ -1,75 +0,0 @@ -#! /bin/bash - -# 3 pcn-bridge; triangle topology; -# connect extra links between bridges -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 2 - del_bridges_lb 3 3 - delete_veth 3 - delete_link 6 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 3 -create_link 6 - -set -e - -add_bridges_stp 2 -add_bridges_lb 3 3 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 24576 -bridge_add_port br1 link32 -bridge_add_port br1 veth1 - -bridge_add_port br2 link12 -set_br_priority br2 28672 -bridge_add_port br2 link21 -bridge_add_port br2 veth2 - -bridge_add_port_lb br3 link22 -bridge_add_port_lb br3 link31 -bridge_add_port_lb br3 veth3 - -bridge_add_port br1 link41 -bridge_add_port br2 link42 - -bridge_add_port br2 link51 -bridge_add_port_lb br3 link52 - -bridge_add_port_lb br3 link61 -bridge_add_port br1 link62 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 3 - -# change topology -polycubectl bridge br1 ports del link11 -polycubectl bridge br2 ports del link12 - -polycubectl bridge br2 ports del link21 -sudo brctl delif br3 link22 - -sudo brctl delif br3 link31 -polycubectl bridge br1 ports del link32 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 3 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test65.sh b/src/services/pcn-bridge/test/stp/stp_pcn_lb/test65.sh deleted file mode 100755 index 673b200d4..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test65.sh +++ /dev/null @@ -1,79 +0,0 @@ -#! /bin/bash - -# 4 pcn-bridge; square topology; -# connect extra links between bridges 3-4 -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 2 - del_bridges_lb 3 4 - delete_veth 4 - delete_link 5 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 4 -create_link 5 - -set -e - -add_bridges_stp 2 -add_bridges_lb 3 4 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 28672 -bridge_add_port br1 link42 -bridge_add_port br1 veth1 - -bridge_add_port br2 link12 -set_br_priority br2 24576 -bridge_add_port br2 link21 -bridge_add_port br2 veth2 - -bridge_add_port_lb br3 link22 -bridge_add_port_lb br3 link31 -bridge_add_port_lb br3 link51 -bridge_add_port_lb br3 veth3 - -bridge_add_port_lb br4 link32 -bridge_add_port_lb br4 link41 -bridge_add_port_lb br4 link52 -bridge_add_port_lb br4 veth4 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 4 - - -# change topology -sudo brctl delif br4 link52 -sudo brctl delif br3 link51 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 4 - - -# change topology -bridge_add_port br2 link51 -bridge_add_port_lb br4 link52 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 4 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test66.sh b/src/services/pcn-bridge/test/stp/stp_pcn_lb/test66.sh deleted file mode 100755 index 84788510b..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test66.sh +++ /dev/null @@ -1,86 +0,0 @@ -#! /bin/bash - -# 4 pcn-bridge; square topology; -# connect extra links between bridges 1-3 2-4 -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 2 - del_bridges_lb 3 4 - delete_veth 4 - delete_link 6 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 4 -create_link 6 - -set -e - -add_bridges_stp 2 -add_bridges_lb 3 4 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 28672 -bridge_add_port br1 link42 - -bridge_add_port br2 link12 -set_br_priority br2 24576 -bridge_add_port br2 link21 - -bridge_add_port_lb br3 link22 -set_br_priority_lb br3 32768 -bridge_add_port_lb br3 link31 - -bridge_add_port_lb br4 link32 -set_br_priority_lb br4 36864 -bridge_add_port_lb br4 link41 - - -bridge_add_port br1 link51 -bridge_add_port_lb br3 link52 -bridge_add_port br2 link61 -bridge_add_port_lb br4 link62 - -bridge_add_port br1 veth1 -bridge_add_port br2 veth2 -bridge_add_port_lb br3 veth3 -bridge_add_port_lb br4 veth4 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 4 - - -# change topology -polycubectl bridge br1 ports del link42 -sudo brctl delif br4 link41 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 4 - - -# change topology -polycubectl bridge br2 ports del link21 -sudo brctl delif br3 link22 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 4 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test67.sh b/src/services/pcn-bridge/test/stp/stp_pcn_lb/test67.sh deleted file mode 100755 index 4f9266e35..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test67.sh +++ /dev/null @@ -1,74 +0,0 @@ -#! /bin/bash - -# 5 pcn-bridge; square topology(1,2,3,4) + triangle(2,3,5) ; -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 3 - del_bridges_lb 4 5 - delete_veth 5 - delete_link 6 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 5 -create_link 6 - -set -e - -add_bridges_stp 3 -add_bridges_lb 4 5 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 28672 -bridge_add_port br1 link42 - -bridge_add_port br2 link12 -set_br_priority br2 24576 -bridge_add_port br2 link21 - -bridge_add_port br3 link22 -set_br_priority br3 32768 -bridge_add_port br3 link31 - -bridge_add_port_lb br4 link32 -set_br_priority_lb br4 36864 -bridge_add_port_lb br4 link41 - -bridge_add_port_lb br5 link52 -set_br_priority_lb br5 36864 -bridge_add_port_lb br5 link61 -bridge_add_port br2 link51 -bridge_add_port br3 link62 - -bridge_add_port br1 veth1 -bridge_add_port br2 veth2 -bridge_add_port br3 veth3 -bridge_add_port_lb br4 veth4 -bridge_add_port_lb br5 veth5 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 5 - - -# change topology -polycubectl bridge br2 ports del link21 -polycubectl bridge br3 ports del link22 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing connectivity -ping_cycle 5 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test71.sh b/src/services/pcn-bridge/test/stp/stp_pcn_lb/test71.sh deleted file mode 100755 index 320d4bc9f..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test71.sh +++ /dev/null @@ -1,55 +0,0 @@ -#! /bin/bash - -# 3 pcn-bridge; triangle topology -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 2 - del_bridges_lb 3 3 - delete_veth 3 - delete_link 3 -} -trap cleanup EXIT - -set -x - -# setup -create_veth 3 -create_link 3 - -set -e - -add_bridges_stp 2 -add_bridges_lb 3 3 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 24576 -bridge_add_port br1 link32 -bridge_add_port br1 veth1 - -bridge_add_port br2 link12 -set_br_priority br2 28672 -bridge_add_port br2 link21 -bridge_add_port br2 veth2 - -bridge_add_port_lb br3 link22 -bridge_add_port_lb br3 link31 -bridge_add_port_lb br3 veth3 - -#sleeping -sleep $CONVERGENCE_TIME - - -#testing ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link32 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link21 - -test_forwarding_lb br3 link31 -test_blocking_lb br3 link22 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test72.sh b/src/services/pcn-bridge/test/stp/stp_pcn_lb/test72.sh deleted file mode 100755 index 6aa4f523f..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test72.sh +++ /dev/null @@ -1,61 +0,0 @@ -#! /bin/bash - -# 3 pcn-bridge; triangle topology; connect one extra link br1-br2 -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 1 - del_bridges_lb 2 3 - delete_veth 3 - delete_link 4 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 3 -create_link 4 - -set -e - -add_bridges_stp 1 -add_bridges_lb 2 3 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 24576 -bridge_add_port br1 link32 -bridge_add_port br1 veth1 - -bridge_add_port_lb br2 link12 -set_br_priority_lb br2 28672 -bridge_add_port_lb br2 link21 -bridge_add_port_lb br2 veth2 - -bridge_add_port_lb br3 link22 -bridge_add_port_lb br3 link31 -bridge_add_port_lb br3 veth3 - -bridge_add_port br1 link41 -bridge_add_port_lb br2 link42 - -#sleeping -sleep $CONVERGENCE_TIME - - -# testing ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link32 - -test_forwarding_lb br2 link12 -test_forwarding_lb br2 link21 - -test_forwarding_lb br3 link31 -test_blocking_lb br3 link22 - -test_forwarding_pcn br1 link41 -test_blocking_lb br2 link42 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test73.sh b/src/services/pcn-bridge/test/stp/stp_pcn_lb/test73.sh deleted file mode 100755 index e0792441b..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test73.sh +++ /dev/null @@ -1,74 +0,0 @@ -#! /bin/bash - -# 3 pcn-bridge; triangle topology; -# connect extra links between bridges -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 2 - del_bridges_lb 3 3 - delete_veth 3 - delete_link 6 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 3 -create_link 6 - -set -e - -add_bridges_stp 2 -add_bridges_lb 3 3 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 24576 -bridge_add_port br1 link32 -bridge_add_port br1 veth1 - -bridge_add_port br2 link12 -set_br_priority br2 28672 -bridge_add_port br2 link21 -bridge_add_port br2 veth2 - -bridge_add_port_lb br3 link22 -bridge_add_port_lb br3 link31 -bridge_add_port_lb br3 veth3 - -bridge_add_port br1 link41 -bridge_add_port br2 link42 - -bridge_add_port br2 link51 -bridge_add_port_lb br3 link52 - -bridge_add_port_lb br3 link61 -bridge_add_port br1 link62 - -#sleeping -sleep $CONVERGENCE_TIME - - -# testing ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link32 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link21 - -test_forwarding_lb br3 link31 -test_blocking_lb br3 link22 - -test_forwarding_pcn br1 link41 -test_forwarding_pcn br1 link62 - -test_blocking_pcn br2 link42 -test_forwarding_pcn br2 link51 - -test_blocking_lb br3 link52 -test_blocking_lb br3 link61 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test75.sh b/src/services/pcn-bridge/test/stp/stp_pcn_lb/test75.sh deleted file mode 100755 index 76ae29491..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test75.sh +++ /dev/null @@ -1,67 +0,0 @@ -#! /bin/bash - -# 4 pcn-bridge; square topology; -# connect extra links between bridges 3-4 -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 2 - del_bridges_lb 3 4 - delete_veth 4 - delete_link 5 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 4 -create_link 5 - -set -e - -add_bridges_stp 2 -add_bridges_lb 3 4 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 28672 -bridge_add_port br1 link42 -bridge_add_port br1 veth1 - -bridge_add_port br2 link12 -set_br_priority br2 24576 -bridge_add_port br2 link21 -bridge_add_port br2 veth2 - -bridge_add_port_lb br3 link22 -bridge_add_port_lb br3 link31 -bridge_add_port_lb br3 link51 -bridge_add_port_lb br3 veth3 - -bridge_add_port_lb br4 link32 -bridge_add_port_lb br4 link41 -bridge_add_port_lb br4 link52 -bridge_add_port_lb br4 veth4 - -#sleeping -sleep $CONVERGENCE_TIME - - -# test ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link42 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link21 - -test_forwarding_lb br3 link22 -test_forwarding_lb br3 link31 -test_forwarding_lb br3 link51 - -test_blocking_lb br4 link32 -test_forwarding_lb br4 link41 -test_blocking_lb br4 link52 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test76.sh b/src/services/pcn-bridge/test/stp/stp_pcn_lb/test76.sh deleted file mode 100755 index 63dd831bb..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test76.sh +++ /dev/null @@ -1,77 +0,0 @@ -#! /bin/bash - -# 4 pcn-bridge; square topology; -# connect extra links between bridges 1-3 2-4 -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 2 - del_bridges_lb 3 4 - delete_veth 4 - delete_link 6 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 4 -create_link 6 - -set -e - -add_bridges_stp 2 -add_bridges_lb 3 4 - -set_br_priority_lb br3 32768 -set_br_priority_lb br4 36864 - -# create ports -bridge_add_port br1 link11 -polycubectl bridge br1 stp 1 set priority=28672 -bridge_add_port br1 link42 - -bridge_add_port br2 link12 -polycubectl bridge br2 stp 1 set priority=24576 -bridge_add_port br2 link21 - -bridge_add_port_lb br3 link22 -bridge_add_port_lb br3 link31 - -bridge_add_port_lb br4 link32 -bridge_add_port_lb br4 link41 - - -bridge_add_port br1 link51 -bridge_add_port_lb br3 link52 -bridge_add_port br2 link61 -bridge_add_port_lb br4 link62 - -bridge_add_port br1 veth1 -bridge_add_port br2 veth2 -bridge_add_port_lb br3 veth3 -bridge_add_port_lb br4 veth4 - -#sleeping -sleep $CONVERGENCE_TIME - - -# test ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link42 -test_forwarding_pcn br1 link51 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link21 -test_forwarding_pcn br2 link61 - -test_forwarding_lb br3 link22 -test_forwarding_lb br3 link31 -test_blocking_lb br3 link52 - -test_blocking_lb br4 link32 -test_blocking_lb br4 link41 -test_forwarding_lb br4 link62 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test77.sh b/src/services/pcn-bridge/test/stp/stp_pcn_lb/test77.sh deleted file mode 100755 index 3101bd40f..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test77.sh +++ /dev/null @@ -1,78 +0,0 @@ -#! /bin/bash - -# 5 pcn-bridge; square topology(1,2,3,4) + triangle(2,3,5) ; -# test connectivity, after convergence -# 1-3 polycube ; 4-5 lb - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 3 - del_bridges_lb 4 5 - delete_veth 5 - delete_link 6 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 5 -create_link 6 - -set -e - -add_bridges_stp 3 -add_bridges_lb 4 5 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 28672 -bridge_add_port br1 link42 - -bridge_add_port br2 link12 -set_br_priority br2 24576 -bridge_add_port br2 link21 - -bridge_add_port br3 link22 -set_br_priority br3 32768 -bridge_add_port br3 link31 - -bridge_add_port_lb br4 link32 -set_br_priority_lb br4 36864 -bridge_add_port_lb br4 link41 - -bridge_add_port_lb br5 link52 -set_br_priority_lb br5 36864 -bridge_add_port_lb br5 link61 -bridge_add_port br2 link51 -bridge_add_port br3 link62 - -bridge_add_port br1 veth1 -bridge_add_port br2 veth2 -bridge_add_port br3 veth3 -bridge_add_port_lb br4 veth4 -bridge_add_port_lb br5 veth5 - -#sleeping -sleep $CONVERGENCE_TIME - - -# test ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link42 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link21 -test_forwarding_pcn br2 link51 - -test_forwarding_pcn br3 link22 -test_forwarding_pcn br3 link31 -test_forwarding_pcn br3 link62 - -test_blocking_lb br4 link32 -test_forwarding_lb br4 link41 - -test_blocking_lb br5 link61 -test_forwarding_lb br5 link52 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test81.sh b/src/services/pcn-bridge/test/stp/stp_pcn_lb/test81.sh deleted file mode 100755 index 24c8843fa..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test81.sh +++ /dev/null @@ -1,71 +0,0 @@ -#! /bin/bash - -# 3 pcn-bridge; triangle topology -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 2 - del_bridges_lb 3 3 - delete_veth 3 - delete_link 3 -} -trap cleanup EXIT - -set -x - -# setup -create_veth 3 -create_link 3 - -set -e - -add_bridges_stp 2 -add_bridges_lb 3 3 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 24576 -bridge_add_port br1 link32 -bridge_add_port br1 veth1 - -bridge_add_port br2 link12 -set_br_priority br2 28672 -bridge_add_port br2 link21 -bridge_add_port br2 veth2 - -bridge_add_port_lb br3 link22 -bridge_add_port_lb br3 link31 -bridge_add_port_lb br3 veth3 - -#sleeping -sleep $CONVERGENCE_TIME - -#testing ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link32 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link21 - -test_forwarding_lb br3 link31 -test_blocking_lb br3 link22 - - -# change topology -polycubectl bridge br1 ports del link32 -# polycubectl bridge br3 ports del link31 -sudo brctl delif br3 link31 - -#sleeping -sleep $CONVERGENCE_TIME - -#testing ports state -test_forwarding_pcn br1 link11 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link21 - -test_forwarding_lb br3 link22 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test82.sh b/src/services/pcn-bridge/test/stp/stp_pcn_lb/test82.sh deleted file mode 100755 index 607d1a6fc..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test82.sh +++ /dev/null @@ -1,96 +0,0 @@ -#! /bin/bash - -# 3 pcn-bridge; triangle topology; connect one extra link br1-br2 -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 1 - del_bridges_lb 2 3 - delete_veth 3 - delete_link 4 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 3 -create_link 4 - -set -e - -add_bridges_stp 1 -add_bridges_lb 2 3 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 24576 -bridge_add_port br1 link32 -bridge_add_port br1 veth1 - -bridge_add_port_lb br2 link12 -set_br_priority_lb br2 28672 -bridge_add_port_lb br2 link21 -bridge_add_port_lb br2 veth2 - -bridge_add_port_lb br3 link22 -bridge_add_port_lb br3 link31 -bridge_add_port_lb br3 veth3 - -bridge_add_port br1 link41 -bridge_add_port_lb br2 link42 - -#sleeping -sleep $CONVERGENCE_TIME - -# testing ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link32 - -test_forwarding_lb br2 link12 -test_forwarding_lb br2 link21 - -test_forwarding_lb br3 link31 -test_blocking_lb br3 link22 - -test_forwarding_pcn br1 link41 -test_blocking_lb br2 link42 - - -# change topology -polycubectl bridge br1 ports del link11 -sudo brctl delif br2 link12 -# polycubectl bridge br2 ports del link12 - -#sleeping -sleep $CONVERGENCE_TIME - -# testing ports state -test_forwarding_pcn br1 link32 - -test_forwarding_lb br2 link21 - -test_forwarding_lb br3 link31 -test_blocking_lb br3 link22 - -test_forwarding_pcn br1 link41 -test_forwarding_lb br2 link42 - - -# change topology -polycubectl bridge br1 ports del link32 -sudo brctl delif br3 link31 -# polycubectl bridge br3 ports del link31 - -#sleeping -sleep $CONVERGENCE_TIME - -# testing ports state -test_forwarding_lb br2 link21 -test_forwarding_lb br3 link22 - -test_forwarding_pcn br1 link41 -test_forwarding_lb br2 link42 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test83.sh b/src/services/pcn-bridge/test/stp/stp_pcn_lb/test83.sh deleted file mode 100755 index b36233b4f..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test83.sh +++ /dev/null @@ -1,102 +0,0 @@ -#! /bin/bash - -# 3 pcn-bridge; triangle topology; -# connect extra links between bridges -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 2 - del_bridges_lb 3 3 - delete_veth 3 - delete_link 6 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 3 -create_link 6 - -set -e - -add_bridges_stp 2 -add_bridges_lb 3 3 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 24576 -bridge_add_port br1 link32 -bridge_add_port br1 veth1 - -bridge_add_port br2 link12 -set_br_priority br2 28672 -bridge_add_port br2 link21 -bridge_add_port br2 veth2 - -bridge_add_port_lb br3 link22 -bridge_add_port_lb br3 link31 -bridge_add_port_lb br3 veth3 - -bridge_add_port br1 link41 -bridge_add_port br2 link42 - -bridge_add_port br2 link51 -bridge_add_port_lb br3 link52 - -bridge_add_port_lb br3 link61 -bridge_add_port br1 link62 - -#sleeping -sleep $CONVERGENCE_TIME - -# testing ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link32 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link21 - -test_forwarding_lb br3 link31 -test_blocking_lb br3 link22 - -test_forwarding_pcn br1 link41 -test_forwarding_pcn br1 link62 - -test_blocking_pcn br2 link42 -test_forwarding_pcn br2 link51 - -test_blocking_lb br3 link52 -test_blocking_lb br3 link61 - - -# change topology -polycubectl bridge br1 ports del link11 -polycubectl bridge br2 ports del link12 - -polycubectl bridge br2 ports del link21 -sudo brctl delif br3 link22 -# polycubectl bridge br3 ports del link22 - -# polycubectl bridge br3 ports del link31 -sudo brctl delif br3 link31 -polycubectl bridge br1 ports del link32 - -#sleeping -sleep $CONVERGENCE_TIME - -# testing ports state -test_forwarding_pcn br1 link41 -test_forwarding_pcn br1 link62 - -test_forwarding_pcn br2 link42 -test_forwarding_pcn br2 link51 - -test_blocking_lb br3 link52 -test_forwarding_lb br3 link61 - -#testing connectivity -ping_cycle 3 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test85.sh b/src/services/pcn-bridge/test/stp/stp_pcn_lb/test85.sh deleted file mode 100755 index 3691644d2..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test85.sh +++ /dev/null @@ -1,144 +0,0 @@ -#! /bin/bash - -# 4 pcn-bridge; square topology; -# connect extra links between bridges 3-4 -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 2 - del_bridges_lb 3 4 - delete_veth 4 - delete_link 5 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 4 -create_link 5 - -set -e - -add_bridges_stp 2 -add_bridges_lb 3 4 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 28672 -bridge_add_port br1 link42 -bridge_add_port br1 veth1 - -bridge_add_port br2 link12 -set_br_priority br2 24576 -bridge_add_port br2 link21 -bridge_add_port br2 veth2 - -bridge_add_port_lb br3 link22 -bridge_add_port_lb br3 link31 -bridge_add_port_lb br3 link51 -bridge_add_port_lb br3 veth3 - -bridge_add_port_lb br4 link32 -bridge_add_port_lb br4 link41 -bridge_add_port_lb br4 link52 -bridge_add_port_lb br4 veth4 - -#sleeping -sleep $CONVERGENCE_TIME - -# test ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link42 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link21 - -test_forwarding_lb br3 link22 -test_forwarding_lb br3 link31 -test_forwarding_lb br3 link51 - -test_blocking_lb br4 link32 -test_forwarding_lb br4 link41 -test_blocking_lb br4 link52 - - -# change topology -# polycubectl bridge br4 ports del link52 -sudo brctl delif br4 link52 -# polycubectl bridge br3 ports del link51 -sudo brctl delif br3 link51 - -#sleeping -sleep $CONVERGENCE_TIME - -# test ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link42 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link21 - -test_forwarding_lb br3 link22 -test_forwarding_lb br3 link31 - -test_blocking_lb br4 link32 -test_forwarding_lb br4 link41 - - -# change topology -bridge_add_port br2 link51 -bridge_add_port_lb br4 link52 - -#sleeping -sleep $CONVERGENCE_TIME - -# test ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link42 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link21 -test_forwarding_pcn br2 link51 - -test_forwarding_lb br3 link22 - -test_forwarding_lb br4 link52 -test_blocking_lb br4 link41 - -macbr4=$(get_bridge_mac_lb br4) -macbr3=$(get_bridge_mac_lb br3) - -if [[ $macbr4 < $macbr3 ]]; then - test_forwarding_lb br4 link32 - test_blocking_lb br3 link31 -else - test_blocking_lb br4 link32 - test_forwarding_lb br3 link31 -fi - - -# change topology -set_br_priority_lb br4 36864 - -#sleeping -sleep $CONVERGENCE_TIME - -# test ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link42 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link21 -test_forwarding_pcn br2 link51 - -test_forwarding_lb br3 link22 - -test_forwarding_lb br4 link52 -test_blocking_lb br4 link41 - -test_blocking_lb br4 link32 -test_forwarding_lb br3 link31 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test86.sh b/src/services/pcn-bridge/test/stp/stp_pcn_lb/test86.sh deleted file mode 100755 index 37c5995de..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test86.sh +++ /dev/null @@ -1,122 +0,0 @@ -#! /bin/bash - -# 4 pcn-bridge; square topology; -# connect extra links between bridges 1-3 2-4 -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 2 - del_bridges_lb 3 4 - delete_veth 4 - delete_link 6 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 4 -create_link 6 - -set -e - -add_bridges_stp 2 -add_bridges_lb 3 4 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 28672 -bridge_add_port br1 link42 - -bridge_add_port br2 link12 -set_br_priority br2 24576 -bridge_add_port br2 link21 - -bridge_add_port_lb br3 link22 -set_br_priority_lb br3 32768 -bridge_add_port_lb br3 link31 - -bridge_add_port_lb br4 link32 -set_br_priority_lb br4 36864 -bridge_add_port_lb br4 link41 - - -bridge_add_port br1 link51 -bridge_add_port_lb br3 link52 -bridge_add_port br2 link61 -bridge_add_port_lb br4 link62 - -bridge_add_port br1 veth1 -bridge_add_port br2 veth2 -bridge_add_port_lb br3 veth3 -bridge_add_port_lb br4 veth4 - -#sleeping -sleep $CONVERGENCE_TIME - -# test ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link42 -test_forwarding_pcn br1 link51 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link21 -test_forwarding_pcn br2 link61 - -test_forwarding_lb br3 link22 -test_forwarding_lb br3 link31 -test_blocking_lb br3 link52 - -test_blocking_lb br4 link32 -test_blocking_lb br4 link41 -test_forwarding_lb br4 link62 - - -# change topology -polycubectl bridge br1 ports del link42 -sudo brctl delif br4 link41 -# polycubectl bridge br4 ports del link41 - -#sleeping -sleep $CONVERGENCE_TIME - -# test ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link51 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link21 -test_forwarding_pcn br2 link61 - -test_forwarding_lb br3 link22 -test_forwarding_lb br3 link31 -test_blocking_lb br3 link52 - -test_blocking_lb br4 link32 -test_forwarding_lb br4 link62 - - - -# change topology -polycubectl bridge br2 ports del link21 -sudo brctl delif br3 link22 - -#sleeping -sleep $CONVERGENCE_TIME -sleep 5 - -# test ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link51 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link61 - -test_blocking_lb br3 link31 -test_forwarding_lb br3 link52 - -test_forwarding_lb br4 link32 -test_forwarding_lb br4 link62 diff --git a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test87.sh b/src/services/pcn-bridge/test/stp/stp_pcn_lb/test87.sh deleted file mode 100755 index d8af625af..000000000 --- a/src/services/pcn-bridge/test/stp/stp_pcn_lb/test87.sh +++ /dev/null @@ -1,102 +0,0 @@ -#! /bin/bash - -# 5 pcn-bridge; square topology(1,2,3,4) + triangle(2,3,5) ; -# test connectivity, after convergence - -source "${BASH_SOURCE%/*}/../../helpers.bash" - -function cleanup { - set +e - del_bridges 3 - del_bridges_lb 4 5 - delete_veth 5 - delete_link 6 -} -trap cleanup EXIT - -set -x - -#setup -create_veth 5 -create_link 6 - -set -e - -add_bridges_stp 3 -add_bridges_lb 4 5 - -# create ports -bridge_add_port br1 link11 -set_br_priority br1 28672 -bridge_add_port br1 link42 - -bridge_add_port br2 link12 -set_br_priority br2 24576 -bridge_add_port br2 link21 - -bridge_add_port br3 link22 -set_br_priority br3 32768 -bridge_add_port br3 link31 - -bridge_add_port_lb br4 link32 -set_br_priority_lb br4 36864 -bridge_add_port_lb br4 link41 - -bridge_add_port_lb br5 link52 -set_br_priority_lb br5 36864 -bridge_add_port_lb br5 link61 -bridge_add_port br2 link51 -bridge_add_port br3 link62 - -bridge_add_port br1 veth1 -bridge_add_port br2 veth2 -bridge_add_port br3 veth3 -bridge_add_port_lb br4 veth4 -bridge_add_port_lb br5 veth5 - -#sleeping -sleep $CONVERGENCE_TIME - -# test ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link42 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link21 -test_forwarding_pcn br2 link51 - -test_forwarding_pcn br3 link22 -test_forwarding_pcn br3 link31 -test_forwarding_pcn br3 link62 - -test_blocking_lb br4 link32 -test_forwarding_lb br4 link41 - -test_blocking_lb br5 link61 -test_forwarding_lb br5 link52 - - -# change topology -polycubectl bridge br2 ports del link21 -polycubectl bridge br3 ports del link22 -set_br_priority_lb br4 32768 - -#sleeping -sleep $CONVERGENCE_TIME -sleep 5 - -# test ports state -test_forwarding_pcn br1 link11 -test_forwarding_pcn br1 link42 - -test_forwarding_pcn br2 link12 -test_forwarding_pcn br2 link51 - -test_blocking_pcn br3 link31 -test_forwarding_pcn br3 link62 - -test_forwarding_lb br4 link32 -test_forwarding_lb br4 link41 - -test_forwarding_lb br5 link61 -test_forwarding_lb br5 link52 diff --git a/src/services/pcn-bridge/test/test106.sh b/src/services/pcn-bridge/test/test106.sh deleted file mode 100755 index 04ab25181..000000000 --- a/src/services/pcn-bridge/test/test106.sh +++ /dev/null @@ -1,28 +0,0 @@ -#! /bin/bash - -# include helper.bash file: used to provide some common function across testing scripts -source "${BASH_SOURCE%/*}/helpers.bash" - -# function cleanup: is invoked each time script exit (with or without errors) -function cleanup { - set +e - del_bridges 1 - delete_link 1 -} -trap cleanup EXIT - -# Enable verbose output -set -x - -# Makes the script exit, at first error -# Errors are thrown by commands returning not 0 value -set -e - -create_link 1 -add_bridges 1 -bridge_add_port br1 link11 -cleanup - -create_link 1 -add_bridges 1 -bridge_add_port br1 link11 diff --git a/src/services/pcn-bridge/test/test107.sh b/src/services/pcn-bridge/test/test107.sh deleted file mode 100755 index df54b23b9..000000000 --- a/src/services/pcn-bridge/test/test107.sh +++ /dev/null @@ -1,28 +0,0 @@ -#! /bin/bash - -# include helper.bash file: used to provide some common function across testing scripts -source "${BASH_SOURCE%/*}/helpers.bash" - -# function cleanup: is invoked each time script exit (with or without errors) -function cleanup { - set +e - del_bridges 1 - delete_link 2 -} -trap cleanup EXIT - -# Enable verbose output -set -x - -# Makes the script exit, at first error -# Errors are thrown by commands returning not 0 value -set -e - -create_link 2 -add_bridges 1 -bridge_add_port br1 link11 -cleanup - -create_link 1 -add_bridges 1 -test_fail bridge_add_port br1 link22 diff --git a/src/services/pcn-bridge/test/vlan/test1.sh b/src/services/pcn-bridge/test/vlan/test1.sh deleted file mode 100755 index c776c22d3..000000000 --- a/src/services/pcn-bridge/test/vlan/test1.sh +++ /dev/null @@ -1,79 +0,0 @@ -#! /bin/bash - -source "${BASH_SOURCE%/*}/../helpers.bash" - -FLAG="TC" - -function cleanup { - set +e - del_bridges 1 - delete_veth 4 -} - -if [ $# -gt 2 ]; then - echo "Wrong number of arguments" - echo "-D for XDP DRIVER MODE" - echo "-S for XDP SKB MODE" - echo "Empty for TC MODE" - exit 1 -fi - -if [ -n "$1" ] && [ "$1" != "-D" ] && [ "$1" != "-S" ]; then - echo "Wrong arguments" - echo "-D for XDP DRIVER MODE" - echo "-S for XDP SKB MODE" - echo "Empty for TC MODE" - exit 1 -fi - -if [ "$1" == "-D" ]; then - FLAG="XDP_DRV" -fi - -if [ "$1" == "-S" ]; then - FLAG="XDP_SKB" -fi - -trap cleanup EXIT -set -x - -# setup -create_veth 4 - -set -e - -add_bridges 1 $FLAG - -bridge_add_port br1 veth1 -bridge_add_port br1 veth2 -bridge_add_port br1 veth3 -bridge_add_port br1 veth4 - -polycubectl bridge br1 ports veth1 access set vlanid="10" -polycubectl bridge br1 ports veth2 access set vlanid="10" - -polycubectl bridge br1 ports veth3 access set vlanid="20" -polycubectl bridge br1 ports veth4 access set vlanid="20" - -#sleeping -#sleep $CONVERGENCE_TIME - -echo "should pass" -sudo ip netns exec ns1 ping 10.0.0.2 -c 2 -i 0.5 -sudo ip netns exec ns2 ping 10.0.0.1 -c 2 -i 0.5 - -sudo ip netns exec ns3 ping 10.0.0.4 -c 2 -i 0.5 -sudo ip netns exec ns4 ping 10.0.0.3 -c 2 -i 0.5 - -echo "+++should fail" -test_fail sudo ip netns exec ns1 ping 10.0.0.3 -c 2 -i 0.5 -w 1 -test_fail sudo ip netns exec ns1 ping 10.0.0.4 -c 2 -i 0.5 -w 1 - -test_fail sudo ip netns exec ns2 ping 10.0.0.3 -c 2 -i 0.5 -w 1 -test_fail sudo ip netns exec ns2 ping 10.0.0.4 -c 2 -i 0.5 -w 1 - -test_fail sudo ip netns exec ns3 ping 10.0.0.1 -c 2 -i 0.5 -w 1 -test_fail sudo ip netns exec ns3 ping 10.0.0.2 -c 2 -i 0.5 -w 1 - -test_fail sudo ip netns exec ns4 ping 10.0.0.1 -c 2 -i 0.5 -w 1 -test_fail sudo ip netns exec ns4 ping 10.0.0.2 -c 2 -i 0.5 -w 1 diff --git a/src/services/pcn-bridge/test/vlan/test2.sh b/src/services/pcn-bridge/test/vlan/test2.sh deleted file mode 100755 index f14249e6e..000000000 --- a/src/services/pcn-bridge/test/vlan/test2.sh +++ /dev/null @@ -1,88 +0,0 @@ -#! /bin/bash - -source "${BASH_SOURCE%/*}/../helpers.bash" - -FLAG="TC" - -function cleanup { - set +e - del_bridges 2 - delete_veth 4 - delete_link 1 -} - -if [ $# -gt 2 ]; then - echo "Wrong number of arguments" - echo "-D for XDP DRIVER MODE" - echo "-S for XDP SKB MODE" - echo "Empty for TC MODE" - exit 1 -fi - -if [ -n "$1" ] && [ "$1" != "-D" ] && [ "$1" != "-S" ]; then - echo "Wrong arguments" - echo "-D for XDP DRIVER MODE" - echo "-S for XDP SKB MODE" - echo "Empty for TC MODE" - exit 1 -fi - -if [ "$1" == "-D" ]; then - FLAG="XDP_DRV" -fi - -if [ "$1" == "-S" ]; then - FLAG="XDP_SKB" -fi - -trap cleanup EXIT -set -x - -# setup -create_veth 4 -create_link 1 - -set -e - -add_bridges 2 $FLAG - -bridge_add_port br1 veth1 -bridge_add_port br1 veth2 -bridge_add_port br1 link11 - -bridge_add_port br2 veth3 -bridge_add_port br2 veth4 -bridge_add_port br2 link12 - -polycubectl bridge br1 ports veth1 access set vlanid="10" -polycubectl bridge br1 ports veth2 access set vlanid="20" - -polycubectl bridge br2 ports veth3 access set vlanid="10" -polycubectl bridge br2 ports veth4 access set vlanid="20" - -polycubectl bridge br1 ports link11 set mode="trunk" -polycubectl bridge br2 ports link12 set mode="trunk" - -polycubectl bridge br1 ports link11 trunk allowed add 10 -polycubectl bridge br1 ports link11 trunk allowed add 20 - -polycubectl bridge br2 ports link12 trunk allowed add 10 -polycubectl bridge br2 ports link12 trunk allowed add 20 - -#sleeping -#sleep $CONVERGENCE_TIME - -echo "should pass" -sudo ip netns exec ns1 ping 10.0.0.3 -c 2 -i 0.5 -sudo ip netns exec ns3 ping 10.0.0.1 -c 2 -i 0.5 - -sudo ip netns exec ns2 ping 10.0.0.4 -c 2 -i 0.5 -sudo ip netns exec ns4 ping 10.0.0.2 -c 2 -i 0.5 - - -echo "+++should fail" -test_fail sudo ip netns exec ns1 ping 10.0.0.4 -c 2 -i 0.5 -w 1 -test_fail sudo ip netns exec ns4 ping 10.0.0.1 -c 2 -i 0.5 -w 1 - -test_fail sudo ip netns exec ns2 ping 10.0.0.3 -c 2 -i 0.5 -w 1 -test_fail sudo ip netns exec ns3 ping 10.0.0.2 -c 2 -i 0.5 -w 1 diff --git a/src/services/pcn-bridge/test/vlan/test3.sh b/src/services/pcn-bridge/test/vlan/test3.sh deleted file mode 100755 index c7ac70022..000000000 --- a/src/services/pcn-bridge/test/vlan/test3.sh +++ /dev/null @@ -1,165 +0,0 @@ -#! /bin/bash - -source "${BASH_SOURCE%/*}/../helpers.bash" - -FLAG="TC" - -function cleanup { - set +e - del_bridges 3 - delete_veth 13 - delete_link 2 -} - -if [ $# -gt 2 ]; then - echo "Wrong number of arguments" - echo "-D for XDP DRIVER MODE" - echo "-S for XDP SKB MODE" - echo "Empty for TC MODE" - exit 1 -fi - -if [ -n "$1" ] && [ "$1" != "-D" ] && [ "$1" != "-S" ]; then - echo "Wrong arguments" - echo "-D for XDP DRIVER MODE" - echo "-S for XDP SKB MODE" - echo "Empty for TC MODE" - exit 1 -fi - -if [ "$1" == "-D" ]; then - FLAG="XDP_DRV" -fi - -if [ "$1" == "-S" ]; then - FLAG="XDP_SKB" -fi - -trap cleanup EXIT -set -x - -# setup -create_veth 13 -create_link 2 - -set -e - -add_bridges 3 $FLAG - -bridge_add_port br1 veth1 -bridge_add_port br1 veth2 -bridge_add_port br1 veth3 -bridge_add_port br1 veth4 -bridge_add_port br1 link11 - -bridge_add_port br2 veth5 -bridge_add_port br2 veth6 -bridge_add_port br2 veth7 -bridge_add_port br2 veth8 -bridge_add_port br2 veth9 - -bridge_add_port br2 link12 -bridge_add_port br2 link21 - -bridge_add_port br3 veth10 -bridge_add_port br3 veth11 -bridge_add_port br3 veth12 -bridge_add_port br3 veth13 -bridge_add_port br3 link22 - -polycubectl bridge br1 ports veth1 access set vlanid="10" -polycubectl bridge br1 ports veth2 access set vlanid="20" -polycubectl bridge br1 ports veth3 access set vlanid="20" -polycubectl bridge br1 ports veth4 access set vlanid="30" - -polycubectl bridge br2 ports veth5 access set vlanid="10" -polycubectl bridge br2 ports veth6 access set vlanid="30" -polycubectl bridge br2 ports veth7 access set vlanid="40" -polycubectl bridge br2 ports veth8 access set vlanid="50" -polycubectl bridge br2 ports veth9 access set vlanid="50" - - -polycubectl bridge br3 ports veth10 access set vlanid="10" -polycubectl bridge br3 ports veth11 access set vlanid="40" -polycubectl bridge br3 ports veth12 access set vlanid="60" -polycubectl bridge br3 ports veth13 access set vlanid="60" - - -polycubectl bridge br1 ports link11 set mode="trunk" -polycubectl bridge br2 ports link12 set mode="trunk" -polycubectl bridge br2 ports link21 set mode="trunk" -polycubectl bridge br3 ports link22 set mode="trunk" - - -polycubectl bridge br1 ports link11 trunk allowed add 10 -polycubectl bridge br1 ports link11 trunk allowed add 30 -polycubectl bridge br2 ports link12 trunk allowed add 10 -polycubectl bridge br2 ports link12 trunk allowed add 30 - -polycubectl bridge br2 ports link21 trunk allowed add 10 -polycubectl bridge br2 ports link21 trunk allowed add 40 -polycubectl bridge br3 ports link22 trunk allowed add 10 -polycubectl bridge br3 ports link22 trunk allowed add 40 - -#sleeping -# sleep $CONVERGENCE_TIME - -echo "" -echo "++should pass++" -echo "++local bridge vlans++" -sudo ip netns exec ns2 ping 10.0.0.3 -c 2 -i 0.5 -sudo ip netns exec ns3 ping 10.0.0.2 -c 2 -i 0.5 - -sudo ip netns exec ns8 ping 10.0.0.9 -c 2 -i 0.5 -sudo ip netns exec ns9 ping 10.0.0.8 -c 2 -i 0.5 - -sudo ip netns exec ns12 ping 10.0.0.13 -c 2 -i 0.5 -sudo ip netns exec ns13 ping 10.0.0.12 -c 2 -i 0.5 - -echo "" -echo "++should pass++" -echo "++vlan10 over all switches++" - -sudo ip netns exec ns1 ping 10.0.0.5 -c 2 -i 0.5 -sudo ip netns exec ns1 ping 10.0.0.10 -c 2 -i 0.5 - -sudo ip netns exec ns5 ping 10.0.0.1 -c 2 -i 0.5 -sudo ip netns exec ns5 ping 10.0.0.10 -c 2 -i 0.5 - -sudo ip netns exec ns10 ping 10.0.0.1 -c 2 -i 0.5 -sudo ip netns exec ns10 ping 10.0.0.5 -c 2 -i 0.5 - -echo "" -echo "++should pass++" -echo "++over 2 bridges++" -sudo ip netns exec ns4 ping 10.0.0.6 -c 2 -i 0.5 -sudo ip netns exec ns6 ping 10.0.0.4 -c 2 -i 0.5 - -sudo ip netns exec ns7 ping 10.0.0.11 -c 2 -i 0.5 -sudo ip netns exec ns11 ping 10.0.0.7 -c 2 -i 0.5 - -echo "" -echo "++should FAIL++" -echo "++should FAIL++" -test_fail sudo ip netns exec ns1 ping 10.0.0.2 -c 2 -i 0.5 -w 1 -test_fail sudo ip netns exec ns1 ping 10.0.0.3 -c 2 -i 0.5 -w 1 -test_fail sudo ip netns exec ns1 ping 10.0.0.4 -c 2 -i 0.5 -w 1 -test_fail sudo ip netns exec ns1 ping 10.0.0.6 -c 2 -i 0.5 -w 1 -test_fail sudo ip netns exec ns1 ping 10.0.0.7 -c 2 -i 0.5 -w 1 -test_fail sudo ip netns exec ns1 ping 10.0.0.8 -c 2 -i 0.5 -w 1 -test_fail sudo ip netns exec ns1 ping 10.0.0.9 -c 2 -i 0.5 -w 1 -test_fail sudo ip netns exec ns4 ping 10.0.0.11 -c 2 -i 0.5 -w 1 -test_fail sudo ip netns exec ns4 ping 10.0.0.12 -c 2 -i 0.5 -w 1 -test_fail sudo ip netns exec ns4 ping 10.0.0.13 -c 2 -i 0.5 -w 1 - -test_fail sudo ip netns exec ns2 ping 10.0.0.1 -c 2 -i 0.5 -w 1 -test_fail sudo ip netns exec ns2 ping 10.0.0.4 -c 2 -i 0.5 -w 1 -test_fail sudo ip netns exec ns2 ping 10.0.0.5 -c 2 -i 0.5 -w 1 -test_fail sudo ip netns exec ns2 ping 10.0.0.6 -c 2 -i 0.5 -w 1 -test_fail sudo ip netns exec ns2 ping 10.0.0.7 -c 2 -i 0.5 -w 1 -test_fail sudo ip netns exec ns2 ping 10.0.0.8 -c 2 -i 0.5 -w 1 -test_fail sudo ip netns exec ns2 ping 10.0.0.9 -c 2 -i 0.5 -w 1 -test_fail sudo ip netns exec ns2 ping 10.0.0.10 -c 2 -i 0.5 -w 1 -test_fail sudo ip netns exec ns2 ping 10.0.0.11 -c 2 -i 0.5 -w 1 -test_fail sudo ip netns exec ns2 ping 10.0.0.12 -c 2 -i 0.5 -w 1 -test_fail sudo ip netns exec ns2 ping 10.0.0.13 -c 2 -i 0.5 -w 1