Allow using key & configuration parser from tincd in tinc.
[tinc] / src / conf_net.c
1 #include "conf_net.h"
2 #include "logger.h"
3
4 bool get_config_subnet(const config_t *cfg, subnet_t **result) {
5         subnet_t subnet = {0};
6
7         if(!cfg) {
8                 return false;
9         }
10
11         if(!str2net(&subnet, cfg->value)) {
12                 logger(DEBUG_ALWAYS, LOG_ERR, "Subnet expected for configuration variable %s in %s line %d",
13                        cfg->variable, cfg->file, cfg->line);
14                 return false;
15         }
16
17         if(subnetcheck(subnet)) {
18                 *(*result = new_subnet()) = subnet;
19                 return true;
20         }
21
22         logger(DEBUG_ALWAYS, LOG_ERR, "Network address and prefix length do not match for configuration variable %s in %s line %d",
23                cfg->variable, cfg->file, cfg->line);
24         return false;
25 }
26