xref: /csrg-svn/usr.bin/tn3270/api/api_exch.h (revision 31493)
1 /*
2  * This file describes the structures passed back and forth
3  * between the API client and API server on a Unix-based
4  * tn3270 implementation.
5  *
6  */
7 
8 /*
9  * The following are the low-level opcodes exchanged between the
10  * two sides.  These are designed to allow for type, sequence number,
11  * and direction checking.
12  *
13  * We enforce conversation flow.  There are three states: CONTENTION,
14  * SEND, and RECEIVE.  Both sides start in CONTENTION.
15  * We never leave RECEIVE state without first reading a TURNAROUND
16  * opcode.  We never leave SEND state without first writing a TURNAROUND
17  * opcode.  This scheme ensures that we always have conversation flowing
18  * in a synchronized direction (or detect an application error), and that
19  * we never hang with both sides trying to read from the "wire".
20  *
21  * State	event			action
22  *
23  * CONTENTION	read request		send TURNAROUND
24  *					read RTS
25  *					enter RECEIVE
26  * CONTENTION	write request		send RTS
27  *					read TURNAROUND
28  *					enter SEND
29  *
30  * RECEIVE	read request		read whatever
31  * RECEIVE	write request		read TURNAROUND
32  *
33  * SEND		read request		send TURNAROUND
34  * SEND		write			write whatever
35  */
36 
37 #define	EXCH_EXCH_COMMAND	0	/* The following is a command */
38 #define	EXCH_EXCH_TURNAROUND	1	/* Your turn to send */
39 #define	EXCH_EXCH_RTS		2	/* Request to send */
40 #define	EXCH_EXCH_TYPE		3	/* The following is a type */
41 
42 struct exch_exch {
43     unsigned char
44 	opcode,			/* COMMAND, TURNAROUND, or TYPE */
45 	my_sequence,		/* 0-ff, initially zero */
46 	your_sequence,		/* 0-ff, initially zero */
47 	command_or_type;	/* Application level command or type */
48     unsigned short
49 	length;			/* The length of any following data */
50 };
51 
52 /*
53  * The following are the command codes which the higher level protocols
54  * send and receive.
55  */
56 
57 #define	EXCH_CMD_ASSOCIATE	0	/* Connect [client->server] */
58 #define	EXCH_CMD_DISASSOCIATE	1	/* Disconnect [client->server] */
59 #define	EXCH_CMD_SEND_AUTH	2	/* Send password [server->client] */
60 	/*
61 	 * struct storeage_desc
62 	 * char prompt[]
63 	 * struct storeage_desc
64 	 * char seed[]
65 	 */
66 #define	EXCH_CMD_AUTH		3	/* Authorization [client->server] */
67 	/*
68 	 * struct storeage_desc
69 	 * char authenticator[]
70 	 */
71 #define	EXCH_CMD_ASSOCIATED	4	/* Connected [server->client] */
72 #define	EXCH_CMD_REJECTED	5	/* Too bad [server->client] */
73 	/*
74 	 * struct storeage_desc
75 	 * char message[]
76 	 */
77 
78 #define	EXCH_CMD_REQUEST	6	/* A request [client->server] */
79 	/* struct regs,
80 	 * struct sregs,
81 	 * struct storage_desc
82 	 * char bytes[]
83 	 */
84 #define	EXCH_CMD_GIMME		7	/* Send storage [server->client] */
85 	/*
86 	 * struct storage_desc
87 	 */
88 #define	EXCH_CMD_HEREIS		8	/* Here is storage [BOTH WAYS] */
89 	/*
90 	 * struct storage_desc
91 	 * char bytes[]
92 	 */
93 #define	EXCH_CMD_REPLY		9	/* End of discussion */
94 	/*
95 	 * struct regs,
96 	 * struct sregs,
97 	 */
98 
99 /*
100  * The following are typed parameters sent across the wire.
101  *
102  * This should be done much more generally, with some form of
103  * XDR or mapped conversation ability.
104  */
105 
106 #define	EXCH_TYPE_REGS		0
107 #define	EXCH_TYPE_SREGS		1
108 #define	EXCH_TYPE_STORE_DESC	2
109 #define	EXCH_TYPE_BYTES		3
110 
111 /*
112  * each parameter that comes over looks like:
113  *
114  *	char			type of following
115  *	short (2 bytes)		length of following (network byte order)
116  *	following
117  */
118 
119 struct storage_descriptor {
120     long	location;	/* In network byte order */
121     short	length;		/* In network byte order */
122 };
123