2 * src/lib/rule.c CLI Routing Rule Helpers
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
9 * Copyright (c) 2008-2009 Thomas Graf <tgraf@suug.ch>
14 * @defgroup cli_rule Routing Rules
19 #include <netlink/cli/utils.h>
20 #include <netlink/cli/rule.h>
22 struct rtnl_rule *nl_cli_rule_alloc(void)
24 struct rtnl_rule *rule;
26 rule = rtnl_rule_alloc();
28 nl_cli_fatal(ENOMEM, "Unable to allocate rule object");
33 struct nl_cache *nl_cli_rule_alloc_cache(struct nl_sock *sk)
35 struct nl_cache *cache;
38 if ((err = rtnl_rule_alloc_cache(sk, AF_UNSPEC, &cache)) < 0)
39 nl_cli_fatal(err, "Unable to allocate routing rule cache: %s\n",
42 nl_cache_mngt_provide(cache);
47 void nl_cli_rule_parse_family(struct rtnl_rule *rule, char *arg)
51 if ((family = nl_str2af(arg)) != AF_UNSPEC)
52 rtnl_rule_set_family(rule, family);