source: rtems-docs/networking/network_servers.rst @ 170418a

4.115am
Last change on this file since 170418a was b412038, checked in by Chris Johns <chrisj@…>, on 04/11/16 at 03:53:58

Clean up and review of Networking User Guide.

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