1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
/*
* src/qdisc-utils.c QDisc Helpers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* Copyright (c) 2008 Thomas Graf <tgraf@suug.ch>
*/
#include "qdisc-utils.h"
struct rtnl_qdisc *nlt_alloc_qdisc(void)
{
struct rtnl_qdisc *qdisc;
qdisc = rtnl_qdisc_alloc();
if (!qdisc)
fatal(ENOMEM, "Unable to allocate qdisc object");
return qdisc;
}
void parse_dev(struct rtnl_qdisc *qdisc, 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_qdisc_set_ifindex(qdisc, ival);
}
void parse_parent(struct rtnl_qdisc *qdisc, 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_qdisc_set_parent(qdisc, parent);
}
void parse_handle(struct rtnl_qdisc *qdisc, 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_qdisc_set_handle(qdisc, handle);
}
void parse_kind(struct rtnl_qdisc *qdisc, char *arg)
{
rtnl_qdisc_set_kind(qdisc, arg);
}
|