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"
20 #include "pipeline_arpicmp_be.h"
25 uint8_t in_port_dir_a[PIPELINE_MAX_PORT_IN];
26 uint8_t prv_to_pub_map[PIPELINE_MAX_PORT_IN];
27 uint8_t pub_to_prv_map[PIPELINE_MAX_PORT_IN];
28 uint8_t prv_in_port_a[PIPELINE_MAX_PORT_IN];
29 uint8_t prv_que_port_index[PIPELINE_MAX_PORT_IN];
30 uint8_t in_port_egress_prv[PIPELINE_MAX_PORT_IN];
32 uint8_t get_in_port_dir(uint8_t in_port_id)
34 return in_port_dir_a[in_port_id];
37 uint8_t is_phy_port_privte(uint16_t phy_port)
39 return in_port_dir_a[phy_port];
42 uint8_t is_port_index_privte(uint16_t phy_port)
44 return in_port_egress_prv[phy_port];
47 uint32_t get_prv_to_pub_port(uint32_t *ip_addr, uint8_t type)
49 uint32_t dest_if = 0xff;
50 struct ether_addr addr;
56 nhip = get_nh(ip_addr[0], &dest_if, &addr);
66 get_nh_ipv6((uint8_t *)ip_addr, &dest_if, &nhipv6[0]);
76 uint32_t get_pub_to_prv_port(uint32_t *ip_addr, uint8_t type)
78 uint32_t dest_if = 0xff;
79 struct ether_addr addr;
85 nhip = get_nh(ip_addr[0], &dest_if, &addr);
95 get_nh_ipv6((uint8_t *)ip_addr, &dest_if, &nhipv6[0]);
105 void show_ports_info(void)
107 printf("\nin_port_dir_a: %d %d %d %d %d", in_port_dir_a[0],
108 in_port_dir_a[1], in_port_dir_a[2], in_port_dir_a[3],
111 uint8_t i = 0, j = 0;
113 printf("\nprv_to_pub_map: ");
114 for (i = 0; i < PIPELINE_MAX_PORT_IN; i++) {
115 if (prv_to_pub_map[i] != 0xff)
116 printf("(%d,%d) ", i, prv_to_pub_map[i]);
119 printf("\npub_to_prv_map: ");
120 for (i = 0; i < PIPELINE_MAX_PORT_IN; i++) {
121 if (pub_to_prv_map[i] != 0xff)
122 printf("(%d,%d) ", i, pub_to_prv_map[i]);
125 printf("\n%d entries in Ports MAC List\n", link_hw_addr_array_idx);
126 for (j = 0; j < link_hw_addr_array_idx; j++) {
127 struct ether_addr *link_hw_addr = get_link_hw_addr(j);
129 for (i = 0; i < 6; i++)
130 printf(" %02x ", ((struct ether_addr *)link_hw_addr)->addr_bytes[i]);
135 void trim(char *input)
138 int len = strlen(input);
139 char result[len + 1];
141 memset(result, 0, sizeof(result));
142 for (i = 0; input[i] != '\0'; i++) {
143 if (!isspace(input[i]))
144 result[j++] = input[i];
147 strncpy(input, result, len);