Commit Graph

342 Commits

Author SHA1 Message Date
Andrew Bettison
cbc91d11e0 Improve performance timing diagnostics
Add __whence args to fd_func_enter() and fd_func_exit() so that their log
messages get reported from the location of the IN() or OUT() macro, not a line
in performance_timing.c.

Removed diagnostic information from the FATAL() message in fd_func_exit(), and
a comment explaining why (causes SEGV).
2012-11-12 14:38:50 +10:30
Jeremy Lakeman
54e2d66934 Allow for with slightly longer paths 2012-11-09 13:40:55 +10:30
Andrew Bettison
4450116472 Refactor string functions, add str_fromprint()
Move lots of non-Serval-specific string functions from "serval.h"/dataformats.c
to "str.h"/str.c.

Add str_fromprint() function that reverses the effect of toprint(): interprets
escape sequences in the source string "\n\t\r\0\xHH\\" and replaces them with a
single char in the destination string.
2012-11-07 16:42:45 +10:30
Andrew Bettison
39fc4ce6de Issue #30, remove periodic Rhizome fetch alarm
Replace the main-loop scheduled periodic alarm with an "activate" alarm that is
scheduled whenever a fetch candidate is added to any queue, unless the alarm is
already scheduled.

Replace the "rhizome.fetch_interval_ms" config item with
"rhizome.fetch_delay_ms" [default 50], which is the number of milliseconds
between adding a fetch candidate and firing the "activate" alarm.  This allows
time for a few more Rhizome advertisment packets to arrive after the first one,
before deciding which fetches to start first.

Add new `is_scheduled()` alarm primitive.
2012-10-24 15:13:50 +10:30
Andrew Bettison
a9d3a1387c Issue #30, rewrite Rhizome fetch queues and slots
Causes SEGV in rhizomestress test.
2012-10-23 18:10:20 +10:30
Jeremy Lakeman
f93216f369 Remove dead code 2012-10-19 15:02:22 +10:30
Jeremy Lakeman
f1b0374b97 Extract crypto signing primitives from mdp processing 2012-10-19 14:54:41 +10:30
Jeremy Lakeman
95843e1f20 Pass overlay frame into mdp processing 2012-10-19 10:40:03 +10:30
Andrew Bettison
8ab7cc79b5 Improve debug logging from watch(), schedule() etc.
Use new '__whence' mechanism.
2012-10-16 17:00:03 +10:30
Andrew Bettison
259b9a9d24 Logging/debug improvements: __WHENCE__, __whence
Introduce __WHENCE__ macro and a block comment in log.h explaining it.

In "primitive" kinds of functions, rename 'whence' arguments to '__whence' and
use WHYF(), WARNF(), DEBUGF() macros instead of calling logMessage() directly.
2012-10-16 17:00:03 +10:30
Paul Gardner-Stephen
37495e4794 fix interface detection on solaris. 2012-10-15 15:58:42 +10:30
Andrew Bettison
3f1f495d68 Issue #17, overhaul manifest author crypto logic
Add test case for new feature of the "rhizome add" command: if the author SID
is not specified (empty arg) then it searches the keyring for the author.

Removed "authorSid" argument from several functions that also take a struct
rhizome_manifest * arg, since the author, if known, is now supplied in the
struct.

Improve return value handling and refactored some rhizome crypto code.
2012-10-11 17:58:24 +10:30
Jeremy Lakeman
b22e3f1964 Add hop count to mdp ping
- Allow mdp client to specify ttl
- Copy ttl into and out of overlay frame
2012-10-10 16:22:31 +10:30
Jeremy Lakeman
4b2b8f1783 Store keyring identity pointer for local identities in subscriber tree 2012-10-10 15:29:36 +10:30
Jeremy Lakeman
5d553538e7 Remove dead code 2012-10-09 16:20:44 +10:30
Jeremy Lakeman
1f379ea209 Add and preserve QOS bit flags in packet header 2012-10-09 16:17:07 +10:30
Jeremy Lakeman
e28deeb6d5 Move requested payload queue into frame structure 2012-10-09 15:44:37 +10:30
Andrew Bettison
3433b0fbb5 Move is_sid_broadcast() and is_sid_any() macros into serval.h
From overlay_mdp.c.  is_sid_broadcast() was defined as is_broadcast().

Also clean up the signature and implementation of is_all_matching().
2012-10-09 13:49:23 +10:30
Jeremy Lakeman
275aa49903 Change route announcement format, add please explain support 2012-10-09 12:57:11 +10:30
Andrew Bettison
89343c69cd Merge branch 'rhizomedirect' into 'master' 2012-10-05 17:45:30 +09:30
Jeremy Lakeman
48c9a7067e keyring_get_nm_bytes doesn't need to know about port numbers 2012-10-05 09:14:24 +09:30
Jeremy Lakeman
32cd46c165 Simplify id peers command, hide mdp implementation details from node info 2012-10-03 16:21:06 +09:30
Jeremy Lakeman
b72c01518b Move SAS key storage into subscriber structure 2012-10-03 13:59:46 +09:30
Jeremy Lakeman
fa7719fbe8 Write simple vomp console client 2012-09-28 15:23:50 +09:30
Jeremy Lakeman
2a7bd28e51 Extend packet queue to allow sending multiple copies of the same payload for reliability 2012-09-28 11:28:01 +09:30
Andrew Bettison
14721fab19 Merge branch 'solaris' into rhizomedirect
All test cases pass on Solaris (see issue #16) except the 'jni' tests because
there is no Java compiler available on Solaris, and the new 'rhizomeprotocol'
tests from the rhizomedirect branch, which have always failed.
2012-09-27 17:38:16 +09:30
Jeremy Lakeman
ac3864ff20 Reuse command line parsing framework with monitor interface 2012-09-25 13:31:34 +09:30
Jeremy Lakeman
b7c088f2fd Reduce latency of dummy interface, improve some debug messages 2012-09-20 10:28:02 +09:30
Jeremy Lakeman
0538e95be8 Reduce the potential for packet storms 2012-09-20 10:28:01 +09:30
Jeremy Lakeman
7c73ca7a78 Finish test and implementation of directory service 2012-09-18 12:30:15 +09:30
Jeremy Lakeman
e854409e0b Start dna helper immediately (it's convenient for starting another service) 2012-09-18 12:24:33 +09:30
Jeremy Lakeman
ac8d9b93e6 Add stub directory service 2012-09-14 11:50:45 +09:30
Jeremy Lakeman
6483d9e0ae Split client mdp functions so they can be built separately 2012-09-14 11:47:48 +09:30
Jeremy Lakeman
3b55643b08 Send my full sid periodically for any outgoing payload header 2012-09-07 10:01:34 +09:30
gardners
d3f5c6e598 Merged rhizome direct httpd back into main rhizome httpd server.
bundles can be imported via HTTP POST multi-part form. #9
2012-09-06 13:21:13 +09:30
Paul Gardner-Stephen
bba6839656 Initial stab at porting to Solaris.
It compiles without warning (with CC=gcc) but doesn't link
because NaCL doesn't build yet.
2012-09-05 20:42:50 +09:30
Jeremy Lakeman
545c05fddb Relay broadcast payloads via olsr plugin 2012-09-01 12:41:50 +09:30
Jeremy Lakeman
1b91724da2 Allow for interfaces that don't tick, pack rhizome manifests into all packets 2012-09-01 12:18:39 +09:30
Jeremy Lakeman
e05806f25e Separate routing calculation from resulting rules, refactor more code to use subscriber structure 2012-08-31 15:11:18 +09:30
Jeremy Lakeman
f6c899e107 Refactor overlay buffer interface to support simple parsing 2012-08-31 15:03:07 +09:30
Jeremy Lakeman
22c6b530ed Rework broadcast address handling, working towards a unified address struct 2012-08-31 15:03:07 +09:30
Jeremy Lakeman
aa5706f9d7 Refactor routing node information to use new subscriber tree 2012-08-31 15:03:07 +09:30
Jeremy Lakeman
30d5ed2b6d Simple refactoring 2012-08-31 15:03:07 +09:30
gardners
9d2aa61792 Refactoring of Rhizome http server code so that we can supply a
different request parser, but otherwise share code between
rhizome transfers and rhizome direct. #9
2012-08-31 13:01:28 +09:30
gardners
bde9d1c56a Rhizome http server now allows specification of client socket callback
when starting, so that same server code can be shared for rhizome transfers
and rhizome direct. #9
2012-08-31 13:01:28 +09:30
gardners
2b29893a02 Initial work towards rhizome direct syncrhonisation functions #9 2012-08-31 12:58:37 +09:30
Daniel O'Connor
e7201963d0 Staticise a bunch of functions so I get some understanding of what is needed where. 2012-08-31 12:13:20 +09:30
Andrew Bettison
27a0a6eeb5 Introduce struct __sourceloc
Replaces (const char *file, unsigned int line, const char *function) arguments
to all logging functions, simplifies malloc/free tracking code in
overlay_buffer.c and Rhizome manifest alloc/free tracking in rhizome_bundle.c.

Use __HERE__ macro instead of (__FILE__, __LINE__, __FUNCTION__) everywhere.

Special __NOWHERE__ macro is equivalent to (NULL, 0, NULL).

Declare net.c functions in new "net.h" header, so log.c doesn't have to pull
in the entire "serval.h" just to use write_str().

Facilitates progress on issue #2.
2012-08-23 12:31:07 +09:30
Andrew Bettison
d8fd9fa411 Refactor nanosleep(2) calls into sleep_ms() function 2012-08-21 13:35:33 +09:30
Jeremy Lakeman
1a468f23b6 Fix off by one bug in payload length storage 2012-08-16 16:25:20 +09:30
Andrew Bettison
eec8fb6e95 Improve SAS resolution debug messages 2012-08-14 14:06:59 +09:30
Jeremy Lakeman
dcb2da45fa Allow for audio to arrive in variable sized blocks 2012-08-13 16:35:30 +09:30
Jeremy Lakeman
3ab79d8e5b Pass phone numbers in vomp call initiation 2012-08-13 14:01:57 +09:30
Jeremy Lakeman
fd111a4d1f Listen to INADDR_ANY on OSX, otherwise we can't hear broadcasts 2012-08-09 13:32:08 +09:30
Jeremy Lakeman
f059546eb0 Improve monitor client interface and vomp for asterisk channel driver 2012-08-09 13:32:08 +09:30
Jeremy Lakeman
736a8f43c0 Refactor towards changing the vomp monitor interface 2012-08-09 13:32:08 +09:30
Jeremy Lakeman
fc9a9b337e Wait for vomp client to indicate that ringing has started 2012-08-09 13:30:52 +09:30
Andrew Bettison
12d8bc0c12 Use new typedef time_ms_t everywhere 2012-08-09 12:14:32 +09:30
Andrew Bettison
fd1da2df93 Fix bug that failed dnaprotocol multi-lookup test 2012-08-06 16:44:36 +09:30
Andrew Bettison
03da89225d Add xprintf() extensible stream formatter
Use it to replace open_memstream(3) in logServalPacket() -- not available on
Mac OS X
2012-08-03 16:44:05 +09:30
Andrew Bettison
ee6d9d8ea3 Fix logging in vomp.c
Replace DEBUG_SIMULATION with DEBUG_VOMP

Replace all printf(...) and fprintf(stderr,...) with WHYF(...) and DEBUGF(...)

Make all debug logging conditional on DEBUG_VOMP
2012-08-02 11:29:37 +09:30
Andrew Bettison
f37ec5af09 Reduce use of stderr in many places
serval_packetvisualise() is now replaced by DEBUG_packet_visualise() which uses
logging system not stderr (so now it will appear in Android log).

Replaced several fprintf(stderr,...) with DEBUGF(...).

Command line only prints a full help message on "help" command -- a command
parse failure simply informs the user about the "help" command.
2012-08-01 17:54:02 +09:30
Andrew Bettison
76cfb7beae Fix bug failed dnaprotocol tests non-deterministically
Appending to the dummy interface file was altering the read offset position, so
very many receive packets were being lost.
2012-07-31 17:49:24 +09:30
Andrew Bettison
b9396505f8 Remove some unused declarations 2012-07-30 16:15:42 +09:30
Andrew Bettison
f002f5b9fd Refactor log.h constants.h serval.h
Move DEBUG_ and LOG_LEVEL_ macro constants from constants.h into log.h.

Move dumpResponses() out of log.c, so that log.h is almost ready for re-use
(still depends on conf.h).

Remove unused and now obsolete catv() function -- replaced with toprint()
and alloca_toprint().

Add copyright/licence comments, fix up some copyright attributions.

Add #ifndef..#define..#endif __SERVALD_FOO_H to header files: log.h serval.h
constants.h
2012-07-30 16:15:42 +09:30
Daniel O'Connor
09d0fecf28 Remove carnal knowledge of conf.c from serval.h and commandline.c by providing a function to set the instance path override. 2012-07-29 18:58:41 +09:30
gardners
72f8b1916d minor fixes to get things building with monitor client library. 2012-07-29 12:44:04 +09:30
gardners
274a77fa46 Refactor serval.h to split out log, config and other bits so that
we can have a standalone ServalD monitor client library and simple
header file.  Create that too.
2012-07-29 12:42:27 +09:30
gardners
93449d380e various fixes for libmonitorclient and commits made by others
inbetween. Hopefully I have captured all the changes.
2012-07-29 12:35:53 +09:30
Andrew Bettison
3b1adc3a31 Add DEBUG_argv() and WHY_argv() macros
Implemented usng new logArgv() function.

Refactored logMessage()
2012-07-27 18:04:46 +09:30
Andrew Bettison
0dee99dec2 Remove old command-line support 2012-07-27 11:44:20 +09:30
Andrew Bettison
62d851f97c Improve DEBUG_GATEWAY debugging
Rewrite all fprintf(stderr,...) to DEBUGF(...)

Improve error reporting from runCommand() and safeSystem(), make them local to
gateway.c
2012-07-27 11:28:14 +09:30
Andrew Bettison
a69f637b3a Replace DEBUG_HLR with DEBUG_KEYRING
Convert several fprintf(stderr,...) into DEBUGF() statements
2012-07-27 11:26:19 +09:30
Andrew Bettison
a6a81a0f64 Improve server signal handling
Use sigaction(2) instead of deprecated signal(2), allowing SEGV et al to be
received in handler and therefore in re-spawned server.

Receive SIGSEGV et al in a separate handler function which kills the server
with the same signal if it does not re-spawn.

Log a GDB backtrace on SEGV et al before exiting or respawning.

Rename config option "serval.respawn_on_signal" to "server.respawn_on_crash".
2012-07-26 18:31:23 +09:30
Andrew Bettison
81cafe9d6f Improve log_backtrace() function
Add BACKTRACE macro.  Improve gdb output buffering: log each line individually,
read progressively, reduce buffer size.  Log diagnostics if gdb cannot be run.
2012-07-26 16:51:59 +09:30
Andrew Bettison
04b95d2590 Merge branch 'andrew' into 'master' 2012-07-25 18:04:16 +09:30
Andrew Bettison
2b57773472 Add log_backtrace() function 2012-07-25 17:02:57 +09:30
Jeremy Lakeman
6e7c2196ba Close interfaces on socket errors or when not detected 2012-07-25 16:53:44 +09:30
Jeremy Lakeman
74095e5356 Correctly display interface ip addresses on android 2012-07-25 14:53:53 +09:30
Jeremy Lakeman
5ec739c712 Add performance timing debug option 2012-07-25 13:33:30 +09:30
Andrew Bettison
6de247e576 Improve diagnosis of SEGV failures in tests 2012-07-24 15:39:36 +09:30
Andrew Bettison
f472ac9a8d Lots of 'dnahelper' tests, all pass but one
Test fails because DNA helper logic does not yet impose a timeout on receiving
the "DONE" ACK after a request.
2012-07-23 18:29:57 +09:30
Andrew Bettison
3e0f8df18a Fix bug in DID parsing, affects "set did" command 2012-07-23 15:17:21 +09:30
Andrew Bettison
30567c1d34 Start writing systematic 'dnahelper' tests 2012-07-23 12:23:17 +09:30
Andrew Bettison
0e5c5e0e98 More work on dnahelper, almost done
Servald starts DNA helper, receives startup ACK, sends requests, receives
responses, handles malformed helper responses, echoes dnahelper stderr lines to
log, sends MDP reply packet, waits for dead helper process, all asynchronously.
Shuts down helper process during servald shutdown.

Remaining issues:
 - Does not impose a timeout on helper responses.
 - Only the first URI is reported by the "dna lookup" command.
2012-07-20 18:17:43 +09:30
Andrew Bettison
3b44bb6e58 More progress on dnahelper 2012-07-19 17:59:45 +09:30
Andrew Bettison
5aac5a3854 Unfinished dnahelper implementation 2012-07-18 19:16:30 +09:30
Jeremy Lakeman
87515d5dda Allow a frame buffer to wrap an existing buffer 2012-07-18 14:43:14 +09:30
Jeremy Lakeman
fdc70d7512 Log when a peer becomes reachable or unreachable, edit tests to wait for this message 2012-07-17 18:22:39 +09:30
Jeremy Lakeman
6f12edd7a8 Fix compiler warning 2012-07-17 15:59:06 +09:30
Jeremy Lakeman
1d53726b7b Merge remote-tracking branch 'origin/master'
Conflicts:
	rhizome_fetch.c
	rhizome_http.c
	testframework.sh
2012-07-17 15:39:55 +09:30
Jeremy Lakeman
ddba8033e4 Refactor packet envelope and sid abbreviation reading and writing 2012-07-17 15:30:50 +09:30
Andrew Bettison
dd225bbb7f Refactor rhizome HTTP response headers 2012-07-13 12:31:10 +09:30
Jeremy Lakeman
5e915bcc09 Schedule packet sending 2012-07-13 12:18:50 +09:30
Jeremy Lakeman
d36ba78afe Refactor packet construction and sending 2012-07-13 12:18:50 +09:30
Jeremy Lakeman
e9566de0af Fix payload length fields 2012-07-13 12:18:49 +09:30
Jeremy Lakeman
27c24f377e Add deadline time for alarm prioritisation 2012-07-13 12:18:45 +09:30
Jeremy Lakeman
35b4ba8594 Schedule interface ticks per interface 2012-07-13 12:13:46 +09:30
Andrew Bettison
41f3228300 Refactor rhizome HTTP request parsing
Replace DEBUG_RHIZOMESYNC with DEBUG_RHIZOME_TX
2012-07-13 11:06:10 +09:30
Andrew Bettison
dcf7209304 Add read_nonblock() function
Deal with platforms where EWOULDBLOCK != EAGAIN
2012-07-13 11:04:50 +09:30