_(nat44_add_del_interface_addr_reply) \
_(nat_ipfix_enable_disable_reply) \
_(nat_det_add_del_map_reply) \
-_(nat_det_set_timeouts_reply) \
+_(nat_set_timeouts_reply) \
_(nat_det_close_session_out_reply) \
_(nat_det_close_session_in_reply)
_(NAT_DET_FORWARD_REPLY, nat_det_forward_reply) \
_(NAT_DET_REVERSE_REPLY, nat_det_reverse_reply) \
_(NAT_DET_MAP_DETAILS, nat_det_map_details) \
-_(NAT_DET_SET_TIMEOUTS_REPLY, nat_det_set_timeouts_reply) \
-_(NAT_DET_GET_TIMEOUTS_REPLY, nat_det_get_timeouts_reply) \
+_(NAT_SET_TIMEOUTS_REPLY, nat_set_timeouts_reply) \
+_(NAT_GET_TIMEOUTS_REPLY, nat_get_timeouts_reply) \
_(NAT_DET_CLOSE_SESSION_OUT_REPLY, \
nat_det_close_session_out_reply) \
_(NAT_DET_CLOSE_SESSION_IN_REPLY, \
M(NAT44_INTERFACE_ADD_DEL_FEATURE, mp);
mp->sw_if_index = ntohl(sw_if_index);
mp->is_add = is_add;
- mp->is_inside = is_inside;
+ if (is_inside)
+ mp->flags |= NAT_API_IS_INSIDE;
S(mp);
W (ret);
}
M(NAT44_ADD_DEL_STATIC_MAPPING, mp);
+
mp->is_add = is_add;
- mp->addr_only = addr_only;
+ if (addr_only)
+ mp->flags |= NAT_API_IS_ADDR_ONLY;
+
mp->local_port = ntohs ((u16) local_port);
mp->external_port = ntohs ((u16) external_port);
mp->external_sw_if_index = ntohl (sw_if_index);
{
snat_test_main_t * sm = &snat_test_main;
vat_main_t *vam = sm->vat_main;
+ nat_config_flags_t flags = (nat_config_flags_t) mp->flags;
- if (mp->addr_only && mp->external_sw_if_index != ~0)
+ if (flags & NAT_API_IS_ADDR_ONLY && mp->external_sw_if_index != ~0)
fformat (vam->ofp, "%15U%6s%15d%6s%11d%6d\n",
format_ip4_address, &mp->local_ip_address, "",
ntohl (mp->external_sw_if_index), "",
ntohl (mp->vrf_id),
mp->protocol);
- else if (mp->addr_only && mp->external_sw_if_index == ~0)
+ else if (flags & NAT_API_IS_ADDR_ONLY && mp->external_sw_if_index == ~0)
fformat (vam->ofp, "%15U%6s%15U%6s%11d%6d\n",
format_ip4_address, &mp->local_ip_address, "",
format_ip4_address, &mp->external_ip_address, "",
ntohl (mp->vrf_id),
mp->protocol);
- else if (!mp->addr_only && mp->external_sw_if_index != ~0)
+ else if (!(flags & NAT_API_IS_ADDR_ONLY) && mp->external_sw_if_index != ~0)
fformat (vam->ofp, "%15U%6d%15d%6d%11d%6d\n",
format_ip4_address, &mp->local_ip_address,
ntohs (mp->local_port),
static void vl_api_nat44_interface_details_t_handler
(vl_api_nat44_interface_details_t *mp)
{
+ nat_config_flags_t flags = (nat_config_flags_t) mp->flags;
snat_test_main_t * sm = &snat_test_main;
vat_main_t *vam = sm->vat_main;
- fformat (vam->ofp, "sw_if_index %d %s\n", ntohl (mp->sw_if_index),
- mp->is_inside ? "in" : "out");
+ if ((flags & NAT_API_IS_INSIDE) && (flags & NAT_API_IS_OUTSIDE))
+ {
+ fformat (vam->ofp, "sw_if_index %d in & out\n", ntohl (mp->sw_if_index));
+ }
+ else
+ {
+ fformat (vam->ofp, "sw_if_index %d %s\n", ntohl (mp->sw_if_index),
+ flags & NAT_API_IS_INSIDE ? "in" : "out");
+ }
}
static int api_nat44_interface_dump(vat_main_t * vam)
M(NAT44_ADD_DEL_INTERFACE_ADDR, mp);
mp->sw_if_index = ntohl(sw_if_index);
+
mp->is_add = is_add;
S(mp);
fformat(vam->ofp, "%s session %U:%d to %U:%d protocol id %d "
"total packets %d total bytes %lld\n",
- mp->is_static ? "static" : "dynamic",
+ mp->flags & NAT_API_IS_STATIC ? "static" : "dynamic",
format_ip4_address, mp->inside_ip_address, ntohs(mp->inside_port),
format_ip4_address, mp->outside_ip_address, ntohs(mp->outside_port),
ntohs(mp->protocol), ntohl(mp->total_pkts),
/* Use a control ping for synchronization */
M(NAT_CONTROL_PING, mp_ping);
- memset(mp->ip_address, 0, 16);
+ clib_memset(mp->ip_address, 0, 16);
clib_memcpy(mp->ip_address, &addr, 4);
mp->vrf_id = htonl(vrf_id);
S(mp_ping);
return ret;
}
-static int api_nat_det_set_timeouts (vat_main_t * vam)
+static int api_nat_set_timeouts (vat_main_t * vam)
{
unformat_input_t * i = vam->input;
- vl_api_nat_det_set_timeouts_t * mp;
+ vl_api_nat_set_timeouts_t * mp;
u32 udp = SNAT_UDP_TIMEOUT;
u32 tcp_established = SNAT_TCP_ESTABLISHED_TIMEOUT;
u32 tcp_transitory = SNAT_TCP_TRANSITORY_TIMEOUT;
return -99;
}
- M(NAT_DET_SET_TIMEOUTS, mp);
+ M(NAT_SET_TIMEOUTS, mp);
mp->udp = htonl(udp);
mp->tcp_established = htonl(tcp_established);
mp->tcp_transitory = htonl(tcp_transitory);
return ret;
}
-static void vl_api_nat_det_get_timeouts_reply_t_handler
- (vl_api_nat_det_get_timeouts_reply_t *mp)
+static void vl_api_nat_get_timeouts_reply_t_handler
+ (vl_api_nat_get_timeouts_reply_t *mp)
{
snat_test_main_t * sm = &snat_test_main;
vat_main_t *vam = sm->vat_main;
vam->result_ready = 1;
}
-static int api_nat_det_get_timeouts(vat_main_t * vam)
+static int api_nat_get_timeouts(vat_main_t * vam)
{
- vl_api_nat_det_get_timeouts_t * mp;
+ vl_api_nat_get_timeouts_t * mp;
int ret;
if (vam->json_output)
{
- clib_warning ("JSON output not supported for nat_show_config");
+ clib_warning ("JSON output not supported for nat_get_timeouts");
return -99;
}
- M(NAT_DET_GET_TIMEOUTS, mp);
+ M(NAT_GET_TIMEOUTS, mp);
S(mp);
W (ret);
return ret;
_(nat_det_forward, "<in_addr>") \
_(nat_det_reverse, "<out_addr> <out_port>") \
_(nat_det_map_dump, "") \
-_(nat_det_set_timeouts, "[udp <sec> | tcp_established <sec> | " \
+_(nat_set_timeouts, "[udp <sec> | tcp_established <sec> | " \
"tcp_transitory <sec> | icmp <sec>]") \
-_(nat_det_get_timeouts, "") \
+_(nat_get_timeouts, "") \
_(nat_det_close_session_out, "<out_addr>:<out_port> " \
"<ext_addr>:<ext_port>") \
_(nat_det_close_session_in, "<in_addr>:<in_port> " \