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
This commit is contained in:
Attilio Rao 2010-09-24 15:01:45 +00:00
parent 4511088221
commit 109c1de8ba
8 changed files with 19 additions and 28 deletions

View File

@ -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

View File

@ -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 <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_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)
{
/*

View File

@ -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 <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_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:

View File

@ -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 \

View File

@ -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)

View File

@ -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;

View File

@ -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;

View File

@ -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;