External agents

External agents
SchemeStation documentation

1 Introduction

We have implemented some external agents both in order to illustrate the usage of the external agent interface, but also in order to provide more functionality and service to the SCHEMESTATION system as a whole.

The external agent interface is specified in External Agent Interface Specification.

2 The file server

2.1 Introduction

The SCHEMESTATION system includes an object server (Operating system specification). Since the Operating System specification requires the system to be persistent, there has to be some backup mechanism for the objects.

Also, since the compiler has not yet been ported to be a native part of he system, there has to be a way to import bytecode files to the system.

The files system acts as an gateway from the SCHEMESTATION system to the underlying unix file system. The user may access the files inside the domain communicating through the interface agent of the external agents'.

a file from a specified directory or any its subdirectories.

2.2 The protocol between the file server and the interface agent

The indentification string for the file server is "fileserver".

There three requests a client (the interface agent) may send to the server:

The request if followed by the length of the file name (four octets in network byte order) and the filename itself.

The server may reply with any of these return codes:

The return code if followed by the length of the file name (four octets in network byte order) and the filename itself.

3 The TCP server

The identification string of the TCP-server is "tcpserver".

The TCP server gives the SCHEMESTATION the ability to do any kind of TCP communication. Once the server is started, it begins waiting for a command for the interface agent. The interface agent may instruct the server to begin listening for a local TCP port, or to directly connect to a remote port. The result of a listen request is either a success acknowledgement, or an error message.

If a connection occurs to a listened port, or when an explicitly requested remote connection is succesfully opened, the server acknowledges the interface agent with a open-acknowledgement, which includes the port to which the connection was established (either the local port that was listened for, or the remote port, where the connection was requested to), possibly the remote host (if the ack corresponds to a remote open request) and the connection number, with which the interface id is supposed to later address the connection.

The interface agent may thereafter send packets to the open connection giving the connection number, the length of the data and the data itself.

The interface agent receives similar messages when data arrives to the port.

The requests the interface can make are

3.1 TCPLISTEN = 0

Requests the server to begin listening to a port.

Structure of the packet:

{ 0 (one octet), portno (2 octets in network byteorder) }

The reply can be either

{ 0 (one octet), portno (2 octets in network byteorder) }

in succesful case, or

{ 12 (one octet), portno (2 octets in network byteorder) }

if there was an error.

3.2 TCPCLOSE = 1

Requests the server to close the specified connection.

Structure of the packet:

{ 1 (one octet), connr (2 octets in network byteorder) }

The reply can be either

{ 1 (one octet), connr (2 octets in network byteorder) }

in succesful case, or

{ 13 (one octet), connr (2 octets in network byteorder) }

if there was an error.

3.3 TCPDEAF = 2

Requests the server to stop listening to the specified port.

Structure of the packet:

{ 2 (one octet), portno (2 octets in network byteorder) }

The reply can be either

{ 1 (one octet), portno (2 octets in network byteorder) }

in succesful case, or

{ 12 (one octet), portno (2 octets in network byteorder) }

if there was an error.

3.4 TCPSEND = 3

Requests the server to send the attached data to the specified connection.

Structure of the packet:

{ 3 (one octet), portno (2 octets in network byteorder), datalen (4 octets), data}

3.5 TCPREAD = 4

Requests the server to stop listening to the specified port.

Structure of the packet:

{ 2 (one octet), portno (2 octets in network byteorder) }

The reply can be either

{ 1 (one octet), portno (2 octets in network byteorder) }

in succesful case, or

{ 12 (one octet), portno (2 octets in network byteorder) }

if there was an error.

3.6 TCPOPEN = 5

Requests the server to explicitly open a connection to the specified remote destination.

Structure of the packet:

{ 5 (one octet), portno (2 octets in network byteorder), remote host dns name }

The reply can be either

{ 5 (one octet), portno (2 octets in network byteorder), remote host dns name }

in succesful case, or

{ 12 (one octet), portno (2 octets in network byteorder), remote host dns name }

if there was an error.

4 The replies

4.1 TCPREAD = 4

Acknowledges the interface agent of arriverd data.

Structure of the packet:

{ 4(one octet), portno (2 octets in network byteorder), datalen, data }

4.2 TCPOPEN = 5

Either acknowledges the interface of a succesful explicit open or accepted connection to a listened port.

Structure of the packet:

{ 5 (one octet), portno (2 octets in network byteorder), connection number (2 octets), dns name of the remote host)

or

{ 5 (one octet), portno (2 octets in network byteorder), connection number ( 2 octets) }

5 The Gnu Chess server

The identification string for chess server is "chessserver".

The gnu chess external agent makes it possible to play gnu chess through a SCHEMESTATION terminal interface.

The external agent itself is as simple as possible - it merely passes all the data it receives from the controlling interface agent to the gnuchessx program, and all the data it receives from the gnuchessx program to the controlling interface agent.