- {
- if (vec_len (m->locals))
- {
- s = format (s, "%U vrf %d external %U:%d %s %s",
- format_snat_protocol, m->proto,
- m->vrf_id,
- format_ip4_address, &m->external_addr, m->external_port,
- m->twice_nat ? "twice-nat" : "",
- m->out2in_only ? "out2in-only" : "");
- vec_foreach (local, m->locals)
- s = format (s, "\n local %U:%d probability %d\%",
- format_ip4_address, &local->addr, local->port,
- local->probability);
- }
- else
- s = format (s, "%U local %U:%d external %U:%d vrf %d %s %s",
- format_snat_protocol, m->proto,
- format_ip4_address, &m->local_addr, m->local_port,
- format_ip4_address, &m->external_addr, m->external_port,
- m->vrf_id, m->twice_nat ? "twice-nat" : "",
- m->out2in_only ? "out2in-only" : "");
- }
- return s;
-}
-
-u8 * format_snat_static_map_to_resolve (u8 * s, va_list * args)
-{
- snat_static_map_resolve_t *m = va_arg (*args, snat_static_map_resolve_t *);
- vnet_main_t *vnm = vnet_get_main();
-
- if (m->addr_only)
- s = format (s, "local %U external %U vrf %d",
- format_ip4_address, &m->l_addr,
- format_vnet_sw_interface_name, vnm,
- vnet_get_sw_interface (vnm, m->sw_if_index),
- m->vrf_id);
- else
- s = format (s, "%U local %U:%d external %U:%d vrf %d",
- format_snat_protocol, m->proto,
- format_ip4_address, &m->l_addr, m->l_port,
- format_vnet_sw_interface_name, vnm,
- vnet_get_sw_interface (vnm, m->sw_if_index), m->e_port,
- m->vrf_id);
-
- return s;
-}
-
-u8 * format_det_map_ses (u8 * s, va_list * args)
-{
- snat_det_map_t * det_map = va_arg (*args, snat_det_map_t *);
- ip4_address_t in_addr, out_addr;
- u32 in_offset, out_offset;
- snat_det_session_t * ses = va_arg (*args, snat_det_session_t *);
- u32 * i = va_arg (*args, u32 *);
-
- u32 user_index = *i / SNAT_DET_SES_PER_USER;
- in_addr.as_u32 = clib_host_to_net_u32 (
- clib_net_to_host_u32(det_map->in_addr.as_u32) + user_index);
- in_offset = clib_net_to_host_u32(in_addr.as_u32) -
- clib_net_to_host_u32(det_map->in_addr.as_u32);
- out_offset = in_offset / det_map->sharing_ratio;
- out_addr.as_u32 = clib_host_to_net_u32(
- clib_net_to_host_u32(det_map->out_addr.as_u32) + out_offset);
- s = format (s, "in %U:%d out %U:%d external host %U:%d state: %U expire: %d\n",
- format_ip4_address, &in_addr,
- clib_net_to_host_u16 (ses->in_port),
- format_ip4_address, &out_addr,
- clib_net_to_host_u16 (ses->out.out_port),
- format_ip4_address, &ses->out.ext_host_addr,
- clib_net_to_host_u16 (ses->out.ext_host_port),
- format_snat_session_state, ses->state,
- ses->expire);
-
- return s;