diff --git a/lte/gateway/c/core/oai/test/sgw_s8_task/CMakeLists.txt b/lte/gateway/c/core/oai/test/sgw_s8_task/CMakeLists.txt index ed15816b7fc6..596f0b9fee41 100644 --- a/lte/gateway/c/core/oai/test/sgw_s8_task/CMakeLists.txt +++ b/lte/gateway/c/core/oai/test/sgw_s8_task/CMakeLists.txt @@ -19,6 +19,7 @@ include_directories("${PROJECT_SOURCE_DIR}/tasks/sgw_s8") set(SGW_S8_TEST_CONFIG_SRC sgw_s8_test.cpp sgw_csr.cpp + sgw_open_flow_controller.cpp ) add_executable(sgw_s8_test ${SGW_S8_TEST_CONFIG_SRC}) diff --git a/lte/gateway/c/core/oai/test/sgw_s8_task/sgw_open_flow_controller.cpp b/lte/gateway/c/core/oai/test/sgw_s8_task/sgw_open_flow_controller.cpp new file mode 100644 index 000000000000..8b4ec4734873 --- /dev/null +++ b/lte/gateway/c/core/oai/test/sgw_s8_task/sgw_open_flow_controller.cpp @@ -0,0 +1,80 @@ +/** + * Copyright 2020 The Magma Authors. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. + * + * 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 +extern "C" { +#include "log.h" +#include "sgw_s8_s11_handlers.h" +#include "sgw_handlers.h" +#include "spgw_types.h" +#include "s11_messages_types.h" +#include "common_types.h" +#include "sgw_config.h" +#include "dynamic_memory_check.h" +#include "sgw_context_manager.h" +#include "gtpv1u.h" +} + +using ::testing::Test; +spgw_config_t spgw_config; + +const struct gtp_tunnel_ops* gtp_tunnel_ops; +void initialize_gtpv1u(void) { + int rv = 0; + struct in_addr netaddr; + uint32_t netmask = 0; + int fd0 = 2; + int fd1 = 5; + int mtu = 1024; + gtp_tunnel_ops = gtp_tunnel_ops_init_openflow(); + if (gtp_tunnel_ops == NULL) { + OAILOG_CRITICAL(LOG_GTPV1U, "ERROR in initializing gtp_tunnel_ops\n"); + return; + } + // Reset GTP tunnel states + rv = gtp_tunnel_ops->reset(); + if (rv != 0) { + OAILOG_CRITICAL(LOG_GTPV1U, "ERROR clean existing gtp states.\n"); + return; + } + netaddr.s_addr = INADDR_ANY; + netmask = 0; + // Init GTP device, using the same MTU as SGi. + gtp_tunnel_ops->init(&netaddr, netmask, mtu, &fd0, &fd1, false); + + // END-GTP quick integration only for evaluation purpose + + OAILOG_DEBUG(LOG_GTPV1U, "Initializing GTPV1U interface: DONE\n"); + return; +} + +void uninitialize_gtpv1u(void) { + gtp_tunnel_ops->uninit(); + OAILOG_DEBUG(LOG_GTPV1U, "Uninitializing GTPV1U interface: DONE\n"); + return; +} + +TEST(SGW_S8_OVSTest, openflowControllerStartAndStop) { + spgw_config.pgw_config.enable_nat = false; + spgw_config.sgw_config.ovs_config.uplink_port_num = 2; + + spgw_config.sgw_config.ovs_config.uplink_mac = + bfromcstr_with_str_len("ff:ff:ff:ff:ff:ff", strlen("ff:ff:ff:ff:ff:ff")); + spgw_config.sgw_config.ovs_config.gtp_port_num = 32768; + spgw_config.sgw_config.ovs_config.mtr_port_num = 15577; + spgw_config.sgw_config.ovs_config.internal_sampling_port_num = 15578; + spgw_config.sgw_config.ovs_config.internal_sampling_fwd_tbl_num = 201; + initialize_gtpv1u(); + bdestroy_wrapper(&spgw_config.sgw_config.ovs_config.uplink_mac); + uninitialize_gtpv1u(); +}