From 7dbf4d59030c67e7e1c85252802223d706392567 Mon Sep 17 00:00:00 2001 From: Cong Wang Date: Wed, 29 Jan 2014 15:45:02 -0800 Subject: [PATCH] remove the obsolete src/cls directory Signed-off-by: Cong Wang Signed-off-by: Thomas Haller --- src/cls/basic.c | 90 ---------------------------------------- src/cls/cgroup.c | 78 ----------------------------------- src/cls/utils.c | 105 ----------------------------------------------- src/cls/utils.h | 51 ----------------------- 4 files changed, 324 deletions(-) delete mode 100644 src/cls/basic.c delete mode 100644 src/cls/cgroup.c delete mode 100644 src/cls/utils.c delete mode 100644 src/cls/utils.h diff --git a/src/cls/basic.c b/src/cls/basic.c deleted file mode 100644 index df1c112..0000000 --- a/src/cls/basic.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * src/cls/basic.c Basic 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) 2008 Thomas Graf - */ - -#include "utils.h" -#include -#include - -static void print_usage(void) -{ - printf( -"Usage: ... basic [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) -{ - uint32_t classid; - - for (;;) { - int c, optidx = 0, err; - 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(); - - case 'e': -#if 0 - 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)); -#endif - break; - - case 'c': - if ((err = rtnl_tc_str2handle(optarg, &classid)) < 0) - fatal(err, "Invalid classid \"%s\": %s", - optarg, nl_geterror(err)); - - if ((err = rtnl_basic_set_classid(cls, classid)) < 0) - fatal(err, "Unable to set classid: %s", - nl_geterror(err)); - break; - } - } -} - -static struct cls_module basic_module = { - .name = "basic", - .parse_argv = basic_parse_argv, -}; - -static void __attribute__ ((constructor)) basic_init(void) -{ - register_cls_module(&basic_module); -} - -static void __attribute__ ((destructor)) basic_exit(void) -{ - unregister_cls_module(&basic_module); -} diff --git a/src/cls/cgroup.c b/src/cls/cgroup.c deleted file mode 100644 index ad0392f..0000000 --- a/src/cls/cgroup.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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 - */ - -#include "utils.h" -#include -#include - -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); -} diff --git a/src/cls/utils.c b/src/cls/utils.c deleted file mode 100644 index ef6603b..0000000 --- a/src/cls/utils.c +++ /dev/null @@ -1,105 +0,0 @@ -/* - * src/cls-utils.c Classifier Helpers - * - * 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) 2008-2009 Thomas Graf - */ - -#include "utils.h" - -struct rtnl_cls *nlt_alloc_cls(void) -{ - struct rtnl_cls *cls; - - cls = rtnl_cls_alloc(); - if (!cls) - fatal(ENOMEM, "Unable to allocate classifier object"); - - return cls; -} - -void parse_dev(struct rtnl_cls *cls, struct nl_cache *link_cache, char *arg) -{ - int ival; - - if (!(ival = rtnl_link_name2i(link_cache, arg))) - fatal(ENOENT, "Link \"%s\" does not exist", arg); - - rtnl_cls_set_ifindex(cls, ival); -} - -void parse_prio(struct rtnl_cls *cls, char *arg) -{ - uint32_t prio = parse_u32(arg); - rtnl_cls_set_prio(cls, prio); -} - -void parse_parent(struct rtnl_cls *cls, char *arg) -{ - uint32_t parent; - int err; - - if ((err = rtnl_tc_str2handle(arg, &parent)) < 0) - fatal(err, "Unable to parse handle \"%s\": %s", - arg, nl_geterror(err)); - - rtnl_cls_set_parent(cls, parent); -} - -void parse_handle(struct rtnl_cls *cls, char *arg) -{ - uint32_t handle; - int err; - - if ((err = rtnl_tc_str2handle(arg, &handle)) < 0) - fatal(err, "Unable to parse handle \"%s\": %s", - arg, nl_geterror(err)); - - rtnl_cls_set_handle(cls, handle); -} - -void parse_proto(struct rtnl_cls *cls, char *arg) -{ - int proto = nl_str2ether_proto(arg); - if (proto < 0) - fatal(proto, "Unable to parse protocol \"%s\": %s", - arg, nl_geterror(proto)); - rtnl_cls_set_protocol(cls, proto); -} - -static NL_LIST_HEAD(cls_modules); - -struct cls_module *lookup_cls_mod(struct rtnl_cls_ops *ops) -{ - struct cls_module *mod; - - nl_list_for_each_entry(mod, &cls_modules, list) { - if (mod->ops == ops) - return mod; - } - - return NULL; -} - -void register_cls_module(struct cls_module *mod) -{ - struct rtnl_cls_ops *ops; - - if (!(ops = __rtnl_cls_lookup_ops(mod->name))) - fatal(ENOENT, "Could not locate classifier module \"%s\"", - mod->name); - - if (lookup_cls_mod(ops) != NULL) - fatal(EEXIST, "Duplicate classifier module registration."); - - mod->ops = ops; - nl_list_add_tail(&mod->list, &cls_modules); -} - -void unregister_cls_module(struct cls_module *mod) -{ - nl_list_del(&mod->list); -} diff --git a/src/cls/utils.h b/src/cls/utils.h deleted file mode 100644 index 1a8ee9b..0000000 --- a/src/cls/utils.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * src/cls-utils.h Classifier Helpers - * - * 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) 2008-2009 Thomas Graf - */ - -#ifndef __CLS_UTILS_H_ -#define __CLS_UTILS_H_ - -#include "../utils.h" -#include -#include - -struct cls_module -{ - const char * name; - struct rtnl_cls_ops * ops; - void (*parse_argv)(struct rtnl_cls *, int, char **); - struct nl_list_head list; -}; - -extern struct cls_module *lookup_cls_mod(struct rtnl_cls_ops *); -extern void register_cls_module(struct cls_module *); -extern void unregister_cls_module(struct cls_module *); - -struct ematch_module -{ - int kind; - struct rtnl_ematch_ops *ops; - void (*parse_argv)(struct rtnl_ematch *, int, char **); - struct nl_list_head list; -}; - -extern struct ematch_module *lookup_ematch_mod(struct rtnl_ematch_ops *); -extern void register_ematch_module(struct ematch_module *); -extern void unregister_ematch_module(struct ematch_module *); - -extern struct rtnl_cls *nlt_alloc_cls(void); -extern void parse_dev(struct rtnl_cls *, struct nl_cache *, char *); -extern void parse_prio(struct rtnl_cls *, char *); -extern void parse_parent(struct rtnl_cls *, char *); -extern void parse_handle(struct rtnl_cls *, char *); -extern void parse_proto(struct rtnl_cls *, char *); - -extern int parse_ematch_syntax(const char *, struct rtnl_ematch_tree **); - -#endif -- 2.40.0