fn parse_ctrl_mcast_group_id(
    nl_attr_area: NetlinkGenericDataIter<'_>,
    group_name: &str
) -> Option<u32>
Expand description

Parse CTRL_ATTR_MCAST_GROUPS data in order to get multicast group id

On success, returns group_id for a given group_name

Arguments

  • nl_attr_area

    Nested attributes area (CTRL_ATTR_MCAST_GROUPS data), where nl_attr’s corresponding to specific groups are embed

  • group_name

    String with group_name for which we are looking group_id

the CTRL_ATTR_MCAST_GROUPS data has nested attributes. Each of nested attribute is per multicast group attributes, which have another nested attributes: CTRL_ATTR_MCAST_GRP_NAME and CTRL_ATTR_MCAST_GRP_ID. Need to parse all of them to get mcast group id for a given group_name..

Illustrated layout: CTRL_ATTR_MCAST_GROUPS: GR1 (nl_attr._type = 1): CTRL_ATTR_MCAST_GRP_ID, CTRL_ATTR_MCAST_GRP_NAME, GR2 (nl_attr._type = 2): CTRL_ATTR_MCAST_GRP_ID, CTRL_ATTR_MCAST_GRP_NAME, ..

Unfortunately kernel implementation uses nla_nest_start_noflag for that purpose, which means that it never marked their nest attributes with NLA_F_NESTED flag. Therefore all this nesting stages need to be deduced based on specific nl_attr type.