2 * Copyright (c) 2015 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 *------------------------------------------------------------------
17 * sample_test.c - test harness plugin
18 *------------------------------------------------------------------
22 #include <vlibapi/api.h>
23 #include <vlibmemory/api.h>
24 #include <vppinfra/error.h>
26 #define __plugin_msg_base sample_test_main.msg_id_base
27 #include <vlibapi/vat_helper_macros.h>
29 uword unformat_sw_if_index (unformat_input_t * input, va_list * args);
31 /* Declare message IDs */
32 #include <sample/sample.api_enum.h>
33 #include <sample/sample.api_types.h>
36 /* API message ID base */
41 sample_test_main_t sample_test_main;
43 static int api_sample_macswap_enable_disable (vat_main_t * vam)
45 unformat_input_t * i = vam->input;
46 int enable_disable = 1;
48 vl_api_sample_macswap_enable_disable_t * mp;
51 /* Parse args required to build the message */
52 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) {
64 errmsg ("missing interface name / explicit sw_if_index number \n");
68 /* Construct the API message */
69 M(SAMPLE_MACSWAP_ENABLE_DISABLE, mp);
70 mp->sw_if_index = ntohl (sw_if_index);
71 mp->enable_disable = enable_disable;
76 /* Wait for a reply... */
82 * List of messages that the api test plugin sends,
83 * and that the data plane plugin processes
85 #include <sample/sample.api_test.c>