* @brief NAT44 plugin API implementation
*/
-#define vl_api_nat44_lb_static_mapping_details_t_endian vl_noop_handler
-#define vl_api_nat44_add_del_lb_static_mapping_t_endian vl_noop_handler
-
#include <vnet/ip/ip_types_api.h>
#include <vlibmemory/api.h>
rmp->user_buckets = htonl (sm->user_buckets);
rmp->translation_buckets = htonl (sm->translation_buckets);
+ rmp->timeouts.udp = htonl (sm->timeouts.udp);
+ rmp->timeouts.tcp_established = htonl (sm->timeouts.tcp.established);
+ rmp->timeouts.tcp_transitory = htonl (sm->timeouts.tcp.transitory);
+ rmp->timeouts.icmp = htonl (sm->timeouts.icmp);
+
+ rmp->forwarding_enabled = sm->forwarding_enabled == 1;
+ // consider how to split functionality between subplugins
+ rmp->ipfix_logging_enabled = nat_ipfix_logging_enabled ();
+
if (rc->endpoint_dependent)
rmp->flags |= NAT44_IS_ENDPOINT_DEPENDENT;
else
vl_api_nat_set_timeouts_reply_t *rmp;
int rv = 0;
- sm->udp_timeout = ntohl (mp->udp);
- sm->tcp_established_timeout = ntohl (mp->tcp_established);
- sm->tcp_transitory_timeout = ntohl (mp->tcp_transitory);
- sm->icmp_timeout = ntohl (mp->icmp);
+ sm->timeouts.udp = ntohl (mp->udp);
+ sm->timeouts.tcp.established = ntohl (mp->tcp_established);
+ sm->timeouts.tcp.transitory = ntohl (mp->tcp_transitory);
+ sm->timeouts.icmp = ntohl (mp->icmp);
REPLY_MACRO (VL_API_NAT_SET_TIMEOUTS_REPLY);
}
/* *INDENT-OFF* */
REPLY_MACRO2 (VL_API_NAT_GET_TIMEOUTS_REPLY,
({
- rmp->udp = htonl (sm->udp_timeout);
- rmp->tcp_established = htonl (sm->tcp_established_timeout);
- rmp->tcp_transitory = htonl (sm->tcp_transitory_timeout);
- rmp->icmp = htonl (sm->icmp_timeout);
+ rmp->udp = htonl (sm->timeouts.udp);
+ rmp->tcp_established = htonl (sm->timeouts.tcp.established);
+ rmp->tcp_transitory = htonl (sm->timeouts.tcp.transitory);
+ rmp->icmp = htonl (sm->timeouts.icmp);
}))
/* *INDENT-ON* */
}
int rv = 0;
u16 port_start, port_end;
+ if (sm->endpoint_dependent)
+ {
+ rv = VNET_API_ERROR_UNSUPPORTED;
+ goto send_reply;
+ }
+
switch (mp->alg)
{
case NAT_ADDR_AND_PORT_ALLOC_ALG_DEFAULT:
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* */
}
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++)
{
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* */
}
/* *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)
{