nat: use correct data types for memory sizes
[vpp.git] / src / plugins / cdp / cdp_test.c
1 /*
2  * cdp.c - vpp-api-test cdp protocol plug-in
3  *
4  * Copyright (c) 2011-2018 by 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
22 uword unformat_sw_if_index (unformat_input_t * input, va_list * args);
23
24 /* Declare message IDs */
25 #include <cdp/cdp.api_enum.h>
26 #include <cdp/cdp.api_types.h>
27
28 typedef struct
29 {
30   /* API message ID base */
31   u16 msg_id_base;
32   vat_main_t *vat_main;
33 } cdp_test_main_t;
34
35 cdp_test_main_t cdp_test_main;
36
37 #define __plugin_msg_base cdp_test_main.msg_id_base
38 #include <vlibapi/vat_helper_macros.h>
39
40 /*
41  * Table of message reply handlers, must include boilerplate handlers
42  * we just generated
43  */
44 #define foreach_vpe_api_reply_msg                                       \
45 _(CDP_ENABLE_DISABLE_REPLY, cdp_enable_disable_reply)
46
47 static int
48 api_cdp_enable_disable (vat_main_t * vam)
49 {
50   unformat_input_t *i = vam->input;
51   int enable_disable = 1;
52   vl_api_cdp_enable_disable_t *mp;
53   int ret;
54
55   /* Parse args required to build the message */
56   while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
57     {
58       if (unformat (i, "disable"))
59         enable_disable = 0;
60       else if (unformat (i, "enable"))
61         enable_disable = 1;
62       else
63         break;
64     }
65
66   /* Construct the API message */
67   M (CDP_ENABLE_DISABLE, mp);
68   mp->enable_disable = enable_disable;
69
70   /* send it... */
71   S (mp);
72
73   /* Wait for a reply... */
74   W (ret);
75   return ret;
76 }
77
78 #include <cdp/cdp.api_test.c>
79
80 /*
81  * fd.io coding-style-patch-verification: ON
82  *
83  * Local Variables:
84  * eval: (c-set-style "gnu")
85  * End:
86  */