diff options
author | Thomas Graf <tgraf@redhat.com> | 2012-06-01 11:48:08 +0200 |
---|---|---|
committer | Thomas Graf <tgraf@redhat.com> | 2012-06-01 11:48:08 +0200 |
commit | faef2fa45f67da810415f4dd4f0ce62d70965ad4 (patch) | |
tree | 2d14c8d9788b4468cb3eb78debd377581f6aa920 /include | |
parent | 3656b6f908f966f329fb727a805ee46934c360d0 (diff) | |
download | libnl-faef2fa45f67da810415f4dd4f0ce62d70965ad4.tar.gz |
genl: Support registration of families without depending on caches
Introduces the functions genl_register_family() and
genl_unregister_family() to register a Generic Netlink family
which does not implement a cachable type.
API users can direct received messages into genl_handle_msg() which
will validate the messages and call the callback functions defined
in the commands definition.
See test/test-genl.c for an example on how to use it.
Diffstat (limited to 'include')
-rw-r--r-- | include/netlink/genl/mngt.h | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/include/netlink/genl/mngt.h b/include/netlink/genl/mngt.h index 18d3866..01cbdb5 100644 --- a/include/netlink/genl/mngt.h +++ b/include/netlink/genl/mngt.h @@ -110,16 +110,34 @@ struct genl_cmd * * Definition of a Generic Netlink family * + * @par Example: + * @code + * static struct genl_cmd foo_cmds[] = { + * [...] + * }; + * + * static struct genl_ops my_genl_ops = { + * .o_name = "foo", + * .o_hdrsize = sizeof(struct my_hdr), + * .o_cmds = foo_cmds, + * .o_ncmds = ARRAY_SIZE(foo_cmds), + * }; + * + * if ((err = genl_register_family(&my_genl_ops)) < 0) + * // ERROR + * @endcode + * * @see genl_cmd */ struct genl_ops { - int o_family; + /** Length of user header */ + unsigned int o_hdrsize; - /** Numeric identifier, automatically resolved by genl_mngt_resolve() */ + /** Numeric identifier, automatically filled in by genl_ops_resolve() */ int o_id; - /** Human readable name, used to resolve to numeric identifier */ + /** Human readable name, used by genl_ops_resolve() to resolve numeric id */ char * o_name; /** @@ -128,12 +146,10 @@ struct genl_ops */ struct nl_cache_ops * o_cache_ops; - /** - * Can point to an array of generic netlink commands definitions. - */ + /** Optional array defining the available Generic Netlink commands */ struct genl_cmd * o_cmds; - /** Size of \c o_cmds array */ + /** Number of elements in \c o_cmds array */ int o_ncmds; /** @@ -143,6 +159,9 @@ struct genl_ops struct nl_list_head o_list; }; +extern int genl_register_family(struct genl_ops *); +extern int genl_unregister_family(struct genl_ops *); +extern int genl_handle_msg(struct nl_msg *, void *); extern int genl_register(struct nl_cache_ops *); extern void genl_unregister(struct nl_cache_ops *); |