blob: 0d14c4b0f72fabe6c093f8e9b10b91f7dabd5b6e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
/*
* FtpResponder.h
*
* Created on: 14 Apr 2017
* Authors: David and Christian
*/
#ifndef SRC_NETWORKING_FTPRESPONDER_H_
#define SRC_NETWORKING_FTPRESPONDER_H_
#include "UploadingNetworkResponder.h"
class FtpResponder : public UploadingNetworkResponder
{
public:
FtpResponder(NetworkResponder *n) noexcept;
bool Spin() noexcept override; // do some work, returning true if we did anything significant
bool Accept(Socket *s, NetworkProtocol protocol) noexcept override; // ask the responder to accept this connection, returns true if it did
void Terminate(NetworkProtocol protocol, NetworkInterface *interface) noexcept override; // terminate the responder if it is serving the specified protocol on the specified interface
void Diagnostics(MessageType mtype) const noexcept override;
static void InitStatic() noexcept;
static void Disable() noexcept;
protected:
void ConnectionLost() noexcept override;
void SendData() noexcept override;
void SendPassiveData() noexcept;
void DoUpload() noexcept;
bool ReadData() noexcept;
void CharFromClient(char c) noexcept;
void ProcessLine() noexcept;
const char *GetParameter(const char *after) const noexcept; // return the parameter followed by whitespaces after a command
void ChangeDirectory(const char *newDirectory) noexcept;
void CloseDataPort() noexcept;
static const size_t ftpMessageLength = 128; // maximum line length for incoming FTP commands
static const uint32_t ftpPasvPortTimeout = 10000; // maximum time to wait for an FTP data connection in milliseconds
Socket *dataSocket;
TcpPort passivePort;
uint32_t passivePortOpenTime;
OutputBuffer *dataBuf;
bool sendError;
bool haveCompleteLine;
bool haveFileToMove;
char clientMessage[ftpMessageLength];
size_t clientPointer;
String<MaxFilenameLength> currentDirectory;
};
#endif /* SRC_NETWORKING_FTPRESPONDER_H_ */
|