~ubuntu-branches/ubuntu/trusty/libnl3/trusty

« back to all changes in this revision

Viewing changes to src/cls/cgroup.c

  • Committer: Bazaar Package Importer
  • Author(s): Heiko Stuebner
  • Date: 2011-05-21 19:25:13 UTC
  • Revision ID: james.westby@ubuntu.com-20110521192513-1ieyu9w9kym4bt16
Tags: upstream-3.0
ImportĀ upstreamĀ versionĀ 3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * src/cls/cgroup.c     Control Groups Classifier
 
3
 *
 
4
 *      This library is free software; you can redistribute it and/or
 
5
 *      modify it under the terms of the GNU General Public License as
 
6
 *      published by the Free Software Foundation version 2 of the License.
 
7
 *
 
8
 * Copyright (c) 2009 Thomas Graf <tgraf@suug.ch>
 
9
 */
 
10
 
 
11
#include "utils.h"
 
12
#include <netlink/route/cls/cgroup.h>
 
13
#include <netlink/route/cls/ematch.h>
 
14
 
 
15
static void print_usage(void)
 
16
{
 
17
        printf(
 
18
"Usage: ... cgroup [OPTIONS]...\n"
 
19
"\n"
 
20
"Options\n"
 
21
" -h, --help                Show this help.\n"
 
22
" -e, --ematch=MATCH        Extended match (See --ematch help).\n"
 
23
" -c, --classid=HANDLE      Target class to classify matching packets to.\n"
 
24
        );
 
25
        exit(0);
 
26
}
 
27
 
 
28
static void basic_parse_argv(struct rtnl_cls *cls, int argc, char **argv)
 
29
{
 
30
        for (;;) {
 
31
                int c, optidx = 0;
 
32
                static struct option long_opts[] = {
 
33
                        { "help", 0, 0, 'h' },
 
34
                        { "ematch", 1, 0, 'e' },
 
35
                        { "classid", 1, 0, 'c' },
 
36
                        { 0, 0, 0, 0 }
 
37
                };
 
38
        
 
39
                c = getopt_long(argc, argv, "he:c:", long_opts, &optidx);
 
40
                if (c == -1)
 
41
                        break;
 
42
 
 
43
                switch (c) {
 
44
                case '?':
 
45
                        exit(NLE_INVAL);
 
46
 
 
47
                case 'h':
 
48
                        print_usage();
 
49
 
 
50
#if 0
 
51
                case 'e':
 
52
                        if ((err = parse_ematch_syntax(optarg, &tree)) < 0)
 
53
                                fatal(err, "Error while parsing ematch: %s",
 
54
                                      nl_geterror(err));
 
55
 
 
56
                        if ((err = rtnl_basic_set_ematch(cls, tree)) < 0)
 
57
                                fatal(err, "Unable to set ematch: %s",
 
58
                                        nl_geterror(err));
 
59
                        break;
 
60
#endif
 
61
                }
 
62
        }
 
63
}
 
64
 
 
65
static struct cls_module cgroup_module = {
 
66
        .name           = "cgroup",
 
67
        .parse_argv     = basic_parse_argv,
 
68
};
 
69
 
 
70
static void __init cgroup_init(void)
 
71
{
 
72
        register_cls_module(&cgroup_module);
 
73
}
 
74
 
 
75
static void __exit cgroup_exit(void)
 
76
{
 
77
        unregister_cls_module(&cgroup_module);
 
78
}