1 /* vi: set sw=4 ts=4: */
3 * This program is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU General Public License
5 * as published by the Free Software Foundation; either version
6 * 2 of the License, or (at your option) any later version.
8 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
15 const char* FAST_FUNC rtnl_rtntype_n2a(int id)
48 int FAST_FUNC rtnl_rtntype_a2n(int *id, char *arg)
50 static const char keywords[] ALIGN1 =
51 "local\0""nat\0""broadcast\0""brd\0""anycast\0"
52 "multicast\0""prohibit\0""unreachable\0""blackhole\0"
53 "xresolve\0""unicast\0""throw\0";
55 ARG_local = 1, ARG_nat, ARG_broadcast, ARG_brd, ARG_anycast,
56 ARG_multicast, ARG_prohibit, ARG_unreachable, ARG_blackhole,
57 ARG_xresolve, ARG_unicast, ARG_throw
59 const smalluint key = index_in_substrings(keywords, arg) + 1;
65 else if (key == ARG_nat)
67 else if (key == ARG_broadcast || key == ARG_brd)
69 else if (key == ARG_anycast)
71 else if (key == ARG_multicast)
73 else if (key == ARG_prohibit)
75 else if (key == ARG_unreachable)
76 res = RTN_UNREACHABLE;
77 else if (key == ARG_blackhole)
79 else if (key == ARG_xresolve)
81 else if (key == ARG_unicast)
83 else if (key == ARG_throw)
86 res = strtoul(arg, &end, 0);
87 if (end == arg || *end || res > 255)
94 int FAST_FUNC get_rt_realms(uint32_t *realms, char *arg)
97 char *p = strchr(arg, '/');
102 if (rtnl_rtrealm_a2n(realms, arg)) {
110 if (*arg && rtnl_rtrealm_a2n(&realm, arg))