Expand PMF_FN_* macros.
[netbsd-mini2440.git] / usr.bin / tn3270 / api / api_exch.h
blob5ddbd3debc465c943da4571d45d89e36e5ad4448
1 /* $NetBSD: api_exch.h,v 1.6 2002/06/13 23:41:16 wiz Exp $ */
3 /*-
4 * Copyright (c) 1988 The Regents of the University of California.
5 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
31 * from: @(#)api_exch.h 4.2 (Berkeley) 4/26/91
35 * This file describes the structures passed back and forth
36 * between the API client and API server on a Unix-based
37 * tn3270 implementation.
41 * The following are the low-level opcodes exchanged between the
42 * two sides. These are designed to allow for type, sequence number,
43 * and direction checking.
45 * We enforce conversation flow. There are three states: CONTENTION,
46 * SEND, and RECEIVE. Both sides start in CONTENTION.
47 * We never leave RECEIVE state without first reading a TURNAROUND
48 * opcode. We never leave SEND state without first writing a TURNAROUND
49 * opcode. This scheme ensures that we always have conversation flowing
50 * in a synchronized direction (or detect an application error), and that
51 * we never hang with both sides trying to read from the "wire".
53 * State event action
55 * CONTENTION read request send TURNAROUND
56 * read RTS
57 * enter RECEIVE
58 * CONTENTION write request send RTS
59 * read TURNAROUND
60 * enter SEND
62 * RECEIVE read request read whatever
63 * RECEIVE write request read TURNAROUND
65 * SEND read request send TURNAROUND
66 * SEND write write whatever
69 #define EXCH_EXCH_COMMAND 0 /* The following is a command */
70 #define EXCH_EXCH_TURNAROUND 1 /* Your turn to send */
71 #define EXCH_EXCH_RTS 2 /* Request to send */
72 #define EXCH_EXCH_TYPE 3 /* The following is a type */
74 struct exch_exch {
75 char
76 opcode; /* COMMAND, TURNAROUND, or TYPE */
77 unsigned char
78 my_sequence, /* 0-ff, initially zero */
79 your_sequence, /* 0-ff, initially zero */
80 command_or_type; /* Application level command or type */
81 unsigned short
82 length; /* The length of any following data */
86 * The following are the command codes which the higher level protocols
87 * send and receive.
90 #define EXCH_CMD_ASSOCIATE 0 /* Connect [client->server] */
92 * struct storage_desc
93 * char key[]
95 #define EXCH_CMD_DISASSOCIATE 1 /* Disconnect [client->server] */
96 #define EXCH_CMD_SEND_AUTH 2 /* Send password [server->client] */
98 * struct storage_desc
99 * char prompt[]
100 * struct storage_desc
101 * char seed[]
103 #define EXCH_CMD_AUTH 3 /* Authorization [client->server] */
105 * struct storage_desc
106 * char authenticator[]
108 #define EXCH_CMD_ASSOCIATED 4 /* Connected [server->client] */
109 #define EXCH_CMD_REJECTED 5 /* Too bad [server->client] */
111 * struct storage_desc
112 * char message[]
115 #define EXCH_CMD_REQUEST 6 /* A request [client->server] */
116 /* struct regs,
117 * struct sregs,
118 * struct storage_desc
119 * char bytes[]
121 #define EXCH_CMD_GIMME 7 /* Send storage [server->client] */
123 * struct storage_desc
125 #define EXCH_CMD_HEREIS 8 /* Here is storage [BOTH WAYS] */
127 * struct storage_desc
128 * char bytes[]
130 #define EXCH_CMD_REPLY 9 /* End of discussion */
132 * struct regs,
133 * struct sregs,
137 * The following are typed parameters sent across the wire.
139 * This should be done much more generally, with some form of
140 * XDR or mapped conversation ability.
143 #define EXCH_TYPE_REGS 0
144 #define EXCH_TYPE_SREGS 1
145 #define EXCH_TYPE_STORE_DESC 2
146 #define EXCH_TYPE_BYTES 3
149 * each parameter that comes over looks like:
151 * char type of following
152 * short (2 bytes) length of following (network byte order)
153 * following
156 struct storage_descriptor {
157 long location; /* In network byte order */
158 short length; /* In network byte order */
161 int api_exch_nextcommand(void);
162 int api_exch_incommand(int);
163 int api_exch_outcommand(int);
164 int api_exch_outtype(int, int , const char *);
165 int api_exch_intype(int, int , char *);
166 int api_exch_flush(void);
167 int api_exch_init(int, char *);