Installing the link layer topology discovery (LLTD) protocol responder on Debian Linux

doug
Wed, 24 Dec 2008 23:42:34 +0000

This post on how to install the LLTD is largely ripped off from http://www.howtoforge.com/installing-the-lltd-protocol-responder-for-linux-on-debian-lenny and made a bit more direct for those that just want to make it work and not pay attention to what you're doing! Like me!

So let's dive right in.

mkdir lltd
cd lltd
wget http://download.microsoft.com/download/b/8/e/b8eee444-f8d5-4b8b-aa3d-2f19bf19ac72/Rally-LLTD-PortingKit.exe
unzip Rally-LLTD-PortingKit.exe
sudo apt-get install linux-headers-`uname -r` build-essential

On some debian systems you may need to specifically find the correct headers for you. For instance on one of my machines I was running Debian kernel 2.6.18-6-k7 and uname -r returned this string. However in my repositories the linux-headers package I required was named linux-headers-2.6-k7. Note the lack of the minor version number.

cd "Sample Code/native-linux/"
sudo -s
echo "#include <linux/if.h>" >> /usr/include/linux/wireless.h
echo "#include <limits.h>" >> ../src/globals.h # Make sure INT_MAX is available
make
cp lld2d /usr/sbin/
cd /etc/init.d/
wget -O lld2d http://neverfear.org/files/download/81 # The lld2d init script

The init script assumes you use eth0 as your network interface, use INTFACE variable to change that assumption.

The code for the lld2d init script is given at the end of this article.

chmod 755 lld2d
/etc/init.d/lld2d start
exit

You may now delete the original lltd directory and all it's contents. The LLTD responder should now be active!

Init Script

#! /bin/sh
### BEGIN INIT INFO
# Provides:          lld2d
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
### END INIT INFO
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/lld2d
NAME=lld2d
PIDFILE=/var/run/$NAME.pid
DESC="LLTD Protocol Responder"
INTFACE=eth0 # YOU MAY NEED TO CHANGE ME
test -f $DAEMON || exit 0
set -e
is_running ()
{
    if [ -e "$PIDFILE" ]; then
        #checking if program is running
        if [ -L /proc/`cat $PIDFILE`/exe ]; then
            #checking for stale pidfile
            if grep -q $NAME /proc/`cat $PIDFILE`/cmdline; then
                #program is running and is called lisa
                return 0
            fi
        fi
        rm -f $PIDFILE
    fi
    #program is not running
    return 1
}
case "$1" in
start)
    if is_running; then
        echo "$DESC is already running. Not doing anything"
        exit 0
    fi
    echo -n "Starting $DESC: "
    start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON $INTFACE > /dev/null
    echo $(pidof lld2d) > $PIDFILE
    echo "$NAME."
;;
stop)
    if ! is_running; then
        echo "$DESC is not running. Not doing anything"
        exit 0
    fi
    echo -n "Stopping $DESC: "
    start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON
    rm -f $PIDFILE
    echo "$NAME."
;;
reload|force-reload)
    echo "Reloading $DESC configuration files."
    start-stop-daemon --stop --quiet --signal 1 --pidfile $PIDFILE --exec $DAEMON $INTFACE
;;
status)
    echo -n "$DESC is "
    if ! is_running; then
        echo -n "not "
    fi
    echo "running."
;;
restart)
    echo -n "Restarting $DESC: "
    start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON $INTFACE
    rm -f $PIDFILE
    sleep 1
    start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON $INTFACE > /dev/null
    echo $(pidof lld2d) > $PIDFILE
    echo "$NAME."
;;
cond-restart)
    if ! is_running; then
        echo "$DESC is not running. Not doing anything"
        exit 0
    fi
    echo -n "Restarting $DESC: "
    start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON $INTFACE
    rm -f $PIDFILE
    sleep 1
    start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON $INTFACE > /dev/null
    echo $(pidof lld2d) > $PIDFILE
    echo "$NAME."
;;
*)
    N=/etc/init.d/$NAME
    echo "Usage: $N {start|stop|restart|cond-restart|status|reload|force-reload}" >&2
    exit 1
;;
esac
exit 0