1 /* vi: set sw=4 ts=4: */
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version.
10 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
20 char *rtnl_rtntype_n2a(int id, char *buf, int len)
48 snprintf(buf, len, "%d", id);
54 int rtnl_rtntype_a2n(int *id, char *arg)
59 if (strcmp(arg, "local") == 0)
61 else if (strcmp(arg, "nat") == 0)
63 else if (matches(arg, "broadcast") == 0 ||
64 strcmp(arg, "brd") == 0)
66 else if (matches(arg, "anycast") == 0)
68 else if (matches(arg, "multicast") == 0)
70 else if (matches(arg, "prohibit") == 0)
72 else if (matches(arg, "unreachable") == 0)
73 res = RTN_UNREACHABLE;
74 else if (matches(arg, "blackhole") == 0)
76 else if (matches(arg, "xresolve") == 0)
78 else if (matches(arg, "unicast") == 0)
80 else if (strcmp(arg, "throw") == 0)
83 res = strtoul(arg, &end, 0);
84 if (!end || end == arg || *end || res > 255)
91 int get_rt_realms(__u32 *realms, char *arg)
94 char *p = strchr(arg, '/');
99 if (rtnl_rtrealm_a2n(realms, arg)) {
107 if (*arg && rtnl_rtrealm_a2n(&realm, arg))