svn commit: r213103 - in head/sys: conf libkern modules/krpc netinet nlm rpc

Attilio Rao attilio at FreeBSD.org
Fri Sep 24 15:01:45 UTC 2010


Author: attilio
Date: Fri Sep 24 15:01:45 2010
New Revision: 213103
URL: http://svn.freebsd.org/changeset/base/213103

Log:
  Make the RPC specific __rpc_inet_ntop() and __rpc_inet_pton() general
  in the kernel (just as inet_ntoa() and inet_aton()) are and sync their
  prototype accordingly with already mentioned functions.
  
  Sponsored by:	Sandvine Incorporated
  Reviewed by:	emaste, rstone
  Approved by:	dfr
  MFC after:	2 weeks

Added:
  head/sys/libkern/inet_ntop.c
     - copied, changed from r213102, head/sys/rpc/inet_ntop.c
  head/sys/libkern/inet_pton.c
     - copied, changed from r213102, head/sys/rpc/inet_pton.c
Deleted:
  head/sys/rpc/inet_ntop.c
  head/sys/rpc/inet_pton.c
Modified:
  head/sys/conf/files
  head/sys/modules/krpc/Makefile
  head/sys/netinet/in.h
  head/sys/nlm/nlm_prot_impl.c
  head/sys/rpc/rpc_com.h
  head/sys/rpc/rpc_generic.c

Modified: head/sys/conf/files
==============================================================================
--- head/sys/conf/files	Fri Sep 24 14:44:04 2010	(r213102)
+++ head/sys/conf/files	Fri Sep 24 15:01:45 2010	(r213103)
@@ -2328,6 +2328,8 @@ libkern/iconv_xlat16.c		optional libicon
 libkern/index.c			standard
 libkern/inet_aton.c		standard
 libkern/inet_ntoa.c		standard
+libkern/inet_ntop.c		standard
+libkern/inet_pton.c		standard
 libkern/mcount.c		optional profiling-routine
 libkern/memcmp.c		standard
 libkern/qsort.c			standard
@@ -2735,8 +2737,6 @@ rpc/clnt_dg.c			optional krpc | nfslockd
 rpc/clnt_rc.c			optional krpc | nfslockd | nfsclient | nfscl | nfsd
 rpc/clnt_vc.c			optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd
 rpc/getnetconfig.c		optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd
-rpc/inet_ntop.c			optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd
-rpc/inet_pton.c			optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd
 rpc/replay.c			optional krpc | nfslockd | nfsserver | nfscl | nfsd
 rpc/rpc_callmsg.c		optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd
 rpc/rpc_generic.c		optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd

Copied and modified: head/sys/libkern/inet_ntop.c (from r213102, head/sys/rpc/inet_ntop.c)
==============================================================================
--- head/sys/rpc/inet_ntop.c	Fri Sep 24 14:44:04 2010	(r213102, copy source)
+++ head/sys/libkern/inet_ntop.c	Fri Sep 24 15:01:45 2010	(r213103)
@@ -22,20 +22,18 @@ static const char rcsid[] = "$Id: inet_n
 __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
-#include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/systm.h>
 
-#include <rpc/types.h>
-#include <rpc/rpc_com.h>
+#include <netinet/in.h>
 
 /*%
  * WARNING: Don't even consider trying to compile this on a system where
  * sizeof(int) < 4.  sizeof(int) > 4 is fine; all the world's not a VAX.
  */
 
-static const char *inet_ntop4(const u_char *src, char *dst, socklen_t size);
-static const char *inet_ntop6(const u_char *src, char *dst, socklen_t size);
+static char	*inet_ntop4(const u_char *src, char *dst, socklen_t size);
+static char	*inet_ntop6(const u_char *src, char *dst, socklen_t size);
 
 /* char *
  * inet_ntop(af, src, dst, size)
@@ -45,9 +43,8 @@ static const char *inet_ntop6(const u_ch
  * author:
  *	Paul Vixie, 1996.
  */
-const char *
-__rpc_inet_ntop(int af, const void * __restrict src, char * __restrict dst,
-    socklen_t size)
+char *
+inet_ntop(int af, const void *src, char *dst, socklen_t size)
 {
 	switch (af) {
 	case AF_INET:
@@ -71,7 +68,7 @@ __rpc_inet_ntop(int af, const void * __r
  * author:
  *	Paul Vixie, 1996.
  */
-static const char *
+static char *
 inet_ntop4(const u_char *src, char *dst, socklen_t size)
 {
 	static const char fmt[] = "%u.%u.%u.%u";
@@ -92,7 +89,7 @@ inet_ntop4(const u_char *src, char *dst,
  * author:
  *	Paul Vixie, 1996.
  */
-static const char *
+static char *
 inet_ntop6(const u_char *src, char *dst, socklen_t size)
 {
 	/*

Copied and modified: head/sys/libkern/inet_pton.c (from r213102, head/sys/rpc/inet_pton.c)
==============================================================================
--- head/sys/rpc/inet_pton.c	Fri Sep 24 14:44:04 2010	(r213102, copy source)
+++ head/sys/libkern/inet_pton.c	Fri Sep 24 15:01:45 2010	(r213103)
@@ -22,12 +22,10 @@ static const char rcsid[] = "$Id: inet_p
 __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
-#include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/systm.h>
 
-#include <rpc/types.h>
-#include <rpc/rpc_com.h>
+#include <netinet/in.h>
 
 #if __FreeBSD_version < 700000
 #define strchr index
@@ -53,7 +51,7 @@ static int	inet_pton6(const char *src, u
  *	Paul Vixie, 1996.
  */
 int
-__rpc_inet_pton(int af, const char * __restrict src, void * __restrict dst)
+inet_pton(int af, const char *src, void *dst)
 {
 	switch (af) {
 	case AF_INET:

Modified: head/sys/modules/krpc/Makefile
==============================================================================
--- head/sys/modules/krpc/Makefile	Fri Sep 24 14:44:04 2010	(r213102)
+++ head/sys/modules/krpc/Makefile	Fri Sep 24 15:01:45 2010	(r213103)
@@ -9,8 +9,6 @@ SRCS=	auth_none.c \
 	clnt_rc.c \
 	clnt_vc.c \
 	getnetconfig.c \
-	inet_ntop.c \
-	inet_pton.c \
 	rpc_callmsg.c \
 	rpc_generic.c \
 	rpc_prot.c \

Modified: head/sys/netinet/in.h
==============================================================================
--- head/sys/netinet/in.h	Fri Sep 24 14:44:04 2010	(r213102)
+++ head/sys/netinet/in.h	Fri Sep 24 15:01:45 2010	(r213103)
@@ -726,6 +726,8 @@ int	 in_localip(struct in_addr);
 int	 inet_aton(const char *, struct in_addr *); /* in libkern */
 char	*inet_ntoa(struct in_addr); /* in libkern */
 char	*inet_ntoa_r(struct in_addr ina, char *buf); /* in libkern */
+char	*inet_ntop(int, const void *, char *, socklen_t); /* in libkern */
+int	 inet_pton(int af, const char *, void *); /* in libkern */
 void	 in_ifdetach(struct ifnet *);
 
 #define	in_hosteq(s, t)	((s).s_addr == (t).s_addr)

Modified: head/sys/nlm/nlm_prot_impl.c
==============================================================================
--- head/sys/nlm/nlm_prot_impl.c	Fri Sep 24 14:44:04 2010	(r213102)
+++ head/sys/nlm/nlm_prot_impl.c	Fri Sep 24 15:01:45 2010	(r213103)
@@ -1055,13 +1055,13 @@ nlm_find_host_by_addr(const struct socka
 
 	switch (addr->sa_family) {
 	case AF_INET:
-		__rpc_inet_ntop(AF_INET,
+		inet_ntop(AF_INET,
 		    &((const struct sockaddr_in *) addr)->sin_addr,
 		    tmp, sizeof tmp);
 		break;
 #ifdef INET6
 	case AF_INET6:
-		__rpc_inet_ntop(AF_INET6,
+		inet_ntop(AF_INET6,
 		    &((const struct sockaddr_in6 *) addr)->sin6_addr,
 		    tmp, sizeof tmp);
 		break;

Modified: head/sys/rpc/rpc_com.h
==============================================================================
--- head/sys/rpc/rpc_com.h	Fri Sep 24 14:44:04 2010	(r213102)
+++ head/sys/rpc/rpc_com.h	Fri Sep 24 15:01:45 2010	(r213103)
@@ -111,10 +111,6 @@ extern struct netbuf *__rpc_uaddr2taddr_
 extern int __rpc_seman2socktype(int);
 extern int __rpc_socktype2seman(int);
 extern int __rpc_sockisbound(struct socket*);
-extern const char *__rpc_inet_ntop(int af, const void * __restrict src,
-    char * __restrict dst, socklen_t size);
-extern int __rpc_inet_pton(int af, const char * __restrict src,
-    void * __restrict dst);
 extern int bindresvport(struct socket *so, struct sockaddr *sa);
 
 struct xucred;

Modified: head/sys/rpc/rpc_generic.c
==============================================================================
--- head/sys/rpc/rpc_generic.c	Fri Sep 24 14:44:04 2010	(r213102)
+++ head/sys/rpc/rpc_generic.c	Fri Sep 24 15:01:45 2010	(r213103)
@@ -306,7 +306,7 @@ __rpc_taddr2uaddr_af(int af, const struc
 	switch (af) {
 	case AF_INET:
 		sin = nbuf->buf;
-		if (__rpc_inet_ntop(af, &sin->sin_addr, namebuf, sizeof namebuf)
+		if (inet_ntop(af, &sin->sin_addr, namebuf, sizeof namebuf)
 		    == NULL)
 			return NULL;
 		port = ntohs(sin->sin_port);
@@ -318,7 +318,7 @@ __rpc_taddr2uaddr_af(int af, const struc
 #ifdef INET6
 	case AF_INET6:
 		sin6 = nbuf->buf;
-		if (__rpc_inet_ntop(af, &sin6->sin6_addr, namebuf6, sizeof namebuf6)
+		if (inet_ntop(af, &sin6->sin6_addr, namebuf6, sizeof namebuf6)
 		    == NULL)
 			return NULL;
 		port = ntohs(sin6->sin6_port);
@@ -396,7 +396,7 @@ __rpc_uaddr2taddr_af(int af, const char 
 		memset(sin, 0, sizeof *sin);
 		sin->sin_family = AF_INET;
 		sin->sin_port = htons(port);
-		if (__rpc_inet_pton(AF_INET, addrstr, &sin->sin_addr) <= 0) {
+		if (inet_pton(AF_INET, addrstr, &sin->sin_addr) <= 0) {
 			free(sin, M_RPC);
 			free(ret, M_RPC);
 			ret = NULL;
@@ -414,7 +414,7 @@ __rpc_uaddr2taddr_af(int af, const char 
 		memset(sin6, 0, sizeof *sin6);
 		sin6->sin6_family = AF_INET6;
 		sin6->sin6_port = htons(port);
-		if (__rpc_inet_pton(AF_INET6, addrstr, &sin6->sin6_addr) <= 0) {
+		if (inet_pton(AF_INET6, addrstr, &sin6->sin6_addr) <= 0) {
 			free(sin6, M_RPC);
 			free(ret, M_RPC);
 			ret = NULL;


More information about the svn-src-all mailing list