1 /* SPDX-License-Identifier: LGPL-2.1-only */
2 /*
3  * src/lib/class.c     CLI Class Helpers
4  *
5  *	This library is free software; you can redistribute it and/or
6  *	modify it under the terms of the GNU Lesser General Public
7  *	License as published by the Free Software Foundation version 2.1
8  *	of the License.
9  *
10  * Copyright (c) 2010-2011 Thomas Graf <tgraf@suug.ch>
11  */
12 
13 /**
14  * @ingroup cli
15  * @defgroup cli_class Traffic Classes
16  * @{
17  */
18 
19 #include <netlink/cli/utils.h>
20 #include <netlink/cli/class.h>
21 
nl_cli_class_alloc(void)22 struct rtnl_class *nl_cli_class_alloc(void)
23 {
24 	struct rtnl_class *class;
25 
26 	if (!(class = rtnl_class_alloc()))
27 		nl_cli_fatal(ENOMEM, "Unable to allocate class object");
28 
29 	return class;
30 }
31 
nl_cli_class_alloc_cache(struct nl_sock * sock,int ifindex)32 struct nl_cache *nl_cli_class_alloc_cache(struct nl_sock *sock, int ifindex)
33 {
34 	struct nl_cache *cache;
35 	int err;
36 
37 	if ((err = rtnl_class_alloc_cache(sock, ifindex, &cache)) < 0)
38 		nl_cli_fatal(err, "Unable to allocate class cache: %s",
39 			     nl_geterror(err));
40 
41 	nl_cache_mngt_provide(cache);
42 
43 	return cache;
44 }
45 
46 /** @} */
47