diff options
author | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2000-06-30 18:17:59 +0000 |
---|---|---|
committer | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2000-06-30 18:17:59 +0000 |
commit | 803711ce6616923c9e73b0c3375058d4b486cc08 (patch) | |
tree | 8d9b8e0a3a0ed4fbe0bbba6e53bd391b341f111f /sbin | |
parent | 8507f81ec427f3c3bc034ba108ad55bbfb93f6f4 (diff) |
correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/ifconfig/ifconfig.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 6c844c8aa54..7ba9aa9c6e3 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.38 2000/05/22 03:04:11 itojun Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.39 2000/06/30 18:17:58 itojun Exp $ */ /* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */ /* @@ -81,7 +81,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94"; #else -static char rcsid[] = "$OpenBSD: ifconfig.c,v 1.38 2000/05/22 03:04:11 itojun Exp $"; +static char rcsid[] = "$OpenBSD: ifconfig.c,v 1.39 2000/06/30 18:17:58 itojun Exp $"; #endif #endif /* not lint */ @@ -767,24 +767,26 @@ gifsettunnel(src, dst) char *src; char *dst; { - struct addrinfo *srcres, *dstres; + struct addrinfo hints, *srcres, *dstres; struct ifaliasreq addreq; int ecode; - #ifdef INET6 struct in6_aliasreq in6_addreq; #endif /* INET6 */ - if ((ecode = getaddrinfo(src, NULL, NULL, &srcres)) != 0) + memset(&hints, 0, sizeof(hints)); + hints.ai_family = afp->af_af; + + if ((ecode = getaddrinfo(src, NULL, &hints, &srcres)) != 0) errx(1, "error in parsing address string: %s", gai_strerror(ecode)); - if ((ecode = getaddrinfo(dst, NULL, NULL, &dstres)) != 0) + if ((ecode = getaddrinfo(dst, NULL, &hints, &dstres)) != 0) errx(1, "error in parsing address string: %s", gai_strerror(ecode)); if (srcres->ai_addr->sa_family != dstres->ai_addr->sa_family) - errx(1, + errx(1, "source and destination address families do not match"); switch (srcres->ai_addr->sa_family) |