2 * Copyright (c) 2018 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
17 * @brief NAT66 global declarations
19 #ifndef __included_nat66_h__
20 #define __included_nat66_h__
22 #include <vnet/ip/ip.h>
23 #include <vppinfra/bihash_24_8.h>
30 } nat66_static_mapping_t;
51 #define NAT66_INTERFACE_FLAG_IS_INSIDE 1
52 #define NAT66_INTERFACE_FLAG_IS_OUTSIDE 2
53 #define nat66_interface_is_inside(i) i->flags & NAT66_INTERFACE_FLAG_IS_INSIDE
54 #define nat66_interface_is_outside(i) i->flags & NAT66_INTERFACE_FLAG_IS_OUTSIDE
59 nat66_interface_t *interfaces;
60 /** Static mapping pool */
61 nat66_static_mapping_t *sm;
62 /** Static mapping by local address lookup table */
63 clib_bihash_24_8_t sm_l;
64 /** Static mapping by external address lookup table */
65 clib_bihash_24_8_t sm_e;
66 /** Session counters */
67 vlib_combined_counter_main_t session_counters;
69 u32 in2out_node_index;
70 u32 out2in_node_index;
73 u32 outside_fib_index;
78 vlib_simple_counter_main_t in2out_packets;
79 vlib_simple_counter_main_t out2in_packets;;
82 #define nat66_elog(_level, _str) \
85 nat66_main_t *nm = &nat66_main; \
86 if (PREDICT_FALSE (nm->log_level >= _level)) \
88 ELOG_TYPE_DECLARE (e) = \
90 .format = "nat66-msg " _str, \
93 ELOG_DATA (&vlib_global_main.elog_main, e); \
97 #define nat66_elog_warn(nat_elog_str) \
98 nat66_elog(0x02, "[warning] " nat_elog_str)
101 extern nat66_main_t nat66_main;
102 extern vlib_node_registration_t nat66_in2out_node;
103 extern vlib_node_registration_t nat66_out2in_node;
105 typedef int (*nat66_interface_walk_fn_t) (nat66_interface_t * i, void *ctx);
106 void nat66_interfaces_walk (nat66_interface_walk_fn_t fn, void *ctx);
107 int nat66_interface_add_del (u32 sw_if_index, u8 is_inside, u8 is_add);
108 typedef int (*nat66_static_mapping_walk_fn_t) (nat66_static_mapping_t * sm,
110 void nat66_static_mappings_walk (nat66_static_mapping_walk_fn_t fn,
112 nat66_static_mapping_t *nat66_static_mapping_get (ip6_address_t * addr,
113 u32 fib_index, u8 is_local);
114 int nat66_static_mapping_add_del (ip6_address_t * l_addr,
115 ip6_address_t * e_addr, u32 vrf_id,
118 #endif /* __included_nat66_h__ */
121 * fd.io coding-style-patch-verification: ON
124 * eval: (c-set-style "gnu")