Use zone_name_src_ACTION chain for input rules with non-wildcard source
[project/firewall3.git] / options.c
index a2a0465..5a7a901 100644 (file)
--- a/options.c
+++ b/options.c
@@ -342,12 +342,13 @@ fw3_parse_network(void *ptr, const char *val, bool is_list)
                        list_for_each_entry(addr, addr_list, list)
                        {
                                addr->invert = dev.invert;
                        list_for_each_entry(addr, addr_list, list)
                        {
                                addr->invert = dev.invert;
+                               addr->resolved = true;
 
                                if (!put_value(ptr, addr, sizeof(*addr), is_list))
                                        break;
                        }
 
 
                                if (!put_value(ptr, addr, sizeof(*addr), is_list))
                                        break;
                        }
 
-                       fw3_ubus_address_free(addr_list);
+                       fw3_free_list(addr_list);
                }
        }
 
                }
        }
 
@@ -576,20 +577,22 @@ fw3_parse_ipset_datatype(void *ptr, const char *val, bool is_list)
 {
        struct fw3_ipset_datatype type = { };
 
 {
        struct fw3_ipset_datatype type = { };
 
+       type.dir = "src";
+
        if (!strncmp(val, "dest_", 5))
        {
                val += 5;
        if (!strncmp(val, "dest_", 5))
        {
                val += 5;
-               type.dest = true;
+               type.dir = "dst";
        }
        else if (!strncmp(val, "dst_", 4))
        {
                val += 4;
        }
        else if (!strncmp(val, "dst_", 4))
        {
                val += 4;
-               type.dest = true;
+               type.dir = "dst";
        }
        else if (!strncmp(val, "src_", 4))
        {
                val += 4;
        }
        else if (!strncmp(val, "src_", 4))
        {
                val += 4;
-               type.dest = false;
+               type.dir = "src";
        }
 
        if (parse_enum(&type.type, val, &fw3_ipset_type_names[FW3_IPSET_TYPE_IP],
        }
 
        if (parse_enum(&type.type, val, &fw3_ipset_type_names[FW3_IPSET_TYPE_IP],
@@ -808,6 +811,46 @@ fw3_parse_mark(void *ptr, const char *val, bool is_list)
        return true;
 }
 
        return true;
 }
 
+bool
+fw3_parse_setmatch(void *ptr, const char *val, bool is_list)
+{
+       struct fw3_setmatch *m = ptr;
+       char *p, *s;
+       int i;
+
+       if (*val == '!')
+       {
+               m->invert = true;
+               while (isspace(*++val));
+       }
+
+       if (!(s = strdup(val)))
+               return false;
+
+       if (!(p = strtok(s, " \t")))
+       {
+               free(s);
+               return false;
+       }
+
+       strncpy(m->name, p, sizeof(m->name));
+
+       for (i = 0, p = strtok(NULL, " \t,");
+            i < 3 && p != NULL;
+            i++, p = strtok(NULL, " \t,"))
+       {
+               if (!strncmp(p, "dest", 4) || !strncmp(p, "dst", 3))
+                       m->dir[i] = "dst";
+               else if (!strncmp(p, "src", 3))
+                       m->dir[i] = "src";
+       }
+
+       free(s);
+
+       m->set = true;
+       return true;
+}
+
 
 void
 fw3_parse_options(void *s, const struct fw3_option *opts,
 
 void
 fw3_parse_options(void *s, const struct fw3_option *opts,