return addr;
}
-static bool
-parse_addr(struct interface *iface, const char *str, bool v6, int mask,
- bool ext, uint32_t broadcast, uint32_t ptp, bool deprecated)
+static struct device_addr *
+parse_addr(const char *str, bool v6, int mask, bool ext, uint32_t broadcast,
+ uint32_t ptp, bool deprecated)
{
struct device_addr *addr;
int af = v6 ? AF_INET6 : AF_INET;
addr = alloc_device_addr(v6, ext);
if (!addr)
- return false;
+ return NULL;
addr->mask = mask;
if (!parse_ip_and_netmask(af, str, &addr->addr, &addr->mask))
goto error;
- if (!v6) {
- if (IN_EXPERIMENTAL(ntohl(addr->addr.in.s_addr)))
- goto error;
-
- } else if (IN6_IS_ADDR_MULTICAST(&addr->addr.in6))
+ if (v6 && IN6_IS_ADDR_MULTICAST(&addr->addr.in6))
goto error;
if (broadcast)
if (deprecated)
addr->preferred_until = system_get_rtime();
- vlist_add(&iface->proto_ip.addr, &addr->node, &addr->flags);
- return true;
+ return addr;
error:
- interface_add_error(iface, "proto", "INVALID_ADDRESS", &str, 1);
free(addr);
- return false;
+ return NULL;
}
static int
uint32_t ptp, bool deprecated)
{
struct blob_attr *cur;
+ struct device_addr *addr;
+ const char *str;
int n_addr = 0;
- int rem;
+ size_t rem;
blobmsg_for_each_attr(cur, attr, rem) {
if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING)
return -1;
- n_addr++;
- if (!parse_addr(iface, blobmsg_data(cur), v6, netmask, ext,
- broadcast, ptp, deprecated))
+ str = blobmsg_data(cur);
+ addr = parse_addr(str, v6, netmask, ext, broadcast, ptp, deprecated);
+ if (addr == NULL) {
+ interface_add_error(iface, "proto", "INVALID_ADDRESS", &str, 1);
return -1;
+ }
+ addr->index = n_addr;
+ n_addr++;
+ vlist_add(&iface->proto_ip.addr, &addr->node, addr);
}
return n_addr;
struct device_addr *addr;
struct blob_attr *cur;
int n_addr = 0;
- int rem;
+ size_t rem;
blobmsg_for_each_attr(cur, attr, rem) {
addr = parse_address_item(cur, v6, ext);
if (!addr)
return -1;
+ addr->index = n_addr;
n_addr++;
- vlist_add(&iface->proto_ip.addr, &addr->node, &addr->flags);
+ vlist_add(&iface->proto_ip.addr, &addr->node, addr);
}
return n_addr;
{
struct blob_attr *cur;
int n_addr = 0;
- int rem;
+ size_t rem;
blobmsg_for_each_attr(cur, attr, rem) {
if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING)
unsigned int netmask = 32;
bool ip6deprecated;
int n_v4 = 0, n_v6 = 0;
- struct in_addr bcast = {}, ptp = {};
+ struct in_addr bcast = {0,}, ptp = {0,};
blobmsg_parse(proto_ip_attributes, __OPT_MAX, tb, blob_data(attr), blob_len(attr));