diff options
author | Stuart Henderson <sthen@cvs.openbsd.org> | 2013-05-27 14:07:26 +0000 |
---|---|---|
committer | Stuart Henderson <sthen@cvs.openbsd.org> | 2013-05-27 14:07:26 +0000 |
commit | d8f8ffbfe872f63ffe8217f953edd43675e77f85 (patch) | |
tree | 39bfb42e648effabaeb7ee55f407cc5f0d8ef5ca /sbin/route | |
parent | 36e6d30b3dc7b6db02a21310abacbed16cbf6f77 (diff) |
autodetect ipv6 addresses for route(8). ok benno@ bluhm@, manpage help jmc@
Diffstat (limited to 'sbin/route')
-rw-r--r-- | sbin/route/route.8 | 9 | ||||
-rw-r--r-- | sbin/route/route.c | 11 |
2 files changed, 15 insertions, 5 deletions
diff --git a/sbin/route/route.8 b/sbin/route/route.8 index dd978e077b8..0644fcc9364 100644 --- a/sbin/route/route.8 +++ b/sbin/route/route.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: route.8,v 1.70 2012/07/13 10:15:53 benno Exp $ +.\" $OpenBSD: route.8,v 1.71 2013/05/27 14:07:25 sthen Exp $ .\" $NetBSD: route.8,v 1.6 1995/03/18 15:00:13 cgd Exp $ .\" .\" Copyright (c) 1983, 1991, 1993 @@ -30,7 +30,7 @@ .\" .\" @(#)route.8 8.3 (Berkeley) 3/19/94 .\" -.Dd $Mdocdate: July 13 2012 $ +.Dd $Mdocdate: May 27 2013 $ .Dt ROUTE 8 .Os .Sh NAME @@ -310,6 +310,11 @@ Actual data, in hexadecimal format .El .Pp +In the absence of modifiers, an address is assumed to be IPv4, +unless containing a +.Sq :\& +character, when it is treated as IPv6. +.Pp The optional modifier .Fl link specifies that all subsequent addresses are specified as link-level addresses, diff --git a/sbin/route/route.c b/sbin/route/route.c index c623d4ff7a8..399c4206084 100644 --- a/sbin/route/route.c +++ b/sbin/route/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.161 2013/03/21 04:43:17 deraadt Exp $ */ +/* $OpenBSD: route.c,v 1.162 2013/05/27 14:07:25 sthen Exp $ */ /* $NetBSD: route.c,v 1.16 1996/04/15 18:27:05 cgd Exp $ */ /* @@ -803,8 +803,13 @@ getaddr(int which, char *s, struct hostent **hpp) int afamily, bits; if (af == 0) { - af = AF_INET; - aflen = sizeof(struct sockaddr_in); + if (strchr(s, ':') != NULL) { + af = AF_INET6; + aflen = sizeof(struct sockaddr_in6); + } else { + af = AF_INET; + aflen = sizeof(struct sockaddr_in); + } } afamily = af; /* local copy of af so we can change it */ |