xref: /csrg-svn/usr.bin/tn3270/api/api_exch.h (revision 31493)
131461Sminshall /*
231461Sminshall  * This file describes the structures passed back and forth
331461Sminshall  * between the API client and API server on a Unix-based
431461Sminshall  * tn3270 implementation.
531467Sminshall  *
6*31493Sminshall  */
7*31493Sminshall 
8*31493Sminshall /*
9*31493Sminshall  * The following are the low-level opcodes exchanged between the
10*31493Sminshall  * two sides.  These are designed to allow for type, sequence number,
11*31493Sminshall  * and direction checking.
1231467Sminshall  *
13*31493Sminshall  * We enforce conversation flow.  There are three states: CONTENTION,
14*31493Sminshall  * SEND, and RECEIVE.  Both sides start in CONTENTION.
15*31493Sminshall  * We never leave RECEIVE state without first reading a TURNAROUND
16*31493Sminshall  * opcode.  We never leave SEND state without first writing a TURNAROUND
17*31493Sminshall  * opcode.  This scheme ensures that we always have conversation flowing
18*31493Sminshall  * in a synchronized direction (or detect an application error), and that
19*31493Sminshall  * we never hang with both sides trying to read from the "wire".
20*31493Sminshall  *
21*31493Sminshall  * State	event			action
22*31493Sminshall  *
23*31493Sminshall  * CONTENTION	read request		send TURNAROUND
24*31493Sminshall  *					read RTS
25*31493Sminshall  *					enter RECEIVE
26*31493Sminshall  * CONTENTION	write request		send RTS
27*31493Sminshall  *					read TURNAROUND
28*31493Sminshall  *					enter SEND
29*31493Sminshall  *
30*31493Sminshall  * RECEIVE	read request		read whatever
31*31493Sminshall  * RECEIVE	write request		read TURNAROUND
32*31493Sminshall  *
33*31493Sminshall  * SEND		read request		send TURNAROUND
34*31493Sminshall  * SEND		write			write whatever
3531461Sminshall  */
3631461Sminshall 
37*31493Sminshall #define	EXCH_EXCH_COMMAND	0	/* The following is a command */
38*31493Sminshall #define	EXCH_EXCH_TURNAROUND	1	/* Your turn to send */
39*31493Sminshall #define	EXCH_EXCH_RTS		2	/* Request to send */
40*31493Sminshall #define	EXCH_EXCH_TYPE		3	/* The following is a type */
4131461Sminshall 
42*31493Sminshall struct exch_exch {
43*31493Sminshall     unsigned char
44*31493Sminshall 	opcode,			/* COMMAND, TURNAROUND, or TYPE */
45*31493Sminshall 	my_sequence,		/* 0-ff, initially zero */
46*31493Sminshall 	your_sequence,		/* 0-ff, initially zero */
47*31493Sminshall 	command_or_type;	/* Application level command or type */
48*31493Sminshall     unsigned short
49*31493Sminshall 	length;			/* The length of any following data */
50*31493Sminshall };
51*31493Sminshall 
52*31493Sminshall /*
53*31493Sminshall  * The following are the command codes which the higher level protocols
54*31493Sminshall  * send and receive.
55*31493Sminshall  */
56*31493Sminshall 
57*31493Sminshall #define	EXCH_CMD_ASSOCIATE	0	/* Connect [client->server] */
58*31493Sminshall #define	EXCH_CMD_DISASSOCIATE	1	/* Disconnect [client->server] */
59*31493Sminshall #define	EXCH_CMD_SEND_AUTH	2	/* Send password [server->client] */
6031461Sminshall 	/*
6131461Sminshall 	 * struct storeage_desc
6231461Sminshall 	 * char prompt[]
6331461Sminshall 	 * struct storeage_desc
6431461Sminshall 	 * char seed[]
6531461Sminshall 	 */
66*31493Sminshall #define	EXCH_CMD_AUTH		3	/* Authorization [client->server] */
6731461Sminshall 	/*
6831461Sminshall 	 * struct storeage_desc
6931461Sminshall 	 * char authenticator[]
7031461Sminshall 	 */
71*31493Sminshall #define	EXCH_CMD_ASSOCIATED	4	/* Connected [server->client] */
72*31493Sminshall #define	EXCH_CMD_REJECTED	5	/* Too bad [server->client] */
7331461Sminshall 	/*
7431461Sminshall 	 * struct storeage_desc
7531461Sminshall 	 * char message[]
7631461Sminshall 	 */
7731461Sminshall 
78*31493Sminshall #define	EXCH_CMD_REQUEST	6	/* A request [client->server] */
7931461Sminshall 	/* struct regs,
8031461Sminshall 	 * struct sregs,
8131461Sminshall 	 * struct storage_desc
8231461Sminshall 	 * char bytes[]
8331461Sminshall 	 */
84*31493Sminshall #define	EXCH_CMD_GIMME		7	/* Send storage [server->client] */
8531461Sminshall 	/*
8631461Sminshall 	 * struct storage_desc
8731461Sminshall 	 */
88*31493Sminshall #define	EXCH_CMD_HEREIS		8	/* Here is storage [BOTH WAYS] */
8931461Sminshall 	/*
9031461Sminshall 	 * struct storage_desc
9131461Sminshall 	 * char bytes[]
9231461Sminshall 	 */
93*31493Sminshall #define	EXCH_CMD_REPLY		9	/* End of discussion */
9431461Sminshall 	/*
9531461Sminshall 	 * struct regs,
9631461Sminshall 	 * struct sregs,
9731461Sminshall 	 */
9831461Sminshall 
99*31493Sminshall /*
100*31493Sminshall  * The following are typed parameters sent across the wire.
101*31493Sminshall  *
102*31493Sminshall  * This should be done much more generally, with some form of
103*31493Sminshall  * XDR or mapped conversation ability.
104*31493Sminshall  */
10531461Sminshall 
106*31493Sminshall #define	EXCH_TYPE_REGS		0
107*31493Sminshall #define	EXCH_TYPE_SREGS		1
108*31493Sminshall #define	EXCH_TYPE_STORE_DESC	2
109*31493Sminshall #define	EXCH_TYPE_BYTES		3
110*31493Sminshall 
11131461Sminshall /*
11231467Sminshall  * each parameter that comes over looks like:
11331461Sminshall  *
11431461Sminshall  *	char			type of following
11531461Sminshall  *	short (2 bytes)		length of following (network byte order)
11631461Sminshall  *	following
11731461Sminshall  */
11831461Sminshall 
11931461Sminshall struct storage_descriptor {
12031461Sminshall     long	location;	/* In network byte order */
12131461Sminshall     short	length;		/* In network byte order */
12231461Sminshall };
123