int r;
void *attr_data;
+ assert_return(m, -EINVAL);
+
r = message_attribute_has_type(m, type, NLA_STRING);
if (r < 0)
return r;
else if (strnlen(attr_data, r) >= (size_t) r)
return -EIO;
- *data = (const char *) attr_data;
+ if (data)
+ *data = (const char *) attr_data;
return 0;
}
int r;
void *attr_data;
+ assert_return(m, -EINVAL);
+
r = message_attribute_has_type(m, type, NLA_U8);
if (r < 0)
return r;
else if ((size_t) r < sizeof(uint8_t))
return -EIO;
- *data = *(uint8_t *) attr_data;
+ if (data)
+ *data = *(uint8_t *) attr_data;
return 0;
}
int r;
void *attr_data;
+ assert_return(m, -EINVAL);
+
r = message_attribute_has_type(m, type, NLA_U16);
if (r < 0)
return r;
else if ((size_t) r < sizeof(uint16_t))
return -EIO;
- *data = *(uint16_t *) attr_data;
+ if (data)
+ *data = *(uint16_t *) attr_data;
return 0;
}
int r;
void *attr_data;
+ assert_return(m, -EINVAL);
+
r = message_attribute_has_type(m, type, NLA_U32);
if (r < 0)
return r;
else if ((size_t)r < sizeof(uint32_t))
return -EIO;
- *data = *(uint32_t *) attr_data;
+ if (data)
+ *data = *(uint32_t *) attr_data;
return 0;
}
int r;
void *attr_data;
+ assert_return(m, -EINVAL);
+
r = message_attribute_has_type(m, type, NLA_ETHER_ADDR);
if (r < 0)
return r;
else if ((size_t)r < sizeof(struct ether_addr))
return -EIO;
- memcpy(data, attr_data, sizeof(struct ether_addr));
+ if (data)
+ memcpy(data, attr_data, sizeof(struct ether_addr));
return 0;
}
int r;
void *attr_data;
+ assert_return(m, -EINVAL);
+
r = message_attribute_has_type(m, type, NLA_CACHE_INFO);
if (r < 0)
return r;
else if ((size_t)r < sizeof(struct ifa_cacheinfo))
return -EIO;
- memcpy(info, attr_data, sizeof(struct ifa_cacheinfo));
+ if (info)
+ memcpy(info, attr_data, sizeof(struct ifa_cacheinfo));
return 0;
}
int r;
void *attr_data;
+ assert_return(m, -EINVAL);
+
r = message_attribute_has_type(m, type, NLA_IN_ADDR);
if (r < 0)
return r;
else if ((size_t)r < sizeof(struct in_addr))
return -EIO;
- memcpy(data, attr_data, sizeof(struct in_addr));
+ if (data)
+ memcpy(data, attr_data, sizeof(struct in_addr));
return 0;
}
int r;
void *attr_data;
+ assert_return(m, -EINVAL);
+
r = message_attribute_has_type(m, type, NLA_IN_ADDR);
if (r < 0)
return r;
else if ((size_t)r < sizeof(struct in6_addr))
return -EIO;
- memcpy(data, attr_data, sizeof(struct in6_addr));
+ if (data)
+ memcpy(data, attr_data, sizeof(struct in6_addr));
return 0;
}