source: rtems-docs/networking/network_servers.rst @ 489740f

4.115am
Last change on this file since 489740f was 489740f, checked in by Chris Johns <chrisj@…>, on 05/20/16 at 02:47:09

Set SPDX License Identifier in each source file.

  • Property mode set to 100644
File size: 3.6 KB
Line 
1.. comment SPDX-License-Identifier: CC-BY-SA-4.0
2
3.. COMMENT: RTEMS Remote Debugger Server Specifications
4.. COMMENT: Written by: Emmanuel Raguet <raguet@crf.canon.fr>
5
6Network Servers
7###############
8
9RTEMS FTP Daemon
10================
11
12The RTEMS FTPD is a complete file transfer protocol (FTP) daemon which can
13store, retrieve, and manipulate files on the local filesystem.  In addition,
14the RTEMS FTPD provides "hooks" which are actions performed on received data.
15Hooks are useful in situations where a destination file is not necessarily
16appropriate or in cases when a formal device driver has not yet been
17implemented.
18
19This server was implemented and documented by Jake Janovetz
20(janovetz@tempest.ece.uiuc.edu).
21
22Configuration Parameters
23------------------------
24
25The configuration structure for FTPD is as follows:
26
27.. code-block:: c
28
29    struct rtems_ftpd_configuration
30    {
31        rtems_task_priority     priority;           /* FTPD task priority  */
32        unsigned long           max_hook_filesize;  /* Maximum buffersize  */
33        /*    for hooks        */
34        int                     port;               /* Well-known port     */
35        struct rtems_ftpd_hook  *hooks;             /* List of hooks       */
36    };
37
38The FTPD task priority is specified with ``priority``.  Because hooks are not
39saved as files, the received data is placed in an allocated buffer.
40``max_hook_filesize`` specifies the maximum size of this buffer.  Finally,
41``hooks`` is a pointer to the configured hooks structure.
42
43Initializing FTPD (Starting the daemon)
44---------------------------------------
45
46Starting FTPD is done with a call to ``rtems_initialize_ftpd()``.  The
47configuration structure must be provided in the application source code.
48Example hooks structure and configuration structure folllow.
49
50.. code-block:: c
51
52    struct rtems_ftpd_hook ftp_hooks[] =
53    {
54        {"untar", Untar_FromMemory},
55        {NULL, NULL}
56    };
57
58    struct rtems_ftpd_configuration rtems_ftpd_configuration =
59    {
60        40,                     /* FTPD task priority */
61        512*1024,               /* Maximum hook 'file' size */
62        0,                      /* Use default port */
63        ftp_hooks               /* Local ftp hooks */
64    };
65
66Specifying 0 for the well-known port causes FTPD to use the UNIX standard FTPD
67port (21).
68
69Using Hooks
70-----------
71
72In the example above, one hook was installed.  The hook causes FTPD to call the
73function ``Untar_FromMemory`` when the user sends data to the file ``untar``.
74The prototype for the ``untar`` hook (and hooks, in general) is:
75
76.. code-block:: c
77
78    int Untar_FromMemory(unsigned char *tar_buf, unsigned long size);
79
80An example FTP transcript which exercises this hook is:
81
82.. code-block:: shell
83
84    220 RTEMS FTP server (Version 1.0-JWJ) ready.
85    Name (dcomm0:janovetz): John Galt
86    230 User logged in.
87    Remote system type is RTEMS.
88    ftp> bin
89    200 Type set to I.
90    ftp> dir
91    200 PORT command successful.
92    150 ASCII data connection for LIST.
93    drwxrwx--x      0     0         268  dev
94    drwxrwx--x      0     0           0  TFTP
95    226 Transfer complete.
96    ftp> put html.tar untar
97    local: html.tar remote: untar
98    200 PORT command successful.
99    150 BINARY data connection.
100    210 File transferred successfully.
101    471040 bytes sent in 0.48 secs (9.6e+02 Kbytes/sec)
102    ftp> dir
103    200 PORT command successful.
104    150 ASCII data connection for LIST.
105    drwxrwx--x      0     0         268  dev
106    drwxrwx--x      0     0           0  TFTP
107    drwxrwx--x      0     0        3484  public_html
108    226 Transfer complete.
109    ftp> quit
110    221 Goodbye.
Note: See TracBrowser for help on using the repository browser.