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


Ulm's Oberon Library:
RFC1413Requests


NAME

RFC1413Requests - request identification from RFC 1413 servers

SYNOPSIS

CONST connectFailed = 0;
CONST sendFailed = 1;
CONST gotNoResponse = 2;
CONST invalidResponse = 3;
CONST invalidPort = 4;
CONST noUser = 5;
CONST unknownError = 6;
CONST hiddenUser = 7;
CONST otherError = 8;
CONST timeoutConnect = 9;
CONST timeoutResponse = 10;
CONST errors = 11;
TYPE ErrorCode = SHORTINT;
TYPE ErrorEvent = POINTER TO ErrorEventRec;
TYPE ErrorEventRec =
   RECORD
      (Events.EventRec)
      errorcode: ErrorCode;
      foreignAddress: IPv4Addresses.SocketAddress;
      localAddress: IPv4Addresses.SocketAddress;
      response: ARRAY 512 OF CHAR;
   END;
VAR error: Events.EventType;
VAR errormsg: ARRAY errors OF Events.Message;


PROCEDURE GetIdent(foreignAddress: IPv4Addresses.SocketAddress; localAddress: IPv4Addresses.SocketAddress; timelimit: Times.Time; VAR opsys, charset: ARRAY OF CHAR; VAR ident: ARRAY OF CHAR; VAR errors: RelatedEvents.Object) : BOOLEAN;

DESCRIPTION

RFC1413Requests support client queries to RFC 1413 servers. A query specifies the foreign and local port number of an IPv4 TCP connection and is directed to port 113 at the IP address of the foreign server. If supported by the foreign server and successful, an identification is returned, consisting of an operating system, character set, and a user identification.

GetIdent sends a query to the host specified in foreignAddress using the port numbers out of foreignAddress and localAddress. The timelimit parameter specifies how long GetIdent will wait until it gives up. NIL may be passed to timelimit. In this case, a default value of 5 seconds is taken.

A successful response from an RFC 1413 server includes three fields: the specification of an operating system (e.g. ``UNIX''), a character set (e.g. ``US-ASCII''), and an identification string which is represented in the character set specified by charset.

In case of failures, FALSE is returned, and error events are made available through errors.

DIAGNOSTICS

Following error codes are generated by RFC1413Requests beside the error events returned by the underlying modules:
connectFailed
The connect operation to the remote RFC 1413 server failed. Most likely no RFC 1413 server is running on the given server.
sendFailed
A connection was successful but it was impossible to send a request.
gotNoResponse
A request was successfully sent but no response was received.
invalidResponse
A request was successfully sent but the response did not conform to the response syntax specified in RFC 1413.
invalidPort
The remote RFC 1413 server complained that either the local or foreign port was improperly specified.
noUser
The remote RFC 1413 server complained that the connection specified by the port pair is not currently in use or currently not owned by an identifiable entity.
unknownError
The remote RFC 1413 returned another unspecified error.
hiddenUser
The remote RFC 1413 server complained that the server was able to identify the user of this port, but the information was not returned at the request of the user.
otherError
The remote RFC 1413 returned a non-standard error message.
timeoutConnect
A timeout occurred during the connection phase. This is most likely due to a firewall that dropped the SYN packet.
timeoutResponse
A timeout occurred while waiting for the response.

EXAMPLE

Following code snippets assume following variables:
VAR
   errors: RelatedEvents.Object;
   port: INTEGER;
   socket: IPv4TCPSockets.Socket;
   s: Streams.Stream;
   local, peer: IPv4Addresses.SocketAddress;
   opsys, charset, ident: ARRAY 65 OF CHAR;
The listening socket is set up as usual. Note that we retrieve the local address by IPv4TCPSockets.GetName:
NEW(errors); RelatedEvents.QueueEvents(errors);
IF ~IPv4TCPSockets.Listen(socket, port, errors) OR
      ~IPv4TCPSockets.GetName(socket, local, errors) THEN
   Conclusions.Conclude(errors, Errors.fatal, "");
END;
In case of an incoming connection we can attempt to retrieve the RFC 1413 information:
IF IPv4TCPSockets.Accept(socket, s, Streams.onebuf, peer) THEN
   IF RFC1413Requests.GetIdent(peer, local, NIL,
	 opsys, charset, ident, errors) THEN
      (* got RFC 1413 identification *)
   ELSE
      (* unable to retrieve RFC 1413 identification *)
   END;
   (* ... *)
END;

SEE ALSO

IPv4Addresses
address types for IPv4 sockets.
IPv4TCPSockets
interfaces IPv4 TCP sockets.

Edited by: borchert, last change: 2005/01/24, revision: 1.1, converted to HTML: 2005/01/24

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