#include <nat/nat44.api_enum.h>
#include <nat/nat44.api_types.h>
-#include <nat/nat_ha.h>
+#include <nat/nat44-ei/nat44_ei_ha.h>
+#include <nat/nat44-ei/nat44_ei.h>
#include <nat/nat_inlines.h>
#include <nat/nat44/inlines.h>
/* *INDENT-ON* */
}
+static void
+vl_api_nat_set_fq_options_t_handler (vl_api_nat_set_fq_options_t *mp)
+{
+ snat_main_t *sm = &snat_main;
+ vl_api_nat_set_fq_options_reply_t *rmp;
+ int rv = 0;
+ u32 frame_queue_nelts = ntohl (mp->frame_queue_nelts);
+ rv = snat_set_frame_queue_nelts (frame_queue_nelts);
+ REPLY_MACRO (VL_API_NAT_SET_FQ_OPTIONS_REPLY);
+}
+
+static void
+vl_api_nat_show_fq_options_t_handler (vl_api_nat_show_fq_options_t *mp)
+{
+ vl_api_nat_show_fq_options_reply_t *rmp;
+ snat_main_t *sm = &snat_main;
+ int rv = 0;
+ /* clang-format off */
+ REPLY_MACRO2_ZERO (VL_API_NAT_SHOW_FQ_OPTIONS_REPLY,
+ ({
+ rmp->frame_queue_nelts = htonl (sm->frame_queue_nelts);
+ }));
+ /* clang-format on */
+}
+
static void
vl_api_nat_set_addr_and_port_alloc_alg_t_handler
(vl_api_nat_set_addr_and_port_alloc_alg_t * mp)
switch (mp->alg)
{
case NAT_ADDR_AND_PORT_ALLOC_ALG_DEFAULT:
- nat_set_alloc_addr_and_port_default ();
+ nat44_ei_set_alloc_default ();
break;
case NAT_ADDR_AND_PORT_ALLOC_ALG_MAPE:
- nat_set_alloc_addr_and_port_mape (ntohs (mp->psid), mp->psid_offset,
- mp->psid_length);
+ nat44_ei_set_alloc_mape (ntohs (mp->psid), mp->psid_offset,
+ mp->psid_length);
break;
case NAT_ADDR_AND_PORT_ALLOC_ALG_RANGE:
port_start = ntohs (mp->start_port);
rv = VNET_API_ERROR_INVALID_VALUE;
goto send_reply;
}
- nat_set_alloc_addr_and_port_range (port_start, port_end);
+ nat44_ei_set_alloc_range (port_start, port_end);
break;
default:
rv = VNET_API_ERROR_INVALID_VALUE;
return;
/* *INDENT-OFF* */
- pool_foreach (i, sm->interfaces,
- ({
+ pool_foreach (i, sm->interfaces)
+ {
send_nat44_interface_details(i, reg, mp->context);
- }));
+ }
/* *INDENT-ON* */
}
return;
/* *INDENT-OFF* */
- pool_foreach (i, sm->output_feature_interfaces,
- ({
+ pool_foreach (i, sm->output_feature_interfaces)
+ {
send_nat44_interface_output_feature_details(i, reg, mp->context);
- }));
+ }
/* *INDENT-ON* */
}
tag = format (0, "%s", mp->tag);
vec_terminate_c_string (tag);
- rv = snat_add_static_mapping (local_addr, external_addr, local_port,
- external_port, vrf_id,
- mp->flags & NAT_API_IS_ADDR_ONLY,
- external_sw_if_index, proto,
- mp->is_add, twice_nat,
- mp->flags & NAT_API_IS_OUT2IN_ONLY, tag, 0,
- pool_addr, 0);
+ rv = snat_add_static_mapping (
+ local_addr, external_addr, local_port, external_port, vrf_id,
+ mp->flags & NAT_API_IS_ADDR_ONLY, external_sw_if_index, proto, mp->is_add,
+ twice_nat, mp->flags & NAT_API_IS_OUT2IN_ONLY, tag, 0, pool_addr, 0);
vec_free (tag);
REPLY_MACRO (VL_API_NAT44_ADD_DEL_STATIC_MAPPING_REPLY);
return;
/* *INDENT-OFF* */
- pool_foreach (m, sm->static_mappings,
- ({
+ pool_foreach (m, sm->static_mappings)
+ {
if (!is_identity_static_mapping(m) && !is_lb_static_mapping (m))
send_nat44_static_mapping_details (m, reg, mp->context);
- }));
+ }
/* *INDENT-ON* */
for (j = 0; j < vec_len (sm->to_resolve); j++)
return;
/* *INDENT-OFF* */
- pool_foreach (m, sm->static_mappings,
- ({
+ pool_foreach (m, sm->static_mappings)
+ {
if (is_identity_static_mapping(m) && !is_lb_static_mapping (m))
{
- pool_foreach_index (j, m->locals,
- ({
+ pool_foreach_index (j, m->locals)
+ {
send_nat44_identity_mapping_details (m, j, reg, mp->context);
- }));
+ }
}
- }));
+ }
/* *INDENT-ON* */
for (j = 0; j < vec_len (sm->to_resolve); j++)
int rv = 0;
u8 is_del;
+ if (sm->static_mapping_only)
+ {
+ rv = VNET_API_ERROR_FEATURE_DISABLED;
+ goto send_reply;
+ }
+
is_del = !mp->is_add;
VALIDATE_SW_IF_INDEX (mp);
mp->flags & NAT_API_IS_TWICE_NAT);
BAD_SW_IF_INDEX_LABEL;
+
+send_reply:
REPLY_MACRO (VL_API_NAT44_ADD_DEL_INTERFACE_ADDR_REPLY);
}
{
snat_session_t *s;
/* *INDENT-OFF* */
- pool_foreach (s, tsm->sessions, { nat_ed_user_create_helper (tsm, s); });
+ pool_foreach (s, tsm->sessions) { nat_ed_user_create_helper (tsm, s); }
/* *INDENT-ON* */
}
{
nat_ed_users_create (tsm);
}
- pool_foreach (u, tsm->users,
- ({
+ pool_foreach (u, tsm->users)
+ {
send_nat44_user_details (u, reg, mp->context);
- }));
+ }
if (sm->endpoint_dependent)
{
nat_ed_users_destroy (tsm);
else
{
/* *INDENT-OFF* */
- pool_foreach (s, tsm->sessions, {
+ pool_foreach (s, tsm->sessions) {
if (s->in2out.addr.as_u32 == ukey.addr.as_u32)
{
send_nat44_user_session_details (s, reg, mp->context);
}
- });
+ }
/* *INDENT-ON* */
}
}
rv =
nat44_lb_static_mapping_add_del_local (e_addr,
- clib_net_to_host_u16
- (mp->external_port), l_addr,
- clib_net_to_host_u16 (mp->
- local.port),
+ mp->external_port,
+ l_addr,
+ mp->local.port,
proto,
clib_net_to_host_u32 (mp->
local.vrf_id),
locals = (vl_api_nat44_lb_addr_port_t *) rmp->locals;
/* *INDENT-OFF* */
- pool_foreach (ap, m->locals,
- ({
+ pool_foreach (ap, m->locals)
+ {
clib_memcpy (locals->addr, &(ap->addr), 4);
locals->port = ap->port;
locals->probability = ap->probability;
locals->vrf_id = ntohl (ap->vrf_id);
locals++;
local_num++;
- }));
+ }
/* *INDENT-ON* */
rmp->local_num = ntohl (local_num);
return;
/* *INDENT-OFF* */
- pool_foreach (m, sm->static_mappings,
- ({
+ pool_foreach (m, sm->static_mappings)
+ {
if (is_lb_static_mapping(m))
send_nat44_lb_static_mapping_details (m, reg, mp->context);
- }));
+ }
/* *INDENT-ON* */
}
nat44_del_ed_session (sm, &addr, port, &eh_addr, eh_port, mp->protocol,
vrf_id, is_in);
else
- rv = nat44_del_session (sm, &addr, port, proto, vrf_id, is_in);
+ rv = nat44_ei_del_session (sm, &addr, port, proto, vrf_id, is_in);
REPLY_MACRO (VL_API_NAT44_DEL_SESSION_REPLY);
}
/* *INDENT-OFF* */
vec_foreach (tsm, sm->per_thread_data)
{
- pool_foreach (s, tsm->sessions,
- ({
+ pool_foreach (s, tsm->sessions)
+ {
if (is_fwd_bypass_session(s))
{
vec_add1 (ses_to_be_removed, s - tsm->sessions);
}
- }));
+ }
if(sm->endpoint_dependent){
vec_foreach (ses_index, ses_to_be_removed)
{