libnl
3.2.3
|
00001 /* 00002 * src/lib/rule.c CLI Routing Rule 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) 2008-2009 Thomas Graf <tgraf@suug.ch> 00010 */ 00011 00012 /** 00013 * @ingroup cli 00014 * @defgroup cli_rule Routing Rules 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 /** @} */