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>
18 const char* FAST_FUNC rtnl_rtntype_n2a(int id, char *buf)
46 /* buf is SPRINT_BSIZE big */
47 sprintf(buf, "%d", id);
53 int FAST_FUNC rtnl_rtntype_a2n(int *id, char *arg)
55 static const char keywords[] ALIGN1 =
56 "local\0""nat\0""broadcast\0""brd\0""anycast\0"
57 "multicast\0""prohibit\0""unreachable\0""blackhole\0"
58 "xresolve\0""unicast\0""throw\0";
60 ARG_local = 1, ARG_nat, ARG_broadcast, ARG_brd, ARG_anycast,
61 ARG_multicast, ARG_prohibit, ARG_unreachable, ARG_blackhole,
62 ARG_xresolve, ARG_unicast, ARG_throw
64 const smalluint key = index_in_substrings(keywords, arg) + 1;
70 else if (key == ARG_nat)
72 else if (key == ARG_broadcast || key == ARG_brd)
74 else if (key == ARG_anycast)
76 else if (key == ARG_multicast)
78 else if (key == ARG_prohibit)
80 else if (key == ARG_unreachable)
81 res = RTN_UNREACHABLE;
82 else if (key == ARG_blackhole)
84 else if (key == ARG_xresolve)
86 else if (key == ARG_unicast)
88 else if (key == ARG_throw)
91 res = strtoul(arg, &end, 0);
92 if (end == arg || *end || res > 255)
99 int FAST_FUNC get_rt_realms(uint32_t *realms, char *arg)
102 char *p = strchr(arg, '/');
107 if (rtnl_rtrealm_a2n(realms, arg)) {
115 if (*arg && rtnl_rtrealm_a2n(&realm, arg))