Commit Graph

308 Commits

Author SHA1 Message Date
Andrew Bettison
e97e3db444 Silence unconditional DEBUG log message 2013-11-26 17:44:25 +10:30
Andrew Bettison
97ce07b76c Improve MDP debug logging 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
Andrew Bettison
45450386db Improve sendto(2) failure diagnostics
In MDP client and server MDP overlay code
2013-11-22 13:12:29 +10:30
Andrew Bettison
3805650736 Use ssize_t for sendto(2) return value, not int
Also improve error checking on ssize_t values (use ==-1 not <0) test
and cast ssize_t to size_t for comparisons
2013-11-22 11:55:09 +10:30
Andrew Bettison
e92e7cb65e Improve sendto(2) error log messages 2013-11-22 11:55:09 +10:30
Andrew Bettison
7564d529a1 Add missing copyright/license comment blocks
Update a few existing copyright notices to reflect recent work
2013-11-21 16:05:18 +10:30
Jeremy Lakeman
0b404b0260 Implement id list command 2013-11-13 12:00:46 +10:30
Jeremy Lakeman
ff1f1ff093 Allow tag primitives to be used outside of keyring entries 2013-11-13 12:00:05 +10:30
Jeremy Lakeman
4434b1b65d Create keyring.h and move definitions there 2013-11-13 11:55:12 +10:30
Petter Reinholdtsen
94d45e3d33 Merge with latest development branch. 2013-10-14 10:15:56 +02:00
Jeremy Lakeman
b8ec568711 Send 3-way request to stop routing an identity 2013-10-14 14:40:19 +10:30
Petter Reinholdtsen
fde6dc210f Make code to avoid compiler warnings about uninitialized variables simpler. Fix some more. 2013-10-13 22:55:24 +02:00
Petter Reinholdtsen
2c3c7527d3 Initialize a few more uninitialized values. 2013-10-13 09:49:25 +02:00
Andrew Bettison
147eec4315 Fix compiler warning on Linux ix86 2013-10-10 17:17:03 +10:30
Jeremy Lakeman
ef7351bddc Unload identities from a running daemon 2013-10-10 14:27:00 +10:30
Andrew Bettison
221fc4a4fc mdp_port_t 2013-10-09 19:22:51 +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
ae7e120ed5 Pass keyring entry pin to running daemon and unlock identities 2013-10-09 15:34:41 +10:30
Andrew Bettison
2119433bb0 Issue #11: fix printf "%zd" ssize_t warnings on Android
Also use ssize_t instead of 'int' in a few suitable places
2013-10-08 15:39:29 +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
Andrew Bettison
cc96e08e9d Issue #20: Improve socket name handling
The recently added cmp_sockaddr() function does not call stat(2) any
more to compare local AF_UNIX socket address paths, so not it is stable
enough to use for ordering sockaddr structs.

New function: real_sockaddr() converts the file path of a local AF_UNIX
file socket using realpath(3).  The MDP client uses it on the sender
address of every MDP reply packet it receives to ensure that symlinks in
the instance path do not cause MDP client failures.

Rename recently added socket_setname() function: make_local_sockaddr().
2013-09-20 14:07:19 +09:30
Andrew Bettison
ae61a4f35c Issue #20: Make abstract sockets work
Finish the work started by Daniel in 2012, by using abstract local
AF_UNIX sockets on platforms that support them (Linux, Android).

Fix all sorts of bugs and issues that prevented the existing MDP and
Monitor client and server code from working with abstract socket names.
2013-09-19 17:26:06 +09:30
Andrew Bettison
5c84b2ffd5 Fix Rom's socket cleanup-on-start code
Fix buffer overflow bug: replace call to sprintf(3) with call to
FORM_SERVAL_INSTANCE_PATH()

Fix file descriptor leak bug: add missing closedir(3) call

Use lstat() instead of stat() to avoid warnings on broken sym links

Use WARNF_perror() where appropriate in preference to WARNF()

Remove redundant one-line comments
2013-09-19 04:30:40 +09:30
Andrew Bettison
d64d9487c1 Issue #20: improve socket set-up logging 2013-09-19 04:30:40 +09:30
Andrew Bettison
2b3119b49b Issue #20: merge branch 'sockets' into 'development'
Daniel's improvements to the local file/abstract socket code, with many
improvements to bring it up to date.
2013-09-19 04:30:14 +09:30
Romain Vimont (®om)
2c6a14dd56 Delete all socket files on servald start
If serval does not close properly, socket files are kept in
/data/data/org.servalproject/var/serval-node. Therefore, we need to clean up
when servald starts.
2013-08-26 11:55:11 +09:30
Jeremy Lakeman
bc8ff888e9 If frame sender is NULL, assume you mean our primary SID 2013-08-15 16:31:26 +09:30
Jeremy Lakeman
6fe11c8339 Refactor mdp dispatch so internal services can skip it 2013-08-15 10:14:39 +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
gardners
e808fb0872 got rid of vestigal confValueGet() call in alternate code path. 2013-07-19 20:04:15 +09:30
Jeremy Lakeman
ac734b3161 Prevent trying to send packets that are too large 2013-07-11 12:20:12 +09:30
Jeremy Lakeman
adbbed5275 Add new rhizome sync protocol 2013-06-19 12:05:57 +09:30
Jeremy Lakeman
c6241c6634 Ensure routing table is updated when indirect nodes go offline 2013-06-11 10:18:28 +09:30
Jeremy Lakeman
e5856225cf Add packet retransmissions due to missed ack's 2013-05-29 11:58:05 +09:30
Jeremy Lakeman
6a89f7a321 Improve accuracy of routing print output 2013-05-27 14:24:33 +09:30
gardners
d44e678a4e use generate_nonce() to generate a nonce, instead of reading from
/dev/urandom every time.
2013-05-07 14:43:35 +09:30
Jeremy Lakeman
9ee09e36a0 Replace old routing engine with new link state engine 2013-05-02 14:29:28 +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
Andrew Bettison
a8b88a462f Fix clang compiler warnings (revealed some bugs) 2013-04-12 17:16:50 +09:30
Jeremy Lakeman
af584994a2 Ensure encryption buffer doesn't move between nonce and cypher text allocation 2013-02-22 16:29:07 +10:30
Andrew Bettison
5ac6bd8834 Fix compile error on Linux 2013-02-22 12:06:21 +10:30
Jeremy Lakeman
bb8b3d6376 Add new mdp trace command 2013-02-20 16:18:58 +10:30
Jeremy Lakeman
10234018b0 Add interface name to route print output 2013-02-20 16:18:58 +10: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
gardners
2bbdd523f0 increase size for unix domain socket pathname from arbitrary 100
to PATH_MAX to solve tests erroring out on OSX with long temporary
file names.
2013-02-20 15:36:32 +10:30
Jeremy Lakeman
ba1800012e Only advertise BAR's on an alarm
- we no longer hit the database for every outgoing packet, attempting to announce bundles
- we no longer advertise manifests periodically
- when an interesting bar arrives, we ask for the manifest to be announced, which uses the existing packet format
2013-02-20 15:36:23 +10:30
Jeremy Lakeman
e9d283f3f6 Allow name to be missing 2013-01-17 11:45:45 +10:30
Jeremy Lakeman
82db15db5b Use any packet as a self-announce
Stop sending OF_TYPE_SELFANNOUNCE
Deprecate OF_TYPE_DATA_VOICE
Tweak payload priorities
Don't allow client applications to send high priority payloads
2012-12-16 10:09:29 +10:30
Andrew Bettison
7d970d8f92 Merge branch 'newconfig' into 'master' 2012-12-11 17:21:56 +10:30
Andrew Bettison
5985df751d Overhaul debug flags
Replace debugflags_t and DEBUG_XXX bit masks with config schema "debug.xxx"
entries.

No more support for "debug.all".
2012-12-11 15:59:46 +10:30
Jeremy Lakeman
7bf6beaf14 Throttle network scans some more 2012-12-11 13:31:26 +10:30
Jeremy Lakeman
2932544eb8 Add IPv4 addresses to dummy interface 2012-12-10 14:06:25 +10:30
Jeremy Lakeman
78aa01ad30 Add stun lookup messages 2012-12-10 14:05:57 +10:30
Jeremy Lakeman
f28e95b078 Don't scan broadcast address, limit network size 2012-12-06 10:42:34 +10:30
Jeremy Lakeman
3dfd64f4da Add manually triggered network scan command 2012-12-05 15:13:47 +10:30
Jeremy Lakeman
55cad42932 Make sure the buffer for cryptobox doesn't move 2012-12-04 16:19:50 +10:30
Jeremy Lakeman
5c7eb4a594 Add unicast probe packets
Probe directory service instead of assuming that it is always reachable
Fix directory service and routing tests
2012-12-04 14:47:57 +10:30
Jeremy Lakeman
2b21a691ca Merge remote-tracking branch 'origin/master' into packet_format
Conflicts:
	constants.h
	packetformats.c
2012-12-03 14:10:32 +10:30
Jeremy Lakeman
d5f78bcffe Rework reachable link flags for simpler bitmask tests 2012-11-30 14:38:09 +10:30
gardners
eb7524e068 factored out internal MDP services into a separate file, and made
core case statement in that brief and clear.
2012-11-30 11:48:00 +10:30
gardners
a665750f4c prepare and dispatch mdp frames for rhizome over mdp.
still need to set bodies of frames, and schedule call backs,
and handle the requests when received.
2012-11-29 21:08:11 +10:30
Jeremy Lakeman
053fa0d52f Reduce size of MDP port encoding 2012-11-28 15:45:14 +10:30
Jeremy Lakeman
f86176f3bd Reserve high nonce bit for future use 2012-11-28 15:45:14 +10:30
Jeremy Lakeman
383a63107f Use named constant for crypto_box_BOXZEROBYTES 2012-11-28 15:45:14 +10:30
Jeremy Lakeman
e0878644fe Add command to dump routing table 2012-11-28 15:43:58 +10:30
Jeremy Lakeman
a358d924d7 Remove type flag bits 2012-11-28 15:43:57 +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
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
gardners
499c4018bf Imported ref10/ implementation of crypto_sign from supercop-20120525
as recommended a while back by Dan Bernstein as offering the fastest
implementation of the crypto_sign() primitives for ARM.
Indeed this implementation IS faster. See comparison below for a
Rock 500 handset (800MHz(?) ARM6, no NEON):

Original ref/ implementation on an R500 stock rom (non-rooted)::
mean signature generation time = 96.80ms
mean signature verification time = 272.20ms

ref10/ implementations on an R500 stock rom (non-rooted):
mean signature generation time = 4.00ms
mean signature verification time = 13.00ms

Approximately 20x speed up, just like that :)
2012-10-18 17:26:48 +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
1de2bc8f23 Fix replying to broadcast mdp ping 2012-10-09 17:03:17 +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
c47e99d097 Fix issue #23, regression in 'id' command 2012-10-08 14:59:58 +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
fb7c9e5633 Fix compiler warnings on Linux gcc 4.7.1 2012-09-27 11:02:58 +09:30
Jeremy Lakeman
222cb80ce7 Modify lookup uri format to distinguish between serval identities and gateway services 2012-09-21 15:17:56 +09:30
Jeremy Lakeman
0538e95be8 Reduce the potential for packet storms 2012-09-20 10:28:01 +09:30
Jeremy Lakeman
6d31aa52e7 Use the correct public key when a new keyring is created 2012-09-18 13:43:00 +09:30
Jeremy Lakeman
456bf3fdca Tidy up source port checking 2012-09-14 17:04:35 +09:30
Jeremy Lakeman
337d428f44 Reconstruct encryption / signature flags 2012-09-14 14:41:17 +09:30
Jeremy Lakeman
7b8885fd96 Rework mdp port bindings to use subscriber struct 2012-09-14 11:49:01 +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
fbe9980199 Add explicit flag for unicast peers 2012-09-10 10:55:12 +09:30
Jeremy Lakeman
f2bae4361e Improve logging and failure handling 2012-09-10 10:31:01 +09:30
Jeremy Lakeman
3cfcfb3728 Parse mdp payloads from the middle of a frame 2012-09-07 13:45:57 +09:30
Jeremy Lakeman
dc686ad10b Set incoming packet length 2012-09-07 11:34:00 +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
1f6607af14 Refactor to avoid returning a pointer to the stack 2012-09-01 12:17:22 +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
df0e20408c Close sockets on poll errors 2012-08-31 15:04:06 +09:30