CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
Netdude is designed to provide a core set of functionality upon which protocol and feature support can be built in a modularized fashion. The mechanism used to achieve this is the dynamic linker library, libdl. Well actually it's the libtool wrapper, libltdl [Libtool], to keep life simple. Therefore, Netdude plugins come as platform-dependant normal binary code in shared libraries. They're not interpreted scripts.
When Netdude starts, it scans specific directories for plugins, dynamically opens them and looks for special symbols, actually hooks that provide callback implementations. The plugins are then initialized and hooked into the GUI as menu entries etc. The directories Netdude looks at can always be obtained by issuing the following commands, either at the command line or in your build scripts:
Usually the names will be /usr/share/netdude/plugins and /usr/share/netdude/protocols, or the /usr/local versions thereof. To allow users to install plugins privately, the directories ~/.nd/plugins and ~/.nd/protocols can also be used.
In order to compile new code using the Netdude API, you'll need to include Netdude's header files. You can obtain the directory in which Netdude's header files are installed using the command netdude --includedir. If you add that directory to the include path of your build environment (that's already done for you in the code templates), you can then access the header files as in the following example.
You can always check if a plugin was loaded correctly by looking at Netdude's About menu, which will list the loaded plugins and display info dialogs about them upon request:
Netdude's About menu.
Why would one want to write a Netdude feature plugin? Well, Netdude plugins basically only need to provide one big hook that serves as the entry point into the plugin. In that callback implementation, the plugin can do anything the author desires -- iterate over packets, manipulate packets, gather statistics, etc.
Writing a feature plugin for Netdude is easy, assuming you have reasonable knowledge of the Netdude API (see also the API documentation). If you don't have an existing codebase for Netdude plugins, I suggest you start by downloading the Netdude plugin code template, available from the Netdude download page.
Extract the tarball. If you want to keep multiple plugins in your package, add a directory for each one and update configure.ac/configure.in and the Makefile.ams accordingly. Details of handling the auto* tools are beyond the scope of this document, please consult the appropriate documentation [Autoconf] [Automake]. If you feel you're in trouble, please ask for help on the Netdude mailing lists. For the rest of this section we'll assume that you have a working build environment for your plugin(s).
The following piece of code, taken from nd_plugin.h, lists the callbacks you can provide in your plugin. You may leave out some if you wish, they all get initialized to no-ops by default.
You don't need to worry about filename and lt, they're used internally by Netdude. The other function pointers are pretty much self-explanatory:
Netdude comes with a simple demo plugin that corrects all checksums in the currently selected packets. See plugins/nd_cksumfix.c in the Netdude source tarball. Its code is short enough to be given here in all its glory: