VirtualBox

source: vbox/trunk/include/iprt/ftp.h@ 82699

Last change on this file since 82699 was 82699, checked in by vboxsync, 5 years ago

IPRT/FTP: Renaming. bugref:9437

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.3 KB
Line 
1/* $Id: ftp.h 82699 2020-01-09 14:43:25Z vboxsync $ */
2/** @file
3 * Header file for FTP client / server implementations.
4 */
5
6/*
7 * Copyright (C) 2020 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27#ifndef IPRT_INCLUDED_ftp_h
28#define IPRT_INCLUDED_ftp_h
29#ifndef RT_WITHOUT_PRAGMA_ONCE
30# pragma once
31#endif
32
33#include <iprt/types.h>
34
35RT_C_DECLS_BEGIN
36
37/** @defgroup grp_rt_ftp RTFTPServer - FTP server implementation.
38 * @ingroup grp_rt
39 * @{
40 */
41
42/** @todo the following three definitions may move the iprt/types.h later. */
43/** FTP server handle. */
44typedef R3PTRTYPE(struct RTFTPSERVERINTERNAL *) RTFTPSERVER;
45/** Pointer to a FTP server handle. */
46typedef RTFTPSERVER *PRTFTPSERVER;
47/** Nil FTP client handle. */
48#define NIL_RTFTPSERVER ((RTFTPSERVER)0)
49
50/** Maximum length (in characters) a command can have (without parameters). */
51#define RTFTPSERVER_MAX_CMD_LEN 64
52
53/**
54 * Enumeration for defining the current server connection mode.
55 */
56typedef enum RTFTPSERVER_CONNECTION_MODE
57{
58 /** Normal mode, nothing to transfer. */
59 RTFTPSERVER_CONNECTION_MODE_NORMAL = 0,
60 /** Server is in passive mode (is listening). */
61 RTFTPSERVER_CONNECTION_MODE_PASSIVE,
62 /** Server connects via port to the client. */
63 RTFTPSERVER_CONNECTION_MODE_MODE_PORT,
64 /** The usual 32-bit hack. */
65 RTFTPSERVER_CONNECTION_MODE_32BIT_HACK = 0x7fffffff
66} RTFTPSERVER_CONNECTION_MODE;
67
68/**
69 * Enumeration for defining the data transfer mode.
70 */
71typedef enum RTFTPSERVER_TRANSFER_MODE
72{
73 RTFTPSERVER_TRANSFER_MODE_UNKNOWN = 0,
74 RTFTPSERVER_TRANSFER_MODE_STREAM,
75 RTFTPSERVER_TRANSFER_MODE_BLOCK,
76 RTFTPSERVER_TRANSFER_MODE_COMPRESSED,
77 /** The usual 32-bit hack. */
78 RTFTPSERVER_DATA_MODE_32BIT_HACK = 0x7fffffff
79} RTFTPSERVER_DATA_MODE;
80
81/**
82 * Enumeration for defining the data type.
83 */
84typedef enum RTFTPSERVER_DATA_TYPE
85{
86 RTFTPSERVER_DATA_TYPE_UNKNOWN = 0,
87 RTFTPSERVER_DATA_TYPE_ASCII,
88 RTFTPSERVER_DATA_TYPE_EBCDIC,
89 RTFTPSERVER_DATA_TYPE_IMAGE,
90 RTFTPSERVER_DATA_TYPE_LOCAL,
91 /** The usual 32-bit hack. */
92 RTFTPSERVER_DATA_TYPE_32BIT_HACK = 0x7fffffff
93} RTFTPSERVER_DATA_TYPE;
94
95/**
96 * Enumeration for FTP server reply codes.
97 *
98 ** @todo Might needs more codes, not complete yet.
99 */
100typedef enum RTFTPSERVER_REPLY
101{
102 /** Invalid reply type, do not use. */
103 RTFTPSERVER_REPLY_INVALID = 0,
104 /** Command not implemented, superfluous at this site. */
105 RTFTPSERVER_REPLY_ERROR_CMD_NOT_IMPL_SUPERFLUOUS = 202,
106 /** Command okay. */
107 RTFTPSERVER_REPLY_OKAY = 200,
108 /** Service ready for new user. */
109 RTFTPSERVER_REPLY_READY_FOR_NEW_USER = 220,
110 /** Closing data connection. */
111 RTFTPSERVER_REPLY_CLOSING_DATA_CONN = 226,
112 /** User logged in, proceed. */
113 RTFTPSERVER_REPLY_LOGGED_IN_PROCEED = 230,
114 /** User name okay, need password. */
115 RTFTPSERVER_REPLY_USERNAME_OKAY_NEED_PASSWORD = 331,
116 /** Connection closed; transfer aborted. */
117 RTFTPSERVER_REPLY_CONN_CLOSED_TRANSFER_ABORTED = 426,
118 /** Syntax error, command unrecognized. */
119 RTFTPSERVER_REPLY_ERROR_CMD_NOT_RECOGNIZED = 500,
120 /** Syntax error in parameters or arguments. */
121 RTFTPSERVER_REPLY_ERROR_INVALID_PARAMETERS = 501,
122 /** Command not implemented. */
123 RTFTPSERVER_REPLY_ERROR_CMD_NOT_IMPL = 502,
124 /** Bad sequence of commands. */
125 RTFTPSERVER_REPLY_ERROR_BAD_SEQUENCE = 503,
126 /** Command not implemented for that parameter. */
127 RTFTPSERVER_REPLY_ERROR_CMD_NOT_IMPL_PARAM = 504,
128 /** Not logged in. */
129 RTFTPSERVER_REPLY_NOT_LOGGED_IN = 530,
130 /** The usual 32-bit hack. */
131 RTFTPSERVER_REPLY_32BIT_HACK = 0x7fffffff
132} RTFTPSERVER_REPLY;
133
134/**
135 * Structure for maintaining a FTP server client state.
136 */
137typedef struct RTFTPSERVERCLIENTSTATE
138{
139 /** Timestamp (in ms) of last command issued by the client. */
140 uint64_t tsLastCmdMs;
141} RTFTPSERVERCLIENTSTATE;
142/** Pointer to a FTP server client state. */
143typedef RTFTPSERVERCLIENTSTATE *PRTFTPSERVERCLIENTSTATE;
144
145/**
146 * Structure for storing FTP server callback data.
147 */
148typedef struct RTFTPCALLBACKDATA
149{
150 /** Pointer to the client state. */
151 PRTFTPSERVERCLIENTSTATE pClient;
152 /** Saved user pointer. */
153 void *pvUser;
154 /** Size (in bytes) of data at user pointer. */
155 size_t cbUser;
156} RTFTPCALLBACKDATA;
157/** Pointer to FTP server callback data. */
158typedef RTFTPCALLBACKDATA *PRTFTPCALLBACKDATA;
159
160/**
161 * Function callback table for the FTP server implementation.
162 *
163 * All callbacks are optional and therefore can be NULL.
164 */
165typedef struct RTFTPSERVERCALLBACKS
166{
167 /** User pointer to data. Optional and can be NULL. */
168 void *pvUser;
169 /** Size (in bytes) of user data pointing at. Optional and can be 0. */
170 size_t cbUser;
171 DECLCALLBACKMEMBER(int, pfnOnUserConnect)(PRTFTPCALLBACKDATA pData, const char *pcszUser);
172 DECLCALLBACKMEMBER(int, pfnOnUserAuthenticate)(PRTFTPCALLBACKDATA pData, const char *pcszUser, const char *pcszPassword);
173 DECLCALLBACKMEMBER(int, pfnOnUserDisconnect)(PRTFTPCALLBACKDATA pData);
174 DECLCALLBACKMEMBER(int, pfnOnPathSetCurrent)(PRTFTPCALLBACKDATA pData, const char *pcszCWD);
175 DECLCALLBACKMEMBER(int, pfnOnPathGetCurrent)(PRTFTPCALLBACKDATA pData, char *pszPWD, size_t cbPWD);
176 DECLCALLBACKMEMBER(int, pfnOnList)(PRTFTPCALLBACKDATA pData, void **ppvData, size_t *pcbData);
177} RTFTPSERVERCALLBACKS;
178/** Pointer to a FTP server callback data table. */
179typedef RTFTPSERVERCALLBACKS *PRTFTPSERVERCALLBACKS;
180
181/**
182 * Creates a FTP server instance.
183 *
184 * @returns IPRT status code.
185 * @param phFTPServer Where to store the FTP server handle.
186 * @param pcszAddress The address for creating a listening socket.
187 * If NULL or empty string the server is bound to all interfaces.
188 * @param uPort The port for creating a listening socket.
189 * @param pCallbacks Callback table to use.
190 */
191RTR3DECL(int) RTFtpServerCreate(PRTFTPSERVER phFTPServer, const char *pcszAddress, uint16_t uPort,
192 PRTFTPSERVERCALLBACKS pCallbacks);
193
194/**
195 * Destroys a FTP server instance.
196 *
197 * @returns IPRT status code.
198 * @param hFTPServer Handle to the FTP server handle.
199 */
200RTR3DECL(int) RTFtpServerDestroy(RTFTPSERVER hFTPServer);
201
202RT_C_DECLS_END
203
204#endif /* !IPRT_INCLUDED_ftp_h */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette