You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ha...@apache.org on 2022/09/04 15:03:33 UTC

[incubator-nuttx-apps] branch master updated: ftpd: server port made configurable.

This is an automated email from the ASF dual-hosted git repository.

hartmannathan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new 387eba2ef ftpd: server port made configurable.
387eba2ef is described below

commit 387eba2efd53b057fc53a7c49590a6e1c9786017
Author: Fotis Panagiotopoulos <f....@amco.gr>
AuthorDate: Sat Sep 3 17:42:08 2022 +0300

    ftpd: server port made configurable.
---
 examples/ftpd/Kconfig     |  4 ++++
 examples/ftpd/ftpd_main.c |  6 ++++--
 include/netutils/ftpd.h   |  3 ++-
 netutils/ftpd/ftpd.c      | 12 +++++-------
 4 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/examples/ftpd/Kconfig b/examples/ftpd/Kconfig
index b2edd881e..ab9b1e94c 100644
--- a/examples/ftpd/Kconfig
+++ b/examples/ftpd/Kconfig
@@ -11,6 +11,10 @@ config EXAMPLES_FTPD
 
 if EXAMPLES_FTPD
 
+config EXAMPLES_FTPD_PORT
+	int "FTP Daemon Port"
+	default 21
+
 config EXAMPLES_FTPD_STACKSIZE
 	int "FTP Daemon Stack Size"
 	default DEFAULT_TASK_STACKSIZE
diff --git a/examples/ftpd/ftpd_main.c b/examples/ftpd/ftpd_main.c
index 14991e158..755b534a0 100644
--- a/examples/ftpd/ftpd_main.c
+++ b/examples/ftpd/ftpd_main.c
@@ -22,6 +22,8 @@
  * Included Files
  ****************************************************************************/
 
+#include <nuttx/config.h>
+
 #include <sys/types.h>
 
 #include <stdio.h>
@@ -169,9 +171,9 @@ int ftpd_daemon(int s_argc, char **s_argv)
   /* Open FTPD */
 
 #if ADDR_FAMILY == AF_INET6
-  handle = ftpd_open(AF_INET6);
+  handle = ftpd_open(CONFIG_EXAMPLES_FTPD_PORT, AF_INET6);
 #else
-  handle = ftpd_open(AF_INET);
+  handle = ftpd_open(CONFIG_EXAMPLES_FTPD_PORT, AF_INET);
 #endif
 
   if (!handle)
diff --git a/include/netutils/ftpd.h b/include/netutils/ftpd.h
index 1ebf8164e..31b3ffd1c 100644
--- a/include/netutils/ftpd.h
+++ b/include/netutils/ftpd.h
@@ -119,6 +119,7 @@ extern "C"
  *   used to run the server.
  *
  * Input Parameters:
+ *    port - The port that the server will listen to.
  *    family - The type of INET family to use when opening the socket.
  *    AF_INET and AF_INET6 are supported.
  *
@@ -128,7 +129,7 @@ extern "C"
  *
  ****************************************************************************/
 
-FTPD_SESSION ftpd_open(sa_family_t family);
+FTPD_SESSION ftpd_open(int port, sa_family_t family);
 
 /****************************************************************************
  * Name: ftpd_adduser
diff --git a/netutils/ftpd/ftpd.c b/netutils/ftpd/ftpd.c
index 5dc40e5ed..4aff864a3 100644
--- a/netutils/ftpd/ftpd.c
+++ b/netutils/ftpd/ftpd.c
@@ -4262,7 +4262,9 @@ static FAR void *ftpd_worker(FAR void *arg)
  *   used to run the server.
  *
  * Input Parameters:
- *    None
+ *    port - The port that the server will listen to.
+ *    family - The type of INET family to use when opening the socket.
+ *    AF_INET and AF_INET6 are supported.
  *
  * Returned Value:
  *   On success, a non-NULL handle is returned that can be used to reference
@@ -4270,15 +4272,11 @@ static FAR void *ftpd_worker(FAR void *arg)
  *
  ****************************************************************************/
 
-FTPD_SESSION ftpd_open(sa_family_t family)
+FTPD_SESSION ftpd_open(int port, sa_family_t family)
 {
   FAR struct ftpd_server_s *server;
 
-  server = ftpd_openserver(21, family);
-  if (server == NULL)
-    {
-      server = ftpd_openserver(2211, family);
-    }
+  server = ftpd_openserver(port, family);
 
   return (FTPD_SESSION)server;
 }