-static unsigned long
-xmit_call(int sockfd, struct sockaddr_in *sin,
- u_int32_t prog, u_int32_t vers, u_int32_t proc,
- xdrproc_t func, void *obj)
-/* __u32 prog, __u32 vers, __u32 proc, xdrproc_t func, void *obj) */
-{
- unsigned int msgbuf[MAXMSGSIZE], msglen;
- struct rpc_msg mesg;
- struct pmap pmap;
- XDR xdr, *xdrs = &xdr;
- int err;
-
- if (!xid)
- xid = getpid() + time(NULL);
-
- mesg.rm_xid = ++xid;
- mesg.rm_direction = CALL;
- mesg.rm_call.cb_rpcvers = 2;
- if (sin->sin_port == 0) {
- sin->sin_port = htons(PMAPPORT);
- mesg.rm_call.cb_prog = PMAPPROG;
- mesg.rm_call.cb_vers = PMAPVERS;
- mesg.rm_call.cb_proc = PMAPPROC_GETPORT;
- pmap.pm_prog = prog;
- pmap.pm_vers = vers;
- pmap.pm_prot = IPPROTO_UDP;
- pmap.pm_port = 0;
- func = (xdrproc_t) xdr_pmap;
- obj = &pmap;
- } else {
- mesg.rm_call.cb_prog = prog;
- mesg.rm_call.cb_vers = vers;
- mesg.rm_call.cb_proc = proc;
- }
- mesg.rm_call.cb_cred.oa_flavor = AUTH_NULL;
- mesg.rm_call.cb_cred.oa_base = (caddr_t) NULL;
- mesg.rm_call.cb_cred.oa_length = 0;
- mesg.rm_call.cb_verf.oa_flavor = AUTH_NULL;
- mesg.rm_call.cb_verf.oa_base = (caddr_t) NULL;
- mesg.rm_call.cb_verf.oa_length = 0;
-
- /* Create XDR memory object for encoding */
- xdrmem_create(xdrs, (caddr_t) msgbuf, sizeof(msgbuf), XDR_ENCODE);
-
- /* Encode the RPC header part and payload */
- if (!xdr_callmsg(xdrs, &mesg) || !func(xdrs, obj)) {
- dprintf(L_WARNING, "xmit_mesg: can't encode RPC message!\n");
- xdr_destroy(xdrs);
- return 0;