1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2021 Intel Corporation 3 */ 4 5 /* Log file related character defs. */ 6 #define COMMENT_LEAD_CHAR ('#') 7 #define ROUTE_LEAD_CHAR ('R') 8 9 #define IPV6_ADDR_LEN 16 10 #define IPV6_ADDR_U16 (IPV6_ADDR_LEN / sizeof(uint16_t)) 11 #define IPV6_ADDR_U32 (IPV6_ADDR_LEN / sizeof(uint32_t)) 12 13 #define GET_CB_FIELD(in, fd, base, lim, dlm) do { \ 14 unsigned long val; \ 15 char *end; \ 16 errno = 0; \ 17 val = strtoul((in), &end, (base)); \ 18 if (errno != 0 || end[0] != (dlm) || val > (lim)) \ 19 return -EINVAL; \ 20 (fd) = (typeof(fd))val; \ 21 (in) = end + 1; \ 22 } while (0) 23 24 struct ipv4_l3fwd_route { 25 uint32_t ip; 26 uint8_t depth; 27 uint8_t if_out; 28 }; 29 30 struct ipv6_l3fwd_route { 31 uint8_t ip[16]; 32 uint8_t depth; 33 uint8_t if_out; 34 }; 35 36 struct ipv4_5tuple { 37 uint32_t ip_dst; 38 uint32_t ip_src; 39 uint16_t port_dst; 40 uint16_t port_src; 41 uint8_t proto; 42 } __rte_packed; 43 44 struct ipv6_5tuple { 45 uint8_t ip_dst[IPV6_ADDR_LEN]; 46 uint8_t ip_src[IPV6_ADDR_LEN]; 47 uint16_t port_dst; 48 uint16_t port_src; 49 uint8_t proto; 50 } __rte_packed; 51 52 struct lpm_route_rule { 53 union { 54 uint32_t ip; 55 union { 56 uint32_t ip_32[IPV6_ADDR_U32]; 57 uint8_t ip_8[IPV6_ADDR_LEN]; 58 }; 59 }; 60 uint8_t depth; 61 uint8_t if_out; 62 }; 63 64 struct ipv4_l3fwd_em_route { 65 struct ipv4_5tuple key; 66 uint8_t if_out; 67 }; 68 69 struct ipv6_l3fwd_em_route { 70 struct ipv6_5tuple key; 71 uint8_t if_out; 72 }; 73 74 struct em_rule { 75 union { 76 struct ipv4_5tuple v4_key; 77 struct ipv6_5tuple v6_key; 78 }; 79 uint8_t if_out; 80 }; 81 82 extern struct lpm_route_rule *route_base_v4; 83 extern struct lpm_route_rule *route_base_v6; 84 extern int route_num_v4; 85 extern int route_num_v6; 86 87 extern const struct ipv4_l3fwd_route ipv4_l3fwd_route_array[16]; 88 extern const struct ipv6_l3fwd_route ipv6_l3fwd_route_array[16]; 89 90 extern const struct ipv4_l3fwd_em_route ipv4_l3fwd_em_route_array[16]; 91 extern const struct ipv6_l3fwd_em_route ipv6_l3fwd_em_route_array[16]; 92 93 void 94 read_config_files_lpm(void); 95 96 void 97 read_config_files_em(void); 98 99 void 100 em_free_routes(void); 101 102 void 103 lpm_free_routes(void); 104 105 int 106 is_bypass_line(const char *buff); 107