2 // Copyright (c) 2017 Intel Corporation
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
19 #include "vnf_common.h"
21 #include "pipeline_arpicmp_be.h"
26 uint8_t in_port_dir_a[PIPELINE_MAX_PORT_IN];
27 uint8_t prv_to_pub_map[PIPELINE_MAX_PORT_IN];
28 uint8_t pub_to_prv_map[PIPELINE_MAX_PORT_IN];
29 uint8_t prv_in_port_a[PIPELINE_MAX_PORT_IN];
30 uint8_t prv_que_port_index[PIPELINE_MAX_PORT_IN];
31 uint8_t in_port_egress_prv[PIPELINE_MAX_PORT_IN];
33 uint8_t get_in_port_dir(uint8_t in_port_id)
35 return in_port_dir_a[in_port_id];
38 uint8_t is_phy_port_privte(uint16_t phy_port)
40 return in_port_dir_a[phy_port];
43 uint8_t is_port_index_privte(uint16_t phy_port)
45 return in_port_egress_prv[phy_port];
48 uint32_t get_prv_to_pub_port(uint32_t *ip_addr, uint8_t type)
50 uint32_t dest_if = 0xff;
56 gw_get_nh_port_ipv4(*ip_addr, &dest_if, &nhip);
66 gw_get_nh_port_ipv6((uint8_t *)ip_addr, &dest_if, nhipv6);
77 uint32_t get_pub_to_prv_port(uint32_t *ip_addr, uint8_t type)
79 uint32_t dest_if = 0xff;
86 gw_get_nh_port_ipv4(*ip_addr, &dest_if, &nhip);
97 gw_get_nh_port_ipv6((uint8_t *)ip_addr, &dest_if, nhipv6);
107 void show_ports_info(void)
109 printf("\nin_port_dir_a: %d %d %d %d %d", in_port_dir_a[0],
110 in_port_dir_a[1], in_port_dir_a[2], in_port_dir_a[3],
113 uint8_t i = 0, j = 0;
115 printf("\nprv_to_pub_map: ");
116 for (i = 0; i < PIPELINE_MAX_PORT_IN; i++) {
117 if (prv_to_pub_map[i] != 0xff)
118 printf("(%d,%d) ", i, prv_to_pub_map[i]);
121 printf("\npub_to_prv_map: ");
122 for (i = 0; i < PIPELINE_MAX_PORT_IN; i++) {
123 if (pub_to_prv_map[i] != 0xff)
124 printf("(%d,%d) ", i, pub_to_prv_map[i]);
127 printf("\n%d entries in Ports MAC List\n", link_hw_addr_array_idx);
128 for (j = 0; j < link_hw_addr_array_idx; j++) {
129 struct ether_addr *link_hw_addr = get_link_hw_addr(j);
131 for (i = 0; i < 6; i++)
132 printf(" %02x ", ((struct ether_addr *)link_hw_addr)->addr_bytes[i]);
137 void trim(char *input)
140 int len = strlen(input);
141 char result[len + 1];
143 memset(result, 0, sizeof(result));
144 for (i = 0; (input[i] != '\0') && (i < PIPELINE_MAX_ARGS); i++) {
145 if (!isspace(input[i]))
146 result[j++] = input[i];
150 strncpy(input, result, strlen(result));