Commit Graph

148 Commits

Author SHA1 Message Date
Andrew Bettison
c35af0617a Fix header files for Xcode iOS build
- make "debug.h" a private header so that the DEBUG() macro does not
  interfere with Xcode Debug builds, which set DEBUG=1
- move all #include "debug.h" from headers into .c files
- move 'struct idebug' into a new public header "idebug.h" so that
  "log.h" can be public
- move HTTPD port number defs from "httpd.h" to "constants.h", so that
  "httpd.h" can be private and "conf.h" can be public
- add missing nested includes so each header compiles stand-alone
  without error
- #include "sodium.h" instead of <sodium.h>
- #include "sqlite3.h" instead of <sqlite3.h>
- add header guard to "fifo.h"
- fix header guard in "sync_keys.h"
2018-03-06 15:29:29 +10:30
Andrew Bettison
92fa6c196a Rewrite logging system
Rename the logging primitive functions and utility functions, prefixing
all with 'serval_log', eg: logMessage() -> serval_logf() etc.

Add an XPRINTF xhexdump() function and use it to implement the
serval_log_hexdump() utility, renamed from dump().  Add macros
WHY_dump(), WARN_dump(), HINT_dump() and DEBUG_dump(), and use them
everywhere.

Remove the 'log.console.dump_config' and 'log.file.dump_config'
configuration options; configuration is now dumped in every log prolog.

The logging system now constructs the log prolog by invoking the new
'log_prolog' trigger, so that it no longer depends on the version string
and configuration system.  Any system that wants to present a message in
the log prolog can define its own trigger, which calls standard log
primitives to print the message.

Split the logging system into a front-end (log.c) that provides the
logging primitives and is independent of the configuration system, and a
set of back-end "outputters" (log_output_console.c, log_output_file.c,
log_output_android.c) that may depend on the configuration system and
are decoupled from the front-end using the 'logoutput' link section.

These log outputters are explicitly linked into executables by the
Makefile rules, but could also be linked in using USE_FEATURE().  The
USE_FEATURE() calls have _not_ been added to servald_features.c, so that
different daemon executables can be built with the same feature set but
different log outputs.
2018-03-06 15:16:56 +10:30
Jeremy Lakeman
69fb10395a Send route link messages with extra abbreviation bits 2017-05-01 10:06:24 +09:30
Jeremy Lakeman
65831e31d4 Report the state of each network interface in routing table 2016-10-20 08:48:35 -04:00
Jeremy Lakeman
83b6ecb453 Roll an in memory identity when the keyring is empty 2016-08-02 11:01:32 +09:30
Jeremy Lakeman
2ddbb86cb5 Don't ask for explanation of SIDs with dead routing links 2015-11-16 14:09:35 +10:30
Jeremy Lakeman
79e8a94792 Add route_link.h 2015-09-28 11:58:48 +09:30
Jeremy Lakeman
deb1027024 Ignore duplicate link layer packets, eg bluetooth names 2015-08-03 11:12:39 +09:30
Andrew Bettison
7d9a5faa4e Move if(config.debug.xxx) tests into DEBUGF()
Original DEBUG() and DEBUGF() macros renamed to _DEBUG() and _DEBUGF()
New DEBUG() and DEBUGF() macros, first argument is flagname
New DEBUGF2(foo, bar, ...) macro does if(config.debug.foo||config.debug.bar) test
Replace almost all config.debug.xxx references to IF_DEBUG(xxx)
2015-07-13 16:00:05 +09:30
Jeremy Lakeman
e97f7c4e29 Fix vomp stun tests
- Don't trust stun responses about 3rd parties
- Only ack neighbour links via 1hop destinations (not multi-hop routes)
- Don't override network destinations that were manually supplied
2015-06-22 14:50:28 +09:30
Jeremy Lakeman
f7dbe06836 Rearrange interface config to support unicast settings 2015-03-23 13:35:22 +10:30
Jeremy Lakeman
63f02607e6 Fix duplicate payload detection over unicast links 2014-06-26 17:20:06 +09:30
Jeremy Lakeman
b94378ae97 Remove unused debug flags 2014-05-26 14:01:34 +09:30
Jeremy Lakeman
b8971e51f4 Refactor socket helper functions to take socket_address struct 2014-02-20 14:44:38 +10:30
Jeremy Lakeman
506518ad06 Allow interfaces to use local unix addresses
- broadcast packets are sent to all sockets in the same folder
- switched most tests to use local sockets
2014-01-09 15:01:38 +10:30
Jeremy Lakeman
5f2c6e364a Refactor interface addresses to use new socket_address struct 2014-01-09 15:01:38 +10:30
Jeremy Lakeman
8d80cf55f2 Fix printf formats 2013-12-16 15:19:15 +10:30
Andrew Bettison
3f0008bb39 Eliminate unused variable 2013-12-10 17:22:50 +10:30
Andrew Bettison
ebc3133f5c Change overlay_buffer fields from int to size_t
Fixes many -Wsign-compare warnings
2013-12-10 17:03:30 +10:30
Andrew Bettison
30b2059608 Fix -Wunused-parameter warnings
New UNUSED(param) macro suppresses the warning for a specific parameter

In some cases, removed the unused parameters.  In others, used the
parameter in a DEBUGF() or assert() statement to document the intent.
2013-12-09 18:22:18 +10:30
Andrew Bettison
dafa1fc186 Improve struct socket_address
Add struct sockaddr_in 'inet' union field, rename 'addr_un' union field
to 'local'

Replace recvwithttl()'s (struct sockaddr *) and socklen_t pair of args
with single (struct socket_address *) arg
2013-11-29 12:56:59 +10:30
Andrew Bettison
a9ccd38adc Improve overlay buffer ob_xxx() primitives
All ob_append_xxx(b,...) functions return void

ob_makespace() returns 1 if successful, 0 if not

Add ob_overrun(b) predicate to check for overrun after any number of
appends
2013-11-26 15:33:54 +10:30
Andrew Bettison
a95ef79139 Use sid_t everywhere
Remove stowSid() at last

Change API of tohex() and strbuf_tohex(), to pass string length instead of
binary byte count.  This allows odd numbers of hex digits to be produced.

Remove alloca_tohex_sid(); replace with alloca_tohex_sid_t()

New alloca_tohex_sid_t_trunc() macro
2013-10-09 18:54:21 +10:30
Andrew Bettison
9ba08e465f Issue #11: use socklen_t instead of int where appropriate
Also check for valid recvaddrlen before processing a received MDP packet.
2013-10-08 14:11:00 +10:30
Jeremy Lakeman
08b44e96ed Improve html debug statistics
- shift radio rssi onto interace structure
- track packets sent received
- create html output for interface stats
- create html output for link state routing stats
2013-09-23 11:31:38 +09:30
Jeremy Lakeman
f7bffbfabe Simplify packet debug logging 2013-09-20 14:41:50 +09:30
Jeremy Lakeman
8935db4184 Only ack soon if we have been asked to 2013-08-30 17:38:29 +09:30
Jeremy Lakeman
6ecfc952ed Schedule ack packets in response to neighbour broadcasts 2013-08-30 17:38:29 +09:30
Jeremy Lakeman
9a50d8a9ef Route mulit-hop via unicast links 2013-08-09 16:37:54 +09:30
Jeremy Lakeman
55657623aa Detect unicast links 2013-08-09 12:18:14 +09:30
Jeremy Lakeman
81afc42d8b Major refactor to packet queuing and delivery in preparation for unicast link tracking.
Unicast tests broken
2013-08-09 09:37:08 +09:30
Jeremy Lakeman
d47d1b1684 Split network destination structure from interface structure 2013-08-05 14:35:49 +09:30
Jeremy Lakeman
49e0286b43 Reduce packet header size for point-to-point links
- new interface.x.point_to_point config
- disable local echo for point to point dummy interfaces
- add ME and YOU sid abbreviation codes after learning other sid
2013-07-16 15:38:00 +09:30
Jeremy Lakeman
aa87168d7d Add per-interace dump of sent and received bytes 2013-07-15 15:27:41 +09:30
Jeremy Lakeman
9f9893095b Add small delays to route announcements to reduce packet spam 2013-07-10 13:16:22 +09:30
Jeremy Lakeman
d3a13f8d2c Fix stupid bug, test was backwards 2013-06-03 16:04:08 +09:30
Jeremy Lakeman
96daa47b95 Dump mdp header if we fail to parse length field 2013-05-30 13:24:37 +09:30
Jeremy Lakeman
bc50d3e184 Establish a unicast link to nodes who are filtering broadcasts 2013-05-29 11:58:06 +09:30
Jeremy Lakeman
50bcd3883b Don't forward broadcasts unless we are vital to their delivery 2013-05-29 11:58:06 +09:30
Jeremy Lakeman
f1391355e4 Reduce log noise with debug.overlayframes 2013-05-29 11:58:06 +09:30
Jeremy Lakeman
8ab5073869 Adjust packet format for better duplicate detection 2013-05-29 11:58:05 +09:30
Jeremy Lakeman
5b4e4919cf Mark resent packets so they can be dropped 2013-05-29 11:58:05 +09:30
Jeremy Lakeman
e519633f7a Resend last ACK if it is explicitly NACKed 2013-05-29 11:58:05 +09:30
Jeremy Lakeman
e5856225cf Add packet retransmissions due to missed ack's 2013-05-29 11:58:05 +09:30
Jeremy Lakeman
ef1e93bf52 Establish neighbour links with nodes running our legacy routing engine 2013-05-09 16:57:33 +09:30
Jeremy Lakeman
f405ba5337 Send sequence number on all broadcast frames 2013-05-03 16:23:23 +09:30
Jeremy Lakeman
9ee09e36a0 Replace old routing engine with new link state engine 2013-05-02 14:29:28 +09:30
Jeremy Lakeman
559b270966 Only compare routes that have all links via the same neighbour 2013-04-29 17:07:36 +09:30
Jeremy Lakeman
85b885dde2 Add basic link state routing 2013-04-26 16:54:01 +09:30
Andrew Bettison
8771a50b14 Fix TTL out-of-range bug
Was causing two routing tests to fail since the TTL decrement
logic was fixed in a8b88a46

The default TTL of 64 overflowed the 5-bit unsigned int in the MDP
packet header
2013-04-23 16:02:39 +09:30