diff options
author | Pierre-Yves Ritschard <pyr@cvs.openbsd.org> | 2007-06-19 06:24:29 +0000 |
---|---|---|
committer | Pierre-Yves Ritschard <pyr@cvs.openbsd.org> | 2007-06-19 06:24:29 +0000 |
commit | c1eea903d4acc5860aa5b3e80b2d71c9a0d92358 (patch) | |
tree | 46b812279e1a33af65bb6cb414c19d47cb13cfc1 /sbin/ifconfig/ifconfig.c | |
parent | 14819d31a0a57f5e879ad3196565f50084014f86 (diff) |
Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.
ok henning@, ``looks sane'' djm@.
Diffstat (limited to 'sbin/ifconfig/ifconfig.c')
-rw-r--r-- | sbin/ifconfig/ifconfig.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 8f13ea8b423..eca72a745db 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.181 2007/06/14 18:31:50 reyk Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.182 2007/06/19 06:24:28 pyr Exp $ */ /* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */ /* @@ -3720,11 +3720,23 @@ in6_getaddr(const char *s, int which) { struct sockaddr_in6 *sin6 = sin6tab[which]; struct addrinfo hints, *res; + char buf[MAXHOSTNAMELEN+sizeof("/128")], *pfxlen; int error; memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_INET6; hints.ai_socktype = SOCK_DGRAM; /*dummy*/ + + if (which == ADDR && strchr(s, '/') != NULL) { + if (strlcpy(buf, s, sizeof(buf)) >= sizeof(buf)) + errx(1, "%s: bad value", s); + pfxlen = strchr(buf, '/'); + *pfxlen++ = '\0'; + s = buf; + in6_getprefix(pfxlen, MASK); + explicit_prefix = 1; + } + error = getaddrinfo(s, "0", &hints, &res); if (error) errx(1, "%s: %s", s, gai_strerror(error)); |