From owner-svn-soc-all@FreeBSD.ORG Mon Jul 16 17:07:23 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 6D3E0106566B for ; Mon, 16 Jul 2012 17:07:21 +0000 (UTC) (envelope-from exxo@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Mon, 16 Jul 2012 17:07:21 +0000 Date: Mon, 16 Jul 2012 17:07:21 +0000 From: exxo@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120716170721.6D3E0106566B@hub.freebsd.org> Cc: Subject: socsvn commit: r239474 - in soc2012/exxo/freebsd-head: include/rpcsvc usr.bin/ypwhich X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Jul 2012 17:07:23 -0000 Author: exxo Date: Mon Jul 16 17:07:21 2012 New Revision: 239474 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239474 Log: Add INET6 definitions to ypwhich Modified: soc2012/exxo/freebsd-head/include/rpcsvc/yp_prot.h soc2012/exxo/freebsd-head/usr.bin/ypwhich/Makefile soc2012/exxo/freebsd-head/usr.bin/ypwhich/ypwhich.c Modified: soc2012/exxo/freebsd-head/include/rpcsvc/yp_prot.h ============================================================================== --- soc2012/exxo/freebsd-head/include/rpcsvc/yp_prot.h Mon Jul 16 16:50:28 2012 (r239473) +++ soc2012/exxo/freebsd-head/include/rpcsvc/yp_prot.h Mon Jul 16 17:07:21 2012 (r239474) @@ -241,7 +241,9 @@ sa_family_t ypbind_binding_family; union { struct in_addr in; +#ifdef INET6 struct in6_addr in6; +#endif } ypbind_binding_addr; u_short ypbind_binding_port; }; Modified: soc2012/exxo/freebsd-head/usr.bin/ypwhich/Makefile ============================================================================== --- soc2012/exxo/freebsd-head/usr.bin/ypwhich/Makefile Mon Jul 16 16:50:28 2012 (r239473) +++ soc2012/exxo/freebsd-head/usr.bin/ypwhich/Makefile Mon Jul 16 17:07:21 2012 (r239474) @@ -5,4 +5,8 @@ WARNS?= 2 +.if ${MK_INET6_SUPPORT} != "no" +CFLAGS+= -DINET6 +.endif + .include Modified: soc2012/exxo/freebsd-head/usr.bin/ypwhich/ypwhich.c ============================================================================== --- soc2012/exxo/freebsd-head/usr.bin/ypwhich/ypwhich.c Mon Jul 16 16:50:28 2012 (r239473) +++ soc2012/exxo/freebsd-head/usr.bin/ypwhich/ypwhich.c Mon Jul 16 17:07:21 2012 (r239474) @@ -85,6 +85,11 @@ #define ypb_family ypbr.ypbind_respbody.ypbind_bindinfo.ypbind_binding_family #define ypb_addr ypbr.ypbind_respbody.ypbind_bindinfo.ypbind_binding_addr +#ifdef INET6 +# define ADDRSTRLEN INET6_ADDRSTRLEN +#else +# define ADDRSTRLEN INET_ADDRSTRLEN +#endif /* * Like yp_bind except can query a specific host @@ -97,11 +102,13 @@ struct timeval tv; CLIENT *client; int r; - char str[INET6_ADDRSTRLEN]; + char str[ADDRSTRLEN]; size_t len; union { struct in_addr in; +#ifdef INET6 struct in6_addr in6; +#endif } ss_addr; tv.tv_sec = 15; @@ -131,15 +138,17 @@ } clnt_destroy(client); bcopy(&ypb_addr, &ss_addr, sizeof(ss_addr)); - if (ypb_family == AF_INET) - len = sizeof(ss_addr.in); - else /* AF_INET6 */ +#ifdef INET6 + if (ypb_family == AF_INET6) len = sizeof(ss_addr.in6); + else /* AF_INET */ +#endif + len = sizeof(ss_addr.in); hent = gethostbyaddr((char *)&ss_addr, len, ypb_family); if (hent) printf("%s\n", hent->h_name); else - printf("%s\n", inet_ntop(ypb_family, &ss_addr, str, INET6_ADDRSTRLEN)); + printf("%s\n", inet_ntop(ypb_family, &ss_addr, str, ADDRSTRLEN)); return (0); }