1/*
2 * src/lib/class.c     CLI Class Helpers
3 *
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
7 *	of the License.
8 *
9 * Copyright (c) 2010-2011 Thomas Graf <tgraf@suug.ch>
10 */
11
12/**
13 * @ingroup cli
14 * @defgroup cli_class Traffic Classes
15 * @{
16 */
17
18#include <netlink/cli/utils.h>
19#include <netlink/cli/class.h>
20
21struct rtnl_class *nl_cli_class_alloc(void)
22{
23	struct rtnl_class *class;
24
25	if (!(class = rtnl_class_alloc()))
26		nl_cli_fatal(ENOMEM, "Unable to allocate class object");
27
28	return class;
29}
30
31struct nl_cache *nl_cli_class_alloc_cache(struct nl_sock *sock, int ifindex)
32{
33	struct nl_cache *cache;
34	int err;
35
36	if ((err = rtnl_class_alloc_cache(sock, ifindex, &cache)) < 0)
37		nl_cli_fatal(err, "Unable to allocate class cache: %s",
38			     nl_geterror(err));
39
40	nl_cache_mngt_provide(cache);
41
42	return cache;
43}
44
45/** @} */
46