summaryrefslogtreecommitdiffstats
path: root/libc/inet/rpc/pmap_rmt.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc/inet/rpc/pmap_rmt.c')
-rw-r--r--libc/inet/rpc/pmap_rmt.c138
1 files changed, 75 insertions, 63 deletions
diff --git a/libc/inet/rpc/pmap_rmt.c b/libc/inet/rpc/pmap_rmt.c
index dbba18378..badb6a467 100644
--- a/libc/inet/rpc/pmap_rmt.c
+++ b/libc/inet/rpc/pmap_rmt.c
@@ -39,20 +39,6 @@ static char sccsid[] = "@(#)pmap_rmt.c 1.21 87/08/27 Copyr 1984 Sun Micro";
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
-#define authunix_create_default __authunix_create_default
-#define xdrmem_create __xdrmem_create
-#define xdr_callmsg __xdr_callmsg
-#define xdr_replymsg __xdr_replymsg
-#define xdr_reference __xdr_reference
-#define xdr_u_long __xdr_u_long
-#define inet_makeaddr __inet_makeaddr
-#define inet_netof __inet_netof
-#define clntudp_create __clntudp_create
-#define setsockopt __setsockopt
-#define recvfrom __recvfrom
-#define sendto __sendto
-#define poll __poll
-
#define __FORCE_GLIBC
#include <features.h>
@@ -73,40 +59,32 @@ static char sccsid[] = "@(#)pmap_rmt.c 1.21 87/08/27 Copyr 1984 Sun Micro";
#include <arpa/inet.h>
#define MAX_BROADCAST_SIZE 1400
-extern u_long _create_xid (void) attribute_hidden;
+libc_hidden_proto(memset)
+libc_hidden_proto(ioctl)
+libc_hidden_proto(perror)
+libc_hidden_proto(socket)
+libc_hidden_proto(close)
+libc_hidden_proto(authunix_create_default)
+libc_hidden_proto(xdrmem_create)
+libc_hidden_proto(xdr_callmsg)
+libc_hidden_proto(xdr_replymsg)
+libc_hidden_proto(xdr_reference)
+libc_hidden_proto(xdr_u_long)
+libc_hidden_proto(xdr_void)
+libc_hidden_proto(xdr_rmtcallres)
+libc_hidden_proto(inet_makeaddr)
+libc_hidden_proto(inet_netof)
+libc_hidden_proto(clntudp_create)
+libc_hidden_proto(setsockopt)
+libc_hidden_proto(recvfrom)
+libc_hidden_proto(sendto)
+libc_hidden_proto(poll)
+libc_hidden_proto(fprintf)
-static const struct timeval timeout = {3, 0};
-/*
- * XDR remote call arguments
- * written for XDR_ENCODE direction only
- */
-bool_t attribute_hidden
-__xdr_rmtcall_args (XDR *xdrs, struct rmtcallargs *cap)
-{
- u_int lenposition, argposition, position;
+extern u_long _create_xid (void) attribute_hidden;
- if (xdr_u_long (xdrs, &(cap->prog)) &&
- xdr_u_long (xdrs, &(cap->vers)) &&
- xdr_u_long (xdrs, &(cap->proc)))
- {
- lenposition = XDR_GETPOS (xdrs);
- if (!xdr_u_long (xdrs, &(cap->arglen)))
- return FALSE;
- argposition = XDR_GETPOS (xdrs);
- if (!(*(cap->xdr_args)) (xdrs, cap->args_ptr))
- return FALSE;
- position = XDR_GETPOS (xdrs);
- cap->arglen = (u_long) position - (u_long) argposition;
- XDR_SETPOS (xdrs, lenposition);
- if (!xdr_u_long (xdrs, &(cap->arglen)))
- return FALSE;
- XDR_SETPOS (xdrs, position);
- return TRUE;
- }
- return FALSE;
-}
-strong_alias(__xdr_rmtcall_args,xdr_rmtcall_args)
+static const struct timeval timeout = {3, 0};
/*
* pmapper remote-call-service interface.
@@ -124,14 +102,14 @@ pmap_rmtcall (addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, port_p
struct timeval tout;
u_long *port_ptr;
{
- int socket = -1;
+ int _socket = -1;
CLIENT *client;
struct rmtcallargs a;
struct rmtcallres r;
enum clnt_stat stat;
addr->sin_port = htons (PMAPPORT);
- client = clntudp_create (addr, PMAPPROG, PMAPVERS, timeout, &socket);
+ client = clntudp_create (addr, PMAPPROG, PMAPVERS, timeout, &_socket);
if (client != (CLIENT *) NULL)
{
a.prog = prog;
@@ -142,7 +120,7 @@ pmap_rmtcall (addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, port_p
r.port_ptr = port_ptr;
r.results_ptr = resp;
r.xdr_results = xdrres;
- stat = CLNT_CALL (client, PMAPPROC_CALLIT, (xdrproc_t)__xdr_rmtcall_args,
+ stat = CLNT_CALL (client, PMAPPROC_CALLIT, (xdrproc_t)xdr_rmtcall_args,
(caddr_t)&a, (xdrproc_t)xdr_rmtcallres,
(caddr_t)&r, tout);
CLNT_DESTROY (client);
@@ -151,13 +129,46 @@ pmap_rmtcall (addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, port_p
{
stat = RPC_FAILED;
}
- /* (void)__close(socket); CLNT_DESTROY already closed it */
+ /* (void)close(_socket); CLNT_DESTROY already closed it */
addr->sin_port = 0;
return stat;
}
/*
+ * XDR remote call arguments
+ * written for XDR_ENCODE direction only
+ */
+libc_hidden_proto(xdr_rmtcall_args)
+bool_t
+xdr_rmtcall_args (XDR *xdrs, struct rmtcallargs *cap)
+{
+ u_int lenposition, argposition, position;
+
+ if (xdr_u_long (xdrs, &(cap->prog)) &&
+ xdr_u_long (xdrs, &(cap->vers)) &&
+ xdr_u_long (xdrs, &(cap->proc)))
+ {
+ u_long dummy_arglen = 0;
+ lenposition = XDR_GETPOS (xdrs);
+ if (!xdr_u_long (xdrs, &dummy_arglen))
+ return FALSE;
+ argposition = XDR_GETPOS (xdrs);
+ if (!(*(cap->xdr_args)) (xdrs, cap->args_ptr))
+ return FALSE;
+ position = XDR_GETPOS (xdrs);
+ cap->arglen = (u_long) position - (u_long) argposition;
+ XDR_SETPOS (xdrs, lenposition);
+ if (!xdr_u_long (xdrs, &(cap->arglen)))
+ return FALSE;
+ XDR_SETPOS (xdrs, position);
+ return TRUE;
+ }
+ return FALSE;
+}
+libc_hidden_def(xdr_rmtcall_args)
+
+/*
* XDR remote call results
* written for XDR_DECODE direction only
*/
@@ -177,6 +188,7 @@ xdr_rmtcallres (xdrs, crp)
}
return FALSE;
}
+libc_hidden_def(xdr_rmtcallres)
/*
@@ -198,18 +210,18 @@ getbroadcastnets (struct in_addr *addrs, int sock, char *buf)
ifc.ifc_len = UDPMSGSIZE;
ifc.ifc_buf = buf;
- if (__ioctl (sock, SIOCGIFCONF, (char *) &ifc) < 0)
+ if (ioctl (sock, SIOCGIFCONF, (char *) &ifc) < 0)
{
- __perror (_("broadcast: ioctl (get interface configuration)"));
+ perror (_("broadcast: ioctl (get interface configuration)"));
return (0);
}
ifr = ifc.ifc_req;
for (i = 0, n = ifc.ifc_len / sizeof (struct ifreq); n > 0; n--, ifr++)
{
ifreq = *ifr;
- if (__ioctl (sock, SIOCGIFFLAGS, (char *) &ifreq) < 0)
+ if (ioctl (sock, SIOCGIFFLAGS, (char *) &ifreq) < 0)
{
- __perror (_("broadcast: ioctl (get interface flags)"));
+ perror (_("broadcast: ioctl (get interface flags)"));
continue;
}
if ((ifreq.ifr_flags & IFF_BROADCAST) &&
@@ -218,7 +230,7 @@ getbroadcastnets (struct in_addr *addrs, int sock, char *buf)
{
sin = (struct sockaddr_in *) &ifr->ifr_addr;
#ifdef SIOCGIFBRDADDR /* 4.3BSD */
- if (__ioctl (sock, SIOCGIFBRDADDR, (char *) &ifreq) < 0)
+ if (ioctl (sock, SIOCGIFBRDADDR, (char *) &ifreq) < 0)
{
addrs[i++] = inet_makeaddr (inet_netof
/* Changed to pass struct instead of s_addr member
@@ -277,16 +289,16 @@ clnt_broadcast (prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
* initialization: create a socket, a broadcast address, and
* preserialize the arguments into a send buffer.
*/
- if ((sock = __socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
+ if ((sock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
{
- __perror (_("Cannot create socket for broadcast rpc"));
+ perror (_("Cannot create socket for broadcast rpc"));
stat = RPC_CANTSEND;
goto done_broad;
}
#ifdef SO_BROADCAST
if (setsockopt (sock, SOL_SOCKET, SO_BROADCAST, &on, sizeof (on)) < 0)
{
- __perror (_("Cannot set socket option SO_BROADCAST"));
+ perror (_("Cannot set socket option SO_BROADCAST"));
stat = RPC_CANTSEND;
goto done_broad;
}
@@ -294,7 +306,7 @@ clnt_broadcast (prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
fd.fd = sock;
fd.events = POLLIN;
nets = getbroadcastnets (addrs, sock, inbuf);
- __memset ((char *) &baddr, 0, sizeof (baddr));
+ memset ((char *) &baddr, 0, sizeof (baddr));
baddr.sin_family = AF_INET;
baddr.sin_port = htons (PMAPPORT);
baddr.sin_addr.s_addr = htonl (INADDR_ANY);
@@ -317,7 +329,7 @@ clnt_broadcast (prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
r.xdr_results = xresults;
r.results_ptr = resultsp;
xdrmem_create (xdrs, outbuf, MAX_BROADCAST_SIZE, XDR_ENCODE);
- if ((!xdr_callmsg (xdrs, &msg)) || (!__xdr_rmtcall_args (xdrs, &a)))
+ if ((!xdr_callmsg (xdrs, &msg)) || (!xdr_rmtcall_args (xdrs, &a)))
{
stat = RPC_CANTENCODEARGS;
goto done_broad;
@@ -337,7 +349,7 @@ clnt_broadcast (prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
(struct sockaddr *) &baddr,
sizeof (struct sockaddr)) != outlen)
{
- __perror (_("Cannot send broadcast packet"));
+ perror (_("Cannot send broadcast packet"));
stat = RPC_CANTSEND;
goto done_broad;
}
@@ -362,7 +374,7 @@ clnt_broadcast (prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
case -1: /* some kind of error */
if (errno == EINTR)
goto recv_again;
- __perror (_("Broadcast poll problem"));
+ perror (_("Broadcast poll problem"));
stat = RPC_CANTRECV;
goto done_broad;
@@ -375,7 +387,7 @@ clnt_broadcast (prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
{
if (errno == EINTR)
goto try_again;
- __perror (_("Cannot receive reply to broadcast"));
+ perror (_("Cannot receive reply to broadcast"));
stat = RPC_CANTRECV;
goto done_broad;
}
@@ -422,7 +434,7 @@ clnt_broadcast (prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
}
}
done_broad:
- (void) __close (sock);
+ (void) close (sock);
AUTH_DESTROY (unix_auth);
return stat;
}