]>
git.proxmox.com Git - mirror_iproute2.git/blob - ip/rtm_map.c
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
9 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
18 #include <sys/socket.h>
19 #include <netinet/in.h>
24 char *rtnl_rtntype_n2a(int id
, char *buf
, int len
)
52 snprintf(buf
, len
, "%d", id
);
58 int rtnl_rtntype_a2n(int *id
, char *arg
)
63 if (strcmp(arg
, "local") == 0)
65 else if (strcmp(arg
, "nat") == 0)
67 else if (matches(arg
, "broadcast") == 0 ||
68 strcmp(arg
, "brd") == 0)
70 else if (matches(arg
, "anycast") == 0)
72 else if (matches(arg
, "multicast") == 0)
74 else if (matches(arg
, "prohibit") == 0)
76 else if (matches(arg
, "unreachable") == 0)
77 res
= RTN_UNREACHABLE
;
78 else if (matches(arg
, "blackhole") == 0)
80 else if (matches(arg
, "xresolve") == 0)
82 else if (matches(arg
, "unicast") == 0)
84 else if (strcmp(arg
, "throw") == 0)
87 res
= strtoul(arg
, &end
, 0);
88 if (!end
|| end
== arg
|| *end
|| res
> 255)
95 static int get_rt_realms(__u32
*realms
, char *arg
)
98 char *p
= strchr(arg
, '/');
103 if (rtnl_rtrealm_a2n(realms
, arg
)) {
111 if (*arg
&& rtnl_rtrealm_a2n(&realm
, arg
))
117 int get_rt_realms_or_raw(__u32
*realms
, char *arg
)
119 if (!get_rt_realms(realms
, arg
))
122 return get_unsigned(realms
, arg
, 0);