00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <netlink/cli/utils.h>
00020 #include <netlink/cli/qdisc.h>
00021
00022 struct rtnl_qdisc *nl_cli_qdisc_alloc(void)
00023 {
00024 struct rtnl_qdisc *qdisc;
00025
00026 qdisc = rtnl_qdisc_alloc();
00027 if (!qdisc)
00028 nl_cli_fatal(ENOMEM, "Unable to allocate qdisc object");
00029
00030 return qdisc;
00031 }
00032
00033 void nl_cli_qdisc_parse_dev(struct rtnl_qdisc *qdisc, struct nl_cache *link_cache, char *arg)
00034 {
00035 int ival;
00036
00037 if (!(ival = rtnl_link_name2i(link_cache, arg)))
00038 nl_cli_fatal(ENOENT, "Link \"%s\" does not exist", arg);
00039
00040 rtnl_qdisc_set_ifindex(qdisc, ival);
00041 }
00042
00043 void nl_cli_qdisc_parse_parent(struct rtnl_qdisc *qdisc, char *arg)
00044 {
00045 uint32_t parent;
00046 int err;
00047
00048 if ((err = rtnl_tc_str2handle(arg, &parent)) < 0)
00049 nl_cli_fatal(err, "Unable to parse handle \"%s\": %s",
00050 arg, nl_geterror(err));
00051
00052 rtnl_qdisc_set_parent(qdisc, parent);
00053 }
00054
00055 void nl_cli_qdisc_parse_handle(struct rtnl_qdisc *qdisc, char *arg)
00056 {
00057 uint32_t handle;
00058 int err;
00059
00060 if ((err = rtnl_tc_str2handle(arg, &handle)) < 0)
00061 nl_cli_fatal(err, "Unable to parse handle \"%s\": %s",
00062 arg, nl_geterror(err));
00063
00064 rtnl_qdisc_set_handle(qdisc, handle);
00065 }
00066
00067 void nl_cli_qdisc_parse_kind(struct rtnl_qdisc *qdisc, char *arg)
00068 {
00069 rtnl_qdisc_set_kind(qdisc, arg);
00070 }
00071
00072