PTLib  Version 2.10.4
PFTPServer Class Reference

File Transfer Protocol server channel class. More...

#include <ftp.h>

Inheritance diagram for PFTPServer:
PFTP PInternetProtocol PIndirectChannel PChannel PObject

List of all members.

Public Types

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

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
PTCPSocketpassiveSocket
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

declare a server socket

PFTPServer::PFTPServer ( const PString readyString)
Parameters:
readyStringSign on string on connection ready.

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:
userUser name to authorise.
passwordPassword supplied for the user.
repliedIndication 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:
cmdCommand 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:
codeParsed command code.
argsArguments to command.

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

References thirdPartyPort.

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:
cmdNumCommand 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:
errorCodeError code to use
cmdNumCommand that had the error.
msgError 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:
cmdNumCommand 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:
cmdNumCommand 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:
commandComplete command line received.
virtual PBoolean PFTPServer::OnUSER ( const PCaselessString args) [virtual]

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:
filenameFile name to send.
void PFTPServer::SetAllowThirdPartyPort ( PBoolean  state) [inline]

Set the thirdPartyPort flag.

References state, and thirdPartyPort.


Member Data Documentation

char PFTPServer::mode [protected]
WORD PFTPServer::remotePort [protected]
enum { ... } PFTPServer::state [protected]

Referenced by SetAllowThirdPartyPort().

char PFTPServer::structure [protected]
char PFTPServer::type [protected]

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines