Add remaining config options to new config schema

This commit is contained in:
Andrew Bettison 2012-11-29 13:21:12 +10:30
parent b940ac8617
commit 23fff99fee
3 changed files with 47 additions and 6 deletions

View File

@ -184,14 +184,18 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "strbuf.h"
typedef unsigned long debugflags_t;
#define RHIZOME_BUNDLE_KEY_BYTES 32
#define PORT_DNA 4110
#define RHIZOME_HTTP_PORT 4110
typedef struct binarysid { unsigned char binary[SID_SIZE]; } sid_t;
typedef struct sid_binary { unsigned char binary[SID_SIZE]; } sid_t;
#define SID_NONE ((sid_t){0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0})
#define SID_BROADCAST ((sid_t){0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff})
typedef struct rhizome_bk_binary { unsigned char binary[RHIZOME_BUNDLE_KEY_BYTES]; } rhizome_bk_t;
#define RHIZOME_BK_NONE ((rhizome_bk_t){0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0})
#define INTERFACE_NAME_STRLEN 40
struct pattern_list {
unsigned patc;

View File

@ -186,6 +186,8 @@ END_STRUCT
STRUCT(server)
STRING(256, chdir, "/", opt_absolute_path,, "Absolute path of chdir(2) for server process")
STRING(256, dummy_interface_dir, "", opt_str_nonempty,, "Path of directory containing dummy interface files, either absolute or relative to instance directory")
ATOM(int, respawn_on_crash, 0, opt_boolean,, "If true, server will exec(2) itself on fatal signals, eg SEGV")
END_STRUCT
STRUCT(monitor)
@ -203,10 +205,17 @@ VALUE_SUB_STRUCT(mdp_iftype)
END_ARRAY(5)
STRUCT(mdp)
STRING(256, socket, DEFAULT_MDP_SOCKET_NAME, opt_str_nonempty,, "Name of socket for MDP client interface")
ATOM(uint32_t, ticks_per_full_address, 4, opt_uint32_nonzero,, "Ticks to elapse between announcing full SID")
SUB_STRUCT(mdp_iftypelist, iftype,)
END_STRUCT
STRUCT(olsr)
ATOM(int, enable, 1, opt_boolean,, "If true, OLSR is used for mesh routing")
ATOM(uint16_t, remote_port,4130, opt_port,, "Remote port number")
ATOM(uint16_t, local_port, 4131, opt_port,, "Local port number")
END_STRUCT
ARRAY(argv, vld_argv)
KEY_ATOM(unsigned short, opt_ushort_nonzero, cmp_ushort)
VALUE_STRING(128, opt_str)
@ -232,14 +241,29 @@ KEY_STRING(15, opt_str)
VALUE_NODE(struct config_rhizomepeer, opt_rhizome_peer)
END_ARRAY(10)
STRUCT(rhizomedirect)
STRUCT(rhizome_direct)
SUB_STRUCT(peerlist, peer,)
END_STRUCT
STRUCT(rhizome_api_addfile)
STRING(64, uri_path, "", opt_absolute_path,, "URI path for HTTP add-file request")
ATOM(struct in_addr, allow_host, (struct in_addr){htonl(INADDR_LOOPBACK)}, opt_in_addr,, "IP address of host allowed to make HTTP add-file request")
STRING(256, manifest_template_file, "", opt_str_nonempty,, "Path of manifest template file, either absolute or relative to instance directory")
ATOM(sid_t, default_author, SID_NONE, opt_sid,, "Author of add-file bundle if sender not given")
ATOM(rhizome_bk_t, bundle_secret_key, RHIZOME_BK_NONE, opt_rhizome_bk,, "Secret key of add-file bundle to try if sender not given")
END_STRUCT
STRUCT(rhizome_api)
SUB_STRUCT(rhizome_api_addfile, addfile,)
END_STRUCT
STRUCT(rhizome)
STRING(256, path, "", opt_absolute_path,, "Absolute path of rhizome directory")
ATOM(int, enabled, 1, opt_boolean,, "If true, Rhizome HTTP server is started")
SUB_STRUCT(rhizomedirect, direct,)
ATOM(int, enable, 1, opt_boolean,, "If true, Rhizome HTTP server is started")
STRING(256, datastore_path, "", opt_absolute_path,, "Absolute path of rhizome storage directory")
ATOM(uint64_t, database_size, 1000000, opt_uint64_scaled,, "Size of database in bytes")
ATOM(uint32_t, fetch_delay_ms, 50, opt_uint32_nonzero,, "Delay from receiving first bundle advert to initiating fetch")
SUB_STRUCT(rhizome_direct, direct,)
SUB_STRUCT(rhizome_api, api,)
END_STRUCT
STRUCT(directory)
@ -248,7 +272,7 @@ END_STRUCT
STRUCT(host)
STRING(INTERFACE_NAME_STRLEN, interface, "", opt_str_nonempty, MANDATORY, "Interface name")
ATOM(struct in_addr, address, (struct in_addr){0}, opt_in_addr, MANDATORY, "Host IP address")
ATOM(struct in_addr, address, (struct in_addr){htonl(INADDR_NONE)}, opt_in_addr, MANDATORY, "Host IP address")
ATOM(uint16_t, port, PORT_DNA, opt_port,, "Port number")
END_STRUCT
@ -271,6 +295,7 @@ KEY_STRING(15, opt_str)
VALUE_SUB_STRUCT(network_interface)
END_ARRAY(10)
// The top level.
STRUCT(main)
NODE_STRUCT(interface_list, interfaces, opt_interface_list, MANDATORY)
SUB_STRUCT(log, log,)

View File

@ -422,6 +422,7 @@ int opt_protocol(char *str, size_t len, const char *text);
int opt_in_addr(struct in_addr *addrp, const char *text);
int opt_port(unsigned short *portp, const char *text);
int opt_sid(sid_t *sidp, const char *text);
int opt_rhizome_bk(rhizome_bk_t *bkp, const char *text);
int opt_interface_type(short *typep, const char *text);
int opt_pattern_list(struct pattern_list *listp, const char *text);
int opt_interface_list(struct config_interface_list *listp, const struct cf_om_node *node);
@ -723,6 +724,16 @@ int opt_sid(sid_t *sidp, const char *text)
return CFOK;
}
int opt_rhizome_bk(rhizome_bk_t *bkp, const char *text)
{
rhizome_bk_t sid;
if (!rhizome_str_is_bundle_key(text))
return CFINVALID;
size_t n = fromhex(bkp->binary, text, RHIZOME_BUNDLE_KEY_BYTES);
assert(n == RHIZOME_BUNDLE_KEY_BYTES);
return CFOK;
}
int opt_interface_type(short *typep, const char *text)
{
if (strcasecmp(text, "ethernet") == 0) {
@ -1178,6 +1189,7 @@ int main(int argc, char **argv)
DEBUGF("config.server.chdir = %s", alloca_str(config.server.chdir));
DEBUGF("config.debug = %llx", (unsigned long long) config.debug);
DEBUGF("config.directory.service = %s", alloca_tohex(config.directory.service.binary, SID_SIZE));
DEBUGF("config.rhizome.api.addfile.allow_host = %s", inet_ntoa(config.rhizome.api.addfile.allow_host));
int j;
for (j = 0; j < config.mdp.iftype.ac; ++j) {
DEBUGF("config.mdp.iftype.%u", config.mdp.iftype.av[j].key);