mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-21 14:42:18 +08:00
2010-05-27 Ralf Corsépius <ralf.corsepius@rtems.org>
* librpc/include/rpc/clnt.h, librpc/include/rpc/rpc_msg.h, librpc/src/rpc/clnt_generic.c, librpc/src/rpc/clnt_raw.c, librpc/src/rpc/clnt_tcp.c, librpc/src/rpc/clnt_udp.c, librpc/src/rpc/pmap_clnt.c, librpc/src/rpc/pmap_getmaps.c librpc/src/rpc/pmap_getport.c: Partial merger from freebsd (portability fixes).
This commit is contained in:
@@ -1,3 +1,12 @@
|
||||
2010-05-27 Ralf Corsépius <ralf.corsepius@rtems.org>
|
||||
|
||||
* librpc/include/rpc/clnt.h, librpc/include/rpc/rpc_msg.h,
|
||||
librpc/src/rpc/clnt_generic.c, librpc/src/rpc/clnt_raw.c,
|
||||
librpc/src/rpc/clnt_tcp.c, librpc/src/rpc/clnt_udp.c,
|
||||
librpc/src/rpc/pmap_clnt.c, librpc/src/rpc/pmap_getmaps.c
|
||||
librpc/src/rpc/pmap_getport.c:
|
||||
Partial merger from freebsd (portability fixes).
|
||||
|
||||
2010-05-27 Ralf Corsépius <ralf.corsepius@rtems.org>
|
||||
|
||||
* libnetworking/sys/socketvar.h (struct sockbuf):
|
||||
|
||||
@@ -101,8 +101,8 @@ typedef struct __rpc_client {
|
||||
struct clnt_ops {
|
||||
/* call remote procedure */
|
||||
enum clnt_stat (*cl_call)(struct __rpc_client *,
|
||||
u_long, xdrproc_t, caddr_t, xdrproc_t,
|
||||
caddr_t, struct timeval);
|
||||
rpcproc_t, xdrproc_t, void *, xdrproc_t,
|
||||
void *, struct timeval);
|
||||
/* abort a call */
|
||||
void (*cl_abort)(void);
|
||||
/* get specific error code */
|
||||
@@ -110,7 +110,7 @@ typedef struct __rpc_client {
|
||||
struct rpc_err *);
|
||||
/* frees results */
|
||||
bool_t (*cl_freeres)(struct __rpc_client *,
|
||||
xdrproc_t, caddr_t);
|
||||
xdrproc_t, void *);
|
||||
/* destroy this structure */
|
||||
void (*cl_destroy)(struct __rpc_client *);
|
||||
/* the ioctl() of rpc */
|
||||
@@ -133,19 +133,19 @@ typedef struct __rpc_client {
|
||||
* enum clnt_stat
|
||||
* CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout)
|
||||
* CLIENT *rh;
|
||||
* u_long proc;
|
||||
* rpcproc_t proc;
|
||||
* xdrproc_t xargs;
|
||||
* caddr_t argsp;
|
||||
* void *argsp;
|
||||
* xdrproc_t xres;
|
||||
* caddr_t resp;
|
||||
* void *resp;
|
||||
* struct timeval timeout;
|
||||
*/
|
||||
#define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs) \
|
||||
((*(rh)->cl_ops->cl_call)(rh, proc, (xdrproc_t)xargs, (caddr_t)argsp, \
|
||||
(xdrproc_t) xres, (caddr_t)resp, secs))
|
||||
((*(rh)->cl_ops->cl_call)(rh, proc, xargs, \
|
||||
argsp, xres, resp, secs))
|
||||
#define clnt_call(rh, proc, xargs, argsp, xres, resp, secs) \
|
||||
((*(rh)->cl_ops->cl_call)(rh, proc, (xdrproc_t) xargs, (caddr_t)argsp, \
|
||||
(xdrproc_t) xres, (caddr_t)resp, secs))
|
||||
((*(rh)->cl_ops->cl_call)(rh, proc, xargs, \
|
||||
argsp, xres, resp, secs))
|
||||
|
||||
/*
|
||||
* void
|
||||
@@ -169,10 +169,10 @@ typedef struct __rpc_client {
|
||||
* CLNT_FREERES(rh, xres, resp);
|
||||
* CLIENT *rh;
|
||||
* xdrproc_t xres;
|
||||
* caddr_t resp;
|
||||
* void *resp;
|
||||
*/
|
||||
#define CLNT_FREERES(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,(xdrproc_t)xres,resp))
|
||||
#define clnt_freeres(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,(xdrproc_t)xres,resp))
|
||||
#define CLNT_FREERES(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp))
|
||||
#define clnt_freeres(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp))
|
||||
|
||||
/*
|
||||
* bool_t
|
||||
@@ -256,18 +256,12 @@ typedef struct __rpc_client {
|
||||
/*
|
||||
* Generic client creation routine. Supported protocols are "udp", "tcp"
|
||||
* and "unix".
|
||||
* CLIENT *
|
||||
* clnt_create(host, prog, vers, prot);
|
||||
* char *host; -- hostname
|
||||
* u_long prog; -- program number
|
||||
* u_long vers; -- version number
|
||||
* char *prot; -- protocol
|
||||
*/
|
||||
__BEGIN_DECLS
|
||||
extern CLIENT *clnt_create(char *, u_long, u_long, char *);
|
||||
extern CLIENT *clnt_create(const char *, const rpcprog_t, const rpcvers_t,
|
||||
const char *);
|
||||
__END_DECLS
|
||||
|
||||
|
||||
/*
|
||||
* Added for compatibility to old rpc 4.0. Obsoleted by clnt_vc_create().
|
||||
*/
|
||||
|
||||
@@ -92,8 +92,8 @@ struct accepted_reply {
|
||||
enum accept_stat ar_stat;
|
||||
union {
|
||||
struct {
|
||||
u_int32_t low;
|
||||
u_int32_t high;
|
||||
rpcvers_t low;
|
||||
rpcvers_t high;
|
||||
} AR_versions;
|
||||
struct {
|
||||
caddr_t where;
|
||||
@@ -112,8 +112,8 @@ struct rejected_reply {
|
||||
enum reject_stat rj_stat;
|
||||
union {
|
||||
struct {
|
||||
u_int32_t low;
|
||||
u_int32_t high;
|
||||
rpcvers_t low;
|
||||
rpcvers_t high;
|
||||
} RJ_versions;
|
||||
enum auth_stat RJ_why; /* why authentication did not work */
|
||||
} ru;
|
||||
@@ -138,10 +138,10 @@ struct reply_body {
|
||||
* Body of an rpc request call.
|
||||
*/
|
||||
struct call_body {
|
||||
u_int32_t cb_rpcvers; /* must be equal to two */
|
||||
u_int32_t cb_prog;
|
||||
u_int32_t cb_vers;
|
||||
u_int32_t cb_proc;
|
||||
rpcvers_t cb_rpcvers; /* must be equal to two */
|
||||
rpcprog_t cb_prog;
|
||||
rpcvers_t cb_vers;
|
||||
rpcproc_t cb_proc;
|
||||
struct opaque_auth cb_cred;
|
||||
struct opaque_auth cb_verf; /* protocol specific - provided by client */
|
||||
};
|
||||
|
||||
@@ -53,10 +53,10 @@ static char *rcsid = "$FreeBSD: src/lib/libc/rpc/clnt_generic.c,v 1.9 1999/08/28
|
||||
*/
|
||||
CLIENT *
|
||||
clnt_create(
|
||||
char *hostname,
|
||||
u_long prog,
|
||||
u_long vers,
|
||||
char *proto)
|
||||
const char *hostname,
|
||||
rpcprog_t prog,
|
||||
rpcvers_t vers,
|
||||
const char *proto)
|
||||
{
|
||||
struct hostent *h;
|
||||
struct protoent *p;
|
||||
|
||||
@@ -69,10 +69,10 @@ struct clnt_raw_private {
|
||||
};
|
||||
#define clntraw_private (rtems_rpc_task_variables->clnt_raw_private)
|
||||
|
||||
static enum clnt_stat clntraw_call(CLIENT *h, u_long proc, xdrproc_t xargs, caddr_t argsp, xdrproc_t xresults, caddr_t resultsp, struct timeval timeout);
|
||||
static enum clnt_stat clntraw_call(CLIENT *h, rpcproc_t proc, xdrproc_t xargs, void *argsp, xdrproc_t xresults, void *resultsp, struct timeval timeout);
|
||||
static void clntraw_abort(void);
|
||||
static void clntraw_geterr(CLIENT *h, struct rpc_err*);
|
||||
static bool_t clntraw_freeres(CLIENT *, xdrproc_t, caddr_t);
|
||||
static bool_t clntraw_freeres(CLIENT *, xdrproc_t, void*);
|
||||
static bool_t clntraw_control(CLIENT *, int, char *);
|
||||
static void clntraw_destroy(CLIENT *);
|
||||
|
||||
@@ -134,11 +134,11 @@ clntraw_create(
|
||||
static enum clnt_stat
|
||||
clntraw_call(
|
||||
CLIENT *h,
|
||||
u_long proc,
|
||||
rpcproc_t proc,
|
||||
xdrproc_t xargs,
|
||||
caddr_t argsp,
|
||||
void *argsp,
|
||||
xdrproc_t xresults,
|
||||
caddr_t resultsp,
|
||||
void *resultsp,
|
||||
struct timeval timeout )
|
||||
{
|
||||
struct clnt_raw_private *clp = clntraw_private;
|
||||
@@ -216,7 +216,7 @@ static bool_t
|
||||
clntraw_freeres(
|
||||
CLIENT *cl,
|
||||
xdrproc_t xdr_res,
|
||||
caddr_t res_ptr )
|
||||
void *res_ptr )
|
||||
{
|
||||
struct clnt_raw_private *clp = clntraw_private;
|
||||
XDR *xdrs = &clp->xdr_stream;
|
||||
|
||||
@@ -72,10 +72,10 @@ static char *rcsid = "$FreeBSD: src/lib/libc/rpc/clnt_tcp.c,v 1.14 2000/01/27 23
|
||||
static int readtcp(char *, char*, int);
|
||||
static int writetcp(char *, char*, int);
|
||||
|
||||
static enum clnt_stat clnttcp_call(CLIENT *, u_long, xdrproc_t, caddr_t, xdrproc_t, caddr_t, struct timeval);
|
||||
static enum clnt_stat clnttcp_call(CLIENT *, rpcproc_t, xdrproc_t, void*, xdrproc_t, void*, struct timeval);
|
||||
static void clnttcp_abort(void);
|
||||
static void clnttcp_geterr(CLIENT *, struct rpc_err*);
|
||||
static bool_t clnttcp_freeres(CLIENT *, xdrproc_t, caddr_t);
|
||||
static bool_t clnttcp_freeres(CLIENT *, xdrproc_t, void*);
|
||||
static bool_t clnttcp_control(CLIENT *, int, char *);
|
||||
static void clnttcp_destroy(CLIENT *);
|
||||
|
||||
@@ -120,8 +120,8 @@ struct ct_data {
|
||||
CLIENT *
|
||||
clnttcp_create(
|
||||
struct sockaddr_in *raddr,
|
||||
u_long prog,
|
||||
u_long vers,
|
||||
rpcprog_t prog, /* program number */
|
||||
rpcvers_t vers, /* version number */
|
||||
int *sockp,
|
||||
u_int sendsz,
|
||||
u_int recvsz)
|
||||
@@ -240,11 +240,11 @@ fooy:
|
||||
static enum clnt_stat
|
||||
clnttcp_call(
|
||||
CLIENT *h,
|
||||
u_long proc,
|
||||
rpcproc_t proc,
|
||||
xdrproc_t xdr_args,
|
||||
caddr_t args_ptr,
|
||||
void *args_ptr,
|
||||
xdrproc_t xdr_results,
|
||||
caddr_t results_ptr,
|
||||
void *results_ptr,
|
||||
struct timeval timeout)
|
||||
{
|
||||
struct ct_data *ct = (struct ct_data *) h->cl_private;
|
||||
@@ -351,7 +351,7 @@ static bool_t
|
||||
clnttcp_freeres(
|
||||
CLIENT *cl,
|
||||
xdrproc_t xdr_res,
|
||||
caddr_t res_ptr)
|
||||
void *res_ptr)
|
||||
{
|
||||
struct ct_data *ct;
|
||||
XDR *xdrs;
|
||||
|
||||
@@ -58,10 +58,10 @@ static char *rcsid = "$FreeBSD: src/lib/libc/rpc/clnt_udp.c,v 1.15 2000/01/27 23
|
||||
/*
|
||||
* UDP bases client side rpc operations
|
||||
*/
|
||||
static enum clnt_stat clntudp_call(CLIENT *, u_long, xdrproc_t, caddr_t, xdrproc_t, caddr_t, struct timeval);
|
||||
static enum clnt_stat clntudp_call(CLIENT *, rpcproc_t, xdrproc_t, void*, xdrproc_t, void*, struct timeval);
|
||||
static void clntudp_abort(void);
|
||||
static void clntudp_geterr(CLIENT *, struct rpc_err*);
|
||||
static bool_t clntudp_freeres(CLIENT *, xdrproc_t, caddr_t);
|
||||
static bool_t clntudp_freeres(CLIENT *, xdrproc_t, void*);
|
||||
static bool_t clntudp_control(CLIENT *, int, char *);
|
||||
static void clntudp_destroy(CLIENT *);
|
||||
|
||||
@@ -112,8 +112,8 @@ struct cu_data {
|
||||
CLIENT *
|
||||
clntudp_bufcreate(
|
||||
struct sockaddr_in *raddr,
|
||||
u_long program,
|
||||
u_long version,
|
||||
rpcprog_t program, /* program number */
|
||||
rpcvers_t version, /* version number */
|
||||
struct timeval wait,
|
||||
int *sockp,
|
||||
u_int sendsz,
|
||||
@@ -206,8 +206,8 @@ fooy:
|
||||
CLIENT *
|
||||
clntudp_create(
|
||||
struct sockaddr_in *raddr,
|
||||
u_long program,
|
||||
u_long version,
|
||||
rpcprog_t program, /* program number */
|
||||
rpcvers_t version, /* version number */
|
||||
struct timeval wait,
|
||||
int *sockp)
|
||||
{
|
||||
@@ -219,11 +219,11 @@ clntudp_create(
|
||||
static enum clnt_stat
|
||||
clntudp_call(
|
||||
CLIENT *cl, /* client handle */
|
||||
u_long proc, /* procedure number */
|
||||
rpcproc_t proc, /* procedure number */
|
||||
xdrproc_t xargs, /* xdr routine for args */
|
||||
caddr_t argsp, /* pointer to args */
|
||||
void *argsp, /* pointer to args */
|
||||
xdrproc_t xresults, /* xdr routine for results */
|
||||
caddr_t resultsp, /* pointer to results */
|
||||
void *resultsp, /* pointer to results */
|
||||
struct timeval utimeout ) /* seconds to wait before giving up */
|
||||
{
|
||||
struct cu_data *cu = (struct cu_data *)cl->cl_private;
|
||||
@@ -423,7 +423,7 @@ static bool_t
|
||||
clntudp_freeres(
|
||||
CLIENT *cl,
|
||||
xdrproc_t xdr_res,
|
||||
caddr_t res_ptr)
|
||||
void *res_ptr)
|
||||
{
|
||||
struct cu_data *cu = (struct cu_data *)cl->cl_private;
|
||||
XDR *xdrs = &(cu->cu_outxdrs);
|
||||
|
||||
@@ -72,7 +72,7 @@ pmap_set(
|
||||
{
|
||||
struct sockaddr_in myaddress;
|
||||
int socket = -1;
|
||||
register CLIENT *client;
|
||||
CLIENT *client;
|
||||
struct pmap parms;
|
||||
bool_t rslt;
|
||||
struct stat st;
|
||||
@@ -97,7 +97,7 @@ pmap_set(
|
||||
parms.pm_vers = version;
|
||||
parms.pm_prot = protocol;
|
||||
parms.pm_port = port;
|
||||
if (CLNT_CALL(client, PMAPPROC_SET, xdr_pmap, &parms, xdr_bool, &rslt,
|
||||
if (CLNT_CALL(client, PMAPPROC_SET, (xdrproc_t)xdr_pmap, &parms, (xdrproc_t)xdr_bool, &rslt,
|
||||
tottimeout) != RPC_SUCCESS) {
|
||||
clnt_perror(client, "Cannot register service");
|
||||
return (FALSE);
|
||||
@@ -109,7 +109,7 @@ pmap_set(
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove the mapping between program,version and port.
|
||||
* Remove the mapping between program, version and port.
|
||||
* Calls the pmap service remotely to do the un-mapping.
|
||||
*/
|
||||
bool_t
|
||||
@@ -142,7 +142,7 @@ pmap_unset(
|
||||
parms.pm_prog = program;
|
||||
parms.pm_vers = version;
|
||||
parms.pm_port = parms.pm_prot = 0;
|
||||
CLNT_CALL(client, PMAPPROC_UNSET, xdr_pmap, &parms, xdr_bool, &rslt,
|
||||
CLNT_CALL(client, PMAPPROC_UNSET, (xdrproc_t)xdr_pmap, &parms, (xdrproc_t)xdr_bool, &rslt,
|
||||
tottimeout);
|
||||
CLNT_DESTROY(client);
|
||||
if (socket != -1)
|
||||
|
||||
@@ -66,19 +66,21 @@ static char *rcsid = "$FreeBSD: src/lib/libc/rpc/pmap_getmaps.c,v 1.11 2000/01/2
|
||||
struct pmaplist *
|
||||
pmap_getmaps(struct sockaddr_in *address)
|
||||
{
|
||||
struct pmaplist *head = (struct pmaplist *)NULL;
|
||||
struct pmaplist *head = NULL;
|
||||
int socket = -1;
|
||||
struct timeval minutetimeout;
|
||||
register CLIENT *client;
|
||||
CLIENT *client;
|
||||
|
||||
minutetimeout.tv_sec = 60;
|
||||
minutetimeout.tv_usec = 0;
|
||||
address->sin_port = htons(PMAPPORT);
|
||||
client = clnttcp_create(address, PMAPPROG,
|
||||
PMAPVERS, &socket, 50, 500);
|
||||
if (client != (CLIENT *)NULL) {
|
||||
if (CLNT_CALL(client, PMAPPROC_DUMP, xdr_void, NULL, xdr_pmaplist,
|
||||
&head, minutetimeout) != RPC_SUCCESS) {
|
||||
if (client != NULL) {
|
||||
if (CLNT_CALL(client, (rpcproc_t)PMAPPROC_DUMP,
|
||||
(xdrproc_t)xdr_void, NULL,
|
||||
(xdrproc_t)xdr_pmaplist, &head, minutetimeout) !=
|
||||
RPC_SUCCESS) {
|
||||
clnt_perror(client, "pmap_getmaps rpc problem");
|
||||
}
|
||||
CLNT_DESTROY(client);
|
||||
|
||||
@@ -52,8 +52,8 @@ static char *rcsid = "$FreeBSD: src/lib/libc/rpc/pmap_getport.c,v 1.10 2000/01/2
|
||||
#include <net/if.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static struct timeval timeout = { 5, 0 };
|
||||
static struct timeval tottimeout = { 60, 0 };
|
||||
static const struct timeval timeout = { 5, 0 };
|
||||
static const struct timeval tottimeout = { 60, 0 };
|
||||
|
||||
/*
|
||||
* Find the mapped port for program,version.
|
||||
@@ -69,19 +69,21 @@ pmap_getport(
|
||||
{
|
||||
u_short port = 0;
|
||||
int socket = -1;
|
||||
register CLIENT *client;
|
||||
CLIENT *client;
|
||||
struct pmap parms;
|
||||
|
||||
address->sin_port = htons(PMAPPORT);
|
||||
client = clntudp_bufcreate(address, PMAPPROG,
|
||||
PMAPVERS, timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE);
|
||||
if (client != (CLIENT *)NULL) {
|
||||
if (client != NULL) {
|
||||
parms.pm_prog = program;
|
||||
parms.pm_vers = version;
|
||||
parms.pm_prot = protocol;
|
||||
parms.pm_port = 0; /* not needed or used */
|
||||
if (CLNT_CALL(client, PMAPPROC_GETPORT, xdr_pmap, &parms,
|
||||
xdr_u_short, &port, tottimeout) != RPC_SUCCESS){
|
||||
if (CLNT_CALL(client, (rpcproc_t)PMAPPROC_GETPORT,
|
||||
(xdrproc_t)xdr_pmap,
|
||||
&parms, (xdrproc_t)xdr_u_short, &port, tottimeout) !=
|
||||
RPC_SUCCESS){
|
||||
rpc_createerr.cf_stat = RPC_PMAPFAILURE;
|
||||
clnt_geterr(client, &rpc_createerr.cf_error);
|
||||
} else if (port == 0) {
|
||||
|
||||
Reference in New Issue
Block a user