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/utils.h>
00022 #include <netlink/route/tc.h>
00023 #include <netlink/route/classifier.h>
00024 #include <netlink/route/classifier-modules.h>
00025 #include <netlink/route/link.h>
00026
00027 static struct rtnl_cls_ops *cls_ops_list;
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 int rtnl_cls_register(struct rtnl_cls_ops *cops)
00039 {
00040 struct rtnl_cls_ops *o, **op;
00041
00042 if (!cops->co_kind)
00043 BUG();
00044
00045 for (op = &cls_ops_list; (o = *op) != NULL; op = &o->co_next)
00046 if (!strcasecmp(cops->co_kind, o->co_kind))
00047 return nl_errno(EEXIST);
00048
00049 cops->co_next = NULL;
00050 *op = cops;
00051
00052 return 0;
00053 }
00054
00055
00056
00057
00058
00059 int rtnl_cls_unregister(struct rtnl_cls_ops *cops)
00060 {
00061 struct rtnl_cls_ops *o, **op;
00062
00063 for (op = &cls_ops_list; (o = *op) != NULL; op = &o->co_next)
00064 if (!strcasecmp(cops->co_kind, o->co_kind))
00065 break;
00066
00067 if (!o)
00068 return nl_errno(ENOENT);
00069
00070 *op = cops->co_next;
00071
00072 return 0;
00073 }
00074
00075 struct rtnl_cls_ops *__rtnl_cls_lookup_ops(const char *kind)
00076 {
00077 struct rtnl_cls_ops *cops;
00078
00079 for (cops = cls_ops_list; cops; cops = cops->co_next)
00080 if (!strcmp(kind, cops->co_kind))
00081 return cops;
00082
00083 return NULL;
00084 }
00085
00086
00087
00088
00089
00090
00091
00092 struct rtnl_cls_ops *rtnl_cls_lookup_ops(struct rtnl_cls *cls)
00093 {
00094 if (!cls->c_ops)
00095 cls->c_ops = __rtnl_cls_lookup_ops(cls->c_kind);
00096
00097 return cls->c_ops;
00098 }
00099
00100
00101
00102
00103