diff options
Diffstat (limited to 'package/libs/libnl-tiny/src/genl_family.c')
-rw-r--r-- | package/libs/libnl-tiny/src/genl_family.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/package/libs/libnl-tiny/src/genl_family.c b/package/libs/libnl-tiny/src/genl_family.c index 88aaad9b77..221acfa1a7 100644 --- a/package/libs/libnl-tiny/src/genl_family.c +++ b/package/libs/libnl-tiny/src/genl_family.c @@ -31,12 +31,14 @@ static void family_constructor(struct nl_object *c) struct genl_family *family = (struct genl_family *) c; nl_init_list_head(&family->gf_ops); + nl_init_list_head(&family->gf_mc_grps); } static void family_free_data(struct nl_object *c) { struct genl_family *family = (struct genl_family *) c; struct genl_family_op *ops, *tmp; + struct genl_family_grp *grp, *t_grp; if (family == NULL) return; @@ -45,6 +47,12 @@ static void family_free_data(struct nl_object *c) nl_list_del(&ops->o_list); free(ops); } + + nl_list_for_each_entry_safe(grp, t_grp, &family->gf_mc_grps, list) { + nl_list_del(&grp->list); + free(grp); + } + } static int family_clone(struct nl_object *_dst, struct nl_object *_src) @@ -52,6 +60,7 @@ static int family_clone(struct nl_object *_dst, struct nl_object *_src) struct genl_family *dst = nl_object_priv(_dst); struct genl_family *src = nl_object_priv(_src); struct genl_family_op *ops; + struct genl_family_grp *grp; int err; nl_list_for_each_entry(ops, &src->gf_ops, o_list) { @@ -59,6 +68,13 @@ static int family_clone(struct nl_object *_dst, struct nl_object *_src) if (err < 0) return err; } + + nl_list_for_each_entry(grp, &src->gf_mc_grps, list) { + err = genl_family_add_grp(dst, grp->id, grp->name); + if (err < 0) + return err; + } + return 0; } @@ -119,6 +135,23 @@ int genl_family_add_op(struct genl_family *family, int id, int flags) return 0; } +int genl_family_add_grp(struct genl_family *family, uint32_t id, + const char *name) +{ + struct genl_family_grp *grp; + + grp = calloc(1, sizeof(*grp)); + if (grp == NULL) + return -NLE_NOMEM; + + grp->id = id; + strncpy(grp->name, name, GENL_NAMSIZ - 1); + + nl_list_add_tail(&grp->list, &family->gf_mc_grps); + + return 0; +} + /** @} */ /** @cond SKIP */ |