00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <netlink-local.h>
00019 #include <netlink-tc.h>
00020 #include <netlink/netlink.h>
00021 #include <netlink/route/tc.h>
00022 #include <netlink/route/class.h>
00023 #include <netlink/route/class-modules.h>
00024 #include <netlink/utils.h>
00025
00026 static struct rtnl_class_ops *class_ops_list;
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 int rtnl_class_register(struct rtnl_class_ops *cops)
00038 {
00039 struct rtnl_class_ops *o, **op;
00040
00041 if (!cops->co_kind[0])
00042 BUG();
00043
00044 for (op = &class_ops_list; (o = *op) != NULL; op = &o->co_next)
00045 if (!strcasecmp(cops->co_kind, o->co_kind))
00046 return nl_errno(EEXIST);
00047
00048 cops->co_next = NULL;
00049 *op = cops;
00050
00051 return 0;
00052 }
00053
00054
00055
00056
00057
00058 int rtnl_class_unregister(struct rtnl_class_ops *cops)
00059 {
00060 struct rtnl_class_ops *o, **op;
00061
00062 for (op = &class_ops_list; (o = *op) != NULL; op = &o->co_next)
00063 if (!strcasecmp(cops->co_kind, o->co_kind))
00064 break;
00065
00066 if (!o)
00067 return nl_errno(ENOENT);
00068
00069 *op = cops->co_next;
00070
00071 return 0;
00072 }
00073
00074 struct rtnl_class_ops *__rtnl_class_lookup_ops(const char *kind)
00075 {
00076 struct rtnl_class_ops *cops;
00077
00078 for (cops = class_ops_list; cops; cops = cops->co_next)
00079 if (!strcmp(kind, cops->co_kind))
00080 return cops;
00081
00082 return NULL;
00083 }
00084
00085
00086
00087
00088
00089
00090
00091 struct rtnl_class_ops *rtnl_class_lookup_ops(struct rtnl_class *class)
00092 {
00093 if (!class->c_ops)
00094 class->c_ops = __rtnl_class_lookup_ops(class->c_kind);
00095
00096 return class->c_ops;
00097 }
00098
00099
00100
00101
00102