Lines Matching full:rpc
88 #include "rpc.h"
95 /* Increment RPC statistics */
114 /* Static data, mostly RPC constants in XDR form */
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()
195 * Receive a Sun RPC Request/Reply. Only for SOCK_DGRAM
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()
260 * Receive a Sun RPC Request/Reply. Only for SOCK_STREAM
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()
349 * Received the RPC reply on the socket.
353 static int rpcclnt_reply(struct rpcclnt *rpc, int procid, int prog, in rpcclnt_reply() argument
358 /* Get the next RPC reply from the socket */ in rpcclnt_reply()
360 error = rpcclnt_receive(rpc, rpc->rc_name, procid, prog, reply, resplen); in rpcclnt_reply()
372 rpc->rc_timeout = true; in rpcclnt_reply()
377 /* Get the xid and check that it is an RPC replysvr */ in rpcclnt_reply()
386 nfs_debug_error("Different RPC REPLY returned\n"); 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()
616 * Initialize the RPC client
622 /* RPC constants how about actually using more than one of these! */ in rpcclnt_init()
634 nfs_debug_info("RPC initialized\n"); in rpcclnt_init()
641 * Initialize sockets for a new RPC connection. We do not free the
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()
725 /* Do the RPC to get a dynamic bounding with the server using ppmap. in rpcclnt_connect()
734 error = rpcclnt_request(rpc, PMAPPROC_GETPORT, PMAPPROG, PMAPVERS, in rpcclnt_connect()
746 error = rpcclnt_reconnect(rpc, saddr); in rpcclnt_connect()
753 /* Do RPC to mountd. */ 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()
791 /* Do the RPC to get a dynamic bounding with the server using PMAP. 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()
883 /* Do the RPC to get a dynamic bounding with the server using ppmap. 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()
921 /* Do RPC to umountd. */ 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()
952 * Perform the RPC request. Logic formats the RPC CALL message and calls
953 * rpcclnt_send to send the RPC CALL message. It then calls rpcclnt_reply()
957 * On successful receipt, it verifies the RPC level of the returned values.
963 int rpcclnt_request(struct rpcclnt *rpc, int procnum, int prog, in rpcclnt_request() argument
976 rpc->xid = rpcclnt_newxid(); in rpcclnt_request()
984 /* Initialize the RPC header fields */ in rpcclnt_request()
987 rpc->xid, prog, version, procnum, reqlen); in rpcclnt_request()
989 /* Send the RPC call messsages and receive the RPC response. For UDP-RPC, A limited in rpcclnt_request()
991 * timeouts. While for TCP-RPC, no retry attempted. in rpcclnt_request()
998 /* Do the client side RPC. */ in rpcclnt_request()
1001 rpc->rc_timeout = false; in rpcclnt_request()
1003 /* Send the RPC CALL message */ 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()
1028 nfs_debug_error("RPC failed: %d\n", error); 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()
1060 /* Send the RPC CALL message */ 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()
1082 /* Break down the RPC header and check if it is OK */ in rpcclnt_request()
1121 nfs_debug_error("Unsupported RPC type: %d\n", tmp); in rpcclnt_request()