class.c

00001 /*
00002  * src/lib/class.c     CLI Class Helpers
00003  *
00004  *      This library is free software; you can redistribute it and/or
00005  *      modify it under the terms of the GNU Lesser General Public
00006  *      License as published by the Free Software Foundation version 2.1
00007  *      of the License.
00008  *
00009  * Copyright (c) 2010-2011 Thomas Graf <tgraf@suug.ch>
00010  */
00011 
00012 /**
00013  * @ingroup cli
00014  * @defgroup cli_class Traffic Classes
00015  * @{
00016  */
00017 
00018 #include <netlink/cli/utils.h>
00019 #include <netlink/cli/class.h>
00020 
00021 struct rtnl_class *nl_cli_class_alloc(void)
00022 {
00023         struct rtnl_class *class;
00024 
00025         if (!(class = rtnl_class_alloc()))
00026                 nl_cli_fatal(ENOMEM, "Unable to allocate class object");
00027 
00028         return class;
00029 }
00030 
00031 struct nl_cache *nl_cli_class_alloc_cache(struct nl_sock *sock, int ifindex)
00032 {
00033         struct nl_cache *cache;
00034         int err;
00035 
00036         if ((err = rtnl_class_alloc_cache(sock, ifindex, &cache)) < 0)
00037                 nl_cli_fatal(err, "Unable to allocate class cache: %s",
00038                              nl_geterror(err));
00039 
00040         nl_cache_mngt_provide(cache);
00041 
00042         return cache;
00043 }
00044 
00045 /** @} */