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