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