diff --git a/sys/conf/files b/sys/conf/files index b04fd59d877d..454764bc9918 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -2328,6 +2328,8 @@ libkern/iconv_xlat16.c optional libiconv 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 | nfsclient | nfscl | nfsd 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 diff --git a/sys/rpc/inet_ntop.c b/sys/libkern/inet_ntop.c similarity index 92% rename from sys/rpc/inet_ntop.c rename to sys/libkern/inet_ntop.c index d093a970345b..ce7d93eb9d35 100644 --- a/sys/rpc/inet_ntop.c +++ b/sys/libkern/inet_ntop.c @@ -22,20 +22,18 @@ static const char rcsid[] = "$Id: inet_ntop.c,v 1.3.18.2 2005/11/03 23:02:22 mar __FBSDID("$FreeBSD$"); #include -#include #include #include -#include -#include +#include /*% * 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_char *src, char *dst, socklen_t size); * 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 * __restrict src, char * __restrict dst, * 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, socklen_t size) * author: * Paul Vixie, 1996. */ -static const char * +static char * inet_ntop6(const u_char *src, char *dst, socklen_t size) { /* diff --git a/sys/rpc/inet_pton.c b/sys/libkern/inet_pton.c similarity index 97% rename from sys/rpc/inet_pton.c rename to sys/libkern/inet_pton.c index 3881da9e2452..f8b7293bfa83 100644 --- a/sys/rpc/inet_pton.c +++ b/sys/libkern/inet_pton.c @@ -22,12 +22,10 @@ static const char rcsid[] = "$Id: inet_pton.c,v 1.3.18.2 2005/07/28 07:38:07 mar __FBSDID("$FreeBSD$"); #include -#include #include #include -#include -#include +#include #if __FreeBSD_version < 700000 #define strchr index @@ -53,7 +51,7 @@ static int inet_pton6(const char *src, u_char *dst); * 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: diff --git a/sys/modules/krpc/Makefile b/sys/modules/krpc/Makefile index ab52f5bdbd4d..2f3d3a7f0ae3 100644 --- a/sys/modules/krpc/Makefile +++ b/sys/modules/krpc/Makefile @@ -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 \ diff --git a/sys/netinet/in.h b/sys/netinet/in.h index e453b692e751..d5e429059864 100644 --- a/sys/netinet/in.h +++ b/sys/netinet/in.h @@ -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) diff --git a/sys/nlm/nlm_prot_impl.c b/sys/nlm/nlm_prot_impl.c index f6b296d6f3c9..5f7f8e17daa0 100644 --- a/sys/nlm/nlm_prot_impl.c +++ b/sys/nlm/nlm_prot_impl.c @@ -1055,13 +1055,13 @@ nlm_find_host_by_addr(const struct sockaddr *addr, int vers) 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; diff --git a/sys/rpc/rpc_com.h b/sys/rpc/rpc_com.h index e50e513f5674..290a289e3a48 100644 --- a/sys/rpc/rpc_com.h +++ b/sys/rpc/rpc_com.h @@ -111,10 +111,6 @@ extern struct netbuf *__rpc_uaddr2taddr_af(int, const char *); 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; diff --git a/sys/rpc/rpc_generic.c b/sys/rpc/rpc_generic.c index f15ad28f294a..efc0cb0ce611 100644 --- a/sys/rpc/rpc_generic.c +++ b/sys/rpc/rpc_generic.c @@ -306,7 +306,7 @@ __rpc_taddr2uaddr_af(int af, const struct netbuf *nbuf) 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 struct netbuf *nbuf) #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 *uaddr) 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 *uaddr) 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;