Fix for bug 5422:
[obnox/wireshark/wip.git] / epan / dissectors / packet-tn5250.c
1 /* packet-tn5250.c
2  * Routines for tn5250.packet dissection
3  *
4  * Reference:
5  *  5494 Remote Control Unit - Functions Reference
6  *  Release 3.0 Document Number SC30-3533-04
7  *  Chapters 12, 15, 16
8  *
9  * Copyright 2009, Robert Hogan <robert@roberthogan.net>
10  *
11  * $Id$
12  *
13  * Wireshark - Network traffic analyzer
14  * By Gerald Combs <gerald@wireshark.org>
15  * Copyright 1998 Gerald Combs
16  *
17  *
18  * This program is free software; you can redistribute it and/or
19  * modify it under the terms of the GNU General Public License
20  * as published by the Free Software Foundation; either version 2
21  * of the License, or (at your option) any later version.
22  *
23  * This program is distributed in the hope that it will be useful,
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26  * GNU General Public License for more details.
27  *
28  * You should have received a copy of the GNU General Public License
29  * along with this program; if not, write to the Free Software
30  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
31  *
32  */
33
34
35 #ifdef HAVE_CONFIG_H
36 # include "config.h"
37 #endif
38
39 #include <string.h>
40 #include <glib.h>
41 #include <epan/address.h>
42 #include <epan/conversation.h>
43 #include <epan/packet.h>
44 #include "packet-tn5250.h"
45
46 #include <epan/reassemble.h>
47 #include <epan/strutil.h>
48
49 typedef struct tn5250_conv_info_t {
50   struct tn5250_conv_info_t *next;
51   address outbound_addr;
52   guint32 outbound_port;
53   address inbound_addr;
54   guint32 inbound_port;
55   gint extended;
56 } tn5250_conv_info_t;
57
58 /* 13.4 SNA LU 4 and LU 7 Negative Responses */
59
60 #define NEGATIVE_RESPONSE1 0x081102
61 #define NEGATIVE_RESPONSE2 0x100301
62 #define NEGATIVE_RESPONSE3 0x100501
63 #define NEGATIVE_RESPONSE4 0x100502
64
65 static const value_string vals_tn5250_negative_responses[] = {
66         { 0x08110200,  "The Cancel key of a printer was pressed when it was not in an error state"},
67         { 0x08110201,  "The Cancel key of a printer was pressed when it was in an error state"},
68         { 0x10030101,  "Command that is not valid encountered in data stream"},
69         { 0x10030105,  "Clear unit alternate command not valid"},
70         { 0x10030123,  "Command to enter text mode not valid for the keyboard or country language code used"},
71         { 0x10050103,  "Format table resequencing error on display data stream"},
72         { 0x10050110,  "Structured field length is not valid"},
73         { 0x10050111,  "Structured field class or type is not valid"},
74         { 0x10050112,  "Parameter is not valid in structured field"},
75         { 0x10050113,  "Structured field minor structure length is not valid"},
76         { 0x10050114,  "Parameter is not valid in structured field minor structure"},
77         { 0x1005011B,  "Data stream command is not valid in WP mode"},
78         { 0x1005011C,  "Data stream command is not valid in data processing (DP) mode"},
79         { 0x1005011D,  "Command not allowed on display with unlocked keyboard"},
80         { 0x10050121,  "Premature data stream termination"},
81         { 0x10050122,  "Write to display order row/col address is not valid"},
82         { 0x10050123,  "The address in the Repeat to Address is less than the current workstation screen address"},
83         { 0x10050125,  "Start-of-field order length not valid"},
84         { 0x10050126,  "Start-of-field order address not valid"},
85         { 0x10050127,  "Data in restore not valid"},
86         { 0x10050128,  "Field extends past the end of the display"},
87         { 0x10050129,  "Format table overflow"},
88         { 0x1005012A,  "An attempt was made to write past the end of display"},
89         { 0x1005012B,  "Start-of-header length not valid"},
90         { 0x1005012C,  "Parameter that is not valid is on the ROLL command"},
91         { 0x1005012D,  "Extended attribute type not valid"},
92         { 0x1005012E,  "RAM load parameter not valid"},
93         { 0x1005012F,  "Extended attribute not valid"},
94         { 0x10050130,  "Start-of-field attribute not valid"},
95         { 0x10050131,  "No escape code was found where it was expected"},
96         { 0x10050132,  "WRITE ERROR CODE TO WINDOW command row/col address is not valid"},
97         { 0x10050133,  "WRITE ERROR CODE TO WINDOW command is not valid with the message error line that is in use"},
98         { 0x10050134,  "SAVE PARTIAL SCREEN command was followed by an immediate read or another SAVE type command"},
99         { 0x10050135,  "Continued entry field segment is not valid"},
100         { 0x10050136,  "Word wrap not allowed for this type of entry field"},
101         { 0x10050138,  "An attempt was made to write a scroll bar beyond the last display column"},
102         { 0x10050139,  "The total row/col, slider position (sliderpos), or display row/col on a scroll bar is not valid"},
103         { 0x1005013A,  "At least one selection field choice must be allowed to accept the cursor"},
104         { 0x1005013B,  "An attempt was made to write a selection field choice before column 1 or beyond the last display column"},
105         { 0x1005013C,  "An attempt was made to define too  many selection field choices"},
106         { 0x1005013D,  "An attempt was made to define more than one default selected choice in a single choice selection field"},
107         { 0x1005013E,  "Too many windows defined. 128 windows are allowed."},
108         { 0x10050140,  "Write Data command to non-entry field"},
109         { 0x10050141,  "Too much data or too little data in a Write Data command"},
110         { 0x10050142,  "An attempt was made to write a X'FF' character to the display screen."},
111         { 0x10050148,  "The Fax and Image feature is not supported on this device."},
112         { 0x10050149,  "Data follows an image/fax download command in the data stream and the image/fax download command does not contain the last  of the image data. No other commands are accepted until all the image/fax data has been received."},
113         { 0x1005014C,  "The display is not capable of video delivery."},
114         { 0x1005014D,  "The first 2 bytes of the PC/TV command were not X'E201' or X'E301'."},
115         { 0x1005014F,  "Data stream longer than 16,368 bytes."},
116         { 0x10050180,  "The printer LSID sent in the copy-to-printer data stream from the AS/400 system was not in the SNA session table"},
117         { 0x10050181,  "The LSID sent in the copy-to-printer data stream from the AS/400 system was not a printer LSID"},
118         { 0x10050187,  "Self-check field length (self-check field > 33 bytes) not valid"},
119         { 0x10050188,  "Self-check field control word not valid"},
120         { 0x10050228,  "SCS command not valid"},
121         { 0x10050229,  "SCS parameter not valid"},
122         { 0x1005022A,  "Intelligent Printer Data Stream (IPDS parameter error)"},
123         { 0x10050260,  "IPDS printer's multistatus functions are available"},
124         { 0x00000000, NULL }
125 };
126
127 #define TN5250_ESCAPE  0x04
128 static const value_string vals_tn5250_escape_codes[] = {
129         { 0x04                                                  ,  "ESC"},
130         { 0x00, NULL }
131 };
132
133 /* 15.1 Workstation Data Stream Commands*/
134 #define CLEAR_UNIT                                                              0x40
135 #define CLEAR_UNIT_ALTERNATE                                                    0x20
136 #define CLEAR_FORMAT_TABLE                                                      0x50
137 #define WRITE_TO_DISPLAY                                                        0x11
138 #define WRITE_ERROR_CODE                                                        0x21
139 #define WRITE_ERROR_CODE_TO_WINDOW                                              0x22
140 #define READ_INPUT_FIELDS                                                       0x42
141 #define READ_MDT_FIELDS                                                         0x52
142 #define READ_MDT_ALTERNATE                                                      0x82
143 #define READ_SCREEN                                                             0x62
144 #define READ_SCREEN_WITH_EXTENDED_ATTRIBUTES                                    0x64
145 #define READ_SCREEN_TO_PRINT                                                    0x66
146 #define READ_SCREEN_TO_PRINT_WITH_EXTENDED_ATTRIBUTES                           0x68
147 #define READ_SCREEN_TO_PRINT_WITH_GRIDLINES                                     0x6A
148 #define READ_SCREEN_TO_PRINT_WITH_EXTENDED_ATTRIBUTES_AND_GRIDLINES             0x6C
149 #define READ_IMMEDIATE                                                          0x72
150 #define READ_MODIFIED_IMMEDIATE_ALTERNATE                                       0x83
151 #define SAVE_SCREEN                                                             0x02
152 #define SAVE_PARTIAL_SCREEN                                                     0x03
153 #define RESTORE_SCREEN                                                          0x12
154 #define RESTORE_PARTIAL_SCREEN                                                  0x13
155 #define ROLL                                                                    0x23
156 #define WRITE_STRUCTURED_FIELD                                                  0xF3
157 #define WRITE_SINGLE_STRUCTURED_FIELD                                           0xF4
158 #define COPY_TO_PRINTER                                                         0x16
159
160 static const value_string vals_tn5250_command_codes[] = {
161         { CLEAR_UNIT                                                  ,  "Clear Unit"},
162         { CLEAR_UNIT_ALTERNATE                                        ,  "Clear Unit Alternate"},
163         { CLEAR_FORMAT_TABLE                                          ,  "Clear Format Table"},
164         { WRITE_TO_DISPLAY                                            ,  "Write To Display"},
165         { WRITE_ERROR_CODE                                            ,  "Write Error Code"},
166         { WRITE_ERROR_CODE_TO_WINDOW                                  ,  "Write Error Code To Window"},
167         { READ_INPUT_FIELDS                                           ,  "Read Input Fields"},
168         { READ_MDT_FIELDS                                             ,  "Read Mdt Fields"},
169         { READ_MDT_ALTERNATE                                          ,  "Read Mdt Alternate"},
170         { READ_SCREEN                                                 ,  "Read Screen"},
171         { READ_SCREEN_WITH_EXTENDED_ATTRIBUTES                        ,  "Read Screen With Extended Attributes"},
172         { READ_SCREEN_TO_PRINT                                        ,  "Read Screen To Print"},
173         { READ_SCREEN_TO_PRINT_WITH_EXTENDED_ATTRIBUTES               ,  "Read Screen To Print With Extended Attributes"},
174         { READ_SCREEN_TO_PRINT_WITH_GRIDLINES                         ,  "Read Screen To Print With Gridlines"},
175         { READ_SCREEN_TO_PRINT_WITH_EXTENDED_ATTRIBUTES_AND_GRIDLINES ,  "Read Screen To Print With Extended Attributes And Gridlines"},
176         { READ_IMMEDIATE                                              ,  "Read Immediate"},
177         { READ_MODIFIED_IMMEDIATE_ALTERNATE                           ,  "Read Modified Immediate Alternate"},
178         { SAVE_SCREEN                                                 ,  "Save Screen"},
179         { SAVE_PARTIAL_SCREEN                                         ,  "Save Partial Screen"},
180         { RESTORE_SCREEN                                              ,  "Restore Screen"},
181         { RESTORE_PARTIAL_SCREEN                                      ,  "Restore Partial Screen"},
182         { ROLL                                                        ,  "Roll"},
183         { WRITE_STRUCTURED_FIELD                                      ,  "Write Structured Field"},
184         { WRITE_SINGLE_STRUCTURED_FIELD                               ,  "Write Single Structured Field"},
185         { COPY_TO_PRINTER                                             ,  "Copy-To-Printer"},
186         { 0x00, NULL }
187 };
188
189 /* 15.4 Clear Unit Alternate*/
190 static const value_string vals_tn5250_cua_parms[] = {
191         { 0x00                                                  ,  "Set screen size to 27 rows by 132 columns"},
192         { 0x80                                                  ,  "Leave the screen size unchanged and do not erase image/fax data from the display memory."},
193         { 0x00, NULL }
194 };
195
196
197 /* 15.6 Order Codes */
198 #define TN5250_SBA        0x11
199 #define TN5250_IC         0x13
200 #define TN5250_MC         0x14
201 #define TN5250_RA         0x02
202 #define TN5250_EA         0x03
203 #define TN5250_SOH        0x01
204 #define TN5250_TD         0x10
205 #define TN5250_WEA        0x12
206 #define TN5250_SF         0x1D
207 #define TN5250_WDSF       0x15
208
209 static const value_string vals_tn5250_order_codes[] = {
210         { TN5250_SBA,  "Set Buffer Address (SBA)"},
211         { TN5250_IC ,  "Insert Cursor (IC)"},
212         { TN5250_MC ,  "Move Cursor (MC)"},
213         { TN5250_RA ,  "Repeat to Address (RA)"},
214         { TN5250_EA ,  "Erase to Address (EA)"},
215         { TN5250_SOH , "Start of Header (SOH)"},
216         { TN5250_TD ,  "Transparent Data (TD)"},
217         { TN5250_WEA,  "Write Extended Attribute Order"},
218         { TN5250_SF ,  "Start Field (SF)"},
219         { TN5250_WDSF, "Write to Display Structured Field (WDSF)"},
220         { 0x00, NULL }
221 };
222
223 /* 15.6.1 WTD Control Code */
224 #define CCBITS                                0xFF
225
226 static const value_string vals_tn5250_wtd_cc_byteone[] = {
227         { 0x00  ,  ""},
228         { 0x20  ,  "Reset pending AID, lock keyboard"},
229         { 0x40  ,  "Reset pending AID, lock keyboard, Reset MDT flags in non-bypass fields"},
230         { 0x60  ,  "Reset pending AID, lock keyboard, Reset MDT flags in all fields"},
231         { 0x80  ,  "Reset pending AID, lock keyboard, Null all non-bypass fields with  MDT on"},
232         { 0xA0  ,  "Reset pending AID, lock keyboard, Reset MDT flags in non-bypass fields, Null all non-bypass fields"},
233         { 0xC0  ,  "Reset pending AID, lock keyboard, Reset MDT flags in non-bypass fields, Null all non-bypass fields with MDT on"},
234         { 0xE0  ,  "Reset pending AID, lock keyboard, Reset MDT flags in all fields, Null all non-bypass fields"},
235         { 0x00, NULL }
236 };
237
238 /* 15.6.8 Erase to Address Order */
239 /* 15.6.11 Write Extended Attribute Order */
240 #define EXTENDED_IDEOGRAPHIC_ATTRIBUTES          0x05
241 #define EXTENDED_FOREGROUND_COLOR_ATTRIBUTES     0x03
242 #define EXTENDED_PRIMARY_ATTRIBUTES              0x01
243
244 static const value_string vals_tn5250_attributes[] = {
245         { 0x00,  "Display screen"},
246         { 0x01,  "Extended primary attributes"},
247         { 0x02,  "Extended text attributes (use in WP mode only)"},
248         { 0x03,  "Extended foreground color attributes"},
249         { 0x05,  "Extended ideographic attributes"},
250         { 0xFF,  "Display screen and all extended attribute types supported by this "
251                                                                       "workstation. Use X'FF' to clear all extended attribute types for "
252                                                                       "optimum performance, even if all types are not used."},
253         { 0x00, NULL }
254 };
255
256
257 /* 15.6.11.1 Write Extended Attribute Order - Extended Primary Attribute*/
258 /* 15.6.12.3 Start of Field Order - Field Attribute*/
259 #define FA_ID      0x20
260 #define FA_ID_BITS 0xE0
261 static const value_string vals_tn5250_fa_id[] = {
262         { 0x01       ,  "Identifies Field as Field Format Word"},
263         { 0x00, NULL }
264 };
265
266 static const struct true_false_string tn5250_field_attr_col = {
267         "Column Separator On",
268         "Column Separator Off"
269 };
270
271 static const struct true_false_string tn5250_field_attr_blink = {
272         "Blink Field",
273         "Do Not Blink Field"
274 };
275
276 static const struct true_false_string tn5250_field_attr_und = {
277         "Underscore Field",
278         "Do Not Underscore Field"
279 };
280
281 static const struct true_false_string tn5250_field_attr_int = {
282         "High Intensity",
283         "Low Intensity"
284 };
285
286 static const struct true_false_string tn5250_field_attr_rev = {
287         "Reverse Image",
288         "Normal Image"
289 };
290
291
292 /* 15.6.11.2 Write Extended Attribute Order - Valid Extended Foreground Color Attributes*/
293
294 static const value_string vals_tn5250_foreground_color_attributes[] = {
295         { 0x00,  "Null - continue currently defined attribute"},
296         { 0x80,  "Color of the display background medium; black on most models"},
297         { 0x81 ,  "Color of the display background medium; black on most models"},
298         { 0x82,  "blue"},
299         { 0x83,  "blue; different shade of blue than X'82' on some displays"},
300         { 0x84,  "green"},
301         { 0x85,  "green; different shade of green than X'84' on some displays"},
302         { 0x86,  "turquoise"},
303         { 0x87,  "turquoise; different shade of turquoise than X'86' on some displays"},
304         { 0x88,  "red"},
305         { 0x89,  "red; different shade of red than X'88' on some displays"},
306         { 0x8A,  "pink"},
307         { 0x8B,  "pink; different shade of pink than X'8A' on some displays"},
308         { 0x8C,  "yellow"},
309         { 0x8D,  "yellow; different shade of pink than X'8C' on some displays"},
310         { 0x8E,  "white"},
311         { 0x8F,  "white; different shade of white than X'8E' on some displays"},
312         { 0x00, NULL }
313 };
314
315
316 /* 15.6.11.3 Write Extended Attribute Order - Valid Extended Ideographic Attributes*/
317 static const value_string vals_tn5250_ideographic_attributes[] = {
318         { 0x00,  "Null - continue currently defined attribute"},
319         { 0x80,  "Normal display attribute - end double byte mode (SI)"},
320         { 0x81,  "Begin double byte mode (SO)"},
321         { 0x00, NULL }
322 };
323
324 /* 15.6.12.1 Start of Field Order - Field Format Word */
325 #define FFW_ID      0x40
326 #define FFW_ID_BITS 0xC0
327 static const value_string vals_tn5250_ffw_id[] = {
328         { 0x01       ,  "Identifies Field as Field Format Word"},
329         { 0x00, NULL }
330 };
331
332 static const struct true_false_string tn5250_field_ffw_bypass = {
333         "This is a bypass field",
334         "This is not a bypass field"
335 };
336
337 static const struct true_false_string tn5250_field_ffw_dup = {
338         "Duplication or Field Mark is allowed in this field",
339         "Duplication or Field Mark is not allowed in this field"
340 };
341
342 static const struct true_false_string tn5250_field_ffw_mdt = {
343         "This field has been modified",
344         "This field has not been modified"
345 };
346
347 #define FFW_SHIFT_BITS                        0x07
348
349 static const value_string vals_tn5250_ffw_shift[] = {
350         { 0x00,  "Alpha shift"},
351         { 0x01,  "Alpha only"},
352         { 0x02,  "Numeric shift"},
353         { 0x03,  "Numeric only"},
354         { 0x04,  "Katakana shift"},
355         { 0x05,  "Digits only"},
356         { 0x06,  "I/O-(feature input field)"},
357         { 0x07,  "Signed numeric"},
358         { 0x00, NULL }
359 };
360
361 static const struct true_false_string tn5250_field_ffw_auto = {
362         "Auto Enter When Field is Exited",
363         "No Auto Enter"
364 };
365
366 static const struct true_false_string tn5250_field_ffw_fer = {
367         "Field Exit key is required",
368         "Field Exit key is not required"
369 };
370
371 static const struct true_false_string tn5250_field_ffw_monocase = {
372         "Translate operator keyed letters to uppercase",
373         "Accept lower case letters"
374 };
375
376 static const struct true_false_string tn5250_field_ffw_me = {
377         "Mandatory Enter Field",
378         "Not A Mandatory Enter Field"
379 };
380
381 #define FFW_ADJUST_BITS                0x07
382
383 static const value_string vals_tn5250_ffw_adjust[] = {
384         { 0x00,  "No adjust specified"},
385         { 0x01,  "Reserved"},
386         { 0x02,  "Reserved"},
387         { 0x03,  "Reserved"},
388         { 0x04,  "Reserved"},
389         { 0x05,  "Right adjust, zero fill"},
390         { 0x06,  "Right adjust, blank fill"},
391         { 0x07,  "Mandatory fill"},
392         { 0x00, NULL }
393 };
394
395 /* 15.6.12.2 Start of Field Order - Field Control Word */
396
397 #define SELECTOR                                                     0x81
398 #define IDEOGRAPHIC                                                  0x82
399 #define FORWARD_EDGE                                                 0x85
400 #define CONTINUED_ENTRY                                              0x86
401 #define SELF_CHECK                                                   0xB1
402 #define ENTRY_FIELD_RESEQUENCING                                     0x80
403 #define CURSOR_PROGRESSION_ENTRY_FIELD                               0x88
404 #define HIGHLIGHTED_ENTRY_FIELD                                      0x89
405 #define POINTER_DEVICE_SELECTION_ENTRY_FIELD                         0x8A
406 #define TRANSPARENCY_ENTRY_FIELD                                     0x84
407
408 static const range_string vals_tn5250_fcw[] = {
409     { 0x8000,  0x8080, "Entry field resequencing. The nn specifies the next entry field in the sequence (X'00' to X'80')."},
410     { 0x8101,  0x8101, "Magnetic stripe reader entry field"},
411     { 0x8102,  0x8102, "Selector light pen or cursor select field"},
412     { 0x8103,  0x8103, "Magnetic stripe reader and selector light pen entry field"},
413     { 0x8106,  0x8106, "Selector light pen and selectable attention entry field"},
414     { 0x8200,  0x8200, "Ideographic-only entry field"},
415     { 0x8220,  0x8220, "Ideographic data type entry field"},
416     { 0x8240,  0x8240, "Ideographic-either entry field"},
417     { 0x8280,  0x8280, "Ideographic-open entry field"},
418     { 0x82C0,  0x82C0, "Ideographic-open entry field"},
419     { 0x8400,  0x84FF, "Transparency entry field. The nn can be any two digits."},
420     { 0x8501,  0x8501, "Forward edge trigger entry field"},
421     { 0x8601,  0x8603, "Continued entry field"},
422     { 0x8680,  0x8680, "Word Wrap entry field"},
423     { 0x8800,  0x88FF, "Cursor progression entry field. The nn is the next entry field in the specified application cursor progression sequence."},
424     { 0x8900,  0x89FF, "Highlighted entry field. The nn specifies the field attribute"},
425     { 0x8A00,  0x8AFF, "Pointer device selection entry field. If a user selects the entry field, the nn specifies the AID to be returned."},
426     { 0xB140,  0xB140, "Self-check modulus 11 entry field"},
427     { 0xB1A0,  0xB1A0, "Self-check modulus 10 entry field"},
428     { 0,  0,      NULL}
429 };
430
431
432 /*
433
434 #define MAGNETIC_STRIPE_READER_ENTRY_FIELD                           0x8101
435 #define SELECTOR_LIGHT_PEN_OR_CURSOR_SELECT_FIELD                    0x8102
436 #define MAGNETIC_STRIPE_READER_AND_SELECTOR_LIGHT_PEN_ENTRY_FIELD    0x8103
437 #define SELECTOR_LIGHT_PEN_AND_SELECTABLE_ATTENTION_ENTRY_FIELD      0x8106
438 #define IDEOGRAPHIC_ONLY_ENTRY_FIELD                                 0x8200
439 #define IDEOGRAPHIC_DATA_TYPE_ENTRY_FIELD                            0x8220
440 #define IDEOGRAPHIC_EITHER_ENTRY_FIELD                               0x8240
441 #define IDEOGRAPHIC_OPEN_ENTRY_FIELD                                 0x8280
442 #define IDEOGRAPHIC_OPEN_ENTRY_FIELD1                                0x82C0
443 #define FORWARD_EDGE_TRIGGER_ENTRY_FIELD                             0x8501
444 #define CONTINUED_ENTRY_FIELD                                        0x8601
445 #define CONTINUED_ENTRY_FIELD1                                       0x8602
446 #define CONTINUED_ENTRY_FIELD2                                       0x8603
447 #define WORD_WRAP_ENTRY_FIELD                                        0x8680
448 #define SELF_CHECK_MODULUS_11_ENTRY_FIELD                            0xB140
449 #define SELF_CHECK_MODULUS_10_ENTRY_FIELD                            0xB1A0
450
451 static const value_string vals_tn5250_fcw[] = {
452         { ENTRY_FIELD_RESEQUENCING                                 ,  "Entry field resequencing. The NN specifies the next entry field "
453                                                                       "in the sequence (X'00' to X'80')."},
454         { MAGNETIC_STRIPE_READER_ENTRY_FIELD                       ,  "Magnetic stripe reader entry field"},
455         { SELECTOR_LIGHT_PEN_OR_CURSOR_SELECT_FIELD                ,  "Selector light pen or cursor select field"},
456         { MAGNETIC_STRIPE_READER_AND_SELECTOR_LIGHT_PEN_ENTRY_FIELD,  "Magnetic stripe reader and selector light pen entry field"},
457         { SELECTOR_LIGHT_PEN_AND_SELECTABLE_ATTENTION_ENTRY_FIELD  ,  "Selector light pen and selectable attention entry field"},
458         { IDEOGRAPHIC_ONLY_ENTRY_FIELD                             ,  "Ideographic-only entry field"},
459         { IDEOGRAPHIC_DATA_TYPE_ENTRY_FIELD                        ,  "Ideographic data type entry field"},
460         { IDEOGRAPHIC_EITHER_ENTRY_FIELD                           ,  "Ideographic-either entry field"},
461         { IDEOGRAPHIC_OPEN_ENTRY_FIELD                             ,  "Ideographic-open entry field"},
462         { IDEOGRAPHIC_OPEN_ENTRY_FIELD1                            ,  "Ideographic-open entry field"},
463         { TRANSPARENCY_ENTRY_FIELD                                 ,  "Transparency entry field. The NN can be any two digits."},
464         { FORWARD_EDGE_TRIGGER_ENTRY_FIELD                         ,  "Forward edge trigger entry field"},
465         { CONTINUED_ENTRY_FIELD                                    ,  "Continued entry field"},
466         { CONTINUED_ENTRY_FIELD1                                    ,  "Continued entry field"},
467         { CONTINUED_ENTRY_FIELD2                                    ,  "Continued entry field"},
468         { WORD_WRAP_ENTRY_FIELD                                    ,  "Word Wrap entry field"},
469         { CURSOR_PROGRESSION_ENTRY_FIELD                           ,  "Cursor progression entry field. The NN is the next entry field "
470                                                                       "in the specified application cursor progression sequence."},
471         { HIGHLIGHTED_ENTRY_FIELD                                  ,  "Highlighted entry field. The NN specifies the field attribute"},
472         { POINTER_DEVICE_SELECTION_ENTRY_FIELD                     ,  "Pointer device selection entry field. If a user selects the "
473                                                                        "entry field, the NN specifies the AID to be returned."},
474         { SELF_CHECK_MODULUS_11_ENTRY_FIELD                        ,  "Self-check modulus 11 entry field"},
475         { SELF_CHECK_MODULUS_10_ENTRY_FIELD                        ,  "Self-check modulus 10 entry field"},
476         { 0x00, NULL }
477 };
478 */
479 /* 15.6.12.3 Start of Field Order - Field Attribute */
480
481 static const value_string vals_tn5250_fa_color[] = {
482         { 0x20,  "Green"},
483         { 0x21,  "Green/Reverse image"},
484         { 0x22,  "White"},
485         { 0x23,  "White/Reverse image"},
486         { 0x24,  "Green/Underscore"},
487         { 0x25,  "Green/Underscore/Reverse image"},
488         { 0x26,  "White/Underscore"},
489         { 0x27,  "Nondisplay"},
490         { 0x28,  "Red"},
491         { 0x29,  "Red/Reverse image "},
492         { 0x2A,  "Red/Blink"},
493         { 0x2B,  "Red/Reverse image/Blink"},
494         { 0x2C,  "Red/Underscore"},
495         { 0x2D,  "Red/Underscore/Reverse image"},
496         { 0x2E,  "Red/Underscore/Blink"},
497         { 0x2F,  "Nondisplay"},
498         { 0x30,  "Turquoise/Column separators "},
499         { 0x31,  "Turquoise/Column separators/Reverse image"},
500         { 0x32,  "Yellow/Column separators"},
501         { 0x33,  "Yellow/Column separators/Reverse image"},
502         { 0x34,  "Turquoise/Underscore"},
503         { 0x35,  "Turquoise/Underscore/Reverse image"},
504         { 0x36,  "Yellow/Underscore"},
505         { 0x37,  "Nondisplay"},
506         { 0x38,  "Pink"},
507         { 0x39,  "Pink/Reverse image"},
508         { 0x3A,  "Blue"},
509         { 0x3B,  "Blue/Reverse image"},
510         { 0x3C,  "Pink/Underscore"},
511         { 0x3D,  "Pink/Underscore/Reverse image "},
512         { 0x3E,  "Blue/Underscore"},
513         { 0x3F,  "Nondisplay"},
514         { 0x00, NULL }
515 };
516
517 /* 15.6.13  Write to Display Structured Field Order */
518 #define CLASS_5250            0xD9
519
520 static const value_string vals_tn5250_sf_class[] = {
521         { CLASS_5250       ,  "5250 Class of Structured Field"},
522         { 0x00, NULL }
523 };
524
525 /* 15.6.13 - Major Structure Types */
526 #define DEFINE_SELECTION_FIELD                     0x50
527 #define CREATE_WINDOW                              0x51
528 #define UNRESTRICTED_WINDOW_CURSOR_MOVEMENT        0x52
529 #define DEFINE_SCROLL_BAR_FIELD                    0x53
530 #define WRITE_DATA                                 0x54
531 #define PROGRAMMABLE_MOUSE_BUTTONS                 0x55
532 #define REMOVE_GUI_SELECTION_FIELD                 0x58
533 #define REMOVE_GUI_WINDOW                          0x59
534 #define REMOVE_GUI_SCROLL_BAR_FIELD                0x5B
535 #define REMOVE_ALL_GUI_CONSTRUCTS                  0x5F
536 #define DRAW_ERASE_GRID_LINES                      0x60
537 #define CLEAR_GRID_LINE_BUFFER                     0x61
538 #define IMAGE_FAX_CONTROL                          0x66
539 #define IMAGE_FAX_DOWNLOAD                         0x67
540 #define WSC_CUSTOMIZATION                          0x71
541 #define DEFINE_AUDIT_WINDOW__TABLE                 0x30
542 #define DEFINE_COMMAND_KEY_FUNCTION                0x31
543 #define READ_TEXT_SCREEN                           0x32
544 #define DEFINE_PENDING_OPERATIONS                  0x33
545 #define DEFINE_TEXT_SCREEN_FORMAT                  0x34
546 #define DEFINE_SCALE_LINE                          0x35
547 #define WRITE_TEXT_SCREEN                          0x36
548 #define DEFINE_SPECIAL_CHARACTERS                  0x37
549 #define PENDING_DATA                               0x38
550 #define DEFINE_OPERATOR_ERROR_MESSAGES             0x39
551 #define DEFINE_PITCH_TABLE                         0x3A
552 #define DEFINE_FAKE_DP_COMMAND_KEY_FUNCTION        0x3B
553 #define PASS_THROUGH                               0x3F
554 #define TN5250_QUERY                               0x70
555 #define TN5250_QUERY_STATION_STATE                 0x72
556 #define VIDEO_AUDIO_CONTROLS                       0x68
557 #define TRUE_TRANSPARENCY_WRITE                    0x6A
558
559 static const value_string vals_tn5250_sf_type[] = {
560         { DEFINE_SELECTION_FIELD             ,  "Define Selection Field"},
561         { CREATE_WINDOW                      ,  "Create Window"},
562         { UNRESTRICTED_WINDOW_CURSOR_MOVEMENT,  "Unrestricted Window Cursor Movement"},
563         { DEFINE_SCROLL_BAR_FIELD            ,  "Define Scroll Bar Field"},
564         { WRITE_DATA                         ,  "Write Data"},
565         { PROGRAMMABLE_MOUSE_BUTTONS         ,  "Programmable Mouse Buttons"},
566         { REMOVE_GUI_SELECTION_FIELD         ,  "Remove Gui Selection Field"},
567         { REMOVE_GUI_WINDOW                  ,  "Remove Gui Window"},
568         { REMOVE_GUI_SCROLL_BAR_FIELD        ,  "Remove Gui Scroll Bar Field"},
569         { REMOVE_ALL_GUI_CONSTRUCTS          ,  "Remove All Gui Constructs"},
570         { DRAW_ERASE_GRID_LINES              ,  "Draw/Erase Grid Lines"},
571         { CLEAR_GRID_LINE_BUFFER             ,  "Clear Grid Line Buffer"},
572         { IMAGE_FAX_CONTROL                  ,  "Image Fax Control"},
573         { IMAGE_FAX_DOWNLOAD                 ,  "Image Fax Download"},
574         { WSC_CUSTOMIZATION                  ,  "Wsc Customization"},
575         { DEFINE_AUDIT_WINDOW__TABLE         ,  "Define Audit Window Table"},
576         { DEFINE_COMMAND_KEY_FUNCTION        ,  "Define Command Key Function"},
577         { READ_TEXT_SCREEN                   ,  "Read Text Screen"},
578         { DEFINE_PENDING_OPERATIONS          ,  "Define Pending Operations"},
579         { DEFINE_TEXT_SCREEN_FORMAT          ,  "Define Text Screen Format"},
580         { DEFINE_SCALE_LINE                  ,  "Define Scale Line"},
581         { WRITE_TEXT_SCREEN                  ,  "Write Text Screen"},
582         { DEFINE_SPECIAL_CHARACTERS          ,  "Define Special Characters"},
583         { PENDING_DATA                       ,  "Pending Data"},
584         { DEFINE_OPERATOR_ERROR_MESSAGES     ,  "Define Operator Error Messages"},
585         { DEFINE_PITCH_TABLE                 ,  "Define Pitch Table"},
586         { DEFINE_FAKE_DP_COMMAND_KEY_FUNCTION,  "Define Fake Dp Command Key Function"},
587         { PASS_THROUGH                       ,  "Pass-Through"},
588         { TN5250_QUERY                       ,  "5250 Query"},
589         { TN5250_QUERY_STATION_STATE         ,  "5250 Query Station State"},
590         { VIDEO_AUDIO_CONTROLS               ,  "Video/Audio Controls Command"},
591         { TRUE_TRANSPARENCY_WRITE            ,  "True Transparency Write Command"},
592         { 0x00, NULL }
593 };
594
595 /* 15.6.13.1  Write to Display Structured Field Order - Create Window */
596 static const struct true_false_string tn5250_field_wdsf_cw_flag1_1 = {
597         "Cursor Restricted To Window",
598         "Cursor Not Restricted To Window"
599 };
600
601 static const struct true_false_string tn5250_field_wdsf_cw_flag1_2 = {
602         "Window Is A Pull-Down Menu Bar",
603         "Window Is Not A Pull-Down Menu Bar"
604 };
605
606 #define CW_BORDER_PRESENTATION                     0x01
607 #define CW_TITLE_FOOTER                            0x10
608
609 static const value_string vals_tn5250_wdsf_cw_minor_type[] = {
610         { CW_BORDER_PRESENTATION             ,  "Border Presentation"},
611         { CW_TITLE_FOOTER                    ,  "Window Title/Footer"},
612         { 0x00, NULL }
613 };
614
615 /* 15.6.13.1  Write to Display Structured Field Order - Create Window - Border Presentation Minor Structure */
616 static const struct true_false_string tn5250_field_wdsf_cw_bp_flag1_1 = {
617         "Use Border Presentation Characters on a GUI-like NWS",
618         "Do Not Use Border Presentation Characters on a GUI-like NWS"
619 };
620
621 /* 15.6.13.1  Write to Display Structured Field Order - Create Window - Window Title/Footer Minor Structure */
622 #define WTF_BITS         0xC0
623
624 static const value_string vals_tn5250_wdsf_cw_tf_flag_orientation[] = {
625         { 0x00,  "Window Title or Footer is Centered"},
626         { 0x40,  "Window Title or Footer is Right Justified"},
627         { 0x80,  "Window Title or Footer is Left Justified"},
628         { 0xC0,  "Reserved (Window Title or Footer is Centered)"},
629         { 0x00, NULL }
630 };
631
632 static const struct true_false_string tn5250_field_wdsf_cw_tf_flag_1 = {
633         "Window Footer is Defined",
634         "Window Title is Defined"
635 };
636
637
638 /* 15.6.13.4  Write to Display Structured Field Order - Remove All GUI Constructs*/
639 static const struct true_false_string tn5250_field_wdsf_ragc_flag1_0 = {
640         "5494 Maps GUI-like Characters",
641         "5494 Does Not Map GUI-like Characters"
642 };
643
644
645 /* 15.6.13.5  Write to Display Structured Field Order - Define Selection Field*/
646 #define DS_CHOICE_TEXT                 0x10
647 #define DS_MENU_BAR_SEPARATOR          0x09
648 #define DS_CHOICE_PRESENTATION_DISPLAY 0x01
649 #define DS_CHOICE_INDICATORS           0x02
650 #define DS_SCROLLBAR_INDICATORS        0x03
651
652
653 static const value_string vals_tn5250_wdsf_ds_minor_type[] = {
654         { DS_CHOICE_TEXT                ,  "Choice Text"},
655         { DS_MENU_BAR_SEPARATOR         ,  "Menu Bar Separator"},
656         { DS_CHOICE_PRESENTATION_DISPLAY,  "Choice Presentation Display Attributes"},
657         { DS_CHOICE_INDICATORS          ,  "Choice Indicators"},
658         { DS_SCROLLBAR_INDICATORS       ,  "Scroll Bar Indicators"},
659         { 0x00, NULL }
660 };
661
662 #define MOUSE_CHARACTERISTICS_BITS         0x03
663
664 static const value_string vals_tn5250_wdsf_ds_flag1_mouse_characteristics[] = {
665         { 0x00,  "Use this selection field in all cases"},
666         { 0x02,  "Use this selection field only if the display does not have a mouse."},
667         { 0x01,  "Use this selection field only if the display has a mouse."},
668         { 0x03,  "Reserved"},
669         { 0x00, NULL }
670 };
671
672 #define DS_AUTO_ENTER_BITS         0x30
673
674 static const value_string vals_tn5250_wdsf_ds_flag1_auto_enter[] = {
675         { 0x00,  "Selection field is not auto-enter"},
676         { 0x20,  "Selection field is auto-enter on selection except if double-digit numeric selection is used."},
677         { 0x10,  "Selection field is auto-enter on selection or deselection except if double-digit numeric selection is used. "},
678         { 0x30,  "Selection field is auto-enter on selection except if single-digit or double-digit numeric selection is used."},
679         { 0x00, NULL }
680 };
681
682 static const struct true_false_string tn5250_field_wdsf_ds_flag1_1 = {
683         "Auto-Select Enabled",
684         "Auto-Select Not Enabled"
685 };
686
687 static const struct true_false_string tn5250_field_wdsf_ds_flag1_2 = {
688         "Field MDT Enabled",
689         "Field MDT Not Enabled"
690 };
691
692 static const struct true_false_string tn5250_field_wdsf_ds_flag2_1 = {
693         "If set to on, a scroll bar should is created beside the selection field choices, and TotalRows and SliderPos that can "
694         "be scrolled are included in the major structure.",
695         "No Action"
696 };
697
698 static const struct true_false_string tn5250_field_wdsf_ds_flag2_2 = {
699         "If set to on, one blank is added after the numeric separator character.",
700         "No Action"
701 };
702
703 static const struct true_false_string tn5250_field_wdsf_ds_flag2_3 = {
704         "If set to on, an asterisk (*) replaces the first character of an unavailable choice on monochrome display.",
705         "No Action"
706 };
707
708 static const struct true_false_string tn5250_field_wdsf_ds_flag2_4 = {
709         "If set to on, cursor is limited to input-capable positions only.",
710         "No Action"
711 };
712
713 static const struct true_false_string tn5250_field_wdsf_ds_flag2_5 = {
714         "If set to on, the Field Advance/Field Backspace function is like the Character Advance/Character Backspace keys within "
715         "this selection field.",
716         "No Action"
717 };
718
719 static const struct true_false_string tn5250_field_wdsf_ds_flag2_6 = {
720         "If set to on, the cursor movement keys are not allowed to exit this selection field.",
721         "No Action"
722 };
723
724 static const struct true_false_string tn5250_field_wdsf_ds_flag3_1 = {
725         "If set to on, any selected choices are changed to available whenever the keyboard is unlocked.",
726         "No Action"
727 };
728
729 #define MENU_BAR                                                 0x01
730 #define SINGLE_CHOICE_SELECTION_FIELD                            0x11
731 #define MULTIPLE_CHOICE_SELECTION_FIELD                          0x12
732 #define SINGLE_CHOICE_SELECTION_LIST                             0x21
733 #define MULTIPLE_CHOICE_SELECTION_LIST                           0x22
734 #define SINGLE_CHOICE_SELECTION_FIELD_AND_A_PULL_DOWN_LIST       0x31
735 #define MULTIPLE_CHOICE_SELECTION_FIELD_AND_A_PULL_DOWN_LIST     0x32
736 #define PUSH_BUTTONS                                             0x41
737 #define PUSH_BUTTONS_IN_A_PULL_DOWN_MENU_                        0x51
738
739 static const value_string vals_tn5250_wdsf_ds_type[] = {
740         { MENU_BAR                                            ,  "Menu bar"},
741         { SINGLE_CHOICE_SELECTION_FIELD                       ,  "Single choice selection field"},
742         { MULTIPLE_CHOICE_SELECTION_FIELD                     ,  "Multiple choice selection field"},
743         { SINGLE_CHOICE_SELECTION_LIST                        ,  "Single choice selection list"},
744         { MULTIPLE_CHOICE_SELECTION_LIST                      ,  "Multiple choice selection list"},
745         { SINGLE_CHOICE_SELECTION_FIELD_AND_A_PULL_DOWN_LIST  ,  "Single choice selection field and a pull-down list"},
746         { MULTIPLE_CHOICE_SELECTION_FIELD_AND_A_PULL_DOWN_LIST,  "Multiple choice selection field and a pull-down list"},
747         { PUSH_BUTTONS                                        ,  "Push buttons"},
748         { PUSH_BUTTONS_IN_A_PULL_DOWN_MENU_                   ,  "Push buttons in a pull-down menu "},
749         { 0x00, NULL }
750 };
751
752 #define DS_INDICATOR1              0x00
753 #define DS_INDICATOR2              0x02
754 #define DS_INDICATOR3              0x03
755 #define DS_INDICATOR4              0x04
756 #define DS_INDICATOR5              0x05
757 #define DS_INDICATOR6              0x06
758 #define DS_INDICATOR7              0x0F
759 #define DS_INDICATORS_BITS         0x0F
760
761 static const value_string vals_tn5250_wdsf_ds_gdc_indicators[] = {
762         { DS_INDICATOR1,  "An indicator to the left of each choice (check box or radio button) is created."},
763         { DS_INDICATOR2,  "A push button box is created around choice text and the choice text is padded with a blank on both sides."},
764         { DS_INDICATOR3,  "A push button indicator specifies each choice instead of a push button  box on a GUI-like NWS. (A GUI "
765                           "PWS treats this setting like B'0010'.)"},
766         { DS_INDICATOR4,  "A push button box is created around choice text and choice text is padded  with a blank on both sides,"
767                           " and a leading choice text attribute is written on top of the previous choice  text ending attribute."},
768         { DS_INDICATOR5,  "A push button indicator specifies each choice instead of a push button box on a GUI-like NWS, and a leading "
769                           "choice text attribute is specified on top of the previous ending choice text attribute. (A GUI PWS treats "
770                           "this setting like B'0100'.)"},
771         { DS_INDICATOR6,  "A push button box is created around choice text (with no padding)."},
772         { DS_INDICATOR7,  "There are no indicators for this value. It is valid for all types of selection."},
773         { 0x00, NULL }
774 };
775
776 #define DS_SELECTION_TECHNIQUES1             0x20
777 #define DS_SELECTION_TECHNIQUES2             0x40
778 #define DS_SELECTION_TECHNIQUES3             0xE0
779 #define DS_SELECTION_TECHNIQUES_BITS         0xE0
780
781 static const value_string vals_tn5250_wdsf_ds_gdc_selection_techniques[] = {
782         { DS_SELECTION_TECHNIQUES1,  "Defines a mnemonic (or numeric) selection for some or all of the choices. The mnemonic is underscored."},
783         { DS_SELECTION_TECHNIQUES2,  "Defines a mnemonic (or numeric) selection for some or all of the choices. "
784                                      "The mnemonic is not underscored."},
785         { DS_SELECTION_TECHNIQUES3,  "No mnemonic (or numeric) selection is specified."},
786         { 0x00, NULL }
787 };
788
789
790 #define DS_NWS_INDICATOR1              0x00
791 #define DS_NWS_INDICATOR2              0x03
792 #define DS_NWS_INDICATOR3              0x05
793 #define DS_NWS_INDICATOR4              0x08
794 #define DS_NWS_INDICATOR5              0x0F
795 #define DS_NWS_INDICATORS_BITS         0x0F
796
797 static const value_string vals_tn5250_wdsf_ds_nws_indicators[] = {
798         { DS_NWS_INDICATOR1,  "An indicator to the left of each  choice (for example, a slash (/)) is  created. (1)"},
799         { DS_NWS_INDICATOR2,  "A push button indicator specifies each choice. (2)"},
800         { DS_NWS_INDICATOR3,  "A push button indicator specifies each choice, and a leading choice text attribute is "
801                               "specified on top of a previous ending choice text attribute. (2)"},
802         { DS_NWS_INDICATOR4,  "A numeric field to the left of the first choice is created. (Single- or double-digit "
803                               "numeric fields are determined by bits 5-7.) (3)"},
804         { DS_NWS_INDICATOR5,  "No indicators are specified for this value. This is valid for all types of selection fields."},
805         { 0x00, NULL }
806 };
807
808 #define DS_NWS_SELECTION_TECHNIQUES1             0x20
809 #define DS_NWS_SELECTION_TECHNIQUES2             0x40
810 #define DS_NWS_SELECTION_TECHNIQUES3             0x80
811 #define DS_NWS_SELECTION_TECHNIQUES4             0xA0
812 #define DS_NWS_SELECTION_TECHNIQUES5             0xE0
813 #define DS_NWS_SELECTION_TECHNIQUES_BITS         0xE0
814
815 static const value_string vals_tn5250_wdsf_ds_nws_selection_techniques[] = {
816         { DS_NWS_SELECTION_TECHNIQUES1,  "Defines a mnemonic (or numeric) selection for some or all of the choices. "
817                                          "The mnemonic is underscored."},
818         { DS_NWS_SELECTION_TECHNIQUES2,  "Defines a mnemonic (or numeric) selection for some or all of the choices. "
819                                           "The mnemonic is not underscored."},
820         { DS_NWS_SELECTION_TECHNIQUES3,  "Defines a single-digit numeric selection."},
821         { DS_NWS_SELECTION_TECHNIQUES4,  "Defines a double-digit numeric selection."},
822         { DS_NWS_SELECTION_TECHNIQUES5,  "No mnemonic or numeric selection is defined."},
823         { 0x00, NULL }
824 };
825
826 /* 15.6.13.5  Write to Display Structured Field Order - Define Selection Field - Choice Text Minor Structure*/
827 #define DS_CHOICE_STATE1             0x01
828 #define DS_CHOICE_STATE2             0x02
829 #define DS_CHOICE_STATE3             0x03
830 #define DS_CHOICE_STATE_BITS         0x03
831
832 static const value_string vals_tn5250_wdsf_ds_ct_flag1_choice_state[] = {
833         { DS_CHOICE_STATE1,  "Available and not a default selection"},
834         { DS_CHOICE_STATE2,  "Available and is a default selection (selected state)"},
835         { DS_CHOICE_STATE3,  "Not available"},
836         { 0x00, NULL }
837 };
838
839 static const struct true_false_string tn5250_field_wdsf_ds_ct_flag1_2 = {
840         "Set to on: specifies a menu bar choice that starts a new row.",
841         "Set to on: does not specify a menu bar choice that starts a new row."
842 };
843
844 static const struct true_false_string tn5250_field_wdsf_ds_ct_flag1_3 = {
845         "Reserved (incorrectely set to on).",
846         "Reserved (set to zero)."
847 };
848
849 static const struct true_false_string tn5250_field_wdsf_ds_ct_flag1_4 = {
850         "Set to on: specifies that a  mnemonic offset is included in the minor structure.",
851         "Set to off: does not specify that a mnemonic offset is included in the minor structure."
852 };
853
854 static const struct true_false_string tn5250_field_wdsf_ds_ct_flag1_5 = {
855         "If set to on, specifies an AID if 'selected' is included in this minor structure.",
856         "No Action"
857 };
858
859 #define DS_NUMERIC_SELECTION_NOT_INCLUDED             0x00
860 #define DS_NUMERIC_SELECTION_SINGLE_DIGIT             0x40
861 #define DS_NUMERIC_SELECTION_DOUBLE_DIGIT             0x80
862 #define DS_NUMERIC_SELECTION_BITS                     0xC0
863
864 static const value_string vals_tn5250_wdsf_ds_ct_flag1_numeric_selection[] = {
865         { DS_NUMERIC_SELECTION_NOT_INCLUDED,  "Numeric selection characters are not included in this minor structure."},
866         { DS_NUMERIC_SELECTION_SINGLE_DIGIT,  "A single-digit numeric selection character is included in this minor structure."},
867         { DS_NUMERIC_SELECTION_DOUBLE_DIGIT,  "Double-digit numeric selection characters are included in this minor structure."},
868         { 0x00, NULL }
869 };
870
871 static const struct true_false_string tn5250_field_wdsf_ds_ct_flag2_0 = {
872         "Set to on, the choice cannot accept a cursor.",
873         "Set to off, the choice can accept a cursor."
874 };
875
876 static const struct true_false_string tn5250_field_wdsf_ds_ct_flag2_1 = {
877         "Set to on, the application user desires a roll-down AID if the Cursor Up key is pressed on this choice.",
878         "Set to off, the application user does not desire a roll-down AID if the Cursor Up key is pressed on this choice."
879 };
880
881 static const struct true_false_string tn5250_field_wdsf_ds_ct_flag2_2 = {
882         "Set to on, the application user desires a roll-up AID if the Cursor Up key is pressed on this choice.",
883         "Set to off, the application user does not desire a roll-up AID if the Cursor Up key is pressed on this choice."
884 };
885
886 static const struct true_false_string tn5250_field_wdsf_ds_ct_flag2_3 = {
887         "Set to on, the application user desires a roll-left AID if the Cursor Up key is pressed on this choice.",
888         "Set to off, the application user does not desire a roll-left AID if the Cursor Up key is pressed on this choice."
889 };
890
891 static const struct true_false_string tn5250_field_wdsf_ds_ct_flag2_4 = {
892         "Set to on, the application user desires a roll-right AID if the Cursor Up key is pressed on this choice.",
893         "Set to off, the application user does not desire a roll-right AID if the Cursor Up key is pressed on this choice."
894 };
895
896 static const struct true_false_string tn5250_field_wdsf_ds_ct_flag2_5 = {
897         "Set to on, no push-button box is written for this choice.",
898         "Set to off, a push-button box is written for this choice."
899 };
900
901 static const struct true_false_string tn5250_field_wdsf_ds_ct_flag2_6 = {
902         "Reserved (incorrectely set to on).",
903         "Reserved (set to zero)."
904 };
905
906 static const struct true_false_string tn5250_field_wdsf_ds_ct_flag2_7 = {
907         "Set to on, cursor direction is right to left.",
908         "Set to off, cursor direction is left to right."
909 };
910
911 static const struct true_false_string tn5250_field_wdsf_ds_ct_flag3_0 = {
912         "Set to on, use this minor structure for GUI devices (including GUI-like NWSs).",
913         "Set to off, do not use this minor structure for GUI devices (including GUI-like NWSs)."
914 };
915
916 static const struct true_false_string tn5250_field_wdsf_ds_ct_flag3_1 = {
917         "Set to on, use this minor structure for non-GUI NWSs that are capable of creating mnemonic underscores.",
918         "Set to off, do not use this minor structure for non-GUI NWSs that are capable of creating mnemonic underscores."
919 };
920
921 static const struct true_false_string tn5250_field_wdsf_ds_ct_flag3_2 = {
922         "Set to on, use this minor structure for NWS display devices that are not capable of creating underscores.",
923         "Set to off, do not use this minor structure for NWS display devices that are not capable of creating underscores."
924 };
925
926 /* 15.6.13.5  Write to Display Structured Field Order - Define Selection Field - Menu Bar Separator Minor Structure*/
927
928 static const struct true_false_string tn5250_field_wdsf_ds_mbs_flag_0 = {
929         "Use specified separator character on GUI-like NWSs.",
930         "Do not use specified separator character on GUI-like NWSs."
931 };
932
933 static const struct true_false_string tn5250_field_wdsf_ds_mbs_flag_1 = {
934         "Suppress writing of leading and ending attributes.",
935         "Do not suppress writing of leading and ending attributes."
936 };
937
938 /* 15.6.13.5  Write to Display Structured Field Order - Define Selection Field - Choice Presentation Display Attributes Minor Structure*/
939
940 static const struct true_false_string tn5250_field_wdsf_ds_cpda_flag1_0 = {
941         "Uses the minor structure for GUI devices (including GUI-like NWSs).",
942         "Does not use the minor structure for GUI devices (including GUI-like NWSs)."
943 };
944
945 static const struct true_false_string tn5250_field_wdsf_ds_cpda_flag1_1 = {
946         "Uses the minor structure for NWSs that are capable of creating underscores.",
947         "Does not use the minor structure for NWSs that are capable of creating underscores."
948 };
949
950 static const struct true_false_string tn5250_field_wdsf_ds_cpda_flag1_2 = {
951         "Uses the minor structure for NWSs that are not capable of creating mnemonic underscores.",
952         "Does not use the minor structure for NWSs that are not capable of creating mnemonic underscores."
953 };
954
955 /* 15.6.13.5  Write to Display Structured Field Order - Define Selection Field - Choice Indicators Minor Structure*/
956
957 static const struct true_false_string tn5250_field_wdsf_ds_ci_flag1_0 = {
958         "Use the specified indicators on GUI-like NWSs.",
959         "Do Not Use the specified indicators on GUI-like NWSs"
960 };
961
962 /* 15.6.13.5  Write to Display Structured Field Order - Define Selection Field - Scroll Bar Indicators Minor Structure*/
963
964 static const struct true_false_string tn5250_field_wdsf_ds_sbi_flag1_0 = {
965         "Use the specified indicators on GUI-like NWSs.",
966         "Do Not Use the specified indicators on GUI-like NWSs"
967 };
968
969 /* 15.6.13.7  Write to Display Structured Field Order - Define Scroll Bar Field */
970
971 static const struct true_false_string tn5250_field_wdsf_dsb_flag1_0 = {
972         "On: Vertical scroll bar is set to off and horizontal scroll bar is set to on.",
973         "Off: Vertical scroll bar is set to off and horizontal scroll bar is set to on."
974 };
975
976 static const struct true_false_string tn5250_field_wdsf_dsb_flag1_1 = {
977         "On: The cursor is moved to the scroll bar on a pointer device scroll bar interaction",
978         "Off: The cursor is moved to the scroll bar on a pointer device scroll bar interaction."
979 };
980
981 static const struct true_false_string tn5250_field_wdsf_dsb_flag1_7 = {
982         "On: Field MDT",
983         "Off: Field MDT"
984 };
985
986 /* 15.6.13.9  Write to Display Structured Field Order - Write Data Field */
987
988 static const struct true_false_string tn5250_field_wdsf_wdf_flag1_0 = {
989         "On: Write data to entry field",
990         "Off: Do not write data to entry field"
991 };
992
993 /* 15.6.13.10  Write to Display Structured Field Order - Programmable Mouse Buttons */
994 static const struct true_false_string tn5250_field_wdsf_pmb_flag1_0 = {
995         "Two-event definition",
996         "Single-event definition"
997 };
998
999 static const struct true_false_string tn5250_field_wdsf_pmb_flag1_1 = {
1000         "On: The text cursor is moved to the location of the mouse cursor.",
1001         "Off: The text cursor is NOT moved to the location of the mouse cursor."
1002 };
1003
1004 static const struct true_false_string tn5250_field_wdsf_pmb_flag1_2 = {
1005         "On: The single mouse event is queued if the keyboard is locked.",
1006         "Off: The single mouse event is not queued if the keyboard is locked"
1007 };
1008
1009 static const struct true_false_string tn5250_field_wdsf_pmb_flag1_3 = {
1010         "On: A marker box is drawn on the first event of a two-event definition",
1011         "Off: A marker box is not drawn on the first event of a two-event definition"
1012 };
1013
1014 #define PMB_RESERVED                              0x00
1015 #define LEFT_BUTTON_PRESSED                       0x01
1016 #define LEFT_BUTTON_RELEASED                      0x02
1017 #define LEFT_BUTTON_DOUBLE_CLICK                  0x03
1018 #define RIGHT_BUTTON_PRESSED                      0x04
1019 #define RIGHT_BUTTON_RELEASED                     0x05
1020 #define RIGHT_BUTTON_DOUBLE_CLICK                 0x06
1021 #define MIDDLE_BUTTON_PRESSED                     0x07
1022 #define MIDDLE_BUTTON_RELEASED                    0x08
1023 #define MIDDLE_BUTTON_DOUBLE_CLICK                0x09
1024 #define SHIFTED_LEFT_BUTTON_PRESSED               0x0A
1025 #define SHIFTED_LEFT_BUTTON_RELEASED              0x0B
1026 #define SHIFTED_LEFT_BUTTON_DOUBLE_CLICK          0x0C
1027 #define SHIFTED_RIGHT_BUTTON_PRESSED              0x0D
1028 #define SHIFTED_RIGHT_BUTTON_RELEASED             0x0E
1029 #define SHIFTED_RIGHT_BUTTON_DOUBLE_CLICK         0x0F
1030 #define SHIFTED_MIDDLE_BUTTON_PRESSED             0x10
1031 #define SHIFTED_MIDDLE_BUTTON_RELEASED            0x11
1032 #define SHIFTED_MIDDLE_BUTTON_DOUBLE_CLICK        0x12
1033
1034 static const value_string vals_tn5250_mouse_events[] = {
1035         { PMB_RESERVED                      ,  "Reserved"},
1036         { LEFT_BUTTON_PRESSED               ,  "Left button pressed"},
1037         { LEFT_BUTTON_RELEASED              ,  "Left button released"},
1038         { LEFT_BUTTON_DOUBLE_CLICK          ,  "Left button double click"},
1039         { RIGHT_BUTTON_PRESSED              ,  "Right button pressed"},
1040         { RIGHT_BUTTON_RELEASED             ,  "Right button released"},
1041         { RIGHT_BUTTON_DOUBLE_CLICK         ,  "Right button double click"},
1042         { MIDDLE_BUTTON_PRESSED             ,  "Middle button pressed"},
1043         { MIDDLE_BUTTON_RELEASED            ,  "Middle button released"},
1044         { MIDDLE_BUTTON_DOUBLE_CLICK        ,  "Middle button double click"},
1045         { SHIFTED_LEFT_BUTTON_PRESSED       ,  "Shifted left button pressed"},
1046         { SHIFTED_LEFT_BUTTON_RELEASED      ,  "Shifted left button released"},
1047         { SHIFTED_LEFT_BUTTON_DOUBLE_CLICK  ,  "Shifted left button double click"},
1048         { SHIFTED_RIGHT_BUTTON_PRESSED      ,  "Shifted right button pressed"},
1049         { SHIFTED_RIGHT_BUTTON_RELEASED     ,  "Shifted right button released"},
1050         { SHIFTED_RIGHT_BUTTON_DOUBLE_CLICK ,  "Shifted right button double click"},
1051         { SHIFTED_MIDDLE_BUTTON_PRESSED     ,  "Shifted middle button pressed"},
1052         { SHIFTED_MIDDLE_BUTTON_RELEASED    ,  "Shifted middle button released"},
1053         { SHIFTED_MIDDLE_BUTTON_DOUBLE_CLICK,  "Shifted middle button double click"},
1054         { 0x00, NULL }
1055 };
1056
1057 /* 15.7 Draw/Erase Grid Lines Structured Field */
1058 static const struct true_false_string tn5250_field_wdsf_deg_flag1_0 = {
1059         "On: Clear the grid line buffer specified by the partition byte",
1060         "Off: Do not clear the grid line buffer specified by the partition byte"
1061 };
1062
1063 #define SOLID_LINE                           0x00
1064 #define THICK_SOLID_LINE_BOLD                0x01
1065 #define DOUBLE_LINE                          0x02
1066 #define DOTTED_LINE                          0x03
1067 #define DASHED_LINE                          0x08
1068 #define THICK_DASHED_LINE_BOLD               0x09
1069 #define DOUBLE_DASHED_LINE                   0x0A
1070 #define USE_DEFAULT_LINE_FOR_THE_DISPLAY     0xFF
1071
1072 static const value_string vals_tn5250_deg_lines[] = {
1073         { SOLID_LINE                      ,  "Solid line"},
1074         { THICK_SOLID_LINE_BOLD           ,  "Thick solid line (bold)"},
1075         { DOUBLE_LINE                     ,  "Double line"},
1076         { DOTTED_LINE                     ,  "Dotted line"},
1077         { DASHED_LINE                     ,  "Dashed line"},
1078         { THICK_DASHED_LINE_BOLD          ,  "Thick dashed line (bold)"},
1079         { DOUBLE_DASHED_LINE              ,  "Double dashed line"},
1080         { USE_DEFAULT_LINE_FOR_THE_DISPLAY,  "Use default line for the display."},
1081         { 0x00, NULL }
1082 };
1083
1084 /* 15.7.1 Draw/Erase Grid Lines Structured Field - Minor Structure*/
1085 #define UPPER_HORIZONTAL_LINE                        0x00
1086 #define LOWER_HORIZONTAL_LINE                        0x01
1087 #define LEFT_VERTICAL_LINE                           0x02
1088 #define RIGHT_VERTICAL_LINE                          0x03
1089 #define PLAIN_BOX                                    0x04
1090 #define HORIZONTALLY_RULED_BOX                       0x05
1091 #define VERTICALLY_RULED_BOX                         0x06
1092 #define HORIZONTALLY_AND_VERTICALLY_RULED_BOX        0x07
1093
1094 static const value_string vals_tn5250_wdsf_deg_minor_type[] = {
1095         { UPPER_HORIZONTAL_LINE                ,  "Upper horizontal line"},
1096         { LOWER_HORIZONTAL_LINE                ,  "Lower horizontal line"},
1097         { LEFT_VERTICAL_LINE                   ,  "Left vertical line"},
1098         { RIGHT_VERTICAL_LINE                  ,  "Right vertical line"},
1099         { PLAIN_BOX                            ,  "Plain box"},
1100         { HORIZONTALLY_RULED_BOX               ,  "Horizontally ruled box"},
1101         { VERTICALLY_RULED_BOX                 ,  "Vertically ruled box"},
1102         { HORIZONTALLY_AND_VERTICALLY_RULED_BOX,  "Horizontally and vertically ruled box"},
1103         { 0x00, NULL }
1104 };
1105
1106 static const struct true_false_string tn5250_field_wdsf_deg_ms_flag1_0 = {
1107         "Erase the construct specified",
1108         "Draw the construct specified"
1109 };
1110
1111 /* 15.22 SAVE PARTIAL SCREEN Command */
1112 static const struct true_false_string tn5250_field_sps_flag1_0 = {
1113         "Do not include image/fax information",
1114         "Include image/fax information if image/fax data is on the 5250 session"
1115 };
1116
1117 /* 15.25 ROLL Command */
1118 static const struct true_false_string tn5250_field_roll_flag1_0 = {
1119         "Roll down",
1120         "Roll up"
1121 };
1122
1123 /* 15.26.1 WRITE SINGLE STRUCTURED FIELD Command - 5250 WSC CUSTOMIZATION Command*/
1124 #define KEYSTROKE_BUFFERING_CONTROL              0x01
1125 #define CURSOR_CONTROL                           0x02
1126
1127 static const value_string vals_tn5250_wssf_minor_type[] = {
1128         { KEYSTROKE_BUFFERING_CONTROL      ,  "Keystroke Buffering Control"},
1129         { CURSOR_CONTROL                   ,  "Cursor Control"},
1130         { 0x00, NULL }
1131 };
1132
1133 #define WSC_MINOR_STRUCTURE_LENGTH               0x03
1134
1135 static const struct true_false_string tn5250_field_wssf_flag2_0 = {
1136         "Reserved",
1137         "WARNING: Reserved, but set."
1138 };
1139
1140 static const struct true_false_string tn5250_field_wssf_flag2_1 = {
1141         "Enhanced field exit required mode.",
1142         "Enhanced field exit required mode not set"
1143 };
1144
1145 static const struct true_false_string tn5250_field_wssf_flag2_2 = {
1146         "Resets enhanced field exit required mode",
1147         "Does not reset enhanced field exit required mode"
1148 };
1149
1150 static const struct true_false_string tn5250_field_wssf_flag2_3 = {
1151         "Sets System/36* mode of operation",
1152         "Does not set System/36* mode of operation"
1153 };
1154
1155 static const struct true_false_string tn5250_field_wssf_flag2_4 = {
1156         "Resets System/36* mode of operation",
1157         "Does not reset System/36* mode of operation"
1158 };
1159
1160 static const struct true_false_string tn5250_field_wssf_flag2_5 = {
1161         "Set SBA code to X'04' in data returned for READ commands if set to logic 1.",
1162         "Does not set SBA code to X'04' in data returned for READ commands."
1163 };
1164
1165 static const struct true_false_string tn5250_field_wssf_flag2_6 = {
1166         "Set SBA code to X'11' in data returned for READ commands if set to logic 1.",
1167         "Does not set SBA code to X'11' in data returned for READ commands."
1168 };
1169
1170 static const struct true_false_string tn5250_field_wssf_flag2_7 = {
1171         "Customization applies to entire 5494 if set to logic 1",
1172         "Customization does not apply to entire 5494 if set to logic 1"
1173 };
1174
1175 /* 15.26.1 WRITE SINGLE STRUCTURED FIELD Command - 5250 WSC CUSTOMIZATION Command
1176                                                 - Keystroke Buffering Control Minor Structure*/
1177 static const struct true_false_string tn5250_field_wssf_kbc_flag1_5 = {
1178         "Change type-ahead state if set to logic 1",
1179         "Change type-ahead state not set"
1180 };
1181
1182 static const struct true_false_string tn5250_field_wssf_kbc_flag1_6 = {
1183         "Indicates type-ahead is on if set to logic 1 (and bit 5 set to 1). If bit 6 is set to 0 and bit 5 is set to 1, type-ahead is turned off. If bit 5 is set to 0, bit 6 is ignored.",
1184         "Indicates type-ahead is on if set to logic 1 (and bit 5 set to 1). If bit 6 is set to 0 and bit 5 is set to 1, type-ahead is turned off. If bit 5 is set to 0, bit 6 is ignored."
1185 };
1186
1187 static const struct true_false_string tn5250_field_wssf_kbc_flag1_7 = {
1188         "Attention key is buffered",
1189         "Attention key is not buffered"
1190 };
1191
1192 /* 15.26.1 WRITE SINGLE STRUCTURED FIELD Command - 5250 WSC CUSTOMIZATION Command
1193                                                 - Cursor Control Minor Structure*/
1194
1195 static const struct true_false_string tn5250_field_wssf_cc_flag1_7 = {
1196         "Cursor will blink",
1197         "Cursor will not blink"
1198 };
1199
1200 /* 15.26.2 WRITE SINGLE STRUCTURED FIELD Command - IMAGE/FAX CONTROL Command */
1201
1202 static const struct true_false_string tn5250_field_wssf_ifc_flag1_0 = {
1203         "If the display supports a cache,this image/fax data remains in cache memory when the application sends one of the above commands to erase this image/fax data",
1204         "Erase this image/fax from memory whenever any of the following commands are received: CLEAR UNIT, CLEAR UNIT ALTERNATE (without saving image/fax), RESTORE RESTORE PARTIAL (if image/fax data was indicated in the SAVE PARTIAL), Another IMAGE/FAX CONTROL command"
1205 };
1206
1207 static const value_string tn5250_vals_tn5250_wssf_ifc_vals[] = {
1208         { 0x00   ,  "Normal display (default)"},
1209         { 0x08   ,  "Transparent display (underlying text may be seen through the image/fax)"},
1210         { 0x04   ,  "Non-display (the image/fax data remains in memory until it is erased). All other parameters in this command are ignored."},
1211         { 0x02   ,  "Previously stored image/fax data is erased from the 5250 session and possibly from display memory (see bit 0 previously). All other parameters in this command are ignored."},
1212         { 0x00, NULL }
1213 };
1214
1215 static const struct true_false_string tn5250_field_wssf_ifc_flag1_4 = {
1216         "The display does not present scroll bars",
1217         "The display presents vertical and horizontal scroll bars as needed and allows the user to scroll without any interaction with the AS/400 application"
1218 };
1219
1220 static const struct true_false_string tn5250_field_wssf_ifc_flag1_5 = {
1221         "Image/fax is light foreground on dark background. Preserve the light foreground data during scaling",
1222         "Image/fax is dark foreground on light background. Preserve the dark foreground data during scaling"
1223 };
1224
1225 static const struct true_false_string tn5250_field_wssf_ifc_flag1_6 = {
1226         "Background and foreground colors are reversed",
1227         "Normal image/fax display"
1228 };
1229
1230 static const struct true_false_string tn5250_field_wssf_ifc_flag1_7 = {
1231         "Do not allow EasyScroll with the primary mouse button.",
1232         "Allow the primary mouse button to EasyScroll the image/fax"
1233 };
1234
1235 static const struct true_false_string tn5250_field_wssf_ifc_flag2_0 = {
1236         "For Group 3 or 4 fax, each scan line is duplicated. For high-resolution fax transmission, characters would otherwise appear flattened on the display screen",
1237         "Normal image/fax display"
1238 };
1239
1240 static const struct true_false_string tn5250_field_wssf_ifc_flag2_1 = {
1241         "Inhibit the secondary mouse button to Trim Magnify",
1242         "Allow the secondary mouse button to Trim Magnify the image/fax data"
1243 };
1244
1245 static const struct true_false_string tn5250_field_wssf_ifc_flag2_7 = {
1246         "Reserved for IBM image/fax-capable displays. It is used to download compression algorithms. Non-IBM displays should ignore this bit.",
1247         "Reserved for IBM image/fax-capable displays. It is used to download compression algorithms. Non-IBM displays should ignore this bit."
1248 };
1249
1250 static const value_string vals_tn5250_image_format[] = {
1251         { 0x0000,  "An unknown IBM-defined format."},
1252         { 0x0001,  "IOCA (The IOCA header defines the compression algorithm.)"},
1253         { 0x0002,  "TIFF (The TIFF header defines the compression algorithm.)"},
1254         { 0x0003,  "PCX"},
1255         { 0x0004,  "Stand alone Group 3 Fax compression."},
1256         { 0x00, NULL }
1257 };
1258
1259
1260 static const value_string vals_tn5250_wssf_ifc_scaling[] = {
1261         { 0xFFFE,  "No Scroll Bar Scaling. The data is scaled such that it fits within the Viewport without requiring scrolling in either direction."},
1262         { 0xFFFD,  "Fill Scaling. The data is scaled such that it fits horizontally within the Viewport without requiring horizontal scroll bars."},
1263         { 0xFFEA,  "Decrement Scaling Values."},
1264         { 0xFFDA,  "Increment Scaling Values."},
1265         { 0x00, NULL }
1266 };
1267
1268
1269 /* 15.26.3 WRITE SINGLE STRUCTURED FIELD Command - IMAGE/FAX DOWNLOAD Command */
1270 static const struct true_false_string tn5250_field_wssf_ifd_flag1_0 = {
1271         "This is the last or only IMAGE/FAX DOWNLOAD command for this image/fax",
1272         "Additional IMAGE/FAX DOWNLOAD commands follow, containing data for this image/fax"
1273 };
1274
1275 static const value_string vals_tn5250_image_fax_error[] = {
1276     { 0x0001, "Image/fax data was too large. Only the first portion of the data is displayed."},
1277     { 0x0002, " Image/fax data was too large. The data was ignored."},
1278     { 0x0003, " Invalid major length in the IMAGE/FAX CONTROL command"},
1279     { 0x0004, " Invalid major length in the IMAGE/FAX DOWNLOAD command"},
1280     { 0x0005, " Error in the IMAGE/FAX CONTROL command"},
1281     { 0x0006, " Error in the IMAGE/FAX DOWNLOAD command"},
1282     { 0x0007, " Error detected in the image/fax data"},
1283         { 0x0000, NULL }
1284 };
1285
1286
1287
1288 /* 15.26.4 WRITE SINGLE STRUCTURED FIELD Command - Video/Audio Controls Command Major Structure */
1289
1290 static const range_string vals_tn5250_vac_data[] = {
1291     { 0x13000001, 0x13000001, "Set View Mode to PIP"},
1292     { 0x13000000, 0x13000000, "Set View Mode to Off"},
1293     { 0x14000000, 0x14000000, "Turn Audio On"},
1294     { 0x14000001, 0x14000001, "Turn Audio Off"},
1295     { 0x0C000000, 0x0C000064, "Set PC/TV Volume"},
1296     { 0x00000000, 0xFFFFFFFF, "Set PIP Location and Size"},
1297     { 0x1F000001, 0x1F000001, "Set PIP See Through On"},
1298     { 0x1F000000, 0x1F000000, "Set PIP SeeThrough Off"},
1299     { 0x20000001, 0x20000001, "Freeze PIP"},
1300     { 0x20000000, 0x20000000, "Resume After Freeze"},
1301     { 0x12000000, 0x12000064, "Set PC/TV Channel"},
1302     { 0x11000000, 0x11000000, "Set Antenna Tuner Source"},
1303     { 0x11000001, 0x11000001, "Set Cable Tuner Source"},
1304     { 0x21000001, 0x21000001, "Disable Internal Speaker"},
1305     { 0x21000000, 0x21000000, "Enable Internal  Speaker"},
1306     { 0x17000001, 0x17000001, "Keyboard Disable"},
1307     { 0x17000000, 0x17000000, "Keyboard Enable"},
1308     { 0x0D000000, 0x0D000064, "Set PC/TV Brightness"},
1309     { 0x0F000000, 0x0F000064, "Set PC/TV Color"},
1310     { 0x0E000000, 0x0E000064, "Set PC/TV Contrast"},
1311     { 0x10000000, 0x10006464, "Set PC/TV Tint"},
1312     { 0,  0,      NULL}
1313 };
1314
1315 /* Appendix B.1 WRITE SINGLE STRUCTURED FIELD Command - True Transparency Write Command Major Structure */
1316 static const value_string vals_tn5250_wssf_ttw_flag[] = {
1317     { 0x00, "Invalid"},
1318     { 0x01, "ASCII Data"},
1319         { 0x0000, NULL }
1320 };
1321
1322
1323 /* 15.27.3 WRITE STRUCTURED FIELD (WSF) Command - 5250 QUERY STATION STATE Command*/
1324 static const struct true_false_string tn5250_field_wsf_qss_flag1_0 = {
1325         "QUERY STATION STATE Command Response",
1326         "QUERY STATION STATE Command"
1327 };
1328
1329 static const struct true_false_string tn5250_field_wsf_qss_flag2_7 = {
1330         "Return all customization states",
1331         "Return Keystroke Buffering Control Minor Structure"
1332 };
1333
1334 /* 15.27.4.1 DEFINE AUDIT WINDOW TABLE Command */
1335 static const range_string vals_tn5250_dawt_id[] = {
1336     { 0x00, 0x7F, "Indicates if update of primary audit window table is necessary. If this byte matches the ID  of the existing primary audit window table, the  rest of this command is discarded" },
1337     { 0x80, 0xFE, "Indicates if update of secondary audit window table is necessary. If this byte matches the ID  of the existing secondary audit window table, the rest of this command is discarded" },
1338     { 0xFF, 0xFF, "Indicates the value of the ID bytes set by the  5494 when the table is built initially. If an ID value of X'FF' is received, both the primary  and secondary tables are initially emptied" },
1339     { 0,  0,      NULL}
1340 };
1341
1342 static const range_string vals_tn5250_dawt_length[] = {
1343     { 0x00, 0x01, "Length of Table Entry is Invalid (should between 2 and 22)" },
1344     { 0x02, 0x16, "Length of Table Entry" },
1345     { 0x17, 0xFF, "Length of Table Entry is Invalid (should between 2 and 22)" },
1346     { 0,  0,      NULL}
1347 };
1348
1349 /* 15.27.4.2 DEFINE COMMAND KEY FUNCTION Command */
1350 static const range_string vals_tn5250_dckf_id[] = {
1351     { 0x00, 0x7F, "Indicates if update of primary command key function table is necessary. If this byte matches the ID  of the existing primary command key function table, the  rest of this command is discarded" },
1352     { 0x80, 0xFE, "Indicates if update of secondary command key function table is necessary. If this byte matches the ID  of the existing secondary command key function table, the rest of this command is discarded" },
1353     { 0xFF, 0xFF, "Indicates the value of the ID bytes set by the  5494 when the table is built initially. If an ID value of X'FF' is received, both the primary  and secondary tables are initially emptied" },
1354     { 0,  0,      NULL}
1355 };
1356
1357 static const range_string vals_tn5250_dckf_length[] = {
1358     { 0x00, 0x02, "Length of Table Entry is Invalid (should between 3 and 82)" },
1359     { 0x03, 0x52, "Length of Table Entry" },
1360     { 0x53, 0xFF, "Length of Table Entry is Invalid (should between 3 and 82)" },
1361     { 0,  0,      NULL}
1362 };
1363
1364 static const range_string vals_tn5250_dckf_key_code[] = {
1365     { 0x01, 0x18, "Command key number"},
1366     { 0xFB, 0xFB, "Symbols Support (Cmd + A) message"},
1367     { 0xFC, 0xFC, "Formatted text usage"},
1368     { 0xFD, 0xFD, "Stop code advance key"},
1369     { 0xFE, 0xFE, "Del key"},
1370     { 0xFF, 0xFF, "Home key"},
1371     { 0,  0,      NULL}
1372 };
1373
1374 static const value_string vals_tn5250_dckf_function_code[] = {
1375         { 0x01,  "Perform general prompt"},
1376         { 0x02,  "Perform locate"},
1377         { 0x03,  "Perform copy text"},
1378         { 0x04,  "Perform move text"},
1379         { 0x05,  "Perform delete text"},
1380         { 0x06,  "Perform hyphenate text"},
1381         { 0x07,  "Display AS/400 system-defined prompt line message"},
1382         { 0x00, NULL }
1383 };
1384
1385 /* 15.27.4.3 READ TEXT SCREEN Command */
1386
1387 static const range_string vals_tn5250_rts_partition[] = {
1388     { 0x00, 0x00, "Valid Parition ID" },
1389     { 0x01, 0xFF, "Invalid Partition ID" },
1390     { 0,  0,      NULL}
1391 };
1392
1393 static const struct true_false_string tn5250_field_rts_flag1_0 = {
1394         "The data field is in IBM 5250 line format.The structured field command form is used. Command pending format is used. No pending data is included with the command.",
1395         "WARNING: Invalid Value"
1396 };
1397
1398
1399
1400 /* 15.27.4.4 DEFINE PENDING OPERATIONS Command */
1401
1402 static const struct true_false_string tn5250_field_dpo_flag1_0 = {
1403         "Insert mode enabled",
1404         "Insert mode not enabled"
1405 };
1406
1407 static const struct true_false_string tn5250_field_dpo_flag1_1 = {
1408         "Locate mode enabled",
1409         "Locate mode not enabled"
1410 };
1411
1412 static const struct true_false_string tn5250_field_dpo_flag1_2 = {
1413         "AS/400 system controls text delete",
1414         "AS/400 system does not control text delete"
1415 };
1416
1417 static const struct true_false_string tn5250_field_dpo_flag1_3 = {
1418         "5494 responds to the Error Reset key by locking the workstation keyboard and sending an X'4E' AID request to the AS/400 system",
1419         "5494 does not respond to the Error Reset key by locking the workstation keyboard and sending an X'4E' AID request to the AS/400 system"
1420 };
1421
1422 static const struct true_false_string tn5250_field_dpo_flag1_4 = {
1423         "5494 must notify the AS/400 system on completion of a copy, move, or delete operation",
1424         "5494 does not need to notify the AS/400 system on completion of a copy, move, or delete operation"
1425 };
1426
1427 static const struct true_false_string tn5250_field_dpo_flag1_5 = {
1428         "AS/400 system assisted locate function enabled",
1429         "AS/400 system assisted locate function not enabled"
1430 };
1431
1432 static const struct true_false_string tn5250_field_dpo_flag1_6 = {
1433         "Tab function independent of shift status",
1434         "Tab function not independent of shift status"
1435 };
1436
1437 static const struct true_false_string tn5250_field_dpo_flag1_7 = {
1438         "Insert mode is toggled by the Insert key",
1439         "Insert mode is toggled by the Insert key"
1440 };
1441
1442 static const struct true_false_string tn5250_field_dpo_flag2_0 = {
1443         "Copy, move, or delete is pending",
1444         "Copy, move, or delete is not pending"
1445 };
1446
1447
1448 /* 15.27.4.5 DEFINE TEXT SCREEN FORMAT Command */
1449 static const struct true_false_string tn5250_field_dtsf_flag1_0 = {
1450     "Column edit active",
1451     "Column edit is not active"
1452 };
1453
1454 static const struct true_false_string tn5250_field_dtsf_flag1_1 = {
1455     "Data exists outside left margin",
1456     "No data outside left margin"
1457 };
1458
1459 static const struct true_false_string tn5250_field_dtsf_flag1_2 = {
1460     "Data exists outside right margin",
1461     "No data outside right margin"
1462 };
1463
1464 static const struct true_false_string tn5250_field_dtsf_flag1_3 = {
1465     "Cursor-sensitive scrolling active",
1466     "No cursor-sensitive scrolling active"
1467 };
1468
1469 static const struct true_false_string tn5250_field_dtsf_flag1_4 = {
1470     "Fake DP mode active",
1471     "No fake DP mode active"
1472 };
1473
1474 static const struct true_false_string tn5250_field_dtsf_flag1_5 = {
1475     "Do not clear screen",
1476     "Clear screen as normal"
1477 };
1478
1479 static const struct true_false_string tn5250_field_dtsf_flag1_6 = {
1480     "Document orientation is right to left",
1481     "Document orientation is left to right"
1482 };
1483
1484 static const struct true_false_string tn5250_field_dtsf_flag1_7 = {
1485     "Host does not have BIDI support.",
1486     "Host has bi-directional (BIDI) support"
1487 };
1488
1489
1490 static const struct true_false_string tn5250_field_dtsf_flag2_0 = {
1491     "Data stream from AS/400 system.",
1492     "Data stream from S/36 system."
1493 };
1494
1495 static const struct true_false_string tn5250_field_dtsf_flag2_1 = {
1496     "The screen data does have extended attributes.",
1497     "The screen data in READ and WRITE commands does not have extended attributes."
1498 };
1499
1500 static const struct true_false_string tn5250_field_dtsf_flag2_2 = {
1501     "WordPerfect/400* edit session",
1502     "OfficeVision/400* edit session"
1503 };
1504
1505 static const struct true_false_string tn5250_field_dtsf_flag2_3 = {
1506     "Secondary language tables should be used.",
1507     "Primary language tables should be used."
1508 };
1509
1510 static const range_string vals_tn5250_dtsf_flag2_vals[] = {
1511     { 0x00, 0x70, "Reserved"},
1512     { 0x80, 0x80, "System Version 2 Release 2.0"},
1513     { 0x90, 0x90, "System Version 2 Release 3.0"},
1514     { 0xA0, 0xA0, "System Version 3 Release 0.5"},
1515     { 0xB0, 0xB0, "System Version 3 Release 1.0"},
1516     { 0xC0, 0xF0, "Reserved"},
1517     { 0,  0,      NULL}
1518 };
1519
1520 /* 15.27.4.6 DEFINE SCALE LINE Command */
1521 static const struct true_false_string tn5250_field_dsl_flag1_0 = {
1522     "Suppress display of the right margin symbol",
1523     "Do not suppress display of the right margin symbol"
1524 };
1525
1526 static const struct true_false_string tn5250_field_dsl_flag1_1 = {
1527     "Suppress display of the left margin symbol",
1528     "Do not suppress display of the left margin symbol"
1529 };
1530
1531 static const struct true_false_string tn5250_field_dsl_flag1_2 = {
1532     "Indicate a tab stop located off the display if the absolute right margin is not defined",
1533     "Do not indicate a tab stop located off the display if the absolute right margin is not defined"
1534 };
1535
1536 static const range_string vals_tn5250_dsl_function[] = {
1537     { 0x01,  0x01, "Left margin symbol"},
1538     { 0x02,  0x02, "Right margin symbol"},
1539     { 0x03,  0x03, "Left tab symbol"},
1540     { 0x04,  0x04, "Right tab symbol"},
1541     { 0x05,  0x05, "Center tab symbol"},
1542     { 0x06,  0x06, "Decimal align tab symbol"},
1543     { 0x07,  0x07, "Comma align tab symbol"},
1544     { 0x08,  0x08, "Colon align tab symbol"},
1545     { 0x09,  0x09, "Inactive tab stop symbol"},
1546     { 0x0A,  0x0A, "Center of margins symbol"},
1547     { 0x0B,  0x0B, "Paper edge symbol"},
1548     { 0x0C,  0x0C, "Pitch symbol"},
1549     { 0x0D,  0xFF, "Reserved."},
1550     { 0,  0,      NULL}
1551 };
1552
1553
1554 /* 15.27.4.7 WRITE TEXT SCREEN Command */
1555 static const struct true_false_string tn5250_field_wts_flag1_0 = {
1556     "5250 format.",
1557     "3270 format (not supported on 5494)."
1558 };
1559
1560 static const struct true_false_string tn5250_field_wts_flag1_1 = {
1561     "First line in body is an odd number of half-spacing units.",
1562     "First line in body is an even number of half-spacing units."
1563 };
1564
1565 static const struct true_false_string tn5250_field_wts_flag1_2 = {
1566     "Cursor is on a line of formatted text. The 5494 displays text message defined in the Define Command Key table.",
1567     "Cursor is not on a line that contains formatted text. No function is performed."
1568 };
1569
1570 static const struct true_false_string tn5250_field_wts_flag1_3 = {
1571     "Display the primary attribute at the cursor location.",
1572     "Do not display the primary attribute"
1573 };
1574
1575 static const struct true_false_string tn5250_field_wts_flag2_6 = {
1576     "Lock keyboard to inhibit data input before any lines are written to screen",
1577     "Do not lock keyboard to inhibit data input before any lines are written to screen"
1578 };
1579
1580 static const struct true_false_string tn5250_field_wts_flag3_0 = {
1581         "Reserved",
1582         "Reserved: should be 0!"
1583 };
1584
1585 static const struct true_false_string tn5250_field_wts_flag3_1 = {
1586         "Moves cursor to home position after write operation is completed",
1587         "Does not move cursor to home position after write operation is completed"
1588 };
1589
1590 static const struct true_false_string tn5250_field_wts_flag3_2 = {
1591         "Resets Cursor Blinking mode after write operation is completed",
1592         "Does not reset Cursor Blinking mode after write operation is completed"
1593 };
1594
1595 static const struct true_false_string tn5250_field_wts_flag3_3 = {
1596         "Sets Cursor Blinking mode after write operation is completed",
1597         "Does not set Cursor Blinking mode after write operation is completed"
1598 };
1599
1600 static const struct true_false_string tn5250_field_wts_flag3_4 = {
1601         "Resets keyboard locking function after write operation is completed",
1602         "Does not reset keyboard locking function after write operation is completed"
1603 };
1604
1605 static const struct true_false_string tn5250_field_wts_flag3_5 = {
1606         "Enables audible alarm after write operation is completed",
1607         "Does not enable audible alarm after write operation is completed"
1608 };
1609
1610 static const struct true_false_string tn5250_field_wts_flag3_6 = {
1611         "Resets Message Waiting indicator after write operation is completed",
1612         "Does not reset Message Waiting indicator after write operation is completed"
1613 };
1614
1615 static const struct true_false_string tn5250_field_wts_flag3_7 = {
1616         "Sets Message Waiting indicator after write operation is completed",
1617         "Does not set Message Waiting indicator after write operation is completed"
1618 };
1619
1620       /*  Structure of the WRITE TEXT SCREEN Command Line Data */
1621 static const struct true_false_string tn5250_field_wts_cld_flag1_0 = {
1622         "Writes nulls to the line before writing data",
1623         "Does not write nulls to the line before writing data"
1624 };
1625
1626 static const struct true_false_string tn5250_field_wts_cld_flag1_1 = {
1627         "Inhibits changes to text on this line",
1628         "Does not inhibit changes to text on this line"
1629 };
1630
1631 static const struct true_false_string tn5250_field_wts_cld_flag1_2 = {
1632         "Inhibits all input functions on this line",
1633         "Does not inhibit all input functions on this line"
1634 };
1635
1636 static const struct true_false_string tn5250_field_wts_cld_flag1_3 = {
1637         "Indicates that this line has been modified by the operator",
1638         "Indicates that this line has not been modified by the operator"
1639 };
1640
1641 static const struct true_false_string tn5250_field_wts_cld_flag1_4 = {
1642         "Indicates that the text body has been modified",
1643         "Indicates that the text body has not been modified"
1644 };
1645
1646 static const struct true_false_string tn5250_field_wts_cld_flag1_5 = {
1647         "Inhibits the word spill function on this line",
1648         "Does not inhibit the word spill function on this line"
1649 };
1650
1651 static const struct true_false_string tn5250_field_wts_cld_flag1_6 = {
1652         "Spills the last word on this line to the next line",
1653         "Does not spill the last word on this line to the next line"
1654 };
1655
1656 static const struct true_false_string tn5250_field_wts_cld_flag1_7 = {
1657         "Invalid Use of Reserved Field",
1658         "Reserved"
1659 };
1660
1661 static const struct true_false_string tn5250_field_wts_cld_flag2_0 = {
1662         "Indicates that this row contains formatted text",
1663         "Indicates that this row does not contain formatted text"
1664 };
1665
1666 static const struct true_false_string tn5250_field_wts_cld_flag2_1 = {
1667         "Indicates that a required tab character exists left of absolute left margin",
1668         "Indicates that a required tab character does not exist left of absolute left margin"
1669 };
1670
1671 static const struct true_false_string tn5250_field_wts_cld_flag2_2 = {
1672         "Indicates that a tab character exists left of absolute left margin",
1673         "Indicates that a tab character does not exist left of absolute left margin"
1674 };
1675
1676 static const struct true_false_string tn5250_field_wts_cld_flag2_3 = {
1677         "Indicates that a required tab character exists right of absolute right margin",
1678         "Indicates that a required tab character does not exist right of absolute right margin"
1679 };
1680
1681 static const struct true_false_string tn5250_field_wts_cld_flag2_4 = {
1682         "Indicates that a tab character exists right of absolute right margin",
1683         "Indicates that a tab character does not exist right of absolute right margin"
1684 };
1685
1686 static const struct true_false_string tn5250_field_wts_cld_flag3_0 = {
1687         "Indicates that line orientation is right to left",
1688         "Indicates that line orientation is not right to left"
1689 };
1690
1691 static const struct true_false_string tn5250_field_wts_cld_flag3_1 = {
1692         "Indicates that 'begin reverse' exists to the left of left margin",
1693         "Indicates that 'begin reverse' is not to the left of left margin"
1694 };
1695
1696 static const struct true_false_string tn5250_field_wts_cld_flag3_2 = {
1697         "Indicates that 'end reverse' exists to the right of right margin",
1698         "Indicates that 'end reverse' is not to the right of right margin"
1699 };
1700
1701 static const struct true_false_string tn5250_field_wts_cld_flag3_3 = {
1702         "Invalid Use of Reserved Field",
1703         "Reserved"
1704 };
1705
1706 static const struct true_false_string tn5250_field_wts_cld_flag3_4 = {
1707         "Indicates that a primary attribute exists on the line",
1708         "Indicates that a primary attribute does not exist on the line"
1709 };
1710
1711 static const struct true_false_string tn5250_field_wts_cld_flag3_5 = {
1712         "Indicates that an end attribute exists one position to the right of right margin",
1713         "Indicates that an end attribute does not exist one position to the right of right margin"
1714 };
1715
1716 static const struct true_false_string tn5250_field_wts_cld_flag3_6 = {
1717         "Indicates that one or more word underscore control characters (X'1D') exist on the line",
1718         "Indicates that one or more word underscore control characters (X'1D') do not exist on the line"
1719 };
1720
1721 static const struct true_false_string tn5250_field_wts_cld_flag3_7 = {
1722         "Indicates that one or more half index up or half index down text attributes exist on the line",
1723         "Indicates that one or more half index up or half index down text attributes do not exist on the line"
1724 };
1725
1726 /* 15.27.4.10 DEFINE OPERATOR ERROR MESSAGES Command */
1727
1728 static const range_string vals_tn5250_dorm_id[] = {
1729     { 0x00,  0x7F, "Indicates update of primary operator error message table is necessary."},
1730     { 0x80,  0xFE, "Indicates update of secondary operator error message table is necessary."},
1731     { 0xFF,  0xFF, "Indicates the value of the ID bytes set by the 5494 when the table is built initially."},
1732     { 0,  0,      NULL}
1733 };
1734
1735 static const range_string vals_tn5250_dorm_length[] = {
1736     { 0x00, 0x02, "Length of Table Entry is Invalid (should between 3 and 82)" },
1737     { 0x03, 0x53, "Length of Table Entry" },
1738     { 0x54, 0xFF, "Length of Table Entry is Invalid (should between 3 and 82)" },
1739     { 0,  0,      NULL}
1740 };
1741
1742 /* 15.27.4.11 DEFINE PITCH TABLE Command */
1743
1744 static const range_string vals_tn5250_dpt_id[] = {
1745     { 0x00,  0x7F, "Indicates update of primary pitch table is necessary."},
1746     { 0x80,  0xFE, "Indicates update of secondary pitch table is necessary."},
1747     { 0xFF,  0xFF, "Indicates the value of the ID bytes set by the 5494 when the table is built initially."},
1748     { 0,  0,      NULL}
1749 };
1750
1751 /* 15.27.4.12 DEFINE FAKE DP COMMAND KEY FUNCTION Command */
1752 #define TOP_ROW_COMMAND_KEYS    0x40
1753 #define CORE_AREA_COMMAND_KEYS  0x80
1754
1755 static const range_string vals_tn5250_dfdpck_data_field[] = {
1756     { 0x00,  0x40, "Invalid Data Field Type"},
1757     { 0x40,  0x40, "Top Row Command Key Functions"},
1758     { 0x41,  0x79, "Invalid Data Field Type"},
1759     { 0x80,  0x80, "Core Area Key Command Functions"},
1760     { 0x81,  0xFF, "Invalid Data Field Type"},
1761     { 0,  0,      NULL}
1762 };
1763
1764   /* Structure of the DEFINE FAKE DP COMMAND KEY FUNCTION Core Area Command Keys */
1765
1766 static const struct true_false_string tn5250_field_dfdpck_coreflag_0 = {
1767         "Typing Cmd u (begin underscore) causes the operator error '77'.",
1768         ""
1769 };
1770
1771 static const struct true_false_string tn5250_field_dfdpck_coreflag_1 = {
1772         "Typing Cmd j (end attribute) causes the operator error '77'.",
1773         ""
1774 };
1775
1776 static const struct true_false_string tn5250_field_dfdpck_coreflag_2 = {
1777         "Typing Cmd b (begin bold) causes the operator error '77'.",
1778         ""
1779 };
1780
1781 static const struct true_false_string tn5250_field_dfdpck_coreflag_3 = {
1782         "Typing Cmd w (word underscore) causes the operator error '77'.",
1783         ""
1784 };
1785
1786 static const struct true_false_string tn5250_field_dfdpck_coreflag_4 = {
1787         "Typing Cmd y (half-index-up) causes the operator error '77'.",
1788         ""
1789 };
1790
1791 static const struct true_false_string tn5250_field_dfdpck_coreflag_5 = {
1792         "Typing Cmd h (half-index-down) causes the operator error '77'.",
1793         ""
1794 };
1795
1796 static const struct true_false_string tn5250_field_dfdpck_coreflag_6 = {
1797         "Typing Cmd s (stop code) causes the operator error '77'.",
1798         ""
1799 };
1800
1801 static const struct true_false_string tn5250_field_dfdpck_coreflag_7 = {
1802         "Typing Cmd space (requiredspace) causes the operator error '77'.",
1803         ""
1804 };
1805
1806   /* Structure of the DEFINE FAKE DP COMMAND KEY FUNCTION Top Row Command Keys */
1807 static const struct true_false_string tn5250_field_dfdpck_toprowflag1_0 = {
1808         "Typing PFA1 causes the operator error '77'.",
1809         ""
1810 };
1811
1812 static const struct true_false_string tn5250_field_dfdpck_toprowflag1_1 = {
1813         "Typing PFA2 causes the operator error '77'.",
1814         ""
1815 };
1816
1817 static const struct true_false_string tn5250_field_dfdpck_toprowflag1_2 = {
1818         "Typing PFA3 causes the operator error '77'.",
1819         ""
1820 };
1821
1822 static const struct true_false_string tn5250_field_dfdpck_toprowflag1_3 = {
1823         "Typing PFA4 causes the operator error '77'.",
1824         ""
1825 };
1826
1827 static const struct true_false_string tn5250_field_dfdpck_toprowflag1_4 = {
1828         "Typing PFA5 causes the operator error '77'.",
1829         ""
1830 };
1831
1832 static const struct true_false_string tn5250_field_dfdpck_toprowflag1_5 = {
1833         "Typing PFA6 causes the operator error '77'.",
1834         ""
1835 };
1836
1837 static const struct true_false_string tn5250_field_dfdpck_toprowflag1_6 = {
1838         "Typing PFA7 causes the operator error '77'.",
1839         ""
1840 };
1841
1842 static const struct true_false_string tn5250_field_dfdpck_toprowflag1_7 = {
1843         "Typing PFA8 causes the operator error '77'.",
1844         ""
1845 };
1846
1847 static const struct true_false_string tn5250_field_dfdpck_toprowflag2_0 = {
1848         "Typing PFA9 causes the operator error '77'.",
1849         ""
1850 };
1851
1852 static const struct true_false_string tn5250_field_dfdpck_toprowflag2_1 = {
1853         "Typing PFA10 causes the operator error '77'.",
1854         ""
1855 };
1856
1857 static const struct true_false_string tn5250_field_dfdpck_toprowflag2_2 = {
1858         "Typing PFA11 causes the operator error '77'.",
1859         ""
1860 };
1861
1862 static const struct true_false_string tn5250_field_dfdpck_toprowflag2_3 = {
1863         "Typing PFA12 causes the operator error '77'.",
1864         ""
1865 };
1866
1867 static const struct true_false_string tn5250_field_dfdpck_toprowflag2_4 = {
1868         "Typing PFA13 causes the operator error '77'.",
1869         ""
1870 };
1871
1872 static const struct true_false_string tn5250_field_dfdpck_toprowflag2_5 = {
1873         "Typing PFA14 causes the operator error '77'.",
1874         ""
1875 };
1876
1877 static const struct true_false_string tn5250_field_dfdpck_toprowflag2_6 = {
1878         "Typing PFA15 causes the operator error '77'.",
1879         ""
1880 };
1881
1882 static const struct true_false_string tn5250_field_dfdpck_toprowflag2_7 = {
1883         "Typing PFA16 causes the operator error '77'.",
1884         ""
1885 };
1886
1887 static const struct true_false_string tn5250_field_dfdpck_toprowflag3_0 = {
1888         "Typing PFA17 causes the operator error '77'.",
1889         ""
1890 };
1891
1892 static const struct true_false_string tn5250_field_dfdpck_toprowflag3_1 = {
1893         "Typing PFA18 causes the operator error '77'.",
1894         ""
1895 };
1896
1897 static const struct true_false_string tn5250_field_dfdpck_toprowflag3_2 = {
1898         "Typing PFA19 causes the operator error '77'.",
1899         ""
1900 };
1901
1902 static const struct true_false_string tn5250_field_dfdpck_toprowflag3_3 = {
1903         "Typing PFA20 causes the operator error '77'.",
1904         ""
1905 };
1906
1907 static const struct true_false_string tn5250_field_dfdpck_toprowflag3_4 = {
1908         "Typing PFA21 causes the operator error '77'.",
1909         ""
1910 };
1911
1912 static const struct true_false_string tn5250_field_dfdpck_toprowflag3_5 = {
1913         "Typing PFA22 causes the operator error '77'.",
1914         ""
1915 };
1916
1917 static const struct true_false_string tn5250_field_dfdpck_toprowflag3_6 = {
1918         "Typing PFA23 causes the operator error '77'.",
1919         ""
1920 };
1921
1922 static const struct true_false_string tn5250_field_dfdpck_toprowflag3_7 = {
1923         "Typing PFA24 causes the operator error '77'.",
1924         ""
1925 };
1926
1927 /* 16.2.1 - AID Codes */
1928 #define AID_CLEAR                                  0xBD
1929 #define AID_ENTER_OR_RECORD_ADV                    0xF1
1930 #define AID_HELP                                   0xF3
1931 #define AID_ROLL_DOWN                              0xF4
1932 #define AID_ROLL_UP                                0xF5
1933 #define AID_ROLL_LEFT                              0xD9
1934 #define AID_ROLL_RIGHT                             0xDA
1935 #define AID_PRINT                                  0xF6
1936 #define AID_RECORD_BACKSPACE                       0xF8
1937 #define AID_SLP_AUTO_ENTER                         0x3F
1938 #define AID_FORWARD_EDGE_TRIGGER_AUTO__ENTER       0x50
1939 #define AID_PA1                                    0x6C
1940 #define AID_PA2                                    0x6E
1941 #define AID_PA3                                    0x6B
1942 #define AID_CMD_01                                 0x31
1943 #define AID_CMD_02                                 0x32
1944 #define AID_CMD_03                                 0x33
1945 #define AID_CMD_04                                 0x34
1946 #define AID_CMD_05                                 0x35
1947 #define AID_CMD_06                                 0x36
1948 #define AID_CMD_07                                 0x37
1949 #define AID_CMD_08                                 0x38
1950 #define AID_CMD_09                                 0x39
1951 #define AID_CMD_10                                 0x3A
1952 #define AID_CMD_11                                 0x3B
1953 #define AID_CMD_12                                 0x3C
1954 #define AID_CMD_13                                 0xB1
1955 #define AID_CMD_14                                 0xB2
1956 #define AID_CMD_15                                 0xB3
1957 #define AID_CMD_16                                 0xB4
1958 #define AID_CMD_17                                 0xB5
1959 #define AID_CMD_18                                 0xB6
1960 #define AID_CMD_19                                 0xB7
1961 #define AID_CMD_20                                 0xB8
1962 #define AID_CMD_21                                 0xB9
1963 #define AID_CMD_22                                 0xBA
1964 #define AID_CMD_23                                 0xBB
1965 #define AID_CMD_24                                 0xBC
1966 #define AID_INBOUND_WRITE_STRUCTURED_FIELD         0x88
1967 #define AID_PASS_THROUGH_RESPONSE                  0xFF
1968 #define AID_IMAGE_FAX_REQUEST                      0x81
1969 #define AID_UNKNOWN_IMAGE_FAX_FORMAT               0x82
1970 #define AID_IMAGE_FAX_ERROR                        0x83
1971
1972 static const range_string vals_tn5250_attention_identification_bytes[] = {
1973     { AID_CLEAR                            ,  AID_CLEAR                            , "Clear"},
1974     { AID_ENTER_OR_RECORD_ADV              ,  AID_ENTER_OR_RECORD_ADV              , "Enter or Record Adv"},
1975     { AID_HELP                             ,  AID_HELP                             , "Help"},
1976     { AID_ROLL_DOWN                        ,  AID_ROLL_DOWN                        , "Roll Down"},
1977     { AID_ROLL_UP                          ,  AID_ROLL_UP                          , "Roll Up"},
1978     { AID_ROLL_LEFT                        ,  AID_ROLL_LEFT                        , "Roll Left"},
1979     { AID_ROLL_RIGHT                       ,  AID_ROLL_RIGHT                       , "Roll Right"},
1980     { AID_PRINT                            ,  AID_PRINT                            , "Print"},
1981     { AID_RECORD_BACKSPACE                 ,  AID_RECORD_BACKSPACE                 , "Record Backspace"},
1982     { AID_SLP_AUTO_ENTER                   ,  AID_SLP_AUTO_ENTER                   , "SLP Auto Enter"},
1983     { AID_FORWARD_EDGE_TRIGGER_AUTO__ENTER ,  AID_FORWARD_EDGE_TRIGGER_AUTO__ENTER , "Forward Edge Trigger Auto  Enter"},
1984     { AID_PA1                              ,  AID_PA1                              , "PA1"},
1985     { AID_PA2                              ,  AID_PA2                              , "PA2"},
1986     { AID_PA3                              ,  AID_PA3                              , "PA3"},
1987     { AID_CMD_01                           ,  AID_CMD_01                           , "Cmd 01"},
1988     { AID_CMD_02                           ,  AID_CMD_02                           , "Cmd 02"},
1989     { AID_CMD_03                           ,  AID_CMD_03                           , "Cmd 03"},
1990     { AID_CMD_04                           ,  AID_CMD_04                           , "Cmd 04"},
1991     { AID_CMD_05                           ,  AID_CMD_05                           , "Cmd 05"},
1992     { AID_CMD_06                           ,  AID_CMD_06                           , "Cmd 06"},
1993     { AID_CMD_07                           ,  AID_CMD_07                           , "Cmd 07"},
1994     { AID_CMD_08                           ,  AID_CMD_08                           , "Cmd 08"},
1995     { AID_CMD_09                           ,  AID_CMD_09                           , "Cmd 09"},
1996     { AID_CMD_10                           ,  AID_CMD_10                           , "Cmd 10"},
1997     { AID_CMD_11                           ,  AID_CMD_11                           , "Cmd 11"},
1998     { AID_CMD_12                           ,  AID_CMD_12                           , "Cmd 12"},
1999     { AID_CMD_13                           ,  AID_CMD_13                           , "Cmd 13"},
2000     { AID_CMD_14                           ,  AID_CMD_14                           , "Cmd 14"},
2001     { AID_CMD_15                           ,  AID_CMD_15                           , "Cmd 15"},
2002     { AID_CMD_16                           ,  AID_CMD_16                           , "Cmd 16"},
2003     { AID_CMD_17                           ,  AID_CMD_17                           , "Cmd 17"},
2004     { AID_CMD_18                           ,  AID_CMD_18                           , "Cmd 18"},
2005     { AID_CMD_19                           ,  AID_CMD_19                           , "Cmd 19"},
2006     { AID_CMD_20                           ,  AID_CMD_20                           , "Cmd 20"},
2007     { AID_CMD_21                           ,  AID_CMD_21                           , "Cmd 21"},
2008     { AID_CMD_22                           ,  AID_CMD_22                           , "Cmd 22"},
2009     { AID_CMD_23                           ,  AID_CMD_23                           , "Cmd 23"},
2010     { AID_CMD_24                           ,  AID_CMD_24                           , "Cmd 24"},
2011     { 0x70                                 ,  0x7F                                 , "Application Use"},
2012     { AID_INBOUND_WRITE_STRUCTURED_FIELD   ,  AID_INBOUND_WRITE_STRUCTURED_FIELD  , "AID Inbound Write Structured Field"},
2013     { AID_IMAGE_FAX_REQUEST                ,  AID_IMAGE_FAX_REQUEST          , "Image/Fax Request Aid"},
2014     { AID_UNKNOWN_IMAGE_FAX_FORMAT         ,  AID_UNKNOWN_IMAGE_FAX_FORMAT   , "Unknown Image/Fax Format Aid"},
2015     { AID_IMAGE_FAX_ERROR                  ,  AID_IMAGE_FAX_ERROR            , " Image/Fax Error Reporting Aid"},
2016     { 0x00,  0x00,      NULL}
2017 };
2018
2019
2020 /*TN5250 - RFC1205 - Query Reply Fields */
2021 static const struct true_false_string tn5250_field_qr_flag_0 = {
2022         "Query Reply",
2023         ""
2024 };
2025
2026 static const value_string vals_tn5250_chc[] = {
2027         { 0x0001,  "Local Twinax Controller"},
2028         { 0x0061,  "Local ASCII Controller"},
2029         { 0x0101,  "SDLC/X.21/X.25 Twinax Controller (5394 emulating a 5294)"},
2030         { 0x0103,  "SDLC/X.21/X.25 Twinax Controller (5394)"},
2031         { 0x0200,  "PC DOS non-DBCS WSF"},
2032         { 0x0300,  "OS/2 non-DBCS WSF"},
2033         { 0x0400,  "PC DOS DBCS WSF"},
2034         { 0x0500,  "OS/2 DBCS WSF"},
2035         { 0x0600,  "Other WSF or any other 5250 Emulator"},
2036         { 0x00, NULL }
2037 };
2038
2039 static const value_string vals_tn5250_dt[] = {
2040         { 0x01,  "5250 Display or 5250 Emulation"},
2041         { 0x02,  "Printer"},
2042         { 0x00, NULL }
2043 };
2044
2045 static const value_string vals_tn5250_qr_ki[] = {
2046         { 0x02,  "Standard Keyboard"},
2047         { 0x82,  "G Keyboard"},
2048         { 0x00, NULL }
2049 };
2050
2051 static const struct true_false_string tn5250_field_qr_flag1_1 = {
2052         "Row 1/Col 1 support",
2053         "No Row 1/Col 1 support"
2054 };
2055
2056 static const struct true_false_string tn5250_field_qr_flag1_2 = {
2057         "Read MDT Alternate Command support",
2058         "No Read MDT Alternate Command support"
2059 };
2060
2061 static const struct true_false_string tn5250_field_qr_flag1_3 = {
2062         "Display does have PA1/PA2 support",
2063         "Display does not have PA1/PA2 support"
2064 };
2065
2066 static const struct true_false_string tn5250_field_qr_flag1_4 = {
2067         "Display does have PA3 support",
2068         "Display does not have PA3 support"
2069 };
2070
2071 static const struct true_false_string tn5250_field_qr_flag1_5 = {
2072         "Display does have Cursor Select support",
2073         "Display does not have Cursor Select support"
2074 };
2075
2076 static const struct true_false_string tn5250_field_qr_flag1_6 = {
2077         "Display does have Move Cursor Order support",
2078         "Display does not have Move Cursor Order support"
2079 };
2080
2081 static const struct true_false_string tn5250_field_qr_flag1_7 = {
2082         "Read MDT Immediate Alt Command support",
2083         "No Read MDT Immediate Alt Command support"
2084 };
2085
2086 static const value_string vals_tn5250_qr_flag2_0to3[] = {
2087         { 0x10,  "24 x 80 Screen Size"},
2088         { 0x30,  "Capable of 24 x 80 and 27 x 132"},
2089         { 0x00, NULL }
2090 };
2091
2092 static const struct true_false_string tn5250_field_qr_flag2_4 = {
2093         "Light pen support",
2094         "No Light pen support"
2095 };
2096
2097 static const struct true_false_string tn5250_field_qr_flag2_5 = {
2098         "Mag Stripe Reader support",
2099         "No Mag Stripe Reader support"
2100 };
2101
2102 static const value_string vals_tn5250_qr_flag2_6to7[] = {
2103         { 0x00,  "Mono display"},
2104         { 0x01,  "5292/3179 style color, including color PCs"},
2105         { 0x00, NULL }
2106 };
2107
2108 static const value_string vals_tn5250_qr_flag3[] = {
2109         { 0x00,  "No Double Byte Character Set (DBCS) capability"},
2110         { 0x20,  "Presentation screen DBCS capability only"},
2111         { 0x00, NULL }
2112 };
2113
2114 static const value_string vals_tn5250_qr_flag4[] = {
2115         { 0x00,  "No graphics capability"},
2116         { 0x20,  "5292-2 style graphics"},
2117         { 0x00, NULL }
2118 };
2119
2120
2121
2122
2123
2124
2125
2126
2127 /* TN5250 Header - Data Type */
2128 #define TN5250_5250_DATA        0x00
2129 #define TN5250_BIND_IMAGE       0x03
2130 #define TN5250_NVT_DATA         0x05
2131 #define TN5250_REQUEST          0x06
2132 #define TN5250_RESPONSE         0x02
2133 #define TN5250_SCS_DATA         0x01
2134 #define TN5250_SSCP_LU_DATA     0x07
2135 #define TN5250_UNBIND           0x04
2136
2137 static const value_string vals_tn5250_header_data_types[] = {
2138         { TN5250_5250_DATA   ,  "5250_DATA"},
2139         { TN5250_BIND_IMAGE  ,  "BIND_IMAGE"},
2140         { TN5250_NVT_DATA    ,  "NVT_DATA"},
2141         { TN5250_REQUEST     ,  "REQUEST"},
2142         { TN5250_RESPONSE    ,  "RESPONSE"},
2143         { TN5250_SCS_DATA    ,  "SCS_DATA"},
2144         { TN5250_SSCP_LU_DATA,  "SSCP_LU_DATA"},
2145         { TN5250_UNBIND      ,  "UNBIND"},
2146         { 0x00, NULL }
2147 };
2148
2149
2150 /* TN5250 Header - Record Type */
2151 #define GDS        0x12A0
2152
2153 static const value_string vals_tn5250_sna_record_type[] = {
2154         { GDS   ,  "General Data Stream"},
2155         { 0x00, NULL }
2156 };
2157
2158 /* TN5250 Header - Operation Code */
2159 #define NO_OPERATION                        0x00
2160 #define INVITE_OPERATION                    0x01
2161 #define OUTPUT_ONLY                         0x02
2162 #define PUT_GET_OPERATION                   0x03
2163 #define SAVE_SCREEN_OPERATION               0x04
2164 #define RESTORE_SCREEN_OPERATION            0x05
2165 #define READ_IMMEDIATE_OPERATION            0x06
2166 #define RESERVED1                           0x07
2167 #define READ_SCREEN_OPERATION               0x08
2168 #define RESERVED2                           0x09
2169 #define CANCEL_INVITE_OPERATION             0x0A
2170 #define TURN_ON_MESSAGE_LIGHT               0x0B
2171 #define TURN_OFF_MESSAGE_LIGHT              0x0C
2172
2173 static const value_string vals_tn5250_header_operation_code[] = {
2174         { NO_OPERATION            ,  "No Operation"},
2175         { INVITE_OPERATION        ,  "Invite Operation"},
2176         { OUTPUT_ONLY             ,  "Output Only"},
2177         { PUT_GET_OPERATION       ,  "Put or Get Operation"},
2178         { SAVE_SCREEN_OPERATION   ,  "Save Screen Operation"},
2179         { RESTORE_SCREEN_OPERATION,  "Restore Screen Operation"},
2180         { READ_IMMEDIATE_OPERATION,  "Read Immediate Operation"},
2181         { RESERVED1               ,  "Reserved"},
2182         { READ_SCREEN_OPERATION   ,  "Read Screen Operation"},
2183         { RESERVED2               ,  "Reserved"},
2184         { CANCEL_INVITE_OPERATION ,  "Cancel Invite Operation"},
2185         { TURN_ON_MESSAGE_LIGHT   ,  "Turn On Message Light"},
2186         { TURN_OFF_MESSAGE_LIGHT  ,  "Turn Off Message Light"},
2187         { 0x00, NULL }
2188 };
2189
2190 /* TN5250 Header _ Response Flags - Data Type Response */
2191 #define TN5250_POSITIVE_RESPONSE   0x00
2192 #define TN5250_NEGATIVE_RESPONSE   0x01
2193
2194 static const value_string vals_tn5250_header_response_flags_response[] = {
2195         { TN5250_POSITIVE_RESPONSE,  "POSITIVE-RESPONSE"},
2196         { TN5250_NEGATIVE_RESPONSE,  "NEGATIVE-RESPONSE"},
2197         { 0x00, NULL }
2198 };
2199
2200
2201 static const value_string vals_tn5250_header_error_codes[] = {
2202     { 0x0000,  "Help key not allowed."},
2203     { 0x0001,  "Keyboard overrun."},
2204     { 0x0002,  "Incorrect scan code."},
2205     { 0x0003,  "Command or PF key not valid."},
2206     { 0x0004,  "Data not allowed in this field."},
2207     { 0x0005,  "Cursor in protected area of display."},
2208     { 0x0006,  "Key following Sys Req Key is not valid."},
2209     { 0x0007,  "Mandatory entry field; you must enter data."},
2210     { 0x0008,  "This field must have alphabetic characters."},
2211     { 0x0009,  "This field must have numeric characters."},
2212     { 0x0010,  "Only characters 0 through 9 allowed."},
2213     { 0x0011,  "You tried to enter data into the last position of a signed numeric field."},
2214     { 0x0012,  "Insert mode; no room to insert data."},
2215     { 0x0013,  "Insert mode; only data keys permitted."},
2216     { 0x0014,  "Must fill field to exit."},
2217     { 0x0015,  "Modulo 10 or 11 check digit error. You entered data into a self-check field, and the number you entered and the check digit do not compare."},
2218     { 0x0016,  "Field- not valid in this field."},
2219     { 0x0017,  "Mandatory-fill field; key pressed is not valid."},
2220     { 0x0018,  "Key used to exit this field not valid."},
2221     { 0x0019,  "Dup or Field Mark not permitted in this field."},
2222     { 0x0020,  "Function key not valid for right-adjust field."},
2223     { 0x0021,  "Must enter data in mandatory entry field."},
2224     { 0x0022,  "An AS/400 system error occurred. The status of the current field is not known. This error can occur during an insert or delete operation."},
2225     { 0x0023,  "Hexadecimal mode; entry not valid."},
2226     { 0x0024,  "Decimal field; entry not valid."},
2227     { 0x0026,  "Field- entry not allowed."},
2228     { 0x0027,  "Cannot use undefined key."},
2229     { 0x0029,  "Diacritic character not valid."},
2230     { 0x0031,  "Data buffer overflow."},
2231     { 0x0032,  "MSR error."},
2232     { 0x0033,  "MSR data not authorized."},
2233     { 0x0034,  "Magnetic stripe reader (MSR) data exceeds length of field."},
2234     { 0x0035,  "MSR error."},
2235     { 0x0036,  "Cursor select not allowed in field exit required state."},
2236     { 0x0037,  "You pressed Cursor Select in a non-selectable field."},
2237     { 0x0038,  "Light pen and magnetic stripe reader (MSR) not allowed."},
2238     { 0x0040,  "The modem or data circuit-terminating equipment (DCE) is not ready for one of the following reasons:"},
2239     { 0x0041,  "X.25: Idle condition has been detected. The receive line was idle for 15 or more contiguous bit-times."},
2240     { 0x0042,  "The receive clock signal is not being received from the modem or data circuit-terminating equipment (DCE)."},
2241     { 0x0043,  "The 5494 attempted to disconnect from the line, but the data set ready (DSR) signal was not deactivated by the modem or DCE."},
2242     { 0x0044,  "Switched lines: This error indicates that no valid data has been received for 30 seconds. The 5494 disconnected the line."},
2243     { 0x0045,  "X.25: The data circuit-terminating equipment (DCE) will not activate. Either a Disconnect mode (DM) or a Disconnect (DISC) command was received during the link setup sequence."},
2244     { 0x0046,  "X.25 or LAN: Frame reject received. The 5494 received a frame reject (FRMR) from the network, indicating that an error was detected in the last frame transmitted."},
2245     { 0x0047,  "X.25 or LAN: An unexpected Disconnect mode (DM) or a Disconnect (DISC) command was received while in information transfer state."},
2246     { 0x0048,  "X.25: An unexpected unnumbered acknowledgment (UA) frame was received."},
2247     { 0x0049,  "LAN: A set asynchronous balance mode extended (SABME) was received while the 5494 was in information transfer state."},
2248     { 0x0050,  "Error in ready-for-sending (RFS) signal, also known as the clear-to-send (CTS) signal, received from the modem or data circuit-terminating equipment (DCE). This error is posted when one of the following has occurred:"},
2249     { 0x0051,  "The transmit clock from the modem or data circuit-terminating equipment (DCE) failed during a transmit operation."},
2250     { 0x0052,  "The link adapter hardware failed to complete a transmit operation within 30 seconds, but no transmit clock or other modem or data circuit-terminating equipment (DCE) signal failure was detected."},
2251     { 0x0053,  "X.25: The retry count has expired. No acknowledgment of a transmission was received within the allowed timeout. Timeout retry count (N2) and retry interval (T1) are specified in the 5494 configuration."},
2252     { 0x0054,  "Frame reject (FRMR) sent. The 5494 sent a link-level FRMR response to the AS/400 system after receiving a data link control (DLC) or link access protocol balanced (LAPB) command that is not valid. Sense bytes S1, S2, and S3 preserve the contents of the FRMR I-field."},
2253     { 0x0055,  "The 5494 ran a cable wrap test and determined that the communication cable is not attached to the 5494."},
2254     { 0x0056,  "The link between the AS/400 system and the 5494 was lost. A bridge failure occurred, the AS/400 system has varied off line, or a node in an SNA Subarea network has failed."},
2255     { 0x0060,  "Ideographic support SRC: You attempted to enter alphanumeric data into a field that accepts only double-byte data characters."},
2256     { 0x0061,  "Ideographic support SRC: You attempted to enter a double-byte character into a field that accepts only alphanumeric data."},
2257     { 0x0062,  "You attempted to change the data type, but the cursor is not in an open field or in the first position of an ideographic either field."},
2258     { 0x0063,  "You entered an ideographic character that is not valid while operating in Alternate Entry mode."},
2259     { 0x0064,  "You pressed a key that is not valid for the current keyboard mode."},
2260     { 0x0065,  "The cursor is positioned in a column reserved for shift-out or shift-in characters."},
2261     { 0x0066,  "Repeat key not valid. The cursor is positioned under a shift character or attribute character, or at the first valid entry character position of an input field. Only data characters can be repeated at these positions."},
2262     { 0x0067,  "The workstation extension character RAM is full. Any additional extension characters display as special default characters."},
2263     { 0x0068,  "The output data stream to the 5494 is not valid for extension characters. Any additional extension characters display as special default characters."},
2264     { 0x0069,  "Ideographic support SRC: The output data stream to the 5494 contains extension characters that are not valid or are undefined. Any additional extension characters display as special default characters."},
2265     { 0x0070,  "An error occurred during the word spill function or the carriage return function."},
2266     { 0x0071,  "You attempted a start copy, move, or delete text operation while one of the previous operations was already in progress."},
2267     { 0x0072,  "The key pressed is not valid when the cursor is in the current position."},
2268     { 0x0073,  "An attempt was made to delete or replace an instruction or format change when the general prompt function was not active."},
2269     { 0x0074,  "A key was pressed that is not valid when using the general prompt function."},
2270     { 0x0075,  "The find function failed to find the keyed characters."},
2271     { 0x0076,  "The insert function failed because the AS/400 system has not processed the text on the screen."},
2272     { 0x0077,  "You either pressed a function key that is not valid at this time or tried to use a 5250 keyboard function while in word-processing mode."},
2273     { 0x0078,  "The required scale line is not defined for your workstation. There is an error in the application program."},
2274     { 0x0081,  "Too many workstations are attached to the 5494. The 5494 with LAN adapter installed allows a maximum of 80 devices."},
2275     { 0x0082,  "Keyboard function is not valid within a selection field. These invalid functions include Dup, Erase EOF, and Field Mark."},
2276     { 0x0083,  "A selection character is not valid. The numeric or mnemonic character you entered is not associated with any of the choices defined within the current selection field."},
2277     { 0x0084,  "An attempt has been made to select an unavailable selection field."},
2278     { 0x0087,  "X.25: A flow control entry error has occurred. The 5494 configuration settings for Flow Control Negotiation and Manual Options Allowed are not compatible. If the configuration setting for Flow Control Negotiation is permitted, then Manual Options must be allowed."},
2279     { 0x0089,  "One or more fields required for the operation of the 5494 are blank. When you press Enter, the 5494 checks for blank fields and moves the cursor to the first blank."},
2280     { 0x008A,  "One or more fields contain an embedded blank. When you press Enter, the 5494 checks for embedded blanks and moves the cursor to the first embedded blank."},
2281     { 0x008B,  "Too many different keyboard codes have been used. A maximum of 4 different keyboard codes can be selected (the master country and 3 others)."},
2282     { 0x008D,  "Printer port and station values are not valid. Valid ports for the Twinaxial Expansion Kit are 4-7. Valid stations are 0-7."},
2283     { 0x008E,  "One or more fields contain an insufficient number of characters. The cursor is positioned in the field that contains an insufficient number of characters."},
2284     { 0x008F,  "One or more fields contain a value that is outside the valid range. The cursor is placed under the first character of the field with a value that is out of range."},
2285     { 0x0091,  "Reverse and Close keys are not supported in a Word Wrap entry field."},
2286     { 0x0092,  "The reverse key is not supported on a display which is configured for shared addressing."},
2287     { 0x0097,  "A test request function is not supported by the AS/400 system."},
2288     { 0x0098,  "Undefined hardware error."},
2289     { 0x0099,  "A key requiring AS/400 system action was pressed, but one of the following has occurred:"},
2290     { 0x009A,  "An invalid password has been entered three times in an attempt to access concurrent diagnostics from a PWS."},
2291     { 0x0170,  "A problem with an attached workstation has been detected. The workstation failed to detect the end of a printer definition table (PDT). Sense data is 00."},
2292     { 0x0172,  "A problem with an attached workstation has been detected. The workstation detected invalid data in a printer definition table (PDT) sent to it from the AS/400 system. The sense data is 00ccxxyyyyyyyy, where cc is the command code of the definition containing invalid data, xx, is the offset from the command to invalid data in bytes, and yyyyyyyy is additional error data."},
2293     { 0x0173,  "A problem with an attached workstation has been detected. The workstation received a printer definition table (PDT) that was larger than its maximum size. Sense data is 00xxxxyyyy, where xxxx is the workstation's maximum PDT size, and yyyy was the size of the PDT sent to the display by the AS/400 system."},
2294     { 0x0176,  "A problem with an attached workstation has been detected. The workstation received a microcode correction file from the AS/400 system that was in error. The sense data defines the error as follows:"},
2295     { 0x0177,  "A problem with an attached workstation has been detected. The workstation received a font file from the AS/400 system that was in error. Sense data defines the error as follows:"},
2296         { 0x0000, NULL }
2297 };
2298
2299 static const range_string vals_tn5250_reserved[] = {
2300     { 0x00,  0x00, "Reserved"},
2301     { 0x01,  0xFE, "Invalid Use of Reserved Field"},
2302     { 0,  0,      NULL}
2303 };
2304
2305
2306 static int proto_tn5250 = -1;
2307 static int hf_tn5250_aid = -1;
2308 static int hf_tn5250_attn_key = -1;
2309 static int hf_tn5250_attribute_type = -1;
2310 static int hf_tn5250_buffer_x = -1;
2311 static int hf_tn5250_buffer_y = -1;
2312 static int hf_tn5250_command_code = -1;
2313 static int hf_tn5250_ctp_lsid = -1;
2314 static int hf_tn5250_ctp_mlpp = -1;
2315 static int hf_tn5250_cua_parm = -1;
2316 static int hf_tn5250_dawt_char = -1;
2317 static int hf_tn5250_dawt_id = -1;
2318 static int hf_tn5250_dawt_length = -1;
2319 static int hf_tn5250_dawt_message = -1;
2320 static int hf_tn5250_dckf_function_code = -1;
2321 static int hf_tn5250_dckf_id = -1;
2322 static int hf_tn5250_dckf_key_code = -1;
2323 static int hf_tn5250_dckf_length = -1;
2324 static int hf_tn5250_dckf_prompt_text = -1;
2325 static int hf_tn5250_dfdpck_coreflag = -1;
2326 static int hf_tn5250_dfdpck_coreflag_0 = -1;
2327 static int hf_tn5250_dfdpck_coreflag_1 = -1;
2328 static int hf_tn5250_dfdpck_coreflag_2 = -1;
2329 static int hf_tn5250_dfdpck_coreflag_3 = -1;
2330 static int hf_tn5250_dfdpck_coreflag_4 = -1;
2331 static int hf_tn5250_dfdpck_coreflag_5 = -1;
2332 static int hf_tn5250_dfdpck_coreflag_6 = -1;
2333 static int hf_tn5250_dfdpck_coreflag_7 = -1;
2334 static int hf_tn5250_dfdpck_data_field = -1;
2335 static int hf_tn5250_dfdpck_partition = -1;
2336 static int hf_tn5250_dfdpck_toprowflag1 = -1;
2337 static int hf_tn5250_dfdpck_toprowflag1_0 = -1;
2338 static int hf_tn5250_dfdpck_toprowflag1_1 = -1;
2339 static int hf_tn5250_dfdpck_toprowflag1_2 = -1;
2340 static int hf_tn5250_dfdpck_toprowflag1_3 = -1;
2341 static int hf_tn5250_dfdpck_toprowflag1_4 = -1;
2342 static int hf_tn5250_dfdpck_toprowflag1_5 = -1;
2343 static int hf_tn5250_dfdpck_toprowflag1_6 = -1;
2344 static int hf_tn5250_dfdpck_toprowflag1_7 = -1;
2345 static int hf_tn5250_dfdpck_toprowflag2 = -1;
2346 static int hf_tn5250_dfdpck_toprowflag2_0 = -1;
2347 static int hf_tn5250_dfdpck_toprowflag2_1 = -1;
2348 static int hf_tn5250_dfdpck_toprowflag2_2 = -1;
2349 static int hf_tn5250_dfdpck_toprowflag2_3 = -1;
2350 static int hf_tn5250_dfdpck_toprowflag2_4 = -1;
2351 static int hf_tn5250_dfdpck_toprowflag2_5 = -1;
2352 static int hf_tn5250_dfdpck_toprowflag2_6 = -1;
2353 static int hf_tn5250_dfdpck_toprowflag2_7 = -1;
2354 static int hf_tn5250_dfdpck_toprowflag3 = -1;
2355 static int hf_tn5250_dfdpck_toprowflag3_0 = -1;
2356 static int hf_tn5250_dfdpck_toprowflag3_1 = -1;
2357 static int hf_tn5250_dfdpck_toprowflag3_2 = -1;
2358 static int hf_tn5250_dfdpck_toprowflag3_3 = -1;
2359 static int hf_tn5250_dfdpck_toprowflag3_4 = -1;
2360 static int hf_tn5250_dfdpck_toprowflag3_5 = -1;
2361 static int hf_tn5250_dfdpck_toprowflag3_6 = -1;
2362 static int hf_tn5250_dfdpck_toprowflag3_7 = -1;
2363 static int hf_tn5250_dorm_ec = -1;
2364 static int hf_tn5250_dorm_id = -1;
2365 static int hf_tn5250_dorm_length = -1;
2366 static int hf_tn5250_dorm_mt = -1;
2367 static int hf_tn5250_dpo_displace_characters = -1;
2368 static int hf_tn5250_dpo_flag1 = -1;
2369 static int hf_tn5250_dpo_flag1_0 = -1;
2370 static int hf_tn5250_dpo_flag1_1 = -1;
2371 static int hf_tn5250_dpo_flag1_2 = -1;
2372 static int hf_tn5250_dpo_flag1_3 = -1;
2373 static int hf_tn5250_dpo_flag1_4 = -1;
2374 static int hf_tn5250_dpo_flag1_5 = -1;
2375 static int hf_tn5250_dpo_flag1_6 = -1;
2376 static int hf_tn5250_dpo_flag1_7 = -1;
2377 static int hf_tn5250_dpo_flag2 = -1;
2378 static int hf_tn5250_dpo_flag2_0 = -1;
2379 static int hf_tn5250_dpo_flag2_reserved = -1;
2380 static int hf_tn5250_dpo_partition = -1;
2381 static int hf_tn5250_dpo_start_location_col = -1;
2382 static int hf_tn5250_dpo_start_location_row = -1;
2383 static int hf_tn5250_dpt_ec = -1;
2384 static int hf_tn5250_dpt_id = -1;
2385 static int hf_tn5250_ds_output_error = -1;
2386 static int hf_tn5250_dsc_ev = -1;
2387 static int hf_tn5250_dsc_partition = -1;
2388 static int hf_tn5250_dsc_sk = -1;
2389 static int hf_tn5250_dsl_flag1 = -1;
2390 static int hf_tn5250_dsl_flag1_0 = -1;
2391 static int hf_tn5250_dsl_flag1_1 = -1;
2392 static int hf_tn5250_dsl_flag1_2 = -1;
2393 static int hf_tn5250_dsl_flag1_reserved = -1;
2394 static int hf_tn5250_dsl_function = -1;
2395 static int hf_tn5250_dsl_id = -1;
2396 static int hf_tn5250_dsl_location = -1;
2397 static int hf_tn5250_dsl_offset = -1;
2398 static int hf_tn5250_dsl_partition = -1;
2399 static int hf_tn5250_dsl_rtl_offset = -1;
2400 static int hf_tn5250_dtsf_first_line = -1;
2401 static int hf_tn5250_dtsf_flag1 = -1;
2402 static int hf_tn5250_dtsf_flag1_0 = -1;
2403 static int hf_tn5250_dtsf_flag1_1 = -1;
2404 static int hf_tn5250_dtsf_flag1_2 = -1;
2405 static int hf_tn5250_dtsf_flag1_3 = -1;
2406 static int hf_tn5250_dtsf_flag1_4 = -1;
2407 static int hf_tn5250_dtsf_flag1_5 = -1;
2408 static int hf_tn5250_dtsf_flag1_6 = -1;
2409 static int hf_tn5250_dtsf_flag1_7 = -1;
2410 static int hf_tn5250_dtsf_flag2 = -1;
2411 static int hf_tn5250_dtsf_flag2_0 = -1;
2412 static int hf_tn5250_dtsf_flag2_1 = -1;
2413 static int hf_tn5250_dtsf_flag2_2 = -1;
2414 static int hf_tn5250_dtsf_flag2_3 = -1;
2415 static int hf_tn5250_dtsf_flag2_4to7 = -1;
2416 static int hf_tn5250_dtsf_line_cmd_field_size = -1;
2417 static int hf_tn5250_dtsf_location_of_pitch = -1;
2418 static int hf_tn5250_dtsf_partition = -1;
2419 static int hf_tn5250_dtsf_text_body_height = -1;
2420 static int hf_tn5250_dtsf_text_body_width = -1;
2421 static int hf_tn5250_soh_err = -1;
2422 static int hf_tn5250_error_code = -1;
2423 static int hf_tn5250_error_state = -1;
2424 static int hf_tn5250_escape_code = -1;
2425 static int hf_tn5250_fa_color = -1;
2426 static int hf_tn5250_fcw = -1;
2427 static int hf_tn5250_ffw = -1;
2428 static int hf_tn5250_ffw_adjust = -1;
2429 static int hf_tn5250_ffw_auto = -1;
2430 static int hf_tn5250_ffw_bypass = -1;
2431 static int hf_tn5250_ffw_dup = -1;
2432 static int hf_tn5250_ffw_fer = -1;
2433 static int hf_tn5250_ffw_id = -1;
2434 static int hf_tn5250_ffw_mdt = -1;
2435 static int hf_tn5250_ffw_me = -1;
2436 static int hf_tn5250_ffw_monocase = -1;
2437 static int hf_tn5250_ffw_res = -1;
2438 static int hf_tn5250_ffw_shift = -1;
2439 static int hf_tn5250_field_data = -1;
2440 static int hf_tn5250_foreground_color_attr = -1;
2441 static int hf_tn5250_header_flags = -1;
2442 static int hf_tn5250_ideographic_attr = -1;
2443 static int hf_tn5250_length = -1;
2444 static int hf_tn5250_length_twobyte = -1;
2445 static int hf_tn5250_logical_record_length = -1;
2446 static int hf_tn5250_operation_code = -1;
2447 static int hf_tn5250_order_code = -1;
2448 static int hf_tn5250_repeated_character = -1;
2449 static int hf_tn5250_reserved = -1;
2450 static int hf_tn5250_roll_bottom_line = -1;
2451 static int hf_tn5250_roll_flag1 = -1;
2452 static int hf_tn5250_roll_flag1_0 = -1;
2453 static int hf_tn5250_roll_flag1_lines = -1;
2454 static int hf_tn5250_roll_flag1_reserved = -1;
2455 static int hf_tn5250_roll_top_line = -1;
2456 static int hf_tn5250_rts_flag1 = -1;
2457 static int hf_tn5250_rts_flag1_0 = -1;
2458 static int hf_tn5250_rts_flag1_reserved = -1;
2459 static int hf_tn5250_rts_partition = -1;
2460 static int hf_tn5250_sf_attr_flag = -1;
2461 static int hf_tn5250_sf_class = -1;
2462 static int hf_tn5250_fa = -1;
2463 static int hf_tn5250_sf_length = -1;
2464 static int hf_tn5250_sf_type = -1;
2465 static int hf_tn5250_sna_record_type = -1;
2466 static int hf_tn5250_soh_cursor_direction = -1;
2467 static int hf_tn5250_soh_flags = -1;
2468 static int hf_tn5250_soh_input_capable_only = -1;
2469 static int hf_tn5250_soh_pf1 = -1;
2470 static int hf_tn5250_soh_pf10 = -1;
2471 static int hf_tn5250_soh_pf11 = -1;
2472 static int hf_tn5250_soh_pf12 = -1;
2473 static int hf_tn5250_soh_pf13 = -1;
2474 static int hf_tn5250_soh_pf14 = -1;
2475 static int hf_tn5250_soh_pf15 = -1;
2476 static int hf_tn5250_soh_pf16 = -1;
2477 static int hf_tn5250_soh_pf16to9 = -1;
2478 static int hf_tn5250_soh_pf17 = -1;
2479 static int hf_tn5250_soh_pf18 = -1;
2480 static int hf_tn5250_soh_pf19 = -1;
2481 static int hf_tn5250_soh_pf2 = -1;
2482 static int hf_tn5250_soh_pf20 = -1;
2483 static int hf_tn5250_soh_pf21 = -1;
2484 static int hf_tn5250_soh_pf22 = -1;
2485 static int hf_tn5250_soh_pf23 = -1;
2486 static int hf_tn5250_soh_pf24 = -1;
2487 static int hf_tn5250_soh_pf24to17 = -1;
2488 static int hf_tn5250_soh_pf3 = -1;
2489 static int hf_tn5250_soh_pf4 = -1;
2490 static int hf_tn5250_soh_pf5 = -1;
2491 static int hf_tn5250_soh_pf6 = -1;
2492 static int hf_tn5250_soh_pf7 = -1;
2493 static int hf_tn5250_soh_pf8 = -1;
2494 static int hf_tn5250_soh_pf8to1 = -1;
2495 static int hf_tn5250_soh_pf9 = -1;
2496 static int hf_tn5250_soh_resq = -1;
2497 static int hf_tn5250_soh_screen_reverse = -1;
2498 static int hf_tn5250_sps_flag1 = -1;
2499 static int hf_tn5250_sps_flag1_0 = -1;
2500 static int hf_tn5250_sps_flag1_reserved = -1;
2501 static int hf_tn5250_sps_left_column = -1;
2502 static int hf_tn5250_sps_top_row = -1;
2503 static int hf_tn5250_sps_window_depth = -1;
2504 static int hf_tn5250_sps_window_width = -1;
2505 static int hf_tn5250_sys_request_key = -1;
2506 static int hf_tn5250_test_request_key = -1;
2507 static int hf_tn5250_unknown_data = -1;
2508 static int hf_tn5250_variable_record_length = -1;
2509 static int hf_tn5250_wdsf_cw_bp_flag1_reserved = -1;
2510 static int hf_tn5250_wdsf_cw_tf_flag_reserved = -1;
2511 static int hf_tn5250_wdsf_deg_flag2_reserved = -1;
2512 static int hf_tn5250_wdsf_deg_ms_flag1_reserved = -1;
2513 static int hf_tn5250_wdsf_ds_ci_flag1_reserved = -1;
2514 static int hf_tn5250_wdsf_ds_cpda_flag1_reserved = -1;
2515 static int hf_tn5250_wdsf_ds_ct_flag3_reserved = -1;
2516 static int hf_tn5250_wdsf_ds_gdc_reserved = -1;
2517 static int hf_tn5250_wdsf_ds_nws_reserved = -1;
2518 static int hf_tn5250_wdsf_ds_sbi_flag1_reserved = -1;
2519 static int hf_tn5250_wdsf_dsb_flag1_reserved = -1;
2520 static int hf_tn5250_wdsf_pmb_flag1_reserved = -1;
2521 static int hf_tn5250_wdsf_wdf_flag1_reserved = -1;
2522 static int hf_tn5250_wdsf_cgl_partition = -1;
2523 static int hf_tn5250_wdsf_cgl_rectangle_height = -1;
2524 static int hf_tn5250_wdsf_cgl_rectangle_width = -1;
2525 static int hf_tn5250_wdsf_cgl_start_column = -1;
2526 static int hf_tn5250_wdsf_cgl_start_row = -1;
2527 static int hf_tn5250_wdsf_cw_bp_bbc = -1;
2528 static int hf_tn5250_wdsf_cw_bp_cba = -1;
2529 static int hf_tn5250_wdsf_cw_bp_flag1 = -1;
2530 static int hf_tn5250_wdsf_cw_bp_flag1_1 = -1;
2531 static int hf_tn5250_wdsf_cw_bp_lbc = -1;
2532 static int hf_tn5250_wdsf_cw_bp_llbc = -1;
2533 static int hf_tn5250_wdsf_cw_bp_lrbc = -1;
2534 static int hf_tn5250_wdsf_cw_bp_mba = -1;
2535 static int hf_tn5250_wdsf_cw_bp_rbc = -1;
2536 static int hf_tn5250_wdsf_cw_bp_tbc = -1;
2537 static int hf_tn5250_wdsf_cw_bp_ulbc = -1;
2538 static int hf_tn5250_wdsf_cw_bp_urbc = -1;
2539 static int hf_tn5250_wdsf_cw_flag1 = -1;
2540 static int hf_tn5250_wdsf_cw_flag1_1 = -1;
2541 static int hf_tn5250_wdsf_cw_flag1_2 = -1;
2542 static int hf_tn5250_wdsf_cw_flag1_reserved = -1;
2543 static int hf_tn5250_wdsf_cw_minor_type = -1;
2544 static int hf_tn5250_wdsf_cw_tf_cba = -1;
2545 static int hf_tn5250_wdsf_cw_tf_flag = -1;
2546 static int hf_tn5250_wdsf_cw_tf_flag_1 = -1;
2547 static int hf_tn5250_wdsf_cw_tf_flag_orientation = -1;
2548 static int hf_tn5250_wdsf_cw_tf_mba = -1;
2549 static int hf_tn5250_wdsf_cw_tf_text = -1;
2550 static int hf_tn5250_wdsf_cw_wd = -1;
2551 static int hf_tn5250_wdsf_cw_ww = -1;
2552 static int hf_tn5250_wdsf_deg_default_color = -1;
2553 static int hf_tn5250_wdsf_deg_default_line = -1;
2554 static int hf_tn5250_wdsf_deg_flag1 = -1;
2555 static int hf_tn5250_wdsf_deg_flag1_0 = -1;
2556 static int hf_tn5250_wdsf_deg_flag1_reserved = -1;
2557 static int hf_tn5250_wdsf_deg_flag2 = -1;
2558 static int hf_tn5250_wdsf_deg_flag2_0 = -1;
2559 static int hf_tn5250_wdsf_deg_minor_type = -1;
2560 static int hf_tn5250_wdsf_deg_ms_default_color = -1;
2561 static int hf_tn5250_wdsf_deg_ms_flag1 = -1;
2562 static int hf_tn5250_wdsf_deg_ms_flag1_0 = -1;
2563 static int hf_tn5250_wdsf_deg_ms_horizontal_dimension = -1;
2564 static int hf_tn5250_wdsf_deg_ms_line_interval = -1;
2565 static int hf_tn5250_wdsf_deg_ms_line_repeat = -1;
2566 static int hf_tn5250_wdsf_deg_ms_start_column = -1;
2567 static int hf_tn5250_wdsf_deg_ms_start_row = -1;
2568 static int hf_tn5250_wdsf_deg_ms_vertical_dimension = -1;
2569 static int hf_tn5250_wdsf_deg_partition = -1;
2570 static int hf_tn5250_wdsf_ds_cancel_aid = -1;
2571 static int hf_tn5250_wdsf_ds_ci_first_choice = -1;
2572 static int hf_tn5250_wdsf_ds_ci_flag1 = -1;
2573 static int hf_tn5250_wdsf_ds_ci_flag1_0 = -1;
2574 static int hf_tn5250_wdsf_ds_ci_left_push = -1;
2575 static int hf_tn5250_wdsf_ds_ci_right_push = -1;
2576 static int hf_tn5250_wdsf_ds_columns = -1;
2577 static int hf_tn5250_wdsf_ds_country_sel = -1;
2578 static int hf_tn5250_wdsf_ds_cpda_color_avail = -1;
2579 static int hf_tn5250_wdsf_ds_cpda_color_indicator = -1;
2580 static int hf_tn5250_wdsf_ds_cpda_color_sel_avail = -1;
2581 static int hf_tn5250_wdsf_ds_cpda_color_sel_selected = -1;
2582 static int hf_tn5250_wdsf_ds_cpda_color_sel_unavail = -1;
2583 static int hf_tn5250_wdsf_ds_cpda_color_selected = -1;
2584 static int hf_tn5250_wdsf_ds_cpda_color_unavail = -1;
2585 static int hf_tn5250_wdsf_ds_cpda_color_unavail_indicator = -1;
2586 static int hf_tn5250_wdsf_ds_cpda_flag1 = -1;
2587 static int hf_tn5250_wdsf_ds_cpda_flag1_0 = -1;
2588 static int hf_tn5250_wdsf_ds_cpda_flag1_1 = -1;
2589 static int hf_tn5250_wdsf_ds_cpda_flag1_2 = -1;
2590 static int hf_tn5250_wdsf_ds_cpda_monochrome_avail = -1;
2591 static int hf_tn5250_wdsf_ds_cpda_monochrome_indicator = -1;
2592 static int hf_tn5250_wdsf_ds_cpda_monochrome_sel_avail = -1;
2593 static int hf_tn5250_wdsf_ds_cpda_monochrome_sel_selected = -1;
2594 static int hf_tn5250_wdsf_ds_cpda_monochrome_sel_unavail = -1;
2595 static int hf_tn5250_wdsf_ds_cpda_monochrome_selected = -1;
2596 static int hf_tn5250_wdsf_ds_cpda_monochrome_unavail = -1;
2597 static int hf_tn5250_wdsf_ds_cpda_monochrome_unavail_indicator = -1;
2598 static int hf_tn5250_wdsf_ds_ct_aid = -1;
2599 static int hf_tn5250_wdsf_ds_ct_flag1 = -1;
2600 static int hf_tn5250_wdsf_ds_ct_flag1_2 = -1;
2601 static int hf_tn5250_wdsf_ds_ct_flag1_3 = -1;
2602 static int hf_tn5250_wdsf_ds_ct_flag1_4 = -1;
2603 static int hf_tn5250_wdsf_ds_ct_flag1_5 = -1;
2604 static int hf_tn5250_wdsf_ds_ct_flag1_choice_state = -1;
2605 static int hf_tn5250_wdsf_ds_ct_flag1_numeric_selection = -1;
2606 static int hf_tn5250_wdsf_ds_ct_flag2 = -1;
2607 static int hf_tn5250_wdsf_ds_ct_flag2_0 = -1;
2608 static int hf_tn5250_wdsf_ds_ct_flag2_1 = -1;
2609 static int hf_tn5250_wdsf_ds_ct_flag2_2 = -1;
2610 static int hf_tn5250_wdsf_ds_ct_flag2_3 = -1;
2611 static int hf_tn5250_wdsf_ds_ct_flag2_4 = -1;
2612 static int hf_tn5250_wdsf_ds_ct_flag2_5 = -1;
2613 static int hf_tn5250_wdsf_ds_ct_flag2_6 = -1;
2614 static int hf_tn5250_wdsf_ds_ct_flag2_7 = -1;
2615 static int hf_tn5250_wdsf_ds_ct_flag3 = -1;
2616 static int hf_tn5250_wdsf_ds_ct_flag3_0 = -1;
2617 static int hf_tn5250_wdsf_ds_ct_flag3_1 = -1;
2618 static int hf_tn5250_wdsf_ds_ct_flag3_2 = -1;
2619 static int hf_tn5250_wdsf_ds_ct_mnemonic_offset = -1;
2620 static int hf_tn5250_wdsf_ds_ct_numeric_onebyte = -1;
2621 static int hf_tn5250_wdsf_ds_ct_numeric_twobyte = -1;
2622 static int hf_tn5250_wdsf_ds_ct_text = -1;
2623 static int hf_tn5250_wdsf_ds_flag1 = -1;
2624 static int hf_tn5250_wdsf_ds_flag1_1 = -1;
2625 static int hf_tn5250_wdsf_ds_flag1_2 = -1;
2626 static int hf_tn5250_wdsf_ds_flag1_auto_enter = -1;
2627 static int hf_tn5250_wdsf_ds_flag1_mouse_characteristics = -1;
2628 static int hf_tn5250_wdsf_ds_flag1_reserved = -1;
2629 static int hf_tn5250_wdsf_ds_flag2 = -1;
2630 static int hf_tn5250_wdsf_ds_flag2_1 = -1;
2631 static int hf_tn5250_wdsf_ds_flag2_2 = -1;
2632 static int hf_tn5250_wdsf_ds_flag2_3 = -1;
2633 static int hf_tn5250_wdsf_ds_flag2_4 = -1;
2634 static int hf_tn5250_wdsf_ds_flag2_5 = -1;
2635 static int hf_tn5250_wdsf_ds_flag2_6 = -1;
2636 static int hf_tn5250_wdsf_ds_flag2_reserved = -1;
2637 static int hf_tn5250_wdsf_ds_flag3 = -1;
2638 static int hf_tn5250_wdsf_ds_flag3_1 = -1;
2639 static int hf_tn5250_wdsf_ds_flag3_reserved = -1;
2640 static int hf_tn5250_wdsf_ds_gdc = -1;
2641 static int hf_tn5250_wdsf_ds_gdc_indicators = -1;
2642 static int hf_tn5250_wdsf_ds_gdc_selection_techniques = -1;
2643 static int hf_tn5250_wdsf_ds_mbs_color_sep = -1;
2644 static int hf_tn5250_wdsf_ds_mbs_end_column = -1;
2645 static int hf_tn5250_wdsf_ds_mbs_flag = -1;
2646 static int hf_tn5250_wdsf_ds_mbs_flag_0 = -1;
2647 static int hf_tn5250_wdsf_ds_mbs_flag_1 = -1;
2648 static int hf_tn5250_wdsf_ds_mbs_flag_reserved = -1;
2649 static int hf_tn5250_wdsf_ds_mbs_monochrome_sep = -1;
2650 static int hf_tn5250_wdsf_ds_mbs_sep_char = -1;
2651 static int hf_tn5250_wdsf_ds_mbs_start_column = -1;
2652 static int hf_tn5250_wdsf_ds_minor_type = -1;
2653 static int hf_tn5250_wdsf_ds_numeric_sep = -1;
2654 static int hf_tn5250_wdsf_ds_nws = -1;
2655 static int hf_tn5250_wdsf_ds_nws_indicators = -1;
2656 static int hf_tn5250_wdsf_ds_nws_selection_techniques = -1;
2657 static int hf_tn5250_wdsf_ds_nws_wout = -1;
2658 static int hf_tn5250_wdsf_ds_padding = -1;
2659 static int hf_tn5250_wdsf_ds_rows = -1;
2660 static int hf_tn5250_wdsf_ds_sbi_bottom_character = -1;
2661 static int hf_tn5250_wdsf_ds_sbi_color_top_highlight = -1;
2662 static int hf_tn5250_wdsf_ds_sbi_color_top_highlight_shaft = -1;
2663 static int hf_tn5250_wdsf_ds_sbi_empty_character = -1;
2664 static int hf_tn5250_wdsf_ds_sbi_flag1 = -1;
2665 static int hf_tn5250_wdsf_ds_sbi_flag1_0 = -1;
2666 static int hf_tn5250_wdsf_ds_sbi_monochrome_top_highlight = -1;
2667 static int hf_tn5250_wdsf_ds_sbi_monochrome_top_highlight_shaft = -1;
2668 static int hf_tn5250_wdsf_ds_sbi_slider_character = -1;
2669 static int hf_tn5250_wdsf_ds_sbi_top_character = -1;
2670 static int hf_tn5250_wdsf_ds_sliderpos = -1;
2671 static int hf_tn5250_wdsf_ds_textsize = -1;
2672 static int hf_tn5250_wdsf_ds_totalrows = -1;
2673 static int hf_tn5250_wdsf_ds_type = -1;
2674 static int hf_tn5250_wdsf_dsb_flag1 = -1;
2675 static int hf_tn5250_wdsf_dsb_flag1_0 = -1;
2676 static int hf_tn5250_wdsf_dsb_flag1_1 = -1;
2677 static int hf_tn5250_wdsf_dsb_flag1_7 = -1;
2678 static int hf_tn5250_wdsf_pmb_first_mouse_event = -1;
2679 static int hf_tn5250_wdsf_pmb_flag1 = -1;
2680 static int hf_tn5250_wdsf_pmb_flag1_0 = -1;
2681 static int hf_tn5250_wdsf_pmb_flag1_1 = -1;
2682 static int hf_tn5250_wdsf_pmb_flag1_2 = -1;
2683 static int hf_tn5250_wdsf_pmb_flag1_3 = -1;
2684 static int hf_tn5250_wdsf_pmb_second_mouse_event = -1;
2685 static int hf_tn5250_wdsf_ragc_flag1 = -1;
2686 static int hf_tn5250_wdsf_ragc_flag1_0 = -1;
2687 static int hf_tn5250_wdsf_ragc_reserved = -1;
2688 static int hf_tn5250_wdsf_rgw_flag1 = -1;
2689 static int hf_tn5250_wdsf_rgw_flag1_0 = -1;
2690 static int hf_tn5250_wdsf_rgw_flag1_1 = -1;
2691 static int hf_tn5250_wdsf_rgw_reserved = -1;
2692 static int hf_tn5250_wdsf_sbi_rowscols = -1;
2693 static int hf_tn5250_wdsf_sbi_sliderpos = -1;
2694 static int hf_tn5250_wdsf_sbi_total_scroll = -1;
2695 static int hf_tn5250_wdsf_wdf_flag1 = -1;
2696 static int hf_tn5250_wdsf_wdf_flag1_0 = -1;
2697 static int hf_tn5250_wea_prim_attr = -1;
2698 static int hf_tn5250_wea_prim_attr_blink = -1;
2699 static int hf_tn5250_wea_prim_attr_col = -1;
2700 static int hf_tn5250_wea_prim_attr_flag = -1;
2701 static int hf_tn5250_wea_prim_attr_int = -1;
2702 static int hf_tn5250_wea_prim_attr_rev = -1;
2703 static int hf_tn5250_wea_prim_attr_und = -1;
2704 static int hf_tn5250_wectw_end_column = -1;
2705 static int hf_tn5250_wectw_start_column = -1;
2706 static int hf_tn5250_wsf_qss_flag1 = -1;
2707 static int hf_tn5250_wsf_qss_flag1_0 = -1;
2708 static int hf_tn5250_wsf_qss_flag1_reserved = -1;
2709 static int hf_tn5250_wsf_qss_flag2 = -1;
2710 static int hf_tn5250_wsf_qss_flag2_7 = -1;
2711 static int hf_tn5250_wsf_qss_flag2_reserved = -1;
2712 static int hf_tn5250_wssf_cc_flag1 = -1;
2713 static int hf_tn5250_wssf_cc_flag1_7 = -1;
2714 static int hf_tn5250_wssf_cc_flag1_reserved = -1;
2715 static int hf_tn5250_wssf_flag1 = -1;
2716 static int hf_tn5250_wssf_flag2 = -1;
2717 static int hf_tn5250_wssf_flag2_0 = -1;
2718 static int hf_tn5250_wssf_flag2_1 = -1;
2719 static int hf_tn5250_wssf_flag2_2 = -1;
2720 static int hf_tn5250_wssf_flag2_3 = -1;
2721 static int hf_tn5250_wssf_flag2_4 = -1;
2722 static int hf_tn5250_wssf_flag2_5 = -1;
2723 static int hf_tn5250_wssf_flag2_6 = -1;
2724 static int hf_tn5250_wssf_flag2_7 = -1;
2725 static int hf_tn5250_wssf_ifc_background_color = -1;
2726 static int hf_tn5250_wssf_ifc_flag1 = -1;
2727 static int hf_tn5250_wssf_ifc_flag1_0 = -1;
2728 static int hf_tn5250_wssf_ifc_flag1_1to3 = -1;
2729 static int hf_tn5250_wssf_ifc_flag1_4 = -1;
2730 static int hf_tn5250_wssf_ifc_flag1_5 = -1;
2731 static int hf_tn5250_wssf_ifc_flag1_6 = -1;
2732 static int hf_tn5250_wssf_ifc_flag1_7 = -1;
2733 static int hf_tn5250_wssf_ifc_flag2 = -1;
2734 static int hf_tn5250_wssf_ifc_flag2_0 = -1;
2735 static int hf_tn5250_wssf_ifc_flag2_1 = -1;
2736 static int hf_tn5250_wssf_ifc_flag2_7 = -1;
2737 static int hf_tn5250_wssf_ifc_flag2_reserved = -1;
2738 static int hf_tn5250_wssf_ifc_foreground_color = -1;
2739 static int hf_tn5250_wssf_ifc_image_format = -1;
2740 static int hf_tn5250_wssf_ifc_imagefax_name = -1;
2741 static int hf_tn5250_wssf_ifc_rotation = -1;
2742 static int hf_tn5250_wssf_ifc_scaling = -1;
2743 static int hf_tn5250_wssf_ifc_viewimage_location_col = -1;
2744 static int hf_tn5250_wssf_ifc_viewimage_location_row = -1;
2745 static int hf_tn5250_wssf_ifc_viewport_location_col = -1;
2746 static int hf_tn5250_wssf_ifc_viewport_location_row = -1;
2747 static int hf_tn5250_wssf_ifc_viewport_size_col = -1;
2748 static int hf_tn5250_wssf_ifc_viewport_size_row = -1;
2749 static int hf_tn5250_wssf_ifd_flag1 = -1;
2750 static int hf_tn5250_wssf_ifd_flag1_0 = -1;
2751 static int hf_tn5250_wssf_ifd_flag1_reserved = -1;
2752 static int hf_tn5250_wssf_ifd_imagefax_data = -1;
2753 static int hf_tn5250_wssf_ifd_imagefax_name = -1;
2754 static int hf_tn5250_wssf_kbc_flag1 = -1;
2755 static int hf_tn5250_wssf_kbc_flag1_5 = -1;
2756 static int hf_tn5250_wssf_kbc_flag1_6 = -1;
2757 static int hf_tn5250_wssf_kbc_flag1_7 = -1;
2758 static int hf_tn5250_wssf_kbc_flag1_reserved = -1;
2759 static int hf_tn5250_wssf_wsc_minor_type = -1;
2760 static int hf_tn5250_wtd_ccc1 = -1;
2761 static int hf_tn5250_wtd_ccc2 = -1;
2762 static int hf_tn5250_wtd_ccc2_alarm = -1;
2763 static int hf_tn5250_wtd_ccc2_cursor = -1;
2764 static int hf_tn5250_wtd_ccc2_off = -1;
2765 static int hf_tn5250_wtd_ccc2_on = -1;
2766 static int hf_tn5250_wtd_ccc2_res = -1;
2767 static int hf_tn5250_wtd_ccc2_reset = -1;
2768 static int hf_tn5250_wtd_ccc2_set = -1;
2769 static int hf_tn5250_wtd_ccc2_unlock = -1;
2770 static int hf_tn5250_wts_cld_flag1 = -1;
2771 static int hf_tn5250_wts_cld_flag1_0 = -1;
2772 static int hf_tn5250_wts_cld_flag1_1 = -1;
2773 static int hf_tn5250_wts_cld_flag1_2 = -1;
2774 static int hf_tn5250_wts_cld_flag1_3 = -1;
2775 static int hf_tn5250_wts_cld_flag1_4 = -1;
2776 static int hf_tn5250_wts_cld_flag1_5 = -1;
2777 static int hf_tn5250_wts_cld_flag1_6 = -1;
2778 static int hf_tn5250_wts_cld_flag1_7 = -1;
2779 static int hf_tn5250_wts_cld_flag2 = -1;
2780 static int hf_tn5250_wts_cld_flag2_0 = -1;
2781 static int hf_tn5250_wts_cld_flag2_1 = -1;
2782 static int hf_tn5250_wts_cld_flag2_2 = -1;
2783 static int hf_tn5250_wts_cld_flag2_3 = -1;
2784 static int hf_tn5250_wts_cld_flag2_4 = -1;
2785 static int hf_tn5250_wts_cld_flag2_line_spacing = -1;
2786 static int hf_tn5250_wts_cld_flag3 = -1;
2787 static int hf_tn5250_wts_cld_flag3_0 = -1;
2788 static int hf_tn5250_wts_cld_flag3_1 = -1;
2789 static int hf_tn5250_wts_cld_flag3_2 = -1;
2790 static int hf_tn5250_wts_cld_flag3_3 = -1;
2791 static int hf_tn5250_wts_cld_flag3_4 = -1;
2792 static int hf_tn5250_wts_cld_flag3_5 = -1;
2793 static int hf_tn5250_wts_cld_flag3_6 = -1;
2794 static int hf_tn5250_wts_cld_flag3_7 = -1;
2795 static int hf_tn5250_wts_cld_io = -1;
2796 static int hf_tn5250_wts_cld_li = -1;
2797 static int hf_tn5250_wts_cld_lmo = -1;
2798 static int hf_tn5250_wts_cld_page_num = -1;
2799 static int hf_tn5250_wts_cld_row = -1;
2800 static int hf_tn5250_wts_cld_sli = -1;
2801 static int hf_tn5250_wts_flag1 = -1;
2802 static int hf_tn5250_wts_flag1_0 = -1;
2803 static int hf_tn5250_wts_flag1_1 = -1;
2804 static int hf_tn5250_wts_flag1_2 = -1;
2805 static int hf_tn5250_wts_flag1_3 = -1;
2806 static int hf_tn5250_wts_flag1_reserved = -1;
2807 static int hf_tn5250_wts_flag2 = -1;
2808 static int hf_tn5250_wts_flag2_6 = -1;
2809 static int hf_tn5250_wts_flag2_reserved = -1;
2810 static int hf_tn5250_wts_flag2_reserved2 = -1;
2811 static int hf_tn5250_wts_flag3 = -1;
2812 static int hf_tn5250_wts_flag3_0 = -1;
2813 static int hf_tn5250_wts_flag3_1 = -1;
2814 static int hf_tn5250_wts_flag3_2 = -1;
2815 static int hf_tn5250_wts_flag3_3 = -1;
2816 static int hf_tn5250_wts_flag3_4 = -1;
2817 static int hf_tn5250_wts_flag3_5 = -1;
2818 static int hf_tn5250_wts_flag3_6 = -1;
2819 static int hf_tn5250_wts_flag3_7 = -1;
2820 static int hf_tn5250_wts_home_position_col = -1;
2821 static int hf_tn5250_wts_home_position_row = -1;
2822 static int hf_tn5250_wts_partition = -1;
2823 static int hf_tn5250_soh_length = -1;
2824 static int hf_tn5250_negative_response = -1;
2825 static int hf_tn5250_qr_ccl = -1;
2826 static int hf_tn5250_qr_chc= -1;
2827 static int hf_tn5250_qr_dm= -1;
2828 static int hf_tn5250_qr_dsn= -1;
2829 static int hf_tn5250_qr_dt= -1;
2830 static int hf_tn5250_qr_dtc= -1;
2831 static int hf_tn5250_qr_eki= -1;
2832 static int hf_tn5250_qr_flag= -1;
2833 static int hf_tn5250_qr_flag1= -1;
2834 static int hf_tn5250_qr_flag2= -1;
2835 static int hf_tn5250_qr_flag3= -1;
2836 static int hf_tn5250_qr_flag4= -1;
2837 static int hf_tn5250_qr_ki= -1;
2838 static int hf_tn5250_qr_flag1_0= -1;
2839 static int hf_tn5250_qr_flag1_1= -1;
2840 static int hf_tn5250_qr_flag1_2= -1;
2841 static int hf_tn5250_qr_flag1_3= -1;
2842 static int hf_tn5250_qr_flag1_4= -1;
2843 static int hf_tn5250_qr_flag1_5= -1;
2844 static int hf_tn5250_qr_flag1_6= -1;
2845 static int hf_tn5250_qr_flag1_7= -1;
2846 static int hf_tn5250_qr_flag2_0to3= -1;
2847 static int hf_tn5250_qr_flag2_4= -1;
2848 static int hf_tn5250_qr_flag2_5= -1;
2849 static int hf_tn5250_qr_flag2_6to7= -1;
2850 static int hf_tn5250_qr_flag_0= -1;
2851 static int hf_tn5250_qr_flag_reserved= -1;
2852 static int hf_tn5250_qr_mni= -1;
2853 static int hf_tn5250_image_fax_error = -1;
2854 static int hf_tn5250_vac_data = -1;
2855 static int hf_tn5250_vac_prefix = -1;
2856 static int hf_tn5250_wssf_ttw_flag = -1;
2857 static int hf_tn5250_wssf_ttw_data = -1;
2858
2859 static gint ett_tn5250 = -1;
2860 static gint ett_tn5250_wcc = -1;
2861 static gint ett_sf = -1;
2862 static gint ett_tn5250_field_attribute = -1;
2863 static gint ett_tn5250_dfdpck_mask = -1;
2864 static gint ett_tn5250_field_validation = -1;
2865 static gint ett_tn5250_header_flags = -1;
2866 static gint ett_tn5250_roll_mask = -1;
2867 static gint ett_tn5250_soh_mask = -1;
2868 static gint ett_tn5250_soh_pf16to9_mask = -1;
2869 static gint ett_tn5250_soh_pf24to17_mask = -1;
2870 static gint ett_tn5250_soh_pf8to1_mask = -1;
2871 static gint ett_tn5250_sps_mask = -1;
2872 static gint ett_tn5250_wdsf_cw_bp_mask = -1;
2873 static gint ett_tn5250_wdsf_cw_mask = -1;
2874 static gint ett_tn5250_wdsf_cw_tf_mask = -1;
2875 static gint ett_tn5250_wdsf_deg_mask = -1;
2876 static gint ett_tn5250_wdsf_deg_ms_mask = -1;
2877 static gint ett_tn5250_wdsf_ds_ci_mask = -1;
2878 static gint ett_tn5250_wdsf_ds_cpda_mask = -1;
2879 static gint ett_tn5250_wdsf_ds_ct_mask = -1;
2880 static gint ett_tn5250_wdsf_ds_mask = -1;
2881 static gint ett_tn5250_wdsf_ds_mbs_mask = -1;
2882 static gint ett_tn5250_wdsf_ds_sbi_mask = -1;
2883 static gint ett_tn5250_wdsf_dsb_mask = -1;
2884 static gint ett_tn5250_wdsf_pmb_mask = -1;
2885 static gint ett_tn5250_wdsf_ragc_mask = -1;
2886 static gint ett_tn5250_wdsf_rgw_mask = -1;
2887 static gint ett_tn5250_wdsf_wdf_mask = -1;
2888 static gint ett_tn5250_wsf_dpo_mask = -1;
2889 static gint ett_tn5250_wsf_dsl_mask = -1;
2890 static gint ett_tn5250_wsf_dtsf_mask = -1;
2891 static gint ett_tn5250_wsf_qss_mask = -1;
2892 static gint ett_tn5250_wsf_rts_mask = -1;
2893 static gint ett_tn5250_wssf_cc_mask = -1;
2894 static gint ett_tn5250_wssf_ifc_mask = -1;
2895 static gint ett_tn5250_wssf_ifd_mask = -1;
2896 static gint ett_tn5250_wssf_kbc_mask = -1;
2897 static gint ett_tn5250_wssf_mask = -1;
2898 static gint ett_tn5250_wts_mask = -1;
2899 static gint ett_tn5250_qr_mask = -1;
2900 static gint ett_tn5250_wea_prim_attr = -1;
2901 static gint ett_cc = -1;
2902
2903 static tn5250_conv_info_t *tn5250_info_items;
2904
2905 static guint32 dissect_tn5250_orders_and_data(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset);
2906
2907 typedef struct hf_items {
2908   int hf;
2909   gint bitmask_ett;
2910   int length;
2911   const int **bitmask;
2912 } hf_items;
2913
2914 /* Utility Functions */
2915
2916 static gint
2917 tn5250_is_valid_aid(gint aid)
2918 {
2919   switch (aid) {
2920     case AID_CLEAR:
2921     case AID_ENTER_OR_RECORD_ADV:
2922     case AID_HELP:
2923     case AID_ROLL_DOWN:
2924     case AID_ROLL_UP:
2925     case AID_ROLL_LEFT:
2926     case AID_ROLL_RIGHT:
2927     case AID_PRINT:
2928     case AID_RECORD_BACKSPACE:
2929     case AID_SLP_AUTO_ENTER:
2930     case AID_FORWARD_EDGE_TRIGGER_AUTO__ENTER:
2931     case AID_PA1:
2932     case AID_PA2:
2933     case AID_PA3:
2934     case AID_CMD_01:
2935     case AID_CMD_02:
2936     case AID_CMD_03:
2937     case AID_CMD_04:
2938     case AID_CMD_05:
2939     case AID_CMD_06:
2940     case AID_CMD_07:
2941     case AID_CMD_08:
2942     case AID_CMD_09:
2943     case AID_CMD_10:
2944     case AID_CMD_11:
2945     case AID_CMD_12:
2946     case AID_CMD_13:
2947     case AID_CMD_14:
2948     case AID_CMD_15:
2949     case AID_CMD_16:
2950     case AID_CMD_17:
2951     case AID_CMD_18:
2952     case AID_CMD_19:
2953     case AID_CMD_20:
2954     case AID_CMD_21:
2955     case AID_CMD_22:
2956     case AID_CMD_23:
2957     case AID_CMD_24:
2958     case AID_INBOUND_WRITE_STRUCTURED_FIELD:
2959     case AID_PASS_THROUGH_RESPONSE:
2960       return 1;
2961     default:
2962       break;
2963   }
2964   return 0;
2965 }
2966
2967 static guint32
2968 tn5250_add_hf_items(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset,
2969                     hf_items *fields)
2970 {
2971   int start=offset, byte;
2972   int i;
2973
2974   for (i = 0; fields[i].hf; ++i) {
2975     if (fields[i].bitmask == 0) {
2976       /* Skip an 0xFF byte acting as an escape byte */
2977       byte = tvb_get_guint8(tvb,offset);
2978       if (byte == 0xFF) {
2979           offset++;
2980       }
2981       proto_tree_add_item(tn5250_tree, fields[i].hf, tvb, offset,
2982                           fields[i].length, FALSE);
2983     } else {
2984       proto_tree_add_bitmask(tn5250_tree, tvb, offset, fields[i].hf,
2985                              fields[i].bitmask_ett, fields[i].bitmask, FALSE);
2986     }
2987     DISSECTOR_ASSERT(fields[i].length > 0);
2988     offset+=fields[i].length;
2989   }
2990   return (offset - start);
2991 }
2992
2993 static guint32
2994 dissect_unknown_data(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset,
2995                      gint start, gint sf_length)
2996 {
2997   int len_left;
2998
2999   len_left = sf_length - (offset - start);
3000
3001   if (len_left > 0) {
3002     proto_tree_add_item(tn5250_tree, hf_tn5250_unknown_data, tvb, offset,
3003                         len_left, FALSE);
3004     return len_left;
3005   }
3006   return 0;
3007 }
3008
3009 static guint32
3010 dissect_wcc(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset)
3011 {
3012
3013   static const int *wcc_byte[] = {
3014       &hf_tn5250_wtd_ccc2_res,
3015       &hf_tn5250_wtd_ccc2_cursor,
3016       &hf_tn5250_wtd_ccc2_reset,
3017       &hf_tn5250_wtd_ccc2_set,
3018       &hf_tn5250_wtd_ccc2_unlock,
3019       &hf_tn5250_wtd_ccc2_alarm,
3020       &hf_tn5250_wtd_ccc2_off,
3021       &hf_tn5250_wtd_ccc2_on,
3022       NULL
3023   };
3024
3025   hf_items wcc_fields[] = {
3026       { hf_tn5250_wtd_ccc1, 0, 1, 0 },
3027       { hf_tn5250_wtd_ccc2, ett_tn5250_wcc, 1, wcc_byte },
3028       { 0, 0, 0, 0 }
3029   };
3030
3031   offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, wcc_fields);
3032
3033   return 2;
3034
3035 }
3036
3037 static guint32
3038 dissect_row_column(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset)
3039 {
3040   int start = offset;
3041   proto_tree_add_item(tn5250_tree, hf_tn5250_buffer_x, tvb, offset, 1, FALSE);
3042   offset++;
3043   proto_tree_add_item(tn5250_tree, hf_tn5250_buffer_y, tvb, offset, 1, FALSE);
3044   offset++;
3045
3046   return (offset - start);
3047 }
3048
3049 /* End - Utility Functions */
3050
3051
3052 /* Start: Handle WCC, Orders and Data */
3053
3054 /* 15.6.8 Erase to Address Order */
3055 static guint32
3056 dissect_erase_to_address(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset)
3057 {
3058   int start = offset;
3059   int i, length = 0;
3060
3061   dissect_row_column(tn5250_tree, tvb, offset);
3062
3063   length = tvb_get_guint8(tvb, offset);
3064   proto_tree_add_item(tn5250_tree, hf_tn5250_length, tvb, offset, 1, FALSE);
3065   offset++;
3066
3067   for (i=1; i < length; i++) {
3068     proto_tree_add_item(tn5250_tree, hf_tn5250_attribute_type, tvb, offset, 1,
3069                         FALSE);
3070     offset++;
3071   }
3072
3073   return (offset - start);
3074 }
3075
3076 /* 15.6.9 Start of Header Order */
3077 static guint32
3078 dissect_start_of_header(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset)
3079 {
3080   int start = offset;
3081   int length = 0;
3082
3083  /*TODO: Warn on invalid length. <= 7 */
3084   static const int *byte[] = {
3085      &hf_tn5250_soh_cursor_direction,
3086      &hf_tn5250_soh_screen_reverse,
3087      &hf_tn5250_soh_input_capable_only,
3088      NULL
3089   };
3090
3091   static const int *byte1[] = {
3092      &hf_tn5250_soh_pf24, &hf_tn5250_soh_pf23, &hf_tn5250_soh_pf22,
3093      &hf_tn5250_soh_pf21, &hf_tn5250_soh_pf20, &hf_tn5250_soh_pf19,
3094      &hf_tn5250_soh_pf18, &hf_tn5250_soh_pf17,
3095      NULL
3096   };
3097
3098   static const int *byte2[] = {
3099      &hf_tn5250_soh_pf16, &hf_tn5250_soh_pf15, &hf_tn5250_soh_pf14,
3100      &hf_tn5250_soh_pf13, &hf_tn5250_soh_pf12, &hf_tn5250_soh_pf11,
3101      &hf_tn5250_soh_pf10, &hf_tn5250_soh_pf9,
3102      NULL
3103   };
3104
3105   static const int *byte3[] = {
3106      &hf_tn5250_soh_pf8, &hf_tn5250_soh_pf7, &hf_tn5250_soh_pf6,
3107      &hf_tn5250_soh_pf5, &hf_tn5250_soh_pf4, &hf_tn5250_soh_pf3,
3108      &hf_tn5250_soh_pf2, &hf_tn5250_soh_pf1,
3109      NULL
3110   };
3111
3112   hf_items start_of_header_fields[] = {
3113       { hf_tn5250_soh_length, 0, 1, 0 },
3114       { hf_tn5250_soh_flags, ett_tn5250_soh_mask, 1, byte },
3115       { hf_tn5250_reserved, 0, 1, 0 },
3116       { hf_tn5250_soh_resq, 1, 1, 0 },
3117       { hf_tn5250_soh_err, 1, 1, 0 },
3118       { hf_tn5250_soh_pf24to17, ett_tn5250_soh_pf24to17_mask, 1, byte1 },
3119       { hf_tn5250_soh_pf16to9, ett_tn5250_soh_pf16to9_mask, 1, byte2 },
3120       { hf_tn5250_soh_pf8to1, ett_tn5250_soh_pf8to1_mask, 1, byte3 },
3121       { 0, 0, 0, 0 }
3122   };
3123
3124   length = tvb_get_guint8(tvb, offset);
3125
3126   offset += tn5250_add_hf_items(tn5250_tree, tvb, offset,
3127                                 start_of_header_fields);
3128
3129   return (offset - start);
3130 }
3131
3132 /* 15.6.10 Transparent Data */
3133 static guint32
3134 dissect_twobyte_length_and_data(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset)
3135 {
3136   int start = offset;
3137   int length = 0;
3138
3139   length = tvb_get_ntohs(tvb, offset);
3140   proto_tree_add_item(tn5250_tree, hf_tn5250_length_twobyte, tvb, offset, 2,
3141                       FALSE);
3142   offset+=2;
3143
3144   if (tvb_reported_length_remaining(tvb, offset) >= length) {
3145     proto_tree_add_item(tn5250_tree, hf_tn5250_field_data, tvb, offset,
3146                         length, FALSE);
3147     offset+=length;
3148   } else {
3149     offset += dissect_unknown_data(tn5250_tree, tvb, offset, start, length);
3150   }
3151
3152   return (offset - start);
3153 }
3154
3155 /* 15.6.11 Write Extended Attribute Order */
3156 static guint32
3157 dissect_field_attribute_pair(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset)
3158 {
3159   int start = offset;
3160   int attribute_type;
3161
3162   static const int *byte[] = {
3163      &hf_tn5250_wea_prim_attr_flag, &hf_tn5250_wea_prim_attr_col,
3164      &hf_tn5250_wea_prim_attr_blink, &hf_tn5250_wea_prim_attr_und,
3165      &hf_tn5250_wea_prim_attr_int, &hf_tn5250_wea_prim_attr_rev,
3166      NULL
3167   };
3168
3169   attribute_type = tvb_get_guint8(tvb, offset);
3170   proto_tree_add_item(tn5250_tree, hf_tn5250_attribute_type, tvb, offset, 1,
3171                       FALSE);
3172   offset++;
3173   switch (attribute_type) {
3174     case EXTENDED_PRIMARY_ATTRIBUTES:
3175       proto_tree_add_bitmask(tn5250_tree, tvb, offset, hf_tn5250_wea_prim_attr,
3176                              ett_tn5250_wea_prim_attr, byte, FALSE);
3177       offset++;
3178       break;
3179     case EXTENDED_FOREGROUND_COLOR_ATTRIBUTES:
3180       proto_tree_add_item(tn5250_tree, hf_tn5250_foreground_color_attr, tvb,
3181                           offset, 1, FALSE);
3182       offset++;
3183       break;
3184     case EXTENDED_IDEOGRAPHIC_ATTRIBUTES:
3185       proto_tree_add_item(tn5250_tree, hf_tn5250_ideographic_attr, tvb, offset,
3186                           1, FALSE);
3187       offset++;
3188       break;
3189     default:
3190       /*TODO: Add invalid data statement here*/
3191       break;
3192   }
3193
3194   return (offset - start);
3195 }
3196
3197 /* 15.6.12 Start of Field Order */
3198 static guint32
3199 dissect_start_of_field(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset)
3200 {
3201   int start = offset;
3202   int done = 0;
3203   int ffw = 0, fcw = 0, fa = 0;
3204
3205   static const int *byte[] = {
3206      &hf_tn5250_ffw_id,
3207      &hf_tn5250_ffw_bypass,
3208      &hf_tn5250_ffw_dup,
3209      &hf_tn5250_ffw_mdt,
3210      &hf_tn5250_ffw_shift,
3211      NULL
3212   };
3213
3214   static const int *byte1[] = {
3215      &hf_tn5250_ffw_auto,
3216      &hf_tn5250_ffw_fer,
3217      &hf_tn5250_ffw_monocase,
3218      &hf_tn5250_ffw_res,
3219      &hf_tn5250_ffw_me,
3220      &hf_tn5250_ffw_adjust,
3221      NULL
3222   };
3223
3224   static const int *fabyte[] = {
3225      &hf_tn5250_sf_attr_flag, &hf_tn5250_wea_prim_attr_col,
3226      &hf_tn5250_wea_prim_attr_blink, &hf_tn5250_wea_prim_attr_und,
3227      &hf_tn5250_wea_prim_attr_int, &hf_tn5250_wea_prim_attr_rev,
3228      NULL
3229   };
3230
3231   hf_items outbound_text_header_fields[] = {
3232       { hf_tn5250_ffw, ett_tn5250_soh_mask, 1, byte },
3233       { hf_tn5250_ffw, ett_tn5250_soh_mask, 1, byte1 },
3234       { 0, 0, 0, 0 }
3235   };
3236
3237   ffw = tvb_get_guint8(tvb, offset);
3238
3239   if (ffw & FFW_ID) {
3240     offset += tn5250_add_hf_items(tn5250_tree, tvb, offset,
3241                                   outbound_text_header_fields);
3242     while (tvb_reported_length_remaining(tvb, offset) > 0 && !done) {
3243       fcw = tvb_get_guint8(tvb, offset);
3244       switch (fcw) {
3245         case SELECTOR:
3246         case IDEOGRAPHIC:
3247         case FORWARD_EDGE:
3248         case CONTINUED_ENTRY:
3249         case SELF_CHECK:
3250         case ENTRY_FIELD_RESEQUENCING:
3251         case CURSOR_PROGRESSION_ENTRY_FIELD:
3252         case HIGHLIGHTED_ENTRY_FIELD:
3253         case POINTER_DEVICE_SELECTION_ENTRY_FIELD:
3254         case TRANSPARENCY_ENTRY_FIELD:
3255             proto_tree_add_item(tn5250_tree, hf_tn5250_fcw, tvb, offset,
3256                                 2, FALSE);
3257             offset+=2;
3258             break;
3259         default:
3260             done = 1;
3261             break;
3262       }
3263     }
3264   }
3265
3266   fa = tvb_get_guint8(tvb, offset);
3267
3268   if (fa & FA_ID) {
3269     proto_tree_add_bitmask(tn5250_tree, tvb, offset, hf_tn5250_fa,
3270                             ett_tn5250_wea_prim_attr, fabyte, FALSE);
3271     offset++;
3272   } else {
3273     proto_tree_add_item(tn5250_tree, hf_tn5250_fa_color, tvb, offset,
3274                         1, FALSE);
3275     offset++;
3276   }
3277   proto_tree_add_item(tn5250_tree, hf_tn5250_length_twobyte, tvb, offset,
3278                         2, FALSE);
3279   offset+=2;
3280
3281   return (offset - start);
3282 }
3283
3284 /* 15.6.13 Write To Display Structured Field Order */
3285 static guint32
3286 dissect_create_window(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset)
3287 {
3288   int start = offset;
3289   int length = 0;
3290   int done = 0, minor_structure = 0;
3291
3292   static const int *byte[] = {
3293      &hf_tn5250_wdsf_cw_flag1_1,
3294      &hf_tn5250_wdsf_cw_flag1_2,
3295      &hf_tn5250_wdsf_cw_flag1_reserved,
3296      NULL
3297   };
3298
3299   hf_items cw_fields[] = {
3300     { hf_tn5250_wdsf_cw_flag1, ett_tn5250_wdsf_cw_mask, 1, byte },
3301     { hf_tn5250_reserved, 0, 1, 0 },
3302     { hf_tn5250_reserved, 0, 1, 0 },
3303     { hf_tn5250_wdsf_cw_wd, 0, 1, 0 },
3304     { hf_tn5250_wdsf_cw_ww, 0, 1, 0 },
3305     { 0, 0, 0, 0 }
3306   };
3307
3308   static const int *cw_bp_flag1[] = {
3309      &hf_tn5250_wdsf_cw_bp_flag1_1,
3310      &hf_tn5250_wdsf_cw_bp_flag1_reserved,
3311      NULL
3312   };
3313
3314
3315   hf_items cwbp_fields[] = {
3316     { hf_tn5250_length, 0, 1, 0 },
3317     { hf_tn5250_wdsf_cw_minor_type, 0, 1, 0 },
3318     { hf_tn5250_wdsf_cw_bp_flag1, ett_tn5250_wdsf_cw_bp_mask, 1, cw_bp_flag1 },
3319     { hf_tn5250_wdsf_cw_bp_mba, 0, 1, 0 },
3320     { hf_tn5250_wdsf_cw_bp_cba, 0, 1, 0 },
3321     { hf_tn5250_wdsf_cw_bp_ulbc, 0, 1, 0 },
3322     { hf_tn5250_wdsf_cw_bp_tbc, 0, 1, 0 },
3323     { hf_tn5250_wdsf_cw_bp_urbc, 0, 1, 0 },
3324     { hf_tn5250_wdsf_cw_bp_lbc, 0, 1, 0 },
3325     { hf_tn5250_wdsf_cw_bp_rbc, 0, 1, 0 },
3326     { hf_tn5250_wdsf_cw_bp_llbc, 0, 1, 0 },
3327     { hf_tn5250_wdsf_cw_bp_bbc, 0, 1, 0 },
3328     { hf_tn5250_wdsf_cw_bp_lrbc, 0, 1, 0 },
3329     { 0, 0, 0, 0 }
3330   };
3331
3332   static const int *cw_tf_flag1[] = {
3333      &hf_tn5250_wdsf_cw_tf_flag_orientation,
3334      &hf_tn5250_wdsf_cw_tf_flag_1,
3335      &hf_tn5250_wdsf_cw_tf_flag_reserved,
3336      NULL
3337   };
3338
3339
3340   hf_items cw_tf_fields[] = {
3341     { hf_tn5250_length, 0, 1, 0 },
3342     { hf_tn5250_wdsf_cw_minor_type, 0, 1, 0 },
3343     { hf_tn5250_wdsf_cw_tf_flag, ett_tn5250_wdsf_cw_tf_mask, 1, cw_tf_flag1 },
3344     { hf_tn5250_wdsf_cw_tf_mba, 0, 1, 0 },
3345     { hf_tn5250_wdsf_cw_tf_cba, 0, 1, 0 },
3346     { hf_tn5250_reserved, 0, 1, 0 },
3347     { 0, 0, 0, 0 }
3348   };
3349
3350   offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, cw_fields);
3351
3352   while (tvb_reported_length_remaining(tvb, offset) > 0 && !done) {
3353     minor_structure = tvb_get_guint8(tvb, offset+1);
3354     switch (minor_structure) {
3355       case CW_BORDER_PRESENTATION:
3356         offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, cwbp_fields);
3357       case CW_TITLE_FOOTER:
3358         length = tvb_get_guint8(tvb,offset);
3359         offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, cw_tf_fields);
3360         proto_tree_add_item(tn5250_tree, hf_tn5250_wdsf_cw_tf_text, tvb, offset,
3361                             (length - 6), FALSE);
3362         offset += (guint32)((length - 6));
3363       default:
3364         done = 1;
3365         break;
3366     }
3367   }
3368
3369   return (offset - start);
3370 }
3371
3372 static guint32
3373 dissect_define_selection(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset)
3374 {
3375   int start = offset;
3376   int length = 0;
3377   int done = 0, minor_structure = 0, digit_selection = 0;
3378
3379   static const int *ds_flag1[] = {
3380      &hf_tn5250_wdsf_ds_flag1_mouse_characteristics, &hf_tn5250_wdsf_ds_flag1_reserved,
3381      &hf_tn5250_wdsf_ds_flag1_auto_enter, &hf_tn5250_wdsf_ds_flag1_1,
3382      &hf_tn5250_wdsf_ds_flag1_2, NULL
3383   };
3384
3385   static const int *ds_flag2[] = {
3386      &hf_tn5250_wdsf_ds_flag2_1, &hf_tn5250_wdsf_ds_flag2_2,
3387      &hf_tn5250_wdsf_ds_flag2_3, &hf_tn5250_wdsf_ds_flag2_4,
3388      &hf_tn5250_wdsf_ds_flag2_5, &hf_tn5250_wdsf_ds_flag2_6,
3389      &hf_tn5250_wdsf_ds_flag2_reserved,
3390      NULL
3391   };
3392
3393   static const int *ds_flag3[] = {
3394      &hf_tn5250_wdsf_ds_flag3_1, &hf_tn5250_wdsf_ds_flag3_reserved,
3395      NULL
3396   };
3397
3398   static const int *ds_gdc[] = {
3399      &hf_tn5250_wdsf_ds_gdc_indicators, &hf_tn5250_wdsf_ds_gdc_reserved,
3400      &hf_tn5250_wdsf_ds_gdc_selection_techniques,
3401      NULL
3402   };
3403
3404   static const int *ds_nws[] = {
3405      &hf_tn5250_wdsf_ds_nws_indicators, &hf_tn5250_wdsf_ds_nws_reserved,
3406      &hf_tn5250_wdsf_ds_nws_selection_techniques,
3407      NULL
3408   };
3409
3410   hf_items ds_fields[] = {
3411     { hf_tn5250_wdsf_ds_flag1, ett_tn5250_wdsf_ds_mask, 1, ds_flag1 },
3412     { hf_tn5250_wdsf_ds_flag2, ett_tn5250_wdsf_ds_mask, 1, ds_flag2 },
3413     { hf_tn5250_wdsf_ds_flag3, ett_tn5250_wdsf_ds_mask, 1, ds_flag3 },
3414     { hf_tn5250_wdsf_ds_type, 0, 1, 0 },
3415     { hf_tn5250_wdsf_ds_gdc, ett_tn5250_wdsf_ds_mask, 1, ds_gdc },
3416     { hf_tn5250_wdsf_ds_nws, ett_tn5250_wdsf_ds_mask, 1, ds_nws },
3417     { hf_tn5250_wdsf_ds_nws_wout, ett_tn5250_wdsf_ds_mask, 1, ds_nws },
3418     { hf_tn5250_reserved, 0, 1, 0 },
3419     { hf_tn5250_reserved, 0, 1, 0 },
3420     { hf_tn5250_wdsf_ds_textsize, 0, 1, 0 },
3421     { hf_tn5250_wdsf_ds_rows, 0, 1, 0 },
3422     { hf_tn5250_wdsf_ds_columns, 0, 1, 0 },
3423     { hf_tn5250_wdsf_ds_padding, 0, 1, 0 },
3424     { hf_tn5250_wdsf_ds_numeric_sep, 0, 1, 0 },
3425     { hf_tn5250_wdsf_ds_country_sel, 0, 1, 0 },
3426     { hf_tn5250_wdsf_ds_cancel_aid, 0, 1, 0 },
3427     { hf_tn5250_wdsf_ds_totalrows, 0, 4, 0 },
3428     { hf_tn5250_wdsf_ds_sliderpos, 0, 4, 0 },
3429     { 0, 0, 0, 0 }
3430   };
3431
3432   static const int *ds_ct_flag1[] = {
3433      &hf_tn5250_wdsf_ds_ct_flag1_choice_state, &hf_tn5250_wdsf_ds_ct_flag1_2,
3434      &hf_tn5250_wdsf_ds_ct_flag1_3, &hf_tn5250_wdsf_ds_ct_flag1_4,
3435      &hf_tn5250_wdsf_ds_ct_flag1_5, &hf_tn5250_wdsf_ds_ct_flag1_numeric_selection,
3436      NULL
3437   };
3438
3439   static const int *ds_ct_flag2[] = {
3440      &hf_tn5250_wdsf_ds_ct_flag2_0, &hf_tn5250_wdsf_ds_ct_flag2_1,
3441      &hf_tn5250_wdsf_ds_ct_flag2_2, &hf_tn5250_wdsf_ds_ct_flag2_3,
3442      &hf_tn5250_wdsf_ds_ct_flag2_4, &hf_tn5250_wdsf_ds_ct_flag2_5,
3443      &hf_tn5250_wdsf_ds_ct_flag2_6, &hf_tn5250_wdsf_ds_ct_flag2_7,
3444      NULL
3445   };
3446
3447   static const int *ds_ct_flag3[] = {
3448      &hf_tn5250_wdsf_ds_ct_flag3_0, &hf_tn5250_wdsf_ds_ct_flag3_1,
3449      &hf_tn5250_wdsf_ds_ct_flag3_2, &hf_tn5250_wdsf_ds_ct_flag3_reserved,
3450      NULL
3451   };
3452
3453   hf_items ds_ct_fields[] = {
3454     { hf_tn5250_length, 0, 1, 0 },
3455     { hf_tn5250_wdsf_ds_minor_type, 0, 1, 0 },
3456     { hf_tn5250_wdsf_ds_ct_flag1, ett_tn5250_wdsf_ds_ct_mask, 1, ds_ct_flag1 },
3457     { hf_tn5250_wdsf_ds_ct_flag2, ett_tn5250_wdsf_ds_ct_mask, 1, ds_ct_flag2 },
3458     { hf_tn5250_wdsf_ds_ct_flag3, ett_tn5250_wdsf_ds_ct_mask, 1, ds_ct_flag3 },
3459     { hf_tn5250_wdsf_ds_ct_mnemonic_offset, 0, 1, 0 },
3460     { hf_tn5250_wdsf_ds_ct_aid, 0, 1, 0 },
3461     { hf_tn5250_wdsf_ds_ct_numeric_onebyte, 0, 1, 0 },
3462     { hf_tn5250_wdsf_ds_ct_numeric_twobyte, 0, 2, 0 },
3463     { 0, 0, 0, 0 }
3464   };
3465
3466   static const int *ds_mbs_flag[] = {
3467      &hf_tn5250_wdsf_ds_mbs_flag_0, &hf_tn5250_wdsf_ds_mbs_flag_1,
3468      &hf_tn5250_wdsf_ds_mbs_flag_reserved,
3469      NULL
3470   };
3471
3472   hf_items ds_mbs_fields[] = {
3473     { hf_tn5250_length, 0, 1, 0 },
3474     { hf_tn5250_wdsf_ds_minor_type, 0, 1, 0 },
3475     { hf_tn5250_wdsf_ds_mbs_flag, ett_tn5250_wdsf_ds_mbs_mask, 1, ds_mbs_flag },
3476     { hf_tn5250_wdsf_ds_mbs_start_column, 0, 1, 0 },
3477     { hf_tn5250_wdsf_ds_mbs_end_column, 0, 1, 0 },
3478     { hf_tn5250_wdsf_ds_mbs_start_column, 0, 1, 0 },
3479     { hf_tn5250_wdsf_ds_mbs_monochrome_sep, 0, 1, 0 },
3480     { hf_tn5250_wdsf_ds_mbs_color_sep, 0, 1, 0 },
3481     { hf_tn5250_wdsf_ds_mbs_sep_char, 0, 1, 0 },
3482     { 0, 0, 0, 0 }
3483   };
3484
3485   static const int *ds_cpda_flag[] = {
3486      &hf_tn5250_wdsf_ds_cpda_flag1_0, &hf_tn5250_wdsf_ds_cpda_flag1_1,
3487       &hf_tn5250_wdsf_ds_cpda_flag1_2, &hf_tn5250_wdsf_ds_cpda_flag1_reserved,
3488      NULL
3489   };
3490
3491   hf_items ds_cpda_fields[] = {
3492     { hf_tn5250_length, 0, 1, 0 },
3493     { hf_tn5250_wdsf_ds_minor_type, 0, 1, 0 },
3494     { hf_tn5250_wdsf_ds_cpda_flag1, ett_tn5250_wdsf_ds_cpda_mask, 1, ds_cpda_flag },
3495     { hf_tn5250_wdsf_ds_cpda_monochrome_sel_avail, 0, 1, 0 },
3496     { hf_tn5250_wdsf_ds_cpda_color_sel_avail, 0, 1, 0 },
3497     { hf_tn5250_wdsf_ds_cpda_monochrome_sel_selected, 0, 1, 0 },
3498     { hf_tn5250_wdsf_ds_cpda_color_sel_selected, 0, 1, 0 },
3499     { hf_tn5250_wdsf_ds_cpda_monochrome_sel_unavail, 0, 1, 0 },
3500     { hf_tn5250_wdsf_ds_cpda_color_sel_unavail, 0, 1, 0 },
3501     { hf_tn5250_wdsf_ds_cpda_monochrome_avail, 0, 1, 0 },
3502     { hf_tn5250_wdsf_ds_cpda_color_avail, 0, 1, 0 },
3503     { hf_tn5250_wdsf_ds_cpda_monochrome_selected, 0, 1, 0 },
3504     { hf_tn5250_wdsf_ds_cpda_color_selected, 0, 1, 0 },
3505     { hf_tn5250_wdsf_ds_cpda_monochrome_unavail, 0, 1, 0 },
3506     { hf_tn5250_wdsf_ds_cpda_color_unavail, 0, 1, 0 },
3507     { hf_tn5250_wdsf_ds_cpda_monochrome_indicator, 0, 1, 0 },
3508     { hf_tn5250_wdsf_ds_cpda_color_indicator, 0, 1, 0 },
3509     { hf_tn5250_wdsf_ds_cpda_monochrome_unavail_indicator, 0, 1, 0 },
3510     { hf_tn5250_wdsf_ds_cpda_color_unavail_indicator, 0, 1, 0 },
3511     { 0, 0, 0, 0 }
3512   };
3513
3514   static const int *ds_ci_flag[] = {
3515      &hf_tn5250_wdsf_ds_ci_flag1_0, &hf_tn5250_wdsf_ds_ci_flag1_reserved,
3516      NULL
3517   };
3518
3519   hf_items ds_ci_fields[] = {
3520     { hf_tn5250_length, 0, 1, 0 },
3521     { hf_tn5250_wdsf_ds_minor_type, 0, 1, 0 },
3522     { hf_tn5250_wdsf_ds_ci_flag1, ett_tn5250_wdsf_ds_ci_mask, 1, ds_ci_flag },
3523     { hf_tn5250_wdsf_ds_ci_left_push, 0, 1, 0 },
3524     { hf_tn5250_wdsf_ds_ci_right_push, 0, 1, 0 },
3525     { hf_tn5250_wdsf_ds_ci_first_choice, 0, 1, 0 },
3526     { 0, 0, 0, 0 }
3527   };
3528
3529   static const int *ds_sbi_flag[] = {
3530      &hf_tn5250_wdsf_ds_sbi_flag1_0, &hf_tn5250_wdsf_ds_sbi_flag1_reserved,
3531      NULL
3532   };
3533
3534   hf_items ds_sbi_fields[] = {
3535     { hf_tn5250_length, 0, 1, 0 },
3536     { hf_tn5250_wdsf_ds_minor_type, 0, 1, 0 },
3537     { hf_tn5250_wdsf_ds_sbi_flag1, ett_tn5250_wdsf_ds_sbi_mask, 1, ds_sbi_flag },
3538     { hf_tn5250_wdsf_ds_sbi_monochrome_top_highlight, 0, 1, 0 },
3539     { hf_tn5250_wdsf_ds_sbi_color_top_highlight, 0, 1, 0 },
3540     { hf_tn5250_wdsf_ds_sbi_monochrome_top_highlight_shaft, 0, 1, 0 },
3541     { hf_tn5250_wdsf_ds_sbi_color_top_highlight_shaft, 0, 1, 0 },
3542     { hf_tn5250_wdsf_ds_sbi_top_character, 0, 1, 0 },
3543     { hf_tn5250_wdsf_ds_sbi_bottom_character, 0, 1, 0 },
3544     { hf_tn5250_wdsf_ds_sbi_empty_character, 0, 1, 0 },
3545     { hf_tn5250_wdsf_ds_sbi_slider_character, 0, 1, 0 },
3546     { 0, 0, 0, 0 }
3547   };
3548
3549   offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, ds_fields);
3550
3551   while (tvb_reported_length_remaining(tvb, offset) > 0 && !done) {
3552     minor_structure = tvb_get_guint8(tvb, offset+1);
3553     switch (minor_structure) {
3554       case DS_CHOICE_TEXT:
3555         length = tvb_get_guint8(tvb, offset);
3556         digit_selection = tvb_get_guint8(tvb, offset+2);
3557         offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, ds_ct_fields);
3558         if (digit_selection & DS_NUMERIC_SELECTION_SINGLE_DIGIT) {
3559           proto_tree_add_item(tn5250_tree, hf_tn5250_wdsf_ds_ct_numeric_onebyte,
3560                               tvb, offset, 1, FALSE);
3561           offset++;
3562         } else if (digit_selection & DS_NUMERIC_SELECTION_DOUBLE_DIGIT) {
3563           proto_tree_add_item(tn5250_tree, hf_tn5250_wdsf_ds_ct_numeric_twobyte,
3564                               tvb, offset, 1, FALSE);
3565           offset++;
3566         }
3567         proto_tree_add_item(tn5250_tree, hf_tn5250_wdsf_ds_ct_text, tvb, offset,
3568                             (length - (offset - start)), FALSE);
3569         offset += (guint32)((length - (offset - start)));
3570         break;
3571       case DS_MENU_BAR_SEPARATOR:
3572         offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, ds_mbs_fields);
3573         break;
3574       case DS_CHOICE_PRESENTATION_DISPLAY:
3575         offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, ds_cpda_fields);
3576         break;
3577       case DS_CHOICE_INDICATORS:
3578         offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, ds_ci_fields);
3579         break;
3580       case DS_SCROLLBAR_INDICATORS:
3581         offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, ds_sbi_fields);
3582         break;
3583       default:
3584         done = 1;
3585         break;
3586     }
3587   }
3588   return (offset - start);
3589 }
3590
3591 static guint32
3592 dissect_define_scrollbar(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset)
3593 {
3594   int start = offset;
3595   int done = 0, minor_structure = 0;
3596
3597   static const int *dsb_byte[] = {
3598      &hf_tn5250_wdsf_dsb_flag1_0, &hf_tn5250_wdsf_dsb_flag1_1,
3599      &hf_tn5250_wdsf_dsb_flag1_reserved, &hf_tn5250_wdsf_dsb_flag1_7,
3600      NULL
3601   };
3602
3603   hf_items dsb_fields[] = {
3604     { hf_tn5250_wdsf_dsb_flag1, ett_tn5250_wdsf_dsb_mask, 1, dsb_byte },
3605     { hf_tn5250_reserved, 0, 1, 0 },
3606     { hf_tn5250_wdsf_sbi_total_scroll, 0, 4, 0 },
3607     { hf_tn5250_wdsf_sbi_sliderpos, 0, 4, 0 },
3608     { hf_tn5250_wdsf_sbi_rowscols, 0, 1, 0 },
3609     { 0, 0, 0, 0 }
3610   };
3611
3612   static const int *ds_sbi_flag[] = {
3613      &hf_tn5250_wdsf_ds_sbi_flag1_0, &hf_tn5250_wdsf_ds_sbi_flag1_reserved,
3614      NULL
3615   };
3616
3617   hf_items ds_sbi_fields[] = {
3618     { hf_tn5250_length, 0, 1, 0 },
3619     { hf_tn5250_wdsf_ds_minor_type, 0, 1, 0 },
3620     { hf_tn5250_wdsf_ds_sbi_flag1, ett_tn5250_wdsf_ds_sbi_mask, 1, ds_sbi_flag },
3621     { hf_tn5250_wdsf_ds_sbi_monochrome_top_highlight, 0, 1, 0 },
3622     { hf_tn5250_wdsf_ds_sbi_color_top_highlight, 0, 1, 0 },
3623     { hf_tn5250_wdsf_ds_sbi_monochrome_top_highlight_shaft, 0, 1, 0 },
3624     { hf_tn5250_wdsf_ds_sbi_color_top_highlight_shaft, 0, 1, 0 },
3625     { hf_tn5250_wdsf_ds_sbi_top_character, 0, 1, 0 },
3626     { hf_tn5250_wdsf_ds_sbi_bottom_character, 0, 1, 0 },
3627     { hf_tn5250_wdsf_ds_sbi_empty_character, 0, 1, 0 },
3628     { hf_tn5250_wdsf_ds_sbi_slider_character, 0, 1, 0 },
3629     { 0, 0, 0, 0 }
3630   };
3631
3632
3633   offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, dsb_fields);
3634
3635   while (tvb_reported_length_remaining(tvb, offset) > 0 && !done) {
3636     minor_structure = tvb_get_guint8(tvb, offset+1);
3637     switch (minor_structure) {
3638       case DS_SCROLLBAR_INDICATORS:
3639         offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, ds_sbi_fields);
3640         break;
3641       default:
3642         done = 1;
3643         break;
3644     }
3645   }
3646   return (offset - start);
3647 }
3648
3649 static guint32
3650 dissect_draw_erase_gridlines(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset)
3651 {
3652   int start = offset;
3653   int done = 0, minor_structure=0;
3654
3655   static const int *deg_byte[] = {
3656      &hf_tn5250_wdsf_deg_flag1_0, &hf_tn5250_wdsf_deg_flag1_reserved,
3657      NULL
3658   };
3659
3660   static const int *deg_byte2[] = {
3661      &hf_tn5250_wdsf_deg_flag2_0, &hf_tn5250_wdsf_deg_flag2_reserved,
3662      NULL
3663   };
3664
3665   hf_items deg_fields[] = {
3666     { hf_tn5250_wdsf_deg_partition, 0, 1, 0 },
3667     { hf_tn5250_wdsf_deg_flag1, ett_tn5250_wdsf_deg_mask, 1, deg_byte },
3668     { hf_tn5250_reserved, 0, 1, 0 },
3669     { hf_tn5250_wdsf_deg_flag2, ett_tn5250_wdsf_deg_mask, 1, deg_byte2 },
3670     { hf_tn5250_reserved, 0, 1, 0 },
3671     { hf_tn5250_wdsf_deg_default_color, 0, 1, 0 },
3672     { hf_tn5250_wdsf_deg_default_line, 0, 1, 0 },
3673     { 0, 0, 0, 0 }
3674   };
3675
3676
3677   static const int *deg_ms_byte[] = {
3678      &hf_tn5250_wdsf_deg_ms_flag1_0, &hf_tn5250_wdsf_deg_ms_flag1_reserved,
3679      NULL
3680   };
3681
3682   hf_items deg_ms_fields[] = {
3683     { hf_tn5250_length, 0, 1, 0 },
3684     { hf_tn5250_wdsf_deg_minor_type, 0, 1, 0 },
3685     { hf_tn5250_wdsf_deg_ms_flag1, ett_tn5250_wdsf_deg_ms_mask, 1, deg_ms_byte },
3686     { hf_tn5250_wdsf_deg_ms_start_row, 0, 1, 0 },
3687     { hf_tn5250_wdsf_deg_ms_start_column, 0, 1, 0 },
3688     { hf_tn5250_wdsf_deg_ms_horizontal_dimension, 0, 1, 0 },
3689     { hf_tn5250_wdsf_deg_ms_vertical_dimension, 0, 1, 0 },
3690     { hf_tn5250_wdsf_deg_ms_default_color, 0, 1, 0 },
3691     { hf_tn5250_wdsf_deg_ms_line_repeat, 0, 1, 0 },
3692     { hf_tn5250_wdsf_deg_ms_line_interval, 0, 1, 0 },
3693     { 0, 0, 0, 0 }
3694   };
3695
3696   offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, deg_fields);
3697
3698   while (tvb_reported_length_remaining(tvb, offset) > 0 && !done) {
3699     minor_structure = tvb_get_guint8(tvb, offset+1);
3700     switch (minor_structure) {
3701       case UPPER_HORIZONTAL_LINE:
3702       case LOWER_HORIZONTAL_LINE:
3703       case LEFT_VERTICAL_LINE:
3704       case RIGHT_VERTICAL_LINE:
3705       case PLAIN_BOX:
3706       case HORIZONTALLY_RULED_BOX:
3707       case VERTICALLY_RULED_BOX:
3708       case HORIZONTALLY_AND_VERTICALLY_RULED_BOX:
3709         offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, deg_ms_fields);
3710         break;
3711       default:
3712         done = 1;
3713         break;
3714     }
3715   }
3716   return (offset - start);
3717 }
3718
3719 static guint32
3720 dissect_wdsf_structured_field(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset)
3721 {
3722   int start = offset;
3723   int length = 0, type;
3724   int done = 0, ln_left = 0, i = 0;
3725
3726   hf_items standard_fields[] = {
3727     { hf_tn5250_sf_length, 0, 2, 0 },
3728     { hf_tn5250_sf_class, 0, 1, 0 },
3729     { hf_tn5250_sf_type, 0, 1, 0 },
3730     { 0, 0, 0, 0 }
3731   };
3732
3733   static const int *rgw_byte[] = {
3734      &hf_tn5250_wdsf_rgw_flag1_0,
3735      &hf_tn5250_wdsf_rgw_flag1_1,
3736      &hf_tn5250_wdsf_rgw_reserved,
3737      NULL
3738   };
3739
3740   hf_items rgw_fields[] = {
3741     { hf_tn5250_wdsf_rgw_flag1, ett_tn5250_wdsf_rgw_mask, 1, rgw_byte },
3742     { hf_tn5250_reserved, 0, 1, 0 },
3743     { hf_tn5250_reserved, 0, 1, 0 },
3744     { 0, 0, 0, 0 }
3745   };
3746
3747   static const int *ragc_byte[] = {
3748      &hf_tn5250_wdsf_ragc_flag1_0,
3749      &hf_tn5250_wdsf_ragc_reserved,
3750      NULL
3751   };
3752
3753   hf_items ragc_fields[] = {
3754     { hf_tn5250_wdsf_ragc_flag1, ett_tn5250_wdsf_ragc_mask, 1, ragc_byte },
3755     { hf_tn5250_reserved, 0, 1, 0 },
3756     { hf_tn5250_reserved, 0, 1, 0 },
3757     { 0, 0, 0, 0 }
3758   };
3759
3760   static const int *wdf_byte[] = {
3761      &hf_tn5250_wdsf_wdf_flag1_0,
3762      &hf_tn5250_wdsf_wdf_flag1_reserved,
3763      NULL
3764   };
3765
3766   hf_items wdf_fields[] = {
3767     { hf_tn5250_wdsf_wdf_flag1, ett_tn5250_wdsf_wdf_mask, 1, wdf_byte },
3768     { hf_tn5250_reserved, 0, 1, 0 },
3769     { 0, 0, 0, 0 }
3770   };
3771
3772   static const int *pmb_byte[] = {
3773      &hf_tn5250_wdsf_pmb_flag1_0, &hf_tn5250_wdsf_pmb_flag1_1,
3774      &hf_tn5250_wdsf_pmb_flag1_2, &hf_tn5250_wdsf_pmb_flag1_3,
3775      &hf_tn5250_wdsf_pmb_flag1_reserved,
3776      NULL
3777   };
3778
3779   hf_items pmb_fields[] = {
3780     { hf_tn5250_wdsf_pmb_flag1, ett_tn5250_wdsf_pmb_mask, 1, pmb_byte },
3781     { hf_tn5250_wdsf_pmb_first_mouse_event, 0, 1, 0 },
3782     { hf_tn5250_wdsf_pmb_second_mouse_event, 0, 1, 0 },
3783     { hf_tn5250_aid, 0, 1, 0 },
3784     { 0, 0, 0, 0 }
3785   };
3786
3787   hf_items cgl_fields[] = {
3788     { hf_tn5250_wdsf_cgl_partition, 0, 1, 0 },
3789     { hf_tn5250_wdsf_cgl_start_row, 0, 1, 0 },
3790     { hf_tn5250_wdsf_cgl_start_column, 0, 1, 0 },
3791     { hf_tn5250_wdsf_cgl_rectangle_width, 0, 1, 0 },
3792     { hf_tn5250_wdsf_cgl_rectangle_height, 0, 1, 0 },
3793     { 0, 0, 0, 0 }
3794   };
3795
3796   length = tvb_get_ntohs(tvb,offset);
3797   type = tvb_get_guint8(tvb, offset+3);
3798
3799   offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, standard_fields);
3800
3801   while (tvb_reported_length_remaining(tvb, offset) > 0 && !done) {
3802     switch (type) {
3803       case CREATE_WINDOW:
3804         offset += dissect_create_window(tn5250_tree, tvb, offset);
3805         break;
3806       case UNRESTRICTED_WINDOW_CURSOR_MOVEMENT:
3807       case REMOVE_GUI_SELECTION_FIELD:
3808       case REMOVE_GUI_SCROLL_BAR_FIELD:
3809         proto_tree_add_item(tn5250_tree, hf_tn5250_reserved, tvb, offset,
3810                             1, FALSE);
3811         proto_tree_add_item(tn5250_tree, hf_tn5250_reserved, tvb, offset,
3812                             1, FALSE);
3813         offset +=2;
3814         break;
3815       case REMOVE_GUI_WINDOW:
3816         offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, rgw_fields);
3817         break;
3818       case REMOVE_ALL_GUI_CONSTRUCTS:
3819         offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, ragc_fields);
3820         break;
3821       case DEFINE_SELECTION_FIELD:
3822         offset += dissect_define_selection(tn5250_tree, tvb, offset);
3823         break;
3824       case DEFINE_SCROLL_BAR_FIELD:
3825         offset += dissect_define_scrollbar(tn5250_tree, tvb, offset);
3826         break;
3827       case WRITE_DATA:
3828         offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, wdf_fields);
3829         proto_tree_add_item(tn5250_tree, hf_tn5250_field_data, tvb, offset,
3830                             (length - 6), FALSE);
3831         offset += (guint32)((length - 6));
3832         break;
3833       case PROGRAMMABLE_MOUSE_BUTTONS:
3834         proto_tree_add_item(tn5250_tree, hf_tn5250_reserved, tvb, offset,
3835                             1, FALSE);
3836         proto_tree_add_item(tn5250_tree, hf_tn5250_reserved, tvb, offset,
3837                             1, FALSE);
3838         offset +=2;
3839         ln_left = length - (offset - start);
3840         for (i = 0; i < ln_left; i+=4) {
3841           offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, pmb_fields);
3842         }
3843         break;
3844       case DRAW_ERASE_GRID_LINES:
3845         offset += dissect_draw_erase_gridlines(tn5250_tree, tvb, offset);
3846         break;
3847       case CLEAR_GRID_LINE_BUFFER:
3848         offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, cgl_fields);
3849         break;
3850       default:
3851         done = 1;
3852         break;
3853     }
3854   }
3855   offset += dissect_unknown_data(tn5250_tree, tvb, offset, start, length);
3856
3857   return (offset - start);
3858
3859 }
3860
3861
3862 /* 15.6 WRITE TO DISPLAY Command - Orders and Data */
3863 static guint32
3864 dissect_tn5250_ra_data(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset)
3865 {
3866   gint order_code, done = 0;
3867   gint start = offset;
3868
3869   while (tvb_reported_length_remaining(tvb, offset) > 0 && !done) {
3870     order_code = tvb_get_guint8(tvb, offset);
3871     switch (order_code) {
3872           case TN5250_IC:
3873           case TN5250_MC:
3874           case TN5250_SBA:
3875           case TN5250_RA:
3876           case TN5250_EA:
3877           case TN5250_SOH:
3878           case TN5250_TD:
3879           case TN5250_WEA:
3880           case TN5250_SF:
3881           case TN5250_WDSF:
3882           case TN5250_ESCAPE:
3883             done = 1;
3884             break;
3885           default:
3886             offset++;
3887             break;
3888     }
3889   }
3890
3891   if (offset > start) {
3892     proto_tree_add_item(tn5250_tree, hf_tn5250_repeated_character,
3893                         tvb, start, (offset - start), FALSE);
3894   }
3895   return (offset - start);
3896
3897 }
3898
3899 static guint32
3900 dissect_tn5250_orders_and_data(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset)
3901 {
3902   gint start = offset, done = 0;
3903   gint order_code;
3904   proto_tree   *cc_tree;
3905   proto_item   *ti;
3906
3907   /* Order Code */
3908
3909   while (tvb_reported_length_remaining(tvb, offset) > 0 && !done) {
3910     order_code = tvb_get_guint8(tvb, offset);
3911     switch (order_code) {
3912           case TN5250_IC:
3913           case TN5250_MC:
3914           case TN5250_SBA:
3915             ti = proto_tree_add_item(tn5250_tree, hf_tn5250_order_code, tvb,
3916                                      offset, 1, FALSE);
3917             offset++;
3918             cc_tree = proto_item_add_subtree(ti, ett_cc);
3919             offset += dissect_row_column(cc_tree, tvb, offset);
3920             offset += dissect_tn5250_ra_data(cc_tree, tvb, offset);
3921             break;
3922           case TN5250_RA:
3923             ti = proto_tree_add_item(tn5250_tree, hf_tn5250_order_code, tvb,
3924                                      offset, 1, FALSE);
3925             offset++;
3926             cc_tree = proto_item_add_subtree(ti, ett_cc);
3927             offset += dissect_row_column(cc_tree, tvb, offset);
3928             offset += dissect_tn5250_ra_data(cc_tree, tvb, offset);
3929             break;
3930           case TN5250_EA:
3931             ti = proto_tree_add_item(tn5250_tree, hf_tn5250_order_code, tvb,
3932                                      offset, 1, FALSE);
3933             offset++;
3934             cc_tree = proto_item_add_subtree(ti, ett_cc);
3935             offset += dissect_erase_to_address(cc_tree, tvb, offset);
3936             break;
3937           case TN5250_SOH:
3938             ti = proto_tree_add_item(tn5250_tree, hf_tn5250_order_code, tvb,
3939                                      offset, 1, FALSE);
3940             offset++;
3941             cc_tree = proto_item_add_subtree(ti, ett_cc);
3942             offset += dissect_start_of_header(cc_tree, tvb, offset);
3943             break;
3944           case TN5250_TD:
3945             ti = proto_tree_add_item(tn5250_tree, hf_tn5250_order_code, tvb,
3946                                      offset, 1, FALSE);
3947             offset++;
3948             cc_tree = proto_item_add_subtree(ti, ett_cc);
3949             offset += dissect_twobyte_length_and_data(cc_tree, tvb, offset);
3950             break;
3951           case TN5250_WEA:
3952             ti = proto_tree_add_item(tn5250_tree, hf_tn5250_order_code, tvb,
3953                                      offset, 1, FALSE);
3954             offset++;
3955             cc_tree = proto_item_add_subtree(ti, ett_cc);
3956             offset += dissect_field_attribute_pair(cc_tree, tvb, offset);
3957             break;
3958           case TN5250_SF:
3959             ti = proto_tree_add_item(tn5250_tree, hf_tn5250_order_code, tvb,
3960                                      offset, 1, FALSE);
3961             offset++;
3962             cc_tree = proto_item_add_subtree(ti, ett_cc);
3963             offset += dissect_start_of_field(cc_tree, tvb, offset);
3964             offset += dissect_tn5250_ra_data(cc_tree, tvb, offset);
3965             break;
3966           case TN5250_WDSF:
3967             ti = proto_tree_add_item(tn5250_tree, hf_tn5250_order_code, tvb,
3968                                      offset, 1, FALSE);
3969             offset++;
3970             cc_tree = proto_item_add_subtree(ti, ett_cc);
3971             offset += dissect_wdsf_structured_field(cc_tree, tvb, offset);
3972             break;
3973           default:
3974             done = 1;
3975             break;
3976     }
3977   }
3978   return (offset - start);
3979 }
3980
3981 /* 15.22 SAVE PARTIAL SCREEN Command */
3982 static guint32
3983 dissect_save_partial_screen(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset)
3984 {
3985   int start = offset;
3986   int length = 0;
3987
3988   static const int *byte[] = {
3989      &hf_tn5250_sps_flag1_0,
3990      &hf_tn5250_sps_flag1_reserved,
3991      NULL
3992   };
3993
3994   hf_items save_partial_screen_fields[] = {
3995       { hf_tn5250_soh_length, 0, 1, 0 },
3996       { hf_tn5250_sps_flag1, ett_tn5250_sps_mask, 1, byte },
3997       { hf_tn5250_sps_top_row, 0, 1, 0 },
3998       { hf_tn5250_sps_left_column, 0, 1, 0 },
3999       { hf_tn5250_sps_window_depth, 0, 1, 0 },
4000       { hf_tn5250_sps_window_width, 0, 1, 0 },
4001       { 0, 0, 0, 0 }
4002   };
4003
4004   length = tvb_get_guint8(tvb, offset);
4005
4006   offset += tn5250_add_hf_items(tn5250_tree, tvb, offset,
4007                                 save_partial_screen_fields);
4008
4009   offset += dissect_unknown_data(tn5250_tree, tvb, offset, start, length);
4010
4011   return (offset - start);
4012 }
4013
4014 /* 15.25 ROLL Command */
4015 static guint32
4016 dissect_roll(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset)
4017 {
4018   int start = offset;
4019
4020   static const int *byte[] = {
4021     &hf_tn5250_roll_flag1_0,
4022     &hf_tn5250_roll_flag1_reserved,
4023     &hf_tn5250_roll_flag1_lines,
4024     NULL
4025   };
4026
4027   hf_items roll_fields[] = {
4028       { hf_tn5250_roll_flag1, ett_tn5250_roll_mask, 1, byte },
4029       { hf_tn5250_roll_top_line, 0, 1, 0 },
4030       { hf_tn5250_roll_bottom_line, 0, 1, 0 },
4031       { 0, 0, 0, 0 }
4032   };
4033
4034
4035   offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, roll_fields);
4036
4037   return (offset - start);
4038 }
4039
4040 /* 15.26 WRITE SINGLE STRUCTURED FIELD Command */
4041 static guint32
4042 dissect_write_single_structured_field_minor_fields(proto_tree *tn5250_tree,
4043                                                    tvbuff_t *tvb, gint offset)
4044 {
4045
4046   int start = offset;
4047   int done = 0, type = 0;
4048
4049   static const int *byte_wssf_kbc_flag1[] = {
4050     &hf_tn5250_wssf_kbc_flag1_reserved,
4051     &hf_tn5250_wssf_kbc_flag1_5,
4052     &hf_tn5250_wssf_kbc_flag1_6,
4053     &hf_tn5250_wssf_kbc_flag1_7,
4054     NULL
4055   };
4056
4057   static const int *byte_wssf_cc_flag1[] = {
4058     &hf_tn5250_wssf_cc_flag1_reserved,
4059     &hf_tn5250_wssf_cc_flag1_7,
4060     NULL
4061   };
4062
4063   hf_items wsc_customization_kbc_fields[] = {
4064       { hf_tn5250_sf_length, 0, 1, 0},
4065       { hf_tn5250_wssf_wsc_minor_type, 0, 1, 0},
4066       { hf_tn5250_wssf_kbc_flag1, ett_tn5250_wssf_kbc_mask, 1, byte_wssf_kbc_flag1 },
4067       { 0, 0, 0, 0 }
4068   };
4069
4070   hf_items wsc_customization_cc_fields[] = {
4071       { hf_tn5250_sf_length, 0, 1, 0},
4072       { hf_tn5250_wssf_wsc_minor_type, 0, 1, 0},
4073       { hf_tn5250_wssf_cc_flag1, ett_tn5250_wssf_cc_mask, 1, byte_wssf_cc_flag1 },
4074       { 0, 0, 0, 0 }
4075   };
4076
4077   while (tvb_reported_length_remaining(tvb, offset) > 0 && !done) {
4078     type = tvb_get_guint8(tvb, offset+1);
4079     switch (type) {
4080       case KEYSTROKE_BUFFERING_CONTROL:
4081         offset += tn5250_add_hf_items(tn5250_tree, tvb, offset,
4082                                       wsc_customization_kbc_fields);
4083         break;
4084       case CURSOR_CONTROL:
4085         offset += tn5250_add_hf_items(tn5250_tree, tvb, offset,
4086                                       wsc_customization_cc_fields);
4087         break;
4088       default:
4089         done = 1;
4090         break;
4091     }
4092   }
4093
4094   return (offset - start);
4095
4096 }
4097
4098 static guint32
4099 dissect_write_single_structured_field(proto_tree *tn5250_tree, tvbuff_t *tvb,
4100                                       gint offset)
4101 {
4102   int start = offset;
4103   int length, type, done = 0;
4104   guint32 namelength;
4105
4106   static const int *byte[] = {
4107     &hf_tn5250_wssf_flag2_0,
4108     &hf_tn5250_wssf_flag2_1,
4109     &hf_tn5250_wssf_flag2_2,
4110     &hf_tn5250_wssf_flag2_3,
4111     &hf_tn5250_wssf_flag2_4,
4112     &hf_tn5250_wssf_flag2_5,
4113     &hf_tn5250_wssf_flag2_6,
4114     &hf_tn5250_wssf_flag2_7,
4115     NULL
4116   };
4117
4118   static const int *ifc_byte[] = {
4119     &hf_tn5250_wssf_ifc_flag1_0,
4120     &hf_tn5250_wssf_ifc_flag1_1to3,
4121     &hf_tn5250_wssf_ifc_flag1_4,
4122     &hf_tn5250_wssf_ifc_flag1_5,
4123     &hf_tn5250_wssf_ifc_flag1_6,
4124     &hf_tn5250_wssf_ifc_flag1_7,
4125     NULL
4126   };
4127
4128   static const int *ifc_byte2[] = {
4129     &hf_tn5250_wssf_ifc_flag2_0,
4130     &hf_tn5250_wssf_ifc_flag2_1,
4131     &hf_tn5250_wssf_ifc_flag2_reserved,
4132     &hf_tn5250_wssf_ifc_flag2_7,
4133     NULL
4134   };
4135
4136   static const int *ifd_byte[] = {
4137     &hf_tn5250_wssf_ifd_flag1_0,
4138     &hf_tn5250_wssf_ifd_flag1_reserved,
4139     NULL
4140   };
4141
4142
4143   hf_items standard_fields[] = {
4144       { hf_tn5250_sf_length, 0, 2, 0 },
4145       { hf_tn5250_sf_class, 0, 1, 0 },
4146       { hf_tn5250_sf_type, 0, 1, 0 },
4147       { 0, 0, 0, 0 }
4148   };
4149
4150   hf_items wsc_customization_fields[] = {
4151       { hf_tn5250_wssf_flag1, 0, 1, 0 },
4152       { hf_tn5250_wssf_flag2, ett_tn5250_wssf_mask, 1, byte },
4153       { 0, 0, 0, 0 }
4154   };
4155
4156   hf_items wsc_image_control_fields[] = {
4157       { hf_tn5250_wssf_ifc_flag1, ett_tn5250_wssf_ifc_mask, 1, ifc_byte },
4158       { hf_tn5250_wssf_ifc_flag2, ett_tn5250_wssf_ifc_mask, 1, ifc_byte2 },
4159       { hf_tn5250_wssf_ifc_image_format, 0, 2, 0 },
4160       { hf_tn5250_wssf_ifc_viewport_location_row, 0, 1, 0 },
4161       { hf_tn5250_wssf_ifc_viewport_location_col, 0, 1, 0 },
4162       { hf_tn5250_wssf_ifc_viewport_size_row, 0, 1, 0 },
4163       { hf_tn5250_wssf_ifc_viewport_size_col, 0, 1, 0 },
4164       { hf_tn5250_wssf_ifc_scaling, 0, 2, 0 },
4165       { hf_tn5250_wssf_ifc_viewimage_location_row, 0, 1, 0 },
4166       { hf_tn5250_wssf_ifc_viewimage_location_col, 0, 1, 0 },
4167       { hf_tn5250_wssf_ifc_rotation, 0, 2, 0 },
4168       { hf_tn5250_wssf_ifc_foreground_color, 0, 1, 0 },
4169       { hf_tn5250_wssf_ifc_background_color, 0, 1, 0 },
4170       { 0, 0, 0, 0 }
4171   };
4172
4173   hf_items wsc_image_download_fields[] = {
4174       { hf_tn5250_wssf_ifd_flag1, ett_tn5250_wssf_ifd_mask, 1, ifd_byte },
4175       { hf_tn5250_reserved, 0, 1, 0 },
4176       { hf_tn5250_reserved, 0, 1, 0 },
4177       { hf_tn5250_reserved, 0, 1, 0 },
4178       { hf_tn5250_reserved, 0, 1, 0 },
4179       { hf_tn5250_reserved, 0, 1, 0 },
4180       { hf_tn5250_length, 0, 2, 0 },
4181       { 0, 0, 0, 0 }
4182   };
4183
4184   length = tvb_get_ntohs(tvb,offset);
4185   type = tvb_get_guint8(tvb, offset+3);
4186
4187   offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, standard_fields);
4188
4189   while (tvb_reported_length_remaining(tvb, offset) > 0 && !done) {
4190     switch (type) {
4191       case WSC_CUSTOMIZATION:
4192         offset += tn5250_add_hf_items(tn5250_tree, tvb, offset,
4193                                       wsc_customization_fields);
4194         offset += dissect_write_single_structured_field_minor_fields(tn5250_tree, tvb, offset);
4195         break;
4196       case IMAGE_FAX_CONTROL:
4197         offset += tn5250_add_hf_items(tn5250_tree, tvb, offset,
4198                                       wsc_image_control_fields);
4199         proto_tree_add_item(tn5250_tree, hf_tn5250_wssf_ifc_imagefax_name, tvb, offset,
4200                             (length - (start + offset)), FALSE);
4201         if (length > (start + offset))
4202           offset += (guint32)(length - (start + offset));
4203         break;
4204       case IMAGE_FAX_DOWNLOAD:
4205         namelength = tvb_get_ntohs(tvb,offset+6);
4206         offset += tn5250_add_hf_items(tn5250_tree, tvb, offset,
4207                                       wsc_image_download_fields);
4208         proto_tree_add_item(tn5250_tree, hf_tn5250_wssf_ifd_imagefax_name, tvb, offset,
4209                             namelength, FALSE);
4210         offset += namelength;
4211         proto_tree_add_item(tn5250_tree, hf_tn5250_wssf_ifd_imagefax_data, tvb, offset,
4212                             (length - (start + offset)), FALSE);
4213         if (length > (start + offset))
4214           offset += (guint32)(length - (start + offset));
4215         break;
4216       case VIDEO_AUDIO_CONTROLS:
4217         proto_tree_add_item(tn5250_tree, hf_tn5250_vac_prefix, tvb, offset,
4218                             2, FALSE);
4219         offset += 2;
4220         proto_tree_add_item(tn5250_tree, hf_tn5250_vac_data, tvb, offset,
4221                             4, FALSE);
4222         offset += 2;
4223         break;
4224       case TRUE_TRANSPARENCY_WRITE:
4225         proto_tree_add_item(tn5250_tree, hf_tn5250_wssf_ttw_flag, tvb, offset,
4226                             1, FALSE);
4227         offset ++;
4228         proto_tree_add_item(tn5250_tree, hf_tn5250_wssf_ttw_data, tvb, offset,
4229                             (length - (start + offset)), FALSE);
4230         if (length > (start + offset))
4231           offset += (guint32)(length - (start + offset));
4232         break;
4233       default:
4234         done = 1;
4235         break;
4236     }
4237   }
4238   offset += dissect_unknown_data(tn5250_tree, tvb, offset, start, length);
4239
4240   return (offset - start);
4241 }
4242
4243 /* 15.27 WRITE STRUCTURED FIELD Command */
4244 static guint32
4245 dissect_write_structured_field(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset)
4246 {
4247   int start = offset;
4248   guint16 sf_length = 0;
4249   int length, type, done = 0, used = 0;
4250
4251   hf_items standard_fields[] = {
4252       { hf_tn5250_sf_length, 0, 2, 0 },
4253       { hf_tn5250_sf_class, 0, 1, 0 },
4254       { hf_tn5250_sf_type, 0, 1, 0 },
4255       { 0, 0, 0, 0 }
4256   };
4257
4258   static const int *qss_byte1[] = {
4259      &hf_tn5250_wsf_qss_flag1_0,
4260      &hf_tn5250_wsf_qss_flag1_reserved,
4261      NULL
4262   };
4263
4264   static const int *qss_byte2[] = {
4265      &hf_tn5250_wsf_qss_flag2_reserved,
4266      &hf_tn5250_wsf_qss_flag2_7,
4267      NULL
4268   };
4269
4270   hf_items qss_fields[] = {
4271       { hf_tn5250_wsf_qss_flag1, ett_tn5250_wsf_qss_mask, 1, qss_byte1 },
4272       { hf_tn5250_wsf_qss_flag2, ett_tn5250_wsf_qss_mask, 1, qss_byte2 },
4273       { 0, 0, 0, 0 }
4274   };
4275
4276   hf_items dawt_fields[] = {
4277       { hf_tn5250_dawt_length, 0, 1, 0 },
4278       { hf_tn5250_dawt_char, 0, 1, 0 },
4279       { 0, 0, 0, 0 }
4280   };
4281
4282   hf_items dckf_fields[] = {
4283       { hf_tn5250_dckf_length, 0, 1, 0 },
4284       { hf_tn5250_dckf_key_code, 0, 1, 0 },
4285       { hf_tn5250_dckf_function_code, 0, 1, 0 },
4286       { 0, 0, 0, 0 }
4287   };
4288
4289   static const int *rts_byte1[] = {
4290      &hf_tn5250_rts_flag1_0,
4291      &hf_tn5250_rts_flag1_reserved,
4292      NULL
4293   };
4294
4295   hf_items rts_fields[] = {
4296       { hf_tn5250_rts_partition, 0, 1, 0 },
4297       { hf_tn5250_rts_flag1, ett_tn5250_wsf_rts_mask, 1, rts_byte1 },
4298       { hf_tn5250_reserved, 0, 1, 0 },
4299       { hf_tn5250_reserved, 0, 1, 0 },
4300       { 0, 0, 0, 0 }
4301   };
4302
4303   static const int *dpo_byte1[] = {
4304      &hf_tn5250_dpo_flag1_0,
4305      &hf_tn5250_dpo_flag1_1,
4306      &hf_tn5250_dpo_flag1_2,
4307      &hf_tn5250_dpo_flag1_3,
4308      &hf_tn5250_dpo_flag1_4,
4309      &hf_tn5250_dpo_flag1_5,
4310      &hf_tn5250_dpo_flag1_6,
4311      &hf_tn5250_dpo_flag1_7,
4312      NULL
4313   };
4314
4315   static const int *dpo_byte2[] = {
4316      &hf_tn5250_dpo_flag2_0,
4317      &hf_tn5250_dpo_flag2_reserved,
4318      NULL
4319   };
4320
4321   hf_items dpo_fields[] = {
4322       { hf_tn5250_dpo_partition, 0, 1, 0 },
4323       { hf_tn5250_dpo_flag1, ett_tn5250_wsf_dpo_mask, 1, dpo_byte1 },
4324       { hf_tn5250_dpo_flag2, ett_tn5250_wsf_dpo_mask, 1, dpo_byte2 },
4325       { hf_tn5250_dpo_displace_characters, 0, 3, 0 },
4326       { hf_tn5250_dpo_start_location_row, 0, 2, 0 },
4327       { hf_tn5250_dpo_start_location_col, 0, 2, 0 },
4328       { 0, 0, 0, 0 }
4329   };
4330
4331   static const int *dtsf_byte1[] = {
4332      &hf_tn5250_dtsf_flag1_0,
4333      &hf_tn5250_dtsf_flag1_1,
4334      &hf_tn5250_dtsf_flag1_2,
4335      &hf_tn5250_dtsf_flag1_3,
4336      &hf_tn5250_dtsf_flag1_4,
4337      &hf_tn5250_dtsf_flag1_5,
4338      &hf_tn5250_dtsf_flag1_6,
4339      &hf_tn5250_dtsf_flag1_7,
4340      NULL
4341   };
4342
4343   static const int *dtsf_byte2[] = {
4344      &hf_tn5250_dtsf_flag2_0,
4345      &hf_tn5250_dtsf_flag2_1,
4346      &hf_tn5250_dtsf_flag2_2,
4347      &hf_tn5250_dtsf_flag2_3,
4348      &hf_tn5250_dtsf_flag2_4to7,
4349      NULL
4350   };
4351
4352   hf_items dtsf_fields[] = {
4353       { hf_tn5250_dtsf_partition, 0, 1, 0 },
4354       { hf_tn5250_dtsf_flag1, ett_tn5250_wsf_dtsf_mask, 1, dtsf_byte1 },
4355       { hf_tn5250_dtsf_flag2, ett_tn5250_wsf_dtsf_mask, 1, dtsf_byte2 },
4356       { hf_tn5250_dtsf_text_body_height, 0, 2, 0 },
4357       { hf_tn5250_dtsf_text_body_width, 0, 2, 0 },
4358       { hf_tn5250_dtsf_line_cmd_field_size, 0, 1, 0 },
4359       { hf_tn5250_dtsf_location_of_pitch, 0, 1, 0 },
4360       { hf_tn5250_dtsf_first_line, 0, 1, 0 },
4361       { 0, 0, 0, 0 }
4362   };
4363
4364   static const int *dsl_byte1[] = {
4365      &hf_tn5250_dsl_flag1_0,
4366      &hf_tn5250_dsl_flag1_1,
4367      &hf_tn5250_dsl_flag1_2,
4368      &hf_tn5250_dsl_flag1_reserved,
4369      NULL
4370   };
4371
4372   hf_items dsl_fields[] = {
4373       { hf_tn5250_dsl_partition, 0, 1, 0 },
4374       { hf_tn5250_reserved, 0, 1, 0 },
4375       { hf_tn5250_dsl_rtl_offset, 0, 1, 0 },
4376       { hf_tn5250_dsl_offset, 0, 1, 0 },
4377       { 0, 0, 0, 0 }
4378   };
4379
4380   hf_items dsl_fields2[] = {
4381       { hf_tn5250_length, 0, 1, 0 },
4382       { hf_tn5250_dsl_flag1, ett_tn5250_wsf_dsl_mask, 1, dsl_byte1 },
4383       { hf_tn5250_dsl_id, 0, 1, 0 },
4384       { hf_tn5250_dsl_location, 0, 1, 0 },
4385       { hf_tn5250_dsl_function, 0, 1, 0 },
4386       { 0, 0, 0, 0 }
4387   };
4388
4389   static const int *wts_byte1[] = {
4390      &hf_tn5250_wts_flag1_0,
4391      &hf_tn5250_wts_flag1_1,
4392      &hf_tn5250_wts_flag1_2,
4393      &hf_tn5250_wts_flag1_3,
4394      &hf_tn5250_wts_flag1_reserved,
4395      NULL
4396   };
4397
4398   static const int *wts_byte2[] = {
4399      &hf_tn5250_wts_flag2_reserved,
4400      &hf_tn5250_wts_flag2_6,
4401      &hf_tn5250_wts_flag2_reserved2,
4402      NULL
4403   };
4404
4405   static const int *wts_byte3[] = {
4406      &hf_tn5250_wts_flag3_0,
4407      &hf_tn5250_wts_flag3_1,
4408      &hf_tn5250_wts_flag3_2,
4409      &hf_tn5250_wts_flag3_3,
4410      &hf_tn5250_wts_flag3_4,
4411      &hf_tn5250_wts_flag3_5,
4412      &hf_tn5250_wts_flag3_6,
4413      &hf_tn5250_wts_flag3_7,
4414      NULL
4415   };
4416
4417   hf_items wts_fields[] = {
4418       { hf_tn5250_wts_partition, 0, 1, 0 },
4419       { hf_tn5250_wts_flag1, ett_tn5250_wts_mask, 1, wts_byte1 },
4420       { hf_tn5250_wts_flag2, ett_tn5250_wts_mask, 1, wts_byte2 },
4421       { hf_tn5250_wts_flag3, ett_tn5250_wts_mask, 1, wts_byte3 },
4422       { hf_tn5250_wts_home_position_row, 0, 2, 0 },
4423       { hf_tn5250_wts_home_position_col, 0, 2, 0 },
4424       { 0, 0, 0, 0 }
4425   };
4426
4427   static const int *wts_cld_byte1[] = {
4428      &hf_tn5250_wts_cld_flag1_0,
4429      &hf_tn5250_wts_cld_flag1_1,
4430      &hf_tn5250_wts_cld_flag1_2,
4431      &hf_tn5250_wts_cld_flag1_3,
4432      &hf_tn5250_wts_cld_flag1_4,
4433      &hf_tn5250_wts_cld_flag1_5,
4434      &hf_tn5250_wts_cld_flag1_6,
4435      &hf_tn5250_wts_cld_flag1_7,
4436      NULL
4437   };
4438
4439   static const int *wts_cld_byte2[] = {
4440      &hf_tn5250_wts_cld_flag2_0,
4441      &hf_tn5250_wts_cld_flag2_1,
4442      &hf_tn5250_wts_cld_flag2_2,
4443      &hf_tn5250_wts_cld_flag2_3,
4444      &hf_tn5250_wts_cld_flag2_4,
4445      &hf_tn5250_wts_cld_flag2_line_spacing,
4446      NULL
4447   };
4448
4449   static const int *wts_cld_byte3[] = {
4450      &hf_tn5250_wts_cld_flag3_0,
4451      &hf_tn5250_wts_cld_flag3_1,
4452      &hf_tn5250_wts_cld_flag3_2,
4453      &hf_tn5250_wts_cld_flag3_3,
4454      &hf_tn5250_wts_cld_flag3_4,
4455      &hf_tn5250_wts_cld_flag3_5,
4456      &hf_tn5250_wts_cld_flag3_6,
4457      &hf_tn5250_wts_cld_flag3_7,
4458      NULL
4459   };
4460
4461   hf_items wts_line_data_fields[] = {
4462       { hf_tn5250_length, 0, 1, 0 }, /*FIXME: Could be one or two bytes! */
4463       { hf_tn5250_wts_cld_flag1, ett_tn5250_wts_mask, 1, wts_cld_byte1 },
4464       { hf_tn5250_wts_cld_flag2, ett_tn5250_wts_mask, 1, wts_cld_byte2 },
4465       { hf_tn5250_wts_cld_row, 0, 2, 0 },
4466       { hf_tn5250_wts_cld_flag3, ett_tn5250_wts_mask, 1, wts_cld_byte3 },
4467       { hf_tn5250_wts_cld_page_num, 0, 2, 0 },
4468       { hf_tn5250_wts_cld_lmo, 0, 1, 0 },
4469       { hf_tn5250_wts_cld_io, 0, 1, 0 },
4470       { hf_tn5250_wts_cld_sli, 0, 1, 0 },
4471       { 0, 0, 0, 0 }
4472   };
4473
4474
4475   hf_items dsc_fields[] = {
4476       { hf_tn5250_dsc_partition, 0, 1, 0 },
4477       { hf_tn5250_reserved, 0, 1, 0 },
4478       { hf_tn5250_reserved, 0, 1, 0 },
4479       { hf_tn5250_dsc_sk, 0, 1, 0 },
4480       { hf_tn5250_dsc_ev, 0, 1, 0 },
4481       { 0, 0, 0, 0 }
4482   };
4483
4484   hf_items dorm_fields[] = {
4485       { hf_tn5250_dorm_length, 0, 1, 0 },
4486       { hf_tn5250_dorm_ec, 0, 2, 0 },
4487       { 0, 0, 0, 0 }
4488   };
4489
4490
4491   static const int *dfdpck_coreflag[] = {
4492      &hf_tn5250_dfdpck_coreflag_0,
4493      &hf_tn5250_dfdpck_coreflag_1,
4494      &hf_tn5250_dfdpck_coreflag_2,
4495      &hf_tn5250_dfdpck_coreflag_3,
4496      &hf_tn5250_dfdpck_coreflag_4,
4497      &hf_tn5250_dfdpck_coreflag_5,
4498      &hf_tn5250_dfdpck_coreflag_6,
4499      &hf_tn5250_dfdpck_coreflag_7,
4500      NULL
4501   };
4502
4503   static const int *dfdpck_toprowflag1[] = {
4504      &hf_tn5250_dfdpck_toprowflag1_0,
4505      &hf_tn5250_dfdpck_toprowflag1_1,
4506      &hf_tn5250_dfdpck_toprowflag1_2,
4507      &hf_tn5250_dfdpck_toprowflag1_3,
4508      &hf_tn5250_dfdpck_toprowflag1_4,
4509      &hf_tn5250_dfdpck_toprowflag1_5,
4510      &hf_tn5250_dfdpck_toprowflag1_6,
4511      &hf_tn5250_dfdpck_toprowflag1_7,
4512      NULL
4513   };
4514
4515   static const int *dfdpck_toprowflag2[] = {
4516      &hf_tn5250_dfdpck_toprowflag2_0,
4517      &hf_tn5250_dfdpck_toprowflag2_1,
4518      &hf_tn5250_dfdpck_toprowflag2_2,
4519      &hf_tn5250_dfdpck_toprowflag2_3,
4520      &hf_tn5250_dfdpck_toprowflag2_4,
4521      &hf_tn5250_dfdpck_toprowflag2_5,
4522      &hf_tn5250_dfdpck_toprowflag2_6,
4523      &hf_tn5250_dfdpck_toprowflag2_7,
4524      NULL
4525   };
4526
4527   static const int *dfdpck_toprowflag3[] = {
4528      &hf_tn5250_dfdpck_toprowflag3_0,
4529      &hf_tn5250_dfdpck_toprowflag3_1,
4530      &hf_tn5250_dfdpck_toprowflag3_2,
4531      &hf_tn5250_dfdpck_toprowflag3_3,
4532      &hf_tn5250_dfdpck_toprowflag3_4,
4533      &hf_tn5250_dfdpck_toprowflag3_5,
4534      &hf_tn5250_dfdpck_toprowflag3_6,
4535      &hf_tn5250_dfdpck_toprowflag3_7,
4536      NULL
4537   };
4538
4539   hf_items dfdpck_fields[] = {
4540       { hf_tn5250_dfdpck_partition, 0, 1, 0 },
4541       { hf_tn5250_reserved, 0, 1, 0 },
4542       { hf_tn5250_reserved, 0, 1, 0 },
4543       { 0, 0, 0, 0 }
4544   };
4545
4546   hf_items dfdpck_core_area_fields[] = {
4547       { hf_tn5250_length, 0, 1, 0 },
4548       { hf_tn5250_dfdpck_data_field, 0, 1, 0 },
4549       { hf_tn5250_dfdpck_coreflag, ett_tn5250_dfdpck_mask, 1, dfdpck_coreflag },
4550       { hf_tn5250_reserved, 0, 1, 0 },
4551       { 0, 0, 0, 0 }
4552   };
4553
4554   hf_items dfdpck_top_row_fields[] = {
4555       { hf_tn5250_length, 0, 1, 0 },
4556       { hf_tn5250_dfdpck_data_field, 0, 1, 0 },
4557       { hf_tn5250_dfdpck_toprowflag1, ett_tn5250_dfdpck_mask, 1, dfdpck_toprowflag1 },
4558       { hf_tn5250_dfdpck_toprowflag2, ett_tn5250_dfdpck_mask, 1, dfdpck_toprowflag2 },
4559       { hf_tn5250_dfdpck_toprowflag3, ett_tn5250_dfdpck_mask, 1, dfdpck_toprowflag3 },
4560       { hf_tn5250_reserved, 0, 1, 0 },
4561       { 0, 0, 0, 0 }
4562   };
4563
4564   while (tvb_reported_length_remaining(tvb, offset) > 0 && !done) {
4565     sf_length = tvb_get_ntohs(tvb,offset);
4566     type = tvb_get_guint8(tvb, offset+3);
4567
4568     offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, standard_fields);
4569
4570     switch (type) {
4571       case PASS_THROUGH:
4572         proto_tree_add_item(tn5250_tree, hf_tn5250_field_data, tvb, offset,
4573                             (sf_length - (start + offset)), FALSE);
4574         offset += (guint32)(sf_length - (start + offset));
4575         break;
4576       case TN5250_QUERY:
4577         proto_tree_add_item(tn5250_tree, hf_tn5250_reserved, tvb, offset,
4578                             1, FALSE);
4579         offset ++;
4580         break;
4581       case TN5250_QUERY_STATION_STATE:
4582         offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, qss_fields);
4583         break;
4584       case DEFINE_AUDIT_WINDOW__TABLE:
4585         proto_tree_add_item(tn5250_tree, hf_tn5250_dawt_id, tvb, offset,
4586                             1, FALSE);
4587         while ((offset - start) < sf_length) {
4588           length = tvb_get_guint8(tvb,offset);
4589           offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, dawt_fields);
4590           proto_tree_add_item(tn5250_tree, hf_tn5250_dawt_message, tvb, offset,
4591                               (length - 2), FALSE);
4592           offset += length;
4593         }
4594         break;
4595       case DEFINE_COMMAND_KEY_FUNCTION:
4596         proto_tree_add_item(tn5250_tree, hf_tn5250_dckf_id, tvb, offset,
4597                             1, FALSE);
4598         while ((offset - start) < sf_length) {
4599           length = tvb_get_guint8(tvb,offset);
4600           offset += tn5250_add_hf_items(tn5250_tree, tvb, offset,
4601                                         dckf_fields);
4602           proto_tree_add_item(tn5250_tree, hf_tn5250_dckf_prompt_text, tvb,
4603                               offset, (length - 2), FALSE);
4604           offset += length;
4605         }
4606         break;
4607       case READ_TEXT_SCREEN:
4608         offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, rts_fields);
4609         break;
4610       case DEFINE_PENDING_OPERATIONS:
4611         offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, dpo_fields);
4612         break;
4613       case DEFINE_TEXT_SCREEN_FORMAT:
4614         offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, dtsf_fields);
4615         break;
4616       case DEFINE_SCALE_LINE:
4617         offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, dsl_fields);
4618         while ((offset - start) < sf_length) {
4619           /* XXX length unused */
4620           length = tvb_get_guint8(tvb,offset);
4621           offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, dsl_fields2);
4622         }
4623         break;
4624       case WRITE_TEXT_SCREEN:
4625         offset += tn5250_add_hf_items(tn5250_tree, tvb, offset,
4626                                       wts_fields);
4627         length = tvb_get_guint8(tvb,offset);
4628         used = tn5250_add_hf_items(tn5250_tree, tvb, offset,
4629                                    wts_line_data_fields);
4630         offset += used;
4631         proto_tree_add_item(tn5250_tree, hf_tn5250_wts_cld_li, tvb, offset,
4632                             (length - used), FALSE);
4633         break;
4634       case DEFINE_SPECIAL_CHARACTERS:
4635         offset += tn5250_add_hf_items(tn5250_tree, tvb, offset,
4636                                       dsc_fields);
4637         break;
4638       case DEFINE_OPERATOR_ERROR_MESSAGES:
4639         proto_tree_add_item(tn5250_tree, hf_tn5250_dorm_id, tvb, offset,
4640                             1, FALSE);
4641         while ((offset - start) < sf_length) {
4642           length = tvb_get_guint8(tvb,offset);
4643           offset += tn5250_add_hf_items(tn5250_tree, tvb, offset,
4644                                         dorm_fields);
4645           proto_tree_add_item(tn5250_tree, hf_tn5250_dorm_mt, tvb, offset,
4646                               (length - 2), FALSE);
4647           offset += length;
4648         }
4649         break;
4650       case DEFINE_PITCH_TABLE:
4651         proto_tree_add_item(tn5250_tree, hf_tn5250_dpt_id, tvb, offset,
4652                             1, FALSE);
4653         while ((offset - start) < sf_length) {
4654           length = tvb_get_guint8(tvb,offset);
4655           proto_tree_add_item(tn5250_tree, hf_tn5250_length, tvb, offset,
4656                               1, FALSE);
4657           proto_tree_add_item(tn5250_tree, hf_tn5250_dpt_ec, tvb, offset,
4658                               length, FALSE);
4659           offset += length;
4660         }
4661         break;
4662       case DEFINE_FAKE_DP_COMMAND_KEY_FUNCTION:
4663         offset += tn5250_add_hf_items(tn5250_tree, tvb, offset,
4664                                       dfdpck_fields);
4665         while ((offset - start) < sf_length) {
4666           length = tvb_get_guint8(tvb,offset);
4667           type = tvb_get_guint8(tvb,offset+1);
4668           if (type == CORE_AREA_COMMAND_KEYS) {
4669             offset += tn5250_add_hf_items(tn5250_tree, tvb, offset,
4670                                           dfdpck_core_area_fields);
4671           } else if (type == TOP_ROW_COMMAND_KEYS) {
4672             offset += tn5250_add_hf_items(tn5250_tree, tvb, offset,
4673                                           dfdpck_top_row_fields);
4674           } else {
4675             offset += dissect_unknown_data(tn5250_tree, tvb, offset, start, length);
4676           }
4677         }
4678         break;
4679       default:
4680         done = 1;
4681         break;
4682     }
4683   }
4684
4685   offset += dissect_unknown_data(tn5250_tree, tvb, offset, start, sf_length);
4686
4687   return (offset - start);
4688 }
4689
4690 /* 15.27.2 5250 Query Command - Response */
4691 /*TN5250 - RFC1205 - Query Reply Fields */
4692 static guint32
4693 dissect_query_reply(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset)
4694 {
4695   int start = offset;
4696
4697   static const int *byte[] = {
4698     &hf_tn5250_qr_flag_0,
4699     &hf_tn5250_qr_flag_reserved,
4700     NULL
4701   };
4702
4703   static const int *byte1[] = {
4704     &hf_tn5250_qr_flag1_0,
4705     &hf_tn5250_qr_flag1_1,
4706     &hf_tn5250_qr_flag1_2,
4707     &hf_tn5250_qr_flag1_3,
4708     &hf_tn5250_qr_flag1_4,
4709     &hf_tn5250_qr_flag1_5,
4710     &hf_tn5250_qr_flag1_6,
4711     &hf_tn5250_qr_flag1_7,
4712     NULL
4713   };
4714
4715   static const int *byte2[] = {
4716     &hf_tn5250_qr_flag2_0to3,
4717     &hf_tn5250_qr_flag2_4,
4718     &hf_tn5250_qr_flag2_5,
4719     &hf_tn5250_qr_flag2_6to7,
4720     NULL
4721   };
4722
4723   hf_items qr_fields[] = {
4724       { hf_tn5250_sf_length, 0, 2, 0 },
4725       { hf_tn5250_sf_class, 0, 1, 0 },
4726       { hf_tn5250_sf_type, 0, 1, 0 },
4727       { hf_tn5250_qr_flag, ett_tn5250_qr_mask, 1, byte },
4728       { hf_tn5250_qr_chc, 0, 2, 0 },
4729       { hf_tn5250_qr_ccl, 0, 3, 0 },
4730       { hf_tn5250_reserved, 0, 1, 0 },
4731       { hf_tn5250_reserved, 0, 1, 0 },
4732       { hf_tn5250_reserved, 0, 1, 0 },
4733       { hf_tn5250_reserved, 0, 1, 0 },
4734       { hf_tn5250_reserved, 0, 1, 0 },
4735       { hf_tn5250_reserved, 0, 1, 0 },
4736       { hf_tn5250_reserved, 0, 1, 0 },
4737       { hf_tn5250_reserved, 0, 1, 0 },
4738       { hf_tn5250_reserved, 0, 1, 0 },
4739       { hf_tn5250_reserved, 0, 1, 0 },
4740       { hf_tn5250_reserved, 0, 1, 0 },
4741       { hf_tn5250_reserved, 0, 1, 0 },
4742       { hf_tn5250_reserved, 0, 1, 0 },
4743       { hf_tn5250_reserved, 0, 1, 0 },
4744       { hf_tn5250_reserved, 0, 1, 0 },
4745       { hf_tn5250_reserved, 0, 1, 0 },
4746       { hf_tn5250_qr_dt, 0, 1, 0 },
4747       { hf_tn5250_qr_dtc, 0, 4, 0 },
4748       { hf_tn5250_qr_dm, 0, 3, 0 },
4749       { hf_tn5250_qr_ki, 0, 1, 0 },
4750       { hf_tn5250_qr_eki, 0, 1, 0 },
4751       { hf_tn5250_reserved, 0, 1, 0 },
4752       { hf_tn5250_qr_dsn, 0, 4, 0 },
4753       { hf_tn5250_qr_mni, 0, 2, 0 },
4754       { hf_tn5250_reserved, 0, 1, 0 },
4755       { hf_tn5250_reserved, 0, 1, 0 },
4756       { hf_tn5250_reserved, 0, 1, 0 },
4757       { hf_tn5250_qr_flag1, ett_tn5250_qr_mask, 1, byte1 },
4758       { hf_tn5250_qr_flag2, ett_tn5250_qr_mask, 1, byte2 },
4759       { hf_tn5250_qr_flag3, 0, 1, 0 },
4760       { hf_tn5250_qr_flag4, 0, 1, 0 },
4761       { hf_tn5250_reserved, 0, 1, 0 },
4762       { hf_tn5250_reserved, 0, 1, 0 },
4763       { hf_tn5250_reserved, 0, 1, 0 },
4764       { hf_tn5250_reserved, 0, 1, 0 },
4765       { hf_tn5250_reserved, 0, 1, 0 },
4766       { hf_tn5250_reserved, 0, 1, 0 },
4767       { hf_tn5250_reserved, 0, 1, 0 },
4768       { hf_tn5250_reserved, 0, 1, 0 },
4769       { 0, 0, 0, 0 }
4770   };
4771
4772
4773   offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, qr_fields);
4774
4775   return (offset - start);
4776 }
4777
4778 /* End: Handle WCC, Orders and Data */
4779
4780
4781 static guint32
4782 dissect_tn5250_header(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset)
4783 {
4784
4785   int start=offset;
4786   int error_flag;
4787
4788   static const int *byte[] = {
4789     &hf_tn5250_ds_output_error,
4790     &hf_tn5250_attn_key,
4791     &hf_tn5250_sys_request_key,
4792     &hf_tn5250_test_request_key,
4793     &hf_tn5250_error_state,
4794     NULL
4795     };
4796
4797   hf_items fields[] = {
4798       { hf_tn5250_logical_record_length, 0, 2, 0 },
4799       { hf_tn5250_sna_record_type, 0, 2, 0 },
4800       { hf_tn5250_reserved, 0, 2, 0 },
4801       { hf_tn5250_variable_record_length, 0, 1, 0 },
4802       { hf_tn5250_header_flags, ett_tn5250_header_flags, 1, byte },
4803       { hf_tn5250_reserved, 0, 1, 0 },
4804       { hf_tn5250_operation_code, 0, 1, 0 },
4805       { 0, 0, 0, 0 }
4806   };
4807
4808   error_flag = tvb_get_guint8(tvb, offset+8);
4809
4810   offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, fields);
4811
4812   if (error_flag & 0x02) { /*HLP*/
4813       proto_tree_add_item(tn5250_tree, hf_tn5250_error_code, tvb, offset, 2, FALSE);
4814   }
4815
4816   return (offset - start);
4817 }
4818
4819 #if 0
4820 /* XXX - unused */
4821 /* Detect and Handle Direction of Stream */
4822 static gint
4823 dissect_tn5250_data_until_next_command(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset)
4824 {
4825   gint order_code, done = 0;
4826   gint start = offset;
4827
4828   while (tvb_reported_length_remaining(tvb, offset) > 0 && !done) {
4829     order_code = tvb_get_guint8(tvb, offset);
4830     switch (order_code) {
4831           case CLEAR_UNIT:
4832           case CLEAR_FORMAT_TABLE:
4833           case CLEAR_UNIT_ALTERNATE:
4834           case WRITE_TO_DISPLAY:
4835           case WRITE_ERROR_CODE:
4836           case RESTORE_SCREEN:
4837           case WRITE_ERROR_CODE_TO_WINDOW:
4838           case READ_INPUT_FIELDS:
4839           case READ_MDT_FIELDS:
4840           case READ_MDT_ALTERNATE:
4841           case READ_SCREEN:
4842           case READ_SCREEN_WITH_EXTENDED_ATTRIBUTES:
4843           case READ_SCREEN_TO_PRINT:
4844           case READ_SCREEN_TO_PRINT_WITH_EXTENDED_ATTRIBUTES:
4845           case READ_SCREEN_TO_PRINT_WITH_GRIDLINES:
4846           case READ_SCREEN_TO_PRINT_WITH_EXTENDED_ATTRIBUTES_AND_GRIDLINES:
4847           case READ_IMMEDIATE:
4848           case READ_MODIFIED_IMMEDIATE_ALTERNATE:
4849           case SAVE_SCREEN:
4850           case SAVE_PARTIAL_SCREEN:
4851           case RESTORE_PARTIAL_SCREEN:
4852           case ROLL:
4853           case WRITE_SINGLE_STRUCTURED_FIELD:
4854           case WRITE_STRUCTURED_FIELD:
4855           case COPY_TO_PRINTER:
4856             done = 1;
4857             break;
4858           default:
4859             offset++;
4860             break;
4861     }
4862   }
4863
4864   if (offset > start) {
4865     proto_tree_add_item(tn5250_tree, hf_tn5250_field_data,
4866                         tvb, start, (offset - start), FALSE);
4867   }
4868
4869   return (offset - start);
4870 }
4871 #endif
4872
4873 static guint32
4874 dissect_outbound_stream(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset)
4875 {
4876   gint command_code;
4877   gint start = offset, length = 0;
4878   proto_tree   *cc_tree;
4879   proto_item   *ti;
4880
4881   /*Escape*/
4882   ti = proto_tree_add_item(tn5250_tree, hf_tn5250_escape_code, tvb, offset, 1,
4883                            FALSE);
4884   offset++;
4885   cc_tree = proto_item_add_subtree(ti, ett_cc);
4886
4887   /* Command Code*/
4888   command_code = tvb_get_guint8(tvb, offset);
4889   switch (command_code) {
4890     case CLEAR_UNIT:
4891     case CLEAR_FORMAT_TABLE:
4892       proto_tree_add_item(cc_tree, hf_tn5250_command_code, tvb, offset, 1,
4893                           FALSE);
4894       offset++;
4895       break;
4896     case CLEAR_UNIT_ALTERNATE:
4897       proto_tree_add_item(cc_tree, hf_tn5250_command_code, tvb, offset, 1,
4898                           FALSE);
4899       offset++;
4900       proto_tree_add_item(cc_tree, hf_tn5250_cua_parm, tvb, offset, 1, FALSE);
4901       offset++;
4902       break;
4903     case WRITE_TO_DISPLAY:
4904       proto_tree_add_item(cc_tree, hf_tn5250_command_code, tvb, offset, 1,
4905                           FALSE);
4906       offset++;
4907       /* WCC */
4908       offset += dissect_wcc(cc_tree, tvb, offset);
4909       offset += dissect_tn5250_orders_and_data(cc_tree, tvb, offset);
4910       break;
4911     case WRITE_ERROR_CODE:
4912       proto_tree_add_item(cc_tree, hf_tn5250_command_code,
4913                           tvb, offset, 1, FALSE);
4914       offset++;
4915       /* Check for the optional TN5250_IC */
4916       offset += dissect_tn5250_orders_and_data(cc_tree, tvb, offset);
4917       /* Add Field Data */
4918       proto_tree_add_item(cc_tree, hf_tn5250_fa, tvb, offset, 1, FALSE);
4919       offset++;
4920       proto_tree_add_item(cc_tree, hf_tn5250_field_data, tvb, offset,
4921                           tvb_reported_length_remaining(tvb, offset) - 1,
4922                           FALSE);
4923       offset += (guint32)(tvb_reported_length_remaining(tvb, offset) - 1);
4924       proto_tree_add_item(cc_tree, hf_tn5250_fa, tvb, offset, 1, FALSE);
4925       offset++;
4926       break;
4927     case RESTORE_SCREEN:
4928       proto_tree_add_item(cc_tree, hf_tn5250_command_code, tvb, offset, 1,
4929                           FALSE);
4930       offset++;
4931       while (tvb_reported_length_remaining(tvb, offset) > 0) {
4932         offset += dissect_outbound_stream(cc_tree, tvb, offset);
4933       }
4934       break;
4935     case WRITE_ERROR_CODE_TO_WINDOW:
4936       proto_tree_add_item(cc_tree, hf_tn5250_command_code, tvb, offset, 1,
4937                           FALSE);
4938       offset++;
4939       proto_tree_add_item(cc_tree, hf_tn5250_wectw_start_column, tvb, offset,
4940                           1, FALSE);
4941       offset++;
4942       proto_tree_add_item(cc_tree, hf_tn5250_wectw_end_column, tvb, offset, 1,
4943                           FALSE);
4944       offset++;
4945       break;
4946     case READ_INPUT_FIELDS:
4947     case READ_MDT_FIELDS:
4948     case READ_MDT_ALTERNATE:
4949       proto_tree_add_item(cc_tree, hf_tn5250_command_code, tvb, offset, 1,
4950                           FALSE);
4951       offset++;
4952       offset += dissect_wcc(cc_tree, tvb, offset);
4953       break;
4954     case READ_SCREEN:
4955     case READ_SCREEN_WITH_EXTENDED_ATTRIBUTES:
4956     case READ_SCREEN_TO_PRINT:
4957     case READ_SCREEN_TO_PRINT_WITH_EXTENDED_ATTRIBUTES:
4958     case READ_SCREEN_TO_PRINT_WITH_GRIDLINES:
4959     case READ_SCREEN_TO_PRINT_WITH_EXTENDED_ATTRIBUTES_AND_GRIDLINES:
4960     case READ_IMMEDIATE:
4961     case READ_MODIFIED_IMMEDIATE_ALTERNATE:
4962     case SAVE_SCREEN:
4963       proto_tree_add_item(cc_tree, hf_tn5250_command_code, tvb, offset, 1,
4964                           FALSE);
4965       offset++;
4966       break;
4967     case SAVE_PARTIAL_SCREEN:
4968       proto_tree_add_item(cc_tree, hf_tn5250_command_code, tvb, offset, 1,
4969                           FALSE);
4970       offset++;
4971       offset += dissect_save_partial_screen(cc_tree, tvb, offset);
4972       break;
4973     case RESTORE_PARTIAL_SCREEN:
4974       proto_tree_add_item(cc_tree, hf_tn5250_command_code, tvb, offset, 1,
4975                           FALSE);
4976       offset++;
4977       length = tvb_get_ntohs(tvb, offset);
4978       proto_tree_add_item(cc_tree, hf_tn5250_length_twobyte, tvb, offset, 2,
4979                           FALSE);
4980       offset++;
4981       offset += dissect_tn5250_orders_and_data(cc_tree, tvb, offset);
4982       proto_tree_add_item(cc_tree, hf_tn5250_field_data, tvb, offset,
4983                           (length - 2), FALSE);
4984       offset++;
4985       break;
4986     case ROLL:
4987       proto_tree_add_item(cc_tree, hf_tn5250_command_code, tvb, offset, 1,
4988                           FALSE);
4989       offset++;
4990       offset += dissect_roll(cc_tree, tvb, offset);
4991       break;
4992     case WRITE_SINGLE_STRUCTURED_FIELD:
4993       proto_tree_add_item(cc_tree, hf_tn5250_command_code, tvb, offset, 1,
4994                           FALSE);
4995       offset++;
4996       offset += dissect_write_single_structured_field(cc_tree, tvb, offset);
4997       break;
4998     case WRITE_STRUCTURED_FIELD:
4999       proto_tree_add_item(cc_tree, hf_tn5250_command_code, tvb, offset, 1,
5000                           FALSE);
5001       offset++;
5002       offset += dissect_write_structured_field(cc_tree, tvb, offset);
5003       break;
5004     case COPY_TO_PRINTER:
5005       proto_tree_add_item(cc_tree, hf_tn5250_command_code, tvb, offset, 1,
5006                           FALSE);
5007       offset++;
5008       proto_tree_add_item(cc_tree, hf_tn5250_ctp_lsid, tvb, offset, 1, FALSE);
5009       offset++;
5010       proto_tree_add_item(cc_tree, hf_tn5250_ctp_mlpp, tvb, offset, 1, FALSE);
5011       offset++;
5012       break;
5013     default:
5014       proto_tree_add_text(cc_tree, tvb, offset, 1, "Bogus value: %u", command_code);
5015       offset ++;
5016       break;
5017   }
5018
5019   return (offset - start);
5020 }
5021
5022 static guint32
5023 dissect_inbound_stream(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset, gint sna_flag)
5024 {
5025   gint start = offset, aid;
5026   guint32 commands;
5027
5028
5029   if (sna_flag & 0x01) { /* Stream contains error code */
5030       proto_tree_add_item(tn5250_tree, hf_tn5250_error_code, tvb, offset, 2,
5031                           FALSE);
5032       offset+=2;
5033       return (offset - start);
5034   } else if (sna_flag & 0x80) { /* Stream contains negative response */
5035       proto_tree_add_item(tn5250_tree, hf_tn5250_negative_response,
5036                           tvb, offset, 4, FALSE);
5037       offset+=4;
5038       return (offset - start);
5039   }
5040
5041   aid = tvb_get_guint8(tvb,offset+2);
5042   if (tn5250_is_valid_aid(aid)) {
5043     switch(aid) {
5044       case AID_IMAGE_FAX_REQUEST:
5045       case AID_UNKNOWN_IMAGE_FAX_FORMAT:
5046       case AID_IMAGE_FAX_ERROR:
5047         proto_tree_add_item(tn5250_tree, hf_tn5250_image_fax_error, tvb, offset,
5048                             2, FALSE);
5049         offset+=2;
5050         break;
5051       default:
5052         /*Response must be a normal row/col, aid, field data response */
5053         offset += dissect_row_column(tn5250_tree, tvb, offset);
5054         break;
5055     }
5056
5057     proto_tree_add_item(tn5250_tree, hf_tn5250_aid, tvb, offset, 1, FALSE);
5058     offset++;
5059
5060     if (aid == AID_INBOUND_WRITE_STRUCTURED_FIELD) {
5061       offset += dissect_query_reply(tn5250_tree, tvb, offset);
5062       return (offset - start);
5063     }
5064     /* Check for a response containing order codes */
5065     offset += dissect_tn5250_orders_and_data(tn5250_tree, tvb, offset);
5066   } else {
5067     /* FIXME: need to know when escape/commands are expected. */
5068     /* Check the response data for commands */
5069     if (tvb_get_guint8(tvb,offset) == TN5250_ESCAPE) {
5070       commands = dissect_outbound_stream(tn5250_tree, tvb, offset);
5071       /* It if contained commands then we're done. Anything else is unexpected data */
5072       if (commands) {
5073         offset += commands;
5074         if (tvb_reported_length_remaining(tvb, offset)) {
5075           proto_tree_add_item(tn5250_tree, hf_tn5250_unknown_data, tvb, offset,
5076                               tvb_reported_length_remaining(tvb, offset), FALSE);
5077           offset += tvb_reported_length_remaining(tvb, offset);
5078         }
5079         return (offset - start);
5080       }
5081     }
5082   }
5083
5084   /* Anything else is unformatted field data */
5085   if (tvb_reported_length_remaining(tvb, offset)) {
5086     proto_tree_add_item(tn5250_tree, hf_tn5250_field_data, tvb, offset,
5087                         tvb_reported_length_remaining(tvb, offset), FALSE);
5088     offset += tvb_reported_length_remaining(tvb, offset);
5089   }
5090
5091   return (offset - start);
5092 }
5093
5094 static void
5095 dissect_tn5250(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
5096 {
5097   proto_tree   *tn5250_tree;
5098   proto_item   *ti;
5099   gint         offset = 0;
5100   conversation_t *conversation;
5101   tn5250_conv_info_t *tn5250_info = NULL;
5102   int sna_flag;
5103
5104   pinfo->fd->flags.encoding = PACKET_CHAR_ENC_CHAR_EBCDIC;
5105
5106   /* Do we have a conversation for this connection? */
5107   conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst,
5108                                    pinfo->ptype, pinfo->srcport,
5109                                    pinfo->destport, 0);
5110   if (conversation != NULL) {
5111       /* Do we already have a type and mechanism? */
5112       tn5250_info = conversation_get_proto_data(conversation, proto_tn5250);
5113   }
5114
5115   if (!tn5250_info)
5116       return;
5117
5118   col_set_str(pinfo->cinfo, COL_PROTOCOL, "TN5250");
5119
5120   ti = proto_tree_add_item(tree, proto_tn5250, tvb, offset, -1, FALSE);
5121   tn5250_tree = proto_item_add_subtree(ti, ett_tn5250);
5122   col_clear(pinfo->cinfo, COL_INFO);
5123   if (pinfo->srcport == tn5250_info->outbound_port) {
5124     col_set_str(pinfo->cinfo, COL_INFO, "TN5250 Data from Mainframe");
5125   } else {
5126     col_set_str(pinfo->cinfo, COL_INFO, "TN5250 Data to Mainframe");
5127   }
5128
5129   if (tree) {
5130     sna_flag = tvb_get_ntohs(tvb, offset+6);
5131     offset += dissect_tn5250_header(tn5250_tree, tvb, offset);
5132
5133     while (tvb_reported_length_remaining(tvb, offset) > 0) {
5134       if (pinfo->srcport == tn5250_info->outbound_port) {
5135         offset += dissect_outbound_stream(tn5250_tree, tvb, offset);
5136       } else {
5137         offset += dissect_inbound_stream(tn5250_tree, tvb, offset, sna_flag);
5138       }
5139     }
5140   }
5141
5142 }
5143
5144 void
5145 add_tn5250_conversation(packet_info *pinfo, int tn5250e)
5146 {
5147     conversation_t *conversation;
5148     tn5250_conv_info_t *tn5250_info = NULL;
5149
5150     conversation = find_or_create_conversation(pinfo);
5151
5152     /*
5153     * Do we already have a type and mechanism?
5154     */
5155     tn5250_info = conversation_get_proto_data(conversation, proto_tn5250);
5156     if (tn5250_info == NULL) {
5157       /* No.  Attach that information to the conversation, and add
5158       * it to the list of information structures.
5159       */
5160       tn5250_info = se_alloc(sizeof(tn5250_conv_info_t));
5161       SE_COPY_ADDRESS(&(tn5250_info->outbound_addr),&(pinfo->dst));
5162       tn5250_info->outbound_port = pinfo->destport;
5163       SE_COPY_ADDRESS(&(tn5250_info->inbound_addr),&(pinfo->src));
5164       tn5250_info->inbound_port = pinfo->srcport;
5165       conversation_add_proto_data(conversation, proto_tn5250, tn5250_info);
5166       tn5250_info->next = tn5250_info_items;
5167       tn5250_info_items = tn5250_info;
5168     }
5169
5170     tn5250_info->extended = tn5250e;
5171
5172 }
5173
5174 int
5175 find_tn5250_conversation(packet_info *pinfo)
5176 {
5177   conversation_t *conversation = NULL;
5178   tn5250_conv_info_t *tn5250_info = NULL;
5179
5180   /*
5181   * Do we have a conversation for this connection?
5182   */
5183   conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst,
5184                                   pinfo->ptype, pinfo->srcport,
5185                                   pinfo->destport, 0);
5186
5187   if (conversation != NULL) {
5188       tn5250_info = conversation_get_proto_data(conversation, proto_tn5250);
5189
5190       if (tn5250_info != NULL) {
5191           /*
5192           * Do we already have a type and mechanism?
5193           */
5194           return 1;
5195       }
5196   }
5197   return 0;
5198 }
5199
5200 void
5201 proto_register_tn5250(void)
5202 {
5203   static hf_register_info hf[] = {
5204     { &hf_tn5250_escape_code,
5205       { "Escape Code",           "tn5250.escape_code",
5206       FT_UINT8, BASE_HEX, VALS(vals_tn5250_escape_codes), 0x0,
5207         NULL, HFILL }},
5208     { &hf_tn5250_command_code,
5209       { "Command Code",           "tn5250.command_code",
5210       FT_UINT8, BASE_HEX, VALS(vals_tn5250_command_codes), 0x0,
5211         NULL, HFILL }},
5212     { &hf_tn5250_sf_length,
5213         {  "Structured Field Length", "tn5250.sf_length",
5214             FT_UINT16, BASE_DEC, NULL, 0x0,
5215             NULL, HFILL }},
5216     { &hf_tn5250_sf_class,
5217       { "Structured Field Class", "tn5250.class",
5218       FT_UINT8, BASE_HEX, VALS(vals_tn5250_sf_class), 0,
5219         NULL, HFILL }},
5220     { &hf_tn5250_sf_type,
5221       { "Structured Field Type", "tn5250.type",
5222       FT_UINT8, BASE_HEX, VALS(vals_tn5250_sf_type), 0,
5223         NULL, HFILL }},
5224
5225     /* 15.4 - Clear Unit Alternate Command Code*/
5226     { &hf_tn5250_cua_parm,
5227       { "TN5250 CUA Parameter", "tn5250.cua_parm",
5228       FT_UINT16, BASE_HEX, VALS(vals_tn5250_cua_parms), 0x0,
5229         NULL, HFILL }},
5230
5231     /* 15.6 Write To Display Command Code */
5232     /* 15.6.1 WTD Control Code */
5233     { &hf_tn5250_wtd_ccc1,
5234       {"Write To Display Command Control Character Byte 1", "tn5250.wtd_ccc1",
5235       FT_UINT8, BASE_HEX,
5236         VALS (vals_tn5250_wtd_cc_byteone), CCBITS, NULL, HFILL}},
5237     { &hf_tn5250_wtd_ccc2,
5238       { "Write To Display Command Control Character Byte 2", "tn5250.wtd_ccc2",
5239       FT_UINT8, BASE_HEX, NULL, 0,
5240         NULL, HFILL }},
5241     { &hf_tn5250_wtd_ccc2_res,
5242         { "Reserved",
5243             "tn5250.wtd_ccc_reserved", FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL }},
5244     { &hf_tn5250_wtd_ccc2_cursor,
5245         { "Cursor does not move when keyboard unlocks",
5246             "tn5250.wtd_ccc_cursor", FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL }},
5247     { &hf_tn5250_wtd_ccc2_reset,
5248         { "Reset blinking cursor",
5249             "tn5250.wtd_ccc_reset", FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL }},
5250     { &hf_tn5250_wtd_ccc2_set,
5251         { "Set blinking cursor",
5252             "tn5250.wtd_ccc_set", FT_BOOLEAN, 8, NULL, 0x10, NULL, HFILL }},
5253     { &hf_tn5250_wtd_ccc2_unlock,
5254         { "Unlock the keyboard and reset any pending AID bytes",
5255             "tn5250.wtd_ccc_unlock", FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL }},
5256     { &hf_tn5250_wtd_ccc2_alarm,
5257         { "Sound Alarm",
5258             "tn5250.wtd_ccc_alarm", FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }},
5259     { &hf_tn5250_wtd_ccc2_off,
5260         { "Set Message Waiting indicator off",
5261             "tn5250.wtd_ccc_off", FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL }},
5262     { &hf_tn5250_wtd_ccc2_on,
5263         { "Set Message Waiting indicator on",
5264             "tn5250.wtd_ccc_on", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
5265
5266
5267     /* 15.6.7 Repeat to Address Order */
5268     { &hf_tn5250_repeated_character,
5269       { "Repeated Character", "tn5250.repeated_character",
5270       FT_EBCDIC, BASE_NONE, NULL, 0x0,
5271         NULL, HFILL }},
5272
5273     /* 15.6.9 Start of Header Order */
5274     { &hf_tn5250_soh_length,
5275       { "Length", "tn5250.soh_length",
5276       FT_UINT8, BASE_DEC, NULL, 0,
5277         NULL, HFILL }},
5278     { &hf_tn5250_soh_flags,
5279       { "Start of Header Flags", "tn5250.soh_flags",
5280       FT_UINT8, BASE_HEX, NULL, 0,
5281         NULL, HFILL }},
5282     { &hf_tn5250_soh_cursor_direction,
5283         { "Right To Left Screen-Level Cursor Direction", "tn5250.soh_cursor_direction",
5284         FT_BOOLEAN, 8, NULL, 0x80,
5285           NULL, HFILL }},
5286     { &hf_tn5250_soh_screen_reverse,
5287         { "Automatic local screen reverse", "tn5250.soh_screen_reverse",
5288         FT_BOOLEAN, 8, NULL, 0x20,
5289           NULL, HFILL }},
5290     { &hf_tn5250_soh_input_capable_only,
5291         { "The cursor is allowed to move only to input-capable positions", "tn5250.soh_input_capable_only",
5292         FT_BOOLEAN, 8, NULL, 0x10,
5293           NULL, HFILL }},
5294
5295     { &hf_tn5250_soh_pf24to17, { "Command Key Switch 1", "tn5250.soh_pf24to17",
5296       FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL }},
5297     { &hf_tn5250_soh_pf24, { "PF24", "tn5250.soh_pf24",
5298         FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL }},
5299     { &hf_tn5250_soh_pf23, { "PF22", "tn5250.soh_pf23",
5300         FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL }},
5301     { &hf_tn5250_soh_pf22, { "PF22", "tn5250.soh_pf22",
5302         FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL }},
5303     { &hf_tn5250_soh_pf21, { "PF21", "tn5250.soh_pf21",
5304         FT_BOOLEAN, 8, NULL, 0x10, NULL, HFILL }},
5305     { &hf_tn5250_soh_pf20, { "PF20", "tn5250.soh_pf20",
5306         FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL }},
5307     { &hf_tn5250_soh_pf19, { "PF19", "tn5250.soh_pf19",
5308         FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }},
5309     { &hf_tn5250_soh_pf18, { "PF18", "tn5250.soh_pf18",
5310         FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL }},
5311     { &hf_tn5250_soh_pf17, { "PF17", "tn5250.soh_pf17",
5312         FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
5313
5314     { &hf_tn5250_soh_pf16to9, { "Command Key Switch 2", "tn5250.soh_pf16to9",
5315       FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL }},
5316     { &hf_tn5250_soh_pf16, { "PF16", "tn5250.soh_pf16",
5317         FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL }},
5318     { &hf_tn5250_soh_pf15, { "PF15", "tn5250.soh_pf15",
5319         FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL }},
5320     { &hf_tn5250_soh_pf14, { "PF14", "tn5250.soh_pf14",
5321         FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL }},
5322     { &hf_tn5250_soh_pf13, { "PF13", "tn5250.soh_pf13",
5323         FT_BOOLEAN, 8, NULL, 0x10, NULL, HFILL }},
5324     { &hf_tn5250_soh_pf12, { "PF12", "tn5250.soh_pf12",
5325         FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL }},
5326     { &hf_tn5250_soh_pf11, { "PF11", "tn5250.soh_pf11",
5327         FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }},
5328     { &hf_tn5250_soh_pf10, { "PF10", "tn5250.soh_pf10",
5329         FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL }},
5330     { &hf_tn5250_soh_pf9, { "PF9", "tn5250.soh_pf9",
5331         FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
5332
5333     { &hf_tn5250_soh_pf8to1, { "Command Key Switch 3", "tn5250.soh_pf8to1",
5334       FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL }},
5335     { &hf_tn5250_soh_pf8, { "PF8", "tn5250.soh_pf8",
5336         FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL }},
5337     { &hf_tn5250_soh_pf7, { "PF7", "tn5250.soh_pf7",
5338         FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL }},
5339     { &hf_tn5250_soh_pf6, { "PF6", "tn5250.soh_pf6",
5340         FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL }},
5341     { &hf_tn5250_soh_pf5, { "PF5", "tn5250.soh_pf5",
5342         FT_BOOLEAN, 8, NULL, 0x10, NULL, HFILL }},
5343     { &hf_tn5250_soh_pf4, { "PF4", "tn5250.soh_pf4",
5344         FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL }},
5345     { &hf_tn5250_soh_pf3, { "PF3", "tn5250.soh_pf3",
5346         FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }},
5347     { &hf_tn5250_soh_pf2, { "PF2", "tn5250.soh_pf2",
5348         FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL }},
5349     { &hf_tn5250_soh_pf1, { "PF1", "tn5250.soh_pf1",
5350         FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
5351
5352     { &hf_tn5250_soh_resq, { "Resequence to Field", "tn5250.soh_resq",
5353       FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
5354     { &hf_tn5250_soh_err, { "Error Row", "tn5250.soh_err",
5355       FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
5356
5357
5358     /* 15.6.11.1 Write Extended Attribute Order - Extended Primary Attribute*/
5359     /* 15.6.12.3 Start of Field Order - Field Attribute*/
5360     { &hf_tn5250_wea_prim_attr,
5361       { "Extended Primary Attributes", "tn5250.wea_prim_attr",
5362       FT_UINT8, BASE_HEX, NULL, 0,
5363         NULL, HFILL }},
5364     { &hf_tn5250_wea_prim_attr_flag,
5365         { "Attribute Change",
5366             "tn5250.wea_prim_attr_flag", FT_BOOLEAN, 8, NULL,
5367             0x80, NULL, HFILL }},
5368     { &hf_tn5250_wea_prim_attr_col,
5369         { "Column Separator",
5370             "tn5250.wea_prim_attr_col", FT_BOOLEAN, 8,
5371             TFS(&tn5250_field_attr_col), 0x10, NULL, HFILL }},
5372     { &hf_tn5250_wea_prim_attr_blink,
5373         { "Blink",
5374             "tn5250.wea_prim_attr_blink", FT_BOOLEAN, 8,
5375             TFS(&tn5250_field_attr_blink), 0x08, NULL, HFILL }},
5376     { &hf_tn5250_wea_prim_attr_und,
5377         { "Underscore",
5378             "tn5250.wea_prim_attr_und", FT_BOOLEAN, 8,
5379             TFS(&tn5250_field_attr_und), 0x04, NULL, HFILL }},
5380     { &hf_tn5250_wea_prim_attr_int,
5381         { "Intensity",
5382             "tn5250.wea_prim_attr_int", FT_BOOLEAN, 8,
5383             TFS(&tn5250_field_attr_int), 0x02, NULL, HFILL }},
5384     { &hf_tn5250_wea_prim_attr_rev,
5385         { "Reverse Image",
5386             "tn5250.wea_prim_attr_rev", FT_BOOLEAN, 8,
5387             TFS(&tn5250_field_attr_rev), 0x01, NULL, HFILL }},
5388
5389     /* 15.6.11.2 Write Extended Attribute Order - Foreground Color Attribute*/
5390     { &hf_tn5250_foreground_color_attr,
5391       { "Foreground Color Attribute",           "tn5250.foreground_color_attr",
5392       FT_UINT8, BASE_HEX, VALS(vals_tn5250_foreground_color_attributes), 0x0,
5393         NULL, HFILL }},
5394     /* 15.6.11.3 Write Extended Attribute Order - Ideographic Attribute*/
5395     { &hf_tn5250_ideographic_attr,
5396       { "Ideographic Attribute",           "tn5250.ideographic_attr",
5397       FT_UINT8, BASE_HEX, VALS(vals_tn5250_ideographic_attributes), 0x0,
5398         NULL, HFILL }},
5399
5400     /* 15.6.12 Start of Field Order - Field Format Word */
5401     { &hf_tn5250_ffw,
5402       { "Field Format Word", "tn5250.ffw",
5403       FT_UINT8, BASE_HEX, NULL, 0,
5404         NULL, HFILL }},
5405     { &hf_tn5250_ffw_id,
5406         { "Field Format Word ID", "tn5250.ffw_id", FT_UINT8, BASE_HEX,
5407           VALS(vals_tn5250_ffw_id), FFW_ID_BITS, NULL, HFILL }},
5408     { &hf_tn5250_ffw_bypass,
5409       { "Bypass", "tn5250.ffw_bypass",
5410         FT_BOOLEAN, 8, TFS(&tn5250_field_ffw_bypass),
5411         0x20, NULL, HFILL }},
5412     { &hf_tn5250_ffw_dup,
5413       { "Dupe or Field Mark Enable", "tn5250.ffw_dup",
5414         FT_BOOLEAN, 8, TFS(&tn5250_field_ffw_dup),
5415         0x10, NULL, HFILL }},
5416     { &hf_tn5250_ffw_mdt,
5417       { "Modified Data Tag", "tn5250.ffw_mdt",
5418         FT_BOOLEAN, 8, TFS(&tn5250_field_ffw_mdt),
5419         0x08, NULL, HFILL }},
5420     { &hf_tn5250_ffw_shift,
5421         { "Field Shift/Edit Specification", "tn5250.ffw_shift", FT_UINT8, BASE_HEX,
5422           VALS(vals_tn5250_ffw_shift), FFW_SHIFT_BITS, NULL, HFILL }},
5423     { &hf_tn5250_ffw_auto,
5424       { "Auto Enter", "tn5250.ffw_auto",
5425         FT_BOOLEAN, 8, TFS(&tn5250_field_ffw_auto),
5426         0x80, NULL, HFILL }},
5427     { &hf_tn5250_ffw_fer,
5428       { "Field Exit Required", "tn5250.ffw_fer",
5429         FT_BOOLEAN, 8, TFS(&tn5250_field_ffw_fer),
5430         0x40, NULL, HFILL }},
5431     { &hf_tn5250_ffw_monocase,
5432       { "Monocase", "tn5250.ffw_monocase",
5433         FT_BOOLEAN, 8, TFS(&tn5250_field_ffw_monocase),
5434         0x20, NULL, HFILL }},
5435     { &hf_tn5250_ffw_res,
5436       { "Reserved", "tn5250.ffw_res",
5437         FT_BOOLEAN, 8, NULL,
5438         0x10, NULL, HFILL }},
5439     { &hf_tn5250_ffw_me,
5440       { "Mandatory Enter", "tn5250.ffw_me",
5441         FT_BOOLEAN, 8, TFS(&tn5250_field_ffw_me),
5442         0x08, NULL, HFILL }},
5443     { &hf_tn5250_ffw_adjust,
5444         { "Right Adjust/Mandatory Fill", "tn5250.ffw_adjust", FT_UINT8, BASE_HEX,
5445           VALS(vals_tn5250_ffw_adjust), FFW_ADJUST_BITS, NULL, HFILL }},
5446
5447     { &hf_tn5250_fcw,
5448       { "Field Control Word", "tn5250.fcw",
5449       FT_UINT16, BASE_HEX|BASE_RANGE_STRING, RVALS(vals_tn5250_fcw), 0,
5450         NULL, HFILL }},
5451
5452     { &hf_tn5250_fa_color,
5453       { "Field Attribute (Color)", "tn5250.fa_color",
5454       FT_UINT8, BASE_HEX, VALS(vals_tn5250_fa_color), 0,
5455         NULL, HFILL }},
5456     { &hf_tn5250_fa,
5457       { "Field Attributes", "tn5250.sf_fa",
5458       FT_UINT8, BASE_HEX, NULL, 0,
5459         NULL, HFILL }},
5460     { &hf_tn5250_sf_attr_flag,
5461         { "Attribute ID",
5462             "tn5250.sf_attr_flag", FT_UINT8, BASE_HEX, VALS(vals_tn5250_fa_id), FA_ID_BITS, NULL, HFILL }},
5463     /* Use Attribute Field fields from 14.6.11.1 for rest of attribute fields */
5464
5465     /* 15.6.13  Write to Display Structured Field Order */
5466
5467     /* 15.6.13.1  Write to Display Structured Field Order - Create Window */
5468     { &hf_tn5250_wdsf_cw_flag1,
5469       { "Flags", "tn5250.wdsf_cw_flag1",
5470       FT_UINT8, BASE_HEX, NULL, 0,
5471         NULL, HFILL }},
5472     { &hf_tn5250_wdsf_cw_flag1_1,
5473       { "Flag 1", "tn5250.wdsf_cw_flag1_1",
5474         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_cw_flag1_1),
5475         0x80, NULL, HFILL }},
5476     { &hf_tn5250_wdsf_cw_flag1_2,
5477       { "Flag 2", "tn5250.wdsf_cw_flag1_2",
5478         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_cw_flag1_2),
5479         0x40, NULL, HFILL }},
5480     { &hf_tn5250_wdsf_cw_flag1_reserved,
5481         { "Reserved", "tn5250.wdsf_cw_flag1_reserved", FT_UINT8, BASE_HEX,
5482           NULL, 0x3F, NULL, HFILL }},
5483     { &hf_tn5250_wdsf_cw_wd,
5484       { "Window Depth", "tn5250.wdsf_cw_wd",
5485       FT_UINT8, BASE_DEC, NULL, 0,
5486         NULL, HFILL }},
5487     { &hf_tn5250_wdsf_cw_ww,
5488       { "Window Width", "tn5250.wdsf_cw_ww",
5489       FT_UINT8, BASE_DEC, NULL, 0,
5490         NULL, HFILL }},
5491
5492     { &hf_tn5250_wdsf_cw_minor_type,
5493       { "Minor Structured Field Type", "tn5250.wdsf_cw_minor_type",
5494       FT_UINT8, BASE_HEX, VALS(vals_tn5250_wdsf_cw_minor_type), 0,
5495         NULL, HFILL }},
5496
5497     /* 15.6.13.1  Write to Display Structured Field Order - Create Window - Border Presentation Minor Structure */
5498     { &hf_tn5250_wdsf_cw_bp_flag1,
5499       { "Flags", "tn5250.wdsf_cw_bp_flag1",
5500       FT_UINT8, BASE_HEX, NULL, 0,
5501         NULL, HFILL }},
5502     { &hf_tn5250_wdsf_cw_bp_flag1_1,
5503       { "Flag 1", "tn5250.wdsf_cw_bp_flag1_1",
5504         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_cw_bp_flag1_1),
5505         0x80, NULL, HFILL }},
5506     { &hf_tn5250_wdsf_cw_bp_flag1_reserved,
5507         { "Reserved", "tn5250.wdsf_cw_bp_flag1_reserved", FT_UINT8, BASE_HEX,
5508           NULL, 0x7F, NULL, HFILL }},
5509     { &hf_tn5250_wdsf_cw_bp_mba,
5510       { "Monochrome Border Attribute", "tn5250.wdsf_cw_bp_mba",
5511       FT_UINT8, BASE_HEX, VALS(vals_tn5250_fa_color), 0,
5512         NULL, HFILL }},
5513     { &hf_tn5250_wdsf_cw_bp_cba,
5514       { "Color Border Attribute", "tn5250.wdsf_cw_bp_cba",
5515       FT_UINT8, BASE_HEX, VALS(vals_tn5250_fa_color), 0,
5516         NULL, HFILL }},
5517     { &hf_tn5250_wdsf_cw_bp_ulbc,
5518       { "Upper Left Border Character", "tn5250.wdsf_cw_bp_ulbc",
5519       FT_EBCDIC, BASE_NONE, NULL, 0,
5520         NULL, HFILL }},
5521     { &hf_tn5250_wdsf_cw_bp_tbc,
5522       { "Top Border Character", "tn5250.wdsf_cw_bp_tbc",
5523       FT_EBCDIC, BASE_NONE, NULL, 0,
5524         NULL, HFILL }},
5525     { &hf_tn5250_wdsf_cw_bp_urbc,
5526       { "Upper Right Border Character", "tn5250.wdsf_cw_bp_urbc",
5527       FT_EBCDIC, BASE_NONE, NULL, 0,
5528         NULL, HFILL }},
5529     { &hf_tn5250_wdsf_cw_bp_lbc,
5530       { "Left Border Character", "tn5250.wdsf_cw_bp_lbc",
5531       FT_EBCDIC, BASE_NONE, NULL, 0,
5532         NULL, HFILL }},
5533     { &hf_tn5250_wdsf_cw_bp_rbc,
5534       { "Right Border Character", "tn5250.wdsf_cw_bp_rbc",
5535       FT_EBCDIC, BASE_NONE, NULL, 0,
5536         NULL, HFILL }},
5537     { &hf_tn5250_wdsf_cw_bp_llbc,
5538       { "Lower Left Border Character", "tn5250.wdsf_cw_bp_llbc",
5539       FT_EBCDIC, BASE_NONE, NULL, 0,
5540         NULL, HFILL }},
5541     { &hf_tn5250_wdsf_cw_bp_bbc,
5542       { "Bottom Border Character", "tn5250.wdsf_cw_bp_bbc",
5543       FT_EBCDIC, BASE_NONE, NULL, 0,
5544         NULL, HFILL }},
5545     { &hf_tn5250_wdsf_cw_bp_lrbc,
5546       { "Lower Right Border Character", "tn5250.wdsf_cw_bp_lrbc",
5547       FT_EBCDIC, BASE_NONE, NULL, 0,
5548         NULL, HFILL }},
5549
5550     /* 15.6.13.1  Write to Display Structured Field Order - Create Window - Window/Title Footer Minor Structure */
5551     { &hf_tn5250_wdsf_cw_tf_flag,
5552       { "Flags", "tn5250.wdsf_cw_tf_flag",
5553       FT_UINT8, BASE_HEX, NULL, 0,
5554         NULL, HFILL }},
5555     { &hf_tn5250_wdsf_cw_tf_flag_orientation,
5556         { "Orientation", "tn5250.wdsf_cw_tf_flag_orientation", FT_UINT8, BASE_HEX,
5557           VALS(vals_tn5250_wdsf_cw_tf_flag_orientation), WTF_BITS, NULL, HFILL }},
5558     { &hf_tn5250_wdsf_cw_tf_flag_1,
5559       { "Title/Footer Defined", "tn5250.wdsf_cw_tf_flag_1",
5560         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_cw_tf_flag_1),
5561         0x20, NULL, HFILL }},
5562     { &hf_tn5250_wdsf_cw_tf_flag_reserved,
5563         { "Reserved", "tn5250.wdsf_cw_tf_flag_reserved", FT_UINT8, BASE_HEX,
5564           NULL, 0xF8, NULL, HFILL }},
5565     { &hf_tn5250_wdsf_cw_tf_mba,
5566       { "Monochrome Title/Footer Attribute", "tn5250.wdsf_cw_tf_mba",
5567       FT_UINT8, BASE_HEX, VALS(vals_tn5250_fa_color), 0,
5568         NULL, HFILL }},
5569     { &hf_tn5250_wdsf_cw_tf_cba,
5570       { "Color Title/Footer Attribute", "tn5250.wdsf_cw_tf_cba",
5571       FT_UINT8, BASE_HEX, VALS(vals_tn5250_fa_color), 0,
5572         NULL, HFILL }},
5573     { &hf_tn5250_wdsf_cw_tf_text,
5574       { "Title Text", "tn5250.wdsf_cw_tf_text",
5575       FT_EBCDIC, BASE_NONE, NULL, 0,
5576         NULL, HFILL }},
5577
5578     /* 15.6.13.2  Write to Display Structured Field Order - Unrestricted Window Cursor Movement */
5579       /* Consists of reserved fields only */
5580
5581     /* 15.6.13.3  Write to Display Structured Field Order - Remove GUI Window */
5582     { &hf_tn5250_wdsf_rgw_flag1,
5583       { "Flags", "tn5250.wdsf_rgw_flag",
5584       FT_UINT8, BASE_HEX, NULL, 0,
5585         NULL, HFILL }},
5586     { &hf_tn5250_wdsf_rgw_flag1_0,
5587       { "Reserved", "tn5250.wdsf_rgw_flag1_0",
5588         FT_BOOLEAN, 8, NULL,
5589         0x80, NULL, HFILL }},
5590     { &hf_tn5250_wdsf_rgw_flag1_1,
5591       { "Window Pull-Down", "tn5250.wdsf_rgw_flag1_1",
5592         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_cw_flag1_2),
5593         0x40, NULL, HFILL }},
5594     { &hf_tn5250_wdsf_rgw_reserved,
5595         { "Reserved", "tn5250.wdsf_rgw_flag_reserved", FT_UINT8, BASE_HEX,
5596           NULL, 0x3F, NULL, HFILL }},
5597
5598     /* 15.6.13.4  Write to Display Structured Field Order - Remove All GUI Constructs*/
5599     { &hf_tn5250_wdsf_ragc_flag1,
5600       { "Flags", "tn5250.wdsf_ragc_flag",
5601       FT_UINT8, BASE_HEX, NULL, 0,
5602         NULL, HFILL }},
5603     { &hf_tn5250_wdsf_ragc_flag1_0,
5604       { "GUI-Like Characters", "tn5250.wdsf_ragc_flag1_0",
5605         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ragc_flag1_0),
5606         0x80, NULL, HFILL }},
5607     { &hf_tn5250_wdsf_ragc_reserved,
5608         { "Reserved", "tn5250.wdsf_ragc_flag_reserved", FT_UINT8, BASE_HEX,
5609           NULL, 0x7F, NULL, HFILL }},
5610
5611     /* 15.6.13.5  Write to Display Structured Field Order - Define Selection Field*/
5612     { &hf_tn5250_wdsf_ds_flag1,
5613       { "Flags", "tn5250.wdsf_ds_flag1",
5614       FT_UINT8, BASE_HEX, NULL, 0,
5615         NULL, HFILL }},
5616     { &hf_tn5250_wdsf_ds_flag1_mouse_characteristics,
5617         { "Mouse Characteristics", "tn5250.wdsf_ds_flag1_mouse_characteristics", FT_UINT8, BASE_HEX,
5618           VALS(vals_tn5250_wdsf_ds_flag1_mouse_characteristics), MOUSE_CHARACTERISTICS_BITS, NULL, HFILL }},
5619     { &hf_tn5250_wdsf_ds_flag1_reserved,
5620         { "Reserved", "tn5250.wdsf_ds_flag1_reserved", FT_UINT8, BASE_HEX,
5621           NULL, 0x0C, NULL, HFILL }},
5622     { &hf_tn5250_wdsf_ds_flag1_auto_enter,
5623         { "Mouse Characteristics", "tn5250.wdsf_ds_flag1_auto_enter", FT_UINT8, BASE_HEX,
5624           VALS(vals_tn5250_wdsf_ds_flag1_auto_enter), DS_AUTO_ENTER_BITS, NULL, HFILL }},
5625     { &hf_tn5250_wdsf_ds_flag1_1,
5626       { "Auto Select", "tn5250.wdsf_ds_flag1_1",
5627         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_flag1_1),
5628         0x40, NULL, HFILL }},
5629     { &hf_tn5250_wdsf_ds_flag1_2,
5630       { "Field MDT", "tn5250.wdsf_ds_flag1_2",
5631         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_flag1_2),
5632         0x80, NULL, HFILL }},
5633
5634     { &hf_tn5250_wdsf_ds_flag2,
5635       { "Flags", "tn5250.wdsf_ds_flag2",
5636       FT_UINT8, BASE_HEX, NULL, 0,
5637         NULL, HFILL }},
5638     { &hf_tn5250_wdsf_ds_flag2_1,
5639       { "Bit 0", "tn5250.wdsf_ds_flag2_1",
5640         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_flag2_1),
5641         0x01, NULL, HFILL }},
5642     { &hf_tn5250_wdsf_ds_flag2_2,
5643       { "Bit 1", "tn5250.wdsf_ds_flag2_2",
5644         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_flag2_2),
5645         0x02, NULL, HFILL }},
5646     { &hf_tn5250_wdsf_ds_flag2_3,
5647       { "Bit 2", "tn5250.wdsf_ds_flag2_3",
5648         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_flag2_3),
5649         0x04, NULL, HFILL }},
5650     { &hf_tn5250_wdsf_ds_flag2_4,
5651       { "Bit 3", "tn5250.wdsf_ds_flag2_4",
5652         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_flag2_4),
5653         0x08, NULL, HFILL }},
5654     { &hf_tn5250_wdsf_ds_flag2_5,
5655       { "Bit 4", "tn5250.wdsf_ds_flag2_5",
5656         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_flag2_5),
5657         0x10, NULL, HFILL }},
5658     { &hf_tn5250_wdsf_ds_flag2_6,
5659       { "Bit 5", "tn5250.wdsf_ds_flag2_6",
5660         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_flag2_6),
5661         0x20, NULL, HFILL }},
5662     { &hf_tn5250_wdsf_ds_flag2_reserved,
5663         { "Reserved", "tn5250.wdsf_ds_flag3_reserved", FT_UINT8, BASE_HEX,
5664           NULL, 0xC0, NULL, HFILL }},
5665
5666     { &hf_tn5250_wdsf_ds_flag3,
5667       { "Flags", "tn5250.wdsf_ds_flag3",
5668       FT_UINT8, BASE_HEX, NULL, 0,
5669         NULL, HFILL }},
5670     { &hf_tn5250_wdsf_ds_flag3_1,
5671       { "Bit 0", "tn5250.wdsf_ds_flag3_1",
5672         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_flag3_1),
5673         0x01, NULL, HFILL }},
5674     { &hf_tn5250_wdsf_ds_flag3_reserved,
5675         { "Reserved", "tn5250.wdsf_ds_flag3_reserved", FT_UINT8, BASE_HEX,
5676           NULL, 0xFE, NULL, HFILL }},
5677
5678     { &hf_tn5250_wdsf_ds_type,
5679       { "Type of Selection Field", "tn5250.wdsf_ds_type",
5680       FT_UINT8, BASE_HEX, VALS(vals_tn5250_wdsf_ds_type), 0,
5681         NULL, HFILL }},
5682
5683     { &hf_tn5250_wdsf_ds_gdc,
5684       { "GUI Device Characteristics", "tn5250.wdsf_ds_gdc",
5685       FT_UINT8, BASE_HEX, NULL, 0,
5686         NULL, HFILL }},
5687     { &hf_tn5250_wdsf_ds_gdc_indicators,
5688         { "Indicators", "tn5250.wdsf_ds_gdc_indicators", FT_UINT8, BASE_HEX,
5689           VALS(vals_tn5250_wdsf_ds_gdc_indicators), DS_INDICATORS_BITS, NULL, HFILL }},
5690     { &hf_tn5250_wdsf_ds_gdc_reserved,
5691         { "Reserved", "tn5250.wdsf_ds_gdc_reserved", FT_BOOLEAN, 8,
5692           NULL, 0x10, NULL, HFILL }},
5693     { &hf_tn5250_wdsf_ds_gdc_selection_techniques,
5694         { "Selection Techniques", "tn5250.wdsf_ds_selection_techniques", FT_UINT8, BASE_HEX,
5695           VALS(vals_tn5250_wdsf_ds_gdc_selection_techniques), DS_SELECTION_TECHNIQUES_BITS, NULL, HFILL }},
5696
5697     { &hf_tn5250_wdsf_ds_nws,
5698       { "NWS With Mnemonic Underscore Characteristics", "tn5250.wdsf_ds_nws",
5699       FT_UINT8, BASE_HEX, NULL, 0,
5700         NULL, HFILL }},
5701     { &hf_tn5250_wdsf_ds_nws_indicators,
5702         { "Indicators", "tn5250.wdsf_ds_nws_indicators", FT_UINT8, BASE_HEX,
5703           VALS(vals_tn5250_wdsf_ds_nws_indicators), DS_NWS_INDICATORS_BITS, NULL, HFILL }},
5704     { &hf_tn5250_wdsf_ds_nws_reserved,
5705         { "Reserved", "tn5250.wdsf_ds_nws_reserved", FT_BOOLEAN, 8,
5706           NULL, 0x10, NULL, HFILL }},
5707     { &hf_tn5250_wdsf_ds_nws_selection_techniques,
5708         { "Selection Techniques", "tn5250.wdsf_ds_selection_techniques", FT_UINT8, BASE_HEX,
5709           VALS(vals_tn5250_wdsf_ds_nws_selection_techniques), DS_NWS_SELECTION_TECHNIQUES_BITS, NULL, HFILL }},
5710
5711     { &hf_tn5250_wdsf_ds_nws_wout,
5712       { "NWS Without Mnemonic Underscore Characteristics", "tn5250.wdsf_ds_nws",
5713       FT_UINT8, BASE_HEX, NULL, 0,
5714         NULL, HFILL }},
5715       /* hf_tn5250_wdsf_ds_nws_wout uses same bitfields as hf_tn5250_wdsf_ds_nws */
5716
5717     { &hf_tn5250_wdsf_ds_textsize,
5718       { "Text Size", "tn5250.wdsf_ds_textsize",
5719       FT_UINT8, BASE_DEC, NULL, 0,
5720         NULL, HFILL }},
5721     { &hf_tn5250_wdsf_ds_rows,
5722       { "Rows", "tn5250.wdsf_ds_rows",
5723       FT_UINT8, BASE_DEC, NULL, 0,
5724         NULL, HFILL }},
5725     { &hf_tn5250_wdsf_ds_columns,
5726       { "Columns/Menu Bar Choices", "tn5250.wdsf_ds_columns",
5727       FT_UINT8, BASE_DEC, NULL, 0,
5728         NULL, HFILL }},
5729     { &hf_tn5250_wdsf_ds_padding,
5730       { "Padding Between Choices", "tn5250.wdsf_ds_padding",
5731       FT_UINT8, BASE_DEC, NULL, 0,
5732         NULL, HFILL }},
5733     { &hf_tn5250_wdsf_ds_numeric_sep,
5734       { "Numeric Separator Character", "tn5250.wdsf_ds_numeric_sep",
5735       FT_EBCDIC, BASE_NONE, NULL, 0,
5736         NULL, HFILL }},
5737     { &hf_tn5250_wdsf_ds_country_sel,
5738       { "Country Specific Selection Character", "tn5250.wdsf_ds_country_sel",
5739       FT_EBCDIC, BASE_NONE, NULL, 0,
5740         NULL, HFILL }},
5741     { &hf_tn5250_wdsf_ds_cancel_aid,
5742       { "Mouse Pull-Down Cancel AID", "tn5250.wdsf_ds_cancel_aid",
5743       FT_UINT8, BASE_HEX, NULL, 0,
5744         NULL, HFILL }},
5745     { &hf_tn5250_wdsf_ds_totalrows,
5746       { "Total Rows or Minor Structures That Can Be Scrolled", "tn5250.wdsf_ds_totalrows",
5747       FT_UINT32, BASE_DEC, NULL, 0,
5748         NULL, HFILL }},
5749     { &hf_tn5250_wdsf_ds_sliderpos,
5750       { "Slider Positions That Can Be Scrolled", "tn5250.wdsf_ds_sliderpos",
5751       FT_UINT32, BASE_DEC, NULL, 0,
5752         NULL, HFILL }},
5753
5754     { &hf_tn5250_wdsf_ds_minor_type,
5755       { "Minor Structured Field Type", "tn5250.wdsf_ds_minor_type",
5756       FT_UINT8, BASE_HEX, VALS(vals_tn5250_wdsf_ds_minor_type), 0,
5757         NULL, HFILL }},
5758
5759     /* 15.6.13.5  Write to Display Structured Field Order - Define Selection Field - Choice Text Minor Structure*/
5760     { &hf_tn5250_wdsf_ds_ct_flag1,
5761       { "Flag Byte 1", "tn5250.wdsf_ds_ct_flag1",
5762       FT_UINT8, BASE_HEX, NULL, 0,
5763         NULL, HFILL }},
5764     { &hf_tn5250_wdsf_ds_ct_flag1_choice_state,
5765         { "Choice State", "tn5250.wdsf_ds_ct_flag1_choice_state", FT_UINT8, BASE_HEX,
5766           VALS(vals_tn5250_wdsf_ds_ct_flag1_choice_state), DS_CHOICE_STATE_BITS, NULL, HFILL }},
5767     { &hf_tn5250_wdsf_ds_ct_flag1_2,
5768       { "Bit 2", "tn5250.wdsf_ds_ct_flag1_2",
5769         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_ct_flag1_2),
5770         0x04, NULL, HFILL }},
5771     { &hf_tn5250_wdsf_ds_ct_flag1_3,
5772       { "Bit 3", "tn5250.wdsf_ds_ct_flag1_3",
5773         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_ct_flag1_3),
5774         0x08, NULL, HFILL }},
5775     { &hf_tn5250_wdsf_ds_ct_flag1_4,
5776       { "Bit 4", "tn5250.wdsf_ds_ct_flag1_4",
5777         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_ct_flag1_4),
5778         0x10, NULL, HFILL }},
5779     { &hf_tn5250_wdsf_ds_ct_flag1_5,
5780       { "Bit 5", "tn5250.wdsf_ds_ct_flag1_5",
5781         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_ct_flag1_5),
5782         0x20, NULL, HFILL }},
5783     { &hf_tn5250_wdsf_ds_ct_flag1_numeric_selection,
5784         { "Numeric Selection Characters", "tn5250.wdsf_ds_ct_flag1_numeric_selection", FT_UINT8, BASE_HEX,
5785           VALS(vals_tn5250_wdsf_ds_ct_flag1_numeric_selection), DS_NUMERIC_SELECTION_BITS, NULL, HFILL }},
5786
5787     { &hf_tn5250_wdsf_ds_ct_flag2,
5788       { "Flag Byte 2", "tn5250.wdsf_ds_ct_flag2",
5789       FT_UINT8, BASE_HEX, NULL, 0,
5790         NULL, HFILL }},
5791     { &hf_tn5250_wdsf_ds_ct_flag2_0,
5792       { "Bit 0", "tn5250.wdsf_ds_ct_flag2_0",
5793         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_ct_flag2_0),
5794         0x01, NULL, HFILL }},
5795     { &hf_tn5250_wdsf_ds_ct_flag2_1,
5796       { "Bit 1", "tn5250.wdsf_ds_ct_flag2_1",
5797         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_ct_flag2_1),
5798         0x02, NULL, HFILL }},
5799     { &hf_tn5250_wdsf_ds_ct_flag2_2,
5800       { "Bit 2", "tn5250.wdsf_ds_ct_flag2_2",
5801         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_ct_flag2_2),
5802         0x04, NULL, HFILL }},
5803     { &hf_tn5250_wdsf_ds_ct_flag2_3,
5804       { "Bit 3", "tn5250.wdsf_ds_ct_flag2_3",
5805         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_ct_flag2_3),
5806         0x08, NULL, HFILL }},
5807     { &hf_tn5250_wdsf_ds_ct_flag2_4,
5808       { "Bit 4", "tn5250.wdsf_ds_ct_flag2_4",
5809         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_ct_flag2_4),
5810         0x10, NULL, HFILL }},
5811     { &hf_tn5250_wdsf_ds_ct_flag2_5,
5812       { "Bit 5", "tn5250.wdsf_ds_ct_flag2_5",
5813         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_ct_flag2_5),
5814         0x20, NULL, HFILL }},
5815     { &hf_tn5250_wdsf_ds_ct_flag2_6,
5816       { "Bit 6", "tn5250.wdsf_ds_ct_flag2_6",
5817         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_ct_flag2_6),
5818         0x40, NULL, HFILL }},
5819     { &hf_tn5250_wdsf_ds_ct_flag2_7,
5820       { "Bit 7", "tn5250.wdsf_ds_ct_flag2_7",
5821         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_ct_flag2_7),
5822         0x80, NULL, HFILL }},
5823
5824     { &hf_tn5250_wdsf_ds_ct_flag3,
5825       { "Flag Byte 3", "tn5250.wdsf_ds_ct_flag3",
5826       FT_UINT8, BASE_HEX, NULL, 0,
5827         NULL, HFILL }},
5828     { &hf_tn5250_wdsf_ds_ct_flag3_0,
5829       { "Bit 0", "tn5250.wdsf_ds_ct_flag3_0",
5830         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_ct_flag3_0),
5831         0x01, NULL, HFILL }},
5832     { &hf_tn5250_wdsf_ds_ct_flag3_1,
5833       { "Bit 1", "tn5250.wdsf_ds_ct_flag3_1",
5834         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_ct_flag3_1),
5835         0x02, NULL, HFILL }},
5836     { &hf_tn5250_wdsf_ds_ct_flag3_2,
5837       { "Bit 2", "tn5250.wdsf_ds_ct_flag3_2",
5838         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_ct_flag3_2),
5839         0x04, NULL, HFILL }},
5840     { &hf_tn5250_wdsf_ds_ct_flag3_reserved,
5841         { "Reserved", "tn5250.wdsf_ds_ct_flag3_reserved", FT_UINT8, BASE_HEX,
5842           NULL, 0xF8, NULL, HFILL }},
5843
5844     { &hf_tn5250_wdsf_ds_ct_mnemonic_offset,
5845       { "Mnemonic Offset", "tn5250.wdsf_ds_ct_mnemonic_offset",
5846       FT_UINT8, BASE_DEC, NULL, 0,
5847         NULL, HFILL }},
5848     { &hf_tn5250_wdsf_ds_ct_aid,
5849       { "AID", "tn5250.wdsf_ds_ct_aid",
5850       FT_UINT8, BASE_HEX, NULL, 0,
5851         NULL, HFILL }},
5852     { &hf_tn5250_wdsf_ds_ct_numeric_onebyte,
5853       { "Numeric Characters", "tn5250.wdsf_ds_ct_numeric",
5854       FT_UINT8, BASE_HEX, NULL, 0,
5855         NULL, HFILL }},
5856     { &hf_tn5250_wdsf_ds_ct_numeric_twobyte,
5857       { "Numeric Characters", "tn5250.wdsf_ds_ct_numeric",
5858       FT_UINT16, BASE_HEX, NULL, 0,
5859         NULL, HFILL }},
5860     { &hf_tn5250_wdsf_ds_ct_text,
5861       { "Choice Text", "tn5250.wdsf_ds_ct_text",
5862       FT_EBCDIC, BASE_NONE, NULL, 0,
5863         NULL, HFILL }},
5864
5865     /* 15.6.13.5  Write to Display Structured Field Order - Define Selection Field - Menu Bar Separator Minor Structure*/
5866
5867     { &hf_tn5250_wdsf_ds_mbs_flag,
5868       { "Flags", "tn5250.wdsf_ds_mbs_flag",
5869       FT_UINT8, BASE_HEX, NULL, 0,
5870         NULL, HFILL }},
5871     { &hf_tn5250_wdsf_ds_mbs_flag_0,
5872       { "Bit 0", "tn5250.wdsf_ds_mbs_flag_0",
5873         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_mbs_flag_0),
5874         0x01, NULL, HFILL }},
5875     { &hf_tn5250_wdsf_ds_mbs_flag_1,
5876       { "Bit 1", "tn5250.wdsf_ds_mbs_flag_1",
5877         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_mbs_flag_1),
5878         0x02, NULL, HFILL }},
5879     { &hf_tn5250_wdsf_ds_mbs_flag_reserved,
5880         { "Reserved", "tn5250.wdsf_ds_mbs_flag_reserved", FT_UINT8, BASE_HEX,
5881           NULL, 0xF8, NULL, HFILL }},
5882     { &hf_tn5250_wdsf_ds_mbs_start_column,
5883       { "Start Column", "tn5250.wdsf_ds_mbs_start_column",
5884       FT_UINT8, BASE_DEC, NULL, 0,
5885         NULL, HFILL }},
5886     { &hf_tn5250_wdsf_ds_mbs_end_column,
5887       { "End Column", "tn5250.wdsf_ds_mbs_end_column",
5888       FT_UINT8, BASE_DEC, NULL, 0,
5889         NULL, HFILL }},
5890     { &hf_tn5250_wdsf_ds_mbs_monochrome_sep,
5891       { "Monochrome Separator Emphasis", "tn5250.wdsf_ds_mbs_monochrome_sep",
5892       FT_UINT8, BASE_HEX, VALS(vals_tn5250_fa_color), 0,
5893         NULL, HFILL }},
5894     { &hf_tn5250_wdsf_ds_mbs_color_sep,
5895       { "Color Separator Emphasis", "tn5250.wdsf_ds_mbs_color_sep",
5896       FT_UINT8, BASE_HEX, VALS(vals_tn5250_fa_color), 0,
5897         NULL, HFILL }},
5898     { &hf_tn5250_wdsf_ds_mbs_sep_char,
5899       { "Separator Character", "tn5250.wdsf_ds_mbs_sep_char",
5900       FT_EBCDIC, BASE_NONE, NULL, 0,
5901         NULL, HFILL }},
5902
5903     /* 15.6.13.5  Write to Display Structured Field Order - Define Selection Field - Choice Presentation Display Attributes Minor Structure*/
5904     { &hf_tn5250_wdsf_ds_cpda_flag1,
5905       { "Flags", "tn5250.wdsf_ds_cpda_flag1",
5906       FT_UINT8, BASE_HEX, NULL, 0,
5907         NULL, HFILL }},
5908     { &hf_tn5250_wdsf_ds_cpda_flag1_0,
5909       { "Bit 0", "tn5250.wdsf_ds_cpda_flag1_0",
5910         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_cpda_flag1_0),
5911         0x01, NULL, HFILL }},
5912     { &hf_tn5250_wdsf_ds_cpda_flag1_1,
5913       { "Bit 1", "tn5250.wdsf_ds_cpda_flag1_1",
5914         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_cpda_flag1_1),
5915         0x02, NULL, HFILL }},
5916     { &hf_tn5250_wdsf_ds_cpda_flag1_2,
5917       { "Bit 2", "tn5250.wdsf_ds_cpda_flag1_2",
5918         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_cpda_flag1_2),
5919         0x04, NULL, HFILL }},
5920     { &hf_tn5250_wdsf_ds_cpda_flag1_reserved,
5921         { "Reserved", "tn5250.wdsf_ds_cpda_flag1_reserved", FT_UINT8, BASE_HEX,
5922           NULL, 0xF8, NULL, HFILL }},
5923
5924     { &hf_tn5250_wdsf_ds_cpda_monochrome_sel_avail,
5925       { "Monochrome Selection Cursor Available Emphasis", "tn5250.wdsf_ds_cpda_monochrome_sel_avail",
5926       FT_UINT8, BASE_HEX, VALS(vals_tn5250_fa_color), 0,
5927         NULL, HFILL }},
5928     { &hf_tn5250_wdsf_ds_cpda_color_sel_avail,
5929       { "Color Selection Cursor Available Emphasis", "tn5250.wdsf_ds_cpda_color_sel_avail",
5930       FT_UINT8, BASE_HEX, VALS(vals_tn5250_fa_color), 0,
5931         NULL, HFILL }},
5932     { &hf_tn5250_wdsf_ds_cpda_monochrome_sel_selected,
5933       { "Monochrome Selection Cursor Selected Emphasis", "tn5250.wdsf_ds_cpda_monochrome_sel_selected",
5934       FT_UINT8, BASE_HEX, VALS(vals_tn5250_fa_color), 0,
5935         NULL, HFILL }},
5936     { &hf_tn5250_wdsf_ds_cpda_color_sel_selected,
5937       { "Color Selection Cursor Selected Emphasis", "tn5250.wdsf_ds_cpda_color_sel_selected",
5938       FT_UINT8, BASE_HEX, VALS(vals_tn5250_fa_color), 0,
5939         NULL, HFILL }},
5940
5941     { &hf_tn5250_wdsf_ds_cpda_monochrome_sel_unavail,
5942       { "Monochrome Selection Cursor Unavailable Emphasis", "tn5250.wdsf_ds_cpda_monochrome_sel_unavail",
5943       FT_UINT8, BASE_HEX, VALS(vals_tn5250_fa_color), 0,
5944         NULL, HFILL }},
5945     { &hf_tn5250_wdsf_ds_cpda_color_sel_unavail,
5946       { "Color Selection Cursor Unavailable Emphasis", "tn5250.wdsf_ds_cpda_color_sel_unavail",
5947       FT_UINT8, BASE_HEX, VALS(vals_tn5250_fa_color), 0,
5948         NULL, HFILL }},
5949
5950     { &hf_tn5250_wdsf_ds_cpda_monochrome_avail,
5951       { "Monochrome Available Emphasis", "tn5250.wdsf_ds_cpda_monochrome_avail",
5952       FT_UINT8, BASE_HEX, VALS(vals_tn5250_fa_color), 0,
5953         NULL, HFILL }},
5954     { &hf_tn5250_wdsf_ds_cpda_color_avail,
5955       { "Color Available Emphasis", "tn5250.wdsf_ds_cpda_color_avail",
5956       FT_UINT8, BASE_HEX, VALS(vals_tn5250_fa_color), 0,
5957         NULL, HFILL }},
5958
5959     { &hf_tn5250_wdsf_ds_cpda_monochrome_selected,
5960       { "Monochrome Selected Emphasis", "tn5250.wdsf_ds_cpda_monochrome_selected",
5961       FT_UINT8, BASE_HEX, VALS(vals_tn5250_fa_color), 0,
5962         NULL, HFILL }},
5963     { &hf_tn5250_wdsf_ds_cpda_color_selected,
5964       { "Color Selected Emphasis", "tn5250.wdsf_ds_cpda_color_selected",
5965       FT_UINT8, BASE_HEX, VALS(vals_tn5250_fa_color), 0,
5966         NULL, HFILL }},
5967
5968     { &hf_tn5250_wdsf_ds_cpda_monochrome_unavail,
5969       { "Monochrome Unavailable Emphasis", "tn5250.wdsf_ds_cpda_monochrome_unavail",
5970       FT_UINT8, BASE_HEX, VALS(vals_tn5250_fa_color), 0,
5971         NULL, HFILL }},
5972     { &hf_tn5250_wdsf_ds_cpda_color_unavail,
5973       { "Color Unavailable Emphasis", "tn5250.wdsf_ds_cpda_color_unavail",
5974       FT_UINT8, BASE_HEX, VALS(vals_tn5250_fa_color), 0,
5975         NULL, HFILL }},
5976
5977     { &hf_tn5250_wdsf_ds_cpda_monochrome_indicator,
5978       { "Monochrome Indicator Emphasis", "tn5250.wdsf_ds_cpda_monochrome_indicator",
5979       FT_UINT8, BASE_HEX, VALS(vals_tn5250_fa_color), 0,
5980         NULL, HFILL }},
5981     { &hf_tn5250_wdsf_ds_cpda_color_indicator,
5982       { "Color Indicator Emphasis", "tn5250.wdsf_ds_cpda_color_indicator",
5983       FT_UINT8, BASE_HEX, VALS(vals_tn5250_fa_color), 0,
5984         NULL, HFILL }},
5985
5986     { &hf_tn5250_wdsf_ds_cpda_monochrome_unavail_indicator,
5987       { "Monochrome Unavailable Indicator Emphasis", "tn5250.wdsf_ds_cpda_monochrome_unavail_indicator",
5988       FT_UINT8, BASE_HEX, VALS(vals_tn5250_fa_color), 0,
5989         NULL, HFILL }},
5990     { &hf_tn5250_wdsf_ds_cpda_color_unavail_indicator,
5991       { "Color Unavailable Indicator Emphasis", "tn5250.wdsf_ds_cpda_color_unavail_indicator",
5992       FT_UINT8, BASE_HEX, VALS(vals_tn5250_fa_color), 0,
5993         NULL, HFILL }},
5994
5995
5996
5997     /* 15.6.13.5  Write to Display Structured Field Order - Define Selection Field - Choice Indicators Minor Structure*/
5998     { &hf_tn5250_wdsf_ds_ci_flag1,
5999       { "Flags", "tn5250.wdsf_ds_ci_flag1",
6000       FT_UINT8, BASE_HEX, NULL, 0,
6001         NULL, HFILL }},
6002     { &hf_tn5250_wdsf_ds_ci_flag1_0,
6003       { "Bit 0", "tn5250.wdsf_ds_ci_flag1_0",
6004         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_ci_flag1_0),
6005         0x01, NULL, HFILL }},
6006     { &hf_tn5250_wdsf_ds_ci_flag1_reserved,
6007         { "Reserved", "tn5250.wdsf_ds_ci_flag1_reserved", FT_UINT8, BASE_HEX,
6008           NULL, 0xFE, NULL, HFILL }},
6009
6010     { &hf_tn5250_wdsf_ds_ci_left_push,
6011       { "Empty Indicator or Left Push Button", "tn5250.wdsf_ds_ci_left_push",
6012       FT_EBCDIC, BASE_NONE, NULL, 0,
6013         NULL, HFILL }},
6014     { &hf_tn5250_wdsf_ds_ci_right_push,
6015       { "Selected Indicator or Right Push Button", "tn5250.wdsf_ds_ci_right_push",
6016       FT_EBCDIC, BASE_NONE, NULL, 0,
6017         NULL, HFILL }},
6018     { &hf_tn5250_wdsf_ds_ci_first_choice,
6019       { "Character That Replaces the First Choice Text Character for Unavailable Choices On a Monochrome Display", "tn5250.wdsf_ds_ci_first_choice",
6020       FT_EBCDIC, BASE_NONE, NULL, 0,
6021         NULL, HFILL }},
6022
6023     /* 15.6.13.5  Write to Display Structured Field Order - Define Selection Field - Scroll Bar Indicators Minor Structure*/
6024     { &hf_tn5250_wdsf_ds_sbi_flag1,
6025       { "Flags", "tn5250.wdsf_ds_sbi_flag1",
6026       FT_UINT8, BASE_HEX, NULL, 0,
6027         NULL, HFILL }},
6028     { &hf_tn5250_wdsf_ds_sbi_flag1_0,
6029       { "Bit 0", "tn5250.wdsf_ds_sbi_flag1_0",
6030         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_sbi_flag1_0),
6031         0x01, NULL, HFILL }},
6032     { &hf_tn5250_wdsf_ds_sbi_flag1_reserved,
6033         { "Reserved", "tn5250.wdsf_ds_sbi_flag1_reserved", FT_UINT8, BASE_HEX,
6034           NULL, 0xFE, NULL, HFILL }},
6035
6036     { &hf_tn5250_wdsf_ds_sbi_monochrome_top_highlight,
6037       { "Monochrome Top of ScrollBar Highlighting", "tn5250.wdsf_ds_sbi_monochrome_top_highlight",
6038       FT_UINT8, BASE_HEX, VALS(vals_tn5250_fa_color), 0,
6039         NULL, HFILL }},
6040     { &hf_tn5250_wdsf_ds_sbi_color_top_highlight,
6041       { "Color Top of ScrollBar Highlighting", "tn5250.wdsf_ds_sbi_color_top_highlightl",
6042       FT_UINT8, BASE_HEX, VALS(vals_tn5250_fa_color), 0,
6043         NULL, HFILL }},
6044
6045     { &hf_tn5250_wdsf_ds_sbi_monochrome_top_highlight_shaft,
6046       { "Monochrome Shaft ScrollBar Highlighting", "tn5250.wdsf_ds_sbi_monochrome_top_highlight_shaft",
6047       FT_UINT8, BASE_HEX, VALS(vals_tn5250_fa_color), 0,
6048         NULL, HFILL }},
6049     { &hf_tn5250_wdsf_ds_sbi_color_top_highlight_shaft,
6050       { "Color Shaft ScrollBar Highlighting", "tn5250.wdsf_ds_sbi_color_top_highlight_shaft",
6051       FT_UINT8, BASE_HEX, VALS(vals_tn5250_fa_color), 0,
6052         NULL, HFILL }},
6053
6054     { &hf_tn5250_wdsf_ds_sbi_top_character,
6055       { "Top Scroll Bar Character", "tn5250.wdsf_ds_sbi_top_character",
6056       FT_EBCDIC, BASE_NONE, NULL, 0,
6057         NULL, HFILL }},
6058     { &hf_tn5250_wdsf_ds_sbi_bottom_character,
6059       { "Bottom Scroll Bar Character", "tn5250.wdsf_ds_sbi_bottom_character",
6060       FT_EBCDIC, BASE_NONE, NULL, 0,
6061         NULL, HFILL }},
6062     { &hf_tn5250_wdsf_ds_sbi_empty_character,
6063       { "Empty Scroll Bar Character", "tn5250.wdsf_ds_sbi_empty_character",
6064       FT_EBCDIC, BASE_NONE, NULL, 0,
6065         NULL, HFILL }},
6066     { &hf_tn5250_wdsf_ds_sbi_slider_character,
6067       { "Slider Scroll Bar Character", "tn5250.wdsf_ds_sbi_slider_character",
6068       FT_EBCDIC, BASE_NONE, NULL, 0,
6069         NULL, HFILL }},
6070
6071     /* 15.6.13.6  Write to Display Structured Field Order - Remove GUI Selection Field */
6072       /* Consists of reserved fields only */
6073
6074     /* 15.6.13.7  Write to Display Structured Field Order - Define Scroll Bar Field */
6075     { &hf_tn5250_wdsf_dsb_flag1,
6076       { "Flags", "tn5250.wdsf_dsb_flag1",
6077       FT_UINT8, BASE_HEX, NULL, 0,
6078         NULL, HFILL }},
6079     { &hf_tn5250_wdsf_dsb_flag1_0,
6080       { "Bit 0", "tn5250.wdsf_dsb_flag1_0",
6081         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_dsb_flag1_0),
6082         0x01, NULL, HFILL }},
6083     { &hf_tn5250_wdsf_dsb_flag1_1,
6084       { "Bit 1", "tn5250.wdsf_dsb_flag1_1",
6085         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_dsb_flag1_0),
6086         0x02, NULL, HFILL }},
6087     { &hf_tn5250_wdsf_dsb_flag1_reserved,
6088         { "Reserved", "tn5250.wdsf_dsb_flag1_reserved", FT_UINT8, BASE_HEX,
6089           NULL, 0x7C, NULL, HFILL }},
6090     { &hf_tn5250_wdsf_dsb_flag1_7,
6091       { "Bit 7", "tn5250.wdsf_dsb_flag1_7",
6092         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_dsb_flag1_7),
6093         0x80, NULL, HFILL }},
6094
6095     { &hf_tn5250_wdsf_sbi_total_scroll,
6096       { "TotalRows or TotalCols That Can  Be Scrolled", "tn5250.wdsf_sbi_total_scroll",
6097       FT_UINT32, BASE_DEC, NULL, 0,
6098         NULL, HFILL }},
6099     { &hf_tn5250_wdsf_sbi_sliderpos,
6100       { "SliderPos", "tn5250.wdsf_sbi_sliderpos",
6101       FT_UINT32, BASE_DEC, NULL, 0,
6102         NULL, HFILL }},
6103     { &hf_tn5250_wdsf_sbi_rowscols,
6104       { "Rows or Columns", "tn5250.wdsf_sbi_rowscols",
6105       FT_UINT8, BASE_DEC, NULL, 0,
6106         NULL, HFILL }},
6107
6108     /* 15.6.13.8  Write to Display Structured Field Order - Remove GUI Scroll Bar Field */
6109       /* Consists of reserved fields only */
6110
6111     /* 15.6.13.9  Write to Display Structured Field Order - Write Data Field */
6112     { &hf_tn5250_wdsf_wdf_flag1,
6113       { "Flags", "tn5250.wdsf_wdf_flag1",
6114       FT_UINT8, BASE_HEX, NULL, 0,
6115         NULL, HFILL }},
6116     { &hf_tn5250_wdsf_wdf_flag1_0,
6117       { "Bit 0", "tn5250.wdsf_wdf_flag1_0",
6118         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_wdf_flag1_0),
6119         0x01, NULL, HFILL }},
6120     { &hf_tn5250_wdsf_wdf_flag1_reserved,
6121         { "Reserved", "tn5250.wdsf_wdf_flag1_reserved", FT_UINT8, BASE_HEX,
6122           NULL, 0xFE, NULL, HFILL }},
6123
6124     /* 15.6.13.10  Write to Display Structured Field Order - Programmable Mouse Buttons */
6125     { &hf_tn5250_wdsf_pmb_flag1,
6126       { "Flags", "tn5250.wdsf_pmb_flag1",
6127       FT_UINT8, BASE_HEX, NULL, 0,
6128         NULL, HFILL }},
6129     { &hf_tn5250_wdsf_pmb_flag1_0,
6130       { "Bit 0", "tn5250.wdsf_pmb_flag1_0",
6131         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_pmb_flag1_0),
6132         0x01, NULL, HFILL }},
6133     { &hf_tn5250_wdsf_pmb_flag1_1,
6134       { "Bit 1", "tn5250.wdsf_pmb_flag1_1",
6135         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_pmb_flag1_1),
6136         0x02, NULL, HFILL }},
6137     { &hf_tn5250_wdsf_pmb_flag1_2,
6138       { "Bit 2", "tn5250.wdsf_pmb_flag1_2",
6139         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_pmb_flag1_2),
6140         0x04, NULL, HFILL }},
6141     { &hf_tn5250_wdsf_pmb_flag1_3,
6142       { "Bit 3", "tn5250.wdsf_pmb_flag1_3",
6143         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_pmb_flag1_3),
6144         0x08, NULL, HFILL }},
6145     { &hf_tn5250_wdsf_pmb_flag1_reserved,
6146         { "Reserved", "tn5250.wdsf_pmb_flag1_reserved", FT_UINT8, BASE_HEX,
6147           NULL, 0xF0, NULL, HFILL }},
6148     { &hf_tn5250_wdsf_pmb_first_mouse_event,
6149       { "First Mouse Event (Leading Edge Event)", "tn5250.wdsf_pmb_first_mouse_event",
6150       FT_UINT8, BASE_HEX, VALS(vals_tn5250_mouse_events), 0,
6151         NULL, HFILL }},
6152     { &hf_tn5250_wdsf_pmb_second_mouse_event,
6153       { "Second Mouse Event (Trailing Edge Event)", "tn5250.wdsf_pmb_second_mouse_event",
6154       FT_UINT8, BASE_HEX, VALS(vals_tn5250_mouse_events), 0,
6155         NULL, HFILL }},
6156
6157     /* 15.7 Draw/Erase Grid Lines Structured Field */
6158     { &hf_tn5250_wdsf_deg_partition,
6159       { "Partition", "tn5250.wdsf_deg_partition",
6160       FT_UINT8, BASE_HEX, NULL, 0,
6161         NULL, HFILL }},
6162     { &hf_tn5250_wdsf_deg_flag1,
6163       { "Flags", "tn5250.wdsf_deg_flag1",
6164       FT_UINT8, BASE_HEX, NULL, 0,
6165         NULL, HFILL }},
6166     { &hf_tn5250_wdsf_deg_flag1_0,
6167       { "Bit 0", "tn5250.wdsf_deg_flag1_0",
6168         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_deg_flag1_0),
6169         0x01, NULL, HFILL }},
6170     { &hf_tn5250_wdsf_deg_flag1_reserved,
6171         { "Reserved", "tn5250.wdsf_deg_flag1_reserved", FT_UINT8, BASE_HEX,
6172           NULL, 0xFE, NULL, HFILL }},
6173     { &hf_tn5250_wdsf_deg_flag2,
6174       { "Flags", "tn5250.wdsf_deg_flag2",
6175       FT_UINT8, BASE_HEX, NULL, 0,
6176         NULL, HFILL }},
6177     { &hf_tn5250_wdsf_deg_flag2_0,
6178       { "Bit 0", "tn5250.wdsf_deg_flag2_0",
6179         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_deg_flag1_0),
6180         0x01, NULL, HFILL }},
6181     { &hf_tn5250_wdsf_deg_flag2_reserved,
6182         { "Reserved", "tn5250.wdsf_deg_flag2_reserved", FT_UINT8, BASE_HEX,
6183           NULL, 0xFE, NULL, HFILL }},
6184     { &hf_tn5250_wdsf_deg_default_color,
6185       { "Default Color for Grid Lines", "tn5250.wdsf_deg_default_color",
6186       FT_UINT8, BASE_HEX, VALS(vals_tn5250_fa_color), 0,
6187         NULL, HFILL }},
6188     { &hf_tn5250_wdsf_deg_default_line,
6189       { "Default Line Style", "tn5250.wdsf_deg_default_line",
6190       FT_UINT8, BASE_HEX, VALS(vals_tn5250_deg_lines), 0,
6191         NULL, HFILL }},
6192
6193     /* 15.7.1 Draw/Erase Grid Lines Structured Field - Minor Structure*/
6194     { &hf_tn5250_wdsf_deg_minor_type,
6195       { "Construct", "tn5250.wdsf_deg_minor_type",
6196       FT_UINT8, BASE_HEX, VALS(vals_tn5250_wdsf_deg_minor_type), 0,
6197         NULL, HFILL }},
6198     { &hf_tn5250_wdsf_deg_ms_flag1,
6199       { "Flags", "tn5250.wdsf_deg_ms_flag1",
6200       FT_UINT8, BASE_HEX, NULL, 0,
6201         NULL, HFILL }},
6202     { &hf_tn5250_wdsf_deg_ms_flag1_0,
6203       { "Bit 0", "tn5250.wdsf_deg_ms_flag1_0",
6204         FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_deg_ms_flag1_0),
6205         0x01, NULL, HFILL }},
6206     { &hf_tn5250_wdsf_deg_ms_flag1_reserved,
6207         { "Reserved", "tn5250.wdsf_deg_ms_flag1_reserved", FT_UINT8, BASE_HEX,
6208           NULL, 0xFE, NULL, HFILL }},
6209     { &hf_tn5250_wdsf_deg_ms_start_row,
6210       { "Start Row", "tn5250.wdsf_deg_ms_start_row",
6211       FT_UINT8, BASE_DEC, NULL, 0,
6212         NULL, HFILL }},
6213     { &hf_tn5250_wdsf_deg_ms_start_column,
6214       { "Start Column", "tn5250.wdsf_deg_ms_start_column",
6215       FT_UINT8, BASE_DEC, NULL, 0,
6216         NULL, HFILL }},
6217     { &hf_tn5250_wdsf_deg_ms_horizontal_dimension,
6218       { "Horizontal Dimenstion", "tn5250.wdsf_deg_ms_horizontal_dimension",
6219       FT_UINT8, BASE_DEC, NULL, 0,
6220         NULL, HFILL }},
6221     { &hf_tn5250_wdsf_deg_ms_vertical_dimension,
6222       { "Vertical Dimenstion", "tn5250.wdsf_deg_ms_vertical_dimension",
6223       FT_UINT8, BASE_DEC, NULL, 0,
6224         NULL, HFILL }},
6225     { &hf_tn5250_wdsf_deg_ms_default_color,
6226       { "Color", "tn5250.wdsf_deg_ms_default_color",
6227       FT_UINT8, BASE_HEX, VALS(vals_tn5250_fa_color), 0,
6228         NULL, HFILL }},
6229     { &hf_tn5250_wdsf_deg_ms_line_repeat,
6230       { "Line Repeat", "tn5250.wdsf_deg_ms_line_repeat",
6231       FT_UINT8, BASE_DEC, NULL, 0,
6232         NULL, HFILL }},
6233     { &hf_tn5250_wdsf_deg_ms_line_interval,
6234       { "Line Interval", "tn5250.wdsf_deg_ms_line_interval",
6235       FT_UINT8, BASE_DEC, NULL, 0,
6236         NULL, HFILL }},
6237
6238     /* 15.7.2 Clear Grid Lines Structured Field */
6239     { &hf_tn5250_wdsf_cgl_partition,
6240       { "Partition", "tn5250.wdsf_cgl_partition",
6241       FT_UINT8, BASE_HEX, NULL, 0,
6242         NULL, HFILL }},
6243     { &hf_tn5250_wdsf_cgl_start_row,
6244       { "Start Row", "tn5250.wdsf_cgl_start_row",
6245       FT_UINT8, BASE_DEC, NULL, 0,
6246         NULL, HFILL }},
6247     { &hf_tn5250_wdsf_cgl_start_column,
6248       { "Start Column", "tn5250.wdsf_cgl_start_column",
6249       FT_UINT8, BASE_DEC, NULL, 0,
6250         NULL, HFILL }},
6251     { &hf_tn5250_wdsf_cgl_rectangle_width,
6252       { "Width of Rectangle", "tn5250.wdsf_cgl_rectangle_width",
6253       FT_UINT8, BASE_DEC, NULL, 0,
6254         NULL, HFILL }},
6255     { &hf_tn5250_wdsf_cgl_rectangle_height,
6256       { "Height of Rectangle", "tn5250.wdsf_cgl_rectangle_height",
6257       FT_UINT8, BASE_DEC, NULL, 0,
6258         NULL, HFILL }},
6259
6260     /* 15.8 WRITE ERROR CODE Command */
6261     /* 15.9 WRITE ERROR CODE TO WINDOW Command */
6262     { &hf_tn5250_wectw_start_column,
6263       { "Start Column", "tn5250.wectw_start_column",
6264       FT_UINT8, BASE_DEC, NULL, 0,
6265         NULL, HFILL }},
6266     { &hf_tn5250_wectw_end_column,
6267       { "End Column", "tn5250.wectw_end_column",
6268       FT_UINT8, BASE_DEC, NULL, 0,
6269         NULL, HFILL }},
6270
6271     /* 15.22 SAVE PARTIAL SCREEN Command */
6272     { &hf_tn5250_sps_flag1,
6273       { "Flags", "tn5250.sps_flag1",
6274       FT_UINT8, BASE_HEX, NULL, 0,
6275         NULL, HFILL }},
6276     { &hf_tn5250_sps_flag1_0,
6277       { "Bit 0", "tn5250.sps_flag1_0",
6278         FT_BOOLEAN, 8, TFS(&tn5250_field_sps_flag1_0),
6279         0x01, NULL, HFILL }},
6280     { &hf_tn5250_sps_flag1_reserved,
6281         { "Reserved", "tn5250.sps_flag1_reserved", FT_UINT8, BASE_HEX,
6282           NULL, 0xFE, NULL, HFILL }},
6283     { &hf_tn5250_sps_top_row,
6284       { "Top Row", "tn5250.sps_top_row",
6285       FT_UINT8, BASE_DEC, NULL, 0,
6286         NULL, HFILL }},
6287     { &hf_tn5250_sps_left_column,
6288       { "Left Column", "tn5250.sps_left_column",
6289       FT_UINT8, BASE_DEC, NULL, 0,
6290         NULL, HFILL }},
6291     { &hf_tn5250_sps_window_depth,
6292       { "Window Depth", "tn5250.sps_window_depth",
6293       FT_UINT8, BASE_DEC, NULL, 0,
6294         NULL, HFILL }},
6295     { &hf_tn5250_sps_window_width,
6296       { "Window Width", "tn5250.sps_window_width",
6297       FT_UINT8, BASE_DEC, NULL, 0,
6298         NULL, HFILL }},
6299
6300     /* 15.25 ROLL Command */
6301     { &hf_tn5250_roll_flag1,
6302       { "Byte 1", "tn5250.roll_flag1",
6303       FT_UINT8, BASE_HEX, NULL, 0,
6304         NULL, HFILL }},
6305     { &hf_tn5250_roll_flag1_0,
6306       { "Bit 0", "tn5250.roll_flag1_0",
6307         FT_BOOLEAN, 8, TFS(&tn5250_field_roll_flag1_0),
6308         0x01, NULL, HFILL }},
6309     { &hf_tn5250_roll_flag1_reserved,
6310         { "Reserved", "tn5250.roll_flag1_reserved", FT_UINT8, BASE_HEX,
6311           NULL, 0x06, NULL, HFILL }},
6312     { &hf_tn5250_roll_flag1_lines,
6313         { "Number of lines that the designated area is to be rolled", "tn5250.roll_flag1_lines", FT_UINT8, BASE_DEC,
6314           NULL, 0xF8, NULL, HFILL }},
6315     { &hf_tn5250_roll_top_line,
6316       { "Line number defining the top line of the area that will participate in the roll", "tn5250.roll_top_line",
6317       FT_UINT8, BASE_DEC, NULL, 0,
6318         NULL, HFILL }},
6319     { &hf_tn5250_roll_bottom_line,
6320       { "Line number defining the bottom line of the area that will participate in the roll", "tn5250.roll_bottom_line",
6321       FT_UINT8, BASE_DEC, NULL, 0,
6322         NULL, HFILL }},
6323
6324     /* 15.26.1 WRITE SINGLE STRUCTURED FIELD Command - 5250 WSC CUSTOMIZATION Command*/
6325     { &hf_tn5250_wssf_wsc_minor_type,
6326       { "Minor Structured Field Type", "tn5250.wssf_wsc_minor_type",
6327       FT_UINT8, BASE_HEX, VALS(vals_tn5250_wssf_minor_type), 0,
6328         NULL, HFILL }},
6329
6330     { &hf_tn5250_wssf_flag1,
6331       { "Byte 1", "tn5250.wssf_flag1",
6332       FT_UINT8, BASE_HEX, NULL, 0,
6333         NULL, HFILL }},
6334     { &hf_tn5250_wssf_flag2,
6335       { "Byte 2", "tn5250.wssf_flag2",
6336       FT_UINT8, BASE_HEX, NULL, 0,
6337         NULL, HFILL }},
6338     { &hf_tn5250_wssf_flag2_0,
6339       { "Bit 0", "tn5250.wssf_flag2_0",
6340         FT_BOOLEAN, 8, TFS(&tn5250_field_wssf_flag2_0),
6341         0x01, NULL, HFILL }},
6342     { &hf_tn5250_wssf_flag2_1,
6343       { "Bit 1", "tn5250.wssf_flag2_1",
6344         FT_BOOLEAN, 8, TFS(&tn5250_field_wssf_flag2_1),
6345         0x02, NULL, HFILL }},
6346     { &hf_tn5250_wssf_flag2_2,
6347       { "Bit 2", "tn5250.wssf_flag2_2",
6348         FT_BOOLEAN, 8, TFS(&tn5250_field_wssf_flag2_2),
6349         0x04, NULL, HFILL }},
6350     { &hf_tn5250_wssf_flag2_3,
6351       { "Bit 3", "tn5250.wssf_flag2_3",
6352         FT_BOOLEAN, 8, TFS(&tn5250_field_wssf_flag2_3),
6353         0x08, NULL, HFILL }},
6354     { &hf_tn5250_wssf_flag2_4,
6355       { "Bit 4", "tn5250.wssf_flag2_4",
6356         FT_BOOLEAN, 8, TFS(&tn5250_field_wssf_flag2_4),
6357         0x10, NULL, HFILL }},
6358     { &hf_tn5250_wssf_flag2_5,
6359       { "Bit 5", "tn5250.wssf_flag2_5",
6360         FT_BOOLEAN, 8, TFS(&tn5250_field_wssf_flag2_5),
6361         0x20, NULL, HFILL }},
6362     { &hf_tn5250_wssf_flag2_6,
6363       { "Bit 6", "tn5250.wssf_flag2_6",
6364         FT_BOOLEAN, 8, TFS(&tn5250_field_wssf_flag2_6),
6365         0x40, NULL, HFILL }},
6366     { &hf_tn5250_wssf_flag2_7,
6367       { "Bit 7", "tn5250.wssf_flag2_7",
6368         FT_BOOLEAN, 8, TFS(&tn5250_field_wssf_flag2_7),
6369         0x80, NULL, HFILL }},
6370
6371     /* 15.26.1 WRITE SINGLE STRUCTURED FIELD Command - 5250 WSC CUSTOMIZATION Command
6372                                                     - Keystroke Buffering Control Minor Structure*/
6373     { &hf_tn5250_wssf_kbc_flag1,
6374       { "Byte 1", "tn5250.wssf_kbc_flag1",
6375       FT_UINT8, BASE_HEX, NULL, 0,
6376         NULL, HFILL }},
6377     { &hf_tn5250_wssf_kbc_flag1_reserved,
6378         { "Reserved", "tn5250.wssf_kbc_flag1_reserved", FT_UINT8, BASE_HEX|BASE_RANGE_STRING,
6379           RVALS(vals_tn5250_reserved), 0x1F, NULL, HFILL }},
6380     { &hf_tn5250_wssf_kbc_flag1_5,
6381       { "Bit 5", "tn5250.wssf_kbc_flag1_5",
6382         FT_BOOLEAN, 8, TFS(&tn5250_field_wssf_kbc_flag1_5),
6383         0x20, NULL, HFILL }},
6384     { &hf_tn5250_wssf_kbc_flag1_6,
6385       { "Bit 6", "tn5250.wssf_kbc_flag1_6",
6386         FT_BOOLEAN, 8, TFS(&tn5250_field_wssf_kbc_flag1_6),
6387         0x40, NULL, HFILL }},
6388     { &hf_tn5250_wssf_kbc_flag1_7,
6389       { "Bit 7", "tn5250.wssf_kbc_flag1_7",
6390         FT_BOOLEAN, 8, TFS(&tn5250_field_wssf_kbc_flag1_7),
6391         0x80, NULL, HFILL }},
6392
6393     /* 15.26.1 WRITE SINGLE STRUCTURED FIELD Command - 5250 WSC CUSTOMIZATION Command
6394                                                     - Cursor Control Minor Structure*/
6395     { &hf_tn5250_wssf_cc_flag1,
6396       { "Byte 1", "tn5250.wssf_cc_flag1",
6397       FT_UINT8, BASE_HEX, NULL, 0,
6398         NULL, HFILL }},
6399     { &hf_tn5250_wssf_cc_flag1_reserved,
6400         { "Reserved", "tn5250.wssf_cc_flag1_reserved", FT_UINT8, BASE_HEX,
6401           NULL, 0x7F, NULL, HFILL }},
6402     { &hf_tn5250_wssf_cc_flag1_7,
6403       { "Bit 7", "tn5250.wssf_cc_flag1_7",
6404         FT_BOOLEAN, 8, TFS(&tn5250_field_wssf_cc_flag1_7),
6405         0x80, NULL, HFILL }},
6406
6407     /* 15.26.2 WRITE SINGLE STRUCTURED FIELD Command - IMAGE/FAX CONTROL Command */
6408     { &hf_tn5250_wssf_ifc_flag1,
6409       { "Byte 1", "tn5250.wssf_ifc_flag1",
6410       FT_UINT8, BASE_HEX, NULL, 0,
6411         NULL, HFILL }},
6412     { &hf_tn5250_wssf_ifc_flag1_0,
6413       { "Bit 0 (Cache allowed flag)", "tn5250.wssf_ifc_flag1_0",
6414         FT_BOOLEAN, 8, TFS(&tn5250_field_wssf_ifc_flag1_0),
6415         0x01, NULL, HFILL }},
6416     { &hf_tn5250_wssf_ifc_flag1_1to3,
6417         { "Bits 1-3 (Type of image/fax display)", "tn5250.wssf_ifc_flag1_1to3", FT_UINT8, BASE_HEX,
6418           VALS(tn5250_vals_tn5250_wssf_ifc_vals), 0x0E, NULL, HFILL }},
6419     { &hf_tn5250_wssf_ifc_flag1_4,
6420       { "Bit 4 (Color importance during scaling)", "tn5250.wssf_ifc_flag1_4",
6421         FT_BOOLEAN, 8, TFS(&tn5250_field_wssf_ifc_flag1_4),
6422         0x10, NULL, HFILL }},
6423     { &hf_tn5250_wssf_ifc_flag1_5,
6424       { "Bit 5 (Allow display to control scaling)", "tn5250.wssf_ifc_flag1_5",
6425         FT_BOOLEAN, 8, TFS(&tn5250_field_wssf_ifc_flag1_5),
6426         0x20, NULL, HFILL }},
6427     { &hf_tn5250_wssf_ifc_flag1_6,
6428       { "Bit 6 (Reverse image)", "tn5250.wssf_ifc_flag1_6",
6429         FT_BOOLEAN, 8, TFS(&tn5250_field_wssf_ifc_flag1_6),
6430         0x40, NULL, HFILL }},
6431     { &hf_tn5250_wssf_ifc_flag1_7,
6432       { "Bit 7 (Allow/Inhibit EasyScroll with a mouse)", "tn5250.wssf_ifc_flag1_7",
6433         FT_BOOLEAN, 8, TFS(&tn5250_field_wssf_ifc_flag1_7),
6434         0x80, NULL, HFILL }},
6435
6436     { &hf_tn5250_wssf_ifc_flag2,
6437       { "Byte 2", "tn5250.wssf_ifc_flag2",
6438       FT_UINT8, BASE_HEX, NULL, 0,
6439         NULL, HFILL }},
6440     { &hf_tn5250_wssf_ifc_flag2_0,
6441       { "Bit 0 (Duplicate Scan Lines)", "tn5250.wssf_ifc_flag2_0",
6442         FT_BOOLEAN, 8, TFS(&tn5250_field_wssf_ifc_flag2_0),
6443         0x01, NULL, HFILL }},
6444     { &hf_tn5250_wssf_ifc_flag2_1,
6445       { "Bit 1 (Allow/Inhibit Trim Magnify Scaling)", "tn5250.wssf_ifc_flag2_1",
6446         FT_BOOLEAN, 8, TFS(&tn5250_field_wssf_ifc_flag2_1),
6447         0x02, NULL, HFILL }},
6448     { &hf_tn5250_wssf_ifc_flag2_reserved,
6449         { "Reserved", "tn5250.wssf_ifc_flag2_reserved", FT_UINT8, BASE_HEX,
6450           NULL, 0x7C, NULL, HFILL }},
6451     { &hf_tn5250_wssf_ifc_flag2_7,
6452       { "Bit 7", "tn5250.wssf_ifc_flag2_7",
6453         FT_BOOLEAN, 8, TFS(&tn5250_field_wssf_ifc_flag2_7),
6454         0x80, NULL, HFILL }},
6455
6456     { &hf_tn5250_wssf_ifc_image_format,
6457       { "Image Format", "tn5250.wssf_ifc_image_format",
6458       FT_UINT16, BASE_DEC, VALS(vals_tn5250_image_format), 0,
6459         NULL, HFILL }},
6460
6461     { &hf_tn5250_wssf_ifc_viewport_location_row,
6462       { "Viewport Location (Row)", "tn5250.wssf_ifc_viewport_location_row",
6463       FT_UINT8, BASE_DEC, NULL, 0,
6464         NULL, HFILL }},
6465     { &hf_tn5250_wssf_ifc_viewport_location_col,
6466       { "Viewport Location (Column)", "tn5250.wssf_ifc_viewport_location_col",
6467       FT_UINT8, BASE_DEC, NULL, 0,
6468         NULL, HFILL }},
6469     { &hf_tn5250_wssf_ifc_viewport_size_row,
6470       { "Viewport Size (Row)", "tn5250.wssf_ifc_viewport_size_row",
6471       FT_UINT8, BASE_DEC, NULL, 0,
6472         NULL, HFILL }},
6473     { &hf_tn5250_wssf_ifc_viewport_size_col,
6474       { "Viewport Size (Column)", "tn5250.wssf_ifc_viewport_size_col",
6475       FT_UINT8, BASE_DEC, NULL, 0,
6476         NULL, HFILL }},
6477
6478     { &hf_tn5250_wssf_ifc_scaling,
6479       { "Scaling", "tn5250.wssf_ifc_scaling",
6480       FT_UINT16, BASE_HEX, VALS(vals_tn5250_wssf_ifc_scaling), 0,
6481         NULL, HFILL }},
6482
6483     { &hf_tn5250_wssf_ifc_viewimage_location_row,
6484       { "View Image Location (Vertical Percentage)", "tn5250.wssf_ifc_viewimage_location_row",
6485       FT_UINT8, BASE_DEC, NULL, 0,
6486         NULL, HFILL }},
6487     { &hf_tn5250_wssf_ifc_viewimage_location_col,
6488       { "View Image Location (Horizontal Position)", "tn5250.wssf_ifc_viewimage_location_col",
6489       FT_UINT8, BASE_DEC, NULL, 0,
6490         NULL, HFILL }},
6491
6492     { &hf_tn5250_wssf_ifc_rotation,
6493       { "Rotation (Degrees)", "tn5250.wssf_ifc_rotation",
6494       FT_UINT16, BASE_DEC, NULL, 0,
6495         NULL, HFILL }},
6496
6497     { &hf_tn5250_wssf_ifc_foreground_color,
6498       { "Foreground Color", "tn5250.wssf_ifc_foreground_color",
6499       FT_UINT8, BASE_HEX, VALS(vals_tn5250_foreground_color_attributes), 0,
6500         NULL, HFILL }},
6501
6502     { &hf_tn5250_wssf_ifc_background_color,
6503       { "Background Color", "tn5250.wssf_ifc_background_color",
6504       FT_UINT8, BASE_HEX, VALS(vals_tn5250_foreground_color_attributes), 0,
6505         NULL, HFILL }},
6506
6507     { &hf_tn5250_wssf_ifc_imagefax_name,
6508       { "Image/Fax Name", "tn5250.wssf_ifc_imagefax_name",
6509       FT_EBCDIC, BASE_NONE, NULL, 0,
6510         NULL, HFILL }},
6511
6512     /* 15.26.3 WRITE SINGLE STRUCTURED FIELD Command - IMAGE/FAX DOWNLOAD Command */
6513     { &hf_tn5250_wssf_ifd_flag1,
6514       { "Byte 1", "tn5250.wssf_ifd_flag1",
6515       FT_UINT8, BASE_HEX, NULL, 0,
6516         NULL, HFILL }},
6517     { &hf_tn5250_wssf_ifd_flag1_0,
6518       { "Bit 0 (Last Data Stream flag)", "tn5250.wssf_ifd_flag1_0",
6519         FT_BOOLEAN, 8, TFS(&tn5250_field_wssf_ifd_flag1_0),
6520         0x01, NULL, HFILL }},
6521     { &hf_tn5250_wssf_ifd_flag1_reserved,
6522         { "Reserved", "tn5250.wssf_ifd_flag1_reserved", FT_UINT8, BASE_HEX,
6523           NULL, 0xFE, NULL, HFILL }},
6524
6525     { &hf_tn5250_wssf_ifd_imagefax_name,
6526       { "Image/Fax Name", "tn5250.wssf_ifd_imagefax_name",
6527       FT_EBCDIC, BASE_NONE, NULL, 0,
6528         NULL, HFILL }},
6529     { &hf_tn5250_wssf_ifd_imagefax_data,
6530       { "Image/Fax Data", "tn5250.wssf_ifd_imagefax_data",
6531       FT_EBCDIC, BASE_NONE, NULL, 0,
6532         NULL, HFILL }},
6533
6534     { &hf_tn5250_image_fax_error,
6535       { "Image/Fax Error", "tn5250.image_fax_error",
6536       FT_UINT16, BASE_HEX, VALS(vals_tn5250_image_fax_error), 0,
6537         NULL, HFILL }},
6538
6539     /* 15.26.4 WRITE SINGLE STRUCTURED FIELD Command - Video/Audio Controls Command Major Structure */
6540     { &hf_tn5250_vac_prefix,
6541       { "Video/Audio Control Data Prefix", "tn5250.vac_data_prefix",
6542       FT_UINT16, BASE_HEX, NULL, 0,
6543         NULL, HFILL }},
6544     { &hf_tn5250_vac_data,
6545       { "Video/Audio Control Data", "tn5250.vac_data",
6546       FT_UINT32, BASE_HEX|BASE_RANGE_STRING, RVALS(vals_tn5250_vac_data), 0,
6547         NULL, HFILL }},
6548
6549     /* Appendix B.1 WRITE SINGLE STRUCTURED FIELD Command - True Transparency Write Command Major Structure */
6550     { &hf_tn5250_wssf_ttw_flag,
6551       { "Flag", "tn5250.wssf_ttw_flag",
6552       FT_UINT8, BASE_HEX, VALS(vals_tn5250_wssf_ttw_flag), 0,
6553         NULL, HFILL }},
6554     { &hf_tn5250_wssf_ttw_data,
6555       { "Transparent Data", "tn5250.wssf_ttw_data",
6556       FT_EBCDIC, BASE_NONE, NULL, 0,
6557         NULL, HFILL }},
6558
6559     /* 15.27 WRITE STRUCTURED FIELD (WSF) Command */
6560     /* 15.27.3 WRITE STRUCTURED FIELD (WSF) Command - 5250 QUERY STATION STATE Command*/
6561     { &hf_tn5250_wsf_qss_flag1,
6562       { "Byte 1", "tn5250.wsf_qss_flag1",
6563       FT_UINT8, BASE_HEX, NULL, 0,
6564         NULL, HFILL }},
6565     { &hf_tn5250_wsf_qss_flag1_0,
6566       { "Bit 0", "tn5250.wsf_qss_flag1_0",
6567         FT_BOOLEAN, 8, TFS(&tn5250_field_wsf_qss_flag1_0),
6568         0x01, NULL, HFILL }},
6569     { &hf_tn5250_wsf_qss_flag1_reserved,
6570         { "Reserved", "tn5250.wsf_qss_flag1_reserved", FT_UINT8, BASE_HEX,
6571           NULL, 0xFE, NULL, HFILL }},
6572     { &hf_tn5250_wsf_qss_flag2,
6573       { "Byte 2", "tn5250.wsf_qss_flag2",
6574       FT_UINT8, BASE_HEX, NULL, 0,
6575         NULL, HFILL }},
6576     { &hf_tn5250_wsf_qss_flag2_reserved,
6577         { "Reserved", "tn5250.wsf_qss_flag2_reserved", FT_UINT8, BASE_HEX,
6578           NULL, 0x7F, NULL, HFILL }},
6579     { &hf_tn5250_wsf_qss_flag2_7,
6580       { "Bit 7", "tn5250.wsf_qss_flag2_7",
6581         FT_BOOLEAN, 8, TFS(&tn5250_field_wsf_qss_flag2_7),
6582         0x80, NULL, HFILL }},
6583
6584     /* 15.27.4.1 DEFINE AUDIT WINDOW TABLE Command */
6585     { &hf_tn5250_dawt_id,
6586       { "ID", "tn5250.dawt_id",
6587       FT_UINT8, BASE_HEX|BASE_RANGE_STRING, RVALS(vals_tn5250_dawt_id), 0,
6588         NULL, HFILL }},
6589     { &hf_tn5250_dawt_length,
6590       { "Length", "tn5250.dawt_length",
6591       FT_UINT8, BASE_HEX|BASE_RANGE_STRING, RVALS(vals_tn5250_dawt_length), 0,
6592         NULL, HFILL }},
6593
6594     { &hf_tn5250_dawt_char,
6595       { "Character", "tn5250.dawt_char",
6596       FT_EBCDIC, BASE_NONE, NULL, 0,
6597         NULL, HFILL }},
6598     { &hf_tn5250_dawt_message,
6599       { "Message", "tn5250.dawt_message",
6600       FT_EBCDIC, BASE_NONE, NULL, 0,
6601         NULL, HFILL }},
6602
6603     /* 15.27.4.2 DEFINE COMMAND KEY FUNCTION Command */
6604     { &hf_tn5250_dckf_id,
6605       { "ID", "tn5250.dckf_id",
6606       FT_UINT8, BASE_HEX|BASE_RANGE_STRING, RVALS(vals_tn5250_dckf_id), 0,
6607         NULL, HFILL }},
6608     { &hf_tn5250_dckf_length,
6609       { "Length", "tn5250.dckf_length",
6610       FT_UINT8, BASE_HEX|BASE_RANGE_STRING, RVALS(vals_tn5250_dckf_length), 0,
6611         NULL, HFILL }},
6612     { &hf_tn5250_dckf_key_code,
6613       { "Key Code", "tn5250.dckf_key_code",
6614       FT_UINT8, BASE_HEX|BASE_RANGE_STRING, RVALS(vals_tn5250_dckf_key_code), 0,
6615         NULL, HFILL }},
6616     { &hf_tn5250_dckf_function_code,
6617       { "Function Code", "tn5250.dckf_function_code",
6618       FT_UINT8, BASE_HEX, VALS(vals_tn5250_dckf_function_code), 0,
6619         NULL, HFILL }},
6620     { &hf_tn5250_dckf_prompt_text,
6621       { "Prompt Text", "tn5250.dckf_prompt_text",
6622       FT_EBCDIC, BASE_NONE, NULL, 0,
6623         NULL, HFILL }},
6624
6625     /* 15.27.4.3 READ TEXT SCREEN Command */
6626     { &hf_tn5250_rts_partition,
6627       { "Partition", "tn5250.rts_partition",
6628       FT_UINT8, BASE_HEX|BASE_RANGE_STRING, RVALS(vals_tn5250_rts_partition), 0,
6629         NULL, HFILL }},
6630     { &hf_tn5250_rts_flag1,
6631       { "Byte 1", "tn5250.rts_flag1",
6632       FT_UINT8, BASE_HEX, NULL, 0,
6633         NULL, HFILL }},
6634     { &hf_tn5250_rts_flag1_0,
6635       { "Bit 0 (Last Data Stream flag)", "tn5250.rts_flag1_0",
6636         FT_BOOLEAN, 8, TFS(&tn5250_field_rts_flag1_0),
6637         0x01, NULL, HFILL }},
6638     { &hf_tn5250_rts_flag1_reserved,
6639         { "Reserved", "tn5250.rts_flag1_reserved", FT_UINT8, BASE_HEX,
6640           NULL, 0xFE, NULL, HFILL }},
6641
6642     /* 15.27.4.4 DEFINE PENDING OPERATIONS Command */
6643     { &hf_tn5250_dpo_partition,
6644       { "Partition", "tn5250.dpo_partition",
6645       FT_UINT8, BASE_HEX|BASE_RANGE_STRING, RVALS(vals_tn5250_rts_partition), 0,
6646         NULL, HFILL }},
6647     { &hf_tn5250_dpo_flag1,
6648       { "Byte 1", "tn5250.dpo_flag1",
6649       FT_UINT8, BASE_HEX, NULL, 0,
6650         NULL, HFILL }},
6651     { &hf_tn5250_dpo_flag1_0,
6652       { "Bit 0", "tn5250.dpo_flag1_0",
6653         FT_BOOLEAN, 8, TFS(&tn5250_field_dpo_flag1_0),
6654         0x01, NULL, HFILL }},
6655     { &hf_tn5250_dpo_flag1_1,
6656       { "Bit 1", "tn5250.dpo_flag1_1",
6657         FT_BOOLEAN, 8, TFS(&tn5250_field_dpo_flag1_1),
6658         0x02, NULL, HFILL }},
6659     { &hf_tn5250_dpo_flag1_2,
6660       { "Bit 2", "tn5250.dpo_flag1_2",
6661         FT_BOOLEAN, 8, TFS(&tn5250_field_dpo_flag1_2),
6662         0x04, NULL, HFILL }},
6663     { &hf_tn5250_dpo_flag1_3,
6664       { "Bit 3", "tn5250.dpo_flag1_3",
6665         FT_BOOLEAN, 8, TFS(&tn5250_field_dpo_flag1_3),
6666         0x08, NULL, HFILL }},
6667     { &hf_tn5250_dpo_flag1_4,
6668       { "Bit 4", "tn5250.dpo_flag1_4",
6669         FT_BOOLEAN, 8, TFS(&tn5250_field_dpo_flag1_4),
6670         0x10, NULL, HFILL }},
6671     { &hf_tn5250_dpo_flag1_5,
6672       { "Bit 5", "tn5250.dpo_flag1_5",
6673         FT_BOOLEAN, 8, TFS(&tn5250_field_dpo_flag1_5),
6674         0x20, NULL, HFILL }},
6675     { &hf_tn5250_dpo_flag1_6,
6676       { "Bit 6", "tn5250.dpo_flag1_6",
6677         FT_BOOLEAN, 8, TFS(&tn5250_field_dpo_flag1_6),
6678         0x40, NULL, HFILL }},
6679     { &hf_tn5250_dpo_flag1_7,
6680       { "Bit 7", "tn5250.dpo_flag1_7",
6681         FT_BOOLEAN, 8, TFS(&tn5250_field_dpo_flag1_7),
6682         0x80, NULL, HFILL }},
6683
6684     { &hf_tn5250_dpo_flag2,
6685       { "Byte 1", "tn5250.dpo_flag2",
6686       FT_UINT8, BASE_HEX, NULL, 0,
6687         NULL, HFILL }},
6688     { &hf_tn5250_dpo_flag2_0,
6689       { "Bit 0", "tn5250.dpo_flag2_0",
6690         FT_BOOLEAN, 8, TFS(&tn5250_field_dpo_flag2_0),
6691         0x01, NULL, HFILL }},
6692     { &hf_tn5250_dpo_flag2_reserved,
6693         { "Reserved", "tn5250.dpo_flag2_reserved", FT_UINT8, BASE_HEX,
6694           NULL, 0xFE, NULL, HFILL }},
6695
6696     { &hf_tn5250_dpo_displace_characters,
6697       { "Displaced Characters", "tn5250.dpo_displace_characters",
6698       FT_EBCDIC, BASE_NONE, NULL, 0,
6699         NULL, HFILL }},
6700
6701     { &hf_tn5250_dpo_start_location_row,
6702       { "Start Location (Row)", "tn5250.dpo_start_location_row",
6703       FT_UINT16, BASE_DEC, NULL, 0,
6704         NULL, HFILL }},
6705     { &hf_tn5250_dpo_start_location_col,
6706       { "Start Location (Column)", "tn5250.dpo_start_location_col",
6707       FT_UINT16, BASE_DEC, NULL, 0,
6708         NULL, HFILL }},
6709
6710     /* 15.27.4.5 DEFINE TEXT SCREEN FORMAT Command */
6711     { &hf_tn5250_dtsf_partition,
6712       { "Partition", "tn5250.dtsf_partition",
6713       FT_UINT8, BASE_HEX|BASE_RANGE_STRING, RVALS(vals_tn5250_rts_partition), 0,
6714         NULL, HFILL }},
6715     { &hf_tn5250_dtsf_flag1,
6716       { "Byte 1", "tn5250.dtsf_flag1",
6717       FT_UINT8, BASE_HEX, NULL, 0,
6718         NULL, HFILL }},
6719     { &hf_tn5250_dtsf_flag1_0,
6720       { "Bit 0", "tn5250.dtsf_flag1_0",
6721         FT_BOOLEAN, 8, TFS(&tn5250_field_dtsf_flag1_0),
6722         0x01, NULL, HFILL }},
6723     { &hf_tn5250_dtsf_flag1_1,
6724       { "Bit 1", "tn5250.dtsf_flag1_1",
6725         FT_BOOLEAN, 8, TFS(&tn5250_field_dtsf_flag1_1),
6726         0x02, NULL, HFILL }},
6727     { &hf_tn5250_dtsf_flag1_2,
6728       { "Bit 2", "tn5250.dtsf_flag1_2",
6729         FT_BOOLEAN, 8, TFS(&tn5250_field_dtsf_flag1_2),
6730         0x04, NULL, HFILL }},
6731     { &hf_tn5250_dtsf_flag1_3,
6732       { "Bit 3", "tn5250.dtsf_flag1_3",
6733         FT_BOOLEAN, 8, TFS(&tn5250_field_dtsf_flag1_3),
6734         0x08, NULL, HFILL }},
6735     { &hf_tn5250_dtsf_flag1_4,
6736       { "Bit 4", "tn5250.dtsf_flag1_4",
6737         FT_BOOLEAN, 8, TFS(&tn5250_field_dtsf_flag1_4),
6738         0x10, NULL, HFILL }},
6739     { &hf_tn5250_dtsf_flag1_5,
6740       { "Bit 5", "tn5250.dtsf_flag1_5",
6741         FT_BOOLEAN, 8, TFS(&tn5250_field_dtsf_flag1_5),
6742         0x20, NULL, HFILL }},
6743     { &hf_tn5250_dtsf_flag1_6,
6744       { "Bit 6", "tn5250.dtsf_flag1_6",
6745         FT_BOOLEAN, 8, TFS(&tn5250_field_dtsf_flag1_6),
6746         0x40, NULL, HFILL }},
6747     { &hf_tn5250_dtsf_flag1_7,
6748       { "Bit 7", "tn5250.dtsf_flag1_7",
6749         FT_BOOLEAN, 8, TFS(&tn5250_field_dtsf_flag1_7),
6750         0x80, NULL, HFILL }},
6751
6752     { &hf_tn5250_dtsf_flag2,
6753       { "Byte 1", "tn5250.dtsf_flag2",
6754       FT_UINT8, BASE_HEX, NULL, 0,
6755         NULL, HFILL }},
6756     { &hf_tn5250_dtsf_flag2_0,
6757       { "Bit 0", "tn5250.dtsf_flag2_0",
6758         FT_BOOLEAN, 8, TFS(&tn5250_field_dtsf_flag2_0),
6759         0x01, NULL, HFILL }},
6760     { &hf_tn5250_dtsf_flag2_1,
6761       { "Bit 1", "tn5250.dtsf_flag2_1",
6762         FT_BOOLEAN, 8, TFS(&tn5250_field_dtsf_flag2_1),
6763         0x02, NULL, HFILL }},
6764     { &hf_tn5250_dtsf_flag2_2,
6765       { "Bit 2", "tn5250.dtsf_flag2_2",
6766         FT_BOOLEAN, 8, TFS(&tn5250_field_dtsf_flag2_2),
6767         0x04, NULL, HFILL }},
6768     { &hf_tn5250_dtsf_flag2_3,
6769       { "Bit 3", "tn5250.dtsf_flag2_3",
6770         FT_BOOLEAN, 8, TFS(&tn5250_field_dtsf_flag2_3),
6771         0x08, NULL, HFILL }},
6772     { &hf_tn5250_dtsf_flag2_4to7,
6773       { "Bits 4 to 7", "tn5250.dtsf_flag2_4to7",
6774       FT_UINT8, BASE_HEX|BASE_RANGE_STRING, RVALS(vals_tn5250_dtsf_flag2_vals), 0xF0,
6775         NULL, HFILL }},
6776
6777     { &hf_tn5250_dtsf_text_body_height,
6778       { "Text Body Height", "tn5250.dtsf_text_body_height",
6779       FT_UINT16, BASE_DEC, NULL, 0,
6780         NULL, HFILL }},
6781     { &hf_tn5250_dtsf_text_body_width,
6782       { "Text Body Width", "tn5250.dtsf_text_body_height",
6783       FT_UINT16, BASE_DEC, NULL, 0,
6784         NULL, HFILL }},
6785
6786     { &hf_tn5250_dtsf_line_cmd_field_size,
6787       { "Line Cmd Field Size", "tn5250.dtsf_line_cmd_field_size",
6788       FT_UINT8, BASE_DEC, NULL, 0,
6789         NULL, HFILL }},
6790     { &hf_tn5250_dtsf_location_of_pitch,
6791       { "Location of Pitch", "tn5250.dtsf_location_of_pitch",
6792       FT_UINT8, BASE_DEC, NULL, 0,
6793         NULL, HFILL }},
6794     { &hf_tn5250_dtsf_first_line,
6795       { "First Line in Text Body", "tn5250.dtsf_first_line",
6796       FT_UINT8, BASE_DEC, NULL, 0,
6797         NULL, HFILL }},
6798
6799     /* 15.27.4.6 DEFINE SCALE LINE Command */
6800     { &hf_tn5250_dsl_partition,
6801       { "Partition", "tn5250.dsl_partition",
6802       FT_UINT8, BASE_HEX|BASE_RANGE_STRING, RVALS(vals_tn5250_rts_partition), 0,
6803         NULL, HFILL }},
6804     { &hf_tn5250_dsl_rtl_offset,
6805       { "RTL Offset", "tn5250.dsl_rtl_offset",
6806       FT_UINT8, BASE_DEC, NULL, 0,
6807         NULL, HFILL }},
6808     { &hf_tn5250_dsl_offset,
6809       { "Offset", "tn5250.dsl_offset",
6810       FT_UINT8, BASE_DEC, NULL, 0,
6811         NULL, HFILL }},
6812
6813     { &hf_tn5250_dsl_flag1,
6814       { "Byte 1", "tn5250.dsl_flag1",
6815       FT_UINT8, BASE_HEX, NULL, 0,
6816         NULL, HFILL }},
6817     { &hf_tn5250_dsl_flag1_0,
6818       { "Bit 0", "tn5250.dsl_flag1_0",
6819         FT_BOOLEAN, 8, TFS(&tn5250_field_dsl_flag1_0),
6820         0x01, NULL, HFILL }},
6821     { &hf_tn5250_dsl_flag1_1,
6822       { "Bit 1", "tn5250.dsl_flag1_1",
6823         FT_BOOLEAN, 8, TFS(&tn5250_field_dsl_flag1_1),
6824         0x02, NULL, HFILL }},
6825     { &hf_tn5250_dsl_flag1_2,
6826       { "Bit 2", "tn5250.dsl_flag1_2",
6827         FT_BOOLEAN, 8, TFS(&tn5250_field_dsl_flag1_2),
6828         0x04, NULL, HFILL }},
6829     { &hf_tn5250_dsl_flag1_reserved,
6830         { "Reserved", "tn5250.dsl_flag1_reserved", FT_UINT8, BASE_HEX,
6831           NULL, 0xF8, NULL, HFILL }},
6832
6833     { &hf_tn5250_dsl_id,
6834       { "ID", "tn5250.dsl_id",
6835       FT_UINT8, BASE_HEX, NULL, 0,
6836         NULL, HFILL }},
6837     { &hf_tn5250_dsl_location,
6838       { "Location", "tn5250.dsl_location",
6839       FT_UINT8, BASE_DEC, NULL, 0,
6840         NULL, HFILL }},
6841     { &hf_tn5250_dsl_function,
6842       { "Function", "tn5250.dsl_function",
6843       FT_UINT8, BASE_HEX|BASE_RANGE_STRING, RVALS(vals_tn5250_dsl_function), 0x00,
6844         NULL, HFILL }},
6845
6846     /* 15.27.4.7 WRITE TEXT SCREEN Command */
6847     { &hf_tn5250_wts_partition,
6848       { "Partition", "tn5250.wts_partition",
6849       FT_UINT8, BASE_HEX|BASE_RANGE_STRING, RVALS(vals_tn5250_rts_partition), 0,
6850         NULL, HFILL }},
6851
6852     { &hf_tn5250_wts_flag1,
6853       { "Byte 1", "tn5250.wts_flag1",
6854       FT_UINT8, BASE_HEX, NULL, 0,
6855         NULL, HFILL }},
6856     { &hf_tn5250_wts_flag1_0,
6857       { "Bit 0", "tn5250.wts_flag1_0",
6858         FT_BOOLEAN, 8, TFS(&tn5250_field_wts_flag1_0),
6859         0x01, NULL, HFILL }},
6860     { &hf_tn5250_wts_flag1_1,
6861       { "Bit 1", "tn5250.wts_flag1_1",
6862         FT_BOOLEAN, 8, TFS(&tn5250_field_wts_flag1_1),
6863         0x02, NULL, HFILL }},
6864     { &hf_tn5250_wts_flag1_2,
6865       { "Bit 2", "tn5250.wts_flag1_2",
6866         FT_BOOLEAN, 8, TFS(&tn5250_field_wts_flag1_2),
6867         0x04, NULL, HFILL }},
6868     { &hf_tn5250_wts_flag1_3,
6869       { "Bit 3", "tn5250.wts_flag1_3",
6870         FT_BOOLEAN, 8, TFS(&tn5250_field_wts_flag1_3),
6871         0x08, NULL, HFILL }},
6872     { &hf_tn5250_wts_flag1_reserved,
6873         { "Reserved", "tn5250.wts_flag1_reserved", FT_UINT8, BASE_HEX,
6874           NULL, 0xF0, NULL, HFILL }},
6875
6876     { &hf_tn5250_wts_flag2,
6877       { "Byte 2", "tn5250.wts_flag2",
6878       FT_UINT8, BASE_HEX, NULL, 0,
6879         NULL, HFILL }},
6880     { &hf_tn5250_wts_flag2_reserved,
6881         { "Reserved", "tn5250.wts_flag2_reserved", FT_UINT8, BASE_HEX,
6882           NULL, 0x1F, NULL, HFILL }},
6883     { &hf_tn5250_wts_flag2_6,
6884       { "Bit 6", "tn5250.wts_flag2_6",
6885         FT_BOOLEAN, 8, TFS(&tn5250_field_wts_flag2_6),
6886         0x20, NULL, HFILL }},
6887     { &hf_tn5250_wts_flag2_reserved2,
6888         { "Reserved", "tn5250.wts_flag2_reserved", FT_UINT8, BASE_HEX,
6889           NULL, 0xC0, NULL, HFILL }},
6890
6891     { &hf_tn5250_wts_flag3,
6892       { "Byte 3", "tn5250.wts_flag3",
6893         FT_UINT8, BASE_HEX, NULL, 0,
6894         NULL, HFILL }},
6895     { &hf_tn5250_wts_flag3_0,
6896       { "Bit 0", "tn5250.wts_flag3_0",
6897         FT_BOOLEAN, 8, TFS(&tn5250_field_wts_flag3_0),
6898         0x01, NULL, HFILL }},
6899     { &hf_tn5250_wts_flag3_1,
6900       { "Bit 1", "tn5250.wts_flag3_1",
6901         FT_BOOLEAN, 8, TFS(&tn5250_field_wts_flag3_1),
6902         0x02, NULL, HFILL }},
6903     { &hf_tn5250_wts_flag3_2,
6904       { "Bit 2", "tn5250.wts_flag3_2",
6905         FT_BOOLEAN, 8, TFS(&tn5250_field_wts_flag3_2),
6906         0x04, NULL, HFILL }},
6907     { &hf_tn5250_wts_flag3_3,
6908       { "Bit 3", "tn5250.wts_flag3_3",
6909         FT_BOOLEAN, 8, TFS(&tn5250_field_wts_flag3_3),
6910         0x08, NULL, HFILL }},
6911     { &hf_tn5250_wts_flag3_4,
6912       { "Bit 4", "tn5250.wts_flag3_4",
6913         FT_BOOLEAN, 8, TFS(&tn5250_field_wts_flag3_4),
6914         0x10, NULL, HFILL }},
6915     { &hf_tn5250_wts_flag3_5,
6916       { "Bit 5", "tn5250.wts_flag3_5",
6917         FT_BOOLEAN, 8, TFS(&tn5250_field_wts_flag3_5),
6918         0x20, NULL, HFILL }},
6919     { &hf_tn5250_wts_flag3_6,
6920       { "Bit 6", "tn5250.wts_flag3_6",
6921         FT_BOOLEAN, 8, TFS(&tn5250_field_wts_flag3_6),
6922         0x40, NULL, HFILL }},
6923     { &hf_tn5250_wts_flag3_7,
6924       { "Bit 7", "tn5250.wts_flag3_7",
6925         FT_BOOLEAN, 8, TFS(&tn5250_field_wts_flag3_7),
6926         0x80, NULL, HFILL }},
6927
6928     { &hf_tn5250_wts_home_position_row,
6929       { "Home Position (Row)", "tn5250.wts_home_position_row",
6930         FT_UINT16, BASE_DEC, NULL, 0,
6931         NULL, HFILL }},
6932     { &hf_tn5250_wts_home_position_col,
6933       { "Home Position (Column)", "tn5250.wts_home_position_col",
6934         FT_UINT16, BASE_DEC, NULL, 0,
6935         NULL, HFILL }},
6936
6937       /*  Structure of the WRITE TEXT SCREEN Command Line Data */
6938     { &hf_tn5250_wts_cld_flag1,
6939       { "Byte 1", "tn5250.wts_cld_flag1",
6940         FT_UINT8, BASE_HEX, NULL, 0,
6941         NULL, HFILL }},
6942     { &hf_tn5250_wts_cld_flag1_0,
6943       { "Bit 0", "tn5250.wts_cld_flag1_0",
6944         FT_BOOLEAN, 8, TFS(&tn5250_field_wts_cld_flag1_0),
6945         0x01, NULL, HFILL }},
6946     { &hf_tn5250_wts_cld_flag1_1,
6947       { "Bit 1", "tn5250.wts_cld_flag1_1",
6948         FT_BOOLEAN, 8, TFS(&tn5250_field_wts_cld_flag1_1),
6949         0x02, NULL, HFILL }},
6950     { &hf_tn5250_wts_cld_flag1_2,
6951       { "Bit 2", "tn5250.wts_cld_flag1_2",
6952         FT_BOOLEAN, 8, TFS(&tn5250_field_wts_cld_flag1_2),
6953         0x04, NULL, HFILL }},
6954     { &hf_tn5250_wts_cld_flag1_3,
6955       { "Bit 3", "tn5250.wts_cld_flag1_3",
6956         FT_BOOLEAN, 8, TFS(&tn5250_field_wts_cld_flag1_3),
6957         0x08, NULL, HFILL }},
6958     { &hf_tn5250_wts_cld_flag1_4,
6959       { "Bit 4", "tn5250.wts_cld_flag1_4",
6960         FT_BOOLEAN, 8, TFS(&tn5250_field_wts_cld_flag1_4),
6961         0x10, NULL, HFILL }},
6962     { &hf_tn5250_wts_cld_flag1_5,
6963       { "Bit 5", "tn5250.wts_cld_flag1_5",
6964         FT_BOOLEAN, 8, TFS(&tn5250_field_wts_cld_flag1_5),
6965         0x20, NULL, HFILL }},
6966     { &hf_tn5250_wts_cld_flag1_6,
6967       { "Bit 6", "tn5250.wts_cld_flag1_6",
6968         FT_BOOLEAN, 8, TFS(&tn5250_field_wts_cld_flag1_6),
6969         0x40, NULL, HFILL }},
6970     { &hf_tn5250_wts_cld_flag1_7,
6971       { "Bit 7", "tn5250.wts_cld_flag1_7",
6972         FT_BOOLEAN, 8, TFS(&tn5250_field_wts_cld_flag1_7),
6973         0x80, NULL, HFILL }},
6974
6975     { &hf_tn5250_wts_cld_flag2,
6976       { "Byte 2", "tn5250.wts_cld_flag2",
6977       FT_UINT8, BASE_HEX, NULL, 0,
6978         NULL, HFILL }},
6979     { &hf_tn5250_wts_cld_flag2_0,
6980       { "Bit 0", "tn5250.wts_cld_flag2_0",
6981         FT_BOOLEAN, 8, TFS(&tn5250_field_wts_cld_flag2_0),
6982         0x01, NULL, HFILL }},
6983     { &hf_tn5250_wts_cld_flag2_1,
6984       { "Bit 1", "tn5250.wts_cld_flag2_1",
6985         FT_BOOLEAN, 8, TFS(&tn5250_field_wts_cld_flag2_1),
6986         0x02, NULL, HFILL }},
6987     { &hf_tn5250_wts_cld_flag2_2,
6988       { "Bit 2", "tn5250.wts_cld_flag2_2",
6989         FT_BOOLEAN, 8, TFS(&tn5250_field_wts_cld_flag2_2),
6990         0x04, NULL, HFILL }},
6991     { &hf_tn5250_wts_cld_flag2_3,
6992       { "Bit 3", "tn5250.wts_cld_flag2_3",
6993         FT_BOOLEAN, 8, TFS(&tn5250_field_wts_cld_flag2_3),
6994         0x08, NULL, HFILL }},
6995     { &hf_tn5250_wts_cld_flag2_4,
6996       { "Bit 4", "tn5250.wts_cld_flag2_4",
6997         FT_BOOLEAN, 8, TFS(&tn5250_field_wts_cld_flag2_4),
6998         0x10, NULL, HFILL }},
6999     { &hf_tn5250_wts_cld_flag2_line_spacing,
7000         { "Line Spacing in Half-Units", "tn5250.wts_cld_flag2_line_spacing", FT_UINT8, BASE_DEC,
7001           NULL, 0xE0, NULL, HFILL }},
7002
7003     { &hf_tn5250_wts_cld_row,
7004       { "Row", "tn5250.wts_cld_row",
7005       FT_UINT16, BASE_DEC, NULL, 0,
7006         NULL, HFILL }},
7007
7008     { &hf_tn5250_wts_cld_flag3,
7009       { "Byte 3", "tn5250.wts_cld_flag3",
7010       FT_UINT8, BASE_HEX, NULL, 0,
7011         NULL, HFILL }},
7012     { &hf_tn5250_wts_cld_flag3_0,
7013       { "Bit 0", "tn5250.wts_cld_flag3_0",
7014         FT_BOOLEAN, 8, TFS(&tn5250_field_wts_cld_flag3_0),
7015         0x01, NULL, HFILL }},
7016     { &hf_tn5250_wts_cld_flag3_1,
7017       { "Bit 1", "tn5250.wts_cld_flag3_1",
7018         FT_BOOLEAN, 8, TFS(&tn5250_field_wts_cld_flag3_1),
7019         0x02, NULL, HFILL }},
7020     { &hf_tn5250_wts_cld_flag3_2,
7021       { "Bit 2", "tn5250.wts_cld_flag3_2",
7022         FT_BOOLEAN, 8, TFS(&tn5250_field_wts_cld_flag3_2),
7023         0x04, NULL, HFILL }},
7024     { &hf_tn5250_wts_cld_flag3_3,
7025       { "Bit 3", "tn5250.wts_cld_flag3_3",
7026         FT_BOOLEAN, 8, TFS(&tn5250_field_wts_cld_flag3_3),
7027         0x08, NULL, HFILL }},
7028     { &hf_tn5250_wts_cld_flag3_4,
7029       { "Bit 4", "tn5250.wts_cld_flag3_4",
7030         FT_BOOLEAN, 8, TFS(&tn5250_field_wts_cld_flag3_4),
7031         0x10, NULL, HFILL }},
7032     { &hf_tn5250_wts_cld_flag3_5,
7033       { "Bit 5", "tn5250.wts_cld_flag3_5",
7034         FT_BOOLEAN, 8, TFS(&tn5250_field_wts_cld_flag3_5),
7035         0x20, NULL, HFILL }},
7036     { &hf_tn5250_wts_cld_flag3_6,
7037       { "Bit 6", "tn5250.wts_cld_flag3_6",
7038         FT_BOOLEAN, 8, TFS(&tn5250_field_wts_cld_flag3_6),
7039         0x40, NULL, HFILL }},
7040     { &hf_tn5250_wts_cld_flag3_7,
7041       { "Bit 7", "tn5250.wts_cld_flag3_7",
7042         FT_BOOLEAN, 8, TFS(&tn5250_field_wts_cld_flag3_7),
7043         0x80, NULL, HFILL }},
7044
7045     { &hf_tn5250_wts_cld_page_num,
7046       { "Page Number", "tn5250.wts_cld_page_num",
7047       FT_UINT16, BASE_DEC, NULL, 0,
7048         NULL, HFILL }},
7049
7050     { &hf_tn5250_wts_cld_lmo,
7051       { "Left Margin Offset", "tn5250.wts_cld_lmo",
7052       FT_UINT8, BASE_DEC, NULL, 0,
7053         NULL, HFILL }},
7054     { &hf_tn5250_wts_cld_io,
7055       { "Indent Offset", "tn5250.wts_cld_io",
7056       FT_UINT8, BASE_DEC, NULL, 0,
7057         NULL, HFILL }},
7058     { &hf_tn5250_wts_cld_sli,
7059       { "Scale Line ID", "tn5250.wts_cld_sli",
7060       FT_UINT8, BASE_DEC, NULL, 0,
7061         NULL, HFILL }},
7062     { &hf_tn5250_wts_cld_li,
7063       { "Line Image", "tn5250.wts_cld_li",
7064       FT_EBCDIC, BASE_NONE, NULL, 0,
7065         NULL, HFILL }},
7066
7067     /* 15.27.4.8 DEFINE SPECIAL CHARACTERS Command */
7068     { &hf_tn5250_dsc_partition,
7069       { "Partition", "tn5250.dsc_partition",
7070       FT_UINT8, BASE_HEX|BASE_RANGE_STRING, RVALS(vals_tn5250_rts_partition), 0,
7071         NULL, HFILL }},
7072     { &hf_tn5250_dsc_sk,
7073       { "Symbol Key", "tn5250.dsc_sk",
7074       FT_UINT8, BASE_HEX, NULL, 0,
7075         NULL, HFILL }},
7076     { &hf_tn5250_dsc_ev,
7077       { "EBCDIC Value", "tn5250.dsc_ev",
7078       FT_EBCDIC, BASE_NONE, NULL, 0,
7079         NULL, HFILL }},
7080
7081     /* 15.27.4.10 DEFINE OPERATOR ERROR MESSAGES Command */
7082     { &hf_tn5250_dorm_id,
7083       { "ID", "tn5250.dorm_id",
7084       FT_UINT8, BASE_HEX|BASE_RANGE_STRING, RVALS(vals_tn5250_dorm_id), 0x00,
7085         NULL, HFILL }},
7086     { &hf_tn5250_dorm_length,
7087       { "Length", "tn5250.dorm_length",
7088       FT_UINT8, BASE_HEX|BASE_RANGE_STRING, RVALS(vals_tn5250_dorm_length), 0,
7089         NULL, HFILL }},
7090
7091     { &hf_tn5250_dorm_ec,
7092       { "Error Code", "tn5250.dorm_ec",
7093       FT_UINT16, BASE_HEX, NULL, 0,
7094         NULL, HFILL }},
7095     { &hf_tn5250_dorm_mt,
7096       { "Message Text", "tn5250.dorm_mt",
7097       FT_EBCDIC, BASE_NONE, NULL, 0,
7098         NULL, HFILL }},
7099
7100     /* 15.27.4.11 DEFINE PITCH TABLE Command */
7101     { &hf_tn5250_dpt_id,
7102       { "ID", "tn5250.dpt_id",
7103       FT_UINT8, BASE_HEX|BASE_RANGE_STRING, RVALS(vals_tn5250_dpt_id), 0x00,
7104         NULL, HFILL }},
7105     { &hf_tn5250_dpt_ec,
7106       { "EBCDIC Code", "tn5250.dpt_ec",
7107       FT_EBCDIC, BASE_NONE, NULL, 0,
7108         NULL, HFILL }},
7109
7110     /* 15.27.4.12 DEFINE FAKE DP COMMAND KEY FUNCTION Command */
7111     { &hf_tn5250_dfdpck_partition,
7112       { "Partition", "tn5250.dfdpck_partition",
7113       FT_UINT8, BASE_HEX|BASE_RANGE_STRING, RVALS(vals_tn5250_rts_partition), 0,
7114         NULL, HFILL }},
7115
7116     { &hf_tn5250_dfdpck_data_field,
7117       { "Data Field", "tn5250.dfdpck_data_field",
7118       FT_UINT8, BASE_HEX|BASE_RANGE_STRING, RVALS(vals_tn5250_dfdpck_data_field), 0,
7119         NULL, HFILL }},
7120
7121       /* Structure of the DEFINE FAKE DP COMMAND KEY FUNCTION Core Area Command Keys */
7122     { &hf_tn5250_dfdpck_coreflag,
7123       { "Core Area Flag", "tn5250.dfdpck_coreflag",
7124       FT_UINT8, BASE_HEX, NULL, 0,
7125         NULL, HFILL }},
7126     { &hf_tn5250_dfdpck_coreflag_0,
7127       { "Bit 0", "tn5250.dfdpck_coreflag_0",
7128         FT_BOOLEAN, 8, TFS(&tn5250_field_dfdpck_coreflag_0),
7129         0x01, NULL, HFILL }},
7130     { &hf_tn5250_dfdpck_coreflag_1,
7131       { "Bit 1", "tn5250.dfdpck_coreflag_1",
7132         FT_BOOLEAN, 8, TFS(&tn5250_field_dfdpck_coreflag_1),
7133         0x02, NULL, HFILL }},
7134     { &hf_tn5250_dfdpck_coreflag_2,
7135       { "Bit 2", "tn5250.dfdpck_coreflag_2",
7136         FT_BOOLEAN, 8, TFS(&tn5250_field_dfdpck_coreflag_2),
7137         0x04, NULL, HFILL }},
7138     { &hf_tn5250_dfdpck_coreflag_3,
7139       { "Bit 3", "tn5250.dfdpck_coreflag_3",
7140         FT_BOOLEAN, 8, TFS(&tn5250_field_dfdpck_coreflag_3),
7141         0x08, NULL, HFILL }},
7142     { &hf_tn5250_dfdpck_coreflag_4,
7143       { "Bit 4", "tn5250.dfdpck_coreflag_4",
7144         FT_BOOLEAN, 8, TFS(&tn5250_field_dfdpck_coreflag_4),
7145         0x10, NULL, HFILL }},
7146     { &hf_tn5250_dfdpck_coreflag_5,
7147       { "Bit 5", "tn5250.dfdpck_coreflag_5",
7148         FT_BOOLEAN, 8, TFS(&tn5250_field_dfdpck_coreflag_5),
7149         0x20, NULL, HFILL }},
7150     { &hf_tn5250_dfdpck_coreflag_6,
7151       { "Bit 6", "tn5250.dfdpck_coreflag_6",
7152         FT_BOOLEAN, 8, TFS(&tn5250_field_dfdpck_coreflag_6),
7153         0x40, NULL, HFILL }},
7154     { &hf_tn5250_dfdpck_coreflag_7,
7155       { "Bit 7", "tn5250.dfdpck_coreflag_7",
7156         FT_BOOLEAN, 8, TFS(&tn5250_field_dfdpck_coreflag_7),
7157         0x80, NULL, HFILL }},
7158
7159     /* Structure of the DEFINE FAKE DP COMMAND KEY FUNCTION Top Row Command Keys */
7160
7161     { &hf_tn5250_dfdpck_toprowflag1,
7162       { "Top Row Flags", "tn5250.dfdpck_toprowflag1",
7163       FT_UINT8, BASE_HEX, NULL, 0,
7164         NULL, HFILL }},
7165     { &hf_tn5250_dfdpck_toprowflag1_0,
7166       { "Bit 0", "tn5250.dfdpck_toprowflag1_0",
7167         FT_BOOLEAN, 8, TFS(&tn5250_field_dfdpck_toprowflag1_0),
7168         0x01, NULL, HFILL }},
7169     { &hf_tn5250_dfdpck_toprowflag1_1,
7170       { "Bit 1", "tn5250.dfdpck_toprowflag1_1",
7171         FT_BOOLEAN, 8, TFS(&tn5250_field_dfdpck_toprowflag1_1),
7172         0x02, NULL, HFILL }},
7173     { &hf_tn5250_dfdpck_toprowflag1_2,
7174       { "Bit 2", "tn5250.dfdpck_toprowflag1_2",
7175         FT_BOOLEAN, 8, TFS(&tn5250_field_dfdpck_toprowflag1_2),
7176         0x04, NULL, HFILL }},
7177     { &hf_tn5250_dfdpck_toprowflag1_3,
7178       { "Bit 3", "tn5250.dfdpck_toprowflag1_3",
7179         FT_BOOLEAN, 8, TFS(&tn5250_field_dfdpck_toprowflag1_3),
7180         0x08, NULL, HFILL }},
7181     { &hf_tn5250_dfdpck_toprowflag1_4,
7182       { "Bit 4", "tn5250.dfdpck_toprowflag1_4",
7183         FT_BOOLEAN, 8, TFS(&tn5250_field_dfdpck_toprowflag1_4),
7184         0x10, NULL, HFILL }},
7185     { &hf_tn5250_dfdpck_toprowflag1_5,
7186       { "Bit 5", "tn5250.dfdpck_toprowflag1_5",
7187         FT_BOOLEAN, 8, TFS(&tn5250_field_dfdpck_toprowflag1_5),
7188         0x20, NULL, HFILL }},
7189     { &hf_tn5250_dfdpck_toprowflag1_6,
7190       { "Bit 6", "tn5250.dfdpck_toprowflag1_6",
7191         FT_BOOLEAN, 8, TFS(&tn5250_field_dfdpck_toprowflag1_6),
7192         0x40, NULL, HFILL }},
7193     { &hf_tn5250_dfdpck_toprowflag1_7,
7194       { "Bit 7", "tn5250.dfdpck_toprowflag1_7",
7195         FT_BOOLEAN, 8, TFS(&tn5250_field_dfdpck_toprowflag1_7),
7196         0x80, NULL, HFILL }},
7197
7198     { &hf_tn5250_dfdpck_toprowflag2,
7199       { "Top Row Flags", "tn5250.dfdpck_toprowflag2",
7200       FT_UINT8, BASE_HEX, NULL, 0,
7201         NULL, HFILL }},
7202     { &hf_tn5250_dfdpck_toprowflag2_0,
7203       { "Bit 0", "tn5250.dfdpck_toprowflag2_0",
7204         FT_BOOLEAN, 8, TFS(&tn5250_field_dfdpck_toprowflag2_0),
7205         0x01, NULL, HFILL }},
7206     { &hf_tn5250_dfdpck_toprowflag2_1,
7207       { "Bit 1", "tn5250.dfdpck_toprowflag2_1",
7208         FT_BOOLEAN, 8, TFS(&tn5250_field_dfdpck_toprowflag2_1),
7209         0x02, NULL, HFILL }},
7210     { &hf_tn5250_dfdpck_toprowflag2_2,
7211       { "Bit 2", "tn5250.dfdpck_toprowflag2_2",
7212         FT_BOOLEAN, 8, TFS(&tn5250_field_dfdpck_toprowflag2_2),
7213         0x04, NULL, HFILL }},
7214     { &hf_tn5250_dfdpck_toprowflag2_3,
7215       { "Bit 3", "tn5250.dfdpck_toprowflag2_3",
7216         FT_BOOLEAN, 8, TFS(&tn5250_field_dfdpck_toprowflag2_3),
7217         0x08, NULL, HFILL }},
7218     { &hf_tn5250_dfdpck_toprowflag2_4,
7219       { "Bit 4", "tn5250.dfdpck_toprowflag2_4",
7220         FT_BOOLEAN, 8, TFS(&tn5250_field_dfdpck_toprowflag2_4),
7221         0x10, NULL, HFILL }},
7222     { &hf_tn5250_dfdpck_toprowflag2_5,
7223       { "Bit 5", "tn5250.dfdpck_toprowflag2_5",
7224         FT_BOOLEAN, 8, TFS(&tn5250_field_dfdpck_toprowflag2_5),
7225         0x20, NULL, HFILL }},
7226     { &hf_tn5250_dfdpck_toprowflag2_6,
7227       { "Bit 6", "tn5250.dfdpck_toprowflag2_6",
7228         FT_BOOLEAN, 8, TFS(&tn5250_field_dfdpck_toprowflag2_6),
7229         0x40, NULL, HFILL }},
7230     { &hf_tn5250_dfdpck_toprowflag2_7,
7231       { "Bit 7", "tn5250.dfdpck_toprowflag2_7",
7232         FT_BOOLEAN, 8, TFS(&tn5250_field_dfdpck_toprowflag2_7),
7233         0x80, NULL, HFILL }},
7234
7235     { &hf_tn5250_dfdpck_toprowflag3,
7236       { "Top Row Flags", "tn5250.dfdpck_toprowflag3",
7237       FT_UINT8, BASE_HEX, NULL, 0,
7238         NULL, HFILL }},
7239     { &hf_tn5250_dfdpck_toprowflag3_0,
7240       { "Bit 0", "tn5250.dfdpck_toprowflag3_0",
7241         FT_BOOLEAN, 8, TFS(&tn5250_field_dfdpck_toprowflag3_0),
7242         0x01, NULL, HFILL }},
7243     { &hf_tn5250_dfdpck_toprowflag3_1,
7244       { "Bit 1", "tn5250.dfdpck_toprowflag3_1",
7245         FT_BOOLEAN, 8, TFS(&tn5250_field_dfdpck_toprowflag3_1),
7246         0x02, NULL, HFILL }},
7247     { &hf_tn5250_dfdpck_toprowflag3_2,
7248       { "Bit 2", "tn5250.dfdpck_toprowflag3_2",
7249         FT_BOOLEAN, 8, TFS(&tn5250_field_dfdpck_toprowflag3_2),
7250         0x04, NULL, HFILL }},
7251     { &hf_tn5250_dfdpck_toprowflag3_3,
7252       { "Bit 3", "tn5250.dfdpck_toprowflag3_3",
7253         FT_BOOLEAN, 8, TFS(&tn5250_field_dfdpck_toprowflag3_3),
7254         0x08, NULL, HFILL }},
7255     { &hf_tn5250_dfdpck_toprowflag3_4,
7256       { "Bit 4", "tn5250.dfdpck_toprowflag3_4",
7257         FT_BOOLEAN, 8, TFS(&tn5250_field_dfdpck_toprowflag3_4),
7258         0x10, NULL, HFILL }},
7259     { &hf_tn5250_dfdpck_toprowflag3_5,
7260       { "Bit 5", "tn5250.dfdpck_toprowflag3_5",
7261         FT_BOOLEAN, 8, TFS(&tn5250_field_dfdpck_toprowflag3_5),
7262         0x20, NULL, HFILL }},
7263     { &hf_tn5250_dfdpck_toprowflag3_6,
7264       { "Bit 6", "tn5250.dfdpck_toprowflag3_6",
7265         FT_BOOLEAN, 8, TFS(&tn5250_field_dfdpck_toprowflag3_6),
7266         0x40, NULL, HFILL }},
7267     { &hf_tn5250_dfdpck_toprowflag3_7,
7268       { "Bit 7", "tn5250.dfdpck_toprowflag3_7",
7269         FT_BOOLEAN, 8, TFS(&tn5250_field_dfdpck_toprowflag3_7),
7270         0x80, NULL, HFILL }},
7271
7272     /* 15.28 COPY-TO-PRINTER Command */
7273     { &hf_tn5250_ctp_lsid,
7274       { "Printer LSID", "tn5250.ctp_lsid",
7275       FT_UINT8, BASE_HEX, NULL, 0,
7276         NULL, HFILL }},
7277     { &hf_tn5250_ctp_mlpp,
7278       { "Max Lines Per Page", "tn5250.ctp_mlpp",
7279       FT_UINT8, BASE_DEC, NULL, 0,
7280         NULL, HFILL }},
7281
7282     /*TN5250 - RFC1205 - Query Reply Fields */
7283     { &hf_tn5250_qr_flag,
7284       { "Flag", "tn5250.qr_flag",
7285       FT_UINT8, BASE_HEX, NULL, 0,
7286         NULL, HFILL }},
7287     { &hf_tn5250_qr_flag_0,
7288       { "Bit 1", "tn5250.qr_flag_0",
7289         FT_BOOLEAN, 8, TFS(&tn5250_field_qr_flag_0),
7290         0x80, NULL, HFILL }},
7291     { &hf_tn5250_qr_flag_reserved,
7292         { "Reserved", "tn5250.qr_flag_reserved", FT_UINT8, BASE_HEX,
7293           NULL, 0x7F, NULL, HFILL }},
7294     { &hf_tn5250_qr_chc,
7295       { "Controller Hardware Class", "tn5250.qr_chc",
7296       FT_UINT16, BASE_HEX, VALS(vals_tn5250_chc), 0x0,
7297         NULL, HFILL }},
7298     { &hf_tn5250_qr_ccl,
7299       { "Controller Code Level", "tn5250.qr_ccl",
7300       FT_UINT24, BASE_HEX, NULL, 0x0,
7301         NULL, HFILL }},
7302     { &hf_tn5250_qr_dt,
7303       { "Device Type", "tn5250.qr_dt",
7304       FT_UINT8, BASE_HEX, VALS(vals_tn5250_dt), 0x0,
7305         NULL, HFILL }},
7306     { &hf_tn5250_qr_dtc,
7307       { "Device Type", "tn5250.qr_dtc",
7308       FT_EBCDIC, BASE_NONE, NULL, 0x0,
7309         NULL, HFILL }},
7310     { &hf_tn5250_qr_dm,
7311       { "Device Model", "tn5250.qr_dm",
7312       FT_EBCDIC, BASE_NONE, NULL, 0x0,
7313         NULL, HFILL }},
7314     { &hf_tn5250_qr_ki,
7315       { "Keyboard ID", "tn5250.qr_ki",
7316       FT_UINT8, BASE_HEX, VALS(vals_tn5250_qr_ki), 0x0,
7317         NULL, HFILL }},
7318     { &hf_tn5250_qr_eki,
7319       { "Extended Keyboard ID", "tn5250.qr_eki",
7320       FT_UINT8, BASE_HEX, NULL, 0x0,
7321         NULL, HFILL }},
7322     { &hf_tn5250_qr_dsn,
7323       { "Display Serial Number", "tn5250.qr_dsn",
7324       FT_UINT32, BASE_DEC, NULL, 0x0,
7325         NULL, HFILL }},
7326     { &hf_tn5250_qr_mni,
7327       { "Maximum number of input fields", "tn5250.qr_mni",
7328       FT_UINT16, BASE_DEC, NULL, 0x0,
7329         NULL, HFILL }},
7330
7331     { &hf_tn5250_qr_flag1,
7332       { "Flags", "tn5250.qr_flag1",
7333       FT_UINT8, BASE_HEX, NULL, 0,
7334         NULL, HFILL }},
7335     { &hf_tn5250_qr_flag1_0,
7336       { "Bit 0 (Reserved)", "tn5250.qr_flag1_0",
7337         FT_BOOLEAN, 8, NULL,
7338         0x80, NULL, HFILL }},
7339     { &hf_tn5250_qr_flag1_1,
7340       { "Bit 1", "tn5250.qr_flag1_1",
7341         FT_BOOLEAN, 8, TFS(&tn5250_field_qr_flag1_1),
7342         0x40, NULL, HFILL }},
7343     { &hf_tn5250_qr_flag1_2,
7344       { "Bit 2", "tn5250.qr_flag1_2",
7345         FT_BOOLEAN, 8, TFS(&tn5250_field_qr_flag1_2),
7346         0x20, NULL, HFILL }},
7347     { &hf_tn5250_qr_flag1_3,
7348       { "Bit 3", "tn5250.qr_flag1_3",
7349         FT_BOOLEAN, 8, TFS(&tn5250_field_qr_flag1_3),
7350         0x10, NULL, HFILL }},
7351     { &hf_tn5250_qr_flag1_4,
7352       { "Bit 4", "tn5250.qr_flag1_4",
7353         FT_BOOLEAN, 8, TFS(&tn5250_field_qr_flag1_4),
7354         0x08, NULL, HFILL }},
7355     { &hf_tn5250_qr_flag1_5,
7356       { "Bit 5", "tn5250.qr_flag1_5",
7357         FT_BOOLEAN, 8, TFS(&tn5250_field_qr_flag1_5),
7358         0x04, NULL, HFILL }},
7359     { &hf_tn5250_qr_flag1_6,
7360       { "Bit 6", "tn5250.qr_flag1_6",
7361         FT_BOOLEAN, 8, TFS(&tn5250_field_qr_flag1_6),
7362         0x02, NULL, HFILL }},
7363     { &hf_tn5250_qr_flag1_7,
7364       { "Bit 7", "tn5250.qr_flag1_7",
7365         FT_BOOLEAN, 8, TFS(&tn5250_field_qr_flag1_7),
7366         0x01, NULL, HFILL }},
7367
7368     { &hf_tn5250_qr_flag2,
7369       { "Flags", "tn5250.qr_flag2",
7370       FT_UINT8, BASE_HEX, NULL, 0,
7371         NULL, HFILL }},
7372     { &hf_tn5250_qr_flag2_0to3,
7373         { "Bits 0 to 3", "tn5250.qr_flag2_0to3",  FT_UINT8, BASE_HEX,
7374           VALS(vals_tn5250_qr_flag2_0to3), 0xF0, NULL, HFILL }},
7375     { &hf_tn5250_qr_flag2_4,
7376       { "Bit 4", "tn5250.qr_flag2_4",
7377         FT_BOOLEAN, 8, TFS(&tn5250_field_qr_flag2_4),
7378         0x08, NULL, HFILL }},
7379     { &hf_tn5250_qr_flag2_5,
7380       { "Bit 5", "tn5250.qr_flag2_5",
7381         FT_BOOLEAN, 8, TFS(&tn5250_field_qr_flag2_5),
7382         0x04, NULL, HFILL }},
7383     { &hf_tn5250_qr_flag2_6to7,
7384         { "Bits 6 to 7", "tn5250.qr_flag2_6to7",  FT_UINT8, BASE_HEX,
7385           VALS(vals_tn5250_qr_flag2_6to7), 0x03, NULL, HFILL }},
7386
7387     { &hf_tn5250_qr_flag3,
7388       { "Flags", "tn5250.qr_flag3",
7389       FT_UINT8, BASE_HEX, VALS(vals_tn5250_qr_flag3), 0,
7390         NULL, HFILL }},
7391     { &hf_tn5250_qr_flag4,
7392       { "Flags", "tn5250.qr_flag4",
7393       FT_UINT8, BASE_HEX, VALS(vals_tn5250_qr_flag4), 0,
7394         NULL, HFILL }},
7395
7396
7397     /* Order Code */
7398     { &hf_tn5250_order_code, { "Order Code", "tn5250.order_code",
7399       FT_UINT8, BASE_HEX, VALS(vals_tn5250_order_codes), 0x0, NULL, HFILL }},
7400     { &hf_tn5250_attribute_type, { "Attribute Type", "tn5250.attribute",
7401       FT_UINT8, BASE_HEX, VALS(vals_tn5250_attributes), 0x0, NULL, HFILL }},
7402     { &hf_tn5250_aid, {  "Attention Identification", "tn5250.aid",
7403       FT_UINT8, BASE_HEX|BASE_RANGE_STRING,
7404       RVALS(vals_tn5250_attention_identification_bytes), 0x0, NULL, HFILL }},
7405
7406     /* Miscellaneous Fields */
7407     { &hf_tn5250_buffer_x, {  "Row Address", "tn5250.buffer_x",
7408             FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7409     { &hf_tn5250_buffer_y, {  "Column Address", "tn5250.buffer_y",
7410             FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7411     { &hf_tn5250_length, {  "Length", "tn5250.length",
7412             FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7413     { &hf_tn5250_length_twobyte, {  "Length", "tn5250.length",
7414             FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7415     { &hf_tn5250_field_data,
7416         {  "Field Data", "tn5250.field_data", FT_EBCDIC, BASE_NONE, NULL, 0x0,
7417             NULL, HFILL }},
7418     { &hf_tn5250_reserved, {  "Flags (Reserved):", "tn5250.reserved",
7419             FT_UINT8, BASE_HEX|BASE_RANGE_STRING, RVALS(vals_tn5250_reserved), 0,
7420             NULL, HFILL }},
7421     { &hf_tn5250_unknown_data,
7422         {  "Unknown Data (Possible Mainframe/Emulator Bug)", "tn5250.unknown_data",
7423             FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
7424
7425     /*TN5250 - RFC1205 - SNA Header Fields */
7426     { &hf_tn5250_logical_record_length,
7427       { "TN5250 Logical Record Length", "tn5250.logical_record_length",
7428       FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7429     { &hf_tn5250_sna_record_type,
7430       { "TN5250 SNA Record Type", "tn5250.sna_record_type",
7431       FT_UINT16, BASE_HEX, VALS(vals_tn5250_sna_record_type), 0x0,
7432         NULL, HFILL }},
7433     { &hf_tn5250_variable_record_length,
7434       { "TN5250 Variable Record Length", "tn5250.variable_record_length",
7435       FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7436     { &hf_tn5250_header_flags, { "TN5250 SNA Flags", "tn5250.header_flags",
7437       FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
7438     { &hf_tn5250_ds_output_error,
7439         { "Data Stream Output Error",
7440             "tn5250.ds_output_error", FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL }},
7441     { &hf_tn5250_attn_key,
7442         { "5250 attention key was pressed.",
7443             "tn5250.attn_key", FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL }},
7444     { &hf_tn5250_sys_request_key,
7445         { "5250 System Request key was pressed",
7446             "tn5250.sys_request_key", FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }},
7447     { &hf_tn5250_test_request_key,
7448         { "5250 Test Request key was pressed",
7449             "tn5250.test_request_key", FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL }},
7450     { &hf_tn5250_error_state,
7451         { "In Error State",
7452             "tn5250.error_state", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
7453     { &hf_tn5250_operation_code,
7454       { "TN5250 Operation Code",           "tn5250.operation_code",
7455       FT_UINT8, BASE_HEX, VALS(vals_tn5250_header_operation_code), 0x0,
7456         NULL, HFILL }},
7457     { &hf_tn5250_error_code,
7458       { "TN5250 Error Code",           "tn5250.error_code",
7459       FT_UINT16, BASE_HEX, VALS(vals_tn5250_header_error_codes), 0x0,
7460         NULL, HFILL }},
7461
7462     /* 13.4 SNA LU 4 and LU 7 Negative Responses */
7463     { &hf_tn5250_negative_response,
7464       { "Negative Response",           "tn5250.negative_response",
7465       FT_UINT32, BASE_HEX, VALS(vals_tn5250_negative_responses), 0x0,
7466         NULL, HFILL }},
7467
7468   };
7469
7470   static gint *ett[] = {
7471     &ett_tn5250,
7472     &ett_sf,
7473     &ett_tn5250_wcc,
7474     &ett_tn5250_field_attribute,
7475     &ett_tn5250_dfdpck_mask,
7476     &ett_tn5250_field_validation,
7477     &ett_tn5250_header_flags,
7478     &ett_tn5250_roll_mask,
7479     &ett_tn5250_soh_mask,
7480     &ett_tn5250_soh_pf16to9_mask,
7481     &ett_tn5250_soh_pf24to17_mask,
7482     &ett_tn5250_soh_pf8to1_mask,
7483     &ett_tn5250_sps_mask,
7484     &ett_tn5250_wdsf_cw_bp_mask,
7485     &ett_tn5250_wdsf_cw_mask,
7486     &ett_tn5250_wdsf_cw_tf_mask,
7487     &ett_tn5250_wdsf_deg_mask,
7488     &ett_tn5250_wdsf_deg_ms_mask,
7489     &ett_tn5250_wdsf_ds_ci_mask,
7490     &ett_tn5250_wdsf_ds_cpda_mask,
7491     &ett_tn5250_wdsf_ds_ct_mask,
7492     &ett_tn5250_wdsf_ds_mask,
7493     &ett_tn5250_wdsf_ds_mbs_mask,
7494     &ett_tn5250_wdsf_ds_sbi_mask,
7495     &ett_tn5250_wdsf_dsb_mask,
7496     &ett_tn5250_wdsf_pmb_mask,
7497     &ett_tn5250_wdsf_ragc_mask,
7498     &ett_tn5250_wdsf_rgw_mask,
7499     &ett_tn5250_wdsf_wdf_mask,
7500     &ett_tn5250_wsf_dpo_mask,
7501     &ett_tn5250_wsf_dsl_mask,
7502     &ett_tn5250_wsf_dtsf_mask,
7503     &ett_tn5250_wsf_qss_mask,
7504     &ett_tn5250_wsf_rts_mask,
7505     &ett_tn5250_wssf_cc_mask,
7506     &ett_tn5250_wssf_ifc_mask,
7507     &ett_tn5250_wssf_ifd_mask,
7508     &ett_tn5250_wssf_kbc_mask,
7509     &ett_tn5250_wssf_mask,
7510     &ett_tn5250_wts_mask,
7511     &ett_tn5250_wea_prim_attr,
7512     &ett_tn5250_qr_mask,
7513     &ett_cc,
7514   };
7515
7516   proto_tn5250 = proto_register_protocol("TN5250 Protocol", "TN5250", "tn5250");
7517   register_dissector("tn5250", dissect_tn5250, proto_tn5250);
7518   proto_register_field_array(proto_tn5250, hf, array_length(hf));
7519   proto_register_subtree_array(ett, array_length(ett));
7520
7521 }
7522