Commit Graph

1720 Commits

Author SHA1 Message Date
Andrew Bettison
c53789d764 Legacy 'interfaces' config option improvements
Legacy form is now incompatible with modern form.

Test case to check legacy parsing.
2012-12-04 18:22:26 +10:30
Andrew Bettison
93c38a764d Improve servald 'config' 'set' and 'del' commands
Return exit status 2 if the new config is invalid in any way.
2012-12-04 18:20:53 +10:30
Andrew Bettison
71ed78e058 Make all 'config' tests pass
Change a test case: configuration options are now case sensitive.

Fix config file load and parse logic in conf.c, always copy 'debug' flags
from config.debug.

The config schema 'interfaces' option is no longer MANDATORY.

Introduce new CLIFLAG_PERMISSIVE_CONFIG to supress bad-config ERROR messages
from the 'config set' and 'config get' commands.

Refactor cli_execute() into cli_parse() and cli_invoke().  Use *const* struct
command_line_option everywhere.
2012-12-04 16:52:49 +10:30
Andrew Bettison
caa209fc1d Integrate new config into servald
Not passing any tests yet, but compiles and links and simple uses do not
SEGV.
2012-12-04 14:12:28 +10:30
Andrew Bettison
d3c2205d44 Add os.c and "os.h", replacing mkdirs.c
The new header "os.h" defines a supplemental API around existing basic
operating system services (system calls and standard library functions).

Moved some function prototypes from serval.h and net.h into os.h.

This allows non-servald executables to take advantage of this API without
having to include serval.h and bringing in all the other servald link-time
baggage.
2012-12-04 10:12:35 +10:30
Andrew Bettison
5139d8d34d Add mem.c and "mem.h" with emalloc() etc. 2012-12-04 10:03:32 +10:30
Andrew Bettison
f995a2a42d More strbuf helper functions
strbuf_append_argv()

strbuf_path_join()
2012-12-04 09:47:39 +10:30
Andrew Bettison
4aac3637ed Improve new config code, SORTED and NO_DUPLICATE flags
Config Object Model parser now returns bitmask result of CFxxx flags and only
allocates root node if the config file is non-empty.

Added emalloc_zero().
2012-11-30 12:32:30 +10:30
Andrew Bettison
f42292ffc6 Refactor emalloc() etc. into mem.c/.h 2012-11-29 17:12:43 +10:30
Andrew Bettison
3686a4ade4 Improve new config code to use "log.h"
With all the __whence/__WHENCE__ goodness, ready for integration into servald.
2012-11-29 16:44:06 +10:30
Andrew Bettison
f654d435b1 Rename some new config source and header files 2012-11-29 16:12:03 +10:30
Andrew Bettison
2853d346f1 Re-organise new config code some more
Split into several source .c files, leave throw-away code in config_test.c.
2012-11-29 16:07:34 +10:30
Andrew Bettison
32debf57ef Reorganise and rename new config code ready for integration 2012-11-29 14:33:32 +10:30
Andrew Bettison
fdb3249522 Improve toprint_str() function
If supplied string pointer is null, return "NULL" result instead of SEGV.
2012-11-29 14:32:43 +10:30
Andrew Bettison
23fff99fee Add remaining config options to new config schema 2012-11-29 13:21:12 +10:30
Andrew Bettison
b940ac8617 Improve new config prototype code
Sort ARRAYs if optional key comparison function is given in schema, no longer
the role of the validator function.
2012-11-29 11:48:01 +10:30
Andrew Bettison
e2f6989fe8 Improve new config prototype code
Rework ARRAYs, replacing label string with typed key, declaring KEY and VALUE
independently.

Implement dna.helper.argv array using key of type unsigned short.

Implement mdp.iftype.<interfacetype>.tick_ms using key of type short for the
interface type code.
2012-11-29 09:24:02 +10:30
Andrew Bettison
58bf0e1752 Improve new config prototype code
Add hosts.SIDHEX.{interface,network,port} config options.
2012-11-29 06:28:28 +10:30
Andrew Bettison
e7cda64190 Improve new config prototype code
The dna.helper.argv validation function now sorts the array in numerical order
of labels using qsort(3).

Add LABELLEN argument to ARRAY schema macros, to control the size of the
label[] string (was fixed at 41 chars before).
2012-11-29 05:47:52 +10:30
Andrew Bettison
c6b2efe396 Improve new config prototype code
Add monitor.socket and monitor.uid to schema.

Remove some deprecated warning functions.
2012-11-28 18:13:53 +10:30
Andrew Bettison
af6a912a1f Improve new config prototype code
Implement dna.helper.argv array label validation.

Ignore comment lines starting with '#'.
2012-11-28 17:54:19 +10:30
Andrew Bettison
8e8a3b1ea2 Improve new config prototype code
Add label parser functions to ARRAY schema, use to enforce numeric argv labels
numbered from 1.
2012-11-27 18:10:51 +10:30
Andrew Bettison
479ec5d0df Improve new config prototype code
Add optional validator functions for STRUCT and ARRAY parsing.  Tighten up
logic for parsing STRUCTs and ARRAYs and the result flags.  Improve
documentation in block comments.  Add CFUNSUPPORTED result flag.
2012-11-27 16:47:30 +10:30
Andrew Bettison
cf3c069f83 Improve new config prototype code
Refactor ARRAY_xxx() schema declaration macros to fix problem in ARRAY_STRING().

Add dna.helper.executable, dna.helper.argv and server.chdir to config schema.
2012-11-26 17:33:54 +10:30
Andrew Bettison
0091cf082b Add documentation comments for new config code 2012-11-26 16:15:59 +10:30
Andrew Bettison
8479c52f54 Improve new config prototype code
Replace ARRAY() macro with ARRAY_ATOM(), ARRAY_STRING(), ARRAY_NODE() and
ARRAY_STRUCT().

Change parse function return value to flag bits, add CFEMPTY, rename CFMISSING
to CFINCOMPLETE, improve logic around mandatory struct items.

Renamed struct config_node to struct cf_om_node.
2012-11-26 16:12:46 +10:30
Andrew Bettison
2d7766eacd Improve new config prototype code
Finish parsing 'interfaces' old- and new-style.
2012-11-24 03:38:10 +10:30
Andrew Bettison
98c3af967d Improve new config prototype code
Refactor and rename, improve logic for reporting unsupported nodes.
2012-11-23 19:13:02 +10:30
Andrew Bettison
8c36b23417 Improve new config prototype code
Refactor to make opt_parsing() functions simpler for ATOM -- no need to check
for missing text or unsupported child nodes, or log parse failures.

Introduce NODE option which passes whole config_node struct to parsing
function.
2012-11-23 10:11:07 +10:30
Andrew Bettison
70531fccb6 Improve new config prototype code
Make config LISTs more flexible.  Start implementing existing config options:
directory.service (SID parsing), interfaces (better list logic).
2012-11-22 18:20:13 +10:30
Andrew Bettison
ef03eb1a3e Re-organise Makefile header dependencies
Add str.h to list of Serval header files.  Make the NaCl objects not dependent
on Serval header files, so that the entire NaCl source does not get re-built
when editing serval.h or str.h etc.
2012-11-22 18:18:00 +10:30
Andrew Bettison
494a766b9e Improve str.h and str.c
Move alloca_tohex() from serval.h into str.h so it can be used stand-alone.

Rename str_to_ll_scaled() to str_to_int64_scaled().  Add str_to_uint64_scaled()
and scale_factor().

Add a few more URI parsing functions.  Move some functions out of str.c and
into str.h as inline functions.
2012-11-22 18:15:40 +10:30
Andrew Bettison
1fbf7001d1 Move packet-related functions from dataformats.c to packetformats.c
So that dataformats.o can be linked into executables that don't have log.o.
2012-11-22 18:11:21 +10:30
Andrew Bettison
a3cdf17410 Improve new config prototype, add LIST to schema 2012-11-21 18:09:05 +10:30
Andrew Bettison
960a6293e1 Move str_is_uri() from dataformats.c to str.c
Add lots of URI unpacking functions as well.
2012-11-21 18:08:06 +10:30
Andrew Bettison
f78098afd8 Prototype code for new config parser 2012-11-20 18:10:38 +10:30
Andrew Bettison
c84b7e5db4 Improve str.h functions
Add strn_startswith() and strncase_startswith().

Make all str*_startswith() functions take const char * arguments, to make it
possible to do safe programming with consts.
2012-11-20 18:10:08 +10:30
Andrew Bettison
0e435683f7 Move toprint functions from log.h to str.h
Move alloca_sockaddr() to strbuf_helpers.h

So that stand-alone executables can use them without pulling in the entire
logging framework.
2012-11-20 18:10:08 +10:30
Jeremy Lakeman
d6336597ee fd_poll now returns zero when there is nothing to do 2012-11-20 16:09:12 +10:30
Jeremy Lakeman
7322fbce71 Fix ping message format 2012-11-20 10:25:33 +10:30
Jeremy Lakeman
3dc831481e Degrade link score to zero within 20 seconds 2012-11-16 15:54:01 +10:30
Jeremy Lakeman
1df18ae43d Better tree walking for duplicate results 2012-11-16 15:39:33 +10:30
Jeremy Lakeman
6599835331 Squelch debug log message 2012-11-16 13:20:32 +10:30
Andrew Bettison
21a0f31ae4 Merge branch 'whacktmps' into 'master' 2012-11-15 13:41:45 +10:30
Andrew Bettison
6395f757cc Fix bugs in earlier conf/log recursion logic
Reinstate better recursion control in conf.c, remove from log.c.

Add <kludge> comment to "config set" code, add the same kludge to "config
del".
2012-11-15 12:38:17 +10:30
Andrew Bettison
f2d6c6d522 Kludge "config set" to fix Batphone upgrade bug 2012-11-14 13:16:23 +10:30
Andrew Bettison
9c69eaca1c Improve logic to avoid log/config infinite recursion
Put logic in log.c, remove from conf.c.  Now messages logged while logging
another message will get appended to the log buffer, and eventually flushed.
2012-11-14 13:16:23 +10:30
Jeremy Lakeman
7c6cdac1b2 Improve command line usage information 2012-11-14 12:27:47 +10:30
Jeremy Lakeman
10bde11918 Remove resolution of peer details from node info command 2012-11-14 12:17:41 +10:30
Jeremy Lakeman
dd93f201e3 Add separate reverse lookup command 2012-11-14 12:17:14 +10:30