131461Sminshall /* 2*33820Sbostic * Copyright (c) 1988 Regents of the University of California. 3*33820Sbostic * All rights reserved. 4*33820Sbostic * 5*33820Sbostic * Redistribution and use in source and binary forms are permitted 6*33820Sbostic * provided that this notice is preserved and that due credit is given 7*33820Sbostic * to the University of California at Berkeley. The name of the University 8*33820Sbostic * may not be used to endorse or promote products derived from this 9*33820Sbostic * software without specific prior written permission. This software 10*33820Sbostic * is provided ``as is'' without express or implied warranty. 11*33820Sbostic * 12*33820Sbostic * @(#)api_exch.h 3.2 (Berkeley) 03/28/88 13*33820Sbostic */ 14*33820Sbostic 15*33820Sbostic /* 1631461Sminshall * This file describes the structures passed back and forth 1731461Sminshall * between the API client and API server on a Unix-based 1831461Sminshall * tn3270 implementation. 1931493Sminshall */ 2031493Sminshall 2131493Sminshall /* 2231493Sminshall * The following are the low-level opcodes exchanged between the 2331493Sminshall * two sides. These are designed to allow for type, sequence number, 2431493Sminshall * and direction checking. 2531467Sminshall * 2631493Sminshall * We enforce conversation flow. There are three states: CONTENTION, 2731493Sminshall * SEND, and RECEIVE. Both sides start in CONTENTION. 2831493Sminshall * We never leave RECEIVE state without first reading a TURNAROUND 2931493Sminshall * opcode. We never leave SEND state without first writing a TURNAROUND 3031493Sminshall * opcode. This scheme ensures that we always have conversation flowing 3131493Sminshall * in a synchronized direction (or detect an application error), and that 3231493Sminshall * we never hang with both sides trying to read from the "wire". 3331493Sminshall * 3431493Sminshall * State event action 3531493Sminshall * 3631493Sminshall * CONTENTION read request send TURNAROUND 3731493Sminshall * read RTS 3831493Sminshall * enter RECEIVE 3931493Sminshall * CONTENTION write request send RTS 4031493Sminshall * read TURNAROUND 4131493Sminshall * enter SEND 4231493Sminshall * 4331493Sminshall * RECEIVE read request read whatever 4431493Sminshall * RECEIVE write request read TURNAROUND 4531493Sminshall * 4631493Sminshall * SEND read request send TURNAROUND 4731493Sminshall * SEND write write whatever 4831461Sminshall */ 4931461Sminshall 5031493Sminshall #define EXCH_EXCH_COMMAND 0 /* The following is a command */ 5131493Sminshall #define EXCH_EXCH_TURNAROUND 1 /* Your turn to send */ 5231493Sminshall #define EXCH_EXCH_RTS 2 /* Request to send */ 5331493Sminshall #define EXCH_EXCH_TYPE 3 /* The following is a type */ 5431461Sminshall 5531493Sminshall struct exch_exch { 5631493Sminshall unsigned char 5731493Sminshall opcode, /* COMMAND, TURNAROUND, or TYPE */ 5831493Sminshall my_sequence, /* 0-ff, initially zero */ 5931493Sminshall your_sequence, /* 0-ff, initially zero */ 6031493Sminshall command_or_type; /* Application level command or type */ 6131493Sminshall unsigned short 6231493Sminshall length; /* The length of any following data */ 6331493Sminshall }; 6431493Sminshall 6531493Sminshall /* 6631493Sminshall * The following are the command codes which the higher level protocols 6731493Sminshall * send and receive. 6831493Sminshall */ 6931493Sminshall 7031493Sminshall #define EXCH_CMD_ASSOCIATE 0 /* Connect [client->server] */ 7131799Sminshall /* 7231799Sminshall * struct storage_desc 7331799Sminshall * char key[] 7431799Sminshall */ 7531493Sminshall #define EXCH_CMD_DISASSOCIATE 1 /* Disconnect [client->server] */ 7631493Sminshall #define EXCH_CMD_SEND_AUTH 2 /* Send password [server->client] */ 7731461Sminshall /* 7831799Sminshall * struct storage_desc 7931461Sminshall * char prompt[] 8031799Sminshall * struct storage_desc 8131461Sminshall * char seed[] 8231461Sminshall */ 8331493Sminshall #define EXCH_CMD_AUTH 3 /* Authorization [client->server] */ 8431461Sminshall /* 8531799Sminshall * struct storage_desc 8631461Sminshall * char authenticator[] 8731461Sminshall */ 8831493Sminshall #define EXCH_CMD_ASSOCIATED 4 /* Connected [server->client] */ 8931493Sminshall #define EXCH_CMD_REJECTED 5 /* Too bad [server->client] */ 9031461Sminshall /* 9131799Sminshall * struct storage_desc 9231461Sminshall * char message[] 9331461Sminshall */ 9431461Sminshall 9531493Sminshall #define EXCH_CMD_REQUEST 6 /* A request [client->server] */ 9631461Sminshall /* struct regs, 9731461Sminshall * struct sregs, 9831461Sminshall * struct storage_desc 9931461Sminshall * char bytes[] 10031461Sminshall */ 10131493Sminshall #define EXCH_CMD_GIMME 7 /* Send storage [server->client] */ 10231461Sminshall /* 10331461Sminshall * struct storage_desc 10431461Sminshall */ 10531493Sminshall #define EXCH_CMD_HEREIS 8 /* Here is storage [BOTH WAYS] */ 10631461Sminshall /* 10731461Sminshall * struct storage_desc 10831461Sminshall * char bytes[] 10931461Sminshall */ 11031493Sminshall #define EXCH_CMD_REPLY 9 /* End of discussion */ 11131461Sminshall /* 11231461Sminshall * struct regs, 11331461Sminshall * struct sregs, 11431461Sminshall */ 11531461Sminshall 11631493Sminshall /* 11731493Sminshall * The following are typed parameters sent across the wire. 11831493Sminshall * 11931493Sminshall * This should be done much more generally, with some form of 12031493Sminshall * XDR or mapped conversation ability. 12131493Sminshall */ 12231461Sminshall 12331493Sminshall #define EXCH_TYPE_REGS 0 12431493Sminshall #define EXCH_TYPE_SREGS 1 12531493Sminshall #define EXCH_TYPE_STORE_DESC 2 12631493Sminshall #define EXCH_TYPE_BYTES 3 12731493Sminshall 12831461Sminshall /* 12931467Sminshall * each parameter that comes over looks like: 13031461Sminshall * 13131461Sminshall * char type of following 13231461Sminshall * short (2 bytes) length of following (network byte order) 13331461Sminshall * following 13431461Sminshall */ 13531461Sminshall 13631461Sminshall struct storage_descriptor { 13731461Sminshall long location; /* In network byte order */ 13831461Sminshall short length; /* In network byte order */ 13931461Sminshall }; 140