2 * lib/route/link/api.c Link Info API
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation version 2.1
9 * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
14 * @defgroup link_info Link Info API
17 * @par 1) Registering/Unregistering a new link info type
19 * static struct rtnl_link_info_ops vlan_info_ops = {
21 * .io_alloc = vlan_alloc,
22 * .io_parse = vlan_parse,
23 * .io_dump[NL_DUMP_BRIEF] = vlan_dump_brief,
24 * .io_dump[NL_DUMP_FULL] = vlan_dump_full,
25 * .io_free = vlan_free,
28 * static void __init vlan_init(void)
30 * rtnl_link_register_info(&vlan_info_ops);
33 * static void __exit vlan_exit(void)
35 * rtnl_link_unregister_info(&vlan_info_ops);
42 #include <netlink-local.h>
43 #include <netlink/netlink.h>
44 #include <netlink/utils.h>
45 #include <netlink/route/link.h>
46 #include <netlink/route/link/info-api.h>
48 static struct rtnl_link_info_ops *info_ops;
50 struct rtnl_link_info_ops *rtnl_link_info_ops_lookup(const char *name)
52 struct rtnl_link_info_ops *ops;
54 for (ops = info_ops; ops; ops = ops->io_next)
55 if (!strcmp(ops->io_name, name))
61 int rtnl_link_register_info(struct rtnl_link_info_ops *ops)
63 if (ops->io_name == NULL)
66 if (rtnl_link_info_ops_lookup(ops->io_name))
69 NL_DBG(1, "Registered link info operations %s\n", ops->io_name);
71 ops->io_next = info_ops;
77 int rtnl_link_unregister_info(struct rtnl_link_info_ops *ops)
79 struct rtnl_link_info_ops *t, **tp;
81 for (tp = &info_ops; (t=*tp) != NULL; tp = &t->io_next)
86 return -NLE_OPNOTSUPP;
91 NL_DBG(1, "Unregistered link info perations %s\n", ops->io_name);