6#include <netlink/cli/utils.h> 
    7#include <netlink/cli/tc.h> 
    8#include <netlink-private/route/tc-api.h> 
   15void nl_cli_tc_parse_dev(
struct rtnl_tc *tc, 
struct nl_cache *link_cache, 
char *name)
 
   21                nl_cli_fatal(ENOENT, 
"Link \"%s\" does not exist.", name);
 
   27void nl_cli_tc_parse_parent(
struct rtnl_tc *tc, 
char *arg)
 
   34                      arg, nl_geterror(err));
 
   39void nl_cli_tc_parse_handle(
struct rtnl_tc *tc, 
char *arg, 
int create)
 
   41        uint32_t handle, parent;
 
   47                if (err == -NLE_OBJ_NOTFOUND && create)
 
   48                        err = rtnl_classid_generate(arg, &handle, parent);
 
   52                                     arg, nl_geterror(err));
 
   58void nl_cli_tc_parse_mtu(
struct rtnl_tc *tc, 
char *arg)
 
   63void nl_cli_tc_parse_mpu(
struct rtnl_tc *tc, 
char *arg)
 
   68void nl_cli_tc_parse_overhead(
struct rtnl_tc *tc, 
char *arg)
 
   73void nl_cli_tc_parse_kind(
struct rtnl_tc *tc, 
char *arg)
 
   78void nl_cli_tc_parse_linktype(
struct rtnl_tc *tc, 
char *arg)
 
   82        if ((type = nl_str2llproto(arg)) < 0)
 
   83                nl_cli_fatal(type, 
"Unable to parse linktype \"%s\": %s",
 
   84                        arg, nl_geterror(type));
 
   89static NL_LIST_HEAD(tc_modules);
 
   95        nl_list_for_each_entry(tm, &tc_modules, tm_list)
 
   96                if (tm->tm_ops == ops)
 
  106        if ((tm = __nl_cli_tc_lookup(ops)))
 
  109        switch (ops->to_type) {
 
  110        case RTNL_TC_TYPE_QDISC:
 
  111        case RTNL_TC_TYPE_CLASS:
 
  112                nl_cli_load_module(
"cli/qdisc", ops->to_kind);
 
  115        case RTNL_TC_TYPE_CLS:
 
  116                nl_cli_load_module(
"cli/cls", ops->to_kind);
 
  120                nl_cli_fatal(EINVAL, 
"BUG: unhandled TC object type %d",
 
  124        if (!(tm = __nl_cli_tc_lookup(ops)))  {
 
  125                nl_cli_fatal(EINVAL, 
"Application bug: The shared library for " 
  126                        "the tc object \"%s\" was successfully loaded but it " 
  127                        "seems that module did not register itself",
 
  136        struct rtnl_tc_ops *ops;
 
  138        if (!(ops = rtnl_tc_lookup_ops(tm->tm_type, tm->tm_name))) {
 
  139                nl_cli_fatal(ENOENT, 
"Unable to register CLI TC module " 
  140                "\"%s\": No matching libnl TC module found.", tm->tm_name);
 
  143        if (__nl_cli_tc_lookup(ops)) {
 
  144                nl_cli_fatal(EEXIST, 
"Unable to register CLI TC module " 
  145                "\"%s\": Module already registered.", tm->tm_name);
 
  150        nl_list_add_tail(&tm->tm_list, &tc_modules);
 
  155        nl_list_del(&tm->tm_list);
 
int rtnl_tc_str2handle(const char *str, uint32_t *res)
Convert a charactering strint to a traffic control handle.
 
void nl_cli_fatal(int err, const char *fmt,...)
Print error message and quit application.
 
uint32_t nl_cli_parse_u32(const char *arg)
Parse a text based 32 bit unsigned integer argument.
 
struct rtnl_link * rtnl_link_get_by_name(struct nl_cache *cache, const char *name)
Lookup link in cache by link name.
 
void rtnl_link_put(struct rtnl_link *link)
Return a link object reference.
 
void rtnl_tc_set_mpu(struct rtnl_tc *tc, uint32_t mpu)
Set the Minimum Packet Unit (MPU) of a traffic control object.
 
uint32_t rtnl_tc_get_parent(struct rtnl_tc *tc)
Return parent identifier of a traffic control object.
 
void rtnl_tc_set_linktype(struct rtnl_tc *tc, uint32_t type)
Set the linktype of a traffic control object.
 
int rtnl_tc_set_kind(struct rtnl_tc *tc, const char *kind)
Define the type of traffic control object.
 
void rtnl_tc_set_overhead(struct rtnl_tc *tc, uint32_t overhead)
Set per packet overhead of a traffic control object.
 
void rtnl_tc_set_link(struct rtnl_tc *tc, struct rtnl_link *link)
Set link of traffic control object.
 
void rtnl_tc_set_handle(struct rtnl_tc *tc, uint32_t id)
Set identifier of traffic control object.
 
void rtnl_tc_set_parent(struct rtnl_tc *tc, uint32_t parent)
Set the parent identifier of a traffic control object.
 
void rtnl_tc_set_mtu(struct rtnl_tc *tc, uint32_t mtu)
Set the Maximum Transmission Unit (MTU) of traffic control object.