2 * lib/route/class_api.c Queueing Classes 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 class_api Class Modules
18 #include <netlink-local.h>
19 #include <netlink-tc.h>
20 #include <netlink/netlink.h>
21 #include <netlink/route/tc.h>
22 #include <netlink/route/class.h>
23 #include <netlink/route/class-modules.h>
24 #include <netlink/utils.h>
26 static struct rtnl_class_ops *class_ops_list;
34 * Register a class module
35 * @arg cops class module operations
37 int rtnl_class_register(struct rtnl_class_ops *cops)
39 struct rtnl_class_ops *o, **op;
41 if (!cops->co_kind[0])
44 for (op = &class_ops_list; (o = *op) != NULL; op = &o->co_next)
45 if (!strcasecmp(cops->co_kind, o->co_kind))
55 * Unregister a class module
56 * @arg cops class module operations
58 int rtnl_class_unregister(struct rtnl_class_ops *cops)
60 struct rtnl_class_ops *o, **op;
62 for (op = &class_ops_list; (o = *op) != NULL; op = &o->co_next)
63 if (!strcasecmp(cops->co_kind, o->co_kind))
67 return -NLE_OBJ_NOTFOUND;
74 struct rtnl_class_ops *__rtnl_class_lookup_ops(const char *kind)
76 struct rtnl_class_ops *cops;
78 for (cops = class_ops_list; cops; cops = cops->co_next)
79 if (!strcmp(kind, cops->co_kind))
86 * Lookup class operations for a class object
87 * @arg class Class object.
89 * @return Class operations or NULL if not found.
91 struct rtnl_class_ops *rtnl_class_lookup_ops(struct rtnl_class *class)
94 class->c_ops = __rtnl_class_lookup_ops(class->c_kind);