X-Git-Url: https://git.archive.openwrt.org/?p=project%2Ffirewall3.git;a=blobdiff_plain;f=ipsets.c;h=215be73605bbfe289d5840ec7df189ccabe5412b;hp=ca0bd299912577c1ec5819877a691e30f63316d2;hb=ea1e5c25c1c4c8c82b51c0440d033944ccb4e2e2;hpb=a60a91f643e2bceb202cc4c965c47dc6325c1f02 diff --git a/ipsets.c b/ipsets.c index ca0bd29..215be73 100644 --- a/ipsets.c +++ b/ipsets.c @@ -351,39 +351,22 @@ fw3_create_ipsets(struct fw3_state *state) } void -fw3_destroy_ipsets(struct fw3_state *state) +fw3_destroy_ipsets(struct list_head *statefile) { - FILE *sf; - - char *p; - char line[128]; - - sf = fopen(FW3_STATEFILE, "r"); - - if (!sf) - return; + struct fw3_statefile_entry *e; info("Destroying ipsets ..."); - while (fgets(line, sizeof(line), sf)) + list_for_each_entry(e, statefile, list) { - if (strncmp(line, "ipset ", 6)) - continue; - - p = strtok(line+6, " \t\n"); - - if (!p || !strlen(p)) + if (e->type != FW3_TYPE_IPSET) continue; - info(" * %s", p); + info(" * %s", e->name); - fw3_pr("flush %s\n", p); - fw3_pr("destroy %s\n", p); + fw3_pr("flush %s\n", e->name); + fw3_pr("destroy %s\n", e->name); } - - fw3_pr("quit\n"); - - fclose(sf); } void