Merge tag 'xtensa-next-20141215' of git://github.com/czankel/xtensa-linux
[cascardo/linux.git] / net / tipc / netlink.c
index 0c00422..b891e39 100644 (file)
 
 #include "core.h"
 #include "config.h"
+#include "socket.h"
+#include "name_table.h"
 #include "bearer.h"
+#include "link.h"
+#include "node.h"
+#include "net.h"
 #include <net/genetlink.h>
 
 static int handle_cmd(struct sk_buff *skb, struct genl_info *info)
@@ -72,6 +77,13 @@ static int handle_cmd(struct sk_buff *skb, struct genl_info *info)
 static const struct nla_policy tipc_nl_policy[TIPC_NLA_MAX + 1] = {
        [TIPC_NLA_UNSPEC]       = { .type = NLA_UNSPEC, },
        [TIPC_NLA_BEARER]       = { .type = NLA_NESTED, },
+       [TIPC_NLA_SOCK]         = { .type = NLA_NESTED, },
+       [TIPC_NLA_PUBL]         = { .type = NLA_NESTED, },
+       [TIPC_NLA_LINK]         = { .type = NLA_NESTED, },
+       [TIPC_NLA_MEDIA]        = { .type = NLA_NESTED, },
+       [TIPC_NLA_NODE]         = { .type = NLA_NESTED, },
+       [TIPC_NLA_NET]          = { .type = NLA_NESTED, },
+       [TIPC_NLA_NAME_TABLE]   = { .type = NLA_NESTED, }
 };
 
 /* Legacy ASCII API */
@@ -118,9 +130,82 @@ static const struct genl_ops tipc_genl_v2_ops[] = {
                .doit   = tipc_nl_bearer_get,
                .dumpit = tipc_nl_bearer_dump,
                .policy = tipc_nl_policy,
+       },
+       {
+               .cmd    = TIPC_NL_BEARER_SET,
+               .doit   = tipc_nl_bearer_set,
+               .policy = tipc_nl_policy,
+       },
+       {
+               .cmd    = TIPC_NL_SOCK_GET,
+               .dumpit = tipc_nl_sk_dump,
+               .policy = tipc_nl_policy,
+       },
+       {
+               .cmd    = TIPC_NL_PUBL_GET,
+               .dumpit = tipc_nl_publ_dump,
+               .policy = tipc_nl_policy,
+       },
+       {
+               .cmd    = TIPC_NL_LINK_GET,
+               .doit   = tipc_nl_link_get,
+               .dumpit = tipc_nl_link_dump,
+               .policy = tipc_nl_policy,
+       },
+       {
+               .cmd    = TIPC_NL_LINK_SET,
+               .doit   = tipc_nl_link_set,
+               .policy = tipc_nl_policy,
+       },
+       {
+               .cmd    = TIPC_NL_LINK_RESET_STATS,
+               .doit   = tipc_nl_link_reset_stats,
+               .policy = tipc_nl_policy,
+       },
+       {
+               .cmd    = TIPC_NL_MEDIA_GET,
+               .doit   = tipc_nl_media_get,
+               .dumpit = tipc_nl_media_dump,
+               .policy = tipc_nl_policy,
+       },
+       {
+               .cmd    = TIPC_NL_MEDIA_SET,
+               .doit   = tipc_nl_media_set,
+               .policy = tipc_nl_policy,
+       },
+       {
+               .cmd    = TIPC_NL_NODE_GET,
+               .dumpit = tipc_nl_node_dump,
+               .policy = tipc_nl_policy,
+       },
+       {
+               .cmd    = TIPC_NL_NET_GET,
+               .dumpit = tipc_nl_net_dump,
+               .policy = tipc_nl_policy,
+       },
+       {
+               .cmd    = TIPC_NL_NET_SET,
+               .doit   = tipc_nl_net_set,
+               .policy = tipc_nl_policy,
+       },
+       {
+               .cmd    = TIPC_NL_NAME_TABLE_GET,
+               .dumpit = tipc_nl_name_table_dump,
+               .policy = tipc_nl_policy,
        }
 };
 
+int tipc_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr ***attr)
+{
+       u32 maxattr = tipc_genl_v2_family.maxattr;
+
+       *attr = tipc_genl_v2_family.attrbuf;
+       if (!*attr)
+               return -EOPNOTSUPP;
+
+       return nlmsg_parse(nlh, GENL_HDRLEN, *attr, maxattr, tipc_nl_policy);
+}
+
 int tipc_netlink_start(void)
 {
        int res;