list_for_each_entry(zone, &state->zones, list)
{
- addrs = fw3_resolve_zone_addresses(zone);
+ addrs = fw3_resolve_zone_addresses(zone, NULL);
if (!addrs)
continue;
if (!redir->_dest || !redir->_src->masq)
return;
- ext_addrs = fw3_resolve_zone_addresses(redir->_src);
- int_addrs = fw3_resolve_zone_addresses(redir->_dest);
+ ext_addrs = fw3_resolve_zone_addresses(redir->_src, &redir->ip_dest);
+ int_addrs = fw3_resolve_zone_addresses(redir->_dest, NULL);
if (!ext_addrs || !int_addrs)
goto out;
}
struct list_head *
-fw3_resolve_zone_addresses(struct fw3_zone *zone)
+fw3_resolve_zone_addresses(struct fw3_zone *zone, struct fw3_address *addr)
{
struct fw3_device *net;
- struct fw3_address *addr, *tmp;
+ struct fw3_address *cur, *tmp;
struct list_head *all;
all = calloc(1, sizeof(*all));
INIT_LIST_HEAD(all);
- list_for_each_entry(net, &zone->networks, list)
- fw3_ubus_address(all, net->name);
-
- list_for_each_entry(addr, &zone->subnets, list)
+ if (addr && addr->set)
{
tmp = malloc(sizeof(*tmp));
- if (!tmp)
- continue;
+ if (tmp)
+ {
+ *tmp = *addr;
+ list_add_tail(&tmp->list, all);
+ }
+ }
+ else
+ {
+ list_for_each_entry(net, &zone->networks, list)
+ fw3_ubus_address(all, net->name);
+
+ list_for_each_entry(cur, &zone->subnets, list)
+ {
+ tmp = malloc(sizeof(*tmp));
- memcpy(tmp, addr, sizeof(*tmp));
- list_add_tail(&tmp->list, all);
+ if (!tmp)
+ continue;
+
+ *tmp = *cur;
+ list_add_tail(&tmp->list, all);
+ }
}
return all;
struct fw3_zone * fw3_lookup_zone(struct fw3_state *state, const char *name);
-struct list_head * fw3_resolve_zone_addresses(struct fw3_zone *zone);
+struct list_head * fw3_resolve_zone_addresses(struct fw3_zone *zone,
+ struct fw3_address *addr);
#define fw3_free_zone(zone) \
fw3_free_object(zone, fw3_zone_opts)