Release 4.1
[unix-history] / usr / src / usr.bin / tn3270 / api / api_exch.h
CommitLineData
f6e43951
KB
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
b36fc510
KB
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.
f6e43951 16 *
d43d1075 17 * @(#)api_exch.h 4.1 (Berkeley) %G%
f6e43951
KB
18 */
19
9ceed847
GM
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.
d024bcc4
GM
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".
62946391 38 *
d024bcc4
GM
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
9ceed847
GM
53 */
54
d024bcc4
GM
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
60struct exch_exch {
db693c34
GM
61 char
62 opcode; /* COMMAND, TURNAROUND, or TYPE */
d024bcc4 63 unsigned char
d024bcc4
GM
64 my_sequence, /* 0-ff, initially zero */
65 your_sequence, /* 0-ff, initially zero */
66 command_or_type; /* Application level command or type */
67 unsigned short
68 length; /* The length of any following data */
69};
70
71/*
72 * The following are the command codes which the higher level protocols
73 * send and receive.
74 */
9ceed847 75
d024bcc4 76#define EXCH_CMD_ASSOCIATE 0 /* Connect [client->server] */
fbda6d30
GM
77 /*
78 * struct storage_desc
79 * char key[]
80 */
d024bcc4
GM
81#define EXCH_CMD_DISASSOCIATE 1 /* Disconnect [client->server] */
82#define EXCH_CMD_SEND_AUTH 2 /* Send password [server->client] */
9ceed847 83 /*
fbda6d30 84 * struct storage_desc
9ceed847 85 * char prompt[]
fbda6d30 86 * struct storage_desc
9ceed847
GM
87 * char seed[]
88 */
d024bcc4 89#define EXCH_CMD_AUTH 3 /* Authorization [client->server] */
9ceed847 90 /*
fbda6d30 91 * struct storage_desc
9ceed847
GM
92 * char authenticator[]
93 */
d024bcc4
GM
94#define EXCH_CMD_ASSOCIATED 4 /* Connected [server->client] */
95#define EXCH_CMD_REJECTED 5 /* Too bad [server->client] */
9ceed847 96 /*
fbda6d30 97 * struct storage_desc
9ceed847
GM
98 * char message[]
99 */
100
d024bcc4 101#define EXCH_CMD_REQUEST 6 /* A request [client->server] */
9ceed847
GM
102 /* struct regs,
103 * struct sregs,
104 * struct storage_desc
105 * char bytes[]
106 */
d024bcc4 107#define EXCH_CMD_GIMME 7 /* Send storage [server->client] */
9ceed847
GM
108 /*
109 * struct storage_desc
110 */
d024bcc4 111#define EXCH_CMD_HEREIS 8 /* Here is storage [BOTH WAYS] */
9ceed847
GM
112 /*
113 * struct storage_desc
114 * char bytes[]
115 */
d024bcc4 116#define EXCH_CMD_REPLY 9 /* End of discussion */
9ceed847
GM
117 /*
118 * struct regs,
119 * struct sregs,
120 */
121
d024bcc4
GM
122/*
123 * The following are typed parameters sent across the wire.
124 *
125 * This should be done much more generally, with some form of
126 * XDR or mapped conversation ability.
127 */
128
129#define EXCH_TYPE_REGS 0
130#define EXCH_TYPE_SREGS 1
131#define EXCH_TYPE_STORE_DESC 2
132#define EXCH_TYPE_BYTES 3
9ceed847
GM
133
134/*
62946391 135 * each parameter that comes over looks like:
9ceed847
GM
136 *
137 * char type of following
138 * short (2 bytes) length of following (network byte order)
139 * following
140 */
141
142struct storage_descriptor {
143 long location; /* In network byte order */
144 short length; /* In network byte order */
145};