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