There are get apis such as
rtnl_link_get_by_name
I'm reffering to (https://www.infradead.org/~tgr/libnl/doc/api/structrtnl__link.html)
I'm able to get it using following code :
static void
netlink_parse_afspec(struct rtattr *rta, int len, int* vlan)
{
while (RTA_OK(rta, len)) {
struct bridge_vlan_info *vinfo;
switch (rta->rta_type) {
case IFLA_BRIDGE_VLAN_INFO:
vinfo = RTA_DATA(rta);
/*log_debug("netlink", "found VLAN %d on interface %s",
vinfo->vid, iff->name ? iff->name : "(unknown)");
bitmap_set(iff->vlan_bmap, vinfo->vid);
if (vinfo->flags & (BRIDGE_VLAN_INFO_PVID | BRIDGE_VLAN_INFO_UNTAGGED))
iff->pvid = vinfo->vid;
break;*/
printf("vlan %d \n",vinfo->vid);
default:
printf("unknown afspec attribute type %d\n",rta->rta_type);
break;
}
rta = RTA_NEXT(rta, len);
}
/* All enbridged interfaces will have VLAN 1 by default, ignore it */
}
int main()
{
//code to receive netlink message
switch(h->nlmsg_type) {
case IFLA_AF_SPEC: netlink_parse_afspec( RTA_DATA(attribute), RTA_PAYLOAD(attribute),vlan);
}
}