xref: /csrg-svn/usr.bin/tn3270/api/api_exch.h (revision 34888)
131461Sminshall /*
233820Sbostic  * Copyright (c) 1988 Regents of the University of California.
333820Sbostic  * All rights reserved.
433820Sbostic  *
533820Sbostic  * Redistribution and use in source and binary forms are permitted
6*34888Sbostic  * provided that the above copyright notice and this paragraph are
7*34888Sbostic  * duplicated in all such forms and that any documentation,
8*34888Sbostic  * advertising materials, and other materials related to such
9*34888Sbostic  * distribution and use acknowledge that the software was developed
10*34888Sbostic  * by the University of California, Berkeley.  The name of the
11*34888Sbostic  * University may not be used to endorse or promote products derived
12*34888Sbostic  * from this software without specific prior written permission.
13*34888Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14*34888Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15*34888Sbostic  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1633820Sbostic  *
17*34888Sbostic  *	@(#)api_exch.h	3.3 (Berkeley) 06/29/88
1833820Sbostic  */
1933820Sbostic 
2033820Sbostic /*
2131461Sminshall  * This file describes the structures passed back and forth
2231461Sminshall  * between the API client and API server on a Unix-based
2331461Sminshall  * tn3270 implementation.
2431493Sminshall  */
2531493Sminshall 
2631493Sminshall /*
2731493Sminshall  * The following are the low-level opcodes exchanged between the
2831493Sminshall  * two sides.  These are designed to allow for type, sequence number,
2931493Sminshall  * and direction checking.
3031467Sminshall  *
3131493Sminshall  * We enforce conversation flow.  There are three states: CONTENTION,
3231493Sminshall  * SEND, and RECEIVE.  Both sides start in CONTENTION.
3331493Sminshall  * We never leave RECEIVE state without first reading a TURNAROUND
3431493Sminshall  * opcode.  We never leave SEND state without first writing a TURNAROUND
3531493Sminshall  * opcode.  This scheme ensures that we always have conversation flowing
3631493Sminshall  * in a synchronized direction (or detect an application error), and that
3731493Sminshall  * we never hang with both sides trying to read from the "wire".
3831493Sminshall  *
3931493Sminshall  * State	event			action
4031493Sminshall  *
4131493Sminshall  * CONTENTION	read request		send TURNAROUND
4231493Sminshall  *					read RTS
4331493Sminshall  *					enter RECEIVE
4431493Sminshall  * CONTENTION	write request		send RTS
4531493Sminshall  *					read TURNAROUND
4631493Sminshall  *					enter SEND
4731493Sminshall  *
4831493Sminshall  * RECEIVE	read request		read whatever
4931493Sminshall  * RECEIVE	write request		read TURNAROUND
5031493Sminshall  *
5131493Sminshall  * SEND		read request		send TURNAROUND
5231493Sminshall  * SEND		write			write whatever
5331461Sminshall  */
5431461Sminshall 
5531493Sminshall #define	EXCH_EXCH_COMMAND	0	/* The following is a command */
5631493Sminshall #define	EXCH_EXCH_TURNAROUND	1	/* Your turn to send */
5731493Sminshall #define	EXCH_EXCH_RTS		2	/* Request to send */
5831493Sminshall #define	EXCH_EXCH_TYPE		3	/* The following is a type */
5931461Sminshall 
6031493Sminshall struct exch_exch {
6131493Sminshall     unsigned char
6231493Sminshall 	opcode,			/* COMMAND, TURNAROUND, or TYPE */
6331493Sminshall 	my_sequence,		/* 0-ff, initially zero */
6431493Sminshall 	your_sequence,		/* 0-ff, initially zero */
6531493Sminshall 	command_or_type;	/* Application level command or type */
6631493Sminshall     unsigned short
6731493Sminshall 	length;			/* The length of any following data */
6831493Sminshall };
6931493Sminshall 
7031493Sminshall /*
7131493Sminshall  * The following are the command codes which the higher level protocols
7231493Sminshall  * send and receive.
7331493Sminshall  */
7431493Sminshall 
7531493Sminshall #define	EXCH_CMD_ASSOCIATE	0	/* Connect [client->server] */
7631799Sminshall 	/*
7731799Sminshall 	 * struct storage_desc
7831799Sminshall 	 * char key[]
7931799Sminshall 	 */
8031493Sminshall #define	EXCH_CMD_DISASSOCIATE	1	/* Disconnect [client->server] */
8131493Sminshall #define	EXCH_CMD_SEND_AUTH	2	/* Send password [server->client] */
8231461Sminshall 	/*
8331799Sminshall 	 * struct storage_desc
8431461Sminshall 	 * char prompt[]
8531799Sminshall 	 * struct storage_desc
8631461Sminshall 	 * char seed[]
8731461Sminshall 	 */
8831493Sminshall #define	EXCH_CMD_AUTH		3	/* Authorization [client->server] */
8931461Sminshall 	/*
9031799Sminshall 	 * struct storage_desc
9131461Sminshall 	 * char authenticator[]
9231461Sminshall 	 */
9331493Sminshall #define	EXCH_CMD_ASSOCIATED	4	/* Connected [server->client] */
9431493Sminshall #define	EXCH_CMD_REJECTED	5	/* Too bad [server->client] */
9531461Sminshall 	/*
9631799Sminshall 	 * struct storage_desc
9731461Sminshall 	 * char message[]
9831461Sminshall 	 */
9931461Sminshall 
10031493Sminshall #define	EXCH_CMD_REQUEST	6	/* A request [client->server] */
10131461Sminshall 	/* struct regs,
10231461Sminshall 	 * struct sregs,
10331461Sminshall 	 * struct storage_desc
10431461Sminshall 	 * char bytes[]
10531461Sminshall 	 */
10631493Sminshall #define	EXCH_CMD_GIMME		7	/* Send storage [server->client] */
10731461Sminshall 	/*
10831461Sminshall 	 * struct storage_desc
10931461Sminshall 	 */
11031493Sminshall #define	EXCH_CMD_HEREIS		8	/* Here is storage [BOTH WAYS] */
11131461Sminshall 	/*
11231461Sminshall 	 * struct storage_desc
11331461Sminshall 	 * char bytes[]
11431461Sminshall 	 */
11531493Sminshall #define	EXCH_CMD_REPLY		9	/* End of discussion */
11631461Sminshall 	/*
11731461Sminshall 	 * struct regs,
11831461Sminshall 	 * struct sregs,
11931461Sminshall 	 */
12031461Sminshall 
12131493Sminshall /*
12231493Sminshall  * The following are typed parameters sent across the wire.
12331493Sminshall  *
12431493Sminshall  * This should be done much more generally, with some form of
12531493Sminshall  * XDR or mapped conversation ability.
12631493Sminshall  */
12731461Sminshall 
12831493Sminshall #define	EXCH_TYPE_REGS		0
12931493Sminshall #define	EXCH_TYPE_SREGS		1
13031493Sminshall #define	EXCH_TYPE_STORE_DESC	2
13131493Sminshall #define	EXCH_TYPE_BYTES		3
13231493Sminshall 
13331461Sminshall /*
13431467Sminshall  * each parameter that comes over looks like:
13531461Sminshall  *
13631461Sminshall  *	char			type of following
13731461Sminshall  *	short (2 bytes)		length of following (network byte order)
13831461Sminshall  *	following
13931461Sminshall  */
14031461Sminshall 
14131461Sminshall struct storage_descriptor {
14231461Sminshall     long	location;	/* In network byte order */
14331461Sminshall     short	length;		/* In network byte order */
14431461Sminshall };
145