1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief File Transfer Protocol file system (FTP client). |
---|
5 | */ |
---|
6 | |
---|
7 | /* |
---|
8 | * Copyright (c) 2009 |
---|
9 | * embedded brains GmbH |
---|
10 | * Obere Lagerstr. 30 |
---|
11 | * D-82178 Puchheim |
---|
12 | * Germany |
---|
13 | * <rtems@embedded-brains.de> |
---|
14 | * |
---|
15 | * (c) Copyright 2002 |
---|
16 | * Thomas Doerfler |
---|
17 | * IMD Ingenieurbuero fuer Microcomputertechnik |
---|
18 | * Herbststr. 8 |
---|
19 | * 82178 Puchheim, Germany |
---|
20 | * <Thomas.Doerfler@imd-systems.de> |
---|
21 | * |
---|
22 | * Modified by Sebastian Huber <sebastian.huber@embedded-brains.de>. |
---|
23 | * |
---|
24 | * This code has been created after closly inspecting "tftpdriver.c" from Eric |
---|
25 | * Norum. |
---|
26 | * |
---|
27 | * The license and distribution terms for this file may be |
---|
28 | * found in the file LICENSE in this distribution or at |
---|
29 | * http://www.rtems.com/license/LICENSE. |
---|
30 | * |
---|
31 | * $Id$ |
---|
32 | */ |
---|
33 | |
---|
34 | #ifndef _RTEMS_FTPFS_H |
---|
35 | #define _RTEMS_FTPFS_H |
---|
36 | |
---|
37 | #include <sys/time.h> |
---|
38 | #include <sys/ioctl.h> |
---|
39 | |
---|
40 | #include <rtems/libio.h> |
---|
41 | |
---|
42 | #ifdef __cplusplus |
---|
43 | extern "C" { |
---|
44 | #endif |
---|
45 | |
---|
46 | /** |
---|
47 | * @defgroup rtems_ftpfs File Transfer Protocol File System |
---|
48 | * |
---|
49 | * @brief The FTP file system (FTP client) can be used to transfer files from |
---|
50 | * or to remote hosts. |
---|
51 | * |
---|
52 | * You can mount the FTP file system with a call to mount() or |
---|
53 | * mount_and_make_target_path() with the @ref RTEMS_FILESYSTEM_TYPE_FTPFS file |
---|
54 | * system type. |
---|
55 | * |
---|
56 | * You have to add @ref CONFIGURE_FILESYSTEM_FTPFS to your application |
---|
57 | * configuration. |
---|
58 | * |
---|
59 | * You can open files either read-only or write-only. A seek is not allowed. |
---|
60 | * A close terminates the control and data connections. |
---|
61 | * |
---|
62 | * To open a file @c file.txt in the directory @c dir (relative to home |
---|
63 | * directory of the server) on a server named @c host using the user name |
---|
64 | * @c user and the password @c pw you must specify the following path: |
---|
65 | * <tt>/FTP/user:pw@@host/dir/file.txt</tt>. |
---|
66 | * |
---|
67 | * If the server is the default server specified in BOOTP, it can be ommitted: |
---|
68 | * <tt>/FTP/user:pw/dir/file.txt</tt>. |
---|
69 | * |
---|
70 | * The user name will be used for the password if it is ommitted: |
---|
71 | * <tt>/FTP/user@@host/dir/file.txt</tt>. |
---|
72 | * |
---|
73 | * For the data transfer passive (= default) and active (= fallback) mode are |
---|
74 | * supported. |
---|
75 | * |
---|
76 | * @{ |
---|
77 | */ |
---|
78 | |
---|
79 | /** |
---|
80 | * @brief Well-known port number for FTP control connection. |
---|
81 | */ |
---|
82 | #define RTEMS_FTPFS_CTRL_PORT 21 |
---|
83 | |
---|
84 | /** |
---|
85 | * @brief Default mount point for FTP file system. |
---|
86 | */ |
---|
87 | #define RTEMS_FTPFS_MOUNT_POINT_DEFAULT "/FTP" |
---|
88 | |
---|
89 | /** |
---|
90 | * @brief FTP file system IO control requests. |
---|
91 | */ |
---|
92 | typedef enum { |
---|
93 | RTEMS_FTPFS_IOCTL_GET_VERBOSE = _IOR( 'd', 1, bool *), |
---|
94 | RTEMS_FTPFS_IOCTL_SET_VERBOSE = _IOW( 'd', 1, bool *), |
---|
95 | RTEMS_FTPFS_IOCTL_GET_TIMEOUT = _IOR( 'd', 2, struct timeval *), |
---|
96 | RTEMS_FTPFS_IOCTL_SET_TIMEOUT = _IOW( 'd', 2, struct timeval *) |
---|
97 | } rtems_ftpfs_ioctl_numbers; |
---|
98 | |
---|
99 | /** |
---|
100 | * @brief Returns in @a verbose if the verbose mode is enabled or disabled for |
---|
101 | * the file system at @a mount_point. |
---|
102 | * |
---|
103 | * If @a mount_point is @c NULL the default mount point |
---|
104 | * @ref RTEMS_FTPFS_MOUNT_POINT_DEFAULT will be used. |
---|
105 | */ |
---|
106 | rtems_status_code rtems_ftpfs_get_verbose( const char *mount_point, bool *verbose); |
---|
107 | |
---|
108 | /** |
---|
109 | * @brief Enables or disables the verbose mode if @a verbose is @c true or |
---|
110 | * @c false respectively for the file system at @a mount_point. |
---|
111 | * |
---|
112 | * In the enabled verbose mode the commands and replies of the FTP control |
---|
113 | * connections will be printed to standard error. |
---|
114 | * |
---|
115 | * If @a mount_point is @c NULL the default mount point |
---|
116 | * @ref RTEMS_FTPFS_MOUNT_POINT_DEFAULT will be used. |
---|
117 | */ |
---|
118 | rtems_status_code rtems_ftpfs_set_verbose( const char *mount_point, bool verbose); |
---|
119 | |
---|
120 | /** |
---|
121 | * @brief Returns the current timeout value in @a timeout for the file system |
---|
122 | * at @a mount_point. |
---|
123 | * |
---|
124 | * If @a mount_point is @c NULL the default mount point |
---|
125 | * @ref RTEMS_FTPFS_MOUNT_POINT_DEFAULT will be used. |
---|
126 | */ |
---|
127 | rtems_status_code rtems_ftpfs_get_timeout( |
---|
128 | const char *mount_point, |
---|
129 | struct timeval *timeout |
---|
130 | ); |
---|
131 | |
---|
132 | /** |
---|
133 | * @brief Sets the timeout value to @a timeout for the file system at |
---|
134 | * @a mount_point. |
---|
135 | * |
---|
136 | * The timeout value will be used during connection establishment of active |
---|
137 | * data connections. It will be also used for send and receive operations on |
---|
138 | * data and control connections. |
---|
139 | * |
---|
140 | * If @a mount_point is @c NULL the default mount point |
---|
141 | * @ref RTEMS_FTPFS_MOUNT_POINT_DEFAULT will be used. |
---|
142 | */ |
---|
143 | rtems_status_code rtems_ftpfs_set_timeout( |
---|
144 | const char *mount_point, |
---|
145 | const struct timeval *timeout |
---|
146 | ); |
---|
147 | |
---|
148 | /** @} */ |
---|
149 | |
---|
150 | /** |
---|
151 | * @brief Do not call directly, use mount(). |
---|
152 | */ |
---|
153 | int rtems_ftpfs_initialize( |
---|
154 | rtems_filesystem_mount_table_entry_t *mt_entry, |
---|
155 | const void *data |
---|
156 | ); |
---|
157 | |
---|
158 | #ifdef __cplusplus |
---|
159 | } |
---|
160 | #endif |
---|
161 | |
---|
162 | #endif |
---|