track used family for ipsets
[project/firewall3.git] / ipsets.c
index 6d7ff78bd753d5864c0a23170038c3ada1c7749f..f4253c7bab64b467a5ca59d0a2813678084029ce 100644 (file)
--- a/ipsets.c
+++ b/ipsets.c
@@ -351,37 +351,25 @@ fw3_create_ipsets(struct fw3_state *state)
 }
 
 void
-fw3_destroy_ipsets(struct fw3_state *state)
+fw3_destroy_ipsets(struct list_head *statefile)
 {
-       FILE *sf;
+       struct fw3_statefile_entry *e;
 
-       char *p;
-       char line[128];
-
-       sf = fopen(FW3_STATEFILE, "r");
-
-       if (!sf)
-               return;
-
-       info("Destroying ipsets ...");
-
-       while (fgets(line, sizeof(line), sf))
+       if (statefile)
        {
-               if (strncmp(line, "ipset ", 6))
-                       continue;
+               info("Destroying ipsets ...");
 
-               p = strtok(line+6, " \t\n");
-
-               if (!p || !strlen(p))
-                       continue;
+               list_for_each_entry(e, statefile, list)
+               {
+                       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");
 }
 
 void