config: blobmsg_check_attr expects bool type as last argument
[project/odhcpd.git] / src / config.c
index f9ad3b8..8f2c6bf 100644 (file)
@@ -40,6 +40,7 @@ enum {
        IFACE_ATTR_RA_OFFLINK,
        IFACE_ATTR_RA_PREFERENCE,
        IFACE_ATTR_RA_ADVROUTER,
+       IFACE_ATTR_RA_MAXINTERVAL,
        IFACE_ATTR_PD_MANAGER,
        IFACE_ATTR_PD_CER,
        IFACE_ATTR_NDPROXY_ROUTING,
@@ -74,6 +75,7 @@ static const struct blobmsg_policy iface_attrs[IFACE_ATTR_MAX] = {
        [IFACE_ATTR_RA_OFFLINK] = { .name = "ra_offlink", .type = BLOBMSG_TYPE_BOOL },
        [IFACE_ATTR_RA_PREFERENCE] = { .name = "ra_preference", .type = BLOBMSG_TYPE_STRING },
        [IFACE_ATTR_RA_ADVROUTER] = { .name = "ra_advrouter", .type = BLOBMSG_TYPE_BOOL },
+       [IFACE_ATTR_RA_MAXINTERVAL] = { .name = "ra_maxinterval", .type = BLOBMSG_TYPE_INT32 },
        [IFACE_ATTR_NDPROXY_ROUTING] = { .name = "ndproxy_routing", .type = BLOBMSG_TYPE_BOOL },
        [IFACE_ATTR_NDPROXY_SLAVE] = { .name = "ndproxy_slave", .type = BLOBMSG_TYPE_BOOL },
 };
@@ -298,11 +300,6 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr
        }
 
        const char *ifname = NULL;
-#ifdef WITH_UBUS
-       if (overwrite || !iface->ifname[0])
-               ifname = ubus_get_ifname(name);
-#endif
-
        if (overwrite) {
                if ((c = tb[IFACE_ATTR_IFNAME]))
                        ifname = blobmsg_get_string(c);
@@ -310,14 +307,19 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr
                        ifname = blobmsg_get_string(c);
        }
 
+#ifdef WITH_UBUS
+       if (overwrite || !iface->ifname[0])
+               ifname = ubus_get_ifname(name);
+#endif
+
        if (!iface->ifname[0] && !ifname)
-               return -1;
+               goto err;
 
        if (ifname)
                strncpy(iface->ifname, ifname, sizeof(iface->ifname) - 1);
 
        if ((iface->ifindex = if_nametoindex(iface->ifname)) <= 0)
-               return -1;
+               goto err;
 
        iface->inuse = true;
 
@@ -368,7 +370,7 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr
                unsigned rem;
 
                blobmsg_for_each_attr(cur, c, rem) {
-                       if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING || !blobmsg_check_attr(cur, NULL))
+                       if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING || !blobmsg_check_attr(cur, false))
                                continue;
 
                        iface->upstream = realloc(iface->upstream,
@@ -415,7 +417,7 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr
                unsigned rem;
 
                blobmsg_for_each_attr(cur, c, rem) {
-                       if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING || !blobmsg_check_attr(cur, NULL))
+                       if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING || !blobmsg_check_attr(cur, false))
                                continue;
 
                        struct in_addr addr4;
@@ -438,7 +440,7 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr
 
                iface->always_rewrite_dns = true;
                blobmsg_for_each_attr(cur, c, rem) {
-                       if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING || !blobmsg_check_attr(cur, NULL))
+                       if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING || !blobmsg_check_attr(cur, false))
                                continue;
 
                        struct in_addr addr4;
@@ -468,7 +470,7 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr
                unsigned rem;
 
                blobmsg_for_each_attr(cur, c, rem) {
-                       if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING || !blobmsg_check_attr(cur, NULL))
+                       if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING || !blobmsg_check_attr(cur, false))
                                continue;
 
                        uint8_t buf[256];
@@ -515,6 +517,9 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr
        if ((c = tb[IFACE_ATTR_RA_ADVROUTER]))
                iface->ra_advrouter = blobmsg_get_bool(c);
 
+       if ((c = tb[IFACE_ATTR_RA_MAXINTERVAL]))
+               iface->ra_maxinterval = blobmsg_get_u32(c);
+
        if ((c = tb[IFACE_ATTR_RA_PREFERENCE])) {
                const char *prio = blobmsg_get_string(c);