Commit Graph

95 Commits

Author SHA1 Message Date
Andrew Bettison
f91033820b Use explicit serverMode enum values everywhere 2018-06-01 17:40:09 +09:30
Andrew Bettison
1b2147074f Add more assertions to keyring functions 2018-05-17 11:21:41 +09:30
Jeremy Lakeman
9ba27b28a0 Possible race condition in command cleanup due to linking order, (Fixes #136) 2018-04-16 09:36:17 +09:30
Andrew Bettison
8345d896a6 Add Route REST API (fixes #96)
Consists of a single, one-shot request, GET /restful/route/all.json, for
the time being.  A "newsince" request can be added later.

Add a Markdown tech doc that specifies the new Route REST API and update
the MDP tech doc a little.

Add the 'routerestful' test script, which uses some test utility
fuctions that have been factored out of the 'routing' test script into
the new testdefs_routing.sh.

Add the new 'allrestful' test script.
2018-03-29 15:31:03 +10:30
Andrew Bettison
1a091aa8a1 Expose daemon's primary SID in 'proc/primary_sid'
This helps tests distinguish which of a daemon's keyring identities
is used as its primary identity, which is not otherwise obvious
without consulting the routing table, because slots are allocated
in random order.
2018-03-29 15:19:54 +10:30
Andrew Bettison
c7a2fb4573 Add nibble-tree iterator
The new struct tree_iterator and associated start/get/next/free
functions replace the recursive walk() function, removing the need for a
callback when iterating over all nodes in the tree, and allowing
iteration to be suspended while other pseudo-threads are run.  This
allows an HTTP REST request to keep a tree_iterator in its state struct
and potentially simplifies other areas of the code.

The iterator free()s any empty internal tree nodes that it encounters,
as did the original tree_walk() function.  To support the existence of
multiple iterators at once, a reference count has been added to the
tree_node struct, to prevent any iterator from free()ing a node while
any other iterators point to it; only the last iterator to pop out of an
empty node will free() it.

The tree_walk() and tree_walk_prefix() functions have been
re-implemented to use an iterator state object internally.  This
resolves an outstanding TODO to perform tree-node freeing during a
prefix walk, and simplifies the code considerably.

Renamed some function parameters and struct members to make the
nibble-tree API a little more self-explanatory.

Added a nibble-tree test to the 'serval-tests' utility.
2018-03-29 15:19:54 +10:30
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
0650666acb Allow PREVIOUS overlay address to refer to SIGNKEY 2017-11-22 17:38:17 +10:30
Jeremy Lakeman
e158a38137 Clean up a number of memory leaks, as revealed by clang's sanitiser 2017-09-11 14:09:27 +09:30
Jeremy Lakeman
de0258e30f Remove route structures from memory when all links are down 2017-05-02 14:46:08 +09:30
Jeremy Lakeman
69fb10395a Send route link messages with extra abbreviation bits 2017-05-01 10:06:24 +09:30
Andrew Bettison
ccacd19dfa Add global keyring assertions
Many functions require that the global 'keyring' pointer is set,
but there were no assertions to document this precondition.
2016-11-14 11:28:08 +10:30
Andrew Bettison
6d2eb268ed Add 'cmd_cleanup' trigger
The new 'cmd_cleanup' trigger replaces the old command_cleanup()
function, which was causing linking problems on OS X and inverted strict
dependency.  The keyring cmd_cleanup calls keyring_free(global_keyring),
instead of merely asserting keyring == NULL, so the error exit cases of
many CLI functions have been simplified.
2016-11-14 11:28:03 +10:30
Jeremy Lakeman
30aa1c16b8 Set authorship to remote if the sender sid can be generated from the id 2016-10-20 08:51:46 -04:00
Jeremy Lakeman
65831e31d4 Report the state of each network interface in routing table 2016-10-20 08:48:35 -04:00
Andrew Bettison
41b3e304be Updated some copyright messages and COPYRIGHT.txt 2016-10-13 16:23:18 +10:30
Jeremy Lakeman
b927af79a8 Introduce new typedef for signing keys to expose their internal structure 2016-09-27 10:28:46 +09:30
Jeremy Lakeman
ecb79d818f Refactor storage of binary values to enable reuse 2016-09-13 15:25:39 +09:30
Andrew Bettison
2cfdafdb56 Add some MDP client DEBUG trace statements 2016-09-06 13:31:38 +09:30
Jeremy Lakeman
b6256ea89a Add identity_t type & rename signing key api to identity. 2016-08-16 12:22:13 +09:30
Jeremy Lakeman
83b6ecb453 Roll an in memory identity when the keyring is empty 2016-08-02 11:01:32 +09:30
Jeremy Lakeman
d028818c0b Detect combined identities & transmit them more efficiently 2016-07-25 15:50:43 +09:30
Jeremy Lakeman
e15e332072 Swap from included nacl to host libsodium 2016-05-09 10:32:04 +09:30
Jeremy Lakeman
4fc48d44fd Simplify subscriber enumeration & only support the use-cases we need 2016-01-12 11:47:29 +10:30
Jeremy Lakeman
75523b7f3c Don't talk about SID's that don't match the whole abbreviation 2016-01-12 10:29:46 +10: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
51ed6162dd Add support for running and stopping servald from a JVM thread
fdpoll will now run a callback when about to sleep / woke up.
A new Java interface to indicate server started / sleeping / waking up.
An android implementation may allow the CPU to sleep.
If there's a java exception the server will try to shutdown.
Calling servald stop is currently undefined.
2015-05-25 11:46:37 +09:30
Jeremy Lakeman
13bb8a558d Re-route packets on retransmision if the route has changed 2015-03-30 11:27:37 +10:30
Jeremy Lakeman
a37db8e958 Move most console commands to other files 2014-08-25 16:03:30 +09:30
Jeremy Lakeman
5f2c6e364a Refactor interface addresses to use new socket_address struct 2014-01-09 15:01:38 +10:30
Andrew Bettison
9b64bb87e0 Uniform copyright notices
Added some missing copyright/license block comments
2013-12-04 17:15:36 +10:30
Andrew Bettison
851dbb4d64 Add 'debug.subscriber' config option
Add debug logging to find_subscriber() function
2013-11-26 15:33:54 +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
Jeremy Lakeman
7629f24d3f Free subscriber entries after all commands 2013-11-06 15:36:21 +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
Jeremy Lakeman
926665e860 Ask for explanation of SIDs over point to point links 2013-09-20 14:41:50 +09:30
Jeremy Lakeman
2a5ba97b48 Add rhizome test over fakeradio 2013-09-13 14:02:35 +09:30
Jeremy Lakeman
9a50d8a9ef Route mulit-hop via unicast links 2013-08-09 16:37:54 +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
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
61a958fd34 Avoid setting alarms with deadlines that have already elapsed 2013-06-19 15:36:18 +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
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
gardners
2252fdcaa7 created tool for automatically finding IN()s without matching
OUT()s or where return() is used instead of RETURN().
Added OUT() to end of all functions using IN() that lacked it to
make it easier to statically analyse this invariant.
Fixed several return instead of RETURNs detected through use of
this tool. #49
2013-02-20 16:18:56 +10:30
Jeremy Lakeman
c7caec488a Don't aggregate packets together on radio links 2013-02-20 15:36:23 +10:30
Jeremy Lakeman
7be03f15e7 Move link tracking to one c file 2012-12-14 17:07:28 +10:30