2 * Copyright (c) 2020 Cisco and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include <vnet/ip/ip_types_api.h>
18 #include <vlibmemory/api.h>
20 #include <vnet/fib/fib_table.h>
22 #include <nat/lib/nat_inlines.h>
23 #include <nat/lib/ipfix_logging.h>
25 #include <nat/nat44-ei/nat44_ei.api_enum.h>
26 #include <nat/nat44-ei/nat44_ei.api_types.h>
28 #include <nat/nat44-ei/nat44_ei_ha.h>
29 #include <nat/nat44-ei/nat44_ei.h>
31 #define REPLY_MSG_ID_BASE nm->msg_id_base
32 #include <vlibapi/api_helper_macros.h>
35 vl_api_nat44_ei_show_running_config_t_handler (
36 vl_api_nat44_ei_show_running_config_t *mp)
38 vl_api_nat44_ei_show_running_config_reply_t *rmp;
39 nat44_ei_main_t *nm = &nat44_ei_main;
40 nat44_ei_config_t *rc = &nm->rconfig;
44 VL_API_NAT44_EI_SHOW_RUNNING_CONFIG_REPLY, ({
45 rmp->inside_vrf = htonl (rc->inside_vrf);
46 rmp->outside_vrf = htonl (rc->outside_vrf);
47 rmp->users = htonl (rc->users);
48 rmp->sessions = htonl (rc->sessions);
49 rmp->user_sessions = htonl (rc->user_sessions);
51 rmp->user_buckets = htonl (nm->user_buckets);
52 rmp->translation_buckets = htonl (nm->translation_buckets);
54 rmp->timeouts.udp = htonl (nm->timeouts.udp);
55 rmp->timeouts.tcp_established = htonl (nm->timeouts.tcp.established);
56 rmp->timeouts.tcp_transitory = htonl (nm->timeouts.tcp.transitory);
57 rmp->timeouts.icmp = htonl (nm->timeouts.icmp);
59 rmp->forwarding_enabled = nm->forwarding_enabled == 1;
60 // consider how to split functionality between subplugins
61 rmp->ipfix_logging_enabled = nat_ipfix_logging_enabled ();
63 if (rc->static_mapping_only)
64 rmp->flags |= NAT44_EI_STATIC_MAPPING_ONLY;
65 if (rc->connection_tracking)
66 rmp->flags |= NAT44_EI_CONNECTION_TRACKING;
68 rmp->flags |= NAT44_EI_OUT2IN_DPO;
73 vl_api_nat44_ei_set_workers_t_handler (vl_api_nat44_ei_set_workers_t *mp)
75 nat44_ei_main_t *nm = &nat44_ei_main;
76 vl_api_nat44_ei_set_workers_reply_t *rmp;
81 mask = clib_net_to_host_u64 (mp->worker_mask);
83 if (nm->num_workers < 2)
85 rv = VNET_API_ERROR_FEATURE_DISABLED;
89 bitmap = clib_bitmap_set_multiple (bitmap, 0, mask, BITS (mask));
90 rv = nat44_ei_set_workers (bitmap);
91 clib_bitmap_free (bitmap);
94 REPLY_MACRO (VL_API_NAT44_EI_SET_WORKERS_REPLY);
98 send_nat_worker_details (u32 worker_index, vl_api_registration_t *reg,
101 vl_api_nat44_ei_worker_details_t *rmp;
102 nat44_ei_main_t *nm = &nat44_ei_main;
103 vlib_worker_thread_t *w =
104 vlib_worker_threads + worker_index + nm->first_worker_index;
106 rmp = vl_msg_api_alloc (sizeof (*rmp));
107 clib_memset (rmp, 0, sizeof (*rmp));
108 rmp->_vl_msg_id = ntohs (VL_API_NAT44_EI_WORKER_DETAILS + nm->msg_id_base);
109 rmp->context = context;
110 rmp->worker_index = htonl (worker_index);
111 rmp->lcore_id = htonl (w->cpu_id);
112 strncpy ((char *) rmp->name, (char *) w->name, ARRAY_LEN (rmp->name) - 1);
114 vl_api_send_msg (reg, (u8 *) rmp);
118 vl_api_nat44_ei_worker_dump_t_handler (vl_api_nat44_ei_worker_dump_t *mp)
120 vl_api_registration_t *reg;
121 nat44_ei_main_t *nm = &nat44_ei_main;
124 reg = vl_api_client_index_to_registration (mp->client_index);
128 vec_foreach (worker_index, nm->workers)
130 send_nat_worker_details (*worker_index, reg, mp->context);
135 vl_api_nat44_ei_set_log_level_t_handler (vl_api_nat44_ei_set_log_level_t *mp)
137 nat44_ei_main_t *nm = &nat44_ei_main;
138 vl_api_nat44_ei_set_log_level_reply_t *rmp;
141 if (nm->log_level > NAT_LOG_DEBUG)
142 rv = VNET_API_ERROR_UNSUPPORTED;
144 nm->log_level = mp->log_level;
146 REPLY_MACRO (VL_API_NAT44_EI_SET_LOG_LEVEL_REPLY);
150 vl_api_nat44_ei_plugin_enable_disable_t_handler (
151 vl_api_nat44_ei_plugin_enable_disable_t *mp)
153 nat44_ei_main_t *nm = &nat44_ei_main;
154 nat44_ei_config_t c = { 0 };
155 vl_api_nat44_ei_plugin_enable_disable_reply_t *rmp;
160 c.static_mapping_only = mp->flags & NAT44_EI_STATIC_MAPPING_ONLY;
161 c.connection_tracking = mp->flags & NAT44_EI_CONNECTION_TRACKING;
162 c.out2in_dpo = mp->flags & NAT44_EI_OUT2IN_DPO;
164 c.inside_vrf = ntohl (mp->inside_vrf);
165 c.outside_vrf = ntohl (mp->outside_vrf);
167 c.users = ntohl (mp->users);
169 c.sessions = ntohl (mp->sessions);
171 c.user_sessions = ntohl (mp->user_sessions);
173 rv = nat44_ei_plugin_enable (c);
177 rv = nat44_ei_plugin_disable ();
180 REPLY_MACRO (VL_API_NAT44_EI_PLUGIN_ENABLE_DISABLE_REPLY);
184 vl_api_nat44_ei_ipfix_enable_disable_t_handler (
185 vl_api_nat44_ei_ipfix_enable_disable_t *mp)
187 nat44_ei_main_t *nm = &nat44_ei_main;
188 vl_api_nat44_ei_ipfix_enable_disable_reply_t *rmp;
191 rv = nat_ipfix_logging_enable_disable (mp->enable,
192 clib_host_to_net_u32 (mp->domain_id),
193 clib_host_to_net_u16 (mp->src_port));
195 REPLY_MACRO (VL_API_NAT44_EI_IPFIX_ENABLE_DISABLE_REPLY);
199 vl_api_nat44_ei_set_timeouts_t_handler (vl_api_nat44_ei_set_timeouts_t *mp)
201 nat44_ei_main_t *nm = &nat44_ei_main;
202 vl_api_nat44_ei_set_timeouts_reply_t *rmp;
205 nm->timeouts.udp = ntohl (mp->udp);
206 nm->timeouts.tcp.established = ntohl (mp->tcp_established);
207 nm->timeouts.tcp.transitory = ntohl (mp->tcp_transitory);
208 nm->timeouts.icmp = ntohl (mp->icmp);
210 REPLY_MACRO (VL_API_NAT44_EI_SET_TIMEOUTS_REPLY);
214 vl_api_nat44_ei_set_addr_and_port_alloc_alg_t_handler (
215 vl_api_nat44_ei_set_addr_and_port_alloc_alg_t *mp)
217 nat44_ei_main_t *nm = &nat44_ei_main;
218 vl_api_nat44_ei_set_addr_and_port_alloc_alg_reply_t *rmp;
220 u16 port_start, port_end;
224 case NAT44_EI_ADDR_AND_PORT_ALLOC_ALG_DEFAULT:
225 nat44_ei_set_alloc_default ();
227 case NAT44_EI_ADDR_AND_PORT_ALLOC_ALG_MAPE:
228 nat44_ei_set_alloc_mape (ntohs (mp->psid), mp->psid_offset,
231 case NAT44_EI_ADDR_AND_PORT_ALLOC_ALG_RANGE:
232 port_start = ntohs (mp->start_port);
233 port_end = ntohs (mp->end_port);
234 if (port_end <= port_start)
236 rv = VNET_API_ERROR_INVALID_VALUE;
239 nat44_ei_set_alloc_range (port_start, port_end);
242 rv = VNET_API_ERROR_INVALID_VALUE;
247 REPLY_MACRO (VL_API_NAT44_EI_SET_ADDR_AND_PORT_ALLOC_ALG_REPLY);
251 vl_api_nat44_ei_get_addr_and_port_alloc_alg_t_handler (
252 vl_api_nat44_ei_get_addr_and_port_alloc_alg_t *mp)
254 nat44_ei_main_t *nm = &nat44_ei_main;
255 vl_api_nat44_ei_get_addr_and_port_alloc_alg_reply_t *rmp;
258 REPLY_MACRO2 (VL_API_NAT44_EI_GET_ADDR_AND_PORT_ALLOC_ALG_REPLY, ({
259 rmp->alg = nm->addr_and_port_alloc_alg;
260 rmp->psid_offset = nm->psid_offset;
261 rmp->psid_length = nm->psid_length;
262 rmp->psid = htons (nm->psid);
263 rmp->start_port = htons (nm->start_port);
264 rmp->end_port = htons (nm->end_port);
269 vl_api_nat44_ei_set_mss_clamping_t_handler (
270 vl_api_nat44_ei_set_mss_clamping_t *mp)
272 nat44_ei_main_t *nm = &nat44_ei_main;
273 vl_api_nat44_ei_set_mss_clamping_reply_t *rmp;
277 nm->mss_clamping = ntohs (mp->mss_value);
279 nm->mss_clamping = 0;
281 REPLY_MACRO (VL_API_NAT44_EI_SET_MSS_CLAMPING_REPLY);
285 vl_api_nat44_ei_get_mss_clamping_t_handler (
286 vl_api_nat44_ei_get_mss_clamping_t *mp)
288 nat44_ei_main_t *nm = &nat44_ei_main;
289 vl_api_nat44_ei_get_mss_clamping_reply_t *rmp;
292 REPLY_MACRO2 (VL_API_NAT44_EI_GET_MSS_CLAMPING_REPLY, ({
293 rmp->enable = nm->mss_clamping ? 1 : 0;
294 rmp->mss_value = htons (nm->mss_clamping);
299 vl_api_nat44_ei_ha_set_listener_t_handler (
300 vl_api_nat44_ei_ha_set_listener_t *mp)
302 nat44_ei_main_t *nm = &nat44_ei_main;
303 vl_api_nat44_ei_ha_set_listener_reply_t *rmp;
307 memcpy (&addr, &mp->ip_address, sizeof (addr));
308 rv = nat_ha_set_listener (vlib_get_main (), &addr,
309 clib_net_to_host_u16 (mp->port),
310 clib_net_to_host_u32 (mp->path_mtu));
312 REPLY_MACRO (VL_API_NAT44_EI_HA_SET_LISTENER_REPLY);
316 vl_api_nat44_ei_ha_get_listener_t_handler (
317 vl_api_nat44_ei_ha_get_listener_t *mp)
319 nat44_ei_main_t *nm = &nat44_ei_main;
320 vl_api_nat44_ei_ha_get_listener_reply_t *rmp;
326 nat_ha_get_listener (&addr, &port, &path_mtu);
328 REPLY_MACRO2 (VL_API_NAT44_EI_HA_GET_LISTENER_REPLY, ({
329 clib_memcpy (rmp->ip_address, &addr, sizeof (ip4_address_t));
330 rmp->port = clib_host_to_net_u16 (port);
331 rmp->path_mtu = clib_host_to_net_u32 (path_mtu);
336 vl_api_nat44_ei_ha_set_failover_t_handler (
337 vl_api_nat44_ei_ha_set_failover_t *mp)
339 nat44_ei_main_t *nm = &nat44_ei_main;
340 vl_api_nat44_ei_ha_set_failover_reply_t *rmp;
344 memcpy (&addr, &mp->ip_address, sizeof (addr));
345 rv = nat_ha_set_failover (
346 vlib_get_main (), &addr, clib_net_to_host_u16 (mp->port),
347 clib_net_to_host_u32 (mp->session_refresh_interval));
349 REPLY_MACRO (VL_API_NAT44_EI_HA_SET_FAILOVER_REPLY);
353 vl_api_nat44_ei_ha_get_failover_t_handler (
354 vl_api_nat44_ei_ha_get_failover_t *mp)
356 nat44_ei_main_t *nm = &nat44_ei_main;
357 vl_api_nat44_ei_ha_get_failover_reply_t *rmp;
361 u32 session_refresh_interval;
363 nat_ha_get_failover (&addr, &port, &session_refresh_interval);
365 REPLY_MACRO2 (VL_API_NAT44_EI_HA_GET_FAILOVER_REPLY, ({
366 clib_memcpy (rmp->ip_address, &addr, sizeof (ip4_address_t));
367 rmp->port = clib_host_to_net_u16 (port);
368 rmp->session_refresh_interval =
369 clib_host_to_net_u32 (session_refresh_interval);
374 vl_api_nat44_ei_ha_flush_t_handler (vl_api_nat44_ei_ha_flush_t *mp)
376 nat44_ei_main_t *nm = &nat44_ei_main;
377 vl_api_nat44_ei_ha_flush_reply_t *rmp;
382 REPLY_MACRO (VL_API_NAT44_EI_HA_FLUSH_REPLY);
386 nat_ha_resync_completed_event_cb (u32 client_index, u32 pid, u32 missed_count)
388 nat44_ei_main_t *nm = &nat44_ei_main;
389 vl_api_registration_t *reg;
390 vl_api_nat44_ei_ha_resync_completed_event_t *mp;
392 reg = vl_api_client_index_to_registration (client_index);
396 mp = vl_msg_api_alloc (sizeof (*mp));
397 clib_memset (mp, 0, sizeof (*mp));
398 mp->client_index = client_index;
400 mp->missed_count = clib_host_to_net_u32 (missed_count);
402 ntohs (VL_API_NAT44_EI_HA_RESYNC_COMPLETED_EVENT + nm->msg_id_base);
404 vl_api_send_msg (reg, (u8 *) mp);
408 vl_api_nat44_ei_ha_resync_t_handler (vl_api_nat44_ei_ha_resync_t *mp)
410 nat44_ei_main_t *nm = &nat44_ei_main;
411 vl_api_nat44_ei_ha_resync_reply_t *rmp;
415 mp->client_index, mp->pid,
416 mp->want_resync_event ? nat_ha_resync_completed_event_cb : NULL);
418 REPLY_MACRO (VL_API_NAT44_EI_HA_RESYNC_REPLY);
422 vl_api_nat44_ei_del_user_t_handler (vl_api_nat44_ei_del_user_t *mp)
424 nat44_ei_main_t *nm = &nat44_ei_main;
425 vl_api_nat44_ei_del_user_reply_t *rmp;
428 memcpy (&addr.as_u8, mp->ip_address, 4);
429 rv = nat44_ei_user_del (&addr, ntohl (mp->fib_index));
430 REPLY_MACRO (VL_API_NAT44_EI_DEL_USER_REPLY);
434 vl_api_nat44_ei_add_del_address_range_t_handler (
435 vl_api_nat44_ei_add_del_address_range_t *mp)
437 nat44_ei_main_t *nm = &nat44_ei_main;
438 vl_api_nat44_ei_add_del_address_range_reply_t *rmp;
439 ip4_address_t this_addr;
441 u32 start_host_order, end_host_order;
447 if (nm->static_mapping_only)
449 rv = VNET_API_ERROR_FEATURE_DISABLED;
455 tmp = (u32 *) mp->first_ip_address;
456 start_host_order = clib_host_to_net_u32 (tmp[0]);
457 tmp = (u32 *) mp->last_ip_address;
458 end_host_order = clib_host_to_net_u32 (tmp[0]);
460 count = (end_host_order - start_host_order) + 1;
462 vrf_id = clib_host_to_net_u32 (mp->vrf_id);
465 nat44_ei_log_info ("%U - %U, %d addresses...", format_ip4_address,
466 mp->first_ip_address, format_ip4_address,
467 mp->last_ip_address, count);
469 memcpy (&this_addr.as_u8, mp->first_ip_address, 4);
471 for (i = 0; i < count; i++)
474 rv = nat44_ei_add_address (&this_addr, vrf_id);
476 rv = nat44_ei_del_address (this_addr, 0);
482 nat44_ei_add_del_address_dpo (this_addr, is_add);
484 increment_v4_address (&this_addr);
488 REPLY_MACRO (VL_API_NAT44_EI_ADD_DEL_ADDRESS_RANGE_REPLY);
492 send_nat44_ei_address_details (nat44_ei_address_t *a,
493 vl_api_registration_t *reg, u32 context)
495 vl_api_nat44_ei_address_details_t *rmp;
496 nat44_ei_main_t *nm = &nat44_ei_main;
498 rmp = vl_msg_api_alloc (sizeof (*rmp));
499 clib_memset (rmp, 0, sizeof (*rmp));
500 rmp->_vl_msg_id = ntohs (VL_API_NAT44_EI_ADDRESS_DETAILS + nm->msg_id_base);
501 clib_memcpy (rmp->ip_address, &(a->addr), 4);
502 if (a->fib_index != ~0)
504 fib_table_t *fib = fib_table_get (a->fib_index, FIB_PROTOCOL_IP4);
505 rmp->vrf_id = ntohl (fib->ft_table_id);
509 rmp->context = context;
511 vl_api_send_msg (reg, (u8 *) rmp);
515 vl_api_nat44_ei_address_dump_t_handler (vl_api_nat44_ei_address_dump_t *mp)
517 vl_api_registration_t *reg;
518 nat44_ei_main_t *nm = &nat44_ei_main;
519 nat44_ei_address_t *a;
521 reg = vl_api_client_index_to_registration (mp->client_index);
525 vec_foreach (a, nm->addresses)
527 send_nat44_ei_address_details (a, reg, mp->context);
532 vl_api_nat44_ei_interface_add_del_feature_t_handler (
533 vl_api_nat44_ei_interface_add_del_feature_t *mp)
535 nat44_ei_main_t *nm = &nat44_ei_main;
536 vl_api_nat44_ei_interface_add_del_feature_reply_t *rmp;
537 u32 sw_if_index = ntohl (mp->sw_if_index);
540 VALIDATE_SW_IF_INDEX (mp);
545 nat44_ei_add_interface (sw_if_index, mp->flags & NAT44_EI_IF_INSIDE);
550 nat44_ei_del_interface (sw_if_index, mp->flags & NAT44_EI_IF_INSIDE);
553 BAD_SW_IF_INDEX_LABEL;
554 REPLY_MACRO (VL_API_NAT44_EI_INTERFACE_ADD_DEL_FEATURE_REPLY);
558 send_nat44_ei_interface_details (nat44_ei_interface_t *i,
559 vl_api_registration_t *reg, u32 context)
561 vl_api_nat44_ei_interface_details_t *rmp;
562 nat44_ei_main_t *nm = &nat44_ei_main;
564 rmp = vl_msg_api_alloc (sizeof (*rmp));
565 clib_memset (rmp, 0, sizeof (*rmp));
567 ntohs (VL_API_NAT44_EI_INTERFACE_DETAILS + nm->msg_id_base);
568 rmp->sw_if_index = ntohl (i->sw_if_index);
570 if (nat44_ei_interface_is_inside (i))
571 rmp->flags |= NAT44_EI_IF_INSIDE;
572 if (nat44_ei_interface_is_outside (i))
573 rmp->flags |= NAT44_EI_IF_OUTSIDE;
575 rmp->context = context;
577 vl_api_send_msg (reg, (u8 *) rmp);
581 vl_api_nat44_ei_interface_dump_t_handler (vl_api_nat44_ei_interface_dump_t *mp)
583 vl_api_registration_t *reg;
584 nat44_ei_main_t *nm = &nat44_ei_main;
585 nat44_ei_interface_t *i;
587 reg = vl_api_client_index_to_registration (mp->client_index);
591 pool_foreach (i, nm->interfaces)
593 send_nat44_ei_interface_details (i, reg, mp->context);
597 static_always_inline int
598 add_del_dummy_output_interface (u32 sw_if_index, u8 is_inside, u8 is_add)
600 nat44_ei_main_t *nm = &nat44_ei_main;
601 nat44_ei_interface_t *i;
604 pool_foreach (i, nm->output_feature_dummy_interfaces)
606 if (i->sw_if_index == sw_if_index)
610 pool_put (nm->output_feature_dummy_interfaces, i);
619 pool_get (nm->output_feature_dummy_interfaces, i);
620 i->sw_if_index = sw_if_index;
624 i->flags |= NAT44_EI_INTERFACE_FLAG_IS_INSIDE;
628 i->flags |= NAT44_EI_INTERFACE_FLAG_IS_OUTSIDE;
639 vl_api_nat44_ei_interface_add_del_output_feature_t_handler (
640 vl_api_nat44_ei_interface_add_del_output_feature_t *mp)
642 vl_api_nat44_ei_interface_add_del_output_feature_reply_t *rmp;
643 nat44_ei_main_t *nm = &nat44_ei_main;
647 VALIDATE_SW_IF_INDEX (mp);
649 sw_if_index = ntohl (mp->sw_if_index);
651 // register all interfaces in the dummy structure
652 rv = add_del_dummy_output_interface (
653 sw_if_index, mp->flags & NAT44_EI_IF_INSIDE, mp->is_add);
655 if (!(mp->flags & NAT44_EI_IF_INSIDE))
659 rv = nat44_ei_add_output_interface (sw_if_index);
663 rv = nat44_ei_del_output_interface (sw_if_index);
667 BAD_SW_IF_INDEX_LABEL;
668 REPLY_MACRO (VL_API_NAT44_EI_INTERFACE_ADD_DEL_OUTPUT_FEATURE_REPLY);
672 send_nat44_ei_interface_output_feature_details (nat44_ei_interface_t *i,
673 vl_api_registration_t *reg,
676 vl_api_nat44_ei_interface_output_feature_details_t *rmp;
677 nat44_ei_main_t *nm = &nat44_ei_main;
679 rmp = vl_msg_api_alloc (sizeof (*rmp));
680 clib_memset (rmp, 0, sizeof (*rmp));
682 ntohs (VL_API_NAT44_EI_INTERFACE_OUTPUT_FEATURE_DETAILS + nm->msg_id_base);
683 rmp->sw_if_index = ntohl (i->sw_if_index);
684 rmp->context = context;
686 if (nat44_ei_interface_is_inside (i))
688 rmp->flags |= NAT44_EI_IF_INSIDE;
691 vl_api_send_msg (reg, (u8 *) rmp);
695 vl_api_nat44_ei_interface_output_feature_dump_t_handler (
696 vl_api_nat44_ei_interface_output_feature_dump_t *mp)
698 vl_api_registration_t *reg;
699 nat44_ei_main_t *nm = &nat44_ei_main;
700 nat44_ei_interface_t *i;
702 reg = vl_api_client_index_to_registration (mp->client_index);
706 pool_foreach (i, nm->output_feature_dummy_interfaces)
708 send_nat44_ei_interface_output_feature_details (i, reg, mp->context);
713 vl_api_nat44_ei_add_del_output_interface_t_handler (
714 vl_api_nat44_ei_add_del_output_interface_t *mp)
716 vl_api_nat44_ei_add_del_output_interface_reply_t *rmp;
717 nat44_ei_main_t *nm = &nat44_ei_main;
720 VALIDATE_SW_IF_INDEX_END (mp);
724 rv = nat44_ei_add_output_interface (mp->sw_if_index);
728 rv = nat44_ei_del_output_interface (mp->sw_if_index);
732 REPLY_MACRO_END (VL_API_NAT44_EI_ADD_DEL_OUTPUT_INTERFACE_REPLY);
736 #include <nat/nat44-ei/nat44_ei.api.h>
739 send_nat44_ei_output_interface_details (u32 index, vl_api_registration_t *rp,
742 nat44_ei_main_t *nm = &nat44_ei_main;
743 vl_api_nat44_ei_output_interface_details_t *rmp;
744 nat44_ei_interface_t *i =
745 pool_elt_at_index (nm->output_feature_interfaces, index);
747 /* Make sure every field is initiated (or don't skip the clib_memset()) */
748 REPLY_MACRO_DETAILS4 (
749 VL_API_NAT44_EI_OUTPUT_INTERFACE_DETAILS, rp, context, ({
750 rmp->sw_if_index = i->sw_if_index;
752 /* Endian hack until apigen registers _details
753 * endian functions */
754 vl_api_nat44_ei_output_interface_details_t_endian (rmp,
756 rmp->_vl_msg_id = htons (rmp->_vl_msg_id);
757 rmp->context = htonl (rmp->context);
762 vl_api_nat44_ei_output_interface_get_t_handler (
763 vl_api_nat44_ei_output_interface_get_t *mp)
765 vl_api_nat44_ei_output_interface_get_reply_t *rmp;
766 nat44_ei_main_t *nm = &nat44_ei_main;
769 if (pool_elts (nm->output_feature_interfaces) == 0)
771 REPLY_MACRO (VL_API_NAT44_EI_OUTPUT_INTERFACE_GET_REPLY);
775 REPLY_AND_DETAILS_MACRO (
776 VL_API_NAT44_EI_OUTPUT_INTERFACE_GET_REPLY, nm->output_feature_interfaces,
777 ({ send_nat44_ei_output_interface_details (cursor, rp, mp->context); }));
781 vl_api_nat44_ei_add_del_static_mapping_t_handler (
782 vl_api_nat44_ei_add_del_static_mapping_t *mp)
784 vl_api_nat44_ei_add_del_static_mapping_reply_t *rmp;
786 nat44_ei_main_t *nm = &nat44_ei_main;
789 ip4_address_t l_addr, e_addr, pool_addr = { 0 };
790 u32 sw_if_index, flags = 0, vrf_id;
791 u16 l_port = 0, e_port = 0;
792 nat_protocol_t proto = 0;
795 memcpy (&l_addr.as_u8, mp->local_ip_address, 4);
797 if (mp->flags & NAT44_EI_ADDR_ONLY_MAPPING)
799 flags |= NAT44_EI_SM_FLAG_ADDR_ONLY;
803 l_port = mp->local_port;
804 e_port = mp->external_port;
805 proto = ip_proto_to_nat_proto (mp->protocol);
808 sw_if_index = clib_net_to_host_u32 (mp->external_sw_if_index);
809 if (sw_if_index != ~0)
811 flags |= NAT44_EI_SM_FLAG_SWITCH_ADDRESS;
815 memcpy (&e_addr.as_u8, mp->external_ip_address, 4);
818 vrf_id = clib_net_to_host_u32 (mp->vrf_id);
822 mp->tag[sizeof (mp->tag) - 1] = 0;
823 tag = format (0, "%s", mp->tag);
824 vec_terminate_c_string (tag);
826 rv = nat44_ei_add_static_mapping (l_addr, e_addr, l_port, e_port, proto,
827 vrf_id, sw_if_index, flags, pool_addr,
833 rv = nat44_ei_del_static_mapping (l_addr, e_addr, l_port, e_port, proto,
834 vrf_id, sw_if_index, flags);
836 REPLY_MACRO (VL_API_NAT44_EI_ADD_DEL_STATIC_MAPPING_REPLY);
840 send_nat44_ei_static_mapping_details (nat44_ei_static_mapping_t *m,
841 vl_api_registration_t *reg, u32 context)
843 vl_api_nat44_ei_static_mapping_details_t *rmp;
844 nat44_ei_main_t *nm = &nat44_ei_main;
845 u32 len = sizeof (*rmp);
847 rmp = vl_msg_api_alloc (len);
848 clib_memset (rmp, 0, len);
850 ntohs (VL_API_NAT44_EI_STATIC_MAPPING_DETAILS + nm->msg_id_base);
852 clib_memcpy (rmp->local_ip_address, &(m->local_addr), 4);
853 clib_memcpy (rmp->external_ip_address, &(m->external_addr), 4);
854 rmp->external_sw_if_index = ~0;
855 rmp->vrf_id = htonl (m->vrf_id);
856 rmp->context = context;
858 if (is_sm_addr_only (m->flags))
860 rmp->flags |= NAT44_EI_ADDR_ONLY_MAPPING;
864 rmp->protocol = nat_proto_to_ip_proto (m->proto);
865 rmp->external_port = m->external_port;
866 rmp->local_port = m->local_port;
870 strncpy ((char *) rmp->tag, (char *) m->tag, vec_len (m->tag));
872 vl_api_send_msg (reg, (u8 *) rmp);
876 send_nat44_ei_static_map_resolve_details (nat44_ei_static_map_resolve_t *m,
877 vl_api_registration_t *reg,
880 vl_api_nat44_ei_static_mapping_details_t *rmp;
881 nat44_ei_main_t *nm = &nat44_ei_main;
883 rmp = vl_msg_api_alloc (sizeof (*rmp));
884 clib_memset (rmp, 0, sizeof (*rmp));
886 ntohs (VL_API_NAT44_EI_STATIC_MAPPING_DETAILS + nm->msg_id_base);
887 clib_memcpy (rmp->local_ip_address, &(m->l_addr), 4);
888 rmp->external_sw_if_index = htonl (m->sw_if_index);
889 rmp->vrf_id = htonl (m->vrf_id);
890 rmp->context = context;
892 if (is_sm_addr_only (m->flags))
894 rmp->flags |= NAT44_EI_ADDR_ONLY_MAPPING;
898 rmp->protocol = nat_proto_to_ip_proto (m->proto);
899 rmp->external_port = m->e_port;
900 rmp->local_port = m->l_port;
903 strncpy ((char *) rmp->tag, (char *) m->tag, vec_len (m->tag));
905 vl_api_send_msg (reg, (u8 *) rmp);
909 vl_api_nat44_ei_static_mapping_dump_t_handler (
910 vl_api_nat44_ei_static_mapping_dump_t *mp)
912 vl_api_registration_t *reg;
913 nat44_ei_main_t *nm = &nat44_ei_main;
914 nat44_ei_static_mapping_t *m;
915 nat44_ei_static_map_resolve_t *rp;
918 reg = vl_api_client_index_to_registration (mp->client_index);
922 pool_foreach (m, nm->static_mappings)
924 if (!is_sm_identity_nat (m->flags))
925 send_nat44_ei_static_mapping_details (m, reg, mp->context);
928 for (j = 0; j < vec_len (nm->to_resolve); j++)
930 rp = nm->to_resolve + j;
931 if (!is_sm_identity_nat (rp->flags))
932 send_nat44_ei_static_map_resolve_details (rp, reg, mp->context);
937 vl_api_nat44_ei_add_del_identity_mapping_t_handler (
938 vl_api_nat44_ei_add_del_identity_mapping_t *mp)
940 vl_api_nat44_ei_add_del_identity_mapping_reply_t *rmp;
942 nat44_ei_main_t *nm = &nat44_ei_main;
945 ip4_address_t addr, pool_addr = { 0 };
946 u32 sw_if_index, flags, vrf_id;
947 nat_protocol_t proto = 0;
951 flags = NAT44_EI_SM_FLAG_IDENTITY_NAT;
953 if (mp->flags & NAT44_EI_ADDR_ONLY_MAPPING)
955 flags |= NAT44_EI_SM_FLAG_ADDR_ONLY;
960 proto = ip_proto_to_nat_proto (mp->protocol);
963 sw_if_index = clib_net_to_host_u32 (mp->sw_if_index);
964 if (sw_if_index != ~0)
966 flags |= NAT44_EI_SM_FLAG_SWITCH_ADDRESS;
970 memcpy (&addr.as_u8, mp->ip_address, 4);
973 vrf_id = clib_net_to_host_u32 (mp->vrf_id);
977 mp->tag[sizeof (mp->tag) - 1] = 0;
978 tag = format (0, "%s", mp->tag);
979 vec_terminate_c_string (tag);
981 rv = nat44_ei_add_static_mapping (addr, addr, port, port, proto, vrf_id,
982 sw_if_index, flags, pool_addr, tag);
987 rv = nat44_ei_del_static_mapping (addr, addr, port, port, proto, vrf_id,
991 REPLY_MACRO (VL_API_NAT44_EI_ADD_DEL_IDENTITY_MAPPING_REPLY);
995 send_nat44_ei_identity_mapping_details (nat44_ei_static_mapping_t *m,
996 int index, vl_api_registration_t *reg,
999 vl_api_nat44_ei_identity_mapping_details_t *rmp;
1000 nat44_ei_main_t *nm = &nat44_ei_main;
1001 nat44_ei_lb_addr_port_t *local = pool_elt_at_index (m->locals, index);
1003 rmp = vl_msg_api_alloc (sizeof (*rmp));
1004 clib_memset (rmp, 0, sizeof (*rmp));
1006 ntohs (VL_API_NAT44_EI_IDENTITY_MAPPING_DETAILS + nm->msg_id_base);
1008 if (is_sm_addr_only (m->flags))
1009 rmp->flags |= NAT44_EI_ADDR_ONLY_MAPPING;
1011 clib_memcpy (rmp->ip_address, &(m->local_addr), 4);
1012 rmp->port = m->local_port;
1013 rmp->sw_if_index = ~0;
1014 rmp->vrf_id = htonl (local->vrf_id);
1015 rmp->protocol = nat_proto_to_ip_proto (m->proto);
1016 rmp->context = context;
1018 strncpy ((char *) rmp->tag, (char *) m->tag, vec_len (m->tag));
1020 vl_api_send_msg (reg, (u8 *) rmp);
1024 send_nat44_ei_identity_map_resolve_details (nat44_ei_static_map_resolve_t *m,
1025 vl_api_registration_t *reg,
1028 vl_api_nat44_ei_identity_mapping_details_t *rmp;
1029 nat44_ei_main_t *nm = &nat44_ei_main;
1030 rmp = vl_msg_api_alloc (sizeof (*rmp));
1031 clib_memset (rmp, 0, sizeof (*rmp));
1033 ntohs (VL_API_NAT44_EI_IDENTITY_MAPPING_DETAILS + nm->msg_id_base);
1035 if (is_sm_addr_only (m->flags))
1036 rmp->flags = (vl_api_nat44_ei_config_flags_t) NAT44_EI_ADDR_ONLY_MAPPING;
1038 rmp->port = m->l_port;
1039 rmp->sw_if_index = htonl (m->sw_if_index);
1040 rmp->vrf_id = htonl (m->vrf_id);
1041 rmp->protocol = nat_proto_to_ip_proto (m->proto);
1042 rmp->context = context;
1044 strncpy ((char *) rmp->tag, (char *) m->tag, vec_len (m->tag));
1046 vl_api_send_msg (reg, (u8 *) rmp);
1050 vl_api_nat44_ei_identity_mapping_dump_t_handler (
1051 vl_api_nat44_ei_identity_mapping_dump_t *mp)
1053 vl_api_registration_t *reg;
1054 nat44_ei_main_t *nm = &nat44_ei_main;
1055 nat44_ei_static_mapping_t *m;
1056 nat44_ei_static_map_resolve_t *rp;
1059 reg = vl_api_client_index_to_registration (mp->client_index);
1063 pool_foreach (m, nm->static_mappings)
1065 if (is_sm_identity_nat (m->flags))
1067 pool_foreach_index (j, m->locals)
1069 send_nat44_ei_identity_mapping_details (m, j, reg, mp->context);
1074 for (j = 0; j < vec_len (nm->to_resolve); j++)
1076 rp = nm->to_resolve + j;
1077 if (is_sm_identity_nat (rp->flags))
1078 send_nat44_ei_identity_map_resolve_details (rp, reg, mp->context);
1083 vl_api_nat44_ei_add_del_interface_addr_t_handler (
1084 vl_api_nat44_ei_add_del_interface_addr_t *mp)
1086 nat44_ei_main_t *nm = &nat44_ei_main;
1087 vl_api_nat44_ei_add_del_interface_addr_reply_t *rmp;
1088 u32 sw_if_index = ntohl (mp->sw_if_index);
1091 VALIDATE_SW_IF_INDEX (mp);
1095 rv = nat44_ei_add_interface_address (sw_if_index);
1099 rv = nat44_ei_del_interface_address (sw_if_index);
1102 BAD_SW_IF_INDEX_LABEL;
1103 REPLY_MACRO (VL_API_NAT44_EI_ADD_DEL_INTERFACE_ADDR_REPLY);
1107 send_nat44_ei_interface_addr_details (u32 sw_if_index,
1108 vl_api_registration_t *reg, u32 context)
1110 vl_api_nat44_ei_interface_addr_details_t *rmp;
1111 nat44_ei_main_t *nm = &nat44_ei_main;
1113 rmp = vl_msg_api_alloc (sizeof (*rmp));
1114 clib_memset (rmp, 0, sizeof (*rmp));
1116 ntohs (VL_API_NAT44_EI_INTERFACE_ADDR_DETAILS + nm->msg_id_base);
1117 rmp->sw_if_index = ntohl (sw_if_index);
1118 rmp->context = context;
1120 vl_api_send_msg (reg, (u8 *) rmp);
1124 vl_api_nat44_ei_interface_addr_dump_t_handler (
1125 vl_api_nat44_ei_interface_addr_dump_t *mp)
1127 vl_api_registration_t *reg;
1128 nat44_ei_main_t *nm = &nat44_ei_main;
1131 reg = vl_api_client_index_to_registration (mp->client_index);
1135 vec_foreach (i, nm->auto_add_sw_if_indices)
1136 send_nat44_ei_interface_addr_details (*i, reg, mp->context);
1140 send_nat44_ei_user_details (nat44_ei_user_t *u, vl_api_registration_t *reg,
1143 vl_api_nat44_ei_user_details_t *rmp;
1144 nat44_ei_main_t *nm = &nat44_ei_main;
1145 ip4_main_t *im = &ip4_main;
1147 rmp = vl_msg_api_alloc (sizeof (*rmp));
1148 clib_memset (rmp, 0, sizeof (*rmp));
1149 rmp->_vl_msg_id = ntohs (VL_API_NAT44_EI_USER_DETAILS + nm->msg_id_base);
1151 if (!pool_is_free_index (im->fibs, u->fib_index))
1153 fib_table_t *fib = fib_table_get (u->fib_index, FIB_PROTOCOL_IP4);
1154 rmp->vrf_id = ntohl (fib->ft_table_id);
1157 clib_memcpy (rmp->ip_address, &(u->addr), 4);
1158 rmp->nsessions = ntohl (u->nsessions);
1159 rmp->nstaticsessions = ntohl (u->nstaticsessions);
1160 rmp->context = context;
1162 vl_api_send_msg (reg, (u8 *) rmp);
1166 vl_api_nat44_ei_user_dump_t_handler (vl_api_nat44_ei_user_dump_t *mp)
1168 vl_api_registration_t *reg;
1169 nat44_ei_main_t *nm = &nat44_ei_main;
1170 nat44_ei_main_per_thread_data_t *tnm;
1173 reg = vl_api_client_index_to_registration (mp->client_index);
1177 vec_foreach (tnm, nm->per_thread_data)
1179 pool_foreach (u, tnm->users)
1181 send_nat44_ei_user_details (u, reg, mp->context);
1187 send_nat44_ei_user_session_details (nat44_ei_session_t *s,
1188 vl_api_registration_t *reg, u32 context)
1190 vl_api_nat44_ei_user_session_details_t *rmp;
1191 nat44_ei_main_t *nm = &nat44_ei_main;
1193 rmp = vl_msg_api_alloc (sizeof (*rmp));
1194 clib_memset (rmp, 0, sizeof (*rmp));
1196 ntohs (VL_API_NAT44_EI_USER_SESSION_DETAILS + nm->msg_id_base);
1197 clib_memcpy (rmp->outside_ip_address, (&s->out2in.addr), 4);
1198 clib_memcpy (rmp->inside_ip_address, (&s->in2out.addr), 4);
1200 if (nat44_ei_is_session_static (s))
1201 rmp->flags |= NAT44_EI_STATIC_MAPPING;
1203 rmp->last_heard = clib_host_to_net_u64 ((u64) s->last_heard);
1204 rmp->total_bytes = clib_host_to_net_u64 (s->total_bytes);
1205 rmp->total_pkts = ntohl (s->total_pkts);
1206 rmp->context = context;
1207 if (nat44_ei_is_unk_proto_session (s))
1209 rmp->outside_port = 0;
1210 rmp->inside_port = 0;
1211 rmp->protocol = ntohs (s->in2out.port);
1215 rmp->outside_port = s->out2in.port;
1216 rmp->inside_port = s->in2out.port;
1217 rmp->protocol = ntohs (nat_proto_to_ip_proto (s->nat_proto));
1219 vl_api_send_msg (reg, (u8 *) rmp);
1223 send_nat44_ei_user_session_v2_details (nat44_ei_session_t *s,
1224 vl_api_registration_t *reg, u32 context)
1226 vl_api_nat44_ei_user_session_v2_details_t *rmp;
1227 nat44_ei_main_t *nm = &nat44_ei_main;
1229 rmp = vl_msg_api_alloc (sizeof (*rmp));
1230 clib_memset (rmp, 0, sizeof (*rmp));
1232 ntohs (VL_API_NAT44_EI_USER_SESSION_V2_DETAILS + nm->msg_id_base);
1233 clib_memcpy (rmp->outside_ip_address, (&s->out2in.addr), 4);
1234 clib_memcpy (rmp->inside_ip_address, (&s->in2out.addr), 4);
1236 if (nat44_ei_is_session_static (s))
1237 rmp->flags |= NAT44_EI_STATIC_MAPPING;
1239 rmp->last_heard = clib_host_to_net_u64 ((u64) s->last_heard);
1240 rmp->time_since_last_heard = clib_host_to_net_u64 (
1241 (u64) (vlib_time_now (vlib_get_main ()) - s->last_heard));
1242 rmp->total_bytes = clib_host_to_net_u64 (s->total_bytes);
1243 rmp->total_pkts = ntohl (s->total_pkts);
1244 rmp->context = context;
1245 if (nat44_ei_is_unk_proto_session (s))
1247 rmp->outside_port = 0;
1248 rmp->inside_port = 0;
1249 rmp->protocol = ntohs (s->in2out.port);
1253 rmp->outside_port = s->out2in.port;
1254 rmp->inside_port = s->in2out.port;
1255 rmp->protocol = ntohs (nat_proto_to_ip_proto (s->nat_proto));
1257 vl_api_send_msg (reg, (u8 *) rmp);
1261 vl_api_nat44_ei_user_session_dump_t_handler (
1262 vl_api_nat44_ei_user_session_dump_t *mp)
1264 vl_api_registration_t *reg;
1265 nat44_ei_main_t *nm = &nat44_ei_main;
1266 nat44_ei_main_per_thread_data_t *tnm;
1267 nat44_ei_session_t *s;
1268 clib_bihash_kv_8_8_t key, value;
1269 nat44_ei_user_key_t ukey;
1271 u32 session_index, head_index, elt_index;
1272 dlist_elt_t *head, *elt;
1275 reg = vl_api_client_index_to_registration (mp->client_index);
1279 clib_memcpy (&ukey.addr, mp->ip_address, 4);
1280 ip.src_address.as_u32 = ukey.addr.as_u32;
1281 ukey.fib_index = fib_table_find (FIB_PROTOCOL_IP4, ntohl (mp->vrf_id));
1282 key.key = ukey.as_u64;
1283 if (nm->num_workers > 1)
1284 tnm = vec_elt_at_index (
1285 nm->per_thread_data,
1286 nat44_ei_get_in2out_worker_index (&ip, ukey.fib_index, 0));
1288 tnm = vec_elt_at_index (nm->per_thread_data, nm->num_workers);
1290 if (clib_bihash_search_8_8 (&tnm->user_hash, &key, &value))
1292 u = pool_elt_at_index (tnm->users, value.value);
1293 if (!u->nsessions && !u->nstaticsessions)
1296 head_index = u->sessions_per_user_list_head_index;
1297 head = pool_elt_at_index (tnm->list_pool, head_index);
1298 elt_index = head->next;
1299 elt = pool_elt_at_index (tnm->list_pool, elt_index);
1300 session_index = elt->value;
1301 while (session_index != ~0)
1303 s = pool_elt_at_index (tnm->sessions, session_index);
1305 send_nat44_ei_user_session_details (s, reg, mp->context);
1307 elt_index = elt->next;
1308 elt = pool_elt_at_index (tnm->list_pool, elt_index);
1309 session_index = elt->value;
1314 vl_api_nat44_ei_user_session_v2_dump_t_handler (
1315 vl_api_nat44_ei_user_session_dump_t *mp)
1317 vl_api_registration_t *reg;
1318 nat44_ei_main_t *nm = &nat44_ei_main;
1319 nat44_ei_main_per_thread_data_t *tnm;
1320 nat44_ei_session_t *s;
1321 clib_bihash_kv_8_8_t key, value;
1322 nat44_ei_user_key_t ukey;
1324 u32 session_index, head_index, elt_index;
1325 dlist_elt_t *head, *elt;
1328 reg = vl_api_client_index_to_registration (mp->client_index);
1332 clib_memcpy (&ukey.addr, mp->ip_address, 4);
1333 ip.src_address.as_u32 = ukey.addr.as_u32;
1334 ukey.fib_index = fib_table_find (FIB_PROTOCOL_IP4, ntohl (mp->vrf_id));
1335 key.key = ukey.as_u64;
1336 if (nm->num_workers > 1)
1337 tnm = vec_elt_at_index (
1338 nm->per_thread_data,
1339 nat44_ei_get_in2out_worker_index (&ip, ukey.fib_index, 0));
1341 tnm = vec_elt_at_index (nm->per_thread_data, nm->num_workers);
1343 if (clib_bihash_search_8_8 (&tnm->user_hash, &key, &value))
1345 u = pool_elt_at_index (tnm->users, value.value);
1346 if (!u->nsessions && !u->nstaticsessions)
1349 head_index = u->sessions_per_user_list_head_index;
1350 head = pool_elt_at_index (tnm->list_pool, head_index);
1351 elt_index = head->next;
1352 elt = pool_elt_at_index (tnm->list_pool, elt_index);
1353 session_index = elt->value;
1354 while (session_index != ~0)
1356 s = pool_elt_at_index (tnm->sessions, session_index);
1358 send_nat44_ei_user_session_v2_details (s, reg, mp->context);
1360 elt_index = elt->next;
1361 elt = pool_elt_at_index (tnm->list_pool, elt_index);
1362 session_index = elt->value;
1367 vl_api_nat44_ei_del_session_t_handler (vl_api_nat44_ei_del_session_t *mp)
1369 nat44_ei_main_t *nm = &nat44_ei_main;
1370 vl_api_nat44_ei_del_session_reply_t *rmp;
1371 ip4_address_t addr, eh_addr;
1376 nat_protocol_t proto;
1378 memcpy (&addr.as_u8, mp->address, 4);
1380 vrf_id = clib_net_to_host_u32 (mp->vrf_id);
1381 proto = ip_proto_to_nat_proto (mp->protocol);
1382 memcpy (&eh_addr.as_u8, mp->ext_host_address, 4);
1384 // is session inside ?
1385 is_in = mp->flags & NAT44_EI_IF_INSIDE;
1387 rv = nat44_ei_del_session (nm, &addr, port, proto, vrf_id, is_in);
1389 REPLY_MACRO (VL_API_NAT44_EI_DEL_SESSION_REPLY);
1393 vl_api_nat44_ei_forwarding_enable_disable_t_handler (
1394 vl_api_nat44_ei_forwarding_enable_disable_t *mp)
1396 nat44_ei_main_t *nm = &nat44_ei_main;
1397 vl_api_nat44_ei_forwarding_enable_disable_reply_t *rmp;
1399 u32 *ses_to_be_removed = 0, *ses_index;
1400 nat44_ei_main_per_thread_data_t *tnm;
1401 nat44_ei_session_t *s;
1403 nm->forwarding_enabled = mp->enable != 0;
1405 if (mp->enable == 0)
1407 vec_foreach (tnm, nm->per_thread_data)
1409 vec_foreach (ses_index, ses_to_be_removed)
1411 s = pool_elt_at_index (tnm->sessions, ses_index[0]);
1412 nat44_ei_free_session_data (nm, s, tnm - nm->per_thread_data, 0);
1413 nat44_ei_delete_session (nm, s, tnm - nm->per_thread_data);
1416 vec_free (ses_to_be_removed);
1420 REPLY_MACRO (VL_API_NAT44_EI_FORWARDING_ENABLE_DISABLE_REPLY);
1424 vl_api_nat44_ei_set_fq_options_t_handler (vl_api_nat44_ei_set_fq_options_t *mp)
1426 nat44_ei_main_t *nm = &nat44_ei_main;
1427 vl_api_nat44_ei_set_fq_options_reply_t *rmp;
1429 u32 frame_queue_nelts = ntohl (mp->frame_queue_nelts);
1430 rv = nat44_ei_set_frame_queue_nelts (frame_queue_nelts);
1431 REPLY_MACRO (VL_API_NAT44_EI_SET_FQ_OPTIONS_REPLY);
1435 vl_api_nat44_ei_show_fq_options_t_handler (
1436 vl_api_nat44_ei_show_fq_options_t *mp)
1438 nat44_ei_main_t *nm = &nat44_ei_main;
1439 vl_api_nat44_ei_show_fq_options_reply_t *rmp;
1441 /* clang-format off */
1442 REPLY_MACRO2_ZERO (VL_API_NAT44_EI_SHOW_FQ_OPTIONS_REPLY,
1444 rmp->frame_queue_nelts = htonl (nm->frame_queue_nelts);
1446 /* clang-format on */
1449 /* API definitions */
1450 #include <vnet/format_fns.h>
1451 #include <nat/nat44-ei/nat44_ei.api.c>
1453 /* Set up the API message handling tables */
1455 nat44_ei_api_hookup (vlib_main_t *vm)
1457 nat44_ei_main_t *nm = &nat44_ei_main;
1458 nm->msg_id_base = setup_message_id_table ();
1463 * fd.io coding-style-patch-verification: ON
1466 * eval: (c-set-style "gnu")