aboutsummaryrefslogtreecommitdiffstats
path: root/src/scvpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'src/scvpp/src')
-rw-r--r--src/scvpp/src/comm.c191
-rw-r--r--src/scvpp/src/interface.c182
-rw-r--r--src/scvpp/src/ip.c259
-rw-r--r--src/scvpp/src/nat.c294
-rw-r--r--src/scvpp/src/v3po.c89
5 files changed, 0 insertions, 1015 deletions
diff --git a/src/scvpp/src/comm.c b/src/scvpp/src/comm.c
deleted file mode 100644
index 11ed8a9..0000000
--- a/src/scvpp/src/comm.c
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright (c) 2018 HUACHENTEL and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <scvpp/comm.h>
-
-#include <stdio.h>
-#include <dirent.h>
-
-#define APP_NAME "sweetcomb_vpp"
-#define MAX_OUTSTANDING_REQUESTS 4
-#define RESPONSE_QUEUE_SIZE 2
-
-sc_vpp_main_t sc_vpp_main = {
- .vapi_ctx = NULL,
- .vapi_mode = VAPI_MODE_BLOCKING,
- .pid = 0
-};
-
-sc_vpp_main_t *sc_connect_vpp()
-{
- vapi_error_e rv;
-
- if (sc_vpp_main.vapi_ctx == NULL) {
- if ((rv = vapi_ctx_alloc(&sc_vpp_main.vapi_ctx)) != VAPI_OK) {
- return NULL;
- }
-
- if ((rv =
- vapi_connect(sc_vpp_main.vapi_ctx, APP_NAME, NULL,
- MAX_OUTSTANDING_REQUESTS, RESPONSE_QUEUE_SIZE,
- sc_vpp_main.vapi_mode, true)) != VAPI_OK) {
- vapi_ctx_free(sc_vpp_main.vapi_ctx);
- sc_vpp_main.vapi_ctx = NULL;
- return NULL;
- }
- }
-
- sc_vpp_main.pid = sc_get_vpp_pid();
- pthread_mutex_init(&sc_vpp_main.vapi_lock, NULL);
- return &sc_vpp_main;
-}
-
-void sc_disconnect_vpp()
-{
- if (NULL != sc_vpp_main.vapi_ctx) {
- pthread_mutex_destroy(&sc_vpp_main.vapi_lock);
- sc_vpp_main.pid = 0;
- vapi_disconnect(sc_vpp_main.vapi_ctx);
- vapi_ctx_free(sc_vpp_main.vapi_ctx);
- sc_vpp_main.vapi_ctx = NULL;
- }
-}
-
-/* get vpp pid in system */
-pid_t sc_get_vpp_pid()
-{
- DIR *dir;
- struct dirent *ptr;
- FILE *fp;
- char cmdline_path[PATH_MAX];
- char cmdline_data[PATH_MAX];
- const char vpp_path[] = "/usr/bin/vpp";
-
- dir = opendir("/proc");
- pid_t pid = 0;
- /* read vpp pid file in proc, return pid of vpp */
- if (NULL != dir) {
- while (NULL != (ptr = readdir(dir))) {
- if ((0 == strcmp(ptr->d_name, "."))
- || (0 == strcmp(ptr->d_name, ".."))) {
- continue;
- }
-
- if (DT_DIR != ptr->d_type) {
- continue;
- }
-
- sprintf(cmdline_path, "/proc/%s/cmdline", ptr->d_name);
- fp = fopen(cmdline_path, "r");
-
- if (NULL != fp) {
- fread(cmdline_data, 1, sizeof(vpp_path), fp);
- cmdline_data[sizeof(vpp_path) - 1] = '\0';
-
- if (cmdline_data ==
- strstr(cmdline_data, "/usr/bin/vpp")) {
- pid = atoi(ptr->d_name);
- }
-
- fclose(fp);
- }
- }
- closedir(dir);
- }
-
- return pid;
-}
-
-int sc_end_with(const char* str, const char* end)
-{
- if (str != NULL && end != NULL)
- {
- int l1 = strlen(str);
- int l2 = strlen(end);
- if (l1 >= l2)
- {
- if (strcmp(str + l1 - l2, end) == 0)
- return 1;
- }
- }
- return 0;
-}
-
-int sc_aton(const char *cp, u8 * buf, size_t length)
-{
- ARG_CHECK2(false, cp, buf);
-
- struct in_addr addr;
- int ret = inet_aton(cp, &addr);
-
- if (0 == ret)
- return -EINVAL;
-
- if (sizeof(addr) > length)
- return -EINVAL;
-
- memcpy(buf, &addr, sizeof (addr));
-
- return 0;
-}
-
-char* sc_ntoa(const u8 * buf)
-{
- ARG_CHECK(NULL, buf);
-
- struct in_addr addr;
- memcpy(&addr, buf, sizeof(addr));
- return inet_ntoa(addr);
-}
-
-int sc_pton(int af, const char *cp, u8 * buf)
-{
- ARG_CHECK2(false, cp, buf);
-
- int ret = inet_pton(af, cp, buf);
-
- if (0 == ret)
- return -EINVAL;
-
- return 0;
-}
-
-const char* sc_ntop(int af, const u8 * buf, char *addr)
-{
- ARG_CHECK(NULL, buf);
- ARG_CHECK(NULL, addr);
-
- socklen_t size = 0;
- if (af == AF_INET)
- size = INET_ADDRSTRLEN;
- else if (af == AF_INET6)
- size = INET6_ADDRSTRLEN;
- else
- return NULL;
-
- return inet_ntop(af, (void*)buf, addr, size);
-}
-
-/**
- * @brief Function converts the u8 array from network byte order to host byte order.
- *
- * @param[in] host IPv4 address.
- * @return host byte order value.
- */
-uint32_t hardntohlu32(uint8_t host[4])
-{
- uint32_t tmp = host[3] | host[2] | host[1] | host[0];
-
- return ntohl(tmp);
-}
diff --git a/src/scvpp/src/interface.c b/src/scvpp/src/interface.c
deleted file mode 100644
index b6b1216..0000000
--- a/src/scvpp/src/interface.c
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Copyright (c) 2018 PANTHEON.tech.
- *
- * 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 <assert.h>
-#include <stdbool.h>
-
-#include <scvpp/comm.h>
-#include <scvpp/interface.h>
-
-#define IFACE_SUBSTR 49
-
-// Use VAPI macros to define symbols
-DEFINE_VAPI_MSG_IDS_INTERFACE_API_JSON
-
-static vapi_error_e
-sw_interface_dump_cb(struct vapi_ctx_s *ctx, void *callback_ctx,
- vapi_error_e rv, bool is_last,
- vapi_payload_sw_interface_details *reply)
-{
- UNUSED(rv); UNUSED(ctx); UNUSED(is_last);
-
- vapi_payload_sw_interface_details *passed;
-
- if (is_last) {
- return VAPI_OK;
- }
-
- ARG_CHECK2(VAPI_EINVAL, callback_ctx, reply);
-
- //copy
- passed = (vapi_payload_sw_interface_details *) callback_ctx;
- *passed = *reply;
-
- return VAPI_OK;
-}
-
-static vapi_error_e
-bin_api_sw_interface_dump(vapi_payload_sw_interface_details *details,
- const char *iface_name)
-{
- vapi_msg_sw_interface_dump *mp;
- vapi_error_e rv;
-
- mp = vapi_alloc_sw_interface_dump(sc_vpp_main.vapi_ctx);
- assert(NULL != mp);
-
- /* Dump a specific interfaces */
- mp->payload.name_filter_valid = true;
- strncpy((char *)mp->payload.name_filter, iface_name, IFACE_SUBSTR);
-
- VAPI_CALL(vapi_sw_interface_dump(sc_vpp_main.vapi_ctx, mp,
- sw_interface_dump_cb, details));
- if (rv != VAPI_OK)
- return -SCVPP_EINVAL;
-
- return rv;
-}
-
-int get_interface_id(const char *if_name, uint32_t *sw_if_index)
-{
- vapi_payload_sw_interface_details details = {0};
- vapi_error_e rv;
-
- ARG_CHECK2(-SCVPP_EINVAL, if_name, sw_if_index);
-
- rv = bin_api_sw_interface_dump(&details, if_name);
- if (rv != VAPI_OK)
- return -SCVPP_EINVAL;
-
- if (strncmp(if_name, (char*) details.interface_name, VPP_INTFC_NAME_LEN)
- != 0)
- return -SCVPP_NOT_FOUND;
-
- *sw_if_index = details.sw_if_index;
-
- return 0;
-}
-
-/*
- * dump only a specific interface
- */
-int interface_dump_iface(sw_interface_dump_t *details, const char *iface_name)
-{
- vapi_error_e rv;
-
- rv = bin_api_sw_interface_dump(details, iface_name);
- if (rv != VAPI_OK)
- return -SCVPP_EINVAL;
-
- if (strncmp(iface_name, (char*) details->interface_name, VPP_INTFC_NAME_LEN)
- != 0)
- return -SCVPP_NOT_FOUND;
-
- return SCVPP_OK;
-}
-
-VAPI_DUMP_LIST_CB(sw_interface)
-
-struct elt* interface_dump_all()
-{
- struct elt* stack = NULL;
- vapi_msg_sw_interface_dump *mp;
- vapi_error_e rv;
-
- mp = vapi_alloc_sw_interface_dump(sc_vpp_main.vapi_ctx);
-
- /* Dump all */
- mp->payload.name_filter_valid = false;
- memset(mp->payload.name_filter, 0, sizeof(mp->payload.name_filter));
-
- VAPI_CALL(vapi_sw_interface_dump(sc_vpp_main.vapi_ctx, mp, sw_interface_all_cb,
- &stack));
- if (VAPI_OK != rv)
- return NULL;
-
- return stack;
-}
-
-VAPI_REQUEST_CB(sw_interface_set_flags);
-
-int interface_enable(const char *interface_name, const bool enable)
-{
- vapi_msg_sw_interface_set_flags *mp;
- uint32_t sw_if_index;
- vapi_error_e rv;
- int rc;
-
- ARG_CHECK(-SCVPP_EINVAL, interface_name);
-
- rc = get_interface_id(interface_name, &sw_if_index);
- if (rc != 0)
- return -SCVPP_NOT_FOUND;
-
- mp = vapi_alloc_sw_interface_set_flags(sc_vpp_main.vapi_ctx);
- assert(NULL != mp);
- mp->payload.sw_if_index = sw_if_index;
- mp->payload.admin_up_down = enable;
-
- VAPI_CALL(vapi_sw_interface_set_flags(sc_vpp_main.vapi_ctx, mp,
- sw_interface_set_flags_cb, NULL));
- if (VAPI_OK != rv)
- return -SCVPP_EINVAL;
-
- return 0;
-}
-
-int get_interface_name(char *interface_name, uint32_t sw_if_index)
-{
- struct elt *stack= NULL;
- sw_interface_dump_t *dump;
- int rc = -SCVPP_NOT_FOUND;
-
- stack = interface_dump_all();
- if (!stack)
- return -SCVPP_NOT_FOUND;
-
- foreach_stack_elt(stack) {
- dump = (sw_interface_dump_t *) data;
-
- if (dump->sw_if_index == sw_if_index) {
- strncpy(interface_name, (char *)dump->interface_name, VPP_INTFC_NAME_LEN);
- rc = SCVPP_OK;
- }
-
- free(dump);
- }
-
- return rc;
-}
diff --git a/src/scvpp/src/ip.c b/src/scvpp/src/ip.c
deleted file mode 100644
index ec44f64..0000000
--- a/src/scvpp/src/ip.c
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * Copyright (c) 2018 PANTHEON.tech.
- *
- * 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 <scvpp/comm.h>
-#include <scvpp/ip.h>
-#include <scvpp/interface.h>
-
-#include <assert.h>
-#include <stdio.h>
-
-// Use VAPI macros to define symbols
-DEFINE_VAPI_MSG_IDS_IP_API_JSON
-
-VAPI_REQUEST_CB(sw_interface_add_del_address);
-
-static vapi_error_e
-bin_api_sw_interface_add_del_address(u32 sw_if_index, bool is_add, bool is_ipv6,
- bool del_all, u8 address_length,
- const char *ip_address)
-{
- vapi_msg_sw_interface_add_del_address *mp;
- vapi_error_e rv;
-
- ARG_CHECK(VAPI_EINVAL, ip_address);
-
- mp = vapi_alloc_sw_interface_add_del_address(sc_vpp_main.vapi_ctx);
- assert(NULL != mp);
-
- mp->payload.sw_if_index = sw_if_index;
- mp->payload.is_add = is_add;
- mp->payload.is_ipv6 = is_ipv6;
- mp->payload.del_all = del_all;
- mp->payload.address_length = address_length;
- if (sc_aton(ip_address, mp->payload.address, VPP_IP4_ADDRESS_LEN))
- return VAPI_EINVAL;
-
- VAPI_CALL(vapi_sw_interface_add_del_address(sc_vpp_main.vapi_ctx, mp,
- sw_interface_add_del_address_cb, NULL));
-
- return rv;
-}
-
-VAPI_REQUEST_CB(ip_add_del_route)
-
-static vapi_error_e
-bin_api_ip_add_del_route(vapi_payload_ip_add_del_route_reply * reply,
- const char* dst_address, uint8_t dst_address_length,
- const char* next_hop, uint8_t is_add,
- uint32_t table_id, const char *next_interface)
-{
- vapi_msg_ip_add_del_route *mp;
- uint32_t sw_if_index;
- vapi_error_e rv ;
- int rc;
-
- ARG_CHECK2(VAPI_EINVAL, reply, dst_address);
-
- //Require interface or next hop IP or both
- if (!next_interface && !next_hop)
- return VAPI_EINVAL;
-
- mp = vapi_alloc_ip_add_del_route(sc_vpp_main.vapi_ctx, 1);
- assert(NULL != mp);
-
- if (next_interface) {
- rc = get_interface_id(next_interface, &sw_if_index);
- if (rc < 0)
- return VAPI_EINVAL;
- }
-
- mp->payload.is_add = is_add;
- mp->payload.table_id = table_id;
- mp->payload.is_ipv6 = false;
- mp->payload.is_local = false;
- sc_aton(dst_address, mp->payload.dst_address, VPP_IP4_ADDRESS_LEN);
- mp->payload.dst_address_length = dst_address_length;
- if (next_interface) //interface is not mandatory
- mp->payload.next_hop_sw_if_index = sw_if_index;
- if (next_hop) //next hop ip is not mandatory
- sc_aton(next_hop, mp->payload.next_hop_address, VPP_IP4_ADDRESS_LEN);
-
- VAPI_CALL(vapi_ip_add_del_route(sc_vpp_main.vapi_ctx, mp,
- ip_add_del_route_cb, reply));
-
- return rv;
-}
-
-static vapi_error_e
-ip_address_dump_cb (struct vapi_ctx_s *ctx, void *callback_ctx, vapi_error_e rv,
- bool is_last, vapi_payload_ip_address_details *reply)
-{
- UNUSED(rv);
- vapi_payload_ip_address_details *passed;
-
- ARG_CHECK3(VAPI_EINVAL, ctx, callback_ctx, reply);
-
- //copy dump reply in callback context
- if (!is_last) {
- passed = (vapi_payload_ip_address_details *) callback_ctx;
- *passed = *reply;
- }
-
- return VAPI_OK;
-}
-
-static vapi_error_e
-bin_api_ip_address_dump(u32 sw_if_index, bool is_ipv6,
- vapi_payload_ip_address_details *dctx)
-{
- vapi_msg_ip_address_dump *mp;
- vapi_error_e rv;
-
- mp = vapi_alloc_ip_address_dump(sc_vpp_main.vapi_ctx);
- assert(mp != NULL);
-
- mp->payload.sw_if_index = sw_if_index;
- mp->payload.is_ipv6 = is_ipv6;
-
- VAPI_CALL(vapi_ip_address_dump(sc_vpp_main.vapi_ctx, mp, ip_address_dump_cb,
- dctx));
- if (rv != VAPI_OK)
- return rv;
-
- return VAPI_OK;
-}
-
-///VAPI_DUMP_LIST_CB(ip_fib); can not be used because of path flexible array
-
-static vapi_error_e
-ip_fib_all_cb(vapi_ctx_t ctx, void *caller_ctx, vapi_error_e rv, bool is_last,
- vapi_payload_ip_fib_details *reply)
-{
- UNUSED(ctx); UNUSED(rv); UNUSED(is_last);
- struct elt **stackp;
- ARG_CHECK2(VAPI_EINVAL, caller_ctx, reply);
-
- stackp = (struct elt**) caller_ctx;
- push(stackp, reply, sizeof(*reply)+reply->count*sizeof(vapi_type_fib_path));
-
- return VAPI_OK;
-}
-
-struct elt* ipv4_fib_dump_all()
-{
- struct elt *stack = NULL;
- vapi_msg_ip_fib_dump *mp;
- vapi_error_e rv;
-
- mp = vapi_alloc_ip_fib_dump(sc_vpp_main.vapi_ctx);
- assert(mp != NULL);
-
- VAPI_CALL(vapi_ip_fib_dump(sc_vpp_main.vapi_ctx, mp, ip_fib_all_cb, &stack));
- if(VAPI_OK != rv)
- return NULL;
-
- return stack;
-}
-
-int ipv4_fib_dump_prefix(const char *prefix_xpath, fib_dump_t **reply)
-{
- struct elt *stack = NULL;
- char prefix[VPP_IP4_PREFIX_STRING_LEN];
- fib_dump_t *dump;
- int rc = -SCVPP_NOT_FOUND;
-
- stack = ipv4_fib_dump_all();
- if (!stack)
- return rc;
-
- foreach_stack_elt(stack) {
- dump = (fib_dump_t *) data;
-
- if (rc == -SCVPP_NOT_FOUND) {
- snprintf(prefix, VPP_IP4_PREFIX_STRING_LEN, "%s/%u",
- sc_ntoa(dump->address), dump->address_length);
- if (!strncmp(prefix_xpath, prefix, VPP_IP4_PREFIX_STRING_LEN)) {
- *reply = dump;
- rc = SCVPP_OK;
- continue;
- }
- }
-
- free(dump);
- }
-
- return rc;
-}
-
-int ipv46_address_dump(const char *interface_name, char *ip_addr,
- u8 *prefix_len, bool is_ipv6)
-{
- vapi_payload_ip_address_details dctx = {0};
- uint32_t sw_if_index;
- vapi_error_e rv;
- int rc;
-
- rc = get_interface_id(interface_name, &sw_if_index);
- if (rc < 0)
- return rc;
-
- rv = bin_api_ip_address_dump(sw_if_index, is_ipv6, &dctx);
- if (rv != VAPI_OK)
- return -SCVPP_EINVAL;
-
- strcpy(ip_addr, sc_ntoa(dctx.ip)); //IP string
- *prefix_len = dctx.prefix_length; //prefix length
-
- return SCVPP_OK;
-}
-
-int ipv46_config_add_remove(const char *if_name, const char *addr,
- uint8_t prefix, bool is_ipv6, bool add)
-{
- vapi_error_e rv;
- uint32_t sw_if_index;
- int rc;
-
- ARG_CHECK2(-1, if_name, addr);
-
- rc = get_interface_id(if_name, &sw_if_index);
- if (rc < 0)
- return rc;
-
- /* add del addr */
- rv = bin_api_sw_interface_add_del_address(sw_if_index, add, is_ipv6, 0,
- prefix, addr);
- if (rv != VAPI_OK)
- return -SCVPP_EINVAL;
-
- return SCVPP_OK;
-}
-
-int ipv46_config_add_del_route(const char* dst_address, u8 dst_address_length,
- const char* next_address, u8 is_add,
- u32 table_id, const char *interface)
-{
- vapi_payload_ip_add_del_route_reply reply = {0};
- vapi_error_e rv;
-
- rv = bin_api_ip_add_del_route(&reply, dst_address, dst_address_length,
- next_address, is_add, table_id, interface);
- if (VAPI_OK != rv || reply.retval > 0)
- return -SCVPP_EINVAL;
-
- return SCVPP_OK;
-}
diff --git a/src/scvpp/src/nat.c b/src/scvpp/src/nat.c
deleted file mode 100644
index 4519c3e..0000000
--- a/src/scvpp/src/nat.c
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * Copyright (c) 2018 PANTHEON.tech.
- *
- * 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 <scvpp/comm.h>
-#include <scvpp/nat.h>
-
-#include <assert.h>
-#include <stdbool.h>
-
-
-DEFINE_VAPI_MSG_IDS_NAT_API_JSON
-
-static vapi_error_e
-nat44_interface_dump_cb(struct vapi_ctx_s *ctx, void *callback_ctx,
- vapi_error_e rv, bool is_last,
- vapi_payload_nat44_interface_details *reply)
-{
- UNUSED(ctx); UNUSED(rv);
- vapi_payload_nat44_interface_details *dctx = callback_ctx;
- assert(dctx);
-
- if (is_last)
- {
- assert(NULL == reply);
- }
- else
- {
- //TODO: Use LOG message for scvpp
-// SC_LOG_DBG("NAT Interface dump entry: [%u]: %u\n", reply->sw_if_index,
-// reply->is_inside);
- *dctx = *reply;
- }
-
- return VAPI_OK;
-}
-
-static vapi_error_e
-bin_api_nat44_interface_dump(vapi_payload_nat44_interface_details *reply)
-{
- vapi_error_e rv;
- vapi_msg_nat44_interface_dump *mp;
-
- ARG_CHECK(VAPI_EINVAL, reply);
-
- mp = vapi_alloc_nat44_interface_dump(sc_vpp_main.vapi_ctx);
- assert(NULL != mp);
-
- VAPI_CALL(vapi_nat44_interface_dump(sc_vpp_main.vapi_ctx, mp,
- nat44_interface_dump_cb, reply));
-
- return rv;
-}
-
-VAPI_REQUEST_CB(nat44_add_del_interface_addr);
-
-static vapi_error_e
-bin_api_nat44_add_del_interface_addr(
- const vapi_payload_nat44_add_del_interface_addr *msg)
-{
- vapi_error_e rv;
- vapi_msg_nat44_add_del_interface_addr *mp;
-
- ARG_CHECK(VAPI_EINVAL, msg);
-
- mp = vapi_alloc_nat44_add_del_interface_addr(sc_vpp_main.vapi_ctx);
- assert(NULL != mp);
-
- mp->payload = *msg;
-
- VAPI_CALL(vapi_nat44_add_del_interface_addr(sc_vpp_main.vapi_ctx, mp,
- nat44_add_del_interface_addr_cb,
- NULL));
-
- return rv;
-}
-
-VAPI_REQUEST_CB(nat44_add_del_address_range);
-
-static vapi_error_e
-bin_api_nat44_add_del_addr_range(
- const vapi_payload_nat44_add_del_address_range *range)
-{
- vapi_error_e rv;
- vapi_msg_nat44_add_del_address_range *mp;
-
- ARG_CHECK(VAPI_EINVAL, range);
-
- mp = vapi_alloc_nat44_add_del_address_range(sc_vpp_main.vapi_ctx);
-
- assert(NULL != mp);
-
- mp->payload = *range;
-
- VAPI_CALL(vapi_nat44_add_del_address_range(sc_vpp_main.vapi_ctx, mp,
- nat44_add_del_address_range_cb,
- NULL));
-
- return rv;
-}
-
-VAPI_REQUEST_CB(nat44_add_del_static_mapping);
-
-static vapi_error_e
-bin_api_nat44_add_del_static_mapping(
- const vapi_payload_nat44_add_del_static_mapping *msg)
-{
- vapi_error_e rv;
- vapi_msg_nat44_add_del_static_mapping *mp;
-
- ARG_CHECK(VAPI_EINVAL, msg);
-
- mp = vapi_alloc_nat44_add_del_static_mapping(sc_vpp_main.vapi_ctx);
- assert(NULL != mp);
-
- mp->payload = *msg;
-
- VAPI_CALL(vapi_nat44_add_del_static_mapping(sc_vpp_main.vapi_ctx, mp,
- nat44_add_del_static_mapping_cb,
- NULL));
-
- return rv;
-}
-
-static vapi_error_e nat44_static_mapping_dump_cb(
- struct vapi_ctx_s *ctx, void *callback_ctx, vapi_error_e rv,
- bool is_last,vapi_payload_nat44_static_mapping_details *reply)
-{
- UNUSED(rv); UNUSED(ctx);
- vapi_payload_nat44_static_mapping_details *dctx = callback_ctx;
- assert(dctx);
-
- if (is_last)
- {
- assert(NULL == reply);
- }
- else
- {
- *dctx = *reply;
- }
-
- return VAPI_OK;
-}
-
-static vapi_error_e
-bin_api_nat44_static_mapping_dump(
- vapi_payload_nat44_static_mapping_details *reply)
-{
- vapi_error_e rv;
- vapi_msg_nat44_static_mapping_dump *msg;
-
- ARG_CHECK(VAPI_EINVAL, reply);
-
- msg = vapi_alloc_nat44_static_mapping_dump(sc_vpp_main.vapi_ctx);
- assert(NULL != msg);
-
- VAPI_CALL(vapi_nat44_static_mapping_dump(sc_vpp_main.vapi_ctx, msg,
- nat44_static_mapping_dump_cb,
- reply));
-
- return rv;
-}
-
-VAPI_REQUEST_CB(nat44_forwarding_enable_disable);
-
-static vapi_error_e bin_api_nat44_forwarding_enable_disable(
- const vapi_payload_nat44_forwarding_enable_disable *msg)
-{
- vapi_error_e rv;
- vapi_msg_nat44_forwarding_enable_disable *mp;
-
- ARG_CHECK(VAPI_EINVAL, msg);
-
- mp = vapi_alloc_nat44_forwarding_enable_disable(sc_vpp_main.vapi_ctx);
- assert(NULL != mp);
-
- mp->payload = *msg;
-
- VAPI_CALL(vapi_nat44_forwarding_enable_disable(
- sc_vpp_main.vapi_ctx, mp, nat44_forwarding_enable_disable_cb, NULL));
-
- return rv;
-}
-
-VAPI_REQUEST_CB(nat_set_workers);
-
-static vapi_error_e
-bin_api_nat_set_workers(const vapi_payload_nat_set_workers *msg)
-{
- vapi_error_e rv;
- vapi_msg_nat_set_workers *mp;
-
- ARG_CHECK(VAPI_EINVAL, msg);
-
- mp = vapi_alloc_nat_set_workers(sc_vpp_main.vapi_ctx);
- assert(NULL != mp);
-
- mp->payload = *msg;
-
- VAPI_CALL(vapi_nat_set_workers(sc_vpp_main.vapi_ctx, mp, nat_set_workers_cb, NULL));
-
- return rv;
-}
-
-int nat44_interface_dump(nat44_interface_details_t *reply)
-{
- vapi_error_e rv;
-
- rv = bin_api_nat44_interface_dump(reply);
- if (VAPI_OK != rv)
- return -SCVPP_EINVAL;
-
- return SCVPP_OK;
-}
-
-int nat44_add_del_interface_addr(const nat44_add_del_interface_addr_t *msg)
-{
- vapi_error_e rv;
-
- rv = bin_api_nat44_add_del_interface_addr(msg);
- if (VAPI_OK != rv)
- return -SCVPP_EINVAL;
-
- return SCVPP_OK;
-}
-
-int nat44_add_del_addr_range(const nat44_add_del_address_range_t *range)
-{
- vapi_error_e rv;
-
- rv = bin_api_nat44_add_del_addr_range(range);
- if (VAPI_OK != rv)
- return -SCVPP_EINVAL;
-
- return SCVPP_OK;
-}
-
-int nat44_add_del_static_mapping(const nat44_add_del_static_mapping_t *msg)
-{
- vapi_error_e rv;
-
- rv = bin_api_nat44_add_del_static_mapping(msg);
- if (VAPI_OK != rv)
- return -SCVPP_EINVAL;
-
- return SCVPP_OK;
-}
-
-int nat44_static_mapping_dump(nat44_static_mapping_details_t *reply)
-{
- vapi_error_e rv;
-
- rv = bin_api_nat44_static_mapping_dump(reply);
- if (VAPI_OK != rv)
- return -SCVPP_EINVAL;
-
- return SCVPP_OK;
-}
-
-int
-nat44_forwarding_enable_disable(const nat44_forwarding_enable_disable_t *msg)
-{
- vapi_error_e rv;
-
- rv = bin_api_nat44_forwarding_enable_disable(msg);
- if (VAPI_OK != rv)
- return -SCVPP_EINVAL;
-
- return 0;
-}
-
-int nat_set_workers(const nat_set_workers_t *msg)
-{
- vapi_error_e rv;
-
- rv = bin_api_nat_set_workers(msg);
- if (VAPI_OK != rv)
- return -SCVPP_EINVAL;
-
- return SCVPP_OK;
-}
-
diff --git a/src/scvpp/src/v3po.c b/src/scvpp/src/v3po.c
deleted file mode 100644
index 8fd83ba..0000000
--- a/src/scvpp/src/v3po.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 2016 Cisco and/or its affiliates.
- * Copyright (c) 2018 PANTHEON.tech.
- *
- * 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 <assert.h>
-
-#include <scvpp/comm.h>
-#include <scvpp/v3po.h>
-#include <scvpp/interface.h>
-
-// Use VAPI macros to define symbols
-DEFINE_VAPI_MSG_IDS_L2_API_JSON;
-DEFINE_VAPI_MSG_IDS_TAPV2_API_JSON
-
-/*
- * tap-v2 interfaces
- */
-
-// Delete tapv2
-
-VAPI_REQUEST_CB(tap_delete_v2);
-
-static vapi_error_e bin_api_delete_tapv2(u32 sw_if_index)
-{
- vapi_msg_tap_delete_v2 *mp;
- vapi_error_e rv;
-
- mp = vapi_alloc_tap_delete_v2(sc_vpp_main.vapi_ctx);
- assert(NULL != mp);
-
- mp->payload.sw_if_index = sw_if_index;
-
- VAPI_CALL(vapi_tap_delete_v2(sc_vpp_main.vapi_ctx, mp, tap_delete_v2_cb, NULL));
- if (rv != VAPI_OK)
- return -rv;
-
- return VAPI_OK;
-}
-
-int delete_tapv2(char *iface_name)
-{
- uint32_t sw_if_index;
- vapi_error_e rv;
- int rc;
-
- rc = get_interface_id(iface_name, &sw_if_index);
- if (rc < 0)
- return rc;
-
- rv = bin_api_delete_tapv2(sw_if_index);
- if (VAPI_OK != rv)
- return -SCVPP_EINVAL;
-
- return SCVPP_OK;
-}
-
-// Create tapv2
-
-VAPI_REQUEST_CB(tap_create_v2);
-
-int create_tapv2(tapv2_create_t *query)
-{
- vapi_msg_tap_create_v2 *mp;
- vapi_error_e rv;
-
- mp = vapi_alloc_tap_create_v2(sc_vpp_main.vapi_ctx);
- assert(NULL != mp);
-
- memcpy(&mp->payload, query, sizeof(tapv2_create_t));
-
- VAPI_CALL(vapi_tap_create_v2(sc_vpp_main.vapi_ctx, mp, tap_create_v2_cb, NULL));
- if (rv != VAPI_OK)
- return -EAGAIN;
-
- return 0;
-}