2 * src/lib/qdisc.c CLI QDisc Helpers
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) 2008-2009 Thomas Graf <tgraf@suug.ch>
14 * @defgroup cli_qdisc Queueing Disciplines
19 #include <netlink/cli/utils.h>
20 #include <netlink/cli/qdisc.h>
22 struct rtnl_qdisc *nl_cli_qdisc_alloc(void)
24 struct rtnl_qdisc *qdisc;
26 qdisc = rtnl_qdisc_alloc();
28 nl_cli_fatal(ENOMEM, "Unable to allocate qdisc object");
33 void nl_cli_qdisc_parse_dev(struct rtnl_qdisc *qdisc, struct nl_cache *link_cache, char *arg)
37 if (!(ival = rtnl_link_name2i(link_cache, arg)))
38 nl_cli_fatal(ENOENT, "Link \"%s\" does not exist", arg);
40 rtnl_qdisc_set_ifindex(qdisc, ival);
43 void nl_cli_qdisc_parse_parent(struct rtnl_qdisc *qdisc, char *arg)
48 if ((err = rtnl_tc_str2handle(arg, &parent)) < 0)
49 nl_cli_fatal(err, "Unable to parse handle \"%s\": %s",
50 arg, nl_geterror(err));
52 rtnl_qdisc_set_parent(qdisc, parent);
55 void nl_cli_qdisc_parse_handle(struct rtnl_qdisc *qdisc, char *arg)
60 if ((err = rtnl_tc_str2handle(arg, &handle)) < 0)
61 nl_cli_fatal(err, "Unable to parse handle \"%s\": %s",
62 arg, nl_geterror(err));
64 rtnl_qdisc_set_handle(qdisc, handle);
67 void nl_cli_qdisc_parse_kind(struct rtnl_qdisc *qdisc, char *arg)
69 rtnl_qdisc_set_kind(qdisc, arg);