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