mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-04 21:23:57 +08:00
FTPD daemon and example now build without errors
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4371 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
@@ -282,15 +282,42 @@ examples/ftpd
|
|||||||
configuration if the network is configuration prior to running the
|
configuration if the network is configuration prior to running the
|
||||||
example.
|
example.
|
||||||
|
|
||||||
If CONFIG_EXAMPELS_FTPD_NONETINIT is not defined, then the following may
|
NSH always initializes the network so if CONFIG_NSH_BUILTIN_APPS is
|
||||||
|
defined, so is CONFIG_EXAMPLES_FTPD_NONETINIT (se it does not explicitly
|
||||||
|
need to be defined in that case):
|
||||||
|
|
||||||
|
CONFIG_NSH_BUILTIN_APPS - Build the FTPD daemon example test as an
|
||||||
|
NSH built-in function. By default the FTPD daemon will be built
|
||||||
|
as a standalone application.
|
||||||
|
|
||||||
|
If CONFIG_EXAMPLES_FTPD_NONETINIT is not defined, then the following may
|
||||||
be specified to customized the network configuration:
|
be specified to customized the network configuration:
|
||||||
|
|
||||||
CONFIG_EXAMPLE_FTPD_NOMAC - If the hardware has no MAC address of its
|
CONFIG_EXAMPLE_FTPD_NOMAC - If the hardware has no MAC address of its
|
||||||
own, define this =y to provide a bogus address for testing.
|
own, define this =y to provide a bogus address for testing.
|
||||||
CONFIG_EXAMPLE_FTPD_IPADDR - The target IP address. Default 10.0.0.2
|
CONFIG_EXAMPLE_FTPD_IPADDR - The target IP address. Default 10.0.0.2
|
||||||
CONFIG_EXAMPLE_FTPD_DRIPADDR - The default router address. Default
|
CONFIG_EXAMPLE_FTPD_DRIPADDR - The default router address. Default
|
||||||
10.0.0.1
|
10.0.0.1
|
||||||
CONFIG_EXAMPLE_FTPD_NETMASK - The network mask. Default: 255.255.255.0
|
CONFIG_EXAMPLE_FTPD_NETMASK - The network mask. Default: 255.255.255.0
|
||||||
|
|
||||||
|
Other required configuration settings: Of course TCP networking support
|
||||||
|
is required. But here are a couple that are less obvious:
|
||||||
|
|
||||||
|
CONFIG_DISABLE_PTHREAD - pthread support is required
|
||||||
|
CONFIG_DISABLE_POLL - poll() support is required
|
||||||
|
|
||||||
|
Other FTPD configuration options thay may be of interest:
|
||||||
|
|
||||||
|
CONFIG_FTPD_VENDORID - The vendor name to use in FTP communications.
|
||||||
|
Default: "NuttX"
|
||||||
|
CONFIG_FTPD_SERVERID - The server name to use in FTP communications.
|
||||||
|
Default: "NuttX FTP Server"
|
||||||
|
CONFIG_FTPD_CMDBUFFERSIZE - The maximum size of one command. Default:
|
||||||
|
512 bytes.
|
||||||
|
CONFIG_FTPD_DATABUFFERSIZE - The size of the I/O buffer for data
|
||||||
|
transfers. Default: 2048 bytes.
|
||||||
|
CONFIG_FTPD_WORKERSTACKSIZE - The stacksize to allocate for each
|
||||||
|
FTP daemon worker thread. Default: 2048 bytes.
|
||||||
|
|
||||||
The appconfig file (apps/.config) should include:
|
The appconfig file (apps/.config) should include:
|
||||||
|
|
||||||
|
|||||||
@@ -56,12 +56,6 @@ endif
|
|||||||
|
|
||||||
ROOTDEPPATH = --dep-path .
|
ROOTDEPPATH = --dep-path .
|
||||||
|
|
||||||
# Buttons built-in application info
|
|
||||||
|
|
||||||
APPNAME = ftpd
|
|
||||||
PRIORITY = SCHED_PRIORITY_DEFAULT
|
|
||||||
STACKSIZE = 2048
|
|
||||||
|
|
||||||
# Common build
|
# Common build
|
||||||
|
|
||||||
VPATH =
|
VPATH =
|
||||||
@@ -84,7 +78,8 @@ $(COBJS): %$(OBJEXT): %.c
|
|||||||
|
|
||||||
.context:
|
.context:
|
||||||
ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
|
ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
|
||||||
$(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
|
$(call REGISTER,ftpd_start,SCHED_PRIORITY_DEFAULT,2048,ftpd_start)
|
||||||
|
$(call REGISTER,ftpd_stop,SCHED_PRIORITY_DEFAULT,2048,ftpd_stop)
|
||||||
@touch $@
|
@touch $@
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
+54
-13
@@ -35,6 +35,16 @@
|
|||||||
#ifndef __APPS_EXAMPLES_FTPD_FTPD_H
|
#ifndef __APPS_EXAMPLES_FTPD_FTPD_H
|
||||||
#define __APPS_EXAMPLES_FTPD_FTPD_H
|
#define __APPS_EXAMPLES_FTPD_FTPD_H
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -48,7 +58,7 @@
|
|||||||
* configuration if the network is configuration prior to running the
|
* configuration if the network is configuration prior to running the
|
||||||
* example.
|
* example.
|
||||||
*
|
*
|
||||||
* If CONFIG_EXAMPELS_FTPD_NONETINIT is not defined, then the following may
|
* If CONFIG_EXAMPLES_FTPD_NONETINIT is not defined, then the following may
|
||||||
* be specified to customized the network configuration:
|
* be specified to customized the network configuration:
|
||||||
*
|
*
|
||||||
* CONFIG_EXAMPLE_FTPD_NOMAC - If the hardware has no MAC address of its
|
* CONFIG_EXAMPLE_FTPD_NOMAC - If the hardware has no MAC address of its
|
||||||
@@ -75,21 +85,33 @@
|
|||||||
# define CONFIG_EXAMPLES_FTPD_CLIENTSTACKSIZE 2048
|
# define CONFIG_EXAMPLES_FTPD_CLIENTSTACKSIZE 2048
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_EXAMPLE_FTPD_IPADDR
|
/* NSH always initializes the network */
|
||||||
# define CONFIG_EXAMPLE_FTPD_IPADDR 0x0a000002
|
|
||||||
|
#if defined(CONFIG_NSH_BUILTIN_APPS) && !defined(CONFIG_EXAMPLES_FTPD_NONETINIT)
|
||||||
|
# define CONFIG_EXAMPLES_FTPD_NONETINIT 1
|
||||||
#endif
|
#endif
|
||||||
#ifndef CONFIG_EXAMPLE_FTPD_DRIPADDR
|
|
||||||
# define CONFIG_EXAMPLE_FTPD_DRIPADDR 0x0a000002
|
#ifdef CONFIG_EXAMPLES_FTPD_NONETINIT
|
||||||
#endif
|
# undef CONFIG_EXAMPLE_FTPD_IPADDR
|
||||||
#ifndef CONFIG_EXAMPLE_FTPD_NETMASK
|
# undef CONFIG_EXAMPLE_FTPD_DRIPADDR
|
||||||
# define CONFIG_EXAMPLE_FTPD_NETMASK 0xffffff00
|
# undef CONFIG_EXAMPLE_FTPD_NETMASK
|
||||||
|
#else
|
||||||
|
# ifndef CONFIG_EXAMPLE_FTPD_IPADDR
|
||||||
|
# define CONFIG_EXAMPLE_FTPD_IPADDR 0x0a000002
|
||||||
|
# endif
|
||||||
|
# ifndef CONFIG_EXAMPLE_FTPD_DRIPADDR
|
||||||
|
# define CONFIG_EXAMPLE_FTPD_DRIPADDR 0x0a000001
|
||||||
|
# endif
|
||||||
|
# ifndef CONFIG_EXAMPLE_FTPD_NETMASK
|
||||||
|
# define CONFIG_EXAMPLE_FTPD_NETMASK 0xffffff00
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Is this being built as an NSH built-in application? */
|
/* Is this being built as an NSH built-in application? */
|
||||||
|
|
||||||
#ifdef CONFIG_NSH_BUILTIN_APPS
|
#ifdef CONFIG_NSH_BUILTIN_APPS
|
||||||
# define MAIN_NAME ftpd_main
|
# define MAIN_NAME ftpd_start
|
||||||
# define MAIN_STRING "ftpd_main: "
|
# define MAIN_STRING "ftpd_start: "
|
||||||
#else
|
#else
|
||||||
# define MAIN_NAME user_start
|
# define MAIN_NAME user_start
|
||||||
# define MAIN_STRING "user_start: "
|
# define MAIN_STRING "user_start: "
|
||||||
@@ -99,6 +121,8 @@
|
|||||||
* Public Types
|
* Public Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* This structure describes one entry in a table of accounts */
|
||||||
|
|
||||||
struct fptd_account_s
|
struct fptd_account_s
|
||||||
{
|
{
|
||||||
uint8_t flags;
|
uint8_t flags;
|
||||||
@@ -107,17 +131,34 @@ struct fptd_account_s
|
|||||||
FAR const char *home;
|
FAR const char *home;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* To minimize the probability of name collisitions, all FTPD example
|
||||||
|
* global data is maintained in single structure.
|
||||||
|
*/
|
||||||
|
|
||||||
struct ftpd_globals_s
|
struct ftpd_globals_s
|
||||||
{
|
{
|
||||||
bool initialized;
|
bool initialized; /* True: Networking is initialized. The
|
||||||
volatile bool stop;
|
* network must be initialized only once.
|
||||||
|
*/
|
||||||
|
#ifdef CONFIG_NSH_BUILTIN_APPS
|
||||||
|
volatile bool stop; /* True: Request daemon to exit */
|
||||||
|
volatile bool running; /* True: The daemon is running */
|
||||||
|
#endif
|
||||||
|
pid_t pid; /* Task ID of the FTPD daemon. The value
|
||||||
|
* -1 is a redundant indication that the
|
||||||
|
* daemon is not running.
|
||||||
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
extern struct ftpd_globls_s g_ftpdglobls;
|
/* To minimize the probability of name collisitions, all FTPD example
|
||||||
|
* global data is maintained in a single instance of a structure.
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern struct ftpd_globals_s g_ftpdglob;
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
|
|||||||
+124
-31
@@ -34,6 +34,20 @@
|
|||||||
* Included Files
|
* Included Files
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sched.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <netinet/in.h>
|
||||||
|
|
||||||
|
#include <apps/netutils/uiplib.h>
|
||||||
|
#include <apps/netutils/ftpd.h>
|
||||||
|
|
||||||
#include "ftpd.h"
|
#include "ftpd.h"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -48,14 +62,24 @@ static const struct fptd_account_s g_ftpdaccounts[] =
|
|||||||
};
|
};
|
||||||
#define NACCOUNTS (sizeof(g_ftpdaccounts) / sizeof(struct fptd_account_s))
|
#define NACCOUNTS (sizeof(g_ftpdaccounts) / sizeof(struct fptd_account_s))
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* To minimize the probability of name collisitions, all FTPD example
|
||||||
|
* global data is maintained in a single instance of a structure.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct ftpd_globals_s g_ftpdglob;
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: shell_netinit
|
* Name: fptd_netinit
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static void shell_netinit(void)
|
static void fptd_netinit(void)
|
||||||
{
|
{
|
||||||
#ifndef CONFIG_EXAMPLES_FTPD_NONETINIT
|
#ifndef CONFIG_EXAMPLES_FTPD_NONETINIT
|
||||||
struct in_addr addr;
|
struct in_addr addr;
|
||||||
@@ -98,14 +122,22 @@ static void shell_netinit(void)
|
|||||||
|
|
||||||
static void ftpd_accounts(FTPD_SESSION handle)
|
static void ftpd_accounts(FTPD_SESSION handle)
|
||||||
{
|
{
|
||||||
FAR onst struct fptd_account_s *account;
|
FAR const struct fptd_account_s *account;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
printf("Adding accounts:\n");
|
||||||
for (i = 0; i < NACCOUNTS; i++)
|
for (i = 0; i < NACCOUNTS; i++)
|
||||||
{
|
{
|
||||||
account = &g_ftpdaccounts[i];
|
account = &g_ftpdaccounts[i];
|
||||||
ftpd_add_user(handle, account->flags, account->user,
|
|
||||||
account->password, account->home);
|
printf("%d. %s account: USER=%s PASSWORD=%s HOME=%s\n",
|
||||||
|
(account->flags & FTPD_ACCOUNTFLAG_SYSTEM) != 0 ? "Root" : "User",
|
||||||
|
(account->user) ? "(none)" : account->user,
|
||||||
|
(account->password) ? "(none)" : account->password,
|
||||||
|
(account->home) ? "(none)" : account->home);
|
||||||
|
|
||||||
|
ftpd_adduser(handle, account->flags, account->user,
|
||||||
|
account->password, account->home);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,12 +150,24 @@ int ftpd_daemon(int s_argc, char **s_argv)
|
|||||||
FTPD_SESSION handle;
|
FTPD_SESSION handle;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
/* The FTPD daemon has been started */
|
||||||
|
|
||||||
|
#ifdef CONFIG_NSH_BUILTIN_APPS
|
||||||
|
g_ftpdglob.running = true;
|
||||||
|
#endif
|
||||||
|
printf("FTP daemon [%d] started\n", g_ftpdglob.pid);
|
||||||
|
|
||||||
/* Open FTPD */
|
/* Open FTPD */
|
||||||
|
|
||||||
handle = ftpd_open();
|
handle = ftpd_open();
|
||||||
if (!handle)
|
if (!handle)
|
||||||
{
|
{
|
||||||
ndbg("Failed to open FTPD\n");
|
printf("FTP daemon [%d] failed to open FTPD\n", g_ftpdglob.pid);
|
||||||
|
#ifdef CONFIG_NSH_BUILTIN_APPS
|
||||||
|
g_ftpdglob.running = false;
|
||||||
|
g_ftpdglob.stop = false;
|
||||||
|
#endif
|
||||||
|
g_ftpdglob.pid = -1;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,16 +175,33 @@ int ftpd_daemon(int s_argc, char **s_argv)
|
|||||||
|
|
||||||
(void)ftpd_accounts(handle);
|
(void)ftpd_accounts(handle);
|
||||||
|
|
||||||
/* Then drive the FTPD server */
|
/* Then drive the FTPD server. */
|
||||||
|
|
||||||
while (g_ftpdglobls.stop == 0)
|
#ifdef CONFIG_NSH_BUILTIN_APPS
|
||||||
|
while (g_ftpdglob.stop == 0)
|
||||||
|
#else
|
||||||
|
for (;;)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
(void)ftpd_run(handle, 1000);
|
/* If ftpd_session returns success, it means that a new FTP session
|
||||||
|
* has been started.
|
||||||
|
*/
|
||||||
|
|
||||||
|
ret = ftpd_session(handle, 1000);
|
||||||
|
printf("FTP daemon [%d] ftpd_session returned %d\n", g_ftpdglob.pid, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Close the FTPD server and exit */
|
/* Close the FTPD server and exit (we can get here only if
|
||||||
|
* CONFIG_NSH_BUILTIN_APPS is defined).
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_NSH_BUILTIN_APPS
|
||||||
|
printf("FTP daemon [%d] stopping\n", g_ftpdglob.pid);
|
||||||
|
g_ftpdglob.running = false;
|
||||||
|
g_ftpdglob.stop = false;
|
||||||
|
g_ftpdglob.pid = -1;
|
||||||
ftpd_close(handle);
|
ftpd_close(handle);
|
||||||
|
#endif
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,44 +209,76 @@ int ftpd_daemon(int s_argc, char **s_argv)
|
|||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: user_start/ftpd_main
|
* Name: user_start/ftpd_start
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int MAIN_NAME(int s_argc, char **s_argv)
|
int MAIN_NAME(int s_argc, char **s_argv)
|
||||||
{
|
{
|
||||||
FTPD_SESSION handle;
|
|
||||||
pid_t pid;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
/* Check if we have already initialized the network */
|
/* Check if we have already initialized the network */
|
||||||
|
|
||||||
if (!g_ftpdglobls.initialized)
|
if (!g_ftpdglob.initialized)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Bring up the network */
|
/* Bring up the network */
|
||||||
|
|
||||||
ret = ftpd_netinit();
|
printf("Initializing the network\n");
|
||||||
if (ret < 0)
|
fptd_netinit();
|
||||||
{
|
|
||||||
ndbg("Failed to initialize the network\n");
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_ftpdglobls.initialized = true;
|
/* Initialize daemon state */
|
||||||
g_ftpdglobls.stop = false;
|
|
||||||
|
g_ftpdglob.initialized = true;
|
||||||
|
g_ftpdglob.pid = -1;
|
||||||
|
#ifdef CONFIG_NSH_BUILTIN_APPS
|
||||||
|
g_ftpdglob.stop = false;
|
||||||
|
g_ftpdglob.running = false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Then start the new daemon */
|
/* Then start the new daemon (if it is not already running) */
|
||||||
|
|
||||||
g_telnetdcommon.daemon = daemon;
|
#ifdef CONFIG_NSH_BUILTIN_APPS
|
||||||
pid = TASK_CREATE("Telnet daemon", CONFIG_EXAMPLES_FTPD_PRIO,
|
if (g_ftpdglob.stop && g_ftpdglob.running)
|
||||||
CONFIG_EXAMPLES_FTPD_STACKSIZE, ftpd_daemon, NULL);
|
|
||||||
if (pid < 0)
|
|
||||||
{
|
{
|
||||||
ndbg("Failed to start the telnet daemon: %d\n", errno);
|
printf("Waiting for FTP daemon [%d] to stop\n", g_ftpdglob.pid);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
if (!g_ftpdglob.running)
|
||||||
|
{
|
||||||
|
printf("Starting the FTP daemon\n");
|
||||||
|
g_ftpdglob.pid = TASK_CREATE("FTP daemon", CONFIG_EXAMPLES_FTPD_PRIO,
|
||||||
|
CONFIG_EXAMPLES_FTPD_STACKSIZE,
|
||||||
|
ftpd_daemon, NULL);
|
||||||
|
if (g_ftpdglob.pid < 0)
|
||||||
|
{
|
||||||
|
printf("Failed to start the FTP daemon: %d\n", errno);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("FTP daemon [%d] is running\n", g_ftpdglob.pid);
|
||||||
|
}
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: ftpd_stop
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_NSH_BUILTIN_APPS
|
||||||
|
int ftpd_stop(int s_argc, char **s_argv)
|
||||||
|
{
|
||||||
|
if (!g_ftpdglob.initialized || g_ftpdglob.running)
|
||||||
|
{
|
||||||
|
printf("The FTP daemon not running\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("The FTP daemon is running, pid=%d\n", pid);
|
printf("Stopping the FTP daemon, pid=%d\n", g_ftpdglob.pid);
|
||||||
|
g_ftpdglob.stop = true;
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -48,11 +48,34 @@
|
|||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
/* Configuration ************************************************************/
|
/* Configuration ************************************************************/
|
||||||
|
/* Required configuration settings: Of course TCP networking support is
|
||||||
|
* required. But here are a couple that are less obvious:
|
||||||
|
*
|
||||||
|
* CONFIG_DISABLE_PTHREAD - pthread support is required
|
||||||
|
* CONFIG_DISABLE_POLL - poll() support is required
|
||||||
|
*
|
||||||
|
* Other FTPD configuration options thay may be of interest:
|
||||||
|
*
|
||||||
|
* CONFIG_FTPD_VENDORID - The vendor name to use in FTP communications.
|
||||||
|
* Default: "NuttX"
|
||||||
|
* CONFIG_FTPD_SERVERID - The server name to use in FTP communications.
|
||||||
|
* Default: "NuttX FTP Server"
|
||||||
|
* CONFIG_FTPD_CMDBUFFERSIZE - The maximum size of one command. Default:
|
||||||
|
* 512 bytes.
|
||||||
|
* CONFIG_FTPD_DATABUFFERSIZE - The size of the I/O buffer for data
|
||||||
|
* transfers. Default: 2048 bytes.
|
||||||
|
* CONFIG_FTPD_WORKERSTACKSIZE - The stacksize to allocate for each
|
||||||
|
* FTP daemon worker thread. Default: 2048 bytes.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifdef CONFIG_DISABLE_PTHREAD
|
#ifdef CONFIG_DISABLE_PTHREAD
|
||||||
# error "pthread support is required (CONFIG_DISABLE_PTHREAD=n)"
|
# error "pthread support is required (CONFIG_DISABLE_PTHREAD=n)"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_DISABLE_POLL
|
||||||
|
# error "poll() support is required (CONFIG_DISABLE_POLL=n)"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_FTPD_VENDORID
|
#ifndef CONFIG_FTPD_VENDORID
|
||||||
# define CONFIG_FTPD_VENDORID "NuttX"
|
# define CONFIG_FTPD_VENDORID "NuttX"
|
||||||
#endif
|
#endif
|
||||||
@@ -73,6 +96,13 @@
|
|||||||
# define CONFIG_FTPD_WORKERSTACKSIZE 2048
|
# define CONFIG_FTPD_WORKERSTACKSIZE 2048
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Interface definitions ****************************************************/
|
||||||
|
|
||||||
|
#define FTPD_ACCOUNTFLAG_NONE (0)
|
||||||
|
#define FTPD_ACCOUNTFLAG_ADMIN (1 << 0)
|
||||||
|
#define FTPD_ACCOUNTFLAG_SYSTEM (1 << 1)
|
||||||
|
#define FTPD_ACCOUNTFLAG_GUEST (1 << 2)
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Types
|
* Public Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -123,7 +153,7 @@ EXTERN FTPD_SESSION ftpd_open(void);
|
|||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* handle - A handle previously returned by ftpd_open
|
* handle - A handle previously returned by ftpd_open
|
||||||
* accountflags - The characteristics of this user (see FTPD_ACCOUNTFLAGS_*
|
* accountflags - The characteristics of this user (see FTPD_ACCOUNTFLAGS_*
|
||||||
* defintiions.
|
* definitions above).
|
||||||
* user - The user login name. May be NULL indicating that no login is
|
* user - The user login name. May be NULL indicating that no login is
|
||||||
* required.
|
* required.
|
||||||
* passwd - The user password. May be NULL indicating that no password
|
* passwd - The user password. May be NULL indicating that no password
|
||||||
|
|||||||
+163
-320
File diff suppressed because it is too large
Load Diff
+55
-56
@@ -50,24 +50,23 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
/* Networking definitions ***************************************************/
|
||||||
|
|
||||||
|
#define FTPD_PROTOCOL_TCP (6) /* TCP protocol number */
|
||||||
|
|
||||||
/* FPTD Definitions *********************************************************/
|
/* FPTD Definitions *********************************************************/
|
||||||
|
|
||||||
# define FTPD_ACCOUNTFLAG_NONE (0)
|
#define FTPD_SESSIONFLAG_USER (1 << 0)
|
||||||
# define FTPD_ACCOUNTFLAG_ADMIN (1 << 0)
|
#define FTPD_SESSIONFLAG_RESTARTPOS (1 << 1)
|
||||||
# define FTPD_ACCOUNTFLAG_SYSTEM (1 << 1)
|
#define FTPD_SESSIONFLAG_RENAMEFROM (1 << 2)
|
||||||
# define FTPD_ACCOUNTFLAG_GUEST (1 << 2)
|
|
||||||
|
|
||||||
# define FTPD_SESSIONFLAG_USER (1 << 0)
|
#define FTPD_LISTOPTION_A (1 << 0)
|
||||||
# define FTPD_SESSIONFLAG_RESTARTPOS (1 << 1)
|
#define FTPD_LISTOPTION_L (1 << 1)
|
||||||
# define FTPD_SESSIONFLAG_RENAMEFROM (1 << 2)
|
#define FTPD_LISTOPTION_F (1 << 2)
|
||||||
|
#define FTPD_LISTOPTION_R (1 << 3)
|
||||||
|
#define FTPD_LISTOPTION_UNKNOWN (1 << 7)
|
||||||
|
|
||||||
# define FTPD_LISTOPTION_A (1 << 0)
|
#define FTPD_CMDFLAG_LOGIN (1 << 0)
|
||||||
# define FTPD_LISTOPTION_L (1 << 1)
|
|
||||||
# define FTPD_LISTOPTION_F (1 << 2)
|
|
||||||
# define FTPD_LISTOPTION_R (1 << 3)
|
|
||||||
# define FTPD_LISTOPTION_UNKNOWN (1 << 7)
|
|
||||||
|
|
||||||
# define FTPD_CMDFLAG_LOGIN (1 << 0)
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Types
|
* Public Types
|
||||||
@@ -84,21 +83,21 @@ enum ftpd_sessiontype_e
|
|||||||
|
|
||||||
struct ftpd_pathnode_s
|
struct ftpd_pathnode_s
|
||||||
{
|
{
|
||||||
struct ftpd_pathnode_s *flink;
|
struct ftpd_pathnode_s *flink;
|
||||||
struct ftpd_pathnode_s *blink;
|
struct ftpd_pathnode_s *blink;
|
||||||
bool ignore;
|
bool ignore;
|
||||||
FAR char *name;
|
FAR char *name;
|
||||||
};
|
};
|
||||||
|
|
||||||
union ftpd_sockaddr_u
|
union ftpd_sockaddr_u
|
||||||
{
|
{
|
||||||
uint8_t raw[sizeof(struct sockaddr_storage)];
|
uint8_t raw[sizeof(struct sockaddr_storage)];
|
||||||
struct sockaddr_storage ss;
|
struct sockaddr_storage ss;
|
||||||
struct sockaddr sa;
|
struct sockaddr sa;
|
||||||
#ifdef CONFIG_NET_IPv6
|
#ifdef CONFIG_NET_IPv6
|
||||||
struct sockaddr_in6 in6;
|
struct sockaddr_in6 in6;
|
||||||
#else
|
#else
|
||||||
struct sockaddr_in in4;
|
struct sockaddr_in in4;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -106,52 +105,52 @@ union ftpd_sockaddr_u
|
|||||||
|
|
||||||
struct ftpd_account_s
|
struct ftpd_account_s
|
||||||
{
|
{
|
||||||
struct ftpd_account_s *blink;
|
struct ftpd_account_s *blink;
|
||||||
struct ftpd_account_s *flink;
|
struct ftpd_account_s *flink;
|
||||||
uint8_t flags; /* See FTPD_ACCOUNTFLAG_* definitions */
|
uint8_t flags; /* See FTPD_ACCOUNTFLAG_* definitions */
|
||||||
FAR char *user; /* User name */
|
FAR char *user; /* User name */
|
||||||
FAR char *password; /* Un-encrypted password */
|
FAR char *password; /* Un-encrypted password */
|
||||||
FAR char *home; /* Home directory path */
|
FAR char *home; /* Home directory path */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* This structures describes an FTP session a list of associated accounts */
|
/* This structures describes an FTP session a list of associated accounts */
|
||||||
|
|
||||||
struct ftpd_server_s
|
struct ftpd_server_s
|
||||||
{
|
{
|
||||||
int sd; /* Listen socket descriptor */
|
int sd; /* Listen socket descriptor */
|
||||||
union ftpd_sockaddr_u addr; /* Listen address */
|
union ftpd_sockaddr_u addr; /* Listen address */
|
||||||
struct ftpd_account_s *head; /* Head of a list of accounts */
|
struct ftpd_account_s *head; /* Head of a list of accounts */
|
||||||
struct ftpd_account_s *tail; /* Tail of a list of accounts */
|
struct ftpd_account_s *tail; /* Tail of a list of accounts */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ftpd_stream_s
|
struct ftpd_stream_s
|
||||||
{
|
{
|
||||||
int sd; /* Socket descriptor */
|
int sd; /* Socket descriptor */
|
||||||
union ftpd_sockaddr_u addr; /* Network address */
|
union ftpd_sockaddr_u addr; /* Network address */
|
||||||
socklen_t addrlen; /* Length of the address */
|
socklen_t addrlen; /* Length of the address */
|
||||||
size_t buflen; /* Length of the buffer */
|
size_t buflen; /* Length of the buffer */
|
||||||
uint8_t *buffer; /* Pointer to the buffer */
|
char *buffer; /* Pointer to the buffer */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ftpd_session_s
|
struct ftpd_session_s
|
||||||
{
|
{
|
||||||
FAR struct ftpd_server_s shadow;
|
FAR struct ftpd_server_s *server;
|
||||||
FAR struct ftpd_account_s *head;
|
FAR struct ftpd_account_s *head;
|
||||||
FAR struct ftpd_account_s *curr;
|
FAR struct ftpd_account_s *curr;
|
||||||
uint8_t flags; /* See TPD_SESSIONFLAG_* definitions */
|
uint8_t flags; /* See TPD_SESSIONFLAG_* definitions */
|
||||||
int txtimeout;
|
int rxtimeout;
|
||||||
int txtimeout;
|
int txtimeout;
|
||||||
|
|
||||||
/* Command */
|
/* Command */
|
||||||
|
|
||||||
struct ftpd_stream_s cmd;
|
struct ftpd_stream_s cmd;
|
||||||
FAR char *cmd;
|
FAR char *command;
|
||||||
FAR char *param;
|
FAR char *param;
|
||||||
|
|
||||||
/* Data */
|
/* Data */
|
||||||
|
|
||||||
struct ftpd_stream_s data;
|
struct ftpd_stream_s data;
|
||||||
off_t restartpos;
|
off_t restartpos;
|
||||||
|
|
||||||
/* File */
|
/* File */
|
||||||
|
|
||||||
@@ -159,27 +158,27 @@ struct ftpd_session_s
|
|||||||
|
|
||||||
/* Current user */
|
/* Current user */
|
||||||
|
|
||||||
FAR char *user;
|
FAR char *user;
|
||||||
uint8_t m_type; /* See enum ftpd_sessiontype_e */
|
uint8_t type; /* See enum ftpd_sessiontype_e */
|
||||||
FAR char *home;
|
FAR char *home;
|
||||||
FAR char *work;
|
FAR char *work;
|
||||||
FAR char *renamefrom;
|
FAR char *renamefrom;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef int (*ftpd_cmdhandler_t)(struct ftpd_session_s *);
|
typedef int (*ftpd_cmdhandler_t)(struct ftpd_session_s *);
|
||||||
|
|
||||||
struct ftpd_cmd_s
|
struct ftpd_cmd_s
|
||||||
{
|
{
|
||||||
FAR const char *cmd; /* The command string */
|
FAR const char *command; /* The command string */
|
||||||
ftpd_cmdhandler_t handler; /* The function that handles the command */
|
ftpd_cmdhandler_t handler; /* The function that handles the command */
|
||||||
uint8_t flags; /* See FTPD_CMDFLAGS_* definitions */
|
uint8_t flags; /* See FTPD_CMDFLAGS_* definitions */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Used to maintain a list of protocol names */
|
/* Used to maintain a list of protocol names */
|
||||||
|
|
||||||
struct ftpd_protocol_s
|
struct ftpd_protocol_s
|
||||||
{
|
{
|
||||||
FAR const char *name;
|
FAR const char *name;
|
||||||
int value;
|
int value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ include $(APPDIR)/Make.defs
|
|||||||
# NSH Library
|
# NSH Library
|
||||||
|
|
||||||
ASRCS =
|
ASRCS =
|
||||||
CSRCS = nsh_parse.c nsh_console.c nsh_fscmds.c nsh_ddcmd.c nsh_proccmds.c \
|
CSRCS = nsh_init.c nsh_parse.c nsh_console.c nsh_fscmds.c nsh_ddcmd.c \
|
||||||
nsh_mmcmds.c nsh_envcmds.c nsh_dbgcmds.c
|
nsh_proccmds.c nsh_mmcmds.c nsh_envcmds.c nsh_dbgcmds.c
|
||||||
|
|
||||||
ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
|
ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
|
||||||
CSRCS += nsh_apps.c
|
CSRCS += nsh_apps.c
|
||||||
|
|||||||
@@ -0,0 +1,102 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* apps/nshlib/nsh_init.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007-2012 Gregory Nutt. All rights reserved.
|
||||||
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include "nsh.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Types
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Function Prototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: nsh_initialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This nterfaces is used to initialize the NuttShell (NSH).
|
||||||
|
* nsh_initialize() should be called one during application start-up prior
|
||||||
|
* to executing either nsh_consolemain() or nsh_telnetstart().
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void nsh_initialize(void)
|
||||||
|
{
|
||||||
|
/* Mount the /etc filesystem */
|
||||||
|
|
||||||
|
(void)nsh_romfsetc();
|
||||||
|
|
||||||
|
/* Perform architecture-specific initialization (if available) */
|
||||||
|
|
||||||
|
(void)nsh_archinitialize();
|
||||||
|
|
||||||
|
/* Bring up the network */
|
||||||
|
|
||||||
|
(void)nsh_netinit();
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1017,37 +1017,6 @@ static inline int nsh_nice(FAR struct nsh_vtbl_s *vtbl, FAR char **ppcmd, FAR ch
|
|||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: nsh_initialize
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* This nterfaces is used to initialize the NuttShell (NSH).
|
|
||||||
* nsh_initialize() should be called one during application start-up prior
|
|
||||||
* to executing either nsh_consolemain() or nsh_telnetstart().
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void nsh_initialize(void)
|
|
||||||
{
|
|
||||||
/* Mount the /etc filesystem */
|
|
||||||
|
|
||||||
(void)nsh_romfsetc();
|
|
||||||
|
|
||||||
/* Perform architecture-specific initialization (if available) */
|
|
||||||
|
|
||||||
(void)nsh_archinitialize();
|
|
||||||
|
|
||||||
/* Bring up the network */
|
|
||||||
|
|
||||||
(void)nsh_netinit();
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: nsh_parse
|
* Name: nsh_parse
|
||||||
*
|
*
|
||||||
|
|||||||
+1
-1
@@ -2446,4 +2446,4 @@
|
|||||||
* lib/stdio/lib_avsprintf.c: Add avsprintf().
|
* lib/stdio/lib_avsprintf.c: Add avsprintf().
|
||||||
* lib/net/lib_inetntop.c: Add inet_ntop().
|
* lib/net/lib_inetntop.c: Add inet_ntop().
|
||||||
* lib/net/lib_inetpton.c: Add inet_pton().
|
* lib/net/lib_inetpton.c: Add inet_pton().
|
||||||
|
* include/pthread.h: Correct PTHREAD_MUTEX_INITIALIZER.
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
<h1><big><font color="#3c34ec">
|
<h1><big><font color="#3c34ec">
|
||||||
<i>NuttX RTOS Porting Guide</i>
|
<i>NuttX RTOS Porting Guide</i>
|
||||||
</font></big></h1>
|
</font></big></h1>
|
||||||
<p>Last Updated: January 25, 2011</p>
|
<p>Last Updated: February 5, 2011</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -4866,6 +4866,36 @@ build
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<h3>FTP Server</h3>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<code>CONFIG_FTPD_VENDORID</code>: The vendor name to use in FTP communications. Default: "NuttX"
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<code>CONFIG_FTPD_SERVERID</code>: The server name to use in FTP communications. Default: "NuttX FTP Server"
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<code>CONFIG_FTPD_CMDBUFFERSIZE</code>: The maximum size of one command. Default: 512 bytes.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<code>CONFIG_FTPD_DATABUFFERSIZE</code>: The size of the I/O buffer for data transfers. Default: 2048 bytes.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<code>CONFIG_FTPD_WORKERSTACKSIZE</code>: The stacksize to allocate for each FTP daemon worker thread. Default: 2048 bytes.
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<p>
|
||||||
|
Other required FTPD configuration settings: Of course TCP networking support is required. But here are a couple that are less obvious:
|
||||||
|
</p>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<code>CONFIG_DISABLE_PTHREAD=n</code>: pthread support is required
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<code>CONFIG_DISABLE_POLL=n</code>: poll() support is required
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
<h2>USB Device-Side Support</h2>
|
<h2>USB Device-Side Support</h2>
|
||||||
<h3>USB Device Controller Driver</h3>
|
<h3>USB Device Controller Driver</h3>
|
||||||
<ul>
|
<ul>
|
||||||
|
|||||||
@@ -916,6 +916,25 @@ defconfig -- This is a configuration file similar to the Linux
|
|||||||
CONFIG_THTTPD_URLPATTERN - If defined, then it will be used to match
|
CONFIG_THTTPD_URLPATTERN - If defined, then it will be used to match
|
||||||
and verify referrers.
|
and verify referrers.
|
||||||
|
|
||||||
|
FTP Server
|
||||||
|
|
||||||
|
CONFIG_FTPD_VENDORID - The vendor name to use in FTP communications.
|
||||||
|
Default: "NuttX"
|
||||||
|
CONFIG_FTPD_SERVERID - The server name to use in FTP communications.
|
||||||
|
Default: "NuttX FTP Server"
|
||||||
|
CONFIG_FTPD_CMDBUFFERSIZE - The maximum size of one command. Default:
|
||||||
|
512 bytes.
|
||||||
|
CONFIG_FTPD_DATABUFFERSIZE - The size of the I/O buffer for data
|
||||||
|
transfers. Default: 2048 bytes.
|
||||||
|
CONFIG_FTPD_WORKERSTACKSIZE - The stacksize to allocate for each
|
||||||
|
FTP daemon worker thread. Default: 2048 bytes.
|
||||||
|
|
||||||
|
Other required configuration settings: Of course TCP networking support
|
||||||
|
is required. But here are a couple that are less obvious:
|
||||||
|
|
||||||
|
CONFIG_DISABLE_PTHREAD - pthread support is required
|
||||||
|
CONFIG_DISABLE_POLL - poll() support is required
|
||||||
|
|
||||||
USB device controller driver
|
USB device controller driver
|
||||||
|
|
||||||
CONFIG_USBDEV - Enables USB device support
|
CONFIG_USBDEV - Enables USB device support
|
||||||
|
|||||||
@@ -661,7 +661,25 @@ Where <subdir> is one of the following:
|
|||||||
CONFIG_DEBUG_CAN
|
CONFIG_DEBUG_CAN
|
||||||
CONFIG_CAN_REGDEBUG
|
CONFIG_CAN_REGDEBUG
|
||||||
|
|
||||||
5. This configuration requires that jumper JP22 be set to enable RS-232 operation.
|
5. This example can support an FTP client. In order to build in FTP client
|
||||||
|
support simply uncomment the following lines in the appconfig file (before
|
||||||
|
configuring) or in the apps/.config file (after configuring):
|
||||||
|
|
||||||
|
#CONFIGURED_APPS += netutils/ftpc
|
||||||
|
#CONFIGURED_APPS += examples/ftpc
|
||||||
|
|
||||||
|
6. This example can support an FTP server. In order to build in FTP server
|
||||||
|
support simply uncomment the following lines in the appconfig file (before
|
||||||
|
configuring) or in the apps/.config file (after configuring):
|
||||||
|
|
||||||
|
#CONFIGURED_APPS += netutils/ftpd
|
||||||
|
#CONFIGURED_APPS += examples/ftpd
|
||||||
|
|
||||||
|
And enable poll() support in the NuttX configuration file:
|
||||||
|
|
||||||
|
CONFIG_DISABLE_POLL=n
|
||||||
|
|
||||||
|
7. This configuration requires that jumper JP22 be set to enable RS-232 operation.
|
||||||
|
|
||||||
nsh2:
|
nsh2:
|
||||||
-----
|
-----
|
||||||
|
|||||||
@@ -43,8 +43,8 @@ CONFIGURED_APPS += system/readline
|
|||||||
CONFIGURED_APPS += nshlib
|
CONFIGURED_APPS += nshlib
|
||||||
|
|
||||||
# Networking libraries.
|
# Networking libraries.
|
||||||
# Uncomment netutils/ftpc to include an FTP client
|
# Uncomment netutils/ftpc to include an FTP client library
|
||||||
# Uncomment netutils/ftpd to include an FTP server
|
# Uncomment netutils/ftpd to include an FTP server library
|
||||||
|
|
||||||
ifeq ($(CONFIG_NET),y)
|
ifeq ($(CONFIG_NET),y)
|
||||||
CONFIGURED_APPS += netutils/uiplib
|
CONFIGURED_APPS += netutils/uiplib
|
||||||
|
|||||||
+41
-12
@@ -51,8 +51,36 @@
|
|||||||
|
|
||||||
/* Values for protocol argument to socket() */
|
/* Values for protocol argument to socket() */
|
||||||
|
|
||||||
#define IPPROTO_TCP 1
|
#define IPPROTO_IP 0 /* Dummy protocol for TCP */
|
||||||
#define IPPROTO_UDP 2
|
#define IPPROTO_HOPOPTS 0 /* IPv6 Hop-by-Hop options. */
|
||||||
|
#define IPPROTO_ICMP 1 /* Internet Control Message Protocol */
|
||||||
|
#define IPPROTO_IGMP 2 /* Internet Group Management Protocol */
|
||||||
|
#define IPPROTO_IPIP 4 /* IPIP tunnels (older KA9Q tunnels use 94) */
|
||||||
|
#define IPPROTO_TCP 6 /* Transmission Control Protocol */
|
||||||
|
#define IPPROTO_EGP 8 /* Exterior Gateway Protocol */
|
||||||
|
#define IPPROTO_PUP 12 /* PUP protocol */
|
||||||
|
#define IPPROTO_UDP 17 /* User Datagram Protocol */
|
||||||
|
#define IPPROTO_IDP 22 /* XNS IDP protocol */
|
||||||
|
#define IPPROTO_TP 29 /* SO Transport Protocol Class 4. */
|
||||||
|
#define IPPROTO_DCCP 33 /* Datagram Congestion Control Protocol */
|
||||||
|
#define IPPROTO_IPV6 41 /* IPv6-in-IPv4 tunnelling */
|
||||||
|
#define IPPROTO_ROUTING 43 /* IPv6 routing header. */
|
||||||
|
#define IPPROTO_FRAGMENT 44 /* IPv6 fragmentation header. */
|
||||||
|
#define IPPROTO_RSVP 46 /* Reservation Protocol. */
|
||||||
|
#define IPPROTO_GRE 47 /* General Routing Encapsulation. */
|
||||||
|
#define IPPROTO_ESP 50 /* Encapsulation Security Payload protocol */
|
||||||
|
#define IPPROTO_AH 51 /* Authentication Header protocol */
|
||||||
|
#define IPPROTO_ICMPV6 58 /* ICMPv6 */
|
||||||
|
#define IPPROTO_NONE 59 /* IPv6 no next header. */
|
||||||
|
#define IPPROTO_DSTOPTS 60 /* IPv6 destination options. */
|
||||||
|
#define IPPROTO_MTP 92 /* Multicast Transport Protocol. */
|
||||||
|
#define IPPROTO_ENCAP 98 /* Encapsulation Header. */
|
||||||
|
#define IPPROTO_BEETPH 94 /* IP option pseudo header for BEET */
|
||||||
|
#define IPPROTO_PIM 103 /* Protocol Independent Multicast */
|
||||||
|
#define IPPROTO_COMP 108 /* Compression Header protocol */
|
||||||
|
#define IPPROTO_SCTP 132 /* Stream Control Transport Protocol */
|
||||||
|
#define IPPROTO_UDPLITE 136 /* UDP-Lite (RFC 3828) */
|
||||||
|
#define IPPROTO_RAW 255 /* Raw IP packets */
|
||||||
|
|
||||||
/* Values used with SIOCSIFMCFILTER and SIOCGIFMCFILTER ioctl's */
|
/* Values used with SIOCSIFMCFILTER and SIOCGIFMCFILTER ioctl's */
|
||||||
|
|
||||||
@@ -88,16 +116,17 @@
|
|||||||
/* IPv4 Internet address */
|
/* IPv4 Internet address */
|
||||||
|
|
||||||
typedef uint32_t in_addr_t;
|
typedef uint32_t in_addr_t;
|
||||||
|
|
||||||
struct in_addr
|
struct in_addr
|
||||||
{
|
{
|
||||||
in_addr_t s_addr; /* Address (network byte order) */
|
in_addr_t s_addr; /* Address (network byte order) */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sockaddr_in
|
struct sockaddr_in
|
||||||
{
|
{
|
||||||
sa_family_t sin_family; /* Address family: AF_INET */
|
sa_family_t sin_family; /* Address family: AF_INET */
|
||||||
uint16_t sin_port; /* Port in network byte order */
|
uint16_t sin_port; /* Port in network byte order */
|
||||||
struct in_addr sin_addr; /* Internet address */
|
struct in_addr sin_addr; /* Internet address */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* IPv6 Internet address */
|
/* IPv6 Internet address */
|
||||||
@@ -106,17 +135,17 @@ struct in6_addr
|
|||||||
{
|
{
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
uint8_t u6_addr8[16];
|
uint8_t u6_addr8[16];
|
||||||
uint16_t u6_addr16[8];
|
uint16_t u6_addr16[8];
|
||||||
uint32_t u6_addr32[4];
|
uint32_t u6_addr32[4];
|
||||||
} in6_u;
|
} in6_u;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sockaddr_in6
|
struct sockaddr_in6
|
||||||
{
|
{
|
||||||
sa_family_t sin_family; /* Address family: AF_INET */
|
sa_family_t sin_family; /* Address family: AF_INET */
|
||||||
uint16_t sin_port; /* Port in network byte order */
|
uint16_t sin_port; /* Port in network byte order */
|
||||||
struct in6_addr sin6_addr; /* IPv6 internet address */
|
struct in6_addr sin6_addr; /* IPv6 internet address */
|
||||||
};
|
};
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -197,9 +197,9 @@ struct pthread_mutex_s
|
|||||||
typedef struct pthread_mutex_s pthread_mutex_t;
|
typedef struct pthread_mutex_s pthread_mutex_t;
|
||||||
|
|
||||||
#ifdef CONFIG_MUTEX_TYPES
|
#ifdef CONFIG_MUTEX_TYPES
|
||||||
# define PTHREAD_MUTEX_INITIALIZER {0, {1, 0xffff}, PTHREAD_MUTEX_DEFAULT, 0}
|
# define PTHREAD_MUTEX_INITIALIZER {0, SEM_INITIALIZER(1), PTHREAD_MUTEX_DEFAULT, 0}
|
||||||
#else
|
#else
|
||||||
# define PTHREAD_MUTEX_INITIALIZER {0, {1, 0xffff}}
|
# define PTHREAD_MUTEX_INITIALIZER {0, SEM_INITIALIZER(1)}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct pthread_barrierattr_s
|
struct pthread_barrierattr_s
|
||||||
|
|||||||
@@ -71,7 +71,13 @@ struct semholder_s
|
|||||||
void *holder; /* Holder TCB (actual type is _TCB) */
|
void *holder; /* Holder TCB (actual type is _TCB) */
|
||||||
int16_t counts; /* Number of counts owned by this holder */
|
int16_t counts; /* Number of counts owned by this holder */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if CONFIG_SEM_PREALLOCHOLDERS > 0
|
||||||
|
# define SEMHOLDER_INITIALIZER {NULL, NULL, 0}
|
||||||
|
#else
|
||||||
|
# define SEMHOLDER_INITIALIZER {NULL, 0}
|
||||||
#endif
|
#endif
|
||||||
|
#endif /* CONFIG_PRIORITY_INHERITANCE */
|
||||||
|
|
||||||
/* This is the generic semaphore structure. */
|
/* This is the generic semaphore structure. */
|
||||||
|
|
||||||
@@ -85,6 +91,12 @@ struct sem_s
|
|||||||
};
|
};
|
||||||
typedef struct sem_s sem_t;
|
typedef struct sem_s sem_t;
|
||||||
|
|
||||||
|
#ifdef CONFIG_PRIORITY_INHERITANCE
|
||||||
|
# define SEM_INITIALIZER(c) {(c), SEMHOLDER_INITIALIZER}
|
||||||
|
#else
|
||||||
|
# define SEM_INITIALIZER(c) {(c)}
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Variables
|
* Public Variables
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|||||||
+53
-28
@@ -52,35 +52,35 @@
|
|||||||
|
|
||||||
/* Protocol families */
|
/* Protocol families */
|
||||||
|
|
||||||
#define PF_UNSPEC 0 /* Protocol family unspecified */
|
#define PF_UNSPEC 0 /* Protocol family unspecified */
|
||||||
#define PF_UNIX 1 /* Local communication */
|
#define PF_UNIX 1 /* Local communication */
|
||||||
#define PF_LOCAL 1 /* Local communication */
|
#define PF_LOCAL 1 /* Local communication */
|
||||||
#define PF_INET 2 /* IPv4 Internet protocols */
|
#define PF_INET 2 /* IPv4 Internet protocols */
|
||||||
#define PF_INET6 3 /* IPv6 Internet protocols */
|
#define PF_INET6 3 /* IPv6 Internet protocols */
|
||||||
#define PF_IPX 4 /* IPX - Novell protocols */
|
#define PF_IPX 4 /* IPX - Novell protocols */
|
||||||
#define PF_NETLINK 5 /* Kernel user interface device */
|
#define PF_NETLINK 5 /* Kernel user interface device */
|
||||||
#define PF_X25 6 /* ITU-T X.25 / ISO-8208 protocol */
|
#define PF_X25 6 /* ITU-T X.25 / ISO-8208 protocol */
|
||||||
#define PF_AX25 7 /* Amateur radio AX.25 protocol */
|
#define PF_AX25 7 /* Amateur radio AX.25 protocol */
|
||||||
#define PF_ATMPVC 8 /* Access to raw ATM PVCs */
|
#define PF_ATMPVC 8 /* Access to raw ATM PVCs */
|
||||||
#define PF_APPLETALK 9 /* Appletalk */
|
#define PF_APPLETALK 9 /* Appletalk */
|
||||||
#define PF_PACKET 10 /* Low level packet interface */
|
#define PF_PACKET 10 /* Low level packet interface */
|
||||||
|
|
||||||
/* Address families */
|
/* Address families */
|
||||||
|
|
||||||
#define AF_UNSPEC PF_UNSPEC
|
#define AF_UNSPEC PF_UNSPEC
|
||||||
#define AF_UNIX PF_UNIX
|
#define AF_UNIX PF_UNIX
|
||||||
#define AF_LOCAL PF_LOCAL
|
#define AF_LOCAL PF_LOCAL
|
||||||
#define AF_INET PF_INET
|
#define AF_INET PF_INET
|
||||||
#define AF_INET6 PF_INET6
|
#define AF_INET6 PF_INET6
|
||||||
#define AF_IPX PF_IPX
|
#define AF_IPX PF_IPX
|
||||||
#define AF_NETLINK PF_NETLINK
|
#define AF_NETLINK PF_NETLINK
|
||||||
#define AF_X25 PF_X25
|
#define AF_X25 PF_X25
|
||||||
#define AF_AX25 PF_AX25
|
#define AF_AX25 PF_AX25
|
||||||
#define AF_ATMPVC PF_ATMPVC
|
#define AF_ATMPVC PF_ATMPVC
|
||||||
#define AF_APPLETALK PF_APPLETALK
|
#define AF_APPLETALK PF_APPLETALK
|
||||||
#define AF_PACKET PF_PACKET
|
#define AF_PACKET PF_PACKET
|
||||||
|
|
||||||
/*The socket created by socket() has the indicated type, which specifies
|
/* The socket created by socket() has the indicated type, which specifies
|
||||||
* the communication semantics.
|
* the communication semantics.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -95,7 +95,6 @@
|
|||||||
#define SOCK_RDM 4 /* Provides a reliable datagram layer that does not guarantee ordering. */
|
#define SOCK_RDM 4 /* Provides a reliable datagram layer that does not guarantee ordering. */
|
||||||
#define SOCK_PACKET 5 /* Obsolete and should not be used in new programs */
|
#define SOCK_PACKET 5 /* Obsolete and should not be used in new programs */
|
||||||
|
|
||||||
|
|
||||||
/* Bits in the FLAGS argument to `send', `recv', et al. These are the bits
|
/* Bits in the FLAGS argument to `send', `recv', et al. These are the bits
|
||||||
* recognized by Linus, not all are supported by NuttX.
|
* recognized by Linus, not all are supported by NuttX.
|
||||||
*/
|
*/
|
||||||
@@ -160,10 +159,36 @@
|
|||||||
* Type Definitions
|
* Type Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* sockaddr_storage structure. This structure must be (1) large enough to
|
||||||
|
* accommodate all supported protocol-specific address structures, and (2)
|
||||||
|
* aligned at an appropriate boundary so that pointers to it can be cast
|
||||||
|
* as pointers to protocol-specific address structures and used to access
|
||||||
|
* the fields of those structures without alignment problems
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_IPv6
|
||||||
|
struct sockaddr_storage
|
||||||
|
{
|
||||||
|
sa_family_t ss_family; /* Address family */
|
||||||
|
char ss_data[18]; /* 18-bytes of address data */
|
||||||
|
};
|
||||||
|
#else
|
||||||
|
struct sockaddr_storage
|
||||||
|
{
|
||||||
|
sa_family_t ss_family; /* Address family */
|
||||||
|
char ss_data[14]; /* 14-bytes of address data */
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* The sockaddr structure is used to define a socket address which is used
|
||||||
|
* in the bind(), connect(), getpeername(), getsockname(), recvfrom(), and
|
||||||
|
* sendto() functions.
|
||||||
|
*/
|
||||||
|
|
||||||
struct sockaddr
|
struct sockaddr
|
||||||
{
|
{
|
||||||
sa_family_t sa_family;
|
sa_family_t sa_family; /* Address family: See AF_* definitions */
|
||||||
char sa_data[14];
|
char sa_data[14]; /* 14-bytes of address data */
|
||||||
};
|
};
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
Reference in New Issue
Block a user