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