00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include <netlink-local.h>
00043 #include <netlink/netlink.h>
00044 #include <netlink/utils.h>
00045 #include <netlink/route/link.h>
00046 #include <netlink/route/link/info-api.h>
00047
00048 static struct rtnl_link_info_ops *info_ops;
00049
00050 struct rtnl_link_info_ops *rtnl_link_info_ops_lookup(const char *name)
00051 {
00052 struct rtnl_link_info_ops *ops;
00053
00054 for (ops = info_ops; ops; ops = ops->io_next)
00055 if (!strcmp(ops->io_name, name))
00056 return ops;
00057
00058 return NULL;
00059 }
00060
00061 int rtnl_link_register_info(struct rtnl_link_info_ops *ops)
00062 {
00063 if (ops->io_name == NULL)
00064 return nl_error(EINVAL, "No name specified");
00065
00066 if (rtnl_link_info_ops_lookup(ops->io_name))
00067 return nl_error(EEXIST, "Link info operations already exist");
00068
00069 NL_DBG(1, "Registered link info operations %s\n", ops->io_name);
00070
00071 ops->io_next = info_ops;
00072 info_ops = ops;
00073
00074 return 0;
00075 }
00076
00077 int rtnl_link_unregister_info(struct rtnl_link_info_ops *ops)
00078 {
00079 struct rtnl_link_info_ops *t, **tp;
00080
00081 for (tp = &info_ops; (t=*tp) != NULL; tp = &t->io_next)
00082 if (t == ops)
00083 break;
00084
00085 if (!t)
00086 return nl_error(ENOENT, "No such link info operations");
00087
00088 if (t->io_refcnt > 0)
00089 return nl_error(EBUSY, "Info operations in use");
00090
00091 NL_DBG(1, "Unregistered link info perations %s\n", ops->io_name);
00092
00093 *tp = t->io_next;
00094 return 0;
00095 }
00096
00097
00098