1 /*
2  * Copyright (c) 1996-2009, 2014 Paul Mattes.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *     * Redistributions of source code must retain the above copyright
8  *       notice, this list of conditions and the following disclaimer.
9  *     * Redistributions in binary form must reproduce the above copyright
10  *       notice, this list of conditions and the following disclaimer in the
11  *       documentation and/or other materials provided with the distribution.
12  *     * Neither the names of Paul Mattes nor the names of his contributors
13  *       may be used to endorse or promote products derived from this software
14  *       without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY PAUL MATTES "AS IS" AND ANY EXPRESS OR IMPLIED
17  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19  * EVENT SHALL PAUL MATTES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 /*
29  *	tn3270e.h
30  *
31  *		Header file for the TN3270E Protocol, RFC 2355.
32  */
33 
34 /* Negotiation operations. */
35 #define TN3270E_OP_ASSOCIATE		0
36 #define TN3270E_OP_CONNECT		1
37 #define TN3270E_OP_DEVICE_TYPE		2
38 #define TN3270E_OP_FUNCTIONS		3
39 #define TN3270E_OP_IS			4
40 #define TN3270E_OP_REASON		5
41 #define TN3270E_OP_REJECT		6
42 #define TN3270E_OP_REQUEST		7
43 #define TN3270E_OP_SEND			8
44 
45 /* Negotiation reason-codes. */
46 #define TN3270E_REASON_CONN_PARTNER	0
47 #define TN3270E_REASON_DEVICE_IN_USE	1
48 #define TN3270E_REASON_INV_ASSOCIATE	2
49 #define TN3270E_REASON_INV_DEVICE_NAME	3
50 #define TN3270E_REASON_INV_DEVICE_TYPE	4
51 #define TN3270E_REASON_TYPE_NAME_ERROR	5
52 #define TN3270E_REASON_UNKNOWN_ERROR	6
53 #define TN3270E_REASON_UNSUPPORTED_REQ	7
54 
55 /* Negotiation function Names. */
56 #define TN3270E_FUNC_BIND_IMAGE		0
57 #define TN3270E_FUNC_DATA_STREAM_CTL	1
58 #define TN3270E_FUNC_RESPONSES		2
59 #define TN3270E_FUNC_SCS_CTL_CODES	3
60 #define TN3270E_FUNC_SYSREQ		4
61 
62 /* Header data type names. */
63 #define TN3270E_DT_3270_DATA		0x00
64 #define TN3270E_DT_SCS_DATA		0x01
65 #define TN3270E_DT_RESPONSE		0x02
66 #define TN3270E_DT_BIND_IMAGE		0x03
67 #define TN3270E_DT_UNBIND		0x04
68 #define TN3270E_DT_NVT_DATA		0x05
69 #define TN3270E_DT_REQUEST		0x06
70 #define TN3270E_DT_SSCP_LU_DATA		0x07
71 #define TN3270E_DT_PRINT_EOJ		0x08
72 
73 /* Header request flags. */
74 #define TN3270E_RQF_ERR_COND_CLEARED	0x00
75 
76 /* Header response flags. */
77 #define TN3270E_RSF_NO_RESPONSE		0x00
78 #define TN3270E_RSF_ERROR_RESPONSE	0x01
79 #define TN3270E_RSF_ALWAYS_RESPONSE	0x02
80 #define TN3270E_RSF_POSITIVE_RESPONSE	0x00
81 #define TN3270E_RSF_NEGATIVE_RESPONSE	0x01
82 
83 /* Header response data. */
84 #define TN3270E_POS_DEVICE_END		0x00
85 #define TN3270E_NEG_COMMAND_REJECT	0x00
86 #define TN3270E_NEG_INTERVENTION_REQUIRED 0x01
87 #define TN3270E_NEG_OPERATION_CHECK	0x02
88 #define TN3270E_NEG_COMPONENT_DISCONNECTED 0x03
89 
90 /* TN3270E data header. */
91 typedef struct {
92     unsigned char data_type;
93     unsigned char request_flag;
94     unsigned char response_flag;
95     unsigned char seq_number[2]; /* actually, 16 bits, unaligned (!) */
96 } tn3270e_header;
97 
98 #define EH_SIZE 5
99 
100 /* UNBIND types. */
101 #define TN3270E_UNBIND_NORMAL		0x01
102 #define TN3270E_UNBIND_BIND_FORTHCOMING	0x02
103 #define TN3270E_UNBIND_VR_INOPERATIVE	0x07
104 #define TN3270E_UNBIND_RX_INOPERATIVE	0x08
105 #define TN3270E_UNBIND_HRESET		0x09
106 #define TN3270E_UNBIND_SSCP_GONE	0x0a
107 #define TN3270E_UNBIND_VR_DEACTIVATED	0x0b
108 #define TN3270E_UNBIND_LU_FAILURE_PERM	0x0c
109 #define TN3270E_UNBIND_LU_FAILURE_TEMP	0x0e
110 #define TN3270E_UNBIND_CLEANUP		0x0f
111 #define TN3270E_UNBIND_BAD_SENSE	0xfe
112