# PFTPServer Class Reference

File Transfer Protocol server channel class. More...

`#include <ftp.h>`

Inheritance diagram for PFTPServer:

List of all members.

## Public Types

| MaxIllegalPasswords = 3
enum | { MaxIllegalPasswords = 3 }

## Public Member Functions

| PFTPServer ()
| declare a server socket
| PFTPServer (const PString &readyString)
| ~PFTPServer ()
| Delete the server, cleaning up passive sockets.
virtual PString | GetHelloString (const PString &user) const
| Get the string printed when a user logs in default value is a string giving the user name.
virtual PString | GetGoodbyeString (const PString &user) const
| return the string printed just before exiting
virtual PString | GetSystemTypeString () const
| return the string to be returned by the SYST command
PBoolean | GetAllowThirdPartyPort () const
| return the thirdPartyPort flag, allowing 3 host put and get.
void | SetAllowThirdPartyPort (PBoolean state)
| Set the thirdPartyPort flag.
PBoolean | ProcessCommand ()
| Process commands, dispatching to the appropriate virtual function.
virtual PBoolean | DispatchCommand (PINDEX code, const PString &args)
| Dispatching to the appropriate virtual function.
virtual PBoolean | CheckLoginRequired (PINDEX cmd)
| Check to see if the command requires the server to be logged in before it may be processed.
virtual PBoolean | AuthoriseUser (const PString &user, const PString &password, PBoolean &replied)
| Validate the user name and password for access.
virtual PBoolean | OnUnknown (const PCaselessString &command)
| Handle an unknown command.
virtual void | OnError (PINDEX errorCode, PINDEX cmdNum, const char *msg)
| Handle an error in command.
virtual void | OnSyntaxError (PINDEX cmdNum)
| Called for syntax errors in commands.
virtual void | OnNotImplemented (PINDEX cmdNum)
| Called for unimplemented commands.
virtual void | OnCommandSuccessful (PINDEX cmdNum)
| Called for successful commands.
virtual PBoolean | OnUSER (const PCaselessString &args)
virtual PBoolean | OnPASS (const PCaselessString &args)
virtual PBoolean | OnQUIT (const PCaselessString &args)
virtual PBoolean | OnPORT (const PCaselessString &args)
virtual PBoolean | OnSTRU (const PCaselessString &args)
virtual PBoolean | OnMODE (const PCaselessString &args)
virtual PBoolean | OnTYPE (const PCaselessString &args)
virtual PBoolean | OnNOOP (const PCaselessString &args)
virtual PBoolean | OnSYST (const PCaselessString &args)
virtual PBoolean | OnSTAT (const PCaselessString &args)
virtual PBoolean | OnRETR (const PCaselessString &args)
virtual PBoolean | OnSTOR (const PCaselessString &args)
virtual PBoolean | OnACCT (const PCaselessString &args)
virtual PBoolean | OnAPPE (const PCaselessString &args)
virtual PBoolean | OnRNFR (const PCaselessString &args)
virtual PBoolean | OnRNTO (const PCaselessString &args)
virtual PBoolean | OnDELE (const PCaselessString &args)
virtual PBoolean | OnCWD (const PCaselessString &args)
virtual PBoolean | OnCDUP (const PCaselessString &args)
virtual PBoolean | OnRMD (const PCaselessString &args)
virtual PBoolean | OnMKD (const PCaselessString &args)
virtual PBoolean | OnPWD (const PCaselessString &args)
virtual PBoolean | OnLIST (const PCaselessString &args)
virtual PBoolean | OnNLST (const PCaselessString &args)
virtual PBoolean | OnPASV (const PCaselessString &args)
virtual PBoolean | OnHELP (const PCaselessString &args)
virtual PBoolean | OnSITE (const PCaselessString &args)
virtual PBoolean | OnABOR (const PCaselessString &args)
virtual PBoolean | OnSMNT (const PCaselessString &args)
virtual PBoolean | OnREIN (const PCaselessString &args)
virtual PBoolean | OnSTOU (const PCaselessString &args)
virtual PBoolean | OnALLO (const PCaselessString &args)
virtual PBoolean | OnREST (const PCaselessString &args)
void | SendToClient (const PFilePath &filename)
| Send the specified file to the client.

## Protected Types

| NotConnected
| NeedUser
| NeedPassword
| Connected
| ClientConnect
enum | { NotConnected, NeedUser, NeedPassword, Connected, ClientConnect }

## Protected Member Functions

PBoolean | OnOpen ()
| Call back to verify open succeeded in an PInternetProtocol class.
void | Construct ()

## Protected Attributes

PString | readyString
PBoolean | thirdPartyPort
enum PFTPServer:: { ... } | state
PIPSocket::Address | remoteHost
WORD | remotePort
PTCPSocket * | passiveSocket
char | type
char | structure
char | mode
PString | userName
int | illegalPasswordCount

## Detailed Description

File Transfer Protocol server channel class.

## Member Enumeration Documentation

anonymous enum

Enumerator:

  MaxIllegalPasswords |

anonymous enum`[protected]`

Enumerator:

  NotConnected |
  NeedUser |
  NeedPassword |
  Connected |
  ClientConnect |

## Constructor & Destructor Documentation

PFTPServer::PFTPServer | ( |  | ) |

declare a server socket

PFTPServer::PFTPServer | ( | const PString & | readyString | ) |

Parameters:

  readyString | Sign on string on connection ready.

PFTPServer::~PFTPServer | ( |  | ) |

Delete the server, cleaning up passive sockets.

## Member Function Documentation

virtual PBoolean PFTPServer::AuthoriseUser | ( | const PString & | user,
|  | const PString & | password,
|  | PBoolean & | replied |
| ) |  |  | `[virtual]`

Validate the user name and password for access.

After three invalid attempts, the socket will close and false is returned.

Default implementation returns true for all strings.

Returns:
  true if user can access, otherwise false

Parameters:

  user | User name to authorise.
  password | Password supplied for the user.
  replied | Indication that a reply was sent to client.

virtual PBoolean PFTPServer::CheckLoginRequired | ( | PINDEX | cmd | ) | `[virtual]`

Check to see if the command requires the server to be logged in before it may be processed.

Returns:
  true if the command required the user to be logged in.

Parameters:

  cmd | Command to check if log in required.

void PFTPServer::Construct | ( |  | ) | `[protected]`

Reimplemented from PChannel.

virtual PBoolean PFTPServer::DispatchCommand | ( | PINDEX | code,
|  | const PString & | args |
| ) |  |  | `[virtual]`

Dispatching to the appropriate virtual function.

This is used when the socket is acting as a server.

Returns:
  true if more processing may be done, false if the QUIT command was received or the `OnUnknown()` function returns false.

Parameters:

  code | Parsed command code.
  args | Arguments to command.

PBoolean PFTPServer::GetAllowThirdPartyPort | ( |  | ) | const`[inline]`

return the thirdPartyPort flag, allowing 3 host put and get.

virtual PString PFTPServer::GetGoodbyeString | ( | const PString & | user | ) | const`[virtual]`

return the string printed just before exiting

virtual PString PFTPServer::GetHelloString | ( | const PString & | user | ) | const`[virtual]`

Get the string printed when a user logs in default value is a string giving the user name.

virtual PString PFTPServer::GetSystemTypeString | ( |  | ) | const`[virtual]`

return the string to be returned by the SYST command

virtual PBoolean PFTPServer::OnABOR | ( | const PCaselessString & | args | ) | `[virtual]`

virtual PBoolean PFTPServer::OnACCT | ( | const PCaselessString & | args | ) | `[virtual]`

virtual PBoolean PFTPServer::OnALLO | ( | const PCaselessString & | args | ) | `[virtual]`

virtual PBoolean PFTPServer::OnAPPE | ( | const PCaselessString & | args | ) | `[virtual]`

virtual PBoolean PFTPServer::OnCDUP | ( | const PCaselessString & | args | ) | `[virtual]`

virtual void PFTPServer::OnCommandSuccessful | ( | PINDEX | cmdNum | ) | `[virtual]`

Called for successful commands.

Parameters:

  cmdNum | Command that had was successful.

virtual PBoolean PFTPServer::OnCWD | ( | const PCaselessString & | args | ) | `[virtual]`

virtual PBoolean PFTPServer::OnDELE | ( | const PCaselessString & | args | ) | `[virtual]`

virtual void PFTPServer::OnError | ( | PINDEX | errorCode,
|  | PINDEX | cmdNum,
|  | const char * | msg |
| ) |  |  | `[virtual]`

Handle an error in command.

Returns:
  true if more processing may be done, false if the `ProcessCommand()` function is to return false.

Parameters:

  errorCode | Error code to use
  cmdNum | Command that had the error.
  msg | Error message.

virtual PBoolean PFTPServer::OnHELP | ( | const PCaselessString & | args | ) | `[virtual]`

virtual PBoolean PFTPServer::OnLIST | ( | const PCaselessString & | args | ) | `[virtual]`

virtual PBoolean PFTPServer::OnMKD | ( | const PCaselessString & | args | ) | `[virtual]`

virtual PBoolean PFTPServer::OnMODE | ( | const PCaselessString & | args | ) | `[virtual]`

virtual PBoolean PFTPServer::OnNLST | ( | const PCaselessString & | args | ) | `[virtual]`

virtual PBoolean PFTPServer::OnNOOP | ( | const PCaselessString & | args | ) | `[virtual]`

virtual void PFTPServer::OnNotImplemented | ( | PINDEX | cmdNum | ) | `[virtual]`

Called for unimplemented commands.

Parameters:

  cmdNum | Command that was not implemented.

PBoolean PFTPServer::OnOpen | ( |  | ) | `[protected, virtual]`

Call back to verify open succeeded in an PInternetProtocol class.

Reimplemented from PIndirectChannel.

virtual PBoolean PFTPServer::OnPASS | ( | const PCaselessString & | args | ) | `[virtual]`

virtual PBoolean PFTPServer::OnPASV | ( | const PCaselessString & | args | ) | `[virtual]`

virtual PBoolean PFTPServer::OnPORT | ( | const PCaselessString & | args | ) | `[virtual]`

virtual PBoolean PFTPServer::OnPWD | ( | const PCaselessString & | args | ) | `[virtual]`

virtual PBoolean PFTPServer::OnQUIT | ( | const PCaselessString & | args | ) | `[virtual]`

virtual PBoolean PFTPServer::OnREIN | ( | const PCaselessString & | args | ) | `[virtual]`

virtual PBoolean PFTPServer::OnREST | ( | const PCaselessString & | args | ) | `[virtual]`

virtual PBoolean PFTPServer::OnRETR | ( | const PCaselessString & | args | ) | `[virtual]`

virtual PBoolean PFTPServer::OnRMD | ( | const PCaselessString & | args | ) | `[virtual]`

virtual PBoolean PFTPServer::OnRNFR | ( | const PCaselessString & | args | ) | `[virtual]`

virtual PBoolean PFTPServer::OnRNTO | ( | const PCaselessString & | args | ) | `[virtual]`

virtual PBoolean PFTPServer::OnSITE | ( | const PCaselessString & | args | ) | `[virtual]`

virtual PBoolean PFTPServer::OnSMNT | ( | const PCaselessString & | args | ) | `[virtual]`

virtual PBoolean PFTPServer::OnSTAT | ( | const PCaselessString & | args | ) | `[virtual]`

virtual PBoolean PFTPServer::OnSTOR | ( | const PCaselessString & | args | ) | `[virtual]`

virtual PBoolean PFTPServer::OnSTOU | ( | const PCaselessString & | args | ) | `[virtual]`

virtual PBoolean PFTPServer::OnSTRU | ( | const PCaselessString & | args | ) | `[virtual]`

virtual void PFTPServer::OnSyntaxError | ( | PINDEX | cmdNum | ) | `[virtual]`

Called for syntax errors in commands.

Parameters:

  cmdNum | Command that had the syntax error.

virtual PBoolean PFTPServer::OnSYST | ( | const PCaselessString & | args | ) | `[virtual]`

virtual PBoolean PFTPServer::OnTYPE | ( | const PCaselessString & | args | ) | `[virtual]`

virtual PBoolean PFTPServer::OnUnknown | ( | const PCaselessString & | command | ) | `[virtual]`

Handle an unknown command.

Returns:
  true if more processing may be done, false if the `ProcessCommand()` function is to return false.

Parameters:

  command | Complete command line received.

virtual PBoolean PFTPServer::OnUSER | ( | const PCaselessString & | args | ) | `[virtual]`

PBoolean PFTPServer::ProcessCommand | ( |  | ) |

Process commands, dispatching to the appropriate virtual function.

This is used when the socket is acting as a server.

Returns:
  true if more processing may be done, false if the QUIT command was received or the `OnUnknown()` function returns false.

void PFTPServer::SendToClient | ( | const PFilePath & | filename | ) |

Send the specified file to the client.

Parameters:

  filename | File name to send.

void PFTPServer::SetAllowThirdPartyPort | ( | PBoolean | state | ) | `[inline]`

Set the thirdPartyPort flag.

## Member Data Documentation

int PFTPServer::illegalPasswordCount `[protected]`

char PFTPServer::mode `[protected]`

PTCPSocket* PFTPServer::passiveSocket `[protected]`

PString PFTPServer::readyString `[protected]`

PIPSocket::Address PFTPServer::remoteHost `[protected]`

WORD PFTPServer::remotePort `[protected]`

enum { ... } PFTPServer::state `[protected]`

char PFTPServer::structure `[protected]`

PBoolean PFTPServer::thirdPartyPort `[protected]`

char PFTPServer::type `[protected]`

PString PFTPServer::userName `[protected]`

The documentation for this class was generated from the following file:

- ftp.h