netifd: Add mldversion config support
[project/netifd.git] / device.c
index d261e25..6eb1486 100644 (file)
--- a/device.c
+++ b/device.c
@@ -40,6 +40,9 @@ static const struct blobmsg_policy dev_attrs[__DEV_ATTR_MAX] = {
        [DEV_ATTR_IPV6] = { .name = "ipv6", .type = BLOBMSG_TYPE_BOOL },
        [DEV_ATTR_PROMISC] = { .name = "promisc", .type = BLOBMSG_TYPE_BOOL },
        [DEV_ATTR_RPFILTER] = { .name = "rpfilter", .type = BLOBMSG_TYPE_STRING },
+       [DEV_ATTR_ACCEPTLOCAL] = { .name = "acceptlocal", .type = BLOBMSG_TYPE_BOOL },
+       [DEV_ATTR_IGMPVERSION] = { .name = "igmpversion", .type = BLOBMSG_TYPE_INT32 },
+       [DEV_ATTR_MLDVERSION] = { .name = "mldversion", .type = BLOBMSG_TYPE_INT32 },
 };
 
 const struct uci_blob_param_list device_attr_list = {
@@ -156,6 +159,9 @@ device_merge_settings(struct device *dev, struct device_settings *n)
        n->ipv6 = s->flags & DEV_OPT_IPV6 ? s->ipv6 : os->ipv6;
        n->promisc = s->flags & DEV_OPT_PROMISC ? s->promisc : os->promisc;
        n->rpfilter = s->flags & DEV_OPT_RPFILTER ? s->rpfilter : os->rpfilter;
+       n->acceptlocal = s->flags & DEV_OPT_ACCEPTLOCAL ? s->acceptlocal : os->acceptlocal;
+       n->igmpversion = s->flags & DEV_OPT_IGMPVERSION ? s->igmpversion : os->igmpversion;
+       n->mldversion = s->flags & DEV_OPT_MLDVERSION ? s->mldversion : os->mldversion;
        n->flags = s->flags | os->flags;
 }
 
@@ -206,6 +212,27 @@ device_init_settings(struct device *dev, struct blob_attr **tb)
                        DPRINTF("Failed to resolve rpfilter: %s\n", (char *) blobmsg_data(cur));
        }
 
+       if ((cur = tb[DEV_ATTR_ACCEPTLOCAL])) {
+               s->acceptlocal = blobmsg_get_bool(cur);
+               s->flags |= DEV_OPT_ACCEPTLOCAL;
+       }
+
+       if ((cur = tb[DEV_ATTR_IGMPVERSION])) {
+               s->igmpversion = blobmsg_get_u32(cur);
+               if (s->igmpversion >= 1 && s->igmpversion <= 3)
+                       s->flags |= DEV_OPT_IGMPVERSION;
+               else
+                       DPRINTF("Failed to resolve igmpversion: %d\n", blobmsg_get_u32(cur));
+       }
+
+       if ((cur = tb[DEV_ATTR_MLDVERSION])) {
+               s->mldversion = blobmsg_get_u32(cur);
+               if (s->mldversion >= 1 && s->mldversion <= 2)
+                       s->flags |= DEV_OPT_MLDVERSION;
+               else
+                       DPRINTF("Failed to resolve mldversion: %d\n", blobmsg_get_u32(cur));
+       }
+
        device_set_disabled(dev, disabled);
 }
 
@@ -745,6 +772,12 @@ device_dump_status(struct blob_buf *b, struct device *dev)
                        blobmsg_add_u8(b, "promisc", st.promisc);
                if (st.flags & DEV_OPT_RPFILTER)
                        blobmsg_add_u32(b, "rpfilter", st.rpfilter);
+               if (st.flags & DEV_OPT_ACCEPTLOCAL)
+                       blobmsg_add_u8(b, "acceptlocal", st.acceptlocal);
+               if (st.flags & DEV_OPT_IGMPVERSION)
+                       blobmsg_add_u32(b, "igmpversion", st.igmpversion);
+               if (st.flags & DEV_OPT_MLDVERSION)
+                       blobmsg_add_u32(b, "mldversion", st.mldversion);
        }
 
        s = blobmsg_open_table(b, "statistics");