-bool get_config_subnet(const config_t *cfg, subnet_t ** result)
-{
- subnet_t *subnet;
-
- cp();
-
- if(!cfg)
- return false;
-
- subnet = str2net(cfg->value);
-
- if(!subnet) {
- logger(LOG_ERR, _("Subnet expected for configuration variable %s in %s line %d"),
- cfg->variable, cfg->file, cfg->line);
- return false;
- }
-
- /* Teach newbies what subnets are... */
-
- if(((subnet->type == SUBNET_IPV4)
- && !maskcheck(&subnet->net.ipv4.address, subnet->net.ipv4.prefixlength, sizeof(ipv4_t)))
- || ((subnet->type == SUBNET_IPV6)
- && !maskcheck(&subnet->net.ipv6.address, subnet->net.ipv6.prefixlength, sizeof(ipv6_t)))) {
- logger(LOG_ERR, _ ("Network address and prefix length do not match for configuration variable %s in %s line %d"),
- cfg->variable, cfg->file, cfg->line);
- free(subnet);
- return false;
- }
-
- *result = subnet;
-
- return true;
-}
-