summaryrefslogtreecommitdiffstats
path: root/src/cls/cgroup.c
diff options
context:
space:
mode:
authorThomas Graf <tgr@lsx.localdomain>2009-09-02 18:31:14 +0200
committerThomas Graf <tgr@lsx.localdomain>2009-09-02 18:31:14 +0200
commitef858fb492dfe98e3ae194264fbc73649cf8493a (patch)
tree86e6c7adc5f4ba2294cb31a386c3f8d90c8b88be /src/cls/cgroup.c
parent7d249fc2e1d0cb06cd4a4dfcc0a3c425ce63def7 (diff)
downloadandroid_external_libnl-ef858fb492dfe98e3ae194264fbc73649cf8493a.tar.gz
android_external_libnl-ef858fb492dfe98e3ae194264fbc73649cf8493a.tar.bz2
android_external_libnl-ef858fb492dfe98e3ae194264fbc73649cf8493a.zip
- Reworked the classifier interface.
- Added initial ematch support - Added support for the basic classifier - Added support for the cgroup classifier
Diffstat (limited to 'src/cls/cgroup.c')
-rw-r--r--src/cls/cgroup.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/src/cls/cgroup.c b/src/cls/cgroup.c
new file mode 100644
index 0000000..ad0392f
--- /dev/null
+++ b/src/cls/cgroup.c
@@ -0,0 +1,78 @@
+/*
+ * src/cls/cgroup.c Control Groups Classifier
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2 of the License.
+ *
+ * Copyright (c) 2009 Thomas Graf <tgraf@suug.ch>
+ */
+
+#include "utils.h"
+#include <netlink/route/cls/cgroup.h>
+#include <netlink/route/cls/ematch.h>
+
+static void print_usage(void)
+{
+ printf(
+"Usage: ... cgroup [OPTIONS]...\n"
+"\n"
+"Options\n"
+" -h, --help Show this help.\n"
+" -e, --ematch=MATCH Extended match (See --ematch help).\n"
+" -c, --classid=HANDLE Target class to classify matching packets to.\n"
+ );
+ exit(0);
+}
+
+static void basic_parse_argv(struct rtnl_cls *cls, int argc, char **argv)
+{
+ for (;;) {
+ int c, optidx = 0;
+ static struct option long_opts[] = {
+ { "help", 0, 0, 'h' },
+ { "ematch", 1, 0, 'e' },
+ { "classid", 1, 0, 'c' },
+ { 0, 0, 0, 0 }
+ };
+
+ c = getopt_long(argc, argv, "he:c:", long_opts, &optidx);
+ if (c == -1)
+ break;
+
+ switch (c) {
+ case '?':
+ exit(NLE_INVAL);
+
+ case 'h':
+ print_usage();
+
+#if 0
+ case 'e':
+ if ((err = parse_ematch_syntax(optarg, &tree)) < 0)
+ fatal(err, "Error while parsing ematch: %s",
+ nl_geterror(err));
+
+ if ((err = rtnl_basic_set_ematch(cls, tree)) < 0)
+ fatal(err, "Unable to set ematch: %s",
+ nl_geterror(err));
+ break;
+#endif
+ }
+ }
+}
+
+static struct cls_module cgroup_module = {
+ .name = "cgroup",
+ .parse_argv = basic_parse_argv,
+};
+
+static void __init cgroup_init(void)
+{
+ register_cls_module(&cgroup_module);
+}
+
+static void __exit cgroup_exit(void)
+{
+ unregister_cls_module(&cgroup_module);
+}