u16 port;
u32 proto;
- proto = ip_proto_to_snat_proto (ip->protocol);
+ proto = ip_proto_to_nat_proto (ip->protocol);
udp = ip4_next_header (ip);
port = udp->dst_port;
/* unknown protocol */
- if (PREDICT_FALSE (proto == ~0))
+ if (PREDICT_FALSE (proto == NAT_PROTOCOL_OTHER))
{
nat64_db_t *db;
ip46_address_t daddr;
{
/* if error message, then it's not fragmented and we can access it */
ip4_header_t *inner_ip = (ip4_header_t *) (echo + 1);
- proto = ip_proto_to_snat_proto (inner_ip->protocol);
+ proto = ip_proto_to_nat_proto (inner_ip->protocol);
void *l4_header = ip4_next_header (inner_ip);
switch (proto)
{
- case SNAT_PROTOCOL_ICMP:
+ case NAT_PROTOCOL_ICMP:
icmp = (icmp46_header_t *) l4_header;
echo = (icmp_echo_header_t *) (icmp + 1);
port = echo->identifier;
break;
- case SNAT_PROTOCOL_UDP:
- case SNAT_PROTOCOL_TCP:
+ case NAT_PROTOCOL_UDP:
+ case NAT_PROTOCOL_TCP:
port = ((tcp_udp_header_t *) l4_header)->src_port;
break;
default:
clib_memset (a->busy_##n##_port_refcounts, 0, sizeof(a->busy_##n##_port_refcounts)); \
a->busy_##n##_ports = 0; \
vec_validate_init_empty (a->busy_##n##_ports_per_thread, tm->n_vlib_mains - 1, 0);
- foreach_snat_protocol
+ foreach_nat_protocol
#undef _
}
else
}
int
-nat64_alloc_out_addr_and_port (u32 fib_index, snat_protocol_t proto,
+nat64_alloc_out_addr_and_port (u32 fib_index, nat_protocol_t proto,
ip4_address_t * addr, u16 * port,
u32 thread_index)
{
nat64_main_t *nm = &nat64_main;
snat_main_t *sm = nm->sm;
- snat_session_key_t k;
u32 worker_index = 0;
int rv;
- k.protocol = proto;
-
if (sm->num_workers > 1)
worker_index = thread_index - sm->first_worker_index;
rv =
- sm->alloc_addr_and_port (nm->addr_pool, fib_index, thread_index, &k,
- sm->port_per_thread, worker_index);
-
- if (!rv)
- {
- *port = k.port;
- addr->as_u32 = k.addr.as_u32;
- }
+ sm->alloc_addr_and_port (nm->addr_pool, fib_index, thread_index,
+ proto, addr, port, sm->port_per_thread,
+ worker_index);
return rv;
}
int i;
snat_address_t *a;
u32 thread_index = db - nm->db;
- snat_protocol_t proto = ip_proto_to_snat_proto (protocol);
+ nat_protocol_t proto = ip_proto_to_nat_proto (protocol);
u16 port_host_byte_order = clib_net_to_host_u16 (port);
for (i = 0; i < vec_len (nm->addr_pool); i++)
switch (proto)
{
#define _(N, j, n, s) \
- case SNAT_PROTOCOL_##N: \
+ case NAT_PROTOCOL_##N: \
ASSERT (a->busy_##n##_port_refcounts[port_host_byte_order] >= 1); \
--a->busy_##n##_port_refcounts[port_host_byte_order]; \
a->busy_##n##_ports--; \
a->busy_##n##_ports_per_thread[thread_index]--; \
break;
- foreach_snat_protocol
+ foreach_nat_protocol
#undef _
default:
nat_elog_notice ("unknown protocol");
nat64_db_bib_entry_t *bibe;
u32 fib_index = fib_table_find_or_create_and_lock (FIB_PROTOCOL_IP6, vrf_id,
nat_fib_src_hi);
- snat_protocol_t p = ip_proto_to_snat_proto (proto);
+ nat_protocol_t p = ip_proto_to_nat_proto (proto);
ip46_address_t addr;
int i;
snat_address_t *a;
switch (p)
{
#define _(N, j, n, s) \
- case SNAT_PROTOCOL_##N: \
+ case NAT_PROTOCOL_##N: \
if (a->busy_##n##_port_refcounts[out_port]) \
return VNET_API_ERROR_INVALID_VALUE; \
++a->busy_##n##_port_refcounts[out_port]; \
a->busy_##n##_ports_per_thread[thread_index]++; \
} \
break;
- foreach_snat_protocol
+ foreach_nat_protocol
#undef _
default:
clib_memset (&addr, 0, sizeof (addr));
nat64_main_t *nm = &nat64_main;
u32 now = (u32) vlib_time_now (vm);
- switch (ip_proto_to_snat_proto (ste->proto))
+ switch (ip_proto_to_nat_proto (ste->proto))
{
- case SNAT_PROTOCOL_ICMP:
+ case NAT_PROTOCOL_ICMP:
ste->expire = now + nm->icmp_timeout;
return;
- case SNAT_PROTOCOL_TCP:
+ case NAT_PROTOCOL_TCP:
{
switch (ste->tcp_state)
{
return;
}
}
- case SNAT_PROTOCOL_UDP:
+ case NAT_PROTOCOL_UDP:
ste->expire = now + nm->udp_timeout;
return;
default: