The check of prerequisitions is rather long and becomes unreadable. Having
it in an extra function makes the code slightly more structured and better
readable.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
The 6th argument to recvfrom is not an unsigned int pointer. This may work
on systems where socklen_t and unsigned int are both 4 byte but other
systems may use 8 byte for that (glibc uses size_t as type for socklen_t
and size_t is 8 byte on amd64 and similar architectures).
Signed-off-by: Sven Eckelmann <sven@narfation.org>
The recvfrom can fail and return -1. The caller must check for this error
to avoid that it reads uninitialized data from pkt.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
The ICMPv6 packet is stored in network byte order. It must therefore always
be converted to host byteorder before it can be used in calculations.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
The router access code is spread throughout the program. It is easier to
modify it when the common functionality is encapsulated in some helper
functions.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
The bind to an interface can fail and the socket then isn't working as
expected. The daemon must therefore handle this problem.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
These variables are only used in the the same file. They can therefore be
static and don't have to be exported by the executable.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
The macro foreach is dereferencing router to get the next node in list.
This even happens when the node was just freed in the last iteration (and
thus could crash the program).
To avoid this crash, the next pointer has to be saved before the node is
freed.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Both source files require the _GNU_SOURCE preprocessor. But for one file it is
defined in the source and for the other one in the Makefile. It is better
to have it in the Makefile to avoid that different source files in the same
project use different.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Previously, only one nexthop was recognized. The parsing of the whole file
failed immediately when two or more hops were possible for *any* originator (not
only for one with a router behind it).
This makes the parser ignore most of the line in the originators table.
As I have seen instances of ebtables being killed with a timeout of 100ms,
increasing it to 500ms.
Also, to ease the straint on the CPU, increasing minimum time between TQ checks
to 15 seconds.
This reduces the average CPU consumption (on a WDR4300) from 3% to 1%.
Also, this commit adds error messages when the parsing fails and makes matching
more flexible after all relevant fields have been found.
This package drops all incoming router advertisements except for the
default router with the best metric according to B.A.T.M.A.N. advanced.
Note that advertisements originating from the node itself (for example
via gluon-radvd) are not affected.
We would like to check the file size instead of downloading indefinitely.
The file size is added in another copy of the manifest lines, which is
ignored by older autoupdater implementations.
Interacting with batman-adv's genl interface requires some code and
definitions which could be shared between different packages. libbatadv is
trying to do this without providing any guarantee for ABI or API stability.
It is only useful in very controlled environments like gluon.
Signed-off-by: Sven Eckelmann <sven@narfation.org>