+enum {
+ OPT_IPADDR,
+ OPT_IP6ADDR,
+ OPT_NETMASK,
+ OPT_BROADCAST,
+ OPT_GATEWAY,
+ OPT_IP6GW,
+ OPT_IP6PREFIX,
+ __OPT_MAX,
+};
+
+static const struct blobmsg_policy proto_ip_attributes[__OPT_MAX] = {
+ [OPT_IPADDR] = { .name = "ipaddr", .type = BLOBMSG_TYPE_ARRAY },
+ [OPT_IP6ADDR] = { .name = "ip6addr", .type = BLOBMSG_TYPE_ARRAY },
+ [OPT_NETMASK] = { .name = "netmask", .type = BLOBMSG_TYPE_STRING },
+ [OPT_BROADCAST] = { .name = "broadcast", .type = BLOBMSG_TYPE_STRING },
+ [OPT_GATEWAY] = { .name = "gateway", .type = BLOBMSG_TYPE_STRING },
+ [OPT_IP6GW] = { .name = "ip6gw", .type = BLOBMSG_TYPE_STRING },
+ [OPT_IP6PREFIX] = { .name = "ip6prefix", .type = BLOBMSG_TYPE_ARRAY },
+};
+
+static const struct uci_blob_param_info proto_ip_attr_info[__OPT_MAX] = {
+ [OPT_IPADDR] = { .type = BLOBMSG_TYPE_STRING },
+ [OPT_IP6ADDR] = { .type = BLOBMSG_TYPE_STRING },
+ [OPT_IP6PREFIX] = { .type = BLOBMSG_TYPE_STRING },
+};
+
+static const char * const proto_ip_validate[__OPT_MAX] = {
+ [OPT_IPADDR] = "ip4addr",
+ [OPT_IP6ADDR] = "ip6addr",
+ [OPT_NETMASK] = "netmask",
+ [OPT_BROADCAST] = "ipaddr",
+ [OPT_GATEWAY] = "ip4addr",
+ [OPT_IP6GW] = "ip6addr",
+ [OPT_IP6PREFIX] = "ip6addr",
+};
+
+const struct uci_blob_param_list proto_ip_attr = {
+ .n_params = __OPT_MAX,
+ .params = proto_ip_attributes,
+ .validate = proto_ip_validate,
+ .info = proto_ip_attr_info,
+};
+
+enum {
+ ADDR_IPADDR,
+ ADDR_MASK,
+ ADDR_BROADCAST,
+ ADDR_PTP,
+ ADDR_PREFERRED,
+ ADDR_VALID,
+ ADDR_OFFLINK,
+ ADDR_CLASS,
+ __ADDR_MAX
+};
+
+static const struct blobmsg_policy proto_ip_addr[__ADDR_MAX] = {
+ [ADDR_IPADDR] = { .name = "ipaddr", .type = BLOBMSG_TYPE_STRING },
+ [ADDR_MASK] = { .name = "mask", .type = BLOBMSG_TYPE_STRING },
+ [ADDR_BROADCAST] = { .name = "broadcast", .type = BLOBMSG_TYPE_STRING },
+ [ADDR_PTP] = { .name = "ptp", .type = BLOBMSG_TYPE_STRING },
+ [ADDR_PREFERRED] = { .name = "preferred", .type = BLOBMSG_TYPE_INT32 },
+ [ADDR_VALID] = { .name = "valid", .type = BLOBMSG_TYPE_INT32 },
+ [ADDR_OFFLINK] = { .name = "offlink", .type = BLOBMSG_TYPE_BOOL },
+ [ADDR_CLASS] = { .name = "class", .type = BLOBMSG_TYPE_STRING },
+};
+
+static struct device_addr *
+alloc_device_addr(bool v6, bool ext)