aboutsummaryrefslogtreecommitdiffstats
path: root/build-root/emacs-lisp
diff options
context:
space:
mode:
Diffstat (limited to 'build-root/emacs-lisp')
-rw-r--r--build-root/emacs-lisp/plugin-main-skel.el78
-rw-r--r--build-root/emacs-lisp/plugin-node-skel.el24
-rw-r--r--build-root/emacs-lisp/plugin-test-skel.el122
3 files changed, 106 insertions, 118 deletions
diff --git a/build-root/emacs-lisp/plugin-main-skel.el b/build-root/emacs-lisp/plugin-main-skel.el
index 90b98949e83..46615c311c7 100644
--- a/build-root/emacs-lisp/plugin-main-skel.el
+++ b/build-root/emacs-lisp/plugin-main-skel.el
@@ -21,8 +21,8 @@ nil
'(if (not (boundp 'plugin-name))
(setq plugin-name (read-string "Plugin name: ")))
'(setq PLUGIN-NAME (upcase plugin-name))
-"
-/*
+'(setq capital-oh-en "ON")
+"/*
* " plugin-name ".c - skeleton vpp engine plug-in
*
* Copyright (c) <current-year> <your-organization>
@@ -46,6 +46,7 @@ nil
#include <vlibapi/api.h>
#include <vlibmemory/api.h>
#include <vlibsocket/api.h>
+#include <vpp/app/version.h>
/* define message IDs */
#include <" plugin-name "/" plugin-name "_msg_enum.h>
@@ -100,27 +101,6 @@ do { \\
#define foreach_" plugin-name "_plugin_api_msg \\
_(" PLUGIN-NAME "_ENABLE_DISABLE, " plugin-name "_enable_disable)
-/*
- * This routine exists to convince the vlib plugin framework that
- * we haven't accidentally copied a random .dll into the plugin directory.
- *
- * Also collects global variable pointers passed from the vpp engine
- */
-
-clib_error_t *
-vlib_plugin_register (vlib_main_t * vm, vnet_plugin_handoff_t * h,
- int from_early_init)
-{
- " plugin-name "_main_t * sm = &" plugin-name "_main;
- clib_error_t * error = 0;
-
- sm->vlib_main = vm;
- sm->vnet_main = h->vnet_main;
- sm->ethernet_main = h->ethernet_main;
-
- return error;
-}
-
/* Action function shared between message handler and debug CLI */
int " plugin-name "_enable_disable (" plugin-name "_main_t * sm, u32 sw_if_index,
@@ -156,14 +136,15 @@ static clib_error_t *
int rv;
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) {
- if (unformat (input, \"disable\"))
- enable_disable = 0;
- else if (unformat (input, \"%U\", unformat_vnet_sw_interface,
- sm->vnet_main, &sw_if_index))
- ;
- else
- break;
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (input, \"disable\"))
+ enable_disable = 0;
+ else if (unformat (input, \"%U\", unformat_vnet_sw_interface,
+ sm->vnet_main, &sw_if_index))
+ ;
+ else
+ break;
}
if (sw_if_index == ~0)
@@ -171,7 +152,8 @@ static clib_error_t *
rv = " plugin-name "_enable_disable (sm, sw_if_index, enable_disable);
- switch(rv) {
+ switch(rv)
+ {
case 0:
break;
@@ -187,16 +169,19 @@ static clib_error_t *
default:
return clib_error_return (0, \"" plugin-name "_enable_disable returned %d\",
rv);
- }
+ }
return 0;
}
-VLIB_CLI_COMMAND (" plugin-name "_enable_disable_command, static) = {
- .path = \"" plugin-name " enable-disable\",
- .short_help =
- \"" plugin-name " enable-disable <interface-name> [disable]\",
- .function = " plugin-name "_enable_disable_command_fn,
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (" plugin-name "_enable_disable_command, static) =
+{
+ .path = \"" plugin-name " enable-disable\",
+ .short_help =
+ \"" plugin-name " enable-disable <interface-name> [disable]\",
+ .function = " plugin-name "_enable_disable_command_fn,
};
+/* *INDENT-ON* */
/* API message handler */
static void vl_api_" plugin-name "_enable_disable_t_handler
@@ -268,11 +253,28 @@ static clib_error_t * " plugin-name "_init (vlib_main_t * vm)
VLIB_INIT_FUNCTION (" plugin-name "_init);
+/* *INDENT-OFF* */
VNET_FEATURE_INIT (" plugin-name ", static) =
{
.arc_name = \"device-input\",
.node_name = \"" plugin-name "\",
.runs_before = VNET_FEATURES (\"ethernet-input\"),
};
+/* *INDENT-ON */
+
+/* *INDENT-OFF* */
+VLIB_PLUGIN_REGISTER () =
+{
+ .version = VPP_BUILD_VER,
+};
+/* *INDENT-ON* */
+
+/*
+ * fd.io coding-style-patch-verification: " capital-oh-en "
+ *
+ * Local Variables:
+ * eval: (c-set-style \"gnu\")
+ * End:
+ */
")
diff --git a/build-root/emacs-lisp/plugin-node-skel.el b/build-root/emacs-lisp/plugin-node-skel.el
index ee745c35326..167519aa266 100644
--- a/build-root/emacs-lisp/plugin-node-skel.el
+++ b/build-root/emacs-lisp/plugin-node-skel.el
@@ -21,8 +21,8 @@ nil
'(if (not (boundp 'plugin-name))
(setq plugin-name (read-string "Plugin name: ")))
'(setq PLUGIN-NAME (upcase plugin-name))
-"
-/*
+'(setq capital-oh-en "ON")
+"/*
* node.c - skeleton vpp engine plug-in dual-loop node skeleton
*
* Copyright (c) <current-year> <your-organization>
@@ -44,7 +44,8 @@ nil
#include <vppinfra/error.h>
#include <" plugin-name "/" plugin-name ".h>
-typedef struct {
+typedef struct
+{
u32 next_index;
u32 sw_if_index;
u8 new_src_mac[6];
@@ -92,7 +93,8 @@ static char * " plugin-name "_error_strings[] = {
#undef _
};
-typedef enum {
+typedef enum
+{
" PLUGIN-NAME "_NEXT_INTERFACE_OUTPUT,
" PLUGIN-NAME "_N_NEXT,
} " plugin-name "_next_t;
@@ -187,8 +189,6 @@ static uword
foreach_mac_address_offset;
#undef _
-
-
sw_if_index0 = vnet_buffer(b0)->sw_if_index[VLIB_RX];
sw_if_index1 = vnet_buffer(b1)->sw_if_index[VLIB_RX];
@@ -300,7 +300,9 @@ static uword
return frame->n_vectors;
}
-VLIB_REGISTER_NODE (" plugin-name "_node) = {
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE (" plugin-name "_node) =
+{
.function = " plugin-name "_node_fn,
.name = \"" plugin-name "\",
.vector_size = sizeof (u32),
@@ -317,4 +319,12 @@ VLIB_REGISTER_NODE (" plugin-name "_node) = {
[" PLUGIN-NAME "_NEXT_INTERFACE_OUTPUT] = \"interface-output\",
},
};
+/* *INDENT-ON* */
+/*
+ * fd.io coding-style-patch-verification: " capital-oh-en "
+ *
+ * Local Variables:
+ * eval: (c-set-style \"gnu\")
+ * End:
+ */
")
diff --git a/build-root/emacs-lisp/plugin-test-skel.el b/build-root/emacs-lisp/plugin-test-skel.el
index b546747f522..2f8121a8226 100644
--- a/build-root/emacs-lisp/plugin-test-skel.el
+++ b/build-root/emacs-lisp/plugin-test-skel.el
@@ -21,8 +21,8 @@ nil
'(if (not (boundp 'plugin-name))
(setq plugin-name (read-string "Plugin name: ")))
'(setq PLUGIN-NAME (upcase plugin-name))
-"
-/*
+'(setq capital-oh-en "ON")
+"/*
* " plugin-name ".c - skeleton vpp-api-test plug-in
*
* Copyright (c) <current-year> <your-organization>
@@ -72,14 +72,18 @@ uword unformat_sw_if_index (unformat_input_t * input, va_list * args);
#undef vl_api_version
-typedef struct {
- /* API message ID base */
- u16 msg_id_base;
- vat_main_t *vat_main;
+typedef struct
+{
+ /* API message ID base */
+ u16 msg_id_base;
+ vat_main_t *vat_main;
} " plugin-name "_test_main_t;
" plugin-name "_test_main_t " plugin-name "_test_main;
+#define __plugin_msg_base " plugin-name"_test_main.msg_id_base
+#include <vlibapi/vat_helper_macros.h>
+
#define foreach_standard_reply_retval_handler \\
_(" plugin-name "_enable_disable_reply)
@@ -107,79 +111,44 @@ foreach_standard_reply_retval_handler;
_(" PLUGIN-NAME "_ENABLE_DISABLE_REPLY, " plugin-name "_enable_disable_reply)
-/* M: construct, but don't yet send a message */
-
-#define M(T, mp) \\
-do { \\
- vam->result_ready = 0; \\
- mp = vl_msg_api_alloc(sizeof(*mp)); \\
- memset (mp, 0, sizeof (*mp)); \\
- mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \\
- mp->client_index = vam->my_client_index; \\
-} while(0);
-
-#define M2(T, mp, n) \\
-do { \\
- vam->result_ready = 0; \\
- mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \\
- memset (mp, 0, sizeof (*mp)); \\
- mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \\
- mp->client_index = vam->my_client_index; \\
-} while(0);
-
-/* S: send a message */
-#define S(mp) (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp))
-
-/* W: wait for results, with timeout */
-#define W \\
-do { \\
- f64 timeout = vat_time_now (vam) + 1.0; \\
- \\
- while (vat_time_now (vam) < timeout) { \\
- if (vam->result_ready == 1) { \\
- return (vam->retval); \\
- } \\
- } \\
- return -99; \\
-} while(0);
-
static int api_" plugin-name "_enable_disable (vat_main_t * vam)
{
- " plugin-name "_test_main_t * sm = &" plugin-name "_test_main;
- unformat_input_t * i = vam->input;
- int enable_disable = 1;
- u32 sw_if_index = ~0;
- vl_api_" plugin-name "_enable_disable_t * mp;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) {
- if (unformat (i, \"%U\", unformat_sw_if_index, vam, &sw_if_index))
- ;
- else if (unformat (i, \"sw_if_index %d\", &sw_if_index))
- ;
- else if (unformat (i, \"disable\"))
- enable_disable = 0;
- else
- break;
+ unformat_input_t * i = vam->input;
+ int enable_disable = 1;
+ u32 sw_if_index = ~0;
+ vl_api_" plugin-name "_enable_disable_t * mp;
+ int ret;
+
+ /* Parse args required to build the message */
+ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (i, \"%U\", unformat_sw_if_index, vam, &sw_if_index))
+ ;
+ else if (unformat (i, \"sw_if_index %d\", &sw_if_index))
+ ;
+ else if (unformat (i, \"disable\"))
+ enable_disable = 0;
+ else
+ break;
}
-
- if (sw_if_index == ~0) {
- errmsg (\"missing interface name / explicit sw_if_index number \\n\");
- return -99;
+
+ if (sw_if_index == ~0)
+ {
+ errmsg (\"missing interface name / explicit sw_if_index number \\n\");
+ return -99;
}
-
- /* Construct the API message */
- M(" PLUGIN-NAME "_ENABLE_DISABLE, mp);
- mp->sw_if_index = ntohl (sw_if_index);
- mp->enable_disable = enable_disable;
+
+ /* Construct the API message */
+ M(" PLUGIN-NAME "_ENABLE_DISABLE, mp);
+ mp->sw_if_index = ntohl (sw_if_index);
+ mp->enable_disable = enable_disable;
- /* send it... */
- S(mp);
+ /* send it... */
+ S(mp);
- /* Wait for a reply... */
- W (ret);
- return ret;
+ /* Wait for a reply... */
+ W (ret);
+ return ret;
}
/*
@@ -233,4 +202,11 @@ clib_error_t * vat_plugin_register (vat_main_t *vam)
return 0;
}
+/*
+ * fd.io coding-style-patch-verification: " capital-oh-en "
+ *
+ * Local Variables:
+ * eval: (c-set-style \"gnu\")
+ * End:
+ */
")