#include <string.h>
#include <stdlib.h>
#include <stdio.h>
-#include <unistd.h>
#include <arpa/inet.h>
struct vlist_tree iprules;
static bool iprules_flushed = false;
+static unsigned int iprules_counter[2];
enum {
RULE_INTERFACE_IN,
[RULE_GOTO] = { .name = "goto", .type = BLOBMSG_TYPE_INT32 },
};
-const struct config_param_list rule_attr_list = {
+const struct uci_blob_param_list rule_attr_list = {
.n_params = __RULE_MAX,
.params = rule_attr,
};
return;
rule->flags = v6 ? IPRULE_INET6 : IPRULE_INET4;
+ rule->order = iprules_counter[rule->flags]++;
if ((cur = tb[RULE_INVERT]) != NULL)
rule->invert = blobmsg_get_bool(cur);
rule->flags |= IPRULE_GOTO;
}
- /* trigger flush of existing rules when adding first uci rule the first time */
- if (!iprules_flushed)
- {
- system_flush_iprules();
- iprules_flushed = true;
- }
-
vlist_add(&iprules, &rule->node, &rule->flags);
return;
void
iprule_update_start(void)
{
+ if (!iprules_flushed) {
+ system_flush_iprules();
+ iprules_flushed = true;
+ }
+
+ iprules_counter[0] = 1;
+ iprules_counter[1] = 1;
vlist_update(&iprules);
}