vxlan: vxlan/vxlan.api API cleanup
[vpp.git] / extras / emacs / plugin-test-skel.el
1 ;;; plugin-test-skel.el - vpp-api-test plug-in skeleton
2 ;;;
3 ;;; Copyright (c) 2016 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:
7 ;;;
8 ;;;     http://www.apache.org/licenses/LICENSE-2.0
9 ;;;
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
16 (require 'skeleton)
17
18 (define-skeleton skel-plugin-test
19 "Insert a plug-in vpp-api-test skeleton "
20 nil
21 '(if (not (boundp 'plugin-name))
22      (setq plugin-name (read-string "Plugin name: ")))
23 '(setq PLUGIN-NAME (upcase plugin-name))
24 '(setq capital-oh-en "ON")
25 '(setq main-p (concat (substring plugin-name 0 1) "tmp"))
26 "/*
27  * " plugin-name ".c - " plugin-name " vpp-api-test plug-in
28  *
29  * Copyright (c) <current-year> <your-organization>
30  * Licensed under the Apache License, Version 2.0 (the \"License\");
31  * you may not use this file except in compliance with the License.
32  * You may obtain a copy of the License at:
33  *
34  *     http://www.apache.org/licenses/LICENSE-2.0
35  *
36  * Unless required by applicable law or agreed to in writing, software
37  * distributed under the License is distributed on an \"AS IS\" BASIS,
38  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
39  * See the License for the specific language governing permissions and
40  * limitations under the License.
41  */
42 #include <vat/vat.h>
43 #include <vlibapi/api.h>
44 #include <vlibmemory/api.h>
45 #include <vppinfra/error.h>
46 #include <stdbool.h>
47
48 #define __plugin_msg_base " plugin-name"_test_main.msg_id_base
49 #include <vlibapi/vat_helper_macros.h>
50
51 uword unformat_sw_if_index (unformat_input_t * input, va_list * args);
52
53 /* Declare message IDs */
54 #include <" plugin-name "/" plugin-name ".api_enum.h>
55 #include <" plugin-name "/" plugin-name ".api_types.h>
56
57 typedef struct
58 {
59   /* API message ID base */
60   u16 msg_id_base;
61   vat_main_t *vat_main;
62 } " plugin-name "_test_main_t;
63
64 " plugin-name "_test_main_t " plugin-name "_test_main;
65
66 static int api_" plugin-name "_enable_disable (vat_main_t * vam)
67 {
68   unformat_input_t * i = vam->input;
69   int enable_disable = 1;
70   u32 sw_if_index = ~0;
71   vl_api_" plugin-name "_enable_disable_t * mp;
72   int ret;
73
74   /* Parse args required to build the message */
75   while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
76     {
77       if (unformat (i, \"%U\", unformat_sw_if_index, vam, &sw_if_index))
78           ;
79         else if (unformat (i, \"sw_if_index %d\", &sw_if_index))
80           ;
81       else if (unformat (i, \"disable\"))
82           enable_disable = 0;
83       else
84           break;
85     }
86
87   if (sw_if_index == ~0)
88     {
89       errmsg (\"missing interface name / explicit sw_if_index number \\n\");
90       return -99;
91     }
92
93   /* Construct the API message */
94   M(" PLUGIN-NAME "_ENABLE_DISABLE, mp);
95   mp->sw_if_index = ntohl (sw_if_index);
96   mp->enable_disable = enable_disable;
97
98   /* send it... */
99   S(mp);
100
101   /* Wait for a reply... */
102   W (ret);
103   return ret;
104 }
105
106 /*
107  * List of messages that the " plugin-name" test plugin sends,
108  * and that the data plane plugin processes
109  */
110 #include <" plugin-name "/" plugin-name ".api_test.c>
111
112 /*
113  * fd.io coding-style-patch-verification: " capital-oh-en "
114  *
115  * Local Variables:
116  * eval: (c-set-style \"gnu\")
117  * End:
118  */
119 ")