unsigned int *multicast_group, unsigned int fallback)
{
struct nlattr *family_attrs[ARRAY_SIZE(family_policy)];
- struct ofpbuf all_mcs;
+ const struct nlattr *mc;
struct ofpbuf *reply;
- struct nlattr *mc;
unsigned int left;
int error;
goto exit;
}
- nl_attr_get_nested(family_attrs[CTRL_ATTR_MCAST_GROUPS], &all_mcs);
- NL_ATTR_FOR_EACH (mc, left, all_mcs.data, all_mcs.size) {
+ NL_NESTED_FOR_EACH (mc, left, family_attrs[CTRL_ATTR_MCAST_GROUPS]) {
static const struct nl_policy mc_policy[] = {
[CTRL_ATTR_MCAST_GRP_ID] = {.type = NL_A_U32},
[CTRL_ATTR_MCAST_GRP_NAME] = {.type = NL_A_STRING},
(LEFT) > 0; \
(LEFT) -= NLA_ALIGN((ITER)->nla_len), (ITER) = nl_attr_next(ITER))
+/* These variants are convenient for iterating nested attributes. */
+#define NL_NESTED_FOR_EACH(ITER, LEFT, A) \
+ NL_ATTR_FOR_EACH(ITER, LEFT, nl_attr_get(A), nl_attr_get_size(A))
+#define NL_NESTED_FOR_EACH_UNSAFE(ITER, LEFT, A) \
+ NL_ATTR_FOR_EACH_UNSAFE(ITER, LEFT, nl_attr_get(A), nl_attr_get_size(A))
+
/* Netlink attribute parsing. */
int nl_attr_type(const struct nlattr *);
const void *nl_attr_get(const struct nlattr *);