Lines Matching refs:rpc
137 static int rpcclnt_send(struct rpcclnt *rpc, int procid, int prog,
139 static int rpcclnt_receive(struct rpcclnt *rpc, struct sockaddr *aname,
141 static int rpcclnt_reply(struct rpcclnt *rpc, int procid, int prog,
146 static int rpcclnt_reconnect(struct rpcclnt *rpc, struct sockaddr *saddr);
163 static int rpcclnt_send(struct rpcclnt *rpc, int procid, int prog, in rpcclnt_send() argument
175 nbytes = sendto(rpc->rc_so, call, reqlen, 0, in rpcclnt_send()
176 rpc->rc_name, sizeof(struct sockaddr)); in rpcclnt_send()
199 static int rpcclnt_receive(struct rpcclnt *rpc, struct sockaddr *aname, in rpcclnt_receive() argument
212 FD_SET((uint32_t)(rpc->rc_so), &fdreadset); in rpcclnt_receive()
217 ret = select(rpc->rc_so + 1, &fdreadset, 0, 0, &timeval); in rpcclnt_receive()
230 nbytes = recvfrom(rpc->rc_so, reply, resplen, 0, aname, &fromlen); in rpcclnt_receive()
244 if (fxdr_unsigned(uint32_t, xid) != rpc->xid) in rpcclnt_receive()
264 static int rpcclnt_receive(struct rpcclnt *rpc, struct sockaddr *aname, in rpcclnt_receive() argument
281 FD_SET((uint32_t)(rpc->rc_so), &fdreadset); in rpcclnt_receive()
286 ret = select(rpc->rc_so + 1, &fdreadset, 0, 0, &timeval); in rpcclnt_receive()
299 nbytes = recvfrom(rpc->rc_so, (char *)reply + offset, resplen - offset, 0, aname, &fromlen); in rpcclnt_receive()
353 static int rpcclnt_reply(struct rpcclnt *rpc, int procid, int prog, in rpcclnt_reply() argument
360 error = rpcclnt_receive(rpc, rpc->rc_name, procid, prog, reply, resplen); in rpcclnt_reply()
372 rpc->rc_timeout = true; in rpcclnt_reply()
446 static int rpcclnt_alivecheck(struct rpcclnt *rpc) in rpcclnt_alivecheck() argument
453 int sockfd = rpc->rc_so; in rpcclnt_alivecheck()
482 (void)close(rpc->rc_so); in rpcclnt_alivecheck()
483 rpc->rc_so = -1; in rpcclnt_alivecheck()
548 static int rpcclnt_reconnect(struct rpcclnt *rpc, struct sockaddr *saddr) in rpcclnt_reconnect() argument
559 rpcclnt_disconnect(rpc); in rpcclnt_reconnect()
561 error = socket(rpc->rc_name->sa_family, rpc->rc_sotype, IPPROTO_TCP); in rpcclnt_reconnect()
568 rpc->rc_so = error; in rpcclnt_reconnect()
579 error = bind(rpc->rc_so, (struct sockaddr *)&sock_in, sizeof(sock_in)); in rpcclnt_reconnect()
594 error = connect(rpc->rc_so, saddr, sizeof(*saddr)); in rpcclnt_reconnect()
604 rpcclnt_disconnect(rpc); in rpcclnt_reconnect()
646 int rpcclnt_connect(struct rpcclnt *rpc) in rpcclnt_connect() argument
674 saddr = rpc->rc_name; in rpcclnt_connect()
678 error = socket(saddr->sa_family, rpc->rc_sotype, NFS_PROTOTYPE); in rpcclnt_connect()
685 rpc->rc_so = error; in rpcclnt_connect()
697 error = bind(rpc->rc_so, (struct sockaddr *)&sin, sizeof(sin)); in rpcclnt_connect()
717 error = connect(rpc->rc_so, saddr, sizeof(*saddr)); in rpcclnt_connect()
734 error = rpcclnt_request(rpc, PMAPPROC_GETPORT, PMAPPROG, PMAPVERS, in rpcclnt_connect()
746 error = rpcclnt_reconnect(rpc, saddr); in rpcclnt_connect()
762 rpc->rc_path, RPC_RPATH_MAXSIZE - 1); in rpcclnt_connect()
770 error = rpcclnt_request(rpc, RPCMNT_MOUNT, RPCPROG_MNT, RPCMNT_VER3, in rpcclnt_connect()
788 rpc->rc_fhsize = fxdr_unsigned(uint32_t, response.mdata.mount.fhandle.length); in rpcclnt_connect()
789 memcpy(&rpc->rc_fh, &response.mdata.mount.fhandle.handle, rpc->rc_fhsize); in rpcclnt_connect()
797 error = rpcclnt_reconnect(rpc, saddr); in rpcclnt_connect()
809 error = rpcclnt_request(rpc, PMAPPROC_GETPORT, PMAPPROG, PMAPVERS, in rpcclnt_connect()
822 error = rpcclnt_reconnect(rpc, saddr); in rpcclnt_connect()
832 rpcclnt_disconnect(rpc); in rpcclnt_connect()
844 void rpcclnt_disconnect(struct rpcclnt *rpc) in rpcclnt_disconnect() argument
846 if (rpc->rc_so != -1) in rpcclnt_disconnect()
848 (void)lwip_close(rpc->rc_so); in rpcclnt_disconnect()
849 rpc->rc_so = -1; in rpcclnt_disconnect()
861 int rpcclnt_umount(struct rpcclnt *rpc) in rpcclnt_umount() argument
880 saddr = rpc->rc_name; in rpcclnt_umount()
889 error = rpcclnt_reconnect(rpc, saddr); in rpcclnt_umount()
901 error = rpcclnt_request(rpc, PMAPPROC_GETPORT, PMAPPROG, PMAPVERS, in rpcclnt_umount()
914 error = rpcclnt_reconnect(rpc, saddr); in rpcclnt_umount()
924 rpc->rc_path, sizeof(request.mountd.umount.rpath) - 1); in rpcclnt_umount()
928 error = rpcclnt_request(rpc, RPCMNT_UMOUNT, RPCPROG_MNT, RPCMNT_VER3, in rpcclnt_umount()
963 int rpcclnt_request(struct rpcclnt *rpc, int procnum, int prog, in rpcclnt_request() argument
976 rpc->xid = rpcclnt_newxid(); in rpcclnt_request()
987 rpc->xid, prog, version, procnum, reqlen); in rpcclnt_request()
1001 rpc->rc_timeout = false; in rpcclnt_request()
1005 error = rpcclnt_send(rpc, procnum, prog, request, reqlen); in rpcclnt_request()
1015 error = rpcclnt_reply(rpc, procnum, prog, response, resplen); in rpcclnt_request()
1024 while (rpc->rc_timeout && retries <= rpc->rc_retry); in rpcclnt_request()
1036 if (rpc->rc_so != -1) in rpcclnt_request()
1038 error = rpcclnt_alivecheck(rpc); in rpcclnt_request()
1048 if (rpc->rc_so == -1) in rpcclnt_request()
1050 error = rpcclnt_reconnect(rpc, rpc->rc_name); in rpcclnt_request()
1062 error = rpcclnt_send(rpc, procnum, prog, request, reqlen); in rpcclnt_request()
1065 rpcclnt_disconnect(rpc); in rpcclnt_request()
1072 error = rpcclnt_reply(rpc, procnum, prog, response, resplen); in rpcclnt_request()
1075 rpcclnt_disconnect(rpc); in rpcclnt_request()