alfred: Allow to specify batman-adv interface

Alfred uses the batman-adv interface to translate mac addresses and to query
the tq values for server selection. Therefore it has to know which batman-adv
interface it has to use when multiple interfaces exist. This is also necessary
when it wasn't started directly on that interface and instead on a virtual
interface which uses the batman-adv device as its slave.

Alfred assumes by default that the interface is called bat0. This name can be
changed using the parameter -b followed by the name of the interface. It is
also possible to disable the batman-adv support completely by using the special
interface name "none". This special mode is only for debugging and should not
be used in production setups.

Signed-off-by: Sven Eckelmann <sven@open-mesh.com>
alfred: Fix warnings about mixing (un-)signed types in comparisons

Signed-off-by: Sven Eckelmann <sven@open-mesh.com>
alfred: Break out of set_data loop when buffer is full

The current limit for data the client program can supply is 9000 bytes. But
client programs providing more than 9000 bytes before they close their socket
would create an endless loop and therefore block the complete daemon program.

Signed-off-by: Sven Eckelmann <sven@open-mesh.com>
alfred: Return error code when alfred could not be started

Signed-off-by: Sven Eckelmann <sven@open-mesh.com>
alfred: Avoid buffer overruns with large MTUs

Different functions like the sending function assume an MTU smaller than the
default buffer size of 9000. This must not be true and therefore it can happend
that the buffer on the stack is overwritten.

The mtu is reduce instead to avoid this problem until all functions using such
a buffer are sanatized.

Signed-off-by: Sven Eckelmann <sven@open-mesh.com>
alfred: Mark local functions as static

Signed-off-by: Sven Eckelmann <sven@open-mesh.com>
alfred: Change transport protocol to link-local UDP/IPv6

The main purpose of alfred is to transfer additional data between different
batman-adv nodes. Therefore using a transport layer instead of the data layer
seems to be the right choice. This allows to use the functionality like
fragmentation or checksumming without implementing it again.

It makes it also possible to reduce the privileges to non-root users
capabilities to mitigate attacks against this daemon.

Signed-off-by: Sven Eckelmann <sven@open-mesh.com>
alfred: Use isprint to check for printable characters

Signed-off-by: Sven Eckelmann <sven@open-mesh.com>
alfred: Move send_alfred_packet to send.c

send_alfred_packet is a send-only function. The better home for this function
would be send.c instead of recv.c because recv.c has more a focus on processing
incoming packets.

Signed-off-by: Sven Eckelmann <sven@open-mesh.com>
alfred: Place all network struct definitions in packet.h

Signed-off-by: Sven Eckelmann <sven@open-mesh.com>