1 # Sample plugin for VPP {#sample_plugin_doc}
5 This is the VPP sample plugin demonstrates how to create a new plugin that integrates
6 with VPP. The sample code implements a trival macswap algorithim that demonstrates plugin
7 runtime integration with the VPP graph hierachy, api and cli.
9 For deeper dive information see the annotations in the sample code itself. See [sample.c](@ref sample.c)
11 ## How to build and run the sample plugin.
17 Define environmental variable 'VPP_WITH_SAMPLE_PLUGIN=yes' with a process scope
19 $ VPP_WITH_SAMPLE_PLUGIN=yes make build
21 or a session scope, and build VPP.
23 $ export VPP_WITH_SAMPLE_PLUGIN=yes
26 Now run VPP and make sure the plugin is loaded.
30 load_one_plugin:184: Loaded plugin: memif_plugin.so (Packet Memory Interface (experimetal))
31 load_one_plugin:184: Loaded plugin: sample_plugin.so (Sample of VPP Plugin)
32 load_one_plugin:184: Loaded plugin: nat_plugin.so (Network Address Translation)
36 ## How to create a new plugin
38 To create a new plugin based on the sample plugin, copy and rename the sample plugin directory and automake config.
40 cp -r src/examples/sample-plugin/sample src/plugins/newplugin
41 cp src/examples/sample-plugin/sample.am src/plugins/newplugin.am
43 Add the following entry to the plugins section of `src/configure.ac`.
45 PLUGIN_ENABLED(newplugin)
47 Add the following entry to the plugins section of `src/plugins/Makefile.am`
60 To enable the sample plugin
62 sample macswap <interface name>
64 To disable the sample plugin
66 sample macswap <interface name> disable