+int get_config_port(config_t *cfg, port_t *result)
+{
+cp
+ if(!cfg)
+ return 0;
+
+ if(sscanf(cfg->value, "%hu", result) == 1)
+ return 1;
+
+ syslog(LOG_ERR, _("Port number expected for configuration variable %s in %s line %d"),
+ cfg->value, cfg->file, cfg->line);
+ return 0;
+}
+
+int get_config_subnet(config_t *cfg, subnet_t **result)
+{
+ ip_mask_t *ip;
+ subnet_t *subnet;
+cp
+ if(!cfg)
+ return 0;
+
+ ip = strtoip(cfg->value);
+
+ if(!ip)
+ {
+ syslog(LOG_ERR, _("IP address expected for configuration variable %s in %s line %d"),
+ cfg->value, cfg->file, cfg->line);
+ return 0;
+ }
+
+ /* Teach newbies what subnets are... */
+
+ if((ip->address & ip->mask) != ip->address)
+ {
+ syslog(LOG_ERR, _("Network address and subnet mask for configuration variable %s in %s line %d"),
+ cfg->value, cfg->file, cfg->line);
+ free(ip);
+ return 0;
+ }
+
+ subnet = new_subnet();
+ subnet->type = SUBNET_IPV4;
+ subnet->net.ipv4.address = ip->address;
+ subnet->net.ipv4.mask = ip->mask;
+
+ free(ip);
+
+ *result = subnet;
+
+ return 1;
+}
+