diff options
author | Gleb Smirnoff <glebius@FreeBSD.org> | 2025-01-11 04:55:50 +0000 |
---|---|---|
committer | Gleb Smirnoff <glebius@FreeBSD.org> | 2025-01-11 04:55:50 +0000 |
commit | 8a8d095718cb4e3ce84bef1cd61c20b518b8d047 (patch) | |
tree | 3bbd5c14386f85d4f8796a7dba9d4022afeb558a | |
parent | 0fda4ffd69054217096dd1a40355d97be9a8ab94 (diff) |
netlink: add snl(3) primitive to obtain group ID
using the family name and the group name as lookup arguments.
Reviewed by: melifaro
Differential Revision: https://reviews.freebsd.org/D48308
-rw-r--r-- | sys/netlink/netlink_snl_generic.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/sys/netlink/netlink_snl_generic.h b/sys/netlink/netlink_snl_generic.h index 0a2913c9155e..32b460c612bd 100644 --- a/sys/netlink/netlink_snl_generic.h +++ b/sys/netlink/netlink_snl_generic.h @@ -127,6 +127,24 @@ snl_get_genl_family(struct snl_state *ss, const char *family_name) return (attrs.family_id); } +static inline uint16_t +snl_get_genl_mcast_group(struct snl_state *ss, const char *family_name, + const char *group_name, uint16_t *family_id) +{ + struct _getfamily_attrs attrs = {}; + + snl_get_genl_family_info(ss, family_name, &attrs); + if (attrs.family_id == 0) + return (0); + if (family_id != NULL) + *family_id = attrs.family_id; + for (u_int i = 0; i < attrs.mcast_groups.num_groups; i++) + if (strcmp(attrs.mcast_groups.groups[i]->mcast_grp_name, + group_name) == 0) + return (attrs.mcast_groups.groups[i]->mcast_grp_id); + return (0); +} + static const struct snl_hdr_parser *snl_all_genl_parsers[] = { &_genl_ctrl_getfam_parser, &_genl_ctrl_mc_parser, }; |