mdata: buffer metadata change tracker plugin
[vpp.git] / src / plugins / mdata / mdata_test.c
1 /*
2  * mdata.c - buffer metadata change tracker vpp-api-test plug-in
3  *
4  * Copyright (c) 2019 Cisco and/or its 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:
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  */
17 #include <vat/vat.h>
18 #include <vlibapi/api.h>
19 #include <vlibmemory/api.h>
20 #include <vppinfra/error.h>
21 #include <stdbool.h>
22
23 #define __plugin_msg_base mdata_test_main.msg_id_base
24 #include <vlibapi/vat_helper_macros.h>
25
26 /* Declare message IDs */
27 #include <mdata/mdata.api_enum.h>
28 #include <mdata/mdata.api_types.h>
29
30 typedef struct
31 {
32   /* API message ID base */
33   u16 msg_id_base;
34   vat_main_t *vat_main;
35 } mdata_test_main_t;
36
37 mdata_test_main_t mdata_test_main;
38
39 static int
40 api_mdata_enable_disable (vat_main_t * vam)
41 {
42   unformat_input_t *i = vam->input;
43   int enable_disable = 1;
44   vl_api_mdata_enable_disable_t *mp;
45   int ret;
46
47   /* Parse args required to build the message */
48   while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
49     {
50       if (unformat (i, "disable"))
51         enable_disable = 0;
52       else
53         break;
54     }
55
56   /* Construct the API message */
57   M (MDATA_ENABLE_DISABLE, mp);
58   mp->enable_disable = enable_disable;
59
60   /* send it... */
61   S (mp);
62
63   /* Wait for a reply... */
64   W (ret);
65   return ret;
66 }
67
68 /*
69  * List of messages that the mdata test plugin sends,
70  * and that the data plane plugin processes
71  */
72 #include <mdata/mdata.api_test.c>
73
74 /*
75  * fd.io coding-style-patch-verification: ON
76  *
77  * Local Variables:
78  * eval: (c-set-style "gnu")
79  * End:
80  */