Commit Graph

479 Commits

Author SHA1 Message Date
Jeremy Lakeman
ef208c9932 Workaround stack alignment bugs when compiling with clang 2016-01-27 16:27:47 +10:30
gardners
dab244d92f shorten section names (and precursors) to keep in the 16 char limit
of the O-MACH assembler on OSX.
2015-08-24 10:17:04 +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
3ae0e95e0b Treat null strings as empty 2015-03-02 15:44:34 +10:30
Jeremy Lakeman
7bc253e844 Refactor source and build process to split out test commands 2014-12-01 13:26:27 +10:30
Jeremy Lakeman
a37db8e958 Move most console commands to other files 2014-08-25 16:03:30 +09:30
Jeremy Lakeman
2ec63b371a Build the array of console commands by using linkage tricks 2014-08-22 10:36:52 +09:30
Andrew Bettison
cf43635789 Improve Rhizome HTTP RESTful interface
Add RHIZOME_BUNDLE_STATUS_READONLY enum value

Tighten up switch statements on bundle and payload status enums (no
default labels)

Rename some recently added enum entries

Return bundle status and payload status in HTTP responses

Add test for failing to decrypt a foreign encrypted bundle payload,
fix bug that caused an assertion failure

Add tests for fetching a non-existent manifest and fetching bundles
whose payload blob is not in the store
2014-07-10 06:29:51 +09:30
Jeremy Lakeman
7ff89afcf4 Reinstate rhizome database storage limit
- old / large payloads should be evicted to fit more payloads
- if there isn't enough space, new payloads will not be added
2014-06-19 11:09:09 +09:30
Jeremy Lakeman
80e139c2d9 Ensure orphan payloads or manifests are cleaned up 2014-06-16 15:56:31 +09:30
Andrew Bettison
d46939f81e Improve server start/stop logic
Unlink server pidfile on orderly exit

Only call serverCleanUp() in server process, not in "start" command
(fixes race condition)
2014-06-11 15:18:25 +09:30
Andrew Bettison
3d537f9645 Improve test framework: test coverage support 2014-06-06 14:47:54 +09:30
Jeremy Lakeman
cb9a6731f2 Include signal.h for definition of kill() 2014-06-05 17:27:51 +09:30
Jeremy Lakeman
f09e6c38d2 Test that server quits after deleting pid file 2014-06-05 14:55:50 +09:30
Jeremy Lakeman
b6de3fcd34 Only send rhizome sync packets when we have neighbours 2014-05-30 15:03:22 +09:30
Andrew Bettison
21f51965c1 Overhaul Makefile and header files
Make .o files in separate subdirectories for servald and library
Factor struct __sourceloc and __WHENCE__ from "log.h" into "whence.h"
Factor sid_t etc from "serval.h" into "serval_types.h"
Factor rhizome_bid_t etc from "rhizome.h" into "rhizome_types.h"
Do not include "serval.h" in library sources
Add log_stderr.c and logMessage.c for stand-alone executables
2014-05-26 15:36:26 +09:30
Andrew Bettison
885cf56c95 Fix "unused parameter" warnings for undefined HAVE_JNI_H 2014-05-22 14:17:36 +09:30
Jeremy Lakeman
9e267ece21 Always set keyring to NULL after use. 2014-05-15 16:32:46 +09:30
Jeremy Lakeman
672104bdd8 Create extensible service discovery protocol, with initial basic implementation 2014-05-09 11:21:18 +09:30
Andrew Bettison
7a2f1536bc Improve mdp_recv() error handling
Make all V2 MDP interface calls take a __whence argument

mdp_recv() always sets error before returning -1, does not set
errno=0 otherwise

mdp_recv() does not log errors on EINTR or EAGAIN (EWOULDBLOCK)

mdp_recv() sets errno=EOVERFLOW if local socket name is too long

mdp_recv() sets errno=EBADMSG if malformed or spurious packet
received

Remove redundant mdp_recv() error logging from "mdp ping" and
"config sync" and several "id" commands
2014-05-05 18:23:38 +09:30
Andrew Bettison
459c5a2303 Improve "mdp ping" command
Packet stats now exclude duplicate pong replies

With <count> arg, exits immediately once a pong has been received for
every ping, unless new --wait-for-duplicates option given

Routing tests for unreliable links now assert all pongs received and
very few duplicates
2014-04-17 16:09:34 +09:30
Andrew Bettison
8bc746af25 New "config sync" command 2014-04-16 19:28:16 +09:30
Andrew Bettison
67e3079aa3 Fix return value of mdp_send() 2014-04-16 19:28:11 +09:30
Andrew Bettison
c7d6ce71d5 Fix "mdp ping" to exit after <count> pongs 2014-04-15 15:03:41 +09:30
Andrew Bettison
bb677e50fd Refactor keyring open/seed out of server()
Now the keyring is opened and seeded before the server daemon process is
forked, and any keyring error prevents the server from starting

No longer necessary to pass a (cli_parsed*) argument to server()
2014-04-07 16:22:31 +09:30
Jeremy Lakeman
1228df2b70 Remove bitrot related to voip testing 2014-04-07 15:48:10 +09:30
Andrew Bettison
97850835da Clean up "serval.h" a bit
Move some defs to more appropriate header file
Remove unused function prototypes
Remove unused SLIP and CRC32 code
2014-04-07 14:27:32 +09:30
Jeremy Lakeman
2226a529af Use slightly cheaper JNI exception test 2014-03-27 13:30:46 +10:30
Andrew Bettison
53c1b1c04c Filesystem Heirarchy Standard (FHS) paths
If no instance directory specified, then use paths like
/etc/serval/serval.conf
/var/cache/serval
/var/log/serval
/var/run/serval
etc. for files, instead of all in a single directory.

Log all directory creation as INFO messages.

Interpretation of log.file.directory_path has changed slightly.

Updated servald configuration tech doc.
2014-03-26 15:35:43 +10:30
Jeremy Lakeman
a6f408f013 Return mdp inet & http port numbers in servald start & status 2014-02-25 12:42:36 +10:30
Jeremy Lakeman
ae67dd9c56 Initialise client API sockets before PID file 2014-02-24 17:14:35 +10:30
Jeremy Lakeman
b56f4c27d3 Replace internal usage of overlay_mdp_dispatch 2014-02-19 16:39:42 +10:30
Jeremy Lakeman
487df0408d Refactor mdp packet processing to avoid using struct overlay_mdp_frame 2014-02-19 16:34:11 +10:30
Jeremy Lakeman
46ef40cf23 Migrate and refactor more interfaces from batphone 2014-02-19 15:35:08 +10:30
Jeremy Lakeman
99fb8b6108 Move jni interface classes from batphone repo 2014-02-12 13:09:17 +10:30
Andrew Bettison
0727fb3b62 Merge branch 'naf4' into 'development'
New RESTful HTTP API for MeshMS
2014-02-07 16:42:09 +10:30
Jeremy Lakeman
d3a454e48c Ensure ping flooding doesn't block 2014-01-23 14:09:11 +10:30
Andrew Bettison
94274ba5fa Refactor sqlite_retry_state into rhizome_list_cursor 2014-01-22 17:20:06 +10:30
Jeremy Lakeman
f085ffec50 Add SIGINT handler to cleanup mdp sockets 2014-01-09 15:06:35 +10:30
Jeremy Lakeman
48dce9a575 Add tcp forwarding on the listen end of an MSP connection 2014-01-09 15:06:35 +10:30
Jeremy Lakeman
99e08d1516 Add command to support forwarding TCP connections to an MSP service 2014-01-09 15:06:35 +10:30
Jeremy Lakeman
db7f68afd7 Initial msp library implementation with connection state tracking 2014-01-09 15:01:37 +10:30
Andrew Bettison
72040517e1 New enum rhizome_payload_status
Refactor a lot of Rhizome bundle storage code to use the new "enum
rhizome_payload_status" instead of mysterious int values to represent
the outcome of the operation.
2013-12-30 16:30:35 +10:30
Andrew Bettison
9ebef81a49 Formalise "rhizome add file" exit status
Formalise add-bundle result in "enum rhizome_bundle_status"

Rewrite rhizome_manifest_finalise(), rhizome_find_duplicate() and
rhizome_add_manifest() to return enum rhizome_bundle_status

New function rhizome_manifest_check_stored() that compares a manifest
with its stored counterpart and returns enum rhizome_bundle_status

Remove redundant rhizome_manifest_check_sanity(), consolidating all
manifest validation rules in rhizome_manifest_validate(), which now
checks the 'id' field is present, and that 'sender' and 'recipient' are
both present for MeshMS

Correct manifest finalisation logic: set the 'finalised' flag in
rhizome_manifest_validate(), not in rhizome_manifest_verify() (which
sets 'selfSigned'), and consistently clear 'finalised' flag in all
attribute setter functions

Remove manifest 'ttl' field and all references thereof (leaving unused
space in Rhizome BAR)

Rename some payload functions for clarity
2013-12-21 14:37:18 +10:30
Andrew Bettison
d52ba4c871 Remove rhizome_read_manifest_file()
Replace with memcpy() followed by rhizome_manifest_parse()
for memory buffers

Replace with rhizome_read_manifest_from_file() for files
2013-12-20 11:29:17 +10:30
Andrew Bettison
9b1ad664e9 Log error in "rhizome extract" if payload fails 2013-12-18 17:44:16 +10:30
Andrew Bettison
250309f4d8 Fix strn_to_sid_t(), add strn_to_rhizome_bk_t()
Improve strn_to_rhizome_bid_t() and strn_to_rhizome_filehash_t() to
accept a NULL first arg -- useful for data validation
2013-12-18 17:44:16 +10:30
Andrew Bettison
b53cabaae5 Unify output manifest fields from CLI rhizome commands 2013-12-13 17:24:59 +10:30
Andrew Bettison
4428a76379 Use ssize_t for read(2) and write(2) return value
Test for errors using == -1 not < 0, and cast to (size_t) subsequently

Fixes some -Wsign-compare warnings
2013-12-10 17:21:35 +10:30