148754Sbostic /*- 2*62317Sbostic * Copyright (c) 1988, 1993 3*62317Sbostic * The Regents of the University of California. All rights reserved. 433820Sbostic * 548754Sbostic * %sccs.include.redist.c% 633820Sbostic * 7*62317Sbostic * @(#)api_exch.h 8.1 (Berkeley) 06/06/93 833820Sbostic */ 933820Sbostic 1033820Sbostic /* 1131461Sminshall * This file describes the structures passed back and forth 1231461Sminshall * between the API client and API server on a Unix-based 1331461Sminshall * tn3270 implementation. 1431493Sminshall */ 1531493Sminshall 1631493Sminshall /* 1731493Sminshall * The following are the low-level opcodes exchanged between the 1831493Sminshall * two sides. These are designed to allow for type, sequence number, 1931493Sminshall * and direction checking. 2031467Sminshall * 2131493Sminshall * We enforce conversation flow. There are three states: CONTENTION, 2231493Sminshall * SEND, and RECEIVE. Both sides start in CONTENTION. 2331493Sminshall * We never leave RECEIVE state without first reading a TURNAROUND 2431493Sminshall * opcode. We never leave SEND state without first writing a TURNAROUND 2531493Sminshall * opcode. This scheme ensures that we always have conversation flowing 2631493Sminshall * in a synchronized direction (or detect an application error), and that 2731493Sminshall * we never hang with both sides trying to read from the "wire". 2831493Sminshall * 2931493Sminshall * State event action 3031493Sminshall * 3131493Sminshall * CONTENTION read request send TURNAROUND 3231493Sminshall * read RTS 3331493Sminshall * enter RECEIVE 3431493Sminshall * CONTENTION write request send RTS 3531493Sminshall * read TURNAROUND 3631493Sminshall * enter SEND 3731493Sminshall * 3831493Sminshall * RECEIVE read request read whatever 3931493Sminshall * RECEIVE write request read TURNAROUND 4031493Sminshall * 4131493Sminshall * SEND read request send TURNAROUND 4231493Sminshall * SEND write write whatever 4331461Sminshall */ 4431461Sminshall 4531493Sminshall #define EXCH_EXCH_COMMAND 0 /* The following is a command */ 4631493Sminshall #define EXCH_EXCH_TURNAROUND 1 /* Your turn to send */ 4731493Sminshall #define EXCH_EXCH_RTS 2 /* Request to send */ 4831493Sminshall #define EXCH_EXCH_TYPE 3 /* The following is a type */ 4931461Sminshall 5031493Sminshall struct exch_exch { 5135418Sminshall char 5235418Sminshall opcode; /* COMMAND, TURNAROUND, or TYPE */ 5331493Sminshall unsigned char 5431493Sminshall my_sequence, /* 0-ff, initially zero */ 5531493Sminshall your_sequence, /* 0-ff, initially zero */ 5631493Sminshall command_or_type; /* Application level command or type */ 5731493Sminshall unsigned short 5831493Sminshall length; /* The length of any following data */ 5931493Sminshall }; 6031493Sminshall 6131493Sminshall /* 6231493Sminshall * The following are the command codes which the higher level protocols 6331493Sminshall * send and receive. 6431493Sminshall */ 6531493Sminshall 6631493Sminshall #define EXCH_CMD_ASSOCIATE 0 /* Connect [client->server] */ 6731799Sminshall /* 6831799Sminshall * struct storage_desc 6931799Sminshall * char key[] 7031799Sminshall */ 7131493Sminshall #define EXCH_CMD_DISASSOCIATE 1 /* Disconnect [client->server] */ 7231493Sminshall #define EXCH_CMD_SEND_AUTH 2 /* Send password [server->client] */ 7331461Sminshall /* 7431799Sminshall * struct storage_desc 7531461Sminshall * char prompt[] 7631799Sminshall * struct storage_desc 7731461Sminshall * char seed[] 7831461Sminshall */ 7931493Sminshall #define EXCH_CMD_AUTH 3 /* Authorization [client->server] */ 8031461Sminshall /* 8131799Sminshall * struct storage_desc 8231461Sminshall * char authenticator[] 8331461Sminshall */ 8431493Sminshall #define EXCH_CMD_ASSOCIATED 4 /* Connected [server->client] */ 8531493Sminshall #define EXCH_CMD_REJECTED 5 /* Too bad [server->client] */ 8631461Sminshall /* 8731799Sminshall * struct storage_desc 8831461Sminshall * char message[] 8931461Sminshall */ 9031461Sminshall 9131493Sminshall #define EXCH_CMD_REQUEST 6 /* A request [client->server] */ 9231461Sminshall /* struct regs, 9331461Sminshall * struct sregs, 9431461Sminshall * struct storage_desc 9531461Sminshall * char bytes[] 9631461Sminshall */ 9731493Sminshall #define EXCH_CMD_GIMME 7 /* Send storage [server->client] */ 9831461Sminshall /* 9931461Sminshall * struct storage_desc 10031461Sminshall */ 10131493Sminshall #define EXCH_CMD_HEREIS 8 /* Here is storage [BOTH WAYS] */ 10231461Sminshall /* 10331461Sminshall * struct storage_desc 10431461Sminshall * char bytes[] 10531461Sminshall */ 10631493Sminshall #define EXCH_CMD_REPLY 9 /* End of discussion */ 10731461Sminshall /* 10831461Sminshall * struct regs, 10931461Sminshall * struct sregs, 11031461Sminshall */ 11131461Sminshall 11231493Sminshall /* 11331493Sminshall * The following are typed parameters sent across the wire. 11431493Sminshall * 11531493Sminshall * This should be done much more generally, with some form of 11631493Sminshall * XDR or mapped conversation ability. 11731493Sminshall */ 11831461Sminshall 11931493Sminshall #define EXCH_TYPE_REGS 0 12031493Sminshall #define EXCH_TYPE_SREGS 1 12131493Sminshall #define EXCH_TYPE_STORE_DESC 2 12231493Sminshall #define EXCH_TYPE_BYTES 3 12331493Sminshall 12431461Sminshall /* 12531467Sminshall * each parameter that comes over looks like: 12631461Sminshall * 12731461Sminshall * char type of following 12831461Sminshall * short (2 bytes) length of following (network byte order) 12931461Sminshall * following 13031461Sminshall */ 13131461Sminshall 13231461Sminshall struct storage_descriptor { 13331461Sminshall long location; /* In network byte order */ 13431461Sminshall short length; /* In network byte order */ 13531461Sminshall }; 136