Home | History | Annotate | Download | only in genl

Lines Matching refs:ops

33 static struct genl_cmd *lookup_cmd(struct genl_ops *ops, int cmd_id)
38 for (i = 0; i < ops->o_ncmds; i++) {
39 cmd = &ops->o_cmds[i];
48 struct genl_ops *ops, struct nl_cache_ops *cache_ops, void *arg)
56 if (!(cmd = lookup_cmd(ops, ghdr->cmd))) {
73 err = nlmsg_parse(nlh, GENL_HDRSIZE(ops->o_hdrsize), tb, cmd->c_maxattr,
85 static int genl_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who,
88 if (ops->co_genl == NULL)
91 return cmd_msg_parser(who, nlh, ops->co_genl, ops, pp);
96 struct genl_ops *ops;
98 nl_list_for_each_entry(ops, &genl_ops_list, o_list) {
99 if (ops->o_id == family)
100 return ops;
108 struct genl_ops *ops;
110 nl_list_for_each_entry(ops, &genl_ops_list, o_list) {
111 if (!strcmp(ops->o_name, name))
112 return ops;
120 struct genl_ops *ops;
123 if ((ops = lookup_family(family))) {
124 for (i = 0; i < ops->o_ncmds; i++) {
126 cmd = &ops->o_cmds[i];
148 * @arg ops Generic Netlink family definition
164 int genl_register_family(struct genl_ops *ops)
166 if (!ops->o_name)
169 if (ops->o_cmds && ops->o_ncmds <= 0)
172 if (ops->o_id && lookup_family(ops->o_id))
175 if (lookup_family_by_name(ops->o_name))
178 nl_list_add_tail(&ops->o_list, &genl_ops_list);
185 * @arg ops Generic Netlink family definition
194 int genl_unregister_family(struct genl_ops *ops)
196 nl_list_del(&ops->o_list);
211 struct genl_ops *ops;
216 if (!(ops = lookup_family(nlh->nlmsg_type)))
219 return cmd_msg_parser(nlmsg_get_src(msg), nlh, ops, NULL, arg);
231 * @arg ops Cache operations definition
241 int genl_register(struct nl_cache_ops *ops)
245 if (ops->co_protocol != NETLINK_GENERIC) {
250 if (ops->co_hdrsize < GENL_HDRSIZE(0)) {
255 if (ops->co_genl == NULL) {
260 ops->co_genl->o_cache_ops = ops;
261 ops->co_genl->o_hdrsize = ops->co_hdrsize - GENL_HDRLEN;
262 ops->co_genl->o_name = ops->co_msgtypes[0].mt_name;
263 ops->co_genl->o_id = ops->co_msgtypes[0].mt_id;
264 ops->co_msg_parser = genl_msg_parser;
266 if ((err = genl_register_family(ops->co_genl)) < 0)
269 err = nl_cache_mngt_register(ops);
276 * @arg ops Cache operations definition
278 void genl_unregister(struct nl_cache_ops *ops)
280 if (!ops)
283 nl_cache_mngt_unregister(ops);
285 genl_unregister_family(ops->co_genl);
291 static int __genl_ops_resolve(struct nl_cache *ctrl, struct genl_ops *ops)
295 family = genl_ctrl_search_by_name(ctrl, ops->o_name);
297 ops->o_id = genl_family_get_id(family);
299 if (ops->o_cache_ops)
300 ops->o_cache_ops->co_msgtypes[0].mt_id = ops->o_id;
310 int genl_resolve_id(struct genl_ops *ops)
316 if (ops->o_id != GENL_ID_GENERATE)
319 if (!ops->o_name)
328 err = genl_ops_resolve(sk, ops);
345 * @arg ops Generic Netlink family definition
351 int genl_ops_resolve(struct nl_sock *sk, struct genl_ops *ops)
359 err = __genl_ops_resolve(ctrl, ops);
382 struct genl_ops *ops;
388 nl_list_for_each_entry(ops, &genl_ops_list, o_list) {
389 err = __genl_ops_resolve(ctrl, ops);