aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/nat44-ed/nat44_ed_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/nat/nat44-ed/nat44_ed_api.c')
-rw-r--r--src/plugins/nat/nat44-ed/nat44_ed_api.c55
1 files changed, 32 insertions, 23 deletions
diff --git a/src/plugins/nat/nat44-ed/nat44_ed_api.c b/src/plugins/nat/nat44-ed/nat44_ed_api.c
index d37c2855158..ad00d11052b 100644
--- a/src/plugins/nat/nat44-ed/nat44_ed_api.c
+++ b/src/plugins/nat/nat44-ed/nat44_ed_api.c
@@ -628,7 +628,7 @@ static void
ip4_address_t l_addr, e_addr, pool_addr = { 0 };
u32 sw_if_index, flags = 0, vrf_id;
u16 l_port = 0, e_port = 0;
- ip_protocol_t proto = 0;
+ nat_protocol_t proto = 0;
u8 *tag = 0;
memcpy (&l_addr.as_u8, mp->local_ip_address, 4);
@@ -641,7 +641,7 @@ static void
{
l_port = mp->local_port;
e_port = mp->external_port;
- proto = mp->protocol;
+ proto = ip_proto_to_nat_proto (mp->protocol);
}
if (mp->flags & NAT_API_IS_TWICE_NAT)
@@ -702,7 +702,7 @@ static void
ip4_address_t l_addr, e_addr, pool_addr;
u32 sw_if_index, flags = 0, vrf_id;
u16 l_port = 0, e_port = 0;
- ip_protocol_t proto;
+ nat_protocol_t proto;
u8 *tag = 0;
memcpy (&l_addr.as_u8, mp->local_ip_address, 4);
@@ -748,7 +748,7 @@ static void
memcpy (&e_addr.as_u8, mp->external_ip_address, 4);
}
- proto = mp->protocol;
+ proto = ip_proto_to_nat_proto (mp->protocol);
vrf_id = clib_net_to_host_u32 (mp->vrf_id);
if (mp->is_add)
@@ -812,7 +812,7 @@ send_nat44_static_mapping_details (snat_static_mapping_t * m,
}
else
{
- rmp->protocol = m->proto;
+ rmp->protocol = nat_proto_to_ip_proto (m->proto);
rmp->external_port = m->external_port;
rmp->local_port = m->local_port;
}
@@ -849,7 +849,7 @@ send_nat44_static_map_resolve_details (snat_static_map_resolve_t * m,
}
else
{
- rmp->protocol = m->proto;
+ rmp->protocol = nat_proto_to_ip_proto (m->proto);
rmp->external_port = m->e_port;
rmp->local_port = m->l_port;
}
@@ -898,7 +898,7 @@ static void
ip4_address_t addr, pool_addr = { 0 };
u32 sw_if_index, flags, vrf_id;
- ip_protocol_t proto = 0;
+ nat_protocol_t proto = 0;
u16 port = 0;
u8 *tag = 0;
@@ -911,7 +911,7 @@ static void
else
{
port = mp->port;
- proto = mp->protocol;
+ proto = ip_proto_to_nat_proto (mp->protocol);
}
sw_if_index = clib_net_to_host_u32 (mp->sw_if_index);
@@ -964,7 +964,7 @@ send_nat44_identity_mapping_details (snat_static_mapping_t * m, int index,
rmp->port = m->local_port;
rmp->sw_if_index = ~0;
rmp->vrf_id = htonl (local->vrf_id);
- rmp->protocol = m->proto;
+ rmp->protocol = nat_proto_to_ip_proto (m->proto);
rmp->context = context;
if (m->tag)
strncpy ((char *) rmp->tag, (char *) m->tag, vec_len (m->tag));
@@ -991,7 +991,7 @@ send_nat44_identity_map_resolve_details (snat_static_map_resolve_t * m,
rmp->port = m->l_port;
rmp->sw_if_index = htonl (m->sw_if_index);
rmp->vrf_id = htonl (m->vrf_id);
- rmp->protocol = m->proto;
+ rmp->protocol = nat_proto_to_ip_proto (m->proto);
rmp->context = context;
if (m->tag)
strncpy ((char *) rmp->tag, (char *) m->tag, vec_len (m->tag));
@@ -1140,7 +1140,7 @@ vl_api_nat44_add_del_lb_static_mapping_t_handler (
vl_api_nat44_add_del_lb_static_mapping_reply_t *rmp;
nat44_lb_addr_port_t *locals = 0;
ip4_address_t e_addr;
- ip_protocol_t proto;
+ nat_protocol_t proto;
u32 flags = 0;
u8 *tag = 0;
int rv = 0;
@@ -1148,7 +1148,7 @@ vl_api_nat44_add_del_lb_static_mapping_t_handler (
locals = unformat_nat44_lb_addr_port (mp->locals,
clib_net_to_host_u32 (mp->local_num));
clib_memcpy (&e_addr, mp->external_addr, 4);
- proto = mp->protocol;
+ proto = ip_proto_to_nat_proto (mp->protocol);
if (mp->flags & NAT_API_IS_TWICE_NAT)
{
@@ -1193,11 +1193,11 @@ vl_api_nat44_lb_static_mapping_add_del_local_t_handler (
vl_api_nat44_lb_static_mapping_add_del_local_reply_t *rmp;
int rv = 0;
ip4_address_t e_addr, l_addr;
- ip_protocol_t proto;
+ nat_protocol_t proto;
clib_memcpy (&e_addr, mp->external_addr, 4);
clib_memcpy (&l_addr, mp->local.addr, 4);
- proto = mp->protocol;
+ proto = ip_proto_to_nat_proto (mp->protocol);
rv = nat44_ed_add_del_lb_static_mapping_local (
e_addr, mp->external_port, l_addr, mp->local.port, proto,
@@ -1225,7 +1225,7 @@ send_nat44_lb_static_mapping_details (snat_static_mapping_t *m,
clib_memcpy (rmp->external_addr, &(m->external_addr), 4);
rmp->external_port = m->external_port;
- rmp->protocol = m->proto;
+ rmp->protocol = nat_proto_to_ip_proto (m->proto);
rmp->context = context;
if (is_sm_self_twice_nat (m->flags))
@@ -1740,16 +1740,25 @@ send_nat44_user_session_details (snat_session_t * s,
rmp->total_bytes = clib_host_to_net_u64 (s->total_bytes);
rmp->total_pkts = ntohl (s->total_pkts);
rmp->context = context;
- rmp->outside_port = s->out2in.port;
- rmp->inside_port = s->in2out.port;
- rmp->protocol = ntohs (s->proto);
- clib_memcpy (rmp->ext_host_address, &s->ext_host_addr, 4);
- rmp->ext_host_port = s->ext_host_port;
- if (nat44_ed_is_twice_nat_session (s))
+ if (snat_is_unk_proto_session (s))
{
- clib_memcpy (rmp->ext_host_nat_address, &s->ext_host_nat_addr, 4);
- rmp->ext_host_nat_port = s->ext_host_nat_port;
+ rmp->outside_port = 0;
+ rmp->inside_port = 0;
+ rmp->protocol = ntohs (s->in2out.port);
}
+ else
+ {
+ rmp->outside_port = s->out2in.port;
+ rmp->inside_port = s->in2out.port;
+ rmp->protocol = ntohs (nat_proto_to_ip_proto (s->nat_proto));
+ }
+ clib_memcpy (rmp->ext_host_address, &s->ext_host_addr, 4);
+ rmp->ext_host_port = s->ext_host_port;
+ if (nat44_ed_is_twice_nat_session (s))
+ {
+ clib_memcpy (rmp->ext_host_nat_address, &s->ext_host_nat_addr, 4);
+ rmp->ext_host_nat_port = s->ext_host_nat_port;
+ }
vl_api_send_msg (reg, (u8 *) rmp);
}