def parse_mcast_grps(family, grp_attr):
remaining = c_int()<EOL>if not grp_attr:<EOL><INDENT>raise BUG<EOL><DEDENT>for nla in nla_for_each_nested(grp_attr, remaining):<EOL><INDENT>tb = dict()<EOL>err = nla_parse_nested(tb, CTRL_ATTR_MCAST_GRP_MAX, nla, family_grp_policy)<EOL>if err < <NUM_LIT:0>:<EOL><INDENT>return err<EOL><DEDENT>if not tb[CTRL_ATTR_MCAST_GRP_ID] or not tb[CTRL_ATTR_MCAST_GRP_NAME]:<EOL><INDENT>return -NLE_MISSING_ATTR<EOL><DEDENT>id_ = nla_get_u32(tb[CTRL_ATTR_MCAST_GRP_ID])<EOL>name = nla_get_string(tb[CTRL_ATTR_MCAST_GRP_NAME])<EOL>err = genl_family_add_grp(family, id_, name)<EOL>if err < <NUM_LIT:0>:<EOL><INDENT>return err<EOL><DEDENT><DEDENT>return <NUM_LIT:0><EOL>
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/genl/ctrl.c#L64.

    Positional arguments:
    family -- genl_family class instance.
    grp_attr -- nlattr class instance.

    Returns:
    0 on success or a negative error code.