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