summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-03-08 23:40:14 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-03-08 23:40:14 +0000
commit5f1575bf6b6173c4209dbfd61b4f38d744709c8d (patch)
tree26ccaf91ae477c29985206c4c495ace1bc4247ce
parent75d794ffc49c837547489255f8f0f5d79ec84498 (diff)
downloadnuttx-5f1575bf6b6173c4209dbfd61b4f38d744709c8d.tar.gz
nuttx-5f1575bf6b6173c4209dbfd61b4f38d744709c8d.tar.bz2
nuttx-5f1575bf6b6173c4209dbfd61b4f38d744709c8d.zip
RPC updates
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4466 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r--nuttx/fs/nfs/Make.defs2
-rw-r--r--nuttx/fs/nfs/rpc_subr.c40
2 files changed, 15 insertions, 27 deletions
diff --git a/nuttx/fs/nfs/Make.defs b/nuttx/fs/nfs/Make.defs
index f0431d289..c0a19e8b2 100644
--- a/nuttx/fs/nfs/Make.defs
+++ b/nuttx/fs/nfs/Make.defs
@@ -42,7 +42,7 @@ CSRCS +=
# Files required for NFS RPC
ASRCS +=
-CSRCS += rpc_subr.c rpc_idgen_sub.c
+CSRCS += rpc_subr.c
# Argument for dependency checking
diff --git a/nuttx/fs/nfs/rpc_subr.c b/nuttx/fs/nfs/rpc_subr.c
index ca8aab18f..46543eddb 100644
--- a/nuttx/fs/nfs/rpc_subr.c
+++ b/nuttx/fs/nfs/rpc_subr.c
@@ -59,7 +59,6 @@
#include "rpc_v2.h"
#include "rpc.h"
#include "xdr_subs.h"
-#include "rpc_idgen.h"
/****************************************************************************
* Pre-processor Definitions
@@ -150,21 +149,6 @@ struct xdr_inaddr
* Public Functions
****************************************************************************/
-/* Return an unpredictable XID. */
-
-uint32_t krpc_get_xid(void)
-{
- static struct idgen32_ctx krpc_xid_ctx;
- static int called = 0;
-
- if (!called)
- {
- called = 1;
- idgen32_init(&krpc_xid_ctx);
- }
- return idgen32(&krpc_xid_ctx);
-}
-
/* Call portmap to lookup a port number for a particular rpc program
* Returns non-zero error on failure.
*/
@@ -199,7 +183,7 @@ int krpc_portmap(struct sockaddr_in *sin, unsigned int prog, unsigned int vers,
sdata->prog = txdr_unsigned(prog);
sdata->vers = txdr_unsigned(vers);
sdata->proto = txdr_unsigned(IPPROTO_UDP);
- sdata->port = 0;
+ sdata->port = txdr_unsigned(0);
sin->sin_port = htons(PMAPPORT);
error = krpc_call(sin, PMAPPROG, PMAPVERS, PMAPPROC_GETPORT, NULL, -1);
@@ -280,7 +264,7 @@ int krpc_call(struct sockaddr_in *sa, unsigned int prog, unsigned int vers,
sin->sin_port = htons(tport);
error = psock_bind(so, (struct sockaddr*) sin, sizeof(*sin));
}
- while (error == EADDRINUSE && tport < 1024 / 2);
+ while (error == EADDRINUSE && tport > 1024 / 2);
if (error)
{
@@ -297,13 +281,10 @@ int krpc_call(struct sockaddr_in *sa, unsigned int prog, unsigned int vers,
memset((void*) call, 0, sizeof(*call));
/* rpc_call part */
-
- //xid++
- xid = krpc_get_xid();
+
+ xid = rand();
call->rp_xid = txdr_unsigned(xid);
-
- /* call->rp_direction = 0; */
-
+ call->rp_direction = txdr_unsigned(0);
call->rp_rpcvers = txdr_unsigned(2);
call->rp_prog = txdr_unsigned(prog);
call->rp_vers = txdr_unsigned(vers);
@@ -385,7 +366,8 @@ int krpc_call(struct sockaddr_in *sa, unsigned int prog, unsigned int vers,
{
error = fxdr_unsigned(uint32_t, reply->rp_errno);
printf("rpc denied, error=%d\n", error);
- continue;
+ error = ECONNREFUSED;
+ goto out;
}
/* Did the call succeed? */
@@ -394,14 +376,20 @@ int krpc_call(struct sockaddr_in *sa, unsigned int prog, unsigned int vers,
{
error = fxdr_unsigned(uint32_t, reply->rp_status);
printf("rpc denied, status=%d\n", error);
- continue;
+ error = ECONNREFUSED;
+ goto out;
}
+
+ goto gotsucreply; /* break two levels */
}
}
error = ETIMEDOUT;
goto out;
+gotsucreply:
+ return 0;
+
out:
(void)psock_close(so);
return error;