diff options
author | Filip Varga <fivarga@cisco.com> | 2021-07-26 20:59:21 +0200 |
---|---|---|
committer | Ole Tr�an <otroan@employees.org> | 2021-08-12 19:08:47 +0000 |
commit | 5ae454312c2ffccf47e4b8c430c81f1a3d067e67 (patch) | |
tree | acdd129fb94a0ea62304d23c926af20a6757b8fd /src/plugins/nat/nat44-ed/nat44_ed.h | |
parent | c06d660aba34fc9c309af3204fe2cf2fa6619134 (diff) |
nat: NAT44ED configuration refactor
Refactoring and cleaning up address allocation functions &
ip table update callbacks.
Type: refactor
Change-Id: I9a11700a5f335b64d0d84e04d8e16d040624e01b
Signed-off-by: Filip Varga <fivarga@cisco.com>
Diffstat (limited to 'src/plugins/nat/nat44-ed/nat44_ed.h')
-rw-r--r-- | src/plugins/nat/nat44-ed/nat44_ed.h | 93 |
1 files changed, 20 insertions, 73 deletions
diff --git a/src/plugins/nat/nat44-ed/nat44_ed.h b/src/plugins/nat/nat44-ed/nat44_ed.h index ef4b546a488..ee3f71aaceb 100644 --- a/src/plugins/nat/nat44-ed/nat44_ed.h +++ b/src/plugins/nat/nat44-ed/nat44_ed.h @@ -772,19 +772,19 @@ unformat_function_t unformat_nat_protocol; @param i NAT interface @return 1 if inside interface */ -#define nat_interface_is_inside(i) i->flags & NAT_INTERFACE_FLAG_IS_INSIDE +#define nat_interface_is_inside(i) (i->flags & NAT_INTERFACE_FLAG_IS_INSIDE) /** \brief Check if NAT interface is outside. @param i NAT interface @return 1 if outside interface */ -#define nat_interface_is_outside(i) i->flags & NAT_INTERFACE_FLAG_IS_OUTSIDE +#define nat_interface_is_outside(i) (i->flags & NAT_INTERFACE_FLAG_IS_OUTSIDE) /** \brief Check if NAT44 endpoint-dependent TCP session is closed. @param s NAT session @return 1 if session is closed */ -#define nat44_is_ses_closed(s) s->state == 0xf +#define nat44_is_ses_closed(s) (s->state == 0xf) /** \brief Check if client initiating TCP connection (received SYN from client) @param t TCP header @@ -856,6 +856,23 @@ is_sm_switch_address (u32 f) #define nat_log_debug(...)\ vlib_log(VLIB_LOG_LEVEL_DEBUG, snat_main.log_class, __VA_ARGS__) +clib_error_t *nat44_api_hookup (vlib_main_t *vm); + +int snat_set_workers (uword *bitmap); + +int nat44_plugin_enable (nat44_config_t c); +int nat44_plugin_disable (); + +int nat44_ed_add_interface (u32 sw_if_index, u8 is_inside); +int nat44_ed_del_interface (u32 sw_if_index, u8 is_inside); +int nat44_ed_add_output_interface (u32 sw_if_index); +int nat44_ed_del_output_interface (u32 sw_if_index); + +int nat44_ed_add_address (ip4_address_t *addr, u32 vrf_id, u8 twice_nat); +int nat44_ed_del_address (ip4_address_t addr, u8 delete_sm, u8 twice_nat); +int nat44_ed_add_interface_address (u32 sw_if_index, u8 twice_nat); +int nat44_ed_del_interface_address (u32 sw_if_index, u8 twice_nat); + int nat44_ed_add_static_mapping (ip4_address_t l_addr, ip4_address_t e_addr, u16 l_port, u16 e_port, nat_protocol_t proto, u32 vrf_id, u32 sw_if_index, u32 flags, @@ -879,76 +896,6 @@ int nat44_ed_add_del_lb_static_mapping_local (ip4_address_t e_addr, u16 e_port, u8 probability, u8 is_add); /** - * @brief Enable NAT44 plugin - * - * @param c nat44_config_t - * - * @return 0 on success, non-zero value otherwise - */ -int nat44_plugin_enable (nat44_config_t c); - -/** - * @brief Disable NAT44 plugin - * - * @return 0 on success, non-zero value otherwise - */ -int nat44_plugin_disable (); - -/** - * @brief Add external address to NAT44 pool - * - * @param sm snat global configuration data - * @param addr IPv4 address - * @param vrf_id VRF id of tenant, ~0 means independent of VRF - * @param twice_nat 1 if twice NAT address - * - * @return 0 on success, non-zero value otherwise - */ -int snat_add_address (snat_main_t * sm, ip4_address_t * addr, u32 vrf_id, - u8 twice_nat); - -/** - * @brief Delete external address from NAT44 pool - * - * @param sm snat global configuration data - * @param addr IPv4 address - * @param delete_sm 1 if delete static mapping using address - * @param twice_nat 1 if twice NAT address - * - * @return 0 on success, non-zero value otherwise - */ -int snat_del_address (snat_main_t * sm, ip4_address_t addr, u8 delete_sm, - u8 twice_nat); - -clib_error_t *nat44_api_hookup (vlib_main_t * vm); - -/** - * @brief Set NAT plugin workers - * - * @param bitmap NAT workers bitmap - * - * @return 0 on success, non-zero value otherwise - */ -int snat_set_workers (uword * bitmap); - -int nat44_ed_add_interface (u32 sw_if_index, u8 is_inside); -int nat44_ed_del_interface (u32 sw_if_index, u8 is_inside); -int nat44_ed_add_output_interface (u32 sw_if_index); -int nat44_ed_del_output_interface (u32 sw_if_index); - -/** - * @brief Add/delete NAT44 pool address from specific interface - * - * @param sw_if_index software index of the interface - * @param is_del 1 = delete, 0 = add - * @param twice_nat 1 = twice NAT address for external hosts - * - * @return 0 on success, non-zero value otherwise - */ -int snat_add_interface_address (snat_main_t * sm, u32 sw_if_index, int is_del, - u8 twice_nat); - -/** * @brief Delete NAT44 endpoint-dependent session * * @param sm snat global configuration data |