Draft protocol for slush control messages

A control message consists of the following header:

byte       contents

0          \
1          | magic number
2          |
3          /
4          \ length not including header
5          / 
6          protocol version
7          message type

8+        message body

Message types:

Value   Purpose                            When valid      Direction
--------------------------------------------------------------------
0       Magic                              anytime           C<->S
1       Specify username                   startup           C ->S
2       Request password                   startup           C<- S
3       Specify password                   startup           C ->S
4       Specify environment                startup           C ->S
5       Specify terminal window size       anytime           C ->S
6       End negotiation phase              startup           C<->S
7       Noop                               anytime           C<->S

0 - Magic

This message is used to represent the magic number when it occurs in 
the input stream. The length of the message body must be 0 bytes.

1 - Specify username

This message is sent from the client to the server to specify the name
of the user the client requests to log in as. The message body consists
of the username as a string with no zero termination. The server must
use the message body length specified in the header. The message body
must not be greater than 32 bytes in length.

2 - Request password

This message is sent from the server to the client to inform the client
that a password is required for the login to proceed. The length of the
message body must be 0 bytes.

3 - Specify password

This message is sent from the client to the server to specify the 
password of the user the client requests to log in as. This message 
may only be sent in response to a "Request password" message from the
server. The message body consists of the password as a string with no 
zero termination. The server must use the message body length specified 
in the header. The message body must not be greater than 64 bytes in
length.

4 - Specify environment

This message is sent from the client to the server to specify the 
initial environment of the session. The message body must consists of
one or more environment strings of the form "NAME=VALUE" seperated by
newline characters. The NAME portion of the string must be present. 
The VALUE portion may be absent.

5 - Specify terminal window size

This message is sent from the client to the server to specify the 
new terminal window size of the client. The message body consists of
four unsigned integers of two bytes each. The integers must be sent in
network byte order and represent (in order):

byte   function
0-1    number of rows in window
2-3    number of columns in window
4-5    number of horizontal pixels in window
6-7    number of vertical pixels in window

6 - End negotiation phase

This message is used to represent the magic number when it occurs in 
the input stream. The length of the message body must be 0 bytes.

7 - Noop

This message does nothing. 
