1 ;;; plugin-test-skel.el - vpp-api-test plug-in skeleton
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:
8 ;;; http://www.apache.org/licenses/LICENSE-2.0
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.
18 (define-skeleton skel-plugin-test
19 "Insert a plug-in vpp-api-test skeleton "
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"))
27 * " plugin-name ".c - " plugin-name " vpp-api-test plug-in
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:
34 * http://www.apache.org/licenses/LICENSE-2.0
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.
43 #include <vlibapi/api.h>
44 #include <vlibmemory/api.h>
45 #include <vppinfra/error.h>
48 #define __plugin_msg_base " plugin-name"_test_main.msg_id_base
49 #include <vlibapi/vat_helper_macros.h>
51 uword unformat_sw_if_index (unformat_input_t * input, va_list * args);
53 /* Declare message IDs */
54 #include <" plugin-name "/" plugin-name ".api_enum.h>
55 #include <" plugin-name "/" plugin-name ".api_types.h>
59 /* API message ID base */
62 } " plugin-name "_test_main_t;
64 " plugin-name "_test_main_t " plugin-name "_test_main;
66 static int api_" plugin-name "_enable_disable (vat_main_t * vam)
68 unformat_input_t * i = vam->input;
69 int enable_disable = 1;
71 vl_api_" plugin-name "_enable_disable_t * mp;
74 /* Parse args required to build the message */
75 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
77 if (unformat (i, \"%U\", unformat_sw_if_index, vam, &sw_if_index))
79 else if (unformat (i, \"sw_if_index %d\", &sw_if_index))
81 else if (unformat (i, \"disable\"))
87 if (sw_if_index == ~0)
89 errmsg (\"missing interface name / explicit sw_if_index number \\n\");
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;
101 /* Wait for a reply... */
107 * List of messages that the " plugin-name" test plugin sends,
108 * and that the data plane plugin processes
110 #include <" plugin-name "/" plugin-name ".api_test.c>
113 * fd.io coding-style-patch-verification: " capital-oh-en "
116 * eval: (c-set-style \"gnu\")