2 * adl.c - adl vpp-api-test plug-in
4 * Copyright (c) 2020 Cisco Systems and/or affiliates.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #include <vlibapi/api.h>
19 #include <vlibmemory/api.h>
20 #include <vppinfra/error.h>
23 #define __plugin_msg_base adl_test_main.msg_id_base
24 #include <vlibapi/vat_helper_macros.h>
26 uword unformat_sw_if_index (unformat_input_t * input, va_list * args);
28 /* Declare message IDs */
29 #include <adl/adl.api_enum.h>
30 #include <adl/adl.api_types.h>
34 /* API message ID base */
39 adl_test_main_t adl_test_main;
42 api_adl_interface_enable_disable (vat_main_t * vam)
44 unformat_input_t *i = vam->input;
45 int enable_disable = 1;
47 vl_api_adl_interface_enable_disable_t *mp;
50 /* Parse args required to build the message */
51 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
53 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
55 else if (unformat (i, "sw_if_index %d", &sw_if_index))
57 else if (unformat (i, "disable"))
63 if (sw_if_index == ~0)
65 errmsg ("missing interface name / explicit sw_if_index number \n");
69 /* Construct the API message */
70 M (ADL_INTERFACE_ENABLE_DISABLE, mp);
71 mp->sw_if_index = ntohl (sw_if_index);
72 mp->enable_disable = enable_disable;
77 /* Wait for a reply... */
83 api_adl_allowlist_enable_disable (vat_main_t * vam)
85 unformat_input_t *i = vam->input;
87 vl_api_adl_allowlist_enable_disable_t *mp;
94 /* Parse args required to build the message */
95 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
97 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
99 else if (unformat (i, "sw_if_index %d", &sw_if_index))
101 else if (unformat (i, "fib-id %d", &fib_id))
103 else if (unformat (i, "ip4"))
105 else if (unformat (i, "ip6"))
107 else if (unformat (i, "default"))
113 if (sw_if_index == ~0)
115 errmsg ("missing interface name / explicit sw_if_index number \n");
121 errmsg ("FIB id must be specified...\n");
125 /* Construct the API message */
126 M (ADL_ALLOWLIST_ENABLE_DISABLE, mp);
127 mp->sw_if_index = ntohl (sw_if_index);
128 mp->fib_id = ntohl (fib_id);
131 mp->default_adl = default_adl;
136 /* Wait for a reply... */
142 * List of messages that the adl test plugin sends,
143 * and that the data plane plugin processes
145 #include <adl/adl.api_test.c>
148 * fd.io coding-style-patch-verification: ON
151 * eval: (c-set-style "gnu")