2 * lib/route/cls_api.c Classifier Module 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 cls_api Classifier Modules
18 #include <netlink-local.h>
19 #include <netlink-tc.h>
20 #include <netlink/netlink.h>
21 #include <netlink/utils.h>
22 #include <netlink/route/tc.h>
23 #include <netlink/route/classifier.h>
24 #include <netlink/route/classifier-modules.h>
25 #include <netlink/route/link.h>
27 static struct rtnl_cls_ops *cls_ops_list;
30 * @name Classifier Module API
35 * Register a classifier module
36 * @arg cops classifier module operations
38 int rtnl_cls_register(struct rtnl_cls_ops *cops)
40 struct rtnl_cls_ops *o, **op;
45 for (op = &cls_ops_list; (o = *op) != NULL; op = &o->co_next)
46 if (!strcasecmp(cops->co_kind, o->co_kind))
56 * Unregister a classifier module
57 * @arg cops classifier module operations
59 int rtnl_cls_unregister(struct rtnl_cls_ops *cops)
61 struct rtnl_cls_ops *o, **op;
63 for (op = &cls_ops_list; (o = *op) != NULL; op = &o->co_next)
64 if (!strcasecmp(cops->co_kind, o->co_kind))
68 return -NLE_OBJ_NOTFOUND;
75 struct rtnl_cls_ops *__rtnl_cls_lookup_ops(const char *kind)
77 struct rtnl_cls_ops *cops;
79 for (cops = cls_ops_list; cops; cops = cops->co_next)
80 if (!strcmp(kind, cops->co_kind))
87 * Lookup classifier operations for a classifier object
88 * @arg cls Classifier object.
90 * @return Classifier operations or NULL if not found.
92 struct rtnl_cls_ops *rtnl_cls_lookup_ops(struct rtnl_cls *cls)
95 cls->c_ops = __rtnl_cls_lookup_ops(cls->c_kind);