mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-29 15:43:56 +00:00
New config type: bool_t (char)
Replace 'int_boolean' and 'char_boolean' representations with 'boolean'. Clean up spacing and column alignment in conf_schema.h
This commit is contained in:
parent
4cdd3da77f
commit
c9f9ef5ed4
9
conf.h
9
conf.h
@ -194,6 +194,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#include "serval.h"
|
||||
#include "rhizome.h"
|
||||
|
||||
typedef char bool_t;
|
||||
|
||||
#define CONFIG_FILE_MAX_SIZE (32 * 1024)
|
||||
#define INTERFACE_NAME_STRLEN 40
|
||||
|
||||
@ -519,11 +521,8 @@ struct pattern_list {
|
||||
#undef VALUE_NODE_STRUCT
|
||||
#undef END_ARRAY
|
||||
|
||||
int cf_opt_char_boolean(char *booleanp, const char *text);
|
||||
int cf_fmt_char_boolean(const char **, const char *booleanp);
|
||||
|
||||
int cf_opt_int_boolean(int *booleanp, const char *text);
|
||||
int cf_fmt_int_boolean(const char **, const int *booleanp);
|
||||
int cf_opt_boolean(bool_t *booleanp, const char *text);
|
||||
int cf_fmt_boolean(const char **, const bool_t *booleanp);
|
||||
|
||||
int cf_opt_absolute_path(char *str, size_t len, const char *text);
|
||||
int cf_fmt_absolute_path(const char **, const char *path);
|
||||
|
@ -32,7 +32,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#include "strbuf_helpers.h"
|
||||
#include "conf.h"
|
||||
|
||||
int cf_opt_char_boolean(char *booleanp, const char *text)
|
||||
int cf_opt_boolean(bool_t *booleanp, const char *text)
|
||||
{
|
||||
if (!strcasecmp(text, "true") || !strcasecmp(text, "yes") || !strcasecmp(text, "on") || !strcasecmp(text, "1")) {
|
||||
*booleanp = 1;
|
||||
@ -45,7 +45,7 @@ int cf_opt_char_boolean(char *booleanp, const char *text)
|
||||
return CFINVALID;
|
||||
}
|
||||
|
||||
int cf_fmt_char_boolean(const char **textp, const char *booleanp)
|
||||
int cf_fmt_boolean(const char **textp, const bool_t *booleanp)
|
||||
{
|
||||
if (*booleanp == 1) {
|
||||
*textp = str_edup("true");
|
||||
@ -58,34 +58,7 @@ int cf_fmt_char_boolean(const char **textp, const char *booleanp)
|
||||
return CFINVALID;
|
||||
}
|
||||
|
||||
int cf_cmp_char_boolean(const char *a, const char *b)
|
||||
{
|
||||
return !*a && *b ? -1 : *a && !*b ? 1 : 0;
|
||||
}
|
||||
|
||||
int cf_opt_int_boolean(int *booleanp, const char *text)
|
||||
{
|
||||
char b;
|
||||
int ret = cf_opt_char_boolean(&b, text);
|
||||
if (ret == CFOK)
|
||||
*booleanp = b;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int cf_fmt_int_boolean(const char **textp, const int *booleanp)
|
||||
{
|
||||
if (*booleanp == 1) {
|
||||
*textp = str_edup("true");
|
||||
return CFOK;
|
||||
}
|
||||
else if (*booleanp == 0) {
|
||||
*textp = str_edup("false");
|
||||
return CFOK;
|
||||
}
|
||||
return CFINVALID;
|
||||
}
|
||||
|
||||
int cf_cmp_int_boolean(const int *a, const int *b)
|
||||
int cf_cmp_boolean(const bool_t *a, const bool_t *b)
|
||||
{
|
||||
return !*a && *b ? -1 : *a && !*b ? 1 : 0;
|
||||
}
|
||||
|
150
conf_schema.h
150
conf_schema.h
@ -189,53 +189,53 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
STRUCT(debug)
|
||||
ATOM(char, verbose, 0, char_boolean,, "")
|
||||
ATOM(char, dnaresponses, 0, char_boolean,, "")
|
||||
ATOM(char, dnahelper, 0, char_boolean,, "")
|
||||
ATOM(char, queues, 0, char_boolean,, "")
|
||||
ATOM(char, timing, 0, char_boolean,, "")
|
||||
ATOM(char, io, 0, char_boolean,, "")
|
||||
ATOM(char, verbose_io, 0, char_boolean,, "")
|
||||
ATOM(char, packetformats, 0, char_boolean,, "")
|
||||
ATOM(char, gateway, 0, char_boolean,, "")
|
||||
ATOM(char, keyring, 0, char_boolean,, "")
|
||||
ATOM(char, security, 0, char_boolean,, "")
|
||||
ATOM(char, mdprequests, 0, char_boolean,, "")
|
||||
ATOM(char, peers, 0, char_boolean,, "")
|
||||
ATOM(char, overlayframes, 0, char_boolean,, "")
|
||||
ATOM(char, overlayabbreviations, 0, char_boolean,, "")
|
||||
ATOM(char, overlayrouting, 0, char_boolean,, "")
|
||||
ATOM(char, overlayroutemonitor, 0, char_boolean,, "")
|
||||
ATOM(char, overlayinterfaces, 0, char_boolean,, "")
|
||||
ATOM(char, broadcasts, 0, char_boolean,, "")
|
||||
ATOM(char, packettx, 0, char_boolean,, "")
|
||||
ATOM(char, packetrx, 0, char_boolean,, "")
|
||||
ATOM(char, packetradio, 0, char_boolean,, "")
|
||||
ATOM(char, rejecteddata, 0, char_boolean,, "")
|
||||
ATOM(char, slip, 0, char_boolean,, "")
|
||||
ATOM(char, slipdecode, 0, char_boolean,, "")
|
||||
ATOM(char, packetconstruction, 0, char_boolean,, "")
|
||||
ATOM(char, rhizome, 0, char_boolean,, "")
|
||||
ATOM(char, rhizome_tx, 0, char_boolean,, "")
|
||||
ATOM(char, rhizome_rx, 0, char_boolean,, "")
|
||||
ATOM(char, rhizome_ads, 0, char_boolean,, "")
|
||||
ATOM(char, manifests, 0, char_boolean,, "")
|
||||
ATOM(char, vomp, 0, char_boolean,, "")
|
||||
ATOM(char, trace, 0, char_boolean,, "")
|
||||
ATOM(char, profiling, 0, char_boolean,, "")
|
||||
ATOM(char, externalblobs, 0, char_boolean,, "")
|
||||
ATOM(bool_t, verbose, 0, boolean,, "")
|
||||
ATOM(bool_t, dnaresponses, 0, boolean,, "")
|
||||
ATOM(bool_t, dnahelper, 0, boolean,, "")
|
||||
ATOM(bool_t, queues, 0, boolean,, "")
|
||||
ATOM(bool_t, timing, 0, boolean,, "")
|
||||
ATOM(bool_t, io, 0, boolean,, "")
|
||||
ATOM(bool_t, verbose_io, 0, boolean,, "")
|
||||
ATOM(bool_t, packetformats, 0, boolean,, "")
|
||||
ATOM(bool_t, gateway, 0, boolean,, "")
|
||||
ATOM(bool_t, keyring, 0, boolean,, "")
|
||||
ATOM(bool_t, security, 0, boolean,, "")
|
||||
ATOM(bool_t, mdprequests, 0, boolean,, "")
|
||||
ATOM(bool_t, peers, 0, boolean,, "")
|
||||
ATOM(bool_t, overlayframes, 0, boolean,, "")
|
||||
ATOM(bool_t, overlayabbreviations, 0, boolean,, "")
|
||||
ATOM(bool_t, overlayrouting, 0, boolean,, "")
|
||||
ATOM(bool_t, overlayroutemonitor, 0, boolean,, "")
|
||||
ATOM(bool_t, overlayinterfaces, 0, boolean,, "")
|
||||
ATOM(bool_t, broadcasts, 0, boolean,, "")
|
||||
ATOM(bool_t, packettx, 0, boolean,, "")
|
||||
ATOM(bool_t, packetrx, 0, boolean,, "")
|
||||
ATOM(bool_t, packetradio, 0, boolean,, "")
|
||||
ATOM(bool_t, rejecteddata, 0, boolean,, "")
|
||||
ATOM(bool_t, slip, 0, boolean,, "")
|
||||
ATOM(bool_t, slipdecode, 0, boolean,, "")
|
||||
ATOM(bool_t, packetconstruction, 0, boolean,, "")
|
||||
ATOM(bool_t, rhizome, 0, boolean,, "")
|
||||
ATOM(bool_t, rhizome_tx, 0, boolean,, "")
|
||||
ATOM(bool_t, rhizome_rx, 0, boolean,, "")
|
||||
ATOM(bool_t, rhizome_ads, 0, boolean,, "")
|
||||
ATOM(bool_t, manifests, 0, boolean,, "")
|
||||
ATOM(bool_t, vomp, 0, boolean,, "")
|
||||
ATOM(bool_t, trace, 0, boolean,, "")
|
||||
ATOM(bool_t, profiling, 0, boolean,, "")
|
||||
ATOM(bool_t, externalblobs, 0, boolean,, "")
|
||||
END_STRUCT
|
||||
|
||||
STRUCT(log)
|
||||
STRING(256, file, "", str_nonempty,, "Path of log file, either absolute or relative to instance directory")
|
||||
ATOM(int, show_pid, 1, int_boolean,, "If true, all log lines contain PID of logging process")
|
||||
ATOM(int, show_time, 1, int_boolean,, "If true, all log lines contain time stamp")
|
||||
ATOM(bool_t, show_pid, 1, boolean,, "If true, all log lines contain PID of logging process")
|
||||
ATOM(bool_t, show_time, 1, boolean,, "If true, all log lines contain time stamp")
|
||||
END_STRUCT
|
||||
|
||||
STRUCT(server)
|
||||
STRING(256, chdir, "/", absolute_path,, "Absolute path of chdir(2) for server process")
|
||||
STRING(256, interface_path, "", str_nonempty,, "Path of directory containing interface files, either absolute or relative to instance directory")
|
||||
ATOM(int, respawn_on_crash, 0, int_boolean,, "If true, server will exec(2) itself on fatal signals, eg SEGV")
|
||||
ATOM(bool_t, respawn_on_crash, 0, boolean,, "If true, server will exec(2) itself on fatal signals, eg SEGV")
|
||||
END_STRUCT
|
||||
|
||||
STRUCT(monitor)
|
||||
@ -244,7 +244,7 @@ ATOM(uint32_t, uid, 0, uint32_nonzero,, "Allowed UID for mon
|
||||
END_STRUCT
|
||||
|
||||
STRUCT(mdp_iftype)
|
||||
ATOM(uint32_t, tick_ms, -1, uint32_nonzero,, "Tick interval for this interface type")
|
||||
ATOM(uint32_t, tick_ms, -1, uint32_nonzero,, "Tick interval for this interface type")
|
||||
ATOM(int32_t, packet_interval, -1, int32_nonneg,, "Minimum interval between packets in microseconds")
|
||||
END_STRUCT
|
||||
|
||||
@ -259,9 +259,9 @@ SUB_STRUCT(mdp_iftypelist, iftype,)
|
||||
END_STRUCT
|
||||
|
||||
STRUCT(olsr)
|
||||
ATOM(int, enable, 1, int_boolean,, "If true, OLSR is used for mesh routing")
|
||||
ATOM(uint16_t, remote_port,4130, uint16_nonzero,, "Remote port number")
|
||||
ATOM(uint16_t, local_port, 4131, uint16_nonzero,, "Local port number")
|
||||
ATOM(bool_t, enable, 1, boolean,, "If true, OLSR is used for mesh routing")
|
||||
ATOM(uint16_t, remote_port, 4130, uint16_nonzero,, "Remote port number")
|
||||
ATOM(uint16_t, local_port, 4131, uint16_nonzero,, "Local port number")
|
||||
END_STRUCT
|
||||
|
||||
ARRAY(argv, NO_DUPLICATES, vld_argv)
|
||||
@ -294,11 +294,11 @@ SUB_STRUCT(peerlist, peer,)
|
||||
END_STRUCT
|
||||
|
||||
STRUCT(rhizome_api_addfile)
|
||||
STRING(64, uri_path, "", absolute_path,, "URI path for HTTP add-file request")
|
||||
ATOM(struct in_addr, allow_host, hton_in_addr(INADDR_LOOPBACK), in_addr,, "IP address of host allowed to make HTTP add-file request")
|
||||
STRING(64, uri_path, "", absolute_path,, "URI path for HTTP add-file request")
|
||||
ATOM(struct in_addr, allow_host, hton_in_addr(INADDR_LOOPBACK), in_addr,, "IP address of host allowed to make HTTP add-file request")
|
||||
STRING(256, manifest_template_file, "", str_nonempty,, "Path of manifest template file, either absolute or relative to instance directory")
|
||||
ATOM(sid_t, default_author, SID_ANY, sid,, "Author of add-file bundle if sender not given")
|
||||
ATOM(rhizome_bk_t, bundle_secret_key, RHIZOME_BK_NONE, rhizome_bk,, "Secret key of add-file bundle to try if sender not given")
|
||||
ATOM(sid_t, default_author, SID_ANY, sid,, "Author of add-file bundle if sender not given")
|
||||
ATOM(rhizome_bk_t, bundle_secret_key, RHIZOME_BK_NONE, rhizome_bk,, "Secret key of add-file bundle to try if sender not given")
|
||||
END_STRUCT
|
||||
|
||||
STRUCT(rhizome_api)
|
||||
@ -306,29 +306,29 @@ SUB_STRUCT(rhizome_api_addfile, addfile,)
|
||||
END_STRUCT
|
||||
|
||||
STRUCT(rhizome_http)
|
||||
ATOM(int, enable, 1, int_boolean,, "If true, Rhizome HTTP server is started")
|
||||
ATOM(bool_t, enable, 1, boolean,, "If true, Rhizome HTTP server is started")
|
||||
END_STRUCT
|
||||
|
||||
STRUCT(rhizome_mdp)
|
||||
ATOM(int, enable, 1, int_boolean,, "If true, Rhizome MDP server is started")
|
||||
ATOM(bool_t, enable, 1, boolean,, "If true, Rhizome MDP server is started")
|
||||
END_STRUCT
|
||||
|
||||
STRUCT(rhizome_advertise)
|
||||
ATOM(int, enable, 1, int_boolean,, "If true, Rhizome advertisements are sent")
|
||||
ATOM(bool_t, enable, 1, boolean,, "If true, Rhizome advertisements are sent")
|
||||
ATOM(uint32_t, interval, 500, uint32_nonzero,, "Interval between Rhizome advertisements")
|
||||
END_STRUCT
|
||||
|
||||
STRUCT(rhizome)
|
||||
ATOM(int, enable, 1, int_boolean,, "If true, server opens Rhizome database when starting")
|
||||
ATOM(char, fetch, 1, char_boolean,, "If false, no new bundles will be fetched from peers")
|
||||
ATOM(int, clean_on_open, 1, int_boolean,, "If true, Rhizome database is cleaned at start of every command")
|
||||
ATOM(bool_t, enable, 1, boolean,, "If true, server opens Rhizome database when starting")
|
||||
ATOM(bool_t, fetch, 1, boolean,, "If false, no new bundles will be fetched from peers")
|
||||
ATOM(bool_t, clean_on_open, 1, boolean,, "If true, Rhizome database is cleaned at start of every command")
|
||||
STRING(256, datastore_path, "", absolute_path,, "Path of rhizome storage directory, absolute or relative to instance directory")
|
||||
ATOM(uint64_t, database_size, 1000000, uint64_scaled,, "Size of database in bytes")
|
||||
ATOM(char, external_blobs, 0, char_boolean,, "Store rhizome bundles as separate files.")
|
||||
ATOM(uint64_t, database_size, 1000000, uint64_scaled,, "Size of database in bytes")
|
||||
ATOM(bool_t, external_blobs, 0, boolean,, "Store rhizome bundles as separate files.")
|
||||
|
||||
ATOM(uint64_t, rhizome_mdp_block_size, 512, uint64_scaled,, "Rhizome MDP block size.")
|
||||
ATOM(uint64_t, idle_timeout, RHIZOME_IDLE_TIMEOUT, uint64_scaled,, "Rhizome transfer timeout if no data received.")
|
||||
ATOM(uint32_t, fetch_delay_ms, 50, uint32_nonzero,, "Delay from receiving first bundle advert to initiating fetch")
|
||||
ATOM(uint64_t, idle_timeout, RHIZOME_IDLE_TIMEOUT, uint64_scaled,, "Rhizome transfer timeout if no data received.")
|
||||
ATOM(uint32_t, fetch_delay_ms, 50, uint32_nonzero,, "Delay from receiving first bundle advert to initiating fetch")
|
||||
SUB_STRUCT(rhizome_direct, direct,)
|
||||
SUB_STRUCT(rhizome_api, api,)
|
||||
SUB_STRUCT(rhizome_http, http,)
|
||||
@ -342,9 +342,9 @@ END_STRUCT
|
||||
|
||||
STRUCT(host)
|
||||
STRING(INTERFACE_NAME_STRLEN, interface, "", str_nonempty,, "Interface name")
|
||||
STRING(256, host, "", str_nonempty,, "Host Name")
|
||||
ATOM(struct in_addr, address, hton_in_addr(INADDR_NONE), in_addr,, "Host IP address")
|
||||
ATOM(uint16_t, port, PORT_DNA, uint16_nonzero,, "Port number")
|
||||
STRING(256, host, "", str_nonempty,, "Host Name")
|
||||
ATOM(struct in_addr, address, hton_in_addr(INADDR_NONE), in_addr,, "Host IP address")
|
||||
ATOM(uint16_t, port, PORT_DNA, uint16_nonzero,, "Port number")
|
||||
END_STRUCT
|
||||
|
||||
ARRAY(host_list, NO_DUPLICATES)
|
||||
@ -353,22 +353,22 @@ VALUE_SUB_STRUCT(host)
|
||||
END_ARRAY(32)
|
||||
|
||||
STRUCT(network_interface, vld_network_interface)
|
||||
ATOM(int, exclude, 0, int_boolean,, "If true, do not use matching interfaces")
|
||||
ATOM(struct pattern_list, match, PATTERN_LIST_EMPTY, pattern_list,, "Names that match network interface")
|
||||
ATOM(short, socket_type, SOCK_UNSPECIFIED, socket_type,, "Type of network socket")
|
||||
ATOM(short, encapsulation, ENCAP_OVERLAY, encapsulation,, "Type of packet encapsulation")
|
||||
STRING(256, file, "", str_nonempty,, "Path of interface file, absolute or relative to server.interface_path")
|
||||
ATOM(struct in_addr, dummy_address, hton_in_addr(INADDR_LOOPBACK), in_addr,, "Dummy interface address")
|
||||
ATOM(struct in_addr, dummy_netmask, hton_in_addr(0xFFFFFF00), in_addr,, "Dummy interface netmask")
|
||||
ATOM(uint16_t, port, PORT_DNA, uint16_nonzero,, "Port number for network interface")
|
||||
ATOM(char, drop_broadcasts, 0, char_boolean,, "If true, drop all incoming broadcast packets")
|
||||
ATOM(char, drop_unicasts, 0, char_boolean,, "If true, drop all incoming unicast packets")
|
||||
ATOM(short, type, OVERLAY_INTERFACE_WIFI, interface_type,, "Type of network interface")
|
||||
ATOM(int32_t, packet_interval, -1, int32_nonneg,, "Minimum interval between packets in microseconds")
|
||||
ATOM(int32_t, mdp_tick_ms, -1, int32_nonneg,, "Override MDP tick interval for this interface")
|
||||
ATOM(char, send_broadcasts, 1, char_boolean,, "If false, don't send any broadcast packets")
|
||||
ATOM(char, default_route, 0, char_boolean,, "If true, use this interface as a default route")
|
||||
ATOM(char, prefer_unicast, 0, char_boolean,, "If true, send unicast data as unicast IP packets if available")
|
||||
ATOM(bool_t, exclude, 0, boolean,, "If true, do not use matching interfaces")
|
||||
ATOM(struct pattern_list, match, PATTERN_LIST_EMPTY, pattern_list,, "Names that match network interface")
|
||||
ATOM(short, socket_type, SOCK_UNSPECIFIED, socket_type,, "Type of network socket")
|
||||
ATOM(short, encapsulation, ENCAP_OVERLAY, encapsulation,, "Type of packet encapsulation")
|
||||
STRING(256, file, "", str_nonempty,, "Path of interface file, absolute or relative to server.interface_path")
|
||||
ATOM(struct in_addr, dummy_address, hton_in_addr(INADDR_LOOPBACK), in_addr,, "Dummy interface address")
|
||||
ATOM(struct in_addr, dummy_netmask, hton_in_addr(0xFFFFFF00), in_addr,, "Dummy interface netmask")
|
||||
ATOM(uint16_t, port, PORT_DNA, uint16_nonzero,, "Port number for network interface")
|
||||
ATOM(bool_t, drop_broadcasts, 0, boolean,, "If true, drop all incoming broadcast packets")
|
||||
ATOM(bool_t, drop_unicasts, 0, boolean,, "If true, drop all incoming unicast packets")
|
||||
ATOM(short, type, OVERLAY_INTERFACE_WIFI, interface_type,, "Type of network interface")
|
||||
ATOM(int32_t, packet_interval, -1, int32_nonneg,, "Minimum interval between packets in microseconds")
|
||||
ATOM(int32_t, mdp_tick_ms, -1, int32_nonneg,, "Override MDP tick interval for this interface")
|
||||
ATOM(bool_t, send_broadcasts, 1, boolean,, "If false, don't send any broadcast packets")
|
||||
ATOM(bool_t, default_route, 0, boolean,, "If true, use this interface as a default route")
|
||||
ATOM(bool_t, prefer_unicast, 0, boolean,, "If true, send unicast data as unicast IP packets if available")
|
||||
END_STRUCT
|
||||
|
||||
ARRAY(interface_list, NO_DUPLICATES)
|
||||
|
@ -67,13 +67,13 @@ To examine all configuration option settings:
|
||||
To list all supported configuration options:
|
||||
|
||||
$ servald config schema
|
||||
debug.broadcasts=(cf_opt_char_boolean)
|
||||
debug.dnahelper=(cf_opt_char_boolean)
|
||||
debug.dnaresponses=(cf_opt_char_boolean)
|
||||
debug.broadcasts=(boolean)
|
||||
debug.dnahelper=(boolean)
|
||||
debug.dnaresponses=(boolean)
|
||||
...
|
||||
server.chdir=(cf_opt_absolute_path)
|
||||
server.dummy_interface_dir=(cf_opt_str_nonempty)
|
||||
server.respawn_on_crash=(cf_opt_int_boolean)
|
||||
server.chdir=(absolute_path)
|
||||
server.dummy_interface_dir=(str_nonempty)
|
||||
server.respawn_on_crash=(boolean)
|
||||
$
|
||||
|
||||
The configuration schema is defined in the [conf_schema.h](../conf_schema.h)
|
||||
|
Loading…
x
Reference in New Issue
Block a user