#include <vlibapi/api_helper_macros.h>
-static void
+static int
cnat_endpoint_decode (const vl_api_cnat_endpoint_t * in,
cnat_endpoint_t * out)
{
+ int rv = 0;
out->ce_port = clib_net_to_host_u16 (in->port);
out->ce_sw_if_index = clib_net_to_host_u32 (in->sw_if_index);
out->ce_flags = 0;
if (out->ce_sw_if_index == INDEX_INVALID)
ip_address_decode2 (&in->addr, &out->ce_ip);
else
- ip_address_family_decode (in->if_af, &out->ce_ip.version);
+ rv = ip_address_family_decode (in->if_af, &out->ce_ip.version);
+ return rv;
}
-static void
+static int
cnat_endpoint_tuple_decode (const vl_api_cnat_endpoint_tuple_t * in,
cnat_endpoint_tuple_t * out)
{
- cnat_endpoint_decode (&in->src_ep, &out->src_ep);
- cnat_endpoint_decode (&in->dst_ep, &out->dst_ep);
+ int rv = 0;
+ rv = cnat_endpoint_decode (&in->src_ep, &out->src_ep);
+ if (rv)
+ return rv;
+ rv = cnat_endpoint_decode (&in->dst_ep, &out->dst_ep);
+ return rv;
}
static void
for (pi = 0; pi < n_paths; pi++)
{
path = &paths[pi];
- cnat_endpoint_tuple_decode (&mp->translation.paths[pi], path);
+ rv = cnat_endpoint_tuple_decode (&mp->translation.paths[pi], path);
+ if (rv)
+ goto done;
}
- cnat_endpoint_decode (&mp->translation.vip, &vip);
+
+ rv = cnat_endpoint_decode (&mp->translation.vip, &vip);
+ if (rv)
+ goto done;
flags = mp->translation.flags;
if (!mp->translation.is_real_ip)
/* fill in the message */
mp->context = ctx->context;
+ ep.ce_sw_if_index = INDEX_INVALID;
+ ep.ce_flags = CNAT_EP_FLAG_RESOLVED;
ip_address2_from_46 (&session->value.cs_ip[VLIB_TX], session->key.cs_af,
&ep.ce_ip);
ep.ce_port = clib_host_to_net_u16 (session->value.cs_port[VLIB_TX]);
typedef enum cnat_source_policy_errors_
{
- CNAT_SOURCE_ERROR_EXHAUSTED_PORTS,
- CNAT_SOURCE_ERROR_USE_DEFAULT,
- CNAT_SOURCE_N_ERRORS,
+ CNAT_SOURCE_ERROR_EXHAUSTED_PORTS = 1,
+ CNAT_SOURCE_ERROR_USE_DEFAULT = 2,
} cnat_source_policy_errors_t;
typedef struct cnat_src_port_allocator_