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