aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugins/nat/nat.api623
-rw-r--r--src/plugins/nat/nat_api.c1275
-rw-r--r--src/plugins/nat/nat_test.c437
-rw-r--r--src/vpp-api/java/jvpp-nat/io/fd/vpp/jvpp/nat/test/FutureApiTest.java20
4 files changed, 231 insertions, 2124 deletions
diff --git a/src/plugins/nat/nat.api b/src/plugins/nat/nat.api
index 9a000d5611f..d515a769cb3 100644
--- a/src/plugins/nat/nat.api
+++ b/src/plugins/nat/nat.api
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-vl_api_version 1.0.0
+vl_api_version 2.0.0
/**
* @file nat.api
@@ -24,627 +24,6 @@ vl_api_version 1.0.0
*/
/*
- * Old "snat" APIs, will be deprecated after 17.10
- */
-
-/** \brief Add/del NAT44 address range
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
- @param is_ip4 - 1 if address type is IPv4
- @param first_ip_address - first IP address
- @param last_ip_address - last IP address
- @param vrf_id - VRF id of tenant, ~0 means independent of VRF
- @param is_add - 1 if add, 0 if delete
-*/
-autoreply define snat_add_address_range {
- u32 client_index;
- u32 context;
- u8 is_ip4;
- u8 first_ip_address[16];
- u8 last_ip_address[16];
- u32 vrf_id;
- u8 is_add;
-};
-
-/** \brief Dump NAT44 addresses
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
-*/
-define snat_address_dump {
- u32 client_index;
- u32 context;
-};
-
-/** \brief NAT44 address details response
- @param context - sender context, to match reply w/ request
- @param is_ip4 - 1 if address type is IPv4
- @param ip_address - IP address
- @param vrf_id - VRF id of tenant, ~0 means independent of VRF
-*/
-define snat_address_details {
- u32 context;
- u8 is_ip4;
- u8 ip_address[16];
- u32 vrf_id;
-};
-
-/** \brief Enable/disable NAT44 feature on the interface
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
- @param is_add - 1 if add, 0 if delete
- @param is_inside - 1 if inside, 0 if outside
- @param sw_if_index - software index of the interface
-*/
-autoreply define snat_interface_add_del_feature {
- u32 client_index;
- u32 context;
- u8 is_add;
- u8 is_inside;
- u32 sw_if_index;
-};
-
-/** \brief Dump interfaces with NAT44 feature
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
-*/
-define snat_interface_dump {
- u32 client_index;
- u32 context;
-};
-
-/** \brief NAT44 interface details response
- @param context - sender context, to match reply w/ request
- @param is_inside - 1 if inside, 0 if outside
- @param sw_if_index - software index of the interface
-*/
-define snat_interface_details {
- u32 context;
- u8 is_inside;
- u32 sw_if_index;
-};
-
-/** \brief Enable/disbale NAT44 as an interface output feature (postrouting
- in2out translation)
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
- @param is_add - 1 if add, 0 if delete
- @param is_inside - 1 if inside, 0 if outside
- @param sw_if_index - software index of the interface
-*/
-autoreply define snat_interface_add_del_output_feature {
- u32 client_index;
- u32 context;
- u8 is_add;
- u8 is_inside;
- u32 sw_if_index;
-};
-
-/** \brief Dump interfaces with NAT44 output feature
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
-*/
-define snat_interface_output_feature_dump {
- u32 client_index;
- u32 context;
-};
-
-/** \brief NAT44 interface with output feature details response
- @param context - sender context, to match reply w/ request
- @param is_inside - 1 if inside, 0 if outside
- @param sw_if_index - software index of the interface
-*/
-define snat_interface_output_feature_details {
- u32 context;
- u8 is_inside;
- u32 sw_if_index;
-};
-
-/** \brief Add/delete NAT44 static mapping
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
- @param is_add - 1 if add, 0 if delete
- @param is_ip4 - 1 if address type is IPv4
- @param addr_only - 1 if address only mapping
- @param local_ip_address - local IP address
- @param external_ip_address - external IP address
- @param protocol - IP protocol
- @param local_port - local port number
- @param external_port - external port number
- @param external_sw_if_index - external interface (if set
- external_ip_address is ignored, ~0 means not
- used)
- @param vfr_id - VRF ID
-*/
-autoreply define snat_add_static_mapping {
- u32 client_index;
- u32 context;
- u8 is_add;
- u8 is_ip4;
- u8 addr_only;
- u8 local_ip_address[16];
- u8 external_ip_address[16];
- u8 protocol;
- u16 local_port;
- u16 external_port;
- u32 external_sw_if_index;
- u32 vrf_id;
-};
-
-/** \brief Dump NAT44 static mappings
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
-*/
-define snat_static_mapping_dump {
- u32 client_index;
- u32 context;
-};
-
-/** \brief NAT44 static mapping details response
- @param context - sender context, to match reply w/ request
- @param is_ip4 - 1 if address type is IPv4
- @param addr_only - 1 if address only mapping
- @param local_ip_address - local IP address
- @param external_ip_address - external IP address
- @param protocol - IP protocol
- @param local_port - local port number
- @param external_port - external port number
- @param external_sw_if_index - external interface
- @param vfr_id - VRF ID
-*/
-define snat_static_mapping_details {
- u32 context;
- u8 is_ip4;
- u8 addr_only;
- u8 local_ip_address[16];
- u8 external_ip_address[16];
- u8 protocol;
- u16 local_port;
- u16 external_port;
- u32 external_sw_if_index;
- u32 vrf_id;
-};
-
-/** \brief Control ping from client to api server request
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
-*/
-define snat_control_ping
-{
- u32 client_index;
- u32 context;
-};
-
-/** \brief Control ping from the client to the server response
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
- @param retval - return code for the request
- @param vpe_pid - the pid of the vpe, returned by the server
-*/
-define snat_control_ping_reply
-{
- u32 context;
- i32 retval;
- u32 client_index;
- u32 vpe_pid;
-};
-
-/** \brief Show NAT plugin startup config
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
-*/
-define snat_show_config
-{
- u32 client_index;
- u32 context;
-};
-
-/** \brief Show NAT plugin startup config reply
- @param context - sender context, to match reply w/ request
- @param retval - return code for the request
- @param static_mapping_only - if 1 dynamic translations disabled
- @param static_mapping_connection_tracking - if 1 create session data
- @param deterministic - if 1 deterministic mapping
- @param translation_buckets - number of translation hash buckets
- @param translation_memory_size - translation hash memory size
- @param user_buckets - number of user hash buckets
- @param user_memory_size - user hash memory size
- @param max_translations_per_user - maximum number of translations per user
- @param outside_vrf_id - outside VRF id
- @param inside_vrf_id - default inside VRF id
-*/
-define snat_show_config_reply
-{
- u32 context;
- i32 retval;
- u8 static_mapping_only;
- u8 static_mapping_connection_tracking;
- u8 deterministic;
- u32 translation_buckets;
- u32 translation_memory_size;
- u32 user_buckets;
- u32 user_memory_size;
- u32 max_translations_per_user;
- u32 outside_vrf_id;
- u32 inside_vrf_id;
-};
-
-/** \brief Set NAT workers
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
- @param worker_mask - NAT workers mask
-*/
-autoreply define snat_set_workers {
- u32 client_index;
- u32 context;
- u64 worker_mask;
-};
-
-/** \brief Dump NAT workers
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
-*/
-define snat_worker_dump {
- u32 client_index;
- u32 context;
-};
-
-/** \brief NAT workers details response
- @param context - sender context, to match reply w/ request
- @param worker_index - worker index
- @param lcore_id - lcore ID
- @param name - worker name
-*/
-define snat_worker_details {
- u32 context;
- u32 worker_index;
- u32 lcore_id;
- u8 name[64];
-};
-
-/** \brief Add/delete NAT44 pool address from specific interfce
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
- @param is_add - 1 if add, 0 if delete
- @param sw_if_index - software index of the interface
-*/
-autoreply define snat_add_del_interface_addr {
- u32 client_index;
- u32 context;
- u8 is_add;
- u8 is_inside;
- u32 sw_if_index;
-};
-
-/** \brief Dump NAT44 pool addresses interfaces
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
-*/
-define snat_interface_addr_dump {
- u32 client_index;
- u32 context;
-};
-
-/** \brief NAT44 pool addresses interfaces details response
- @param context - sender context, to match reply w/ request
- @param sw_if_index - software index of the interface
-*/
-define snat_interface_addr_details {
- u32 context;
- u32 sw_if_index;
-};
-
-/** \brief Enable/disable NAT IPFIX logging
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
- @param domain_id - observation domain ID
- @param src_port - source port number
- @param enable - 1 if enable, 0 if disable
-*/
-autoreply define snat_ipfix_enable_disable {
- u32 client_index;
- u32 context;
- u32 domain_id;
- u16 src_port;
- u8 enable;
-};
-
-/** \brief Dump NAT44 users
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
-*/
-define snat_user_dump {
- u32 client_index;
- u32 context;
-};
-
-/** \brief NAT44 users response
- @param context - sender context, to match reply w/ request
- @vrf_id - VRF ID
- @param is_ip4 - 1 if address type is IPv4
- @param ip_adress - IP address
- @param nsessions - number of dynamic sessions
- @param nstaticsessions - number of static sessions
-*/
-define snat_user_details {
- u32 context;
- u32 vrf_id;
- u8 is_ip4;
- u8 ip_address[16];
- u32 nsessions;
- u32 nstaticsessions;
-};
-
-/** \brief NAT44 user's sessions
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
- @param is_ip4 - 1 if address type is IPv4
- @param user_ip - IP address of the user to dump
- @param vrf_id - VRF_ID
-*/
-define snat_user_session_dump {
- u32 client_index;
- u32 context;
- u8 is_ip4;
- u8 ip_address[16];
- u32 vrf_id;
-};
-
-/** \brief NAT44 user's sessions response
- @param context - sender context, to match reply w/ request
- @param is_ip4 - 1 if address type is IPv4
- @param outside_ip_address - outside IP address
- @param outside_port - outside port
- @param inside_ip_address - inside IP address
- @param inside_port - inside port
- @param protocol - protocol
- @param is_static - 1 if session is static
- @param last_heard - last heard timer
- @param total_bytes - count of bytes sent through session
- @param total_pkts - count of pakets sent through session
-*/
-define snat_user_session_details {
- u32 context;
- u8 is_ip4;
- u8 outside_ip_address[16];
- u16 outside_port;
- u8 inside_ip_address[16];
- u16 inside_port;
- u16 protocol;
- u8 is_static;
- u64 last_heard;
- u64 total_bytes;
- u32 total_pkts;
-};
-
-/** \brief Add/delete NAT deterministic mapping
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
- @param is_add - 1 if add, 0 if delete
- @param is_ip4 - 1 if address type is IPv4
- @param in_addr - inside IP address
- @param in_plen - inside IP address prefix length
- @param out_addr - outside IP address
- @param out_addr - outside IP address prefix length
-*/
-autoreply define snat_add_det_map {
- u32 client_index;
- u32 context;
- u8 is_add;
- u8 is_ip4;
- u8 addr_only;
- u8 in_addr[16];
- u8 in_plen;
- u8 out_addr[16];
- u8 out_plen;
-};
-
-/** \brief Get outside address and port range from inside address
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
- @param is_ip4 - 1 if address type is IPv4
- @param in_addr - inside IP address
-*/
-define snat_det_forward {
- u32 client_index;
- u32 context;
- u8 is_ip4;
- u8 in_addr[16];
-};
-
-/** \brief Get outside address and port range from inside address
- @param context - sender context, to match reply w/ request
- @param retval - return code
- @param out_port_lo - outside port range start
- @param out_port_hi - outside port range end
- @param is_ip4 - 1 if address type is IPv4
- @param out_addr - outside IP address
-*/
-define snat_det_forward_reply {
- u32 context;
- i32 retval;
- u16 out_port_lo;
- u16 out_port_hi;
- u8 is_ip4;
- u8 out_addr[16];
-};
-
-/** \brief Get inside address from outside address and port
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
- @param out_port - outside port
- @param is_ip4 - 1 if address type is IPv4
- @param out_addr - outside IP address
-*/
-define snat_det_reverse {
- u32 client_index;
- u32 context;
- u16 out_port;
- u8 is_ip4;
- u8 out_addr[16];
-};
-
-/** \brief Get inside address from outside address and port reply
- @param context - sender context, to match reply w/ request
- @param retval - return code
- @param is_ip4 - 1 if address type is IPv4
- @param in_addr - inside IP address
-*/
-define snat_det_reverse_reply {
- u32 context;
- i32 retval;
- u8 is_ip4;
- u8 in_addr[16];
-};
-
-/** \brief Dump NAT deterministic mappings
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
-*/
-define snat_det_map_dump {
- u32 client_index;
- u32 context;
-};
-
-/** \brief NAT users response
- @param context - sender context, to match reply w/ request
- @param is_ip4 - 1 if address type is IPv4
- @param in_addr - inside IP address
- @param in_plen - inside IP address prefix length
- @param out_addr - outside IP address
- @param out_plen - outside IP address prefix length
- @param sharing_ratio - outside to inside address sharing ratio
- @param ports_per_host - number of ports available to a host
- @param ses_num - number of sessions belonging to this mapping
-*/
-define snat_det_map_details {
- u32 context;
- u8 is_ip4;
- u8 in_addr[16];
- u8 in_plen;
- u8 out_addr[16];
- u8 out_plen;
- u32 sharing_ratio;
- u16 ports_per_host;
- u32 ses_num;
-};
-
-/** \brief Set values of timeouts for deterministic NAT (seconds, 0 = default)
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
- @param udp - UDP timeout (default 300sec)
- @param tcp_established - TCP established timeout (default 7440sec)
- @param tcp_transitory - TCP transitory timeout (default 240sec)
- @param icmp - ICMP timeout (default 60sec)
-*/
-autoreply define snat_det_set_timeouts {
- u32 client_index;
- u32 context;
- u32 udp;
- u32 tcp_established;
- u32 tcp_transitory;
- u32 icmp;
-};
-
-/** \brief Get values of timeouts for deterministic NAT (seconds)
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
-*/
-define snat_det_get_timeouts {
- u32 client_index;
- u32 context;
-};
-
-/** \brief Get values of timeouts for deterministic NAT reply
- @param context - sender context, to match reply w/ request
- @param retval - return code
- @param udp - UDP timeout (default 300sec)
- @param tcp_established - TCP established timeout (default 7440sec)
- @param tcp_transitory - TCP transitory timeout (default 240sec)
- @param icmp - ICMP timeout (default 60sec)
-*/
-define snat_det_get_timeouts_reply {
- u32 context;
- i32 retval;
- u32 udp;
- u32 tcp_established;
- u32 tcp_transitory;
- u32 icmp;
-};
-
-/** \brief Close deterministic NAT session by outside address and port
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
- @param is_ip4 - 1 if address type is IPv4
- @param out_addr - outside IP address
- @param out_port - outside port
- @param ext_addr - external host address
- @param ext_port - external host port
-*/
-autoreply define snat_det_close_session_out {
- u32 client_index;
- u32 context;
- u8 is_ip4;
- u8 out_addr[16];
- u16 out_port;
- u8 ext_addr[16];
- u16 ext_port;
-};
-
-/** \brief Close deterministic NAT session by inside address and port
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
- @param is_ip4 - 1 if address type is IPv4
- @param in_addr - inside IP address
- @param in_port - inside port
- @param ext_addr - external host address
- @param ext_port - external host port
-*/
-autoreply define snat_det_close_session_in {
- u32 client_index;
- u32 context;
- u8 is_ip4;
- u8 in_addr[16];
- u16 in_port;
- u8 ext_addr[16];
- u16 ext_port;
-};
-
-/** \brief Dump determinstic NAT sessions
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
- @param is_ip4 - 1 if address type is IPv4
- @param user_addr - address of an inside user whose sessions to dump
-*/
-define snat_det_session_dump {
- u32 client_index;
- u32 context;
- u8 is_ip4;
- u8 user_addr[16];
-};
-
-/** \brief Deterministic NAT sessions reply
- @param context - sender context, to match reply w/ request
- @param is_ip4 - 1 if address type is IPv4
- @param in_port - inside port
- @param ext_addr - external host address
- @param ext_port - external host port
- @param out_port - outside NAT port
- @param state - session state
- @param expire - session expiration timestamp
-*/
-define snat_det_session_details {
- u32 client_index;
- u32 context;
- u8 is_ip4;
- u16 in_port;
- u8 ext_addr[16];
- u16 ext_port;
- u16 out_port;
- u8 state;
- u32 expire;
-};
-
-/*
* Common NAT plugin APIs
*/
diff --git a/src/plugins/nat/nat_api.c b/src/plugins/nat/nat_api.c
index 127a2b80bbf..eae9764b89b 100644
--- a/src/plugins/nat/nat_api.c
+++ b/src/plugins/nat/nat_api.c
@@ -60,1249 +60,6 @@
vec_free (s); \
return handle;
-static void
- vl_api_snat_add_address_range_t_handler
- (vl_api_snat_add_address_range_t * mp)
-{
- snat_main_t *sm = &snat_main;
- vl_api_snat_add_address_range_reply_t *rmp;
- ip4_address_t this_addr;
- u32 start_host_order, end_host_order;
- u32 vrf_id;
- int i, count;
- int rv = 0;
- u32 *tmp;
-
- if (mp->is_ip4 != 1)
- {
- rv = VNET_API_ERROR_UNIMPLEMENTED;
- goto send_reply;
- }
-
- if (sm->static_mapping_only)
- {
- rv = VNET_API_ERROR_FEATURE_DISABLED;
- goto send_reply;
- }
-
- tmp = (u32 *) mp->first_ip_address;
- start_host_order = clib_host_to_net_u32 (tmp[0]);
- tmp = (u32 *) mp->last_ip_address;
- end_host_order = clib_host_to_net_u32 (tmp[0]);
-
- count = (end_host_order - start_host_order) + 1;
-
- vrf_id = clib_host_to_net_u32 (mp->vrf_id);
-
- if (count > 1024)
- clib_warning ("%U - %U, %d addresses...",
- format_ip4_address, mp->first_ip_address,
- format_ip4_address, mp->last_ip_address, count);
-
- memcpy (&this_addr.as_u8, mp->first_ip_address, 4);
-
- for (i = 0; i < count; i++)
- {
- if (mp->is_add)
- snat_add_address (sm, &this_addr, vrf_id);
- else
- rv = snat_del_address (sm, this_addr, 0);
-
- if (rv)
- goto send_reply;
-
- increment_v4_address (&this_addr);
- }
-
-send_reply:
- REPLY_MACRO (VL_API_SNAT_ADD_ADDRESS_RANGE_REPLY);
-}
-
-static void *vl_api_snat_add_address_range_t_print
- (vl_api_snat_add_address_range_t * mp, void *handle)
-{
- u8 *s;
-
- s = format (0, "SCRIPT: snat_add_address_range ");
- s = format (s, "%U ", format_ip4_address, mp->first_ip_address);
- if (memcmp (mp->first_ip_address, mp->last_ip_address, 4))
- {
- s = format (s, " - %U ", format_ip4_address, mp->last_ip_address);
- }
- FINISH;
-}
-
-static void
- send_snat_address_details
- (snat_address_t * a, unix_shared_memory_queue_t * q, u32 context)
-{
- vl_api_snat_address_details_t *rmp;
- snat_main_t *sm = &snat_main;
-
- rmp = vl_msg_api_alloc (sizeof (*rmp));
- memset (rmp, 0, sizeof (*rmp));
- rmp->_vl_msg_id = ntohs (VL_API_SNAT_ADDRESS_DETAILS + sm->msg_id_base);
- rmp->is_ip4 = 1;
- clib_memcpy (rmp->ip_address, &(a->addr), 4);
- if (a->fib_index != ~0)
- {
- fib_table_t *fib = fib_table_get (a->fib_index, FIB_PROTOCOL_IP4);
- rmp->vrf_id = ntohl (fib->ft_table_id);
- }
- else
- rmp->vrf_id = ~0;
- rmp->context = context;
-
- vl_msg_api_send_shmem (q, (u8 *) & rmp);
-}
-
-static void
-vl_api_snat_address_dump_t_handler (vl_api_snat_address_dump_t * mp)
-{
- unix_shared_memory_queue_t *q;
- snat_main_t *sm = &snat_main;
- snat_address_t *a;
-
- q = vl_api_client_index_to_input_queue (mp->client_index);
- if (q == 0)
- return;
-
- /* *INDENT-OFF* */
- vec_foreach (a, sm->addresses)
- send_snat_address_details (a, q, mp->context);
- /* *INDENT-ON* */
-}
-
-static void *vl_api_snat_address_dump_t_print
- (vl_api_snat_address_dump_t * mp, void *handle)
-{
- u8 *s;
-
- s = format (0, "SCRIPT: snat_address_dump ");
-
- FINISH;
-}
-
-static void
- vl_api_snat_interface_add_del_feature_t_handler
- (vl_api_snat_interface_add_del_feature_t * mp)
-{
- snat_main_t *sm = &snat_main;
- vl_api_snat_interface_add_del_feature_reply_t *rmp;
- u8 is_del = mp->is_add == 0;
- u32 sw_if_index = ntohl (mp->sw_if_index);
- int rv = 0;
-
- VALIDATE_SW_IF_INDEX (mp);
-
- rv = snat_interface_add_del (sw_if_index, mp->is_inside, is_del);
-
- BAD_SW_IF_INDEX_LABEL;
-
- REPLY_MACRO (VL_API_SNAT_INTERFACE_ADD_DEL_FEATURE_REPLY);
-}
-
-static void *vl_api_snat_interface_add_del_feature_t_print
- (vl_api_snat_interface_add_del_feature_t * mp, void *handle)
-{
- u8 *s;
-
- s = format (0, "SCRIPT: snat_interface_add_del_feature ");
- s = format (s, "sw_if_index %d %s %s",
- clib_host_to_net_u32 (mp->sw_if_index),
- mp->is_inside ? "in" : "out", mp->is_add ? "" : "del");
-
- FINISH;
-}
-
-static void
- send_snat_interface_details
- (snat_interface_t * i, unix_shared_memory_queue_t * q, u32 context)
-{
- vl_api_snat_interface_details_t *rmp;
- snat_main_t *sm = &snat_main;
-
- rmp = vl_msg_api_alloc (sizeof (*rmp));
- memset (rmp, 0, sizeof (*rmp));
- rmp->_vl_msg_id = ntohs (VL_API_SNAT_INTERFACE_DETAILS + sm->msg_id_base);
- rmp->sw_if_index = ntohl (i->sw_if_index);
- rmp->is_inside = nat_interface_is_inside (i);
- rmp->context = context;
-
- vl_msg_api_send_shmem (q, (u8 *) & rmp);
-}
-
-static void
-vl_api_snat_interface_dump_t_handler (vl_api_snat_interface_dump_t * mp)
-{
- unix_shared_memory_queue_t *q;
- snat_main_t *sm = &snat_main;
- snat_interface_t *i;
-
- q = vl_api_client_index_to_input_queue (mp->client_index);
- if (q == 0)
- return;
-
- /* *INDENT-OFF* */
- pool_foreach (i, sm->interfaces,
- ({
- send_snat_interface_details(i, q, mp->context);
- }));
- /* *INDENT-ON* */
-}
-
-static void *vl_api_snat_interface_dump_t_print
- (vl_api_snat_interface_dump_t * mp, void *handle)
-{
- u8 *s;
-
- s = format (0, "SCRIPT: snat_interface_dump ");
-
- FINISH;
-}
-
-static void
- vl_api_snat_interface_add_del_output_feature_t_handler
- (vl_api_snat_interface_add_del_output_feature_t * mp)
-{
- snat_main_t *sm = &snat_main;
- vl_api_snat_interface_add_del_output_feature_reply_t *rmp;
- u8 is_del = mp->is_add == 0;
- u32 sw_if_index = ntohl (mp->sw_if_index);
- int rv = 0;
-
- VALIDATE_SW_IF_INDEX (mp);
-
- rv = snat_interface_add_del_output_feature (sw_if_index, mp->is_inside,
- is_del);
-
- BAD_SW_IF_INDEX_LABEL;
-
- REPLY_MACRO (VL_API_SNAT_INTERFACE_ADD_DEL_OUTPUT_FEATURE_REPLY);
-}
-
-static void *vl_api_snat_interface_add_del_output_feature_t_print
- (vl_api_snat_interface_add_del_output_feature_t * mp, void *handle)
-{
- u8 *s;
-
- s = format (0, "SCRIPT: snat_interface_add_del_output_feature ");
- s = format (s, "sw_if_index %d %s %s",
- clib_host_to_net_u32 (mp->sw_if_index),
- mp->is_inside ? "in" : "out", mp->is_add ? "" : "del");
-
- FINISH;
-}
-
-static void
-send_snat_interface_output_feature_details (snat_interface_t * i,
- unix_shared_memory_queue_t * q,
- u32 context)
-{
- vl_api_snat_interface_output_feature_details_t *rmp;
- snat_main_t *sm = &snat_main;
-
- rmp = vl_msg_api_alloc (sizeof (*rmp));
- memset (rmp, 0, sizeof (*rmp));
- rmp->_vl_msg_id =
- ntohs (VL_API_SNAT_INTERFACE_OUTPUT_FEATURE_DETAILS + sm->msg_id_base);
- rmp->sw_if_index = ntohl (i->sw_if_index);
- rmp->context = context;
- rmp->is_inside = nat_interface_is_inside (i);
-
- vl_msg_api_send_shmem (q, (u8 *) & rmp);
-}
-
-static void
- vl_api_snat_interface_output_feature_dump_t_handler
- (vl_api_snat_interface_output_feature_dump_t * mp)
-{
- unix_shared_memory_queue_t *q;
- snat_main_t *sm = &snat_main;
- snat_interface_t *i;
-
- q = vl_api_client_index_to_input_queue (mp->client_index);
- if (q == 0)
- return;
-
- /* *INDENT-OFF* */
- pool_foreach (i, sm->output_feature_interfaces,
- ({
- send_snat_interface_output_feature_details(i, q, mp->context);
- }));
- /* *INDENT-ON* */
-}
-
-static void *vl_api_snat_interface_output_feature_dump_t_print
- (vl_api_snat_interface_output_feature_dump_t * mp, void *handle)
-{
- u8 *s;
-
- s = format (0, "SCRIPT: snat_interface_output_feature_dump ");
-
- FINISH;
-}
-
-static void
- vl_api_snat_add_static_mapping_t_handler
- (vl_api_snat_add_static_mapping_t * mp)
-{
- snat_main_t *sm = &snat_main;
- vl_api_snat_add_static_mapping_reply_t *rmp;
- ip4_address_t local_addr, external_addr;
- u16 local_port = 0, external_port = 0;
- u32 vrf_id, external_sw_if_index;
- int rv = 0;
- snat_protocol_t proto;
-
- if (mp->is_ip4 != 1)
- {
- rv = VNET_API_ERROR_UNIMPLEMENTED;
- goto send_reply;
- }
-
- memcpy (&local_addr.as_u8, mp->local_ip_address, 4);
- memcpy (&external_addr.as_u8, mp->external_ip_address, 4);
- if (mp->addr_only == 0)
- {
- local_port = clib_net_to_host_u16 (mp->local_port);
- external_port = clib_net_to_host_u16 (mp->external_port);
- }
- vrf_id = clib_net_to_host_u32 (mp->vrf_id);
- external_sw_if_index = clib_net_to_host_u32 (mp->external_sw_if_index);
- proto = ip_proto_to_snat_proto (mp->protocol);
-
- rv = snat_add_static_mapping (local_addr, external_addr, local_port,
- external_port, vrf_id, mp->addr_only,
- external_sw_if_index, proto, mp->is_add);
-
-send_reply:
- REPLY_MACRO (VL_API_SNAT_ADD_ADDRESS_RANGE_REPLY);
-}
-
-static void *vl_api_snat_add_static_mapping_t_print
- (vl_api_snat_add_static_mapping_t * mp, void *handle)
-{
- u8 *s;
-
- s = format (0, "SCRIPT: snat_add_static_mapping ");
- s = format (s, "protocol %d local_addr %U external_addr %U ",
- mp->protocol,
- format_ip4_address, mp->local_ip_address,
- format_ip4_address, mp->external_ip_address);
-
- if (mp->addr_only == 0)
- s = format (s, "local_port %d external_port %d ",
- clib_net_to_host_u16 (mp->local_port),
- clib_net_to_host_u16 (mp->external_port));
-
- if (mp->vrf_id != ~0)
- s = format (s, "vrf %d", clib_net_to_host_u32 (mp->vrf_id));
-
- if (mp->external_sw_if_index != ~0)
- s = format (s, "external_sw_if_index %d",
- clib_net_to_host_u32 (mp->external_sw_if_index));
- FINISH;
-}
-
-static void
- send_snat_static_mapping_details
- (snat_static_mapping_t * m, unix_shared_memory_queue_t * q, u32 context)
-{
- vl_api_snat_static_mapping_details_t *rmp;
- snat_main_t *sm = &snat_main;
-
- rmp = vl_msg_api_alloc (sizeof (*rmp));
- memset (rmp, 0, sizeof (*rmp));
- rmp->_vl_msg_id =
- ntohs (VL_API_SNAT_STATIC_MAPPING_DETAILS + sm->msg_id_base);
- rmp->is_ip4 = 1;
- rmp->addr_only = m->addr_only;
- clib_memcpy (rmp->local_ip_address, &(m->local_addr), 4);
- clib_memcpy (rmp->external_ip_address, &(m->external_addr), 4);
- rmp->local_port = htons (m->local_port);
- rmp->external_port = htons (m->external_port);
- rmp->external_sw_if_index = ~0;
- rmp->vrf_id = htonl (m->vrf_id);
- rmp->protocol = snat_proto_to_ip_proto (m->proto);
- rmp->context = context;
-
- vl_msg_api_send_shmem (q, (u8 *) & rmp);
-}
-
-static void
- send_snat_static_map_resolve_details
- (snat_static_map_resolve_t * m, unix_shared_memory_queue_t * q, u32 context)
-{
- vl_api_snat_static_mapping_details_t *rmp;
- snat_main_t *sm = &snat_main;
-
- rmp = vl_msg_api_alloc (sizeof (*rmp));
- memset (rmp, 0, sizeof (*rmp));
- rmp->_vl_msg_id =
- ntohs (VL_API_SNAT_STATIC_MAPPING_DETAILS + sm->msg_id_base);
- rmp->is_ip4 = 1;
- rmp->addr_only = m->addr_only;
- clib_memcpy (rmp->local_ip_address, &(m->l_addr), 4);
- rmp->local_port = htons (m->l_port);
- rmp->external_port = htons (m->e_port);
- rmp->external_sw_if_index = htonl (m->sw_if_index);
- rmp->vrf_id = htonl (m->vrf_id);
- rmp->protocol = snat_proto_to_ip_proto (m->proto);
- rmp->context = context;
-
- vl_msg_api_send_shmem (q, (u8 *) & rmp);
-}
-
-static void
- vl_api_snat_static_mapping_dump_t_handler
- (vl_api_snat_static_mapping_dump_t * mp)
-{
- unix_shared_memory_queue_t *q;
- snat_main_t *sm = &snat_main;
- snat_static_mapping_t *m;
- snat_static_map_resolve_t *rp;
- int j;
-
- q = vl_api_client_index_to_input_queue (mp->client_index);
- if (q == 0)
- return;
-
- /* *INDENT-OFF* */
- pool_foreach (m, sm->static_mappings,
- ({
- if (!vec_len(m->locals))
- send_snat_static_mapping_details (m, q, mp->context);
- }));
- /* *INDENT-ON* */
-
- for (j = 0; j < vec_len (sm->to_resolve); j++)
- {
- rp = sm->to_resolve + j;
- send_snat_static_map_resolve_details (rp, q, mp->context);
- }
-}
-
-static void *vl_api_snat_static_mapping_dump_t_print
- (vl_api_snat_static_mapping_dump_t * mp, void *handle)
-{
- u8 *s;
-
- s = format (0, "SCRIPT: snat_static_mapping_dump ");
-
- FINISH;
-}
-
-static void
-vl_api_snat_control_ping_t_handler (vl_api_snat_control_ping_t * mp)
-{
- vl_api_snat_control_ping_reply_t *rmp;
- snat_main_t *sm = &snat_main;
- int rv = 0;
-
- /* *INDENT-OFF* */
- REPLY_MACRO2 (VL_API_SNAT_CONTROL_PING_REPLY,
- ({
- rmp->vpe_pid = ntohl (getpid ());
- }));
- /* *INDENT-ON* */
-}
-
-static void *vl_api_snat_control_ping_t_print
- (vl_api_snat_control_ping_t * mp, void *handle)
-{
- u8 *s;
-
- s = format (0, "SCRIPT: snat_control_ping ");
-
- FINISH;
-}
-
-static void
-vl_api_snat_show_config_t_handler (vl_api_snat_show_config_t * mp)
-{
- vl_api_snat_show_config_reply_t *rmp;
- snat_main_t *sm = &snat_main;
- int rv = 0;
-
- /* *INDENT-OFF* */
- REPLY_MACRO2 (VL_API_SNAT_SHOW_CONFIG_REPLY,
- ({
- rmp->translation_buckets = htonl (sm->translation_buckets);
- rmp->translation_memory_size = htonl (sm->translation_memory_size);
- rmp->user_buckets = htonl (sm->user_buckets);
- rmp->user_memory_size = htonl (sm->user_memory_size);
- rmp->max_translations_per_user = htonl (sm->max_translations_per_user);
- rmp->outside_vrf_id = htonl (sm->outside_vrf_id);
- rmp->inside_vrf_id = htonl (sm->inside_vrf_id);
- rmp->static_mapping_only = sm->static_mapping_only;
- rmp->static_mapping_connection_tracking =
- sm->static_mapping_connection_tracking;
- rmp->deterministic = sm->deterministic;
- }));
- /* *INDENT-ON* */
-}
-
-static void *vl_api_snat_show_config_t_print
- (vl_api_snat_show_config_t * mp, void *handle)
-{
- u8 *s;
-
- s = format (0, "SCRIPT: snat_show_config ");
-
- FINISH;
-}
-
-static void
-vl_api_snat_set_workers_t_handler (vl_api_snat_set_workers_t * mp)
-{
- snat_main_t *sm = &snat_main;
- vl_api_snat_set_workers_reply_t *rmp;
- int rv = 0;
- uword *bitmap = 0;
- u64 mask = clib_net_to_host_u64 (mp->worker_mask);
-
- if (sm->num_workers < 2)
- {
- rv = VNET_API_ERROR_FEATURE_DISABLED;
- goto send_reply;
- }
-
- bitmap = clib_bitmap_set_multiple (bitmap, 0, mask, BITS (mask));
- rv = snat_set_workers (bitmap);
- clib_bitmap_free (bitmap);
-
-send_reply:
- REPLY_MACRO (VL_API_SNAT_SET_WORKERS_REPLY);
-}
-
-static void *vl_api_snat_set_workers_t_print
- (vl_api_snat_set_workers_t * mp, void *handle)
-{
- u8 *s;
- uword *bitmap = 0;
- u8 first = 1;
- int i;
- u64 mask = clib_net_to_host_u64 (mp->worker_mask);
-
- s = format (0, "SCRIPT: snat_set_workers ");
- bitmap = clib_bitmap_set_multiple (bitmap, 0, mask, BITS (mask));
- /* *INDENT-OFF* */
- clib_bitmap_foreach (i, bitmap,
- ({
- if (first)
- s = format (s, "%d", i);
- else
- s = format (s, ",%d", i);
- first = 0;
- }));
- /* *INDENT-ON* */
- clib_bitmap_free (bitmap);
- FINISH;
-}
-
-static void
- send_snat_worker_details
- (u32 worker_index, unix_shared_memory_queue_t * q, u32 context)
-{
- vl_api_snat_worker_details_t *rmp;
- snat_main_t *sm = &snat_main;
- vlib_worker_thread_t *w =
- vlib_worker_threads + worker_index + sm->first_worker_index;
-
- rmp = vl_msg_api_alloc (sizeof (*rmp));
- memset (rmp, 0, sizeof (*rmp));
- rmp->_vl_msg_id = ntohs (VL_API_SNAT_WORKER_DETAILS + sm->msg_id_base);
- rmp->context = context;
- rmp->worker_index = htonl (worker_index);
- rmp->lcore_id = htonl (w->lcore_id);
- strncpy ((char *) rmp->name, (char *) w->name, ARRAY_LEN (rmp->name) - 1);
-
- vl_msg_api_send_shmem (q, (u8 *) & rmp);
-}
-
-static void
-vl_api_snat_worker_dump_t_handler (vl_api_snat_worker_dump_t * mp)
-{
- unix_shared_memory_queue_t *q;
- snat_main_t *sm = &snat_main;
- u32 *worker_index;
-
- q = vl_api_client_index_to_input_queue (mp->client_index);
- if (q == 0)
- return;
-
- /* *INDENT-OFF* */
- vec_foreach (worker_index, sm->workers)
- send_snat_worker_details(*worker_index, q, mp->context);
- /* *INDENT-ON* */
-}
-
-static void *vl_api_snat_worker_dump_t_print
- (vl_api_snat_worker_dump_t * mp, void *handle)
-{
- u8 *s;
-
- s = format (0, "SCRIPT: snat_worker_dump ");
-
- FINISH;
-}
-
-static void
- vl_api_snat_add_del_interface_addr_t_handler
- (vl_api_snat_add_del_interface_addr_t * mp)
-{
- snat_main_t *sm = &snat_main;
- vl_api_snat_add_del_interface_addr_reply_t *rmp;
- u8 is_del = mp->is_add == 0;
- u32 sw_if_index = ntohl (mp->sw_if_index);
- int rv = 0;
-
- VALIDATE_SW_IF_INDEX (mp);
-
- rv = snat_add_interface_address (sm, sw_if_index, is_del);
-
- BAD_SW_IF_INDEX_LABEL;
-
- REPLY_MACRO (VL_API_SNAT_ADD_DEL_INTERFACE_ADDR_REPLY);
-}
-
-static void *vl_api_snat_add_del_interface_addr_t_print
- (vl_api_snat_add_del_interface_addr_t * mp, void *handle)
-{
- u8 *s;
-
- s = format (0, "SCRIPT: snat_add_del_interface_addr ");
- s = format (s, "sw_if_index %d %s",
- clib_host_to_net_u32 (mp->sw_if_index),
- mp->is_add ? "" : "del");
-
- FINISH;
-}
-
-static void
- send_snat_interface_addr_details
- (u32 sw_if_index, unix_shared_memory_queue_t * q, u32 context)
-{
- vl_api_snat_interface_addr_details_t *rmp;
- snat_main_t *sm = &snat_main;
-
- rmp = vl_msg_api_alloc (sizeof (*rmp));
- memset (rmp, 0, sizeof (*rmp));
- rmp->_vl_msg_id =
- ntohs (VL_API_SNAT_INTERFACE_ADDR_DETAILS + sm->msg_id_base);
- rmp->sw_if_index = ntohl (sw_if_index);
- rmp->context = context;
-
- vl_msg_api_send_shmem (q, (u8 *) & rmp);
-}
-
-static void
- vl_api_snat_interface_addr_dump_t_handler
- (vl_api_snat_interface_addr_dump_t * mp)
-{
- unix_shared_memory_queue_t *q;
- snat_main_t *sm = &snat_main;
- u32 *i;
-
- q = vl_api_client_index_to_input_queue (mp->client_index);
- if (q == 0)
- return;
-
- /* *INDENT-OFF* */
- vec_foreach (i, sm->auto_add_sw_if_indices)
- send_snat_interface_addr_details(*i, q, mp->context);
- /* *INDENT-ON* */
-}
-
-static void *vl_api_snat_interface_addr_dump_t_print
- (vl_api_snat_interface_addr_dump_t * mp, void *handle)
-{
- u8 *s;
-
- s = format (0, "SCRIPT: snat_interface_addr_dump ");
-
- FINISH;
-}
-
-static void
- vl_api_snat_ipfix_enable_disable_t_handler
- (vl_api_snat_ipfix_enable_disable_t * mp)
-{
- snat_main_t *sm = &snat_main;
- vl_api_snat_ipfix_enable_disable_reply_t *rmp;
- int rv = 0;
-
- rv = snat_ipfix_logging_enable_disable (mp->enable,
- clib_host_to_net_u32
- (mp->domain_id),
- clib_host_to_net_u16
- (mp->src_port));
-
- REPLY_MACRO (VL_API_SNAT_IPFIX_ENABLE_DISABLE_REPLY);
-}
-
-static void *vl_api_snat_ipfix_enable_disable_t_print
- (vl_api_snat_ipfix_enable_disable_t * mp, void *handle)
-{
- u8 *s;
-
- s = format (0, "SCRIPT: snat_ipfix_enable_disable ");
- if (mp->domain_id)
- s = format (s, "domain %d ", clib_net_to_host_u32 (mp->domain_id));
- if (mp->src_port)
- s = format (s, "src_port %d ", clib_net_to_host_u16 (mp->src_port));
- if (!mp->enable)
- s = format (s, "disable ");
-
- FINISH;
-}
-
-static void
- send_snat_user_details
- (snat_user_t * u, unix_shared_memory_queue_t * q, u32 context)
-{
- vl_api_snat_user_details_t *rmp;
- snat_main_t *sm = &snat_main;
- fib_table_t *fib = fib_table_get (u->fib_index, FIB_PROTOCOL_IP4);
-
- rmp = vl_msg_api_alloc (sizeof (*rmp));
- memset (rmp, 0, sizeof (*rmp));
- rmp->_vl_msg_id = ntohs (VL_API_SNAT_USER_DETAILS + sm->msg_id_base);
-
- rmp->vrf_id = ntohl (fib->ft_table_id);
-
- rmp->is_ip4 = 1;
- clib_memcpy (rmp->ip_address, &(u->addr), 4);
- rmp->nsessions = ntohl (u->nsessions);
- rmp->nstaticsessions = ntohl (u->nstaticsessions);
- rmp->context = context;
-
- vl_msg_api_send_shmem (q, (u8 *) & rmp);
-}
-
-static void
-vl_api_snat_user_dump_t_handler (vl_api_snat_user_dump_t * mp)
-{
- unix_shared_memory_queue_t *q;
- snat_main_t *sm = &snat_main;
- snat_main_per_thread_data_t *tsm;
- snat_user_t *u;
-
- q = vl_api_client_index_to_input_queue (mp->client_index);
- if (q == 0)
- return;
-
- /* *INDENT-OFF* */
- vec_foreach (tsm, sm->per_thread_data)
- vec_foreach (u, tsm->users)
- send_snat_user_details (u, q, mp->context);
- /* *INDENT-ON* */
-}
-
-static void *vl_api_snat_user_dump_t_print
- (vl_api_snat_user_dump_t * mp, void *handle)
-{
- u8 *s;
-
- s = format (0, "SCRIPT: snat_user_dump ");
-
- FINISH;
-}
-
-static void
- send_snat_user_session_details
- (snat_session_t * s, unix_shared_memory_queue_t * q, u32 context)
-{
- vl_api_snat_user_session_details_t *rmp;
- snat_main_t *sm = &snat_main;
-
- rmp = vl_msg_api_alloc (sizeof (*rmp));
- memset (rmp, 0, sizeof (*rmp));
- rmp->_vl_msg_id =
- ntohs (VL_API_SNAT_USER_SESSION_DETAILS + sm->msg_id_base);
- rmp->is_ip4 = 1;
- clib_memcpy (rmp->outside_ip_address, (&s->out2in.addr), 4);
- clib_memcpy (rmp->inside_ip_address, (&s->in2out.addr), 4);
- rmp->is_static = s->flags & SNAT_SESSION_FLAG_STATIC_MAPPING ? 1 : 0;
- rmp->last_heard = clib_host_to_net_u64 ((u64) s->last_heard);
- rmp->total_bytes = clib_host_to_net_u64 (s->total_bytes);
- rmp->total_pkts = ntohl (s->total_pkts);
- rmp->context = context;
- if (snat_is_unk_proto_session (s))
- {
- 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 (snat_proto_to_ip_proto (s->in2out.protocol));
- }
-
- vl_msg_api_send_shmem (q, (u8 *) & rmp);
-}
-
-static void
- vl_api_snat_user_session_dump_t_handler
- (vl_api_snat_user_session_dump_t * mp)
-{
- unix_shared_memory_queue_t *q;
- snat_main_t *sm = &snat_main;
- snat_main_per_thread_data_t *tsm;
- snat_session_t *s;
- clib_bihash_kv_8_8_t key, value;
- snat_user_key_t ukey;
- snat_user_t *u;
- u32 session_index, head_index, elt_index;
- dlist_elt_t *head, *elt;
- ip4_header_t ip;
-
- q = vl_api_client_index_to_input_queue (mp->client_index);
- if (q == 0)
- return;
- if (!mp->is_ip4)
- return;
-
- clib_memcpy (&ukey.addr, mp->ip_address, 4);
- ip.src_address.as_u32 = ukey.addr.as_u32;
- ukey.fib_index = fib_table_find (FIB_PROTOCOL_IP4, ntohl (mp->vrf_id));
- key.key = ukey.as_u64;
- if (sm->num_workers)
- tsm =
- vec_elt_at_index (sm->per_thread_data,
- sm->worker_in2out_cb (&ip, ukey.fib_index));
- else
- tsm = vec_elt_at_index (sm->per_thread_data, sm->num_workers);
- if (clib_bihash_search_8_8 (&tsm->user_hash, &key, &value))
- return;
- u = pool_elt_at_index (tsm->users, value.value);
- if (!u->nsessions && !u->nstaticsessions)
- return;
-
- head_index = u->sessions_per_user_list_head_index;
- head = pool_elt_at_index (tsm->list_pool, head_index);
- elt_index = head->next;
- elt = pool_elt_at_index (tsm->list_pool, elt_index);
- session_index = elt->value;
- while (session_index != ~0)
- {
- s = pool_elt_at_index (tsm->sessions, session_index);
-
- send_snat_user_session_details (s, q, mp->context);
-
- elt_index = elt->next;
- elt = pool_elt_at_index (tsm->list_pool, elt_index);
- session_index = elt->value;
- }
-}
-
-static void *vl_api_snat_user_session_dump_t_print
- (vl_api_snat_user_session_dump_t * mp, void *handle)
-{
- u8 *s;
-
- s = format (0, "SCRIPT: snat_user_session_dump ");
- s = format (s, "ip_address %U vrf_id %d\n",
- format_ip4_address, mp->ip_address,
- clib_net_to_host_u32 (mp->vrf_id));
-
- FINISH;
-}
-
-/******************************************************************/
-/*** detrministic NAT/CGN (old, will be deprecated after 17.10) ***/
-/******************************************************************/
-
-static void
-vl_api_snat_add_det_map_t_handler (vl_api_snat_add_det_map_t * mp)
-{
- snat_main_t *sm = &snat_main;
- vl_api_snat_add_det_map_reply_t *rmp;
- int rv = 0;
- ip4_address_t in_addr, out_addr;
-
- clib_memcpy (&in_addr, mp->in_addr, 4);
- clib_memcpy (&out_addr, mp->out_addr, 4);
- rv = snat_det_add_map (sm, &in_addr, mp->in_plen, &out_addr,
- mp->out_plen, mp->is_add);
-
- REPLY_MACRO (VL_API_SNAT_ADD_DET_MAP_REPLY);
-}
-
-static void *vl_api_snat_add_det_map_t_print
- (vl_api_snat_add_det_map_t * mp, void *handle)
-{
- u8 *s;
-
- s = format (0, "SCRIPT: snat_add_det_map ");
- s = format (s, "inside address %U/%d outside address %U/%d\n",
- format_ip4_address, mp->in_addr, mp->in_plen,
- format_ip4_address, mp->out_addr, mp->out_plen);
-
- FINISH;
-}
-
-static void
-vl_api_snat_det_forward_t_handler (vl_api_snat_det_forward_t * mp)
-{
- snat_main_t *sm = &snat_main;
- vl_api_snat_det_forward_reply_t *rmp;
- int rv = 0;
- u16 lo_port = 0, hi_port = 0;
- snat_det_map_t *dm;
- ip4_address_t in_addr, out_addr;
-
- out_addr.as_u32 = 0;
- clib_memcpy (&in_addr, mp->in_addr, 4);
- dm = snat_det_map_by_user (sm, &in_addr);
- if (!dm)
- {
- rv = VNET_API_ERROR_NO_SUCH_ENTRY;
- goto send_reply;
- }
-
- snat_det_forward (dm, &in_addr, &out_addr, &lo_port);
- hi_port = lo_port + dm->ports_per_host - 1;
-
-send_reply:
- /* *INDENT-OFF* */
- REPLY_MACRO2 (VL_API_SNAT_DET_FORWARD_REPLY,
- ({
- rmp->out_port_lo = ntohs (lo_port);
- rmp->out_port_hi = ntohs (hi_port);
- rmp->is_ip4 = 1;
- memset (rmp->out_addr, 0, 16);
- clib_memcpy (rmp->out_addr, &out_addr, 4);
- }))
- /* *INDENT-ON* */
-}
-
-static void *vl_api_snat_det_forward_t_print
- (vl_api_snat_det_forward_t * mp, void *handle)
-{
- u8 *s;
-
- s = format (0, "SCRIPT: smat_det_forward_t");
- s = format (s, "inside ip address %U\n", format_ip4_address, mp->in_addr);
-
- FINISH;
-}
-
-static void
-vl_api_snat_det_reverse_t_handler (vl_api_snat_det_reverse_t * mp)
-{
- snat_main_t *sm = &snat_main;
- vl_api_snat_det_reverse_reply_t *rmp;
- int rv = 0;
- ip4_address_t out_addr, in_addr;
- snat_det_map_t *dm;
-
- in_addr.as_u32 = 0;
- clib_memcpy (&out_addr, mp->out_addr, 4);
- dm = snat_det_map_by_out (sm, &out_addr);
- if (!dm)
- {
- rv = VNET_API_ERROR_NO_SUCH_ENTRY;
- goto send_reply;
- }
-
- snat_det_reverse (dm, &out_addr, htons (mp->out_port), &in_addr);
-
-send_reply:
- /* *INDENT-OFF* */
- REPLY_MACRO2 (VL_API_SNAT_DET_REVERSE_REPLY,
- ({
- rmp->is_ip4 = 1;
- memset (rmp->in_addr, 0, 16);
- clib_memcpy (rmp->in_addr, &in_addr, 4);
- }))
- /* *INDENT-ON* */
-}
-
-static void *vl_api_snat_det_reverse_t_print
- (vl_api_snat_det_reverse_t * mp, void *handle)
-{
- u8 *s;
-
- s = format (0, "SCRIPT: smat_det_reverse_t");
- s = format (s, "outside ip address %U outside port %d",
- format_ip4_address, mp->out_addr, ntohs (mp->out_port));
-
- FINISH;
-}
-
-static void
- sent_snat_det_map_details
- (snat_det_map_t * m, unix_shared_memory_queue_t * q, u32 context)
-{
- vl_api_snat_det_map_details_t *rmp;
- snat_main_t *sm = &snat_main;
-
- rmp = vl_msg_api_alloc (sizeof (*rmp));
- memset (rmp, 0, sizeof (*rmp));
- rmp->_vl_msg_id = ntohs (VL_API_SNAT_DET_MAP_DETAILS + sm->msg_id_base);
- rmp->is_ip4 = 1;
- clib_memcpy (rmp->in_addr, &m->in_addr, 4);
- rmp->in_plen = m->in_plen;
- clib_memcpy (rmp->out_addr, &m->out_addr, 4);
- rmp->out_plen = m->out_plen;
- rmp->sharing_ratio = htonl (m->sharing_ratio);
- rmp->ports_per_host = htons (m->ports_per_host);
- rmp->ses_num = htonl (m->ses_num);
- rmp->context = context;
-
- vl_msg_api_send_shmem (q, (u8 *) & rmp);
-}
-
-static void
-vl_api_snat_det_map_dump_t_handler (vl_api_snat_det_map_dump_t * mp)
-{
- unix_shared_memory_queue_t *q;
- snat_main_t *sm = &snat_main;
- snat_det_map_t *m;
-
- q = vl_api_client_index_to_input_queue (mp->client_index);
- if (q == 0)
- return;
-
- /* *INDENT-OFF* */
- vec_foreach(m, sm->det_maps)
- sent_snat_det_map_details(m, q, mp->context);
- /* *INDENT-ON* */
-}
-
-static void *vl_api_snat_det_map_dump_t_print
- (vl_api_snat_det_map_dump_t * mp, void *handle)
-{
- u8 *s;
-
- s = format (0, "SCRIPT: snat_det_map_dump ");
-
- FINISH;
-}
-
-static void
-vl_api_snat_det_set_timeouts_t_handler (vl_api_snat_det_set_timeouts_t * mp)
-{
- snat_main_t *sm = &snat_main;
- vl_api_snat_det_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);
-
- REPLY_MACRO (VL_API_SNAT_DET_SET_TIMEOUTS_REPLY);
-}
-
-static void *vl_api_snat_det_set_timeouts_t_print
- (vl_api_snat_det_set_timeouts_t * mp, void *handle)
-{
- u8 *s;
-
- s = format (0, "SCRIPT: snat_det_set_timeouts ");
- s = format (s, "udp %d tcp_established %d tcp_transitory %d icmp %d\n",
- ntohl (mp->udp),
- ntohl (mp->tcp_established),
- ntohl (mp->tcp_transitory), ntohl (mp->icmp));
-
- FINISH;
-}
-
-static void
-vl_api_snat_det_get_timeouts_t_handler (vl_api_snat_det_get_timeouts_t * mp)
-{
- snat_main_t *sm = &snat_main;
- vl_api_snat_det_get_timeouts_reply_t *rmp;
- int rv = 0;
-
- /* *INDENT-OFF* */
- REPLY_MACRO2 (VL_API_SNAT_DET_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);
- }))
- /* *INDENT-ON* */
-}
-
-static void *vl_api_snat_det_get_timeouts_t_print
- (vl_api_snat_det_get_timeouts_t * mp, void *handle)
-{
- u8 *s;
-
- s = format (0, "SCRIPT: snat_det_get_timeouts");
-
- FINISH;
-}
-
-static void
- vl_api_snat_det_close_session_out_t_handler
- (vl_api_snat_det_close_session_out_t * mp)
-{
- snat_main_t *sm = &snat_main;
- vl_api_snat_det_close_session_out_reply_t *rmp;
- ip4_address_t out_addr, ext_addr, in_addr;
- snat_det_out_key_t key;
- snat_det_map_t *dm;
- snat_det_session_t *ses;
- int rv = 0;
-
- clib_memcpy (&out_addr, mp->out_addr, 4);
- clib_memcpy (&ext_addr, mp->ext_addr, 4);
-
- dm = snat_det_map_by_out (sm, &out_addr);
- if (!dm)
- {
- rv = VNET_API_ERROR_NO_SUCH_ENTRY;
- goto send_reply;
- }
- snat_det_reverse (dm, &ext_addr, ntohs (mp->out_port), &in_addr);
- key.ext_host_addr = ext_addr;
- key.ext_host_port = mp->ext_port;
- key.out_port = mp->out_port;
- ses = snat_det_get_ses_by_out (dm, &in_addr, key.as_u64);
- if (!ses)
- {
- rv = VNET_API_ERROR_NO_SUCH_ENTRY;
- goto send_reply;
- }
- snat_det_ses_close (dm, ses);
-
-send_reply:
- REPLY_MACRO (VL_API_SNAT_DET_CLOSE_SESSION_OUT_REPLY);
-}
-
-static void *vl_api_snat_det_close_session_out_t_print
- (vl_api_snat_det_close_session_out_t * mp, void *handle)
-{
- u8 *s;
-
- s = format (0, "SCRIPT: snat_det_close_session_out ");
- s = format (s, "out_addr %U out_port %d "
- "ext_addr %U ext_port %d\n",
- format_ip4_address, mp->out_addr, ntohs (mp->out_port),
- format_ip4_address, mp->ext_addr, ntohs (mp->ext_port));
-
- FINISH;
-}
-
-static void
- vl_api_snat_det_close_session_in_t_handler
- (vl_api_snat_det_close_session_in_t * mp)
-{
- snat_main_t *sm = &snat_main;
- vl_api_snat_det_close_session_in_reply_t *rmp;
- ip4_address_t in_addr, ext_addr;
- snat_det_out_key_t key;
- snat_det_map_t *dm;
- snat_det_session_t *ses;
- int rv = 0;
-
- clib_memcpy (&in_addr, mp->in_addr, 4);
- clib_memcpy (&ext_addr, mp->ext_addr, 4);
-
- dm = snat_det_map_by_user (sm, &in_addr);
- if (!dm)
- {
- rv = VNET_API_ERROR_NO_SUCH_ENTRY;
- goto send_reply;
- }
- key.ext_host_addr = ext_addr;
- key.ext_host_port = mp->ext_port;
- ses = snat_det_find_ses_by_in (dm, &in_addr, mp->in_port, key);
- if (!ses)
- {
- rv = VNET_API_ERROR_NO_SUCH_ENTRY;
- goto send_reply;
- }
- snat_det_ses_close (dm, ses);
-
-send_reply:
- REPLY_MACRO (VL_API_SNAT_DET_CLOSE_SESSION_OUT_REPLY);
-}
-
-static void *vl_api_snat_det_close_session_in_t_print
- (vl_api_snat_det_close_session_in_t * mp, void *handle)
-{
- u8 *s;
- s = format (0, "SCRIPT: snat_det_close_session_in ");
- s = format (s, "in_addr %U in_port %d "
- "ext_addr %U ext_port %d\n",
- format_ip4_address, mp->in_addr, ntohs (mp->in_port),
- format_ip4_address, mp->ext_addr, ntohs (mp->ext_port));
-
- FINISH;
-}
-
-static void
- send_snat_det_session_details
- (snat_det_session_t * s, unix_shared_memory_queue_t * q, u32 context)
-{
- vl_api_snat_det_session_details_t *rmp;
- snat_main_t *sm = &snat_main;
-
- rmp = vl_msg_api_alloc (sizeof (*rmp));
- memset (rmp, 0, sizeof (*rmp));
- rmp->_vl_msg_id = ntohs (VL_API_SNAT_DET_SESSION_DETAILS + sm->msg_id_base);
- rmp->is_ip4 = 1;
- rmp->in_port = s->in_port;
- clib_memcpy (rmp->ext_addr, &s->out.ext_host_addr, 4);
- rmp->ext_port = s->out.ext_host_port;
- rmp->out_port = s->out.out_port;
- rmp->state = s->state;
- rmp->expire = ntohl (s->expire);
- rmp->context = context;
-
- vl_msg_api_send_shmem (q, (u8 *) & rmp);
-}
-
-static void
-vl_api_snat_det_session_dump_t_handler (vl_api_snat_det_session_dump_t * mp)
-{
- unix_shared_memory_queue_t *q;
- snat_main_t *sm = &snat_main;
- ip4_address_t user_addr;
- snat_det_map_t *dm;
- snat_det_session_t *s, empty_ses;
- u16 i;
-
- q = vl_api_client_index_to_input_queue (mp->client_index);
- if (q == 0)
- return;
- if (!mp->is_ip4)
- return;
-
- memset (&empty_ses, 0, sizeof (empty_ses));
- clib_memcpy (&user_addr, mp->user_addr, 4);
- dm = snat_det_map_by_user (sm, &user_addr);
- if (!dm)
- return;
-
- s = dm->sessions + snat_det_user_ses_offset (&user_addr, dm->in_plen);
- for (i = 0; i < SNAT_DET_SES_PER_USER; i++)
- {
- if (s->out.as_u64)
- send_snat_det_session_details (s, q, mp->context);
- s++;
- }
-}
-
-static void *vl_api_snat_det_session_dump_t_print
- (vl_api_snat_det_session_dump_t * mp, void *handle)
-{
- u8 *s;
-
- s = format (0, "SCRIPT: snat_det_session_dump ");
- s = format (s, "user_addr %U\n", format_ip4_address, mp->user_addr);
-
- FINISH;
-}
/******************************/
/*** Common NAT plugin APIs ***/
@@ -1372,7 +129,7 @@ static void
vl_api_nat_set_workers_t_handler (vl_api_nat_set_workers_t * mp)
{
snat_main_t *sm = &snat_main;
- vl_api_snat_set_workers_reply_t *rmp;
+ vl_api_nat_set_workers_reply_t *rmp;
int rv = 0;
uword *bitmap = 0;
u64 mask = clib_net_to_host_u64 (mp->worker_mask);
@@ -3552,34 +2309,6 @@ static void *vl_api_dslite_add_del_pool_addr_range_t_print
/* List of message types that this plugin understands */
#define foreach_snat_plugin_api_msg \
-_(SNAT_ADD_ADDRESS_RANGE, snat_add_address_range) \
-_(SNAT_INTERFACE_ADD_DEL_FEATURE, snat_interface_add_del_feature) \
-_(SNAT_ADD_STATIC_MAPPING, snat_add_static_mapping) \
-_(SNAT_CONTROL_PING, snat_control_ping) \
-_(SNAT_STATIC_MAPPING_DUMP, snat_static_mapping_dump) \
-_(SNAT_SHOW_CONFIG, snat_show_config) \
-_(SNAT_ADDRESS_DUMP, snat_address_dump) \
-_(SNAT_INTERFACE_DUMP, snat_interface_dump) \
-_(SNAT_SET_WORKERS, snat_set_workers) \
-_(SNAT_WORKER_DUMP, snat_worker_dump) \
-_(SNAT_ADD_DEL_INTERFACE_ADDR, snat_add_del_interface_addr) \
-_(SNAT_INTERFACE_ADDR_DUMP, snat_interface_addr_dump) \
-_(SNAT_IPFIX_ENABLE_DISABLE, snat_ipfix_enable_disable) \
-_(SNAT_USER_DUMP, snat_user_dump) \
-_(SNAT_USER_SESSION_DUMP, snat_user_session_dump) \
-_(SNAT_INTERFACE_ADD_DEL_OUTPUT_FEATURE, \
- snat_interface_add_del_output_feature) \
-_(SNAT_INTERFACE_OUTPUT_FEATURE_DUMP, \
- snat_interface_output_feature_dump) \
-_(SNAT_ADD_DET_MAP, snat_add_det_map) \
-_(SNAT_DET_FORWARD, snat_det_forward) \
-_(SNAT_DET_REVERSE, snat_det_reverse) \
-_(SNAT_DET_MAP_DUMP, snat_det_map_dump) \
-_(SNAT_DET_SET_TIMEOUTS, snat_det_set_timeouts) \
-_(SNAT_DET_GET_TIMEOUTS, snat_det_get_timeouts) \
-_(SNAT_DET_CLOSE_SESSION_OUT, snat_det_close_session_out) \
-_(SNAT_DET_CLOSE_SESSION_IN, snat_det_close_session_in) \
-_(SNAT_DET_SESSION_DUMP, snat_det_session_dump) \
_(NAT_CONTROL_PING, nat_control_ping) \
_(NAT_SHOW_CONFIG, nat_show_config) \
_(NAT_SET_WORKERS, nat_set_workers) \
@@ -3677,7 +2406,7 @@ snat_api_init (vlib_main_t * vm, snat_main_t * sm)
u8 *name;
clib_error_t *error = 0;
- name = format (0, "snat_%08x%c", api_version, 0);
+ name = format (0, "nat_%08x%c", api_version, 0);
/* Ask for a correctly-sized block of API message decode slots */
sm->msg_id_base =
diff --git a/src/plugins/nat/nat_test.c b/src/plugins/nat/nat_test.c
index 7cc85f5ccfa..f2575cea88d 100644
--- a/src/plugins/nat/nat_test.c
+++ b/src/plugins/nat/nat_test.c
@@ -61,17 +61,17 @@ typedef struct {
snat_test_main_t snat_test_main;
-#define foreach_standard_reply_retval_handler \
-_(snat_add_address_range_reply) \
-_(snat_interface_add_del_feature_reply) \
-_(snat_add_static_mapping_reply) \
-_(snat_set_workers_reply) \
-_(snat_add_del_interface_addr_reply) \
-_(snat_ipfix_enable_disable_reply) \
-_(snat_add_det_map_reply) \
-_(snat_det_set_timeouts_reply) \
-_(snat_det_close_session_out_reply) \
-_(snat_det_close_session_in_reply)
+#define foreach_standard_reply_retval_handler \
+_(nat44_add_del_address_range_reply) \
+_(nat44_interface_add_del_feature_reply) \
+_(nat44_add_del_static_mapping_reply) \
+_(nat_set_workers_reply) \
+_(nat44_add_del_interface_addr_reply) \
+_(nat_ipfix_enable_disable_reply) \
+_(nat_det_add_del_map_reply) \
+_(nat_det_set_timeouts_reply) \
+_(nat_det_close_session_out_reply) \
+_(nat_det_close_session_in_reply)
#define _(n) \
static void vl_api_##n##_t_handler \
@@ -89,47 +89,49 @@ _(snat_det_close_session_in_reply)
foreach_standard_reply_retval_handler;
#undef _
-/*
+/*
* Table of message reply handlers, must include boilerplate handlers
* we just generated
*/
#define foreach_vpe_api_reply_msg \
-_(SNAT_ADD_ADDRESS_RANGE_REPLY, snat_add_address_range_reply) \
-_(SNAT_INTERFACE_ADD_DEL_FEATURE_REPLY, \
- snat_interface_add_del_feature_reply) \
-_(SNAT_ADD_STATIC_MAPPING_REPLY, snat_add_static_mapping_reply) \
-_(SNAT_CONTROL_PING_REPLY, snat_control_ping_reply) \
-_(SNAT_STATIC_MAPPING_DETAILS, snat_static_mapping_details) \
-_(SNAT_SHOW_CONFIG_REPLY, snat_show_config_reply) \
-_(SNAT_ADDRESS_DETAILS, snat_address_details) \
-_(SNAT_INTERFACE_DETAILS, snat_interface_details) \
-_(SNAT_SET_WORKERS_REPLY, snat_set_workers_reply) \
-_(SNAT_WORKER_DETAILS, snat_worker_details) \
-_(SNAT_ADD_DEL_INTERFACE_ADDR_REPLY, \
- snat_add_del_interface_addr_reply) \
-_(SNAT_INTERFACE_ADDR_DETAILS, snat_interface_addr_details) \
-_(SNAT_IPFIX_ENABLE_DISABLE_REPLY, \
- snat_ipfix_enable_disable_reply) \
-_(SNAT_USER_DETAILS, snat_user_details) \
-_(SNAT_USER_SESSION_DETAILS, snat_user_session_details) \
-_(SNAT_ADD_DET_MAP_REPLY, snat_add_det_map_reply) \
-_(SNAT_DET_FORWARD_REPLY, snat_det_forward_reply) \
-_(SNAT_DET_REVERSE_REPLY, snat_det_reverse_reply) \
-_(SNAT_DET_MAP_DETAILS, snat_det_map_details) \
-_(SNAT_DET_SET_TIMEOUTS_REPLY, snat_det_set_timeouts_reply) \
-_(SNAT_DET_GET_TIMEOUTS_REPLY, snat_det_get_timeouts_reply) \
-_(SNAT_DET_CLOSE_SESSION_OUT_REPLY, \
- snat_det_close_session_out_reply) \
-_(SNAT_DET_CLOSE_SESSION_IN_REPLY, \
- snat_det_close_session_in_reply) \
-_(SNAT_DET_SESSION_DETAILS, snat_det_session_details)
-
-static int api_snat_add_address_range (vat_main_t * vam)
+_(NAT44_ADD_DEL_ADDRESS_RANGE_REPLY, \
+ nat44_add_del_address_range_reply) \
+_(NAT44_INTERFACE_ADD_DEL_FEATURE_REPLY, \
+ nat44_interface_add_del_feature_reply) \
+_(NAT44_ADD_DEL_STATIC_MAPPING_REPLY, \
+ nat44_add_del_static_mapping_reply) \
+_(NAT_CONTROL_PING_REPLY, nat_control_ping_reply) \
+_(NAT44_STATIC_MAPPING_DETAILS, nat44_static_mapping_details) \
+_(NAT_SHOW_CONFIG_REPLY, nat_show_config_reply) \
+_(NAT44_ADDRESS_DETAILS, nat44_address_details) \
+_(NAT44_INTERFACE_DETAILS, nat44_interface_details) \
+_(NAT_SET_WORKERS_REPLY, nat_set_workers_reply) \
+_(NAT_WORKER_DETAILS, nat_worker_details) \
+_(NAT44_ADD_DEL_INTERFACE_ADDR_REPLY, \
+ nat44_add_del_interface_addr_reply) \
+_(NAT44_INTERFACE_ADDR_DETAILS, nat44_interface_addr_details) \
+_(NAT_IPFIX_ENABLE_DISABLE_REPLY, \
+ nat_ipfix_enable_disable_reply) \
+_(NAT44_USER_DETAILS, nat44_user_details) \
+_(NAT44_USER_SESSION_DETAILS, nat44_user_session_details) \
+_(NAT_DET_ADD_DEL_MAP_REPLY, nat_det_add_del_map_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_DET_CLOSE_SESSION_OUT_REPLY, \
+ nat_det_close_session_out_reply) \
+_(NAT_DET_CLOSE_SESSION_IN_REPLY, \
+ nat_det_close_session_in_reply) \
+_(NAT_DET_SESSION_DETAILS, nat_det_session_details)
+
+static int api_nat44_add_del_address_range (vat_main_t * vam)
{
unformat_input_t * i = vam->input;
ip4_address_t start_addr, end_addr;
u32 start_host_order, end_host_order;
- vl_api_snat_add_address_range_t * mp;
+ vl_api_nat44_add_del_address_range_t * mp;
u8 is_add = 1;
int count;
int ret;
@@ -153,7 +155,7 @@ static int api_snat_add_address_range (vat_main_t * vam)
start_host_order = clib_host_to_net_u32 (start_addr.as_u32);
end_host_order = clib_host_to_net_u32 (end_addr.as_u32);
-
+
if (end_host_order < start_host_order)
{
errmsg ("end address less than start address\n");
@@ -169,12 +171,11 @@ static int api_snat_add_address_range (vat_main_t * vam)
format_ip4_address, &end_addr,
count);
}
-
- M(SNAT_ADD_ADDRESS_RANGE, mp);
+
+ M(NAT44_ADD_DEL_ADDRESS_RANGE, mp);
memcpy (mp->first_ip_address, &start_addr, 4);
memcpy (mp->last_ip_address, &end_addr, 4);
- mp->is_ip4 = 1;
mp->is_add = is_add;
S(mp);
@@ -182,13 +183,13 @@ static int api_snat_add_address_range (vat_main_t * vam)
return ret;
}
-static int api_snat_interface_add_del_feature (vat_main_t * vam)
+static int api_nat44_interface_add_del_feature (vat_main_t * vam)
{
unformat_input_t * i = vam->input;
- vl_api_snat_interface_add_del_feature_t * mp;
+ vl_api_nat44_interface_add_del_feature_t * mp;
u32 sw_if_index;
u8 sw_if_index_set = 0;
- u8 is_inside = 1;
+ u8 is_inside = 1;
u8 is_add = 1;
int ret;
@@ -217,20 +218,20 @@ static int api_snat_interface_add_del_feature (vat_main_t * vam)
return -99;
}
- M(SNAT_INTERFACE_ADD_DEL_FEATURE, mp);
+ 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;
-
+
S(mp);
W (ret);
return ret;
}
-static int api_snat_add_static_mapping(vat_main_t * vam)
+static int api_nat44_add_del_static_mapping(vat_main_t * vam)
{
unformat_input_t * i = vam->input;
- vl_api_snat_add_static_mapping_t * mp;
+ vl_api_nat44_add_del_static_mapping_t * mp;
u8 external_addr_set = 0;
u8 local_addr_set = 0;
u8 is_add = 1;
@@ -289,9 +290,8 @@ static int api_snat_add_static_mapping(vat_main_t * vam)
return -99;
}
- M(SNAT_ADD_STATIC_MAPPING, mp);
+ M(NAT44_ADD_DEL_STATIC_MAPPING, mp);
mp->is_add = is_add;
- mp->is_ip4 = 1;
mp->addr_only = addr_only;
mp->local_port = ntohs ((u16) local_port);
mp->external_port = ntohs ((u16) external_port);
@@ -306,8 +306,8 @@ static int api_snat_add_static_mapping(vat_main_t * vam)
return ret;
}
-static void vl_api_snat_control_ping_reply_t_handler
- (vl_api_snat_control_ping_reply_t * mp)
+static void vl_api_nat_control_ping_reply_t_handler
+ (vl_api_nat_control_ping_reply_t * mp)
{
vat_main_t *vam = &vat_main;
i32 retval = ntohl (mp->retval);
@@ -322,8 +322,8 @@ static void vl_api_snat_control_ping_reply_t_handler
}
}
-static void vl_api_snat_static_mapping_details_t_handler
- (vl_api_snat_static_mapping_details_t *mp)
+static void vl_api_nat44_static_mapping_details_t_handler
+ (vl_api_nat44_static_mapping_details_t *mp)
{
snat_test_main_t * sm = &snat_test_main;
vat_main_t *vam = sm->vat_main;
@@ -359,15 +359,15 @@ static void vl_api_snat_static_mapping_details_t_handler
}
-static int api_snat_static_mapping_dump(vat_main_t * vam)
+static int api_nat44_static_mapping_dump(vat_main_t * vam)
{
- vl_api_snat_static_mapping_dump_t * mp;
- vl_api_snat_control_ping_t *mp_ping;
+ vl_api_nat44_static_mapping_dump_t * mp;
+ vl_api_nat_control_ping_t *mp_ping;
int ret;
if (vam->json_output)
{
- clib_warning ("JSON output not supported for snat_static_mapping_dump");
+ clib_warning ("JSON output not supported for nat44_static_mapping_dump");
return -99;
}
@@ -375,19 +375,19 @@ static int api_snat_static_mapping_dump(vat_main_t * vam)
fformat (vam->ofp, "%15s%6s%15s%6s%11s%6s\n", "address", "port",
"address/if_idx", "port", "vrf", "proto");
- M(SNAT_STATIC_MAPPING_DUMP, mp);
+ M(NAT44_STATIC_MAPPING_DUMP, mp);
S(mp);
/* Use a control ping for synchronization */
- M(SNAT_CONTROL_PING, mp_ping);
+ M(NAT_CONTROL_PING, mp_ping);
S(mp_ping);
W (ret);
return ret;
}
-static void vl_api_snat_show_config_reply_t_handler
- (vl_api_snat_show_config_reply_t *mp)
+static void vl_api_nat_show_config_reply_t_handler
+ (vl_api_nat_show_config_reply_t *mp)
{
snat_test_main_t * sm = &snat_test_main;
vat_main_t *vam = sm->vat_main;
@@ -417,25 +417,25 @@ static void vl_api_snat_show_config_reply_t_handler
vam->result_ready = 1;
}
-static int api_snat_show_config(vat_main_t * vam)
+static int api_nat_show_config(vat_main_t * vam)
{
- vl_api_snat_show_config_t * mp;
+ vl_api_nat_show_config_t * mp;
int ret;
if (vam->json_output)
{
- clib_warning ("JSON output not supported for snat_show_config");
+ clib_warning ("JSON output not supported for nat_show_config");
return -99;
}
- M(SNAT_SHOW_CONFIG, mp);
+ M(NAT_SHOW_CONFIG, mp);
S(mp);
W (ret);
return ret;
}
-static void vl_api_snat_address_details_t_handler
- (vl_api_snat_address_details_t *mp)
+static void vl_api_nat44_address_details_t_handler
+ (vl_api_nat44_address_details_t *mp)
{
snat_test_main_t * sm = &snat_test_main;
vat_main_t *vam = sm->vat_main;
@@ -443,31 +443,31 @@ static void vl_api_snat_address_details_t_handler
fformat (vam->ofp, "%U\n", format_ip4_address, &mp->ip_address);
}
-static int api_snat_address_dump(vat_main_t * vam)
+static int api_nat44_address_dump(vat_main_t * vam)
{
- vl_api_snat_address_dump_t * mp;
- vl_api_snat_control_ping_t *mp_ping;
+ vl_api_nat44_address_dump_t * mp;
+ vl_api_nat_control_ping_t *mp_ping;
int ret;
if (vam->json_output)
{
- clib_warning ("JSON output not supported for snat_address_dump");
+ clib_warning ("JSON output not supported for nat44_address_dump");
return -99;
}
- M(SNAT_ADDRESS_DUMP, mp);
+ M(NAT44_ADDRESS_DUMP, mp);
S(mp);
/* Use a control ping for synchronization */
- M(SNAT_CONTROL_PING, mp_ping);
+ M(NAT_CONTROL_PING, mp_ping);
S(mp_ping);
W (ret);
return ret;
}
-static void vl_api_snat_interface_details_t_handler
- (vl_api_snat_interface_details_t *mp)
+static void vl_api_nat44_interface_details_t_handler
+ (vl_api_nat44_interface_details_t *mp)
{
snat_test_main_t * sm = &snat_test_main;
vat_main_t *vam = sm->vat_main;
@@ -476,33 +476,33 @@ static void vl_api_snat_interface_details_t_handler
mp->is_inside ? "in" : "out");
}
-static int api_snat_interface_dump(vat_main_t * vam)
+static int api_nat44_interface_dump(vat_main_t * vam)
{
- vl_api_snat_interface_dump_t * mp;
- vl_api_snat_control_ping_t *mp_ping;
+ vl_api_nat44_interface_dump_t * mp;
+ vl_api_nat_control_ping_t *mp_ping;
int ret;
if (vam->json_output)
{
- clib_warning ("JSON output not supported for snat_address_dump");
+ clib_warning ("JSON output not supported for nat44_address_dump");
return -99;
}
- M(SNAT_INTERFACE_DUMP, mp);
+ M(NAT44_INTERFACE_DUMP, mp);
S(mp);
/* Use a control ping for synchronization */
- M(SNAT_CONTROL_PING, mp_ping);
+ M(NAT_CONTROL_PING, mp_ping);
S(mp_ping);
W (ret);
return ret;
}
-static int api_snat_set_workers (vat_main_t * vam)
+static int api_nat_set_workers (vat_main_t * vam)
{
unformat_input_t * i = vam->input;
- vl_api_snat_set_workers_t * mp;
+ vl_api_nat_set_workers_t * mp;
uword *bitmap;
int ret;
@@ -517,7 +517,7 @@ static int api_snat_set_workers (vat_main_t * vam)
}
}
- M(SNAT_SET_WORKERS, mp);
+ M(NAT_SET_WORKERS, mp);
mp->worker_mask = clib_host_to_net_u64 (bitmap[0]);
S(mp);
@@ -525,8 +525,8 @@ static int api_snat_set_workers (vat_main_t * vam)
return ret;
}
-static void vl_api_snat_worker_details_t_handler
- (vl_api_snat_worker_details_t *mp)
+static void vl_api_nat_worker_details_t_handler
+ (vl_api_nat_worker_details_t *mp)
{
snat_test_main_t * sm = &snat_test_main;
vat_main_t *vam = sm->vat_main;
@@ -535,33 +535,33 @@ static void vl_api_snat_worker_details_t_handler
ntohl (mp->worker_index), mp->name, ntohl (mp->lcore_id));
}
-static int api_snat_worker_dump(vat_main_t * vam)
+static int api_nat_worker_dump(vat_main_t * vam)
{
- vl_api_snat_worker_dump_t * mp;
- vl_api_snat_control_ping_t *mp_ping;
+ vl_api_nat_worker_dump_t * mp;
+ vl_api_nat_control_ping_t *mp_ping;
int ret;
if (vam->json_output)
{
- clib_warning ("JSON output not supported for snat_address_dump");
+ clib_warning ("JSON output not supported for nat_address_dump");
return -99;
}
- M(SNAT_WORKER_DUMP, mp);
+ M(NAT_WORKER_DUMP, mp);
S(mp);
/* Use a control ping for synchronization */
- M(SNAT_CONTROL_PING, mp_ping);
+ M(NAT_CONTROL_PING, mp_ping);
S(mp_ping);
W (ret);
return ret;
}
-static int api_snat_add_del_interface_addr (vat_main_t * vam)
+static int api_nat44_add_del_interface_addr (vat_main_t * vam)
{
unformat_input_t * i = vam->input;
- vl_api_snat_add_del_interface_addr_t * mp;
+ vl_api_nat44_add_del_interface_addr_t * mp;
u32 sw_if_index;
u8 sw_if_index_set = 0;
u8 is_add = 1;
@@ -588,17 +588,17 @@ static int api_snat_add_del_interface_addr (vat_main_t * vam)
return -99;
}
- M(SNAT_ADD_DEL_INTERFACE_ADDR, mp);
+ M(NAT44_ADD_DEL_INTERFACE_ADDR, mp);
mp->sw_if_index = ntohl(sw_if_index);
mp->is_add = is_add;
-
+
S(mp);
W (ret);
return ret;
}
-static void vl_api_snat_interface_addr_details_t_handler
- (vl_api_snat_interface_addr_details_t *mp)
+static void vl_api_nat44_interface_addr_details_t_handler
+ (vl_api_nat44_interface_addr_details_t *mp)
{
snat_test_main_t * sm = &snat_test_main;
vat_main_t *vam = sm->vat_main;
@@ -606,33 +606,33 @@ static void vl_api_snat_interface_addr_details_t_handler
fformat (vam->ofp, "sw_if_index %d\n", ntohl (mp->sw_if_index));
}
-static int api_snat_interface_addr_dump(vat_main_t * vam)
+static int api_nat44_interface_addr_dump(vat_main_t * vam)
{
- vl_api_snat_interface_addr_dump_t * mp;
- vl_api_snat_control_ping_t *mp_ping;
+ vl_api_nat44_interface_addr_dump_t * mp;
+ vl_api_nat_control_ping_t *mp_ping;
int ret;
if (vam->json_output)
{
- clib_warning ("JSON output not supported for snat_address_dump");
+ clib_warning ("JSON output not supported for nat44_address_dump");
return -99;
}
- M(SNAT_INTERFACE_ADDR_DUMP, mp);
+ M(NAT44_INTERFACE_ADDR_DUMP, mp);
S(mp);
/* Use a control ping for synchronization */
- M(SNAT_CONTROL_PING, mp_ping);
+ M(NAT_CONTROL_PING, mp_ping);
S(mp_ping);
W (ret);
return ret;
}
-static int api_snat_ipfix_enable_disable (vat_main_t * vam)
+static int api_nat_ipfix_enable_disable (vat_main_t * vam)
{
unformat_input_t * i = vam->input;
- vl_api_snat_ipfix_enable_disable_t * mp;
+ vl_api_nat_ipfix_enable_disable_t * mp;
u32 domain_id = 0;
u32 src_port = 0;
u8 enable = 1;
@@ -653,7 +653,7 @@ static int api_snat_ipfix_enable_disable (vat_main_t * vam)
}
}
- M(SNAT_IPFIX_ENABLE_DISABLE, mp);
+ M(NAT_IPFIX_ENABLE_DISABLE, mp);
mp->domain_id = htonl(domain_id);
mp->src_port = htons((u16) src_port);
mp->enable = enable;
@@ -663,8 +663,8 @@ static int api_snat_ipfix_enable_disable (vat_main_t * vam)
return ret;
}
-static void vl_api_snat_user_session_details_t_handler
- (vl_api_snat_user_session_details_t *mp)
+static void vl_api_nat44_user_session_details_t_handler
+ (vl_api_nat44_user_session_details_t *mp)
{
snat_test_main_t * sm = &snat_test_main;
vat_main_t *vam = sm->vat_main;
@@ -677,18 +677,18 @@ static void vl_api_snat_user_session_details_t_handler
ntohl(mp->protocol), ntohl(mp->total_pkts), ntohl(mp->total_bytes));
}
-static int api_snat_user_session_dump(vat_main_t * vam)
+static int api_nat44_user_session_dump(vat_main_t * vam)
{
unformat_input_t* i = vam->input;
- vl_api_snat_user_session_dump_t * mp;
- vl_api_snat_control_ping_t *mp_ping;
+ vl_api_nat44_user_session_dump_t * mp;
+ vl_api_nat_control_ping_t *mp_ping;
ip4_address_t addr;
u32 vrf_id = ~0;
int ret;
if (vam->json_output)
{
- clib_warning ("JSON output not supported for snat_address_dump");
+ clib_warning ("JSON output not supported for nat44_address_dump");
return -99;
}
@@ -701,23 +701,22 @@ static int api_snat_user_session_dump(vat_main_t * vam)
return -99;
}
- M(SNAT_USER_SESSION_DUMP, mp);
+ M(NAT44_USER_SESSION_DUMP, mp);
S(mp);
/* Use a control ping for synchronization */
- M(SNAT_CONTROL_PING, mp_ping);
+ M(NAT_CONTROL_PING, mp_ping);
memset(mp->ip_address, 0, 16);
clib_memcpy(mp->ip_address, &addr, 4);
mp->vrf_id = htonl(vrf_id);
- mp->is_ip4 = 1;
S(mp_ping);
W (ret);
return ret;
}
-static void vl_api_snat_user_details_t_handler
- (vl_api_snat_user_details_t *mp)
+static void vl_api_nat44_user_details_t_handler
+ (vl_api_nat44_user_details_t *mp)
{
snat_test_main_t * sm = &snat_test_main;
vat_main_t *vam = sm->vat_main;
@@ -728,33 +727,33 @@ static void vl_api_snat_user_details_t_handler
ntohl(mp->nsessions), ntohl(mp->nstaticsessions));
}
-static int api_snat_user_dump(vat_main_t * vam)
+static int api_nat44_user_dump(vat_main_t * vam)
{
- vl_api_snat_user_dump_t * mp;
- vl_api_snat_control_ping_t *mp_ping;
+ vl_api_nat44_user_dump_t * mp;
+ vl_api_nat_control_ping_t *mp_ping;
int ret;
if (vam->json_output)
{
- clib_warning ("JSON output not supported for snat_address_dump");
+ clib_warning ("JSON output not supported for nat44_address_dump");
return -99;
}
- M(SNAT_USER_DUMP, mp);
+ M(NAT44_USER_DUMP, mp);
S(mp);
/* Use a control ping for synchronization */
- M(SNAT_CONTROL_PING, mp_ping);
+ M(NAT_CONTROL_PING, mp_ping);
S(mp_ping);
W (ret);
return ret;
}
-static int api_snat_add_det_map (vat_main_t * vam)
+static int api_nat_det_add_del_map (vat_main_t * vam)
{
unformat_input_t * i = vam->input;
- vl_api_snat_add_det_map_t * mp;
+ vl_api_nat_det_add_del_map_t * mp;
ip4_address_t in_addr, out_addr;
u32 in_plen, out_plen;
u8 is_add = 1;
@@ -772,7 +771,7 @@ static int api_snat_add_det_map (vat_main_t * vam)
return -99;
}
- M(SNAT_ADD_DET_MAP, mp);
+ M(NAT_DET_ADD_DEL_MAP, mp);
clib_memcpy(mp->in_addr, &in_addr, 4);
mp->in_plen = in_plen;
clib_memcpy(mp->out_addr, &out_addr, 4);
@@ -784,8 +783,8 @@ static int api_snat_add_det_map (vat_main_t * vam)
return ret;
}
-static void vl_api_snat_det_forward_reply_t_handler
- (vl_api_snat_det_forward_reply_t *mp)
+static void vl_api_nat_det_forward_reply_t_handler
+ (vl_api_nat_det_forward_reply_t *mp)
{
snat_test_main_t * sm = &snat_test_main;
vat_main_t *vam = sm->vat_main;
@@ -802,10 +801,10 @@ static void vl_api_snat_det_forward_reply_t_handler
vam->result_ready = 1;
}
-static int api_snat_det_forward (vat_main_t * vam)
+static int api_nat_det_forward (vat_main_t * vam)
{
unformat_input_t * i = vam->input;
- vl_api_snat_det_forward_t * mp;
+ vl_api_nat_det_forward_t * mp;
ip4_address_t in_addr;
int ret;
@@ -817,7 +816,7 @@ static int api_snat_det_forward (vat_main_t * vam)
return -99;
}
- M(SNAT_DET_FORWARD, mp);
+ M(NAT_DET_FORWARD, mp);
clib_memcpy(mp->in_addr, &in_addr, 4);
S(mp);
@@ -825,8 +824,8 @@ static int api_snat_det_forward (vat_main_t * vam)
return ret;
}
-static void vl_api_snat_det_reverse_reply_t_handler
- (vl_api_snat_det_reverse_reply_t *mp)
+static void vl_api_nat_det_reverse_reply_t_handler
+ (vl_api_nat_det_reverse_reply_t *mp)
{
snat_test_main_t * sm = &snat_test_main;
vat_main_t *vam = sm->vat_main;
@@ -841,10 +840,10 @@ static void vl_api_snat_det_reverse_reply_t_handler
vam->result_ready = 1;
}
-static int api_snat_det_reverse (vat_main_t * vam)
+static int api_nat_det_reverse (vat_main_t * vam)
{
unformat_input_t * i = vam->input;
- vl_api_snat_det_reverse_t * mp;
+ vl_api_nat_det_reverse_t * mp;
ip4_address_t out_addr;
u32 out_port;
int ret;
@@ -857,7 +856,7 @@ static int api_snat_det_reverse (vat_main_t * vam)
return -99;
}
- M(SNAT_DET_REVERSE, mp);
+ M(NAT_DET_REVERSE, mp);
clib_memcpy(mp->out_addr, &out_addr, 4);
mp->out_port = htons((u16)out_port);
@@ -866,8 +865,8 @@ static int api_snat_det_reverse (vat_main_t * vam)
return ret;
}
-static void vl_api_snat_det_map_details_t_handler
- (vl_api_snat_det_map_details_t *mp)
+static void vl_api_nat_det_map_details_t_handler
+ (vl_api_nat_det_map_details_t *mp)
{
snat_test_main_t * sm = &snat_test_main;
vat_main_t *vam = sm->vat_main;
@@ -881,33 +880,33 @@ static void vl_api_snat_det_map_details_t_handler
ntohl(mp->ses_num));
}
-static int api_snat_det_map_dump(vat_main_t * vam)
+static int api_nat_det_map_dump(vat_main_t * vam)
{
- vl_api_snat_det_map_dump_t * mp;
- vl_api_snat_control_ping_t *mp_ping;
+ vl_api_nat_det_map_dump_t * mp;
+ vl_api_nat_control_ping_t *mp_ping;
int ret;
if (vam->json_output)
{
- clib_warning ("JSON output not supported for snat_det_map_dump");
+ clib_warning ("JSON output not supported for nat_det_map_dump");
return -99;
}
- M(SNAT_DET_MAP_DUMP, mp);
+ M(NAT_DET_MAP_DUMP, mp);
S(mp);
/* Use a control ping for synchronization */
- M(SNAT_CONTROL_PING, mp_ping);
+ M(NAT_CONTROL_PING, mp_ping);
S(mp_ping);
W (ret);
return ret;
}
-static int api_snat_det_set_timeouts (vat_main_t * vam)
+static int api_nat_det_set_timeouts (vat_main_t * vam)
{
unformat_input_t * i = vam->input;
- vl_api_snat_det_set_timeouts_t * mp;
+ vl_api_nat_det_set_timeouts_t * mp;
u32 udp = SNAT_UDP_TIMEOUT;
u32 tcp_established = SNAT_TCP_ESTABLISHED_TIMEOUT;
u32 tcp_transitory = SNAT_TCP_TRANSITORY_TIMEOUT;
@@ -928,7 +927,7 @@ static int api_snat_det_set_timeouts (vat_main_t * vam)
return -99;
}
- M(SNAT_DET_SET_TIMEOUTS, mp);
+ M(NAT_DET_SET_TIMEOUTS, mp);
mp->udp = htonl(udp);
mp->tcp_established = htonl(tcp_established);
mp->tcp_transitory = htonl(tcp_transitory);
@@ -939,8 +938,8 @@ static int api_snat_det_set_timeouts (vat_main_t * vam)
return ret;
}
-static void vl_api_snat_det_get_timeouts_reply_t_handler
- (vl_api_snat_det_get_timeouts_reply_t *mp)
+static void vl_api_nat_det_get_timeouts_reply_t_handler
+ (vl_api_nat_det_get_timeouts_reply_t *mp)
{
snat_test_main_t * sm = &snat_test_main;
vat_main_t *vam = sm->vat_main;
@@ -959,27 +958,27 @@ static void vl_api_snat_det_get_timeouts_reply_t_handler
vam->result_ready = 1;
}
-static int api_snat_det_get_timeouts(vat_main_t * vam)
+static int api_nat_det_get_timeouts(vat_main_t * vam)
{
- vl_api_snat_det_get_timeouts_t * mp;
+ vl_api_nat_det_get_timeouts_t * mp;
int ret;
if (vam->json_output)
{
- clib_warning ("JSON output not supported for snat_show_config");
+ clib_warning ("JSON output not supported for nat_show_config");
return -99;
}
- M(SNAT_DET_GET_TIMEOUTS, mp);
+ M(NAT_DET_GET_TIMEOUTS, mp);
S(mp);
W (ret);
return ret;
}
-static int api_snat_det_close_session_out (vat_main_t * vam)
+static int api_nat_det_close_session_out (vat_main_t * vam)
{
unformat_input_t * i = vam->input;
- vl_api_snat_det_close_session_out_t * mp;
+ vl_api_nat_det_close_session_out_t * mp;
ip4_address_t out_addr, ext_addr;
u32 out_port, ext_port;
int ret;
@@ -994,7 +993,7 @@ static int api_snat_det_close_session_out (vat_main_t * vam)
return -99;
}
- M(SNAT_DET_CLOSE_SESSION_OUT, mp);
+ M(NAT_DET_CLOSE_SESSION_OUT, mp);
clib_memcpy(mp->out_addr, &out_addr, 4);
mp->out_port = ntohs((u16)out_port);
clib_memcpy(mp->ext_addr, &ext_addr, 4);
@@ -1005,10 +1004,10 @@ static int api_snat_det_close_session_out (vat_main_t * vam)
return ret;
}
-static int api_snat_det_close_session_in (vat_main_t * vam)
+static int api_nat_det_close_session_in (vat_main_t * vam)
{
unformat_input_t * i = vam->input;
- vl_api_snat_det_close_session_in_t * mp;
+ vl_api_nat_det_close_session_in_t * mp;
ip4_address_t in_addr, ext_addr;
u32 in_port, ext_port;
int ret;
@@ -1023,7 +1022,7 @@ static int api_snat_det_close_session_in (vat_main_t * vam)
return -99;
}
- M(SNAT_DET_CLOSE_SESSION_IN, mp);
+ M(NAT_DET_CLOSE_SESSION_IN, mp);
clib_memcpy(mp->in_addr, &in_addr, 4);
mp->in_port = ntohs((u16)in_port);
clib_memcpy(mp->ext_addr, &ext_addr, 4);
@@ -1034,8 +1033,8 @@ static int api_snat_det_close_session_in (vat_main_t * vam)
return ret;
}
-static void vl_api_snat_det_session_details_t_handler
- (vl_api_snat_det_session_details_t *mp)
+static void vl_api_nat_det_session_details_t_handler
+ (vl_api_nat_det_session_details_t *mp)
{
snat_test_main_t * sm = &snat_test_main;
vat_main_t *vam = sm->vat_main;
@@ -1046,17 +1045,17 @@ static void vl_api_snat_det_session_details_t_handler
mp->out_port, mp->in_port);
}
-static int api_snat_det_session_dump(vat_main_t * vam)
+static int api_nat_det_session_dump(vat_main_t * vam)
{
unformat_input_t* i = vam->input;
- vl_api_snat_det_session_dump_t * mp;
- vl_api_snat_control_ping_t *mp_ping;
+ vl_api_nat_det_session_dump_t * mp;
+ vl_api_nat_control_ping_t *mp_ping;
ip4_address_t user_addr;
int ret;
if (vam->json_output)
{
- clib_warning ("JSON output not supported for snat_det_session_dump");
+ clib_warning ("JSON output not supported for nat_det_session_dump");
return -99;
}
@@ -1068,58 +1067,58 @@ static int api_snat_det_session_dump(vat_main_t * vam)
return -99;
}
- M(SNAT_DET_SESSION_DUMP, mp);
+ M(NAT_DET_SESSION_DUMP, mp);
clib_memcpy (&mp->user_addr, &user_addr, 4);
S(mp);
/* Use a control ping for synchronization */
- M(SNAT_CONTROL_PING, mp_ping);
+ M(NAT_CONTROL_PING, mp_ping);
S(mp_ping);
W (ret);
return ret;
}
-/*
+/*
* List of messages that the api test plugin sends,
* and that the data plane plugin processes
*/
-#define foreach_vpe_api_msg \
-_(snat_add_address_range, "<start-addr> [- <end-addr] [del]") \
-_(snat_interface_add_del_feature, \
- "<intfc> | sw_if_index <id> [in] [out] [del]") \
-_(snat_add_static_mapping, "local_addr <ip> (external_addr <ip>" \
- " | external_if <intfc> | external_sw_if_ndex <id>) " \
- "[local_port <n>] [external_port <n>] [vrf <table-id>] [del] " \
- "protocol <n>") \
-_(snat_set_workers, "<wokrers_bitmap>") \
-_(snat_static_mapping_dump, "") \
-_(snat_show_config, "") \
-_(snat_address_dump, "") \
-_(snat_interface_dump, "") \
-_(snat_worker_dump, "") \
-_(snat_add_del_interface_addr, \
- "<intfc> | sw_if_index <id> [del]") \
-_(snat_interface_addr_dump, "") \
-_(snat_ipfix_enable_disable, "[domain <id>] [src_port <n>] " \
- "[disable]") \
-_(snat_user_dump, "") \
-_(snat_user_session_dump, "ip_address <ip> vrf_id <table-id>") \
-_(snat_add_det_map, "in <in_addr>/<in_plen> out " \
- "<out_addr>/<out_plen> [del]") \
-_(snat_det_forward, "<in_addr>") \
-_(snat_det_reverse, "<out_addr> <out_port>") \
-_(snat_det_map_dump, "") \
-_(snat_det_set_timeouts, "[udp <sec> | tcp_established <sec> | " \
- "tcp_transitory <sec> | icmp <sec>]") \
-_(snat_det_get_timeouts, "") \
-_(snat_det_close_session_out, "<out_addr>:<out_port> " \
- "<ext_addr>:<ext_port>") \
-_(snat_det_close_session_in, "<in_addr>:<in_port> " \
- "<out_addr>:<out_port>") \
-_(snat_det_session_dump, "ip_address <user_addr>")
-
-static void
+#define foreach_vpe_api_msg \
+_(nat44_add_del_address_range, "<start-addr> [- <end-addr] [del]")\
+_(nat44_interface_add_del_feature, \
+ "<intfc> | sw_if_index <id> [in] [out] [del]") \
+_(nat44_add_del_static_mapping, "local_addr <ip>" \
+ " (external_addr <ip> | external_if <intfc> |" \
+ " external_sw_if_ndex <id>) [local_port <n>]" \
+ " [external_port <n>] [vrf <table-id>] [del] protocol <n>") \
+_(nat_set_workers, "<wokrers_bitmap>") \
+_(nat44_static_mapping_dump, "") \
+_(nat_show_config, "") \
+_(nat44_address_dump, "") \
+_(nat44_interface_dump, "") \
+_(nat_worker_dump, "") \
+_(nat44_add_del_interface_addr, \
+ "<intfc> | sw_if_index <id> [del]") \
+_(nat44_interface_addr_dump, "") \
+_(nat_ipfix_enable_disable, "[domain <id>] [src_port <n>] " \
+ "[disable]") \
+_(nat44_user_dump, "") \
+_(nat44_user_session_dump, "ip_address <ip> vrf_id <table-id>") \
+_(nat_det_add_del_map, "in <in_addr>/<in_plen> out " \
+ "<out_addr>/<out_plen> [del]") \
+_(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> | " \
+ "tcp_transitory <sec> | icmp <sec>]") \
+_(nat_det_get_timeouts, "") \
+_(nat_det_close_session_out, "<out_addr>:<out_port> " \
+ "<ext_addr>:<ext_port>") \
+_(nat_det_close_session_in, "<in_addr>:<in_port> " \
+ "<out_addr>:<out_port>") \
+_(nat_det_session_dump, "ip_address <user_addr>")
+
+static void
snat_vat_api_hookup (vat_main_t *vam)
{
snat_test_main_t * sm __attribute__((unused)) = &snat_test_main;
@@ -1131,7 +1130,7 @@ snat_vat_api_hookup (vat_main_t *vam)
vl_noop_handler, \
vl_api_##n##_t_endian, \
vl_api_##n##_t_print, \
- sizeof(vl_api_##n##_t), 1);
+ sizeof(vl_api_##n##_t), 1);
foreach_vpe_api_reply_msg;
#undef _
@@ -1139,8 +1138,8 @@ snat_vat_api_hookup (vat_main_t *vam)
#define _(n,h) \
hash_set_mem (vam->function_by_name, #n, api_##n);
foreach_vpe_api_msg;
-#undef _
-
+#undef _
+
/* Help strings */
#define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
foreach_vpe_api_msg;
@@ -1155,13 +1154,13 @@ clib_error_t * vat_plugin_register (vat_main_t *vam)
sm->vat_main = vam;
/* Ask the vpp engine for the first assigned message-id */
- name = format (0, "snat_%08x%c", api_version, 0);
+ name = format (0, "nat_%08x%c", api_version, 0);
sm->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name);
if (sm->msg_id_base != (u16) ~0)
snat_vat_api_hookup (vam);
-
+
vec_free(name);
-
+
return 0;
}
diff --git a/src/vpp-api/java/jvpp-nat/io/fd/vpp/jvpp/nat/test/FutureApiTest.java b/src/vpp-api/java/jvpp-nat/io/fd/vpp/jvpp/nat/test/FutureApiTest.java
index 8643dcf4661..26d6b98e443 100644
--- a/src/vpp-api/java/jvpp-nat/io/fd/vpp/jvpp/nat/test/FutureApiTest.java
+++ b/src/vpp-api/java/jvpp-nat/io/fd/vpp/jvpp/nat/test/FutureApiTest.java
@@ -20,8 +20,8 @@ package io.fd.vpp.jvpp.nat.test;
import io.fd.vpp.jvpp.JVppRegistry;
import io.fd.vpp.jvpp.JVppRegistryImpl;
import io.fd.vpp.jvpp.nat.JVppNatImpl;
-import io.fd.vpp.jvpp.nat.dto.SnatAddressDetailsReplyDump;
-import io.fd.vpp.jvpp.nat.dto.SnatAddressDump;
+import io.fd.vpp.jvpp.nat.dto.Nat44AddressDetailsReplyDump;
+import io.fd.vpp.jvpp.nat.dto.Nat44AddressDump;
import io.fd.vpp.jvpp.nat.future.FutureJVppNatFacade;
import java.util.concurrent.Future;
@@ -36,7 +36,7 @@ public class FutureApiTest {
}
private static void testCallbackApi(String[] args) throws Exception {
- LOG.info("Testing Java callback API for snat plugin");
+ LOG.info("Testing Java callback API for nat plugin");
try (final JVppRegistry registry = new JVppRegistryImpl("FutureApiTest", args[0]);
final FutureJVppNatFacade jvpp = new FutureJVppNatFacade(registry, new JVppNatImpl())) {
LOG.info("Successfully connected to VPP");
@@ -48,19 +48,19 @@ public class FutureApiTest {
}
private static void testAclDump(FutureJVppNatFacade jvpp) throws Exception {
- LOG.info("Sending SnatAddressDump request...");
- final SnatAddressDump request = new SnatAddressDump();
+ LOG.info("Sending Nat44AddressDump request...");
+ final Nat44AddressDump request = new Nat44AddressDump();
- final Future<SnatAddressDetailsReplyDump> replyFuture = jvpp.snatAddressDump(request).toCompletableFuture();
- final SnatAddressDetailsReplyDump reply = replyFuture.get();
+ final Future<Nat44AddressDetailsReplyDump> replyFuture = jvpp.nat44AddressDump(request).toCompletableFuture();
+ final Nat44AddressDetailsReplyDump reply = replyFuture.get();
- if (reply == null || reply.snatAddressDetails == null) {
+ if (reply == null || reply.nat44AddressDetails == null) {
throw new IllegalStateException("Received null response for empty dump: " + reply);
} else {
LOG.info(
String.format(
- "Received snat address dump reply with list of snat address: %s",
- reply.snatAddressDetails));
+ "Received nat address dump reply with list of nat address: %s",
+ reply.nat44AddressDetails));
}
}
}