socsvn commit: r239474 - in soc2012/exxo/freebsd-head:
include/rpcsvc usr.bin/ypwhich
exxo at FreeBSD.org
exxo at FreeBSD.org
Mon Jul 16 17:07:23 UTC 2012
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 <bsd.prog.mk>
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);
}
More information about the svn-soc-all
mailing list