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 | |
---|
6 | Network Servers |
---|
7 | ############### |
---|
8 | |
---|
9 | RTEMS FTP Daemon |
---|
10 | ================ |
---|
11 | |
---|
12 | The RTEMS FTPD is a complete file transfer protocol (FTP) daemon which can |
---|
13 | store, retrieve, and manipulate files on the local filesystem. In addition, |
---|
14 | the RTEMS FTPD provides "hooks" which are actions performed on received data. |
---|
15 | Hooks are useful in situations where a destination file is not necessarily |
---|
16 | appropriate or in cases when a formal device driver has not yet been |
---|
17 | implemented. |
---|
18 | |
---|
19 | This server was implemented and documented by Jake Janovetz |
---|
20 | (janovetz@tempest.ece.uiuc.edu). |
---|
21 | |
---|
22 | Configuration Parameters |
---|
23 | ------------------------ |
---|
24 | |
---|
25 | The 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 | |
---|
38 | The FTPD task priority is specified with ``priority``. Because hooks are not |
---|
39 | saved 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 | |
---|
43 | Initializing FTPD (Starting the daemon) |
---|
44 | --------------------------------------- |
---|
45 | |
---|
46 | Starting FTPD is done with a call to ``rtems_initialize_ftpd()``. The |
---|
47 | configuration structure must be provided in the application source code. |
---|
48 | Example 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 | |
---|
66 | Specifying 0 for the well-known port causes FTPD to use the UNIX standard FTPD |
---|
67 | port (21). |
---|
68 | |
---|
69 | Using Hooks |
---|
70 | ----------- |
---|
71 | |
---|
72 | In the example above, one hook was installed. The hook causes FTPD to call the |
---|
73 | function ``Untar_FromMemory`` when the user sends data to the file ``untar``. |
---|
74 | The 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 | |
---|
80 | An 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. |
---|