Using libnetdude

`libnetdude` Manual
Prev |  | Next

# Using `libnetdude`

This chapter explains how to build `libnetdude`, what parts of `libnetdude` end up where on your system when you install it, and how to build other programs that use `libnetdude`.

# Building `libnetdude`

Building `libnetdude` will hopefully be easy. `libnetdude` has two dependencies, make sure these are installed before you try to build your copy:

- glib, version 1.2.10 or higher. Download it from gtk.org or just grab an RPM/DEB for it. Do not forget the development packages if your distibution uses those, since you will need the header files during the build process.

- libpcapnav, downloadable from netdude.sf.net.

The build itself is made using the common ./configure && make && make install sequence. Check ./configure --help for a list of available options, particularly the --with-pcapnav... options to specify a `libpcapnav` that's installed in an unusual location.

# Installation Layout

The installation places files in the following locations (the full path depends on what --prefix option you passed to configure. The default value is `/usr/local`):

- `$prefix/lib/`: the core library, in static and dynamic linking versions (unless disabled at configuration time).

- `$prefix/include/libnetdude/VERSION`: header files of the core library.

- `$prefix/include/libnetdude/VERSION/protocols`: protocol plugins that are part of the core distribution. core library.

- `$prefix/include/libnetdude/VERSION/protocols`: header files of protocol plugins that are part of the core distribution.

- `$prefix/include/libnetdude/VERSION/plugins`: header files of feature plugins that are part of the core distribution.

- `$prefix/share/libnetdude/VERSION/protocols`: DLLs of protocol plugins that are part of the core distribution.

- `$prefix/share/libnetdude/VERSION/plugins`: DLLs of feature plugins that are part of the core distribution.

- `$prefix/bin`: the libnetdude-config script.

# Building Applications with `libnetdude`

If you are using the autoconf/automake tools to configure your package, consider using the following check to detect `libnetdude`:

    dnl ##################################################
    dnl # Check for libnetdude
    dnl ##################################################
    AC_ARG_WITH(libnetdude,
        AC_HELP_STRING([--with-libnetdude-config=DIR], [Use given libnetdude-config]),
        [ LIBNETDUDE_LIBS=`$withval --libs`
          LIBNETDUDE_CFLAGS=`$withval --cflags`
          libndcfg="$withval"
        ],
        [ AC_PATH_GENERIC(libnetdude,,
              libndcfg="libnetdude-config",
              AC_MSG_ERROR(Cannot find libnetdude: Is libnetdude-config in path?)) ])

    AC_SUBST(LIBNETDUDE_LIBS)
    AC_SUBST(LIBNETDUDE_CFLAGS)

You can then use the compiler/linker flags that the library requires in your `Makefile.am` using `@LIBNETDUDE_CFLAGS@` and `@LIBNETDUDE_LIBS@`.

| Using the output of `libnetdude-config` provides all the compiler/linker flags you need to pull in the dependencies (`libpcapnav` and glib). You do not need to add extra checks and flags for those in your build scripts. Have a look at libnetdude-config --help for the various options.

# `libnetdude`'s Testsuite

Should you decide to delve into hacking `libnetdude` itself (yay!), you'll want to have a look at the contents of the `test` directory in the source tree. It contains a few programs that can be built using make tests and that are not installed. These programs are:

- `lnd-test`: a test driver that consists of a set of functions that exercise several aspects of the library, primarily trace part management and trace navigation. More tests are highly welcomed contributions, and may make the authors more apt to supporting extensions of the library using the bribery method explained in the chapter on `libnetdude` Plugins.

- `lnd-test-filter`: a small demo/test program that shows how to use the `libnetdude` filter API.

- `lnd-test-plugins`: a helper app that prints the names, versions, and authors of the installed feature and protocol plugins to the console.

- `lnd-dump`: a helper app gives you the equivalent of running tcpdump on a trace file, printing out the familiar ouput for each packet. Additionally, you get the offset of the packets (absolutely and relatively to the end of the pcap savefile header) prepended to the line. Have a look at `lnd-dump.c` and see how easy the code is.

Prev | Home | Next
`libnetdude` Concepts |  | `libnetdude` Plugins