mngt.h

00001 /*
00002  * netlink/genl/mngt.h          Generic Netlink Management
00003  *
00004  *      This library is free software; you can redistribute it and/or
00005  *      modify it under the terms of the GNU Lesser General Public
00006  *      License as published by the Free Software Foundation version 2.1
00007  *      of the License.
00008  *
00009  * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
00010  */
00011 
00012 #ifndef NETLINK_GENL_MNGT_H_
00013 #define NETLINK_GENL_MNGT_H_
00014 
00015 #include <netlink/netlink.h>
00016 #include <netlink/attr.h>
00017 #include <netlink/list.h>
00018 
00019 #ifdef __cplusplus
00020 extern "C" {
00021 #endif
00022 
00023 struct nl_cache_ops;
00024 
00025 struct genl_info
00026 {
00027         struct sockaddr_nl *    who;
00028         struct nlmsghdr *       nlh;
00029         struct genlmsghdr *     genlhdr;
00030         void *                  userhdr;
00031         struct nlattr **        attrs;
00032 };
00033 
00034 /**
00035  * @ingroup genl_mngt
00036  * Generic Netlink Command
00037  */
00038 struct genl_cmd
00039 {
00040         /** Unique command identifier */
00041         int                     c_id;
00042 
00043         /** Name/description of command */
00044         char *                  c_name;
00045 
00046         /**
00047          * Maximum attribute identifier, must be provided if
00048          * a message parser is available.
00049          */
00050         int                     c_maxattr;
00051 
00052         int                   (*c_msg_parser)(struct nl_cache_ops *,
00053                                               struct genl_cmd *,
00054                                               struct genl_info *, void *);
00055 
00056         /**
00057          * Attribute validation policy (optional)
00058          */
00059         struct nla_policy *     c_attr_policy;
00060 };
00061 
00062 /**
00063  * @ingroup genl_mngt
00064  * Generic Netlink Operations
00065  */
00066 struct genl_ops
00067 {
00068         int                     o_family;
00069         int                     o_id;
00070         char *                  o_name;
00071         struct nl_cache_ops *   o_cache_ops;
00072         struct genl_cmd *       o_cmds;
00073         int                     o_ncmds;
00074 
00075         /* linked list of all genl cache operations */
00076         struct nl_list_head     o_list;
00077 };
00078 
00079 
00080 extern int              genl_register(struct nl_cache_ops *);
00081 extern void             genl_unregister(struct nl_cache_ops *);
00082 
00083 #ifdef __cplusplus
00084 }
00085 #endif
00086 
00087 #endif