Oberon || Library || Module Index || Search Engine || Definition || Module

Ulm's Oberon Library:


FTPSessions - framework for the inner core of a FTP server


TYPE Message = POINTER TO MessageRec;
TYPE MessageRec =
         request: FTPRequests.Request;
         response: FTPResponses.Response;
         markEventType: Events.EventType;

TYPE Session = POINTER TO SessionRec; TYPE SessionRec = RECORD (Services.ObjectRec) authorized: BOOLEAN; finished: BOOLEAN; END;

PROCEDURE Create(VAR session: Session); PROCEDURE ProcessRequest(session: Session; request: FTPRequests.Request; markEventType: Events.EventType; VAR response: FTPResponses.Response);


FTPSessions provides a framework for the inner core of a FTP server that processes FTP requests without access to the network connection.

During the initialization phase of a FTP session for a new network connection,

State is maintained by various handlers that were installed by Messages.InstallHandler on base of disciplines, and some public session components:

indicates whether FTP commands beyond FTPCommands.user, FTPCommands.pass, and FTPCommands.acct are to be accepted (initially FALSE).
is initially FALSE, and set to TRUE on encountering the FTPCommands.quit command.

ProcessRequest checks whether request is acceptable at the current state (in dependence of authorized), processes some simple commands itself, and converts all other requests into messages (of type Message) and sends them to session, using Messages.Send. Following commands are implemented by ProcessRequest:

sets the public component finished to TRUE, and returns a 221 return code.
is answered by a 200 return code.
Attempts to re-authorize when authorized is already TRUE are answered with a response code of 230. All commands beyond authorization commands are rejected with 530 as long authorized remains FALSE.

If, after processing of Messages.Send, the response field of the message remains NIL, an error code is returned: either 450 (as indication for temporary failures) if error events were found, or 502 (as indication for an unknown or unsupported command).

Some commands of the FTP protocol request some intermediate responses, called marks, on the command channel as the transfer on the separate channel begins or ends. Marks are to be delivered by raising events of type FTPResponses.Event using markEventType as event type.


persistent object type for incoming requests.
persistent object type for outgoing responses.
general abstraction for message handlers.

Edited by: borchert, last change: 2005/02/09, revision: 1.3, converted to HTML: 2005/02/09

Oberon || Library || Module Index || Search Engine || Definition || Module