aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2012-03-08 23:40:14 +0000
committerpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2012-03-08 23:40:14 +0000
commit9422880309781b1ac9c67ff706f71c6038ab98c8 (patch)
tree26ccaf91ae477c29985206c4c495ace1bc4247ce
parent406e1cd01b010da9deecda3a49c87aec2389ee6b (diff)
downloadpx4-firmware-9422880309781b1ac9c67ff706f71c6038ab98c8.tar.gz
px4-firmware-9422880309781b1ac9c67ff706f71c6038ab98c8.tar.bz2
px4-firmware-9422880309781b1ac9c67ff706f71c6038ab98c8.zip
RPC updates
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4466 7fd9a85b-ad96-42d3-883c-3090e2eb8679
-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;