summaryrefslogtreecommitdiff
path: root/networking/route.c
diff options
context:
space:
mode:
author"Vladimir N. Oleynik"2006-01-25 16:17:58 +0000
committer"Vladimir N. Oleynik"2006-01-25 16:17:58 +0000
commit5775aa2ef6aa749409d98e996216a3b9d6a0f7a9 (patch)
tree88da883fa287561ceb0bd67ec3904a8087bc4ab1 /networking/route.c
parent08c5a1789bc70f55fb01619e9a5aae1c5bd189ae (diff)
downloadbusybox-5775aa2ef6aa749409d98e996216a3b9d6a0f7a9.zip
busybox-5775aa2ef6aa749409d98e996216a3b9d6a0f7a9.tar.gz
added support /prefix for IPV4 form IPV6 code. Close bug 461
Diffstat (limited to 'networking/route.c')
-rw-r--r--networking/route.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/networking/route.c b/networking/route.c
index 49d219a..59c7564 100644
--- a/networking/route.c
+++ b/networking/route.c
@@ -184,14 +184,33 @@ static void INET_setroute(int action, char **args)
{
const char *target = *args++;
+ char *prefix;
+ /* recognize x.x.x.x/mask format. */
+ prefix = strchr(target, '/');
+ if(prefix) {
+ int prefix_len;
+
+ prefix_len = bb_xgetularg10_bnd(prefix+1, 0, 32);
+ mask_in_addr(rt) = htonl( ~ (0xffffffffUL >> prefix_len));
+ *prefix = '\0';
+#if HAVE_NEW_ADDRT
+ rt.rt_genmask.sa_family = AF_INET;
+#endif
+ } else {
+ /* Default netmask. */
+ netmask = bb_INET_default;
+ }
/* Prefer hostname lookup is -host flag (xflag==1) was given. */
isnet = INET_resolve(target, (struct sockaddr_in *) &rt.rt_dst,
(xflag & HOST_FLAG));
if (isnet < 0) {
bb_error_msg_and_die("resolving %s", target);
}
-
+ if(prefix) {
+ /* do not destroy prefix for process args */
+ *prefix = '/';
+ }
}
if (xflag) { /* Reinit isnet if -net or -host was specified. */
@@ -201,8 +220,6 @@ static void INET_setroute(int action, char **args)
/* Fill in the other fields. */
rt.rt_flags = ((isnet) ? RTF_UP : (RTF_UP | RTF_HOST));
- netmask = bb_INET_default;
-
while (*args) {
int k = kw_lookup(tbl_ipvx, &args);
const char *args_m1 = args[-1];