00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <netlink/cli/utils.h>
00020 #include <netlink/cli/rule.h>
00021
00022 struct rtnl_rule *nl_cli_rule_alloc(void)
00023 {
00024 struct rtnl_rule *rule;
00025
00026 rule = rtnl_rule_alloc();
00027 if (!rule)
00028 nl_cli_fatal(ENOMEM, "Unable to allocate rule object");
00029
00030 return rule;
00031 }
00032
00033 struct nl_cache *nl_cli_rule_alloc_cache(struct nl_sock *sk)
00034 {
00035 struct nl_cache *cache;
00036 int err;
00037
00038 if ((err = rtnl_rule_alloc_cache(sk, AF_UNSPEC, &cache)) < 0)
00039 nl_cli_fatal(err, "Unable to allocate routing rule cache: %s\n",
00040 nl_geterror(err));
00041
00042 nl_cache_mngt_provide(cache);
00043
00044 return cache;
00045 }
00046
00047 void nl_cli_rule_parse_family(struct rtnl_rule *rule, char *arg)
00048 {
00049 int family;
00050
00051 if ((family = nl_str2af(arg)) != AF_UNSPEC)
00052 rtnl_rule_set_family(rule, family);
00053 }
00054
00055