summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-06-04 13:32:26 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-06-04 13:32:26 +0000
commit77a8ce12ae20be575adaf975d881da56f4b3b6dc (patch)
tree426040e8b9d76bcbdb8d5de1bd27eb1fc228c569 /apps
parentad9530eeb839266cc6fa940624dce885f5693a2e (diff)
downloadpx4-nuttx-77a8ce12ae20be575adaf975d881da56f4b3b6dc.tar.gz
px4-nuttx-77a8ce12ae20be575adaf975d881da56f4b3b6dc.tar.bz2
px4-nuttx-77a8ce12ae20be575adaf975d881da56f4b3b6dc.zip
Fix FTP bug -- losing passive mode indication
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3667 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps')
-rw-r--r--apps/examples/ftpc/ftpc.h13
-rwxr-xr-xapps/examples/ftpc/ftpc_cmds.c2
-rw-r--r--apps/netutils/ftpc/ftpc_connect.c3
-rw-r--r--apps/netutils/ftpc/ftpc_getfile.c2
-rw-r--r--apps/netutils/ftpc/ftpc_internal.h41
-rw-r--r--apps/netutils/ftpc/ftpc_login.c1
-rw-r--r--apps/netutils/ftpc/ftpc_utils.c3
7 files changed, 33 insertions, 32 deletions
diff --git a/apps/examples/ftpc/ftpc.h b/apps/examples/ftpc/ftpc.h
index 503922375..b6fe35aed 100644
--- a/apps/examples/ftpc/ftpc.h
+++ b/apps/examples/ftpc/ftpc.h
@@ -83,23 +83,10 @@ typedef int (*cmd_t)(SESSION handle, int argc, char **argv);
* Public Data
****************************************************************************/
-extern const char g_ftpcgreeting[];
-extern const char g_ftpcprompt[];
-extern const char g_fmtcmdfailed[];
-
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
-/* Network initialization */
-
-extern int ftpc_netinit(void);
-
-/* Current working directory support */
-
-extern char *ftpc_getfullpath(const char *relpath);
-extern void ftpc_freefullpath(char *relpath);
-
/* FTP command handlers */
extern int cmd_rlogin(SESSION handle, int argc, char **argv);
diff --git a/apps/examples/ftpc/ftpc_cmds.c b/apps/examples/ftpc/ftpc_cmds.c
index a4cab45e0..3acd56ee3 100755
--- a/apps/examples/ftpc/ftpc_cmds.c
+++ b/apps/examples/ftpc/ftpc_cmds.c
@@ -66,7 +66,7 @@
int cmd_rlogin(SESSION handle, int argc, char **argv)
{
- struct ftpc_login_s login = {0, 0, 0, true};
+ struct ftpc_login_s login = {NULL, NULL, NULL, true};
login.uname = argv[1];
if (argc > 2)
diff --git a/apps/netutils/ftpc/ftpc_connect.c b/apps/netutils/ftpc/ftpc_connect.c
index 8affbdade..f36fa08e1 100644
--- a/apps/netutils/ftpc/ftpc_connect.c
+++ b/apps/netutils/ftpc/ftpc_connect.c
@@ -99,7 +99,8 @@ SESSION ftpc_connect(FAR struct ftpc_connect_s *server)
/* Initialize the session structure with all non-zero and variable values */
session->addr.s_addr = server->addr.s_addr;
- session->flags = FTPC_FLAGS_INIT;
+ session->flags &= ~FTPC_FLAGS_CLEAR;
+ session->flags |= FTPC_FLAGS_SET;
session->replytimeo = CONFIG_FTP_DEFTIMEO * CLOCKS_PER_SEC;
session->conntimeo = CONFIG_FTP_DEFTIMEO * CLOCKS_PER_SEC;
session->pid = getpid();
diff --git a/apps/netutils/ftpc/ftpc_getfile.c b/apps/netutils/ftpc/ftpc_getfile.c
index 9df827c6e..30595d942 100644
--- a/apps/netutils/ftpc/ftpc_getfile.c
+++ b/apps/netutils/ftpc/ftpc_getfile.c
@@ -154,7 +154,7 @@ static int ftpc_recvinit(struct ftpc_session_s *session, FAR const char *path,
ret = ftpc_sockaccept(&session->data, FTPC_IS_PASSIVE(session));
if (ret != OK)
{
- ndbg("data connection not accepted\n");
+ ndbg("Data connection not accepted\n");
}
return ret;
diff --git a/apps/netutils/ftpc/ftpc_internal.h b/apps/netutils/ftpc/ftpc_internal.h
index a59e4fdc1..6600b1220 100644
--- a/apps/netutils/ftpc/ftpc_internal.h
+++ b/apps/netutils/ftpc/ftpc_internal.h
@@ -73,24 +73,31 @@
/* Session flag bits ********************************************************/
-#define FTPC_FLAG_CONNECTED (1 << 0) /* Connected to host */
-#define FTPC_FLAG_LOGGEDIN (1 << 1) /* Logged in to host */
-#define FTPC_STATE_FLAGS (0x0003) /* State of connection */
+#define FTPC_FLAG_PASSIVE (1 << 0) /* Passive mode requested */
+#define FTPC_SESSION_FLAGS (0x0001) /* Persist throughout the session */
-#define FTPC_FLAG_MDTM (1 << 2) /* Host supports MDTM command */
-#define FTPC_FLAG_SIZE (1 << 3) /* Host supports SIZE command */
-#define FTPC_FLAG_PASV (1 << 4) /* Host supports PASV command */
-#define FTPC_FLAG_STOU (1 << 5) /* Host supports STOU command */
-#define FTPC_FLAG_CHMOD (1 << 6) /* Host supports SITE CHMOD command */
-#define FTPC_FLAG_IDLE (1 << 7) /* Host supports SITE IDLE command */
-#define FTPC_HOSTCAP_FLAGS (0x00fc) /* Host capabilities */
+#define FTPC_FLAG_CONNECTED (1 << 1) /* Connected to host */
+#define FTPC_FLAG_LOGGEDIN (1 << 2) /* Logged in to host */
+#define FTPC_STATE_FLAGS (0x0006) /* State of connection */
-#define FTPC_FLAG_INTERRUPT (1 << 8) /* Transfer interrupted */
-#define FTPC_FLAG_PUT (1 << 9) /* Transfer is a PUT operation (upload) */
-#define FTPC_FLAG_PASSIVE (1 << 10) /* Passive mode requested */
-#define FTPC_XFER_FLAGS (0x0700) /* Transfer related */
+#define FTPC_FLAG_MDTM (1 << 3) /* Host supports MDTM command */
+#define FTPC_FLAG_SIZE (1 << 4) /* Host supports SIZE command */
+#define FTPC_FLAG_PASV (1 << 5) /* Host supports PASV command */
+#define FTPC_FLAG_STOU (1 << 6) /* Host supports STOU command */
+#define FTPC_FLAG_CHMOD (1 << 7) /* Host supports SITE CHMOD command */
+#define FTPC_FLAG_IDLE (1 << 8) /* Host supports SITE IDLE command */
+#define FTPC_HOSTCAP_FLAGS (0x01f8) /* Host capabilities */
-#define FTPC_FLAGS_INIT FTPC_HOSTCAP_FLAGS
+#define FTPC_FLAG_INTERRUPT (1 << 9) /* Transfer interrupted */
+#define FTPC_FLAG_PUT (1 << 10) /* Transfer is a PUT operation (upload) */
+#define FTPC_XFER_FLAGS (0x0600) /* Transfer related */
+
+/* These are the bits to be set/cleared when the flags are reset */
+
+#define FTPC_FLAGS_CLEAR (FTPC_STATE_FLAGS | FTPC_XFER_FLAGS)
+#define FTPC_FLAGS_SET FTPC_HOSTCAP_FLAGS
+
+/* Macros to set bits */
#define FTPC_SET_CONNECTED(s) do { (s)->flags |= FTPC_FLAG_CONNECTED; } while (0)
#define FTPC_SET_LOGGEDIN(s) do { (s)->flags |= FTPC_FLAG_LOGGEDIN; } while (0)
@@ -104,6 +111,8 @@
#define FTPC_SET_PUT(s) do { (s)->flags |= FTPC_FLAG_PUT; } while (0)
#define FTPC_SET_PASSIVE(s) do { (s)->flags |= FTPC_FLAG_PASSIVE; } while (0)
+/* Macros to clear bits */
+
#define FTPC_CLR_CONNECTED(s) do { (s)->flags &= ~FTPC_FLAG_CONNECTED; } while (0)
#define FTPC_CLR_LOGGEDIN(s) do { (s)->flags &= ~FTPC_FLAG_LOGGEDIN; } while (0)
#define FTPC_CLR_MDTM(s) do { (s)->flags &= ~FTPC_FLAG_MDTM; } while (0)
@@ -116,6 +125,8 @@
#define FTPC_CLR_PUT(s) do { (s)->flags &= ~FTPC_FLAG_PUT; } while (0)
#define FTPC_CLR_PASSIVE(s) do { (s)->flags &= ~FTPC_FLAG_PASSIVE; } while (0)
+/* Macros to test bits */
+
#define FTPC_IS_CONNECTED(s) (((s)->flags & FTPC_FLAG_CONNECTED) != 0)
#define FTPC_IS_LOGGEDIN(s) (((s)->flags & FTPC_FLAG_LOGGEDIN) != 0)
#define FTPC_HAS_MDTM(s) (((s)->flags & FTPC_FLAG_MDTM) != 0)
diff --git a/apps/netutils/ftpc/ftpc_login.c b/apps/netutils/ftpc/ftpc_login.c
index 1d6ff395c..5838f3ba0 100644
--- a/apps/netutils/ftpc/ftpc_login.c
+++ b/apps/netutils/ftpc/ftpc_login.c
@@ -114,6 +114,7 @@ int ftpc_login(SESSION handle, FAR struct ftpc_login_s *login)
FTPC_CLR_PASSIVE(session);
if (login->pasv)
{
+ nvdbg("Setting passive mode\n");
FTPC_SET_PASSIVE(session);
}
diff --git a/apps/netutils/ftpc/ftpc_utils.c b/apps/netutils/ftpc/ftpc_utils.c
index eec52ec8f..0ad2f3280 100644
--- a/apps/netutils/ftpc/ftpc_utils.c
+++ b/apps/netutils/ftpc/ftpc_utils.c
@@ -111,7 +111,8 @@ void ftpc_reset(struct ftpc_session_s *session)
session->pwd = NULL;
free(session->initrdir);
session->initrdir = NULL;
- session->flags = FTPC_FLAGS_INIT;
+ session->flags &= ~FTPC_FLAGS_CLEAR;
+ session->flags |= FTPC_FLAGS_SET;
session->xfrmode = FTPC_XFRMODE_UNKNOWN;
session->code = 0;
session->replytimeo = CONFIG_FTP_DEFTIMEO * CLOCKS_PER_SEC;