diff options
author | Filip Varga <fivarga@cisco.com> | 2021-05-26 18:45:59 +0200 |
---|---|---|
committer | Ole Tr�an <otroan@employees.org> | 2021-07-22 11:27:07 +0000 |
commit | 2cf583e3d6b7f8290e4fefec3b70968048d8dae0 (patch) | |
tree | bb1390a711a346f6dab5d93241ccbda9ab066f0f /src/plugins/nat/nat44-ed/nat44_ed_format.c | |
parent | 976a0ed6ac7e57709c5917bfe7d9c8141e80e901 (diff) |
nat: nat44-ed configuration refactor & cleanup
Refactoring static mapping configuration
functions based on feature type.
Type: refactor
Signed-off-by: Filip Varga <fivarga@cisco.com>
Change-Id: I007d9b0e9717ced613fbcef2b11b6853f479be1e
Diffstat (limited to 'src/plugins/nat/nat44-ed/nat44_ed_format.c')
-rw-r--r-- | src/plugins/nat/nat44-ed/nat44_ed_format.c | 71 |
1 files changed, 33 insertions, 38 deletions
diff --git a/src/plugins/nat/nat44-ed/nat44_ed_format.c b/src/plugins/nat/nat44-ed/nat44_ed_format.c index 29fd1129f32..597bc2b4d0b 100644 --- a/src/plugins/nat/nat44-ed/nat44_ed_format.c +++ b/src/plugins/nat/nat44-ed/nat44_ed_format.c @@ -180,9 +180,9 @@ format_snat_static_mapping (u8 * s, va_list * args) snat_static_mapping_t *m = va_arg (*args, snat_static_mapping_t *); nat44_lb_addr_port_t *local; - if (is_identity_static_mapping (m)) + if (is_sm_identity_nat (m->flags)) { - if (is_addr_only_static_mapping (m)) + if (is_sm_addr_only (m->flags)) s = format (s, "identity mapping %U", format_ip4_address, &m->local_addr); else @@ -191,58 +191,53 @@ format_snat_static_mapping (u8 * s, va_list * args) format_ip4_address, &m->local_addr, clib_net_to_host_u16 (m->local_port)); - /* *INDENT-OFF* */ pool_foreach (local, m->locals) { s = format (s, " vrf %d", local->vrf_id); } - /* *INDENT-ON* */ return s; } - if (is_addr_only_static_mapping (m)) - s = format (s, "local %U external %U vrf %d %s %s", - format_ip4_address, &m->local_addr, - format_ip4_address, &m->external_addr, - m->vrf_id, - m->twice_nat == TWICE_NAT ? "twice-nat" : - m->twice_nat == TWICE_NAT_SELF ? "self-twice-nat" : "", - is_out2in_only_static_mapping (m) ? "out2in-only" : ""); + if (is_sm_addr_only (m->flags)) + s = + format (s, "local %U external %U vrf %d %s %s", format_ip4_address, + &m->local_addr, format_ip4_address, &m->external_addr, m->vrf_id, + is_sm_twice_nat (m->flags) ? + "twice-nat" : + is_sm_self_twice_nat (m->flags) ? "self-twice-nat" : "", + is_sm_out2in_only (m->flags) ? "out2in-only" : ""); else { - if (is_lb_static_mapping (m)) + if (is_sm_lb (m->flags)) { - s = format (s, "%U external %U:%d %s %s", - format_nat_protocol, m->proto, - format_ip4_address, &m->external_addr, - clib_net_to_host_u16 (m->external_port), - m->twice_nat == TWICE_NAT ? "twice-nat" : - m->twice_nat == TWICE_NAT_SELF ? "self-twice-nat" : "", - is_out2in_only_static_mapping (m) ? "out2in-only" : ""); - - /* *INDENT-OFF* */ - pool_foreach (local, m->locals) - { - s = format (s, "\n local %U:%d vrf %d probability %d\%", - format_ip4_address, &local->addr, - clib_net_to_host_u16 (local->port), - local->vrf_id, local->probability); - } - /* *INDENT-ON* */ + s = + format (s, "%U external %U:%d %s %s", format_nat_protocol, + m->proto, format_ip4_address, &m->external_addr, + clib_net_to_host_u16 (m->external_port), + is_sm_twice_nat (m->flags) ? + "twice-nat" : + is_sm_self_twice_nat (m->flags) ? "self-twice-nat" : "", + is_sm_out2in_only (m->flags) ? "out2in-only" : ""); + pool_foreach (local, m->locals) + { + s = format (s, "\n local %U:%d vrf %d probability %d\%", + format_ip4_address, &local->addr, + clib_net_to_host_u16 (local->port), local->vrf_id, + local->probability); + } } else s = format (s, "%U local %U:%d external %U:%d vrf %d %s %s", - format_nat_protocol, m->proto, - format_ip4_address, &m->local_addr, - clib_net_to_host_u16 (m->local_port), + format_nat_protocol, m->proto, format_ip4_address, + &m->local_addr, clib_net_to_host_u16 (m->local_port), format_ip4_address, &m->external_addr, - clib_net_to_host_u16 (m->external_port), - m->vrf_id, - m->twice_nat == TWICE_NAT ? "twice-nat" : - m->twice_nat == TWICE_NAT_SELF ? "self-twice-nat" : "", - is_out2in_only_static_mapping (m) ? "out2in-only" : ""); + clib_net_to_host_u16 (m->external_port), m->vrf_id, + is_sm_twice_nat (m->flags) ? + "twice-nat" : + is_sm_self_twice_nat (m->flags) ? "self-twice-nat" : "", + is_sm_out2in_only (m->flags) ? "out2in-only" : ""); } return s; } |