Changeset View
Changeset View
Standalone View
Standalone View
sys/netlink/netlink_snl_generic.h
| Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | |||||
| #define SNL_DECLARE_GENL_PARSER(_name, _np) SNL_DECLARE_PARSER(_name,\ | #define SNL_DECLARE_GENL_PARSER(_name, _np) SNL_DECLARE_PARSER(_name,\ | ||||
| struct genlmsghdr, snl_fp_genl, _np) | struct genlmsghdr, snl_fp_genl, _np) | ||||
| struct _snl_genl_ctrl_mcast_group { | struct _snl_genl_ctrl_mcast_group { | ||||
| uint32_t mcast_grp_id; | uint32_t mcast_grp_id; | ||||
| const char *mcast_grp_name; | const char *mcast_grp_name; | ||||
| }; | }; | ||||
| struct _snl_genl_ctrl_mcast_groups { | |||||
| uint32_t num_groups; | |||||
| struct _snl_genl_ctrl_mcast_group **groups; | |||||
| }; | |||||
| #define _OUT(_field) offsetof(struct _snl_genl_ctrl_mcast_group, _field) | #define _OUT(_field) offsetof(struct _snl_genl_ctrl_mcast_group, _field) | ||||
| static struct snl_attr_parser _nla_p_getmc[] = { | static struct snl_attr_parser _nla_p_getmc[] = { | ||||
| { | { | ||||
| .type = CTRL_ATTR_MCAST_GRP_NAME, | .type = CTRL_ATTR_MCAST_GRP_NAME, | ||||
| .off = _OUT(mcast_grp_name), | .off = _OUT(mcast_grp_name), | ||||
| .cb = snl_attr_get_string, | .cb = snl_attr_get_string, | ||||
| }, | }, | ||||
| { | { | ||||
| .type = CTRL_ATTR_MCAST_GRP_ID, | .type = CTRL_ATTR_MCAST_GRP_ID, | ||||
| .off = _OUT(mcast_grp_id), | .off = _OUT(mcast_grp_id), | ||||
| .cb = snl_attr_get_uint32, | .cb = snl_attr_get_uint32, | ||||
| }, | }, | ||||
| }; | }; | ||||
| #undef _OUT | #undef _OUT | ||||
| SNL_DECLARE_ATTR_PARSER_EXT(_genl_ctrl_mc_parser, | SNL_DECLARE_ATTR_PARSER_EXT(_genl_ctrl_mc_parser, | ||||
| sizeof(struct _snl_genl_ctrl_mcast_group), _nla_p_getmc, NULL); | sizeof(struct _snl_genl_ctrl_mcast_group), _nla_p_getmc, NULL); | ||||
| struct _getfamily_attrs { | struct _getfamily_attrs { | ||||
| uint16_t family_id; | uint16_t family_id; | ||||
| const char *family_name; | const char *family_name; | ||||
| struct _snl_genl_ctrl_mcast_groups mcast_groups; | struct snl_parray mcast_groups; | ||||
| }; | }; | ||||
| #define _IN(_field) offsetof(struct genlmsghdr, _field) | #define _IN(_field) offsetof(struct genlmsghdr, _field) | ||||
| #define _OUT(_field) offsetof(struct _getfamily_attrs, _field) | #define _OUT(_field) offsetof(struct _getfamily_attrs, _field) | ||||
| static struct snl_attr_parser _nla_p_getfam[] = { | static struct snl_attr_parser _nla_p_getfam[] = { | ||||
| { | { | ||||
| .type = CTRL_ATTR_FAMILY_ID, | .type = CTRL_ATTR_FAMILY_ID, | ||||
| .off = _OUT(family_id), | .off = _OUT(family_id), | ||||
| ▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | snl_get_genl_mcast_group(struct snl_state *ss, const char *family_name, | ||||
| if (__predict_false(!_snl_get_genl_family_info(ss, family_name, | if (__predict_false(!_snl_get_genl_family_info(ss, family_name, | ||||
| &attrs))) | &attrs))) | ||||
| return (0); | return (0); | ||||
| if (attrs.family_id == 0) | if (attrs.family_id == 0) | ||||
| return (0); | return (0); | ||||
| if (family_id != NULL) | if (family_id != NULL) | ||||
| *family_id = attrs.family_id; | *family_id = attrs.family_id; | ||||
| for (u_int i = 0; i < attrs.mcast_groups.num_groups; i++) | for (u_int i = 0; i < attrs.mcast_groups.count; i++) { | ||||
| if (strcmp(attrs.mcast_groups.groups[i]->mcast_grp_name, | struct _snl_genl_ctrl_mcast_group *group; | ||||
| group_name) == 0) | |||||
| return (attrs.mcast_groups.groups[i]->mcast_grp_id); | group = attrs.mcast_groups.items[i]; | ||||
| if (strcmp(group->mcast_grp_name, group_name) == 0) | |||||
| return (group->mcast_grp_id); | |||||
| } | |||||
| return (0); | return (0); | ||||
| } | } | ||||
| #endif | #endif | ||||