summaryrefslogtreecommitdiff
path: root/src/config.c
diff options
context:
space:
mode:
authorAlfred E. Heggestad <aeh@db.org>2016-06-06 10:14:12 +0200
committerAlfred E. Heggestad <aeh@db.org>2016-06-06 10:14:12 +0200
commit6910d50e9b1e80fe758b259149012e7e062eecd0 (patch)
treeaecd149deed8ae71349e3b2e626e53f57a9c974a /src/config.c
parent362914f55831f4ad3afd7c0cad8f01f2f8b4892c (diff)
net: make networking code re-entrant
- The network instance is now in struct network and does not use any local/static data - A new top-level struct in baresip.c owns the single instance of struct network it is a long-term goal to remove all local/static data from libbaresip and make it fully re-entrant.
Diffstat (limited to 'src/config.c')
-rw-r--r--src/config.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/config.c b/src/config.c
index b1506f9..ed4db42 100644
--- a/src/config.c
+++ b/src/config.c
@@ -94,22 +94,25 @@ static int range_print(struct re_printf *pf, const struct range *rng)
static int dns_server_handler(const struct pl *pl, void *arg)
{
+ struct config_net *cfg = arg;
struct sa sa;
int err;
- (void)arg;
-
err = sa_decode(&sa, pl->p, pl->l);
if (err) {
warning("config: dns_server: could not decode `%r'\n", pl);
return err;
}
- err = net_dnssrv_add(&sa);
- if (err) {
- warning("config: failed to add nameserver %r: %m\n", pl, err);
+ if (cfg->nsc >= ARRAY_SIZE(cfg->nsv)) {
+ warning("config: too many DNS nameservers (max %zu)\n",
+ ARRAY_SIZE(cfg->nsv));
+ return EOVERFLOW;
}
+ /* Append dns_server to the network config */
+ cfg->nsv[cfg->nsc++] = sa;
+
return err;
}
@@ -216,7 +219,7 @@ int config_parse_conf(struct config *cfg, const struct conf *conf)
}
/* Network */
- (void)conf_apply(conf, "dns_server", dns_server_handler, NULL);
+ (void)conf_apply(conf, "dns_server", dns_server_handler, &cfg->net);
(void)conf_get_str(conf, "net_interface",
cfg->net.ifname, sizeof(cfg->net.ifname));