rtems-docs/networking/network_servers.rst
Martin Erik Werner 2e711f2b4b Address several issues from compiling examples
Compiling the code from examples "code-block:: c" along with public
includes and a bsp exposed a few issues amongst a lot of false
positives. Address some of these:

* Terminate struct declarations with ';'. Mainly for pedantic
  correctness.

* Show ptrdiff_t instead of size_t for the sbrk() prototype, matching
  the current argument type in rtems.

* Replace some occurrences of unsigned16 with uint16_t.

* Fix odd type declaration, "uint8_t char*" -> "char*".

* Use appropriate helper to get chain head instead of invalid access to
  nonexistent struct member.

* Remove several excess '\' escapes.

* Use RTEMS_SELF instead of undefined SELF.

* Use rtems_task instead of void for task functions.

* Add missing stack size parameter in task creation.

* Use rtems_interrupt_level instead of undefined rtems_interrupt.

* Correct return value format for rtems_object_id_get_api()
  rtems_object_id_get_index() (enum and uint16_t) and also fix
  corresponding print formatting.

* Correct return value documentation for rtems_object_id_get_class(),
  rtems_object_id_get_node() and rtems_object_id_get_index()
  int -> uint32_t.

* Use RTEMS_SUCCESSFUL instead of undefined RTEMS_STATUS_SUCCESSFUL and
  fix return value variable name in rate monotonic examples.

* Use RTEMS_TIMEOUT instead of undefined TIMEOUT and RTEMS_PERIOD_STATUS
  instead of undefined STATUS.

* Add missing fields to ftpd configuration.

* Correct parameter types in ftpd hook prototype,
  unsigned char * -> void *.

* Fix various code-block:: attributes, c -> makefile and c -> shell.

* Add missing parenthesis in socket buffer memory calculation example.

* Remove typedef in declaration of mq_attr since it is defiend without
  typedef in reality.

* Update siginfo_t declaration to match current reality.

* Update shell user command definition example to include mode, uid and
  gid.
2019-09-03 09:48:35 +10:00

117 lines
3.9 KiB
ReStructuredText

.. SPDX-License-Identifier: CC-BY-SA-4.0
.. COMMENT: RTEMS Remote Debugger Server Specifications
.. COMMENT: Written by: Emmanuel Raguet <raguet@crf.canon.fr>
Network Servers
###############
RTEMS FTP Daemon
================
The RTEMS FTPD is a complete file transfer protocol (FTP) daemon which can
store, retrieve, and manipulate files on the local filesystem. In addition,
the RTEMS FTPD provides "hooks" which are actions performed on received data.
Hooks are useful in situations where a destination file is not necessarily
appropriate or in cases when a formal device driver has not yet been
implemented.
This server was implemented and documented by Jake Janovetz
(janovetz@tempest.ece.uiuc.edu).
Configuration Parameters
------------------------
The configuration structure for FTPD is as follows:
.. code-block:: c
struct rtems_ftpd_configuration
{
rtems_task_priority priority; /* FTPD task priority */
unsigned long max_hook_filesize; /* Maximum buffersize */
/* for hooks */
int port; /* Well-known port */
struct rtems_ftpd_hook *hooks; /* List of hooks */
};
The FTPD task priority is specified with ``priority``. Because hooks are not
saved as files, the received data is placed in an allocated buffer.
``max_hook_filesize`` specifies the maximum size of this buffer. Finally,
``hooks`` is a pointer to the configured hooks structure.
Initializing FTPD (Starting the daemon)
---------------------------------------
Starting FTPD is done with a call to ``rtems_initialize_ftpd()``. The
configuration structure must be provided in the application source code.
Example hooks structure and configuration structure folllow.
.. code-block:: c
struct rtems_ftpd_hook ftp_hooks[] =
{
{"untar", Untar_FromMemory},
{NULL, NULL}
};
struct rtems_ftpd_configuration rtems_ftpd_configuration =
{
40, /* FTPD task priority */
512*1024, /* Maximum hook 'file' size */
0, /* Use default port */
ftp_hooks, /* Local ftp hooks */
0, /* Use / as root */
1, /* Max. connections */
0, /* Infinite idle timeout */
0, /* Read-write access */
0, /* Ignore login check */
true /* Say hello */
};
Specifying 0 for the well-known port causes FTPD to use the UNIX standard FTPD
port (21).
Using Hooks
-----------
In the example above, one hook was installed. The hook causes FTPD to call the
function ``Untar_FromMemory`` when the user sends data to the file ``untar``.
The prototype for the ``untar`` hook (and hooks, in general) is:
.. code-block:: c
int Untar_FromMemory(void *tar_buf, size_t size);
An example FTP transcript which exercises this hook is:
.. code-block:: shell
220 RTEMS FTP server (Version 1.0-JWJ) ready.
Name (dcomm0:janovetz): John Galt
230 User logged in.
Remote system type is RTEMS.
ftp> bin
200 Type set to I.
ftp> dir
200 PORT command successful.
150 ASCII data connection for LIST.
drwxrwx--x 0 0 268 dev
drwxrwx--x 0 0 0 TFTP
226 Transfer complete.
ftp> put html.tar untar
local: html.tar remote: untar
200 PORT command successful.
150 BINARY data connection.
210 File transferred successfully.
471040 bytes sent in 0.48 secs (9.6e+02 Kbytes/sec)
ftp> dir
200 PORT command successful.
150 ASCII data connection for LIST.
drwxrwx--x 0 0 268 dev
drwxrwx--x 0 0 0 TFTP
drwxrwx--x 0 0 3484 public_html
226 Transfer complete.
ftp> quit
221 Goodbye.