xref: /csrg-svn/usr.bin/tn3270/api/api_exch.h (revision 35418)
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
634888Sbostic  * provided that the above copyright notice and this paragraph are
734888Sbostic  * duplicated in all such forms and that any documentation,
834888Sbostic  * advertising materials, and other materials related to such
934888Sbostic  * distribution and use acknowledge that the software was developed
1034888Sbostic  * by the University of California, Berkeley.  The name of the
1134888Sbostic  * University may not be used to endorse or promote products derived
1234888Sbostic  * from this software without specific prior written permission.
1334888Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
1434888Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
1534888Sbostic  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1633820Sbostic  *
17*35418Sminshall  *	@(#)api_exch.h	3.4 (Berkeley) 08/28/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 {
61*35418Sminshall     char
62*35418Sminshall 	opcode;			/* COMMAND, TURNAROUND, or TYPE */
6331493Sminshall     unsigned char
6431493Sminshall 	my_sequence,		/* 0-ff, initially zero */
6531493Sminshall 	your_sequence,		/* 0-ff, initially zero */
6631493Sminshall 	command_or_type;	/* Application level command or type */
6731493Sminshall     unsigned short
6831493Sminshall 	length;			/* The length of any following data */
6931493Sminshall };
7031493Sminshall 
7131493Sminshall /*
7231493Sminshall  * The following are the command codes which the higher level protocols
7331493Sminshall  * send and receive.
7431493Sminshall  */
7531493Sminshall 
7631493Sminshall #define	EXCH_CMD_ASSOCIATE	0	/* Connect [client->server] */
7731799Sminshall 	/*
7831799Sminshall 	 * struct storage_desc
7931799Sminshall 	 * char key[]
8031799Sminshall 	 */
8131493Sminshall #define	EXCH_CMD_DISASSOCIATE	1	/* Disconnect [client->server] */
8231493Sminshall #define	EXCH_CMD_SEND_AUTH	2	/* Send password [server->client] */
8331461Sminshall 	/*
8431799Sminshall 	 * struct storage_desc
8531461Sminshall 	 * char prompt[]
8631799Sminshall 	 * struct storage_desc
8731461Sminshall 	 * char seed[]
8831461Sminshall 	 */
8931493Sminshall #define	EXCH_CMD_AUTH		3	/* Authorization [client->server] */
9031461Sminshall 	/*
9131799Sminshall 	 * struct storage_desc
9231461Sminshall 	 * char authenticator[]
9331461Sminshall 	 */
9431493Sminshall #define	EXCH_CMD_ASSOCIATED	4	/* Connected [server->client] */
9531493Sminshall #define	EXCH_CMD_REJECTED	5	/* Too bad [server->client] */
9631461Sminshall 	/*
9731799Sminshall 	 * struct storage_desc
9831461Sminshall 	 * char message[]
9931461Sminshall 	 */
10031461Sminshall 
10131493Sminshall #define	EXCH_CMD_REQUEST	6	/* A request [client->server] */
10231461Sminshall 	/* struct regs,
10331461Sminshall 	 * struct sregs,
10431461Sminshall 	 * struct storage_desc
10531461Sminshall 	 * char bytes[]
10631461Sminshall 	 */
10731493Sminshall #define	EXCH_CMD_GIMME		7	/* Send storage [server->client] */
10831461Sminshall 	/*
10931461Sminshall 	 * struct storage_desc
11031461Sminshall 	 */
11131493Sminshall #define	EXCH_CMD_HEREIS		8	/* Here is storage [BOTH WAYS] */
11231461Sminshall 	/*
11331461Sminshall 	 * struct storage_desc
11431461Sminshall 	 * char bytes[]
11531461Sminshall 	 */
11631493Sminshall #define	EXCH_CMD_REPLY		9	/* End of discussion */
11731461Sminshall 	/*
11831461Sminshall 	 * struct regs,
11931461Sminshall 	 * struct sregs,
12031461Sminshall 	 */
12131461Sminshall 
12231493Sminshall /*
12331493Sminshall  * The following are typed parameters sent across the wire.
12431493Sminshall  *
12531493Sminshall  * This should be done much more generally, with some form of
12631493Sminshall  * XDR or mapped conversation ability.
12731493Sminshall  */
12831461Sminshall 
12931493Sminshall #define	EXCH_TYPE_REGS		0
13031493Sminshall #define	EXCH_TYPE_SREGS		1
13131493Sminshall #define	EXCH_TYPE_STORE_DESC	2
13231493Sminshall #define	EXCH_TYPE_BYTES		3
13331493Sminshall 
13431461Sminshall /*
13531467Sminshall  * each parameter that comes over looks like:
13631461Sminshall  *
13731461Sminshall  *	char			type of following
13831461Sminshall  *	short (2 bytes)		length of following (network byte order)
13931461Sminshall  *	following
14031461Sminshall  */
14131461Sminshall 
14231461Sminshall struct storage_descriptor {
14331461Sminshall     long	location;	/* In network byte order */
14431461Sminshall     short	length;		/* In network byte order */
14531461Sminshall };
146