xref: /csrg-svn/usr.bin/tn3270/api/api_exch.h (revision 31799)
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  *
631493Sminshall  */
731493Sminshall 
831493Sminshall /*
931493Sminshall  * The following are the low-level opcodes exchanged between the
1031493Sminshall  * two sides.  These are designed to allow for type, sequence number,
1131493Sminshall  * and direction checking.
1231467Sminshall  *
1331493Sminshall  * We enforce conversation flow.  There are three states: CONTENTION,
1431493Sminshall  * SEND, and RECEIVE.  Both sides start in CONTENTION.
1531493Sminshall  * We never leave RECEIVE state without first reading a TURNAROUND
1631493Sminshall  * opcode.  We never leave SEND state without first writing a TURNAROUND
1731493Sminshall  * opcode.  This scheme ensures that we always have conversation flowing
1831493Sminshall  * in a synchronized direction (or detect an application error), and that
1931493Sminshall  * we never hang with both sides trying to read from the "wire".
2031493Sminshall  *
2131493Sminshall  * State	event			action
2231493Sminshall  *
2331493Sminshall  * CONTENTION	read request		send TURNAROUND
2431493Sminshall  *					read RTS
2531493Sminshall  *					enter RECEIVE
2631493Sminshall  * CONTENTION	write request		send RTS
2731493Sminshall  *					read TURNAROUND
2831493Sminshall  *					enter SEND
2931493Sminshall  *
3031493Sminshall  * RECEIVE	read request		read whatever
3131493Sminshall  * RECEIVE	write request		read TURNAROUND
3231493Sminshall  *
3331493Sminshall  * SEND		read request		send TURNAROUND
3431493Sminshall  * SEND		write			write whatever
3531461Sminshall  */
3631461Sminshall 
3731493Sminshall #define	EXCH_EXCH_COMMAND	0	/* The following is a command */
3831493Sminshall #define	EXCH_EXCH_TURNAROUND	1	/* Your turn to send */
3931493Sminshall #define	EXCH_EXCH_RTS		2	/* Request to send */
4031493Sminshall #define	EXCH_EXCH_TYPE		3	/* The following is a type */
4131461Sminshall 
4231493Sminshall struct exch_exch {
4331493Sminshall     unsigned char
4431493Sminshall 	opcode,			/* COMMAND, TURNAROUND, or TYPE */
4531493Sminshall 	my_sequence,		/* 0-ff, initially zero */
4631493Sminshall 	your_sequence,		/* 0-ff, initially zero */
4731493Sminshall 	command_or_type;	/* Application level command or type */
4831493Sminshall     unsigned short
4931493Sminshall 	length;			/* The length of any following data */
5031493Sminshall };
5131493Sminshall 
5231493Sminshall /*
5331493Sminshall  * The following are the command codes which the higher level protocols
5431493Sminshall  * send and receive.
5531493Sminshall  */
5631493Sminshall 
5731493Sminshall #define	EXCH_CMD_ASSOCIATE	0	/* Connect [client->server] */
58*31799Sminshall 	/*
59*31799Sminshall 	 * struct storage_desc
60*31799Sminshall 	 * char key[]
61*31799Sminshall 	 */
6231493Sminshall #define	EXCH_CMD_DISASSOCIATE	1	/* Disconnect [client->server] */
6331493Sminshall #define	EXCH_CMD_SEND_AUTH	2	/* Send password [server->client] */
6431461Sminshall 	/*
65*31799Sminshall 	 * struct storage_desc
6631461Sminshall 	 * char prompt[]
67*31799Sminshall 	 * struct storage_desc
6831461Sminshall 	 * char seed[]
6931461Sminshall 	 */
7031493Sminshall #define	EXCH_CMD_AUTH		3	/* Authorization [client->server] */
7131461Sminshall 	/*
72*31799Sminshall 	 * struct storage_desc
7331461Sminshall 	 * char authenticator[]
7431461Sminshall 	 */
7531493Sminshall #define	EXCH_CMD_ASSOCIATED	4	/* Connected [server->client] */
7631493Sminshall #define	EXCH_CMD_REJECTED	5	/* Too bad [server->client] */
7731461Sminshall 	/*
78*31799Sminshall 	 * struct storage_desc
7931461Sminshall 	 * char message[]
8031461Sminshall 	 */
8131461Sminshall 
8231493Sminshall #define	EXCH_CMD_REQUEST	6	/* A request [client->server] */
8331461Sminshall 	/* struct regs,
8431461Sminshall 	 * struct sregs,
8531461Sminshall 	 * struct storage_desc
8631461Sminshall 	 * char bytes[]
8731461Sminshall 	 */
8831493Sminshall #define	EXCH_CMD_GIMME		7	/* Send storage [server->client] */
8931461Sminshall 	/*
9031461Sminshall 	 * struct storage_desc
9131461Sminshall 	 */
9231493Sminshall #define	EXCH_CMD_HEREIS		8	/* Here is storage [BOTH WAYS] */
9331461Sminshall 	/*
9431461Sminshall 	 * struct storage_desc
9531461Sminshall 	 * char bytes[]
9631461Sminshall 	 */
9731493Sminshall #define	EXCH_CMD_REPLY		9	/* End of discussion */
9831461Sminshall 	/*
9931461Sminshall 	 * struct regs,
10031461Sminshall 	 * struct sregs,
10131461Sminshall 	 */
10231461Sminshall 
10331493Sminshall /*
10431493Sminshall  * The following are typed parameters sent across the wire.
10531493Sminshall  *
10631493Sminshall  * This should be done much more generally, with some form of
10731493Sminshall  * XDR or mapped conversation ability.
10831493Sminshall  */
10931461Sminshall 
11031493Sminshall #define	EXCH_TYPE_REGS		0
11131493Sminshall #define	EXCH_TYPE_SREGS		1
11231493Sminshall #define	EXCH_TYPE_STORE_DESC	2
11331493Sminshall #define	EXCH_TYPE_BYTES		3
11431493Sminshall 
11531461Sminshall /*
11631467Sminshall  * each parameter that comes over looks like:
11731461Sminshall  *
11831461Sminshall  *	char			type of following
11931461Sminshall  *	short (2 bytes)		length of following (network byte order)
12031461Sminshall  *	following
12131461Sminshall  */
12231461Sminshall 
12331461Sminshall struct storage_descriptor {
12431461Sminshall     long	location;	/* In network byte order */
12531461Sminshall     short	length;		/* In network byte order */
12631461Sminshall };
127