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 /* 59 * struct storage_desc 60 * char key[] 61 */ 62 #define EXCH_CMD_DISASSOCIATE 1 /* Disconnect [client->server] */ 63 #define EXCH_CMD_SEND_AUTH 2 /* Send password [server->client] */ 64 /* 65 * struct storage_desc 66 * char prompt[] 67 * struct storage_desc 68 * char seed[] 69 */ 70 #define EXCH_CMD_AUTH 3 /* Authorization [client->server] */ 71 /* 72 * struct storage_desc 73 * char authenticator[] 74 */ 75 #define EXCH_CMD_ASSOCIATED 4 /* Connected [server->client] */ 76 #define EXCH_CMD_REJECTED 5 /* Too bad [server->client] */ 77 /* 78 * struct storage_desc 79 * char message[] 80 */ 81 82 #define EXCH_CMD_REQUEST 6 /* A request [client->server] */ 83 /* struct regs, 84 * struct sregs, 85 * struct storage_desc 86 * char bytes[] 87 */ 88 #define EXCH_CMD_GIMME 7 /* Send storage [server->client] */ 89 /* 90 * struct storage_desc 91 */ 92 #define EXCH_CMD_HEREIS 8 /* Here is storage [BOTH WAYS] */ 93 /* 94 * struct storage_desc 95 * char bytes[] 96 */ 97 #define EXCH_CMD_REPLY 9 /* End of discussion */ 98 /* 99 * struct regs, 100 * struct sregs, 101 */ 102 103 /* 104 * The following are typed parameters sent across the wire. 105 * 106 * This should be done much more generally, with some form of 107 * XDR or mapped conversation ability. 108 */ 109 110 #define EXCH_TYPE_REGS 0 111 #define EXCH_TYPE_SREGS 1 112 #define EXCH_TYPE_STORE_DESC 2 113 #define EXCH_TYPE_BYTES 3 114 115 /* 116 * each parameter that comes over looks like: 117 * 118 * char type of following 119 * short (2 bytes) length of following (network byte order) 120 * following 121 */ 122 123 struct storage_descriptor { 124 long location; /* In network byte order */ 125 short length; /* In network byte order */ 126 }; 127