X-Git-Url: http://git.archive.openwrt.org/?p=project%2Ffirewall3.git;a=blobdiff_plain;f=zones.c;h=2ddd7b44443f3b2714e19ffb2f8b8b29320700d2;hp=ebc4a2a6d7b0bcc5c7da894cc7dd931f1573b014;hb=b59934331c4b9271ceb5e30b793a552618299d39;hpb=91953d6a6e90df988f442f53097bd208784a295d diff --git a/zones.c b/zones.c index ebc4a2a..2ddd7b4 100644 --- a/zones.c +++ b/zones.c @@ -83,6 +83,8 @@ const struct fw3_option fw3_zone_opts[] = { FW3_OPT("__flags_v4", int, zone, flags[0]), FW3_OPT("__flags_v6", int, zone, flags[1]), + FW3_LIST("__addrs", address, zone, old_addrs), + { } }; @@ -138,6 +140,8 @@ fw3_alloc_zone(void) INIT_LIST_HEAD(&zone->masq_src); INIT_LIST_HEAD(&zone->masq_dest); + INIT_LIST_HEAD(&zone->old_addrs); + zone->enabled = true; zone->custom_chains = true; zone->log_limit.rate = 10; @@ -674,10 +678,10 @@ fw3_lookup_zone(struct fw3_state *state, const char *name) } 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)); @@ -686,18 +690,31 @@ fw3_resolve_zone_addresses(struct fw3_zone *zone) 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;