2 *------------------------------------------------------------------
3 * Copyright (c) 2021 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.
15 *------------------------------------------------------------------
19 #include <vlibapi/api.h>
20 #include <vlibmemory/api.h>
21 #include <vppinfra/error.h>
22 #include <vpp/api/types.h>
24 #include <vnet/ip/ip_types_api.h>
26 #define __plugin_msg_base interface_test_main.msg_id_base
27 #include <vlibapi/vat_helper_macros.h>
29 /* Declare message IDs */
30 #include <vnet/format_fns.h>
31 #include <vnet/interface.api_enum.h>
32 #include <vnet/interface.api_types.h>
33 #include <vlibmemory/vlib.api_types.h>
34 #include <vlibmemory/memclnt.api_enum.h>
36 #define vl_endianfun /* define message structures */
37 #include <vnet/interface.api.h>
42 /* API message ID base */
45 } interface_test_main_t;
47 static interface_test_main_t interface_test_main;
50 api_sw_interface_set_flags (vat_main_t *vam)
52 unformat_input_t *i = vam->input;
53 vl_api_sw_interface_set_flags_t *mp;
55 u8 sw_if_index_set = 0;
59 /* Parse args required to build the message */
60 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
62 if (unformat (i, "admin-up"))
64 else if (unformat (i, "admin-down"))
66 else if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
68 else if (unformat (i, "sw_if_index %d", &sw_if_index))
74 if (sw_if_index_set == 0)
76 errmsg ("missing interface name or sw_if_index");
80 /* Construct the API message */
81 M (SW_INTERFACE_SET_FLAGS, mp);
82 mp->sw_if_index = ntohl (sw_if_index);
83 mp->flags = ntohl ((admin_up) ? IF_STATUS_API_FLAG_ADMIN_UP : 0);
88 /* Wait for a reply, return the good/bad news... */
94 api_hw_interface_set_mtu (vat_main_t *vam)
96 unformat_input_t *i = vam->input;
97 vl_api_hw_interface_set_mtu_t *mp;
102 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
104 if (unformat (i, "mtu %d", &mtu))
106 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
108 else if (unformat (i, "sw_if_index %d", &sw_if_index))
114 if (sw_if_index == ~0)
116 errmsg ("missing interface name or sw_if_index");
122 errmsg ("no mtu specified");
126 /* Construct the API message */
127 M (HW_INTERFACE_SET_MTU, mp);
128 mp->sw_if_index = ntohl (sw_if_index);
129 mp->mtu = ntohs ((u16) mtu);
137 api_sw_interface_tag_add_del (vat_main_t *vam)
139 unformat_input_t *i = vam->input;
140 vl_api_sw_interface_tag_add_del_t *mp;
141 u32 sw_if_index = ~0;
146 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
148 if (unformat (i, "tag %s", &tag))
150 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
152 else if (unformat (i, "sw_if_index %d", &sw_if_index))
154 else if (unformat (i, "del"))
160 if (sw_if_index == ~0)
162 errmsg ("missing interface name or sw_if_index");
166 if (enable && (tag == 0))
168 errmsg ("no tag specified");
172 /* Construct the API message */
173 M (SW_INTERFACE_TAG_ADD_DEL, mp);
174 mp->sw_if_index = ntohl (sw_if_index);
177 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
186 api_sw_interface_add_del_mac_address (vat_main_t *vam)
188 unformat_input_t *i = vam->input;
189 vl_api_mac_address_t mac = { 0 };
190 vl_api_sw_interface_add_del_mac_address_t *mp;
191 u32 sw_if_index = ~0;
196 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
198 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
200 else if (unformat (i, "sw_if_index %d", &sw_if_index))
202 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
204 else if (unformat (i, "del"))
210 if (sw_if_index == ~0)
212 errmsg ("missing interface name or sw_if_index");
218 errmsg ("missing MAC address");
222 /* Construct the API message */
223 M (SW_INTERFACE_ADD_DEL_MAC_ADDRESS, mp);
224 mp->sw_if_index = ntohl (sw_if_index);
226 clib_memcpy (&mp->addr, &mac, sizeof (mac));
234 vl_api_sw_interface_details_t_handler (vl_api_sw_interface_details_t *mp)
236 vat_main_t *vam = &vat_main;
237 u8 *s = format (0, "%s%c", mp->interface_name, 0);
239 hash_set_mem (vam->sw_if_index_by_interface_name, s,
240 ntohl (mp->sw_if_index));
242 /* In sub interface case, fill the sub interface table entry */
243 if (mp->sw_if_index != mp->sup_sw_if_index)
245 sw_interface_subif_t *sub = NULL;
247 vec_add2 (vam->sw_if_subif_table, sub, 1);
249 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
250 strncpy ((char *) sub->interface_name, (char *) s,
251 vec_len (sub->interface_name));
252 sub->sw_if_index = ntohl (mp->sw_if_index);
253 sub->sub_id = ntohl (mp->sub_id);
255 sub->raw_flags = ntohl (mp->sub_if_flags & SUB_IF_API_FLAG_MASK_VNET);
257 sub->sub_number_of_tags = mp->sub_number_of_tags;
258 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
259 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
261 /* vlan tag rewrite */
262 sub->vtr_op = ntohl (mp->vtr_op);
263 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
264 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
265 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
270 api_sw_interface_get_mac_address (vat_main_t *vat)
276 vl_api_sw_interface_get_mac_address_reply_t_handler (
277 vl_api_sw_interface_get_mac_address_reply_t *mp)
282 api_sw_interface_add_del_address (vat_main_t *vam)
284 unformat_input_t *i = vam->input;
285 vl_api_sw_interface_add_del_address_t *mp;
287 u8 sw_if_index_set = 0;
288 u8 is_add = 1, del_all = 0;
289 u32 address_length = 0;
290 u8 v4_address_set = 0;
291 u8 v6_address_set = 0;
292 ip4_address_t v4address;
293 ip6_address_t v6address;
296 /* Parse args required to build the message */
297 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
299 if (unformat (i, "del-all"))
301 else if (unformat (i, "del"))
303 else if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
305 else if (unformat (i, "sw_if_index %d", &sw_if_index))
307 else if (unformat (i, "%U/%d", unformat_ip4_address, &v4address,
310 else if (unformat (i, "%U/%d", unformat_ip6_address, &v6address,
317 if (sw_if_index_set == 0)
319 errmsg ("missing interface name or sw_if_index");
322 if (v4_address_set && v6_address_set)
324 errmsg ("both v4 and v6 addresses set");
327 if (!v4_address_set && !v6_address_set && !del_all)
329 errmsg ("no addresses set");
333 /* Construct the API message */
334 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
336 mp->sw_if_index = ntohl (sw_if_index);
338 mp->del_all = del_all;
341 mp->prefix.address.af = ADDRESS_IP6;
342 clib_memcpy (mp->prefix.address.un.ip6, &v6address, sizeof (v6address));
346 mp->prefix.address.af = ADDRESS_IP4;
347 clib_memcpy (mp->prefix.address.un.ip4, &v4address, sizeof (v4address));
349 mp->prefix.len = address_length;
354 /* Wait for a reply, return good/bad news */
360 api_sw_interface_get_table (vat_main_t *vam)
362 unformat_input_t *i = vam->input;
363 vl_api_sw_interface_get_table_t *mp;
365 u8 sw_if_index_set = 0;
369 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
371 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
373 else if (unformat (i, "sw_if_index %d", &sw_if_index))
375 else if (unformat (i, "ipv6"))
381 if (sw_if_index_set == 0)
383 errmsg ("missing interface name or sw_if_index");
387 M (SW_INTERFACE_GET_TABLE, mp);
388 mp->sw_if_index = htonl (sw_if_index);
389 mp->is_ipv6 = is_ipv6;
397 api_sw_interface_set_rx_mode (vat_main_t *vam)
399 unformat_input_t *i = vam->input;
400 vl_api_sw_interface_set_rx_mode_t *mp;
402 u8 sw_if_index_set = 0;
404 u8 queue_id_valid = 0;
406 vnet_hw_if_rx_mode mode = VNET_HW_IF_RX_MODE_UNKNOWN;
408 /* Parse args required to build the message */
409 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
411 if (unformat (i, "queue %d", &queue_id))
413 else if (unformat (i, "polling"))
414 mode = VNET_HW_IF_RX_MODE_POLLING;
415 else if (unformat (i, "interrupt"))
416 mode = VNET_HW_IF_RX_MODE_INTERRUPT;
417 else if (unformat (i, "adaptive"))
418 mode = VNET_HW_IF_RX_MODE_ADAPTIVE;
419 else if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
421 else if (unformat (i, "sw_if_index %d", &sw_if_index))
427 if (sw_if_index_set == 0)
429 errmsg ("missing interface name or sw_if_index");
432 if (mode == VNET_HW_IF_RX_MODE_UNKNOWN)
434 errmsg ("missing rx-mode");
438 /* Construct the API message */
439 M (SW_INTERFACE_SET_RX_MODE, mp);
440 mp->sw_if_index = ntohl (sw_if_index);
441 mp->mode = (vl_api_rx_mode_t) mode;
442 mp->queue_id_valid = queue_id_valid;
443 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
448 /* Wait for a reply, return the good/bad news... */
454 api_sw_interface_set_unnumbered (vat_main_t *vam)
456 unformat_input_t *i = vam->input;
457 vl_api_sw_interface_set_unnumbered_t *mp;
459 u32 unnum_sw_index = ~0;
461 u8 sw_if_index_set = 0;
464 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
466 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
468 else if (unformat (i, "sw_if_index %d", &sw_if_index))
470 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
472 else if (unformat (i, "del"))
476 clib_warning ("parse error '%U'", format_unformat_error, i);
481 if (sw_if_index_set == 0)
483 errmsg ("missing interface name or sw_if_index");
487 M (SW_INTERFACE_SET_UNNUMBERED, mp);
489 mp->sw_if_index = ntohl (sw_if_index);
490 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
499 vl_api_sw_interface_get_table_reply_t_handler (
500 vl_api_sw_interface_get_table_reply_t *mp)
502 vat_main_t *vam = interface_test_main.vat_main;
504 fformat (vam->ofp, "%d", ntohl (mp->vrf_id));
506 vam->retval = ntohl (mp->retval);
507 vam->result_ready = 1;
511 api_sw_interface_address_replace_begin (vat_main_t *vam)
517 api_sw_interface_set_mac_address (vat_main_t *vam)
523 api_sw_interface_set_rx_placement (vat_main_t *vam)
525 unformat_input_t *i = vam->input;
526 vl_api_sw_interface_set_rx_placement_t *mp;
528 u8 sw_if_index_set = 0;
531 u32 queue_id, thread_index;
533 /* Parse args required to build the message */
534 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
536 if (unformat (i, "queue %d", &queue_id))
538 else if (unformat (i, "main"))
540 else if (unformat (i, "worker %d", &thread_index))
542 else if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
544 else if (unformat (i, "sw_if_index %d", &sw_if_index))
550 if (sw_if_index_set == 0)
552 errmsg ("missing interface name or sw_if_index");
558 /* Construct the API message */
559 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
560 mp->sw_if_index = ntohl (sw_if_index);
561 mp->worker_id = ntohl (thread_index);
562 mp->queue_id = ntohl (queue_id);
563 mp->is_main = is_main;
567 /* Wait for a reply, return the good/bad news... */
573 api_interface_name_renumber (vat_main_t *vam)
575 unformat_input_t *line_input = vam->input;
576 vl_api_interface_name_renumber_t *mp;
577 u32 sw_if_index = ~0;
578 u32 new_show_dev_instance = ~0;
581 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
583 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
586 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
588 else if (unformat (line_input, "new_show_dev_instance %d",
589 &new_show_dev_instance))
595 if (sw_if_index == ~0)
597 errmsg ("missing interface name or sw_if_index");
601 if (new_show_dev_instance == ~0)
603 errmsg ("missing new_show_dev_instance");
607 M (INTERFACE_NAME_RENUMBER, mp);
609 mp->sw_if_index = ntohl (sw_if_index);
610 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
618 api_delete_subif (vat_main_t *vam)
620 unformat_input_t *i = vam->input;
621 vl_api_delete_subif_t *mp;
622 u32 sw_if_index = ~0;
625 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
627 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
629 if (unformat (i, "sw_if_index %d", &sw_if_index))
635 if (sw_if_index == ~0)
637 errmsg ("missing sw_if_index");
641 /* Construct the API message */
642 M (DELETE_SUBIF, mp);
643 mp->sw_if_index = ntohl (sw_if_index);
651 api_delete_loopback (vat_main_t *vam)
653 unformat_input_t *i = vam->input;
654 vl_api_delete_loopback_t *mp;
655 u32 sw_if_index = ~0;
658 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
660 if (unformat (i, "sw_if_index %d", &sw_if_index))
666 if (sw_if_index == ~0)
668 errmsg ("missing sw_if_index");
672 /* Construct the API message */
673 M (DELETE_LOOPBACK, mp);
674 mp->sw_if_index = ntohl (sw_if_index);
682 api_create_loopback_instance (vat_main_t *vat)
688 api_create_loopback (vat_main_t *vam)
690 unformat_input_t *i = vam->input;
691 vl_api_create_loopback_t *mp;
692 vl_api_create_loopback_instance_t *mp_lbi;
696 u32 user_instance = 0;
699 clib_memset (mac_address, 0, sizeof (mac_address));
701 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
703 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
705 if (unformat (i, "instance %d", &user_instance))
713 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
714 mp_lbi->is_specified = is_specified;
716 mp_lbi->user_instance = htonl (user_instance);
718 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
723 /* Construct the API message */
724 M (CREATE_LOOPBACK, mp);
726 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
735 vl_api_create_subif_reply_t_handler (vl_api_create_subif_reply_t *mp)
737 vat_main_t *vam = interface_test_main.vat_main;
738 vam->result_ready = 1;
741 #define foreach_create_subif_bit \
748 _ (outer_vlan_id_any) \
749 _ (inner_vlan_id_any)
751 #define foreach_create_subif_flag \
756 _ (4, "exact_match") \
757 _ (5, "default_sub") \
758 _ (6, "outer_vlan_id_any") \
759 _ (7, "inner_vlan_id_any")
762 api_create_subif (vat_main_t *vam)
764 unformat_input_t *i = vam->input;
765 vl_api_create_subif_t *mp;
767 u8 sw_if_index_set = 0;
770 u32 __attribute__ ((unused)) no_tags = 0;
771 u32 __attribute__ ((unused)) one_tag = 0;
772 u32 __attribute__ ((unused)) two_tags = 0;
773 u32 __attribute__ ((unused)) dot1ad = 0;
774 u32 __attribute__ ((unused)) exact_match = 0;
775 u32 __attribute__ ((unused)) default_sub = 0;
776 u32 __attribute__ ((unused)) outer_vlan_id_any = 0;
777 u32 __attribute__ ((unused)) inner_vlan_id_any = 0;
779 u16 outer_vlan_id = 0;
780 u16 inner_vlan_id = 0;
783 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
785 if (unformat (i, "sw_if_index %d", &sw_if_index))
787 else if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
789 else if (unformat (i, "sub_id %d", &sub_id))
791 else if (unformat (i, "outer_vlan_id %d", &tmp))
793 else if (unformat (i, "inner_vlan_id %d", &tmp))
796 #define _(a) else if (unformat (i, #a)) a = 1;
797 foreach_create_subif_bit
801 clib_warning ("parse error '%U'", format_unformat_error, i);
806 if (sw_if_index_set == 0)
808 errmsg ("missing interface name or sw_if_index");
814 errmsg ("missing sub_id");
817 M (CREATE_SUBIF, mp);
819 mp->sw_if_index = ntohl (sw_if_index);
820 mp->sub_id = ntohl (sub_id);
822 #define _(a, b) mp->sub_if_flags |= (1 << a);
823 foreach_create_subif_flag;
826 mp->outer_vlan_id = ntohs (outer_vlan_id);
827 mp->inner_vlan_id = ntohs (inner_vlan_id);
835 vl_api_sw_interface_rx_placement_details_t_handler (
836 vl_api_sw_interface_rx_placement_details_t *mp)
838 vat_main_t *vam = interface_test_main.vat_main;
839 u32 worker_id = ntohl (mp->worker_id);
841 print (vam->ofp, "\n%-11d %-11s %-6d %-5d %-9s", ntohl (mp->sw_if_index),
842 (worker_id == 0) ? "main" : "worker", worker_id, ntohl (mp->queue_id),
843 (mp->mode == 1) ? "polling" :
844 ((mp->mode == 2) ? "interrupt" : "adaptive"));
848 vl_api_create_vlan_subif_reply_t_handler (vl_api_create_vlan_subif_reply_t *mp)
850 vat_main_t *vam = interface_test_main.vat_main;
851 vam->result_ready = 1;
855 vl_api_create_loopback_reply_t_handler (vl_api_create_loopback_reply_t *mp)
857 vat_main_t *vam = interface_test_main.vat_main;
858 vam->result_ready = 1;
862 vl_api_create_loopback_instance_reply_t_handler (
863 vl_api_create_loopback_instance_reply_t *mp)
865 vat_main_t *vam = interface_test_main.vat_main;
866 vam->result_ready = 1;
870 api_create_vlan_subif (vat_main_t *vam)
872 unformat_input_t *i = vam->input;
873 vl_api_create_vlan_subif_t *mp;
875 u8 sw_if_index_set = 0;
880 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
882 if (unformat (i, "sw_if_index %d", &sw_if_index))
884 else if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
886 else if (unformat (i, "vlan %d", &vlan_id))
890 clib_warning ("parse error '%U'", format_unformat_error, i);
895 if (sw_if_index_set == 0)
897 errmsg ("missing interface name or sw_if_index");
901 if (vlan_id_set == 0)
903 errmsg ("missing vlan_id");
906 M (CREATE_VLAN_SUBIF, mp);
908 mp->sw_if_index = ntohl (sw_if_index);
909 mp->vlan_id = ntohl (vlan_id);
917 api_collect_detailed_interface_stats (vat_main_t *vam)
923 api_sw_interface_rx_placement_dump (vat_main_t *vam)
925 unformat_input_t *i = vam->input;
926 vl_api_sw_interface_rx_placement_dump_t *mp;
927 vl_api_control_ping_t *mp_ping;
930 u8 sw_if_index_set = 0;
932 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
934 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
936 else if (unformat (i, "sw_if_index %d", &sw_if_index))
942 fformat (vam->ofp, "\n%-11s %-11s %-6s %-5s %-4s", "sw_if_index",
943 "main/worker", "thread", "queue", "mode");
945 /* Dump Interface rx placement */
946 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
949 mp->sw_if_index = htonl (sw_if_index);
951 mp->sw_if_index = ~0;
955 /* Use a control ping for synchronization */
956 PING (&interface_test_main, mp_ping);
964 api_sw_interface_clear_stats (vat_main_t *vam)
966 unformat_input_t *i = vam->input;
967 vl_api_sw_interface_clear_stats_t *mp;
969 u8 sw_if_index_set = 0;
972 /* Parse args required to build the message */
973 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
975 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
977 else if (unformat (i, "sw_if_index %d", &sw_if_index))
983 /* Construct the API message */
984 M (SW_INTERFACE_CLEAR_STATS, mp);
986 if (sw_if_index_set == 1)
987 mp->sw_if_index = ntohl (sw_if_index);
989 mp->sw_if_index = ~0;
994 /* Wait for a reply, return the good/bad news... */
1000 api_sw_interface_set_table (vat_main_t *vam)
1002 unformat_input_t *i = vam->input;
1003 vl_api_sw_interface_set_table_t *mp;
1004 u32 sw_if_index, vrf_id = 0;
1005 u8 sw_if_index_set = 0;
1009 /* Parse args required to build the message */
1010 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
1012 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
1013 sw_if_index_set = 1;
1014 else if (unformat (i, "sw_if_index %d", &sw_if_index))
1015 sw_if_index_set = 1;
1016 else if (unformat (i, "vrf %d", &vrf_id))
1018 else if (unformat (i, "ipv6"))
1024 if (sw_if_index_set == 0)
1026 errmsg ("missing interface name or sw_if_index");
1030 /* Construct the API message */
1031 M (SW_INTERFACE_SET_TABLE, mp);
1033 mp->sw_if_index = ntohl (sw_if_index);
1034 mp->is_ipv6 = is_ipv6;
1035 mp->vrf_id = ntohl (vrf_id);
1040 /* Wait for a reply... */
1046 api_sw_interface_address_replace_end (vat_main_t *vam)
1052 api_sw_interface_set_ip_directed_broadcast (vat_main_t *vam)
1058 api_sw_interface_set_mtu (vat_main_t *vam)
1064 api_sw_interface_set_promisc (vat_main_t *vam)
1070 api_want_interface_events (vat_main_t *vam)
1072 unformat_input_t *i = vam->input;
1073 vl_api_want_interface_events_t *mp;
1077 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
1079 if (unformat (i, "enable"))
1081 else if (unformat (i, "disable"))
1089 errmsg ("missing enable|disable");
1093 M (WANT_INTERFACE_EVENTS, mp);
1094 mp->enable_disable = enable;
1096 vam->interface_event_display = enable;
1110 api_sw_interface_dump (vat_main_t *vam)
1112 vl_api_sw_interface_dump_t *mp;
1113 vl_api_control_ping_t *mp_ping;
1115 name_sort_t *nses = 0, *ns;
1116 sw_interface_subif_t *sub = NULL;
1119 /* Toss the old name table */
1120 hash_foreach_pair (p, vam->sw_if_index_by_interface_name, ({
1121 vec_add2 (nses, ns, 1);
1122 ns->name = (u8 *) (p->key);
1123 ns->value = (u32) p->value[0];
1126 hash_free (vam->sw_if_index_by_interface_name);
1128 vec_foreach (ns, nses)
1129 vec_free (ns->name);
1133 vec_foreach (sub, vam->sw_if_subif_table)
1135 vec_free (sub->interface_name);
1137 vec_free (vam->sw_if_subif_table);
1139 /* recreate the interface name hash table */
1140 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
1143 * Ask for all interface names. Otherwise, the epic catalog of
1144 * name filters becomes ridiculously long, and vat ends up needing
1145 * to be taught about new interface types.
1147 M (SW_INTERFACE_DUMP, mp);
1150 /* Use a control ping for synchronization */
1151 PING (&interface_test_main, mp_ping);
1159 api_sw_interface_set_interface_name (vat_main_t *vam)
1164 #include <vnet/interface.api_test.c>
1168 * eval: (c-set-style "gnu")