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