Index: epan/dissectors/packet-telnet.c =================================================================== --- epan/dissectors/packet-telnet.c (revision 29146) +++ epan/dissectors/packet-telnet.c (working copy) @@ -155,6 +155,17 @@ (strcmp(terminaltype,"IBM-3279-4-E") == 0)) add_tn3270_conversation(pinfo, 0); + if ((strcmp(terminaltype,"IBM-5555-C01") == 0) || /* 24 x 80 Double-Byte Character Set color display */ + (strcmp(terminaltype,"IBM-5555-B01") == 0) || /* 24 x 80 Double-Byte Character Set (DBCS)*/ + (strcmp(terminaltype,"IBM-3477-FC") == 0) || /* 27 x 132 color display*/ + (strcmp(terminaltype,"IBM-3477-FG") == 0) || /* 27 x 132 monochrome display*/ + (strcmp(terminaltype,"IBM-3180-2") == 0) || /* 27 x 132 monochrome display*/ + (strcmp(terminaltype,"IBM-3179-2") == 0) || /* 24 x 80 color display*/ + (strcmp(terminaltype,"IBM-3196-A1") == 0) || /* 24 x 80 monochrome display*/ + (strcmp(terminaltype,"IBM-5292-2") == 0) || /* 24 x 80 color display*/ + (strcmp(terminaltype,"IBM-5291-1") == 0) || /* 24 x 80 monochrome display*/ + (strcmp(terminaltype,"IBM-5251-11") == 0)) /* 24 x 80 monochrome display*/ + add_tn5250_conversation(pinfo, 0); } static void @@ -1844,6 +1855,7 @@ gint offset = 0; guint len = 0; guint is_tn3270 = 0; + guint is_tn5250 = 0; if (check_col(pinfo->cinfo, COL_PROTOCOL)) col_set_str(pinfo->cinfo, COL_PROTOCOL, "TELNET"); @@ -1852,6 +1864,7 @@ col_set_str(pinfo->cinfo, COL_INFO, "Telnet Data ..."); is_tn3270 = find_tn3270_conversation(pinfo); + is_tn5250 = find_tn5250_conversation(pinfo); if (tree) { int data_len; @@ -1873,11 +1886,14 @@ */ data_len = iac_offset - offset; if (data_len > 0) { - if (is_tn3270) { - next_tvb = tvb_new_subset(tvb, offset, data_len, data_len); - call_dissector(tn3270_handle, next_tvb, pinfo, telnet_tree); - } else - telnet_add_text(telnet_tree, tvb, offset, data_len); + if (is_tn3270) { + next_tvb = tvb_new_subset(tvb, offset, data_len, data_len); + call_dissector(tn3270_handle, next_tvb, pinfo, telnet_tree); + }else if (is_tn5250) { + next_tvb = tvb_new_subset(tvb, offset, data_len, data_len); + call_dissector(tn5250_handle, next_tvb, pinfo, telnet_tree); + } else + telnet_add_text(telnet_tree, tvb, offset, data_len); } /* * Now interpret the command. @@ -1885,7 +1901,7 @@ offset = telnet_command(pinfo, telnet_tree, tvb, iac_offset); } else { /* get more data if tn3270 */ - if (is_tn3270) { + if (is_tn3270 || tn5250) { pinfo->desegment_offset = offset; pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT; return; @@ -1991,4 +2007,5 @@ telnet_handle = create_dissector_handle(dissect_telnet, proto_telnet); dissector_add("tcp.port", TCP_PORT_TELNET, telnet_handle); tn3270_handle = find_dissector("tn3270"); + tn5250_handle = find_dissector("tn5250"); } Index: epan/dissectors/packet-tn5250.c =================================================================== --- epan/dissectors/packet-tn5250.c (revision 0) +++ epan/dissectors/packet-tn5250.c (revision 0) @@ -0,0 +1,1755 @@ +/* packet-tn5250.c + * Routines for tn5250.packet dissection + * + * Reference: + * 5494 Remote Control Unit - Functions Reference + * Release 3.0 Document Number SC30-3533-03 + * + * Copyright 2009, Robert Hogan + * + * $Id: packet-tn5250.c 26356 2008-10-05 23:08:54Z wmeier $ + * + * Wireshark - Network traffic analyzer + * By Gerald Combs + * Copyright 1998 Gerald Combs + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * + * TODO: + * Check for memleaks + * + * + */ + +#include "packet-tn5250.h" + +static int proto_tn5250 = -1; + + +static gint ett_tn5250 = -1; +static gint ett_sf = -1; +static gint ett_tn5250_field_attribute = -1; + +tn5250_conv_info_t *tn5250_info_items; + +void proto_reg_handoff_tn5250(void); + +gint dissect_orders_and_data(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset); + +typedef struct hf_items { + int hf; + gint bitmask_ett; + int length; + const int **bitmask; +} hf_items; + +/* Utility Functions */ + +static gint +tn5250_add_hf_items(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset, + hf_items *fields) +{ + int start=offset; + int i; + + for (i = 0; fields[i].hf; ++i) { + if (fields[i].bitmask == 0) { + proto_tree_add_item(tn5250_tree, + fields[i].hf, + tvb, offset, + fields[i].length, + FALSE); + } else { + proto_tree_add_bitmask(tn5250_tree, tvb, offset, fields[i].hf, + fields[i].bitmask_ett, fields[i].bitmask, FALSE); + } + offset+=fields[i].length; + } + return (offset - start); +} + +static gint +dissect_unknown_data(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset, gint start, + gint sf_length) +{ + int len_left; + + len_left = sf_length - (offset - start); + + if (len_left > 0) { + proto_tree_add_item(tn5250_tree, hf_tn5250_unknown_data, + tvb, offset, len_left, + FALSE); + return len_left; + } + return 0; +} + +static gint +add_data_until_next_order_code(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset) +{ + int datalen = 0; + gint order_code = 0; + + while (tvb_offset_exists(tvb, (offset + datalen))) { + order_code = tvb_get_guint8(tvb, (offset + datalen)); + switch (order_code) { + case SF: + /*dummy*/ + case SFE: + case SA: + case MF: + case IC: + case PT: + case RA: + case EUA: + case GE: + case SBA: + goto done; + default: + datalen++; + break; + } + } + +done: + if (datalen) { + proto_tree_add_item(tn5250_tree, + hf_tn5250_field_data, + tvb, offset, + datalen, + FALSE); + } + return datalen; +} + +static gint +dissect_query_reply_resbytes(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset, + gint sf_length) +{ + int start=offset; + + + hf_items fields[] = { + { hf_tn5250_res_twobytes, 0, 2, 0 }, + { 0, 0, 0, 0 }, + }; + + + offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, + fields); + + offset += dissect_unknown_data(tn5250_tree, tvb, offset, start, sf_length); + + return (offset - start); +} + +int +dissect_wcc(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset) +{ + + static const int *wcc_fields[] = { + &hf_tn5250_wtd_ccc2_res, + &hf_tn5250_wtd_ccc2_cursor, + &hf_tn5250_wtd_ccc2_reset, + &hf_tn5250_wtd_ccc2_set, + &hf_tn5250_wtd_ccc2_unlock, + &hf_tn5250_wtd_ccc2_alarm, + &hf_tn5250_wtd_ccc2_off, + &hf_tn5250_wtd_ccc2_on, + NULL + }; + + + + proto_tree_add_item(tn5250_tree, hf_tn5250_wtd_ccc1, + tvb, offset, 1, FALSE); + offset++; + proto_tree_add_bitmask_text(tn5250_tree, tvb, offset, 1, "Write To Display Control Character (Byte 2): ", "None", + ett_tn5250_wcc, wcc_fields, TRUE, 0); + return 2; + +} + +static gint +dissect_3270_field_validation(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset) +{ + int start = offset; + + static const int *byte[] = { + &hf_tn5250_field_validation_mandatory_fill, + &hf_tn5250_field_validation_mandatory_entry, + &hf_tn5250_field_validation_trigger, + NULL + }; + + proto_tree_add_bitmask_text(tn5250_tree, tvb, 1, 1, "Field Validation: ", + "None", ett_tn5250_field_validation, byte, TRUE, 0); + + offset++; + return (offset - start); +} + + + +/* End - Utility Functions */ + + +/* Start: Handle WCC, Orders and Data */ + +static gint +dissect_stop_address(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset) +{ + int start = offset; + int is_ge; + + proto_tree_add_item(tn5250_tree, + hf_tn5250_stop_address, + tvb, offset, + 2, + FALSE); + offset++; + is_ge = tvb_get_guint8(tvb, offset); + if (is_ge != GE) { + proto_tree_add_item(tn5250_tree, + hf_tn5250_character_code, + tvb, offset, + 1, + FALSE); + offset++; + } + + return (offset - start); +} + +/* 14.6.8 Erase to Address Order */ +static gint +dissect_erase_to_address(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset) +{ + int start = offset; + int length = 0; + + dissect_row_column(tn5250_tree, tvb, offset); + + length = tvb_get_guint8(tvb, offset); + proto_tree_add_item(tn5250_tree, + hf_tn5250_length, + tvb, offset, + 1, + FALSE); + offset++; + + for (i=1; i < length; i++) { + proto_tree_add_item(tn5250_tree, + hf_tn5250_attribute, + tvb, offset, + 1, + FALSE); + offset++; + } + + return (offset - start); +} + +/* 14.6.9 Start of Header Order */ +static gint +dissect_start_of_header(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset) +{ + int start = offset; + int length = 0; + + length = tvb_get_guint8(tvb, offset); + + /*TODO: Warn on invalid length. <= 7 */ + static const int *byte[] = { + &hf_tn5250_soh_cursor_direction, + &hf_tn5250_soh_screen_reverse, + &hf_tn5250_soh_input_capable_only, + NULL + }; + + static const int *byte1[] = { + &hf_tn5250_soh_pf24, &hf_tn5250_soh_pf23, &hf_tn5250_soh_pf22, + &hf_tn5250_soh_pf21, &hf_tn5250_soh_pf20, &hf_tn5250_soh_pf19, + &hf_tn5250_soh_pf18, &hf_tn5250_soh_pf17, + NULL + }; + + static const int *byte2[] = { + &hf_tn5250_soh_pf16, &hf_tn5250_soh_pf15, &hf_tn5250_soh_pf14, + &hf_tn5250_soh_pf13, &hf_tn5250_soh_pf12, &hf_tn5250_soh_pf11, + &hf_tn5250_soh_pf10, &hf_tn5250_soh_pf9, + NULL + }; + + static const int *byte3[] = { + &hf_tn5250_soh_pf8, &hf_tn5250_soh_pf7, &hf_tn5250_soh_pf6, + &hf_tn5250_soh_pf5, &hf_tn5250_soh_pf4, &hf_tn5250_soh_pf3, + &hf_tn5250_soh_pf2, &hf_tn5250_soh_pf1, + NULL + }; + + hf_items outbound_text_header_fields[] = { + { hf_tn5250_soh_length, 0, 1, 0 }, + { hf_tn5250_soh_flags, ett_tn5250_soh_mask, 1, byte }, + { hf_tn5250_resbyte, 0, 1, 0 }, + { hf_tn5250_soh_resq, 1, 1, 0 }, + { hf_tn5250_soh_err, 1, 1, 0 }, + { hf_tn5250_soh_pf24to17, ett_tn5250_soh_pf24to17_mask, 1, byte1 }, + { hf_tn5250_soh_pf16to9, ett_tn5250_soh_pf16to9_mask, 1, byte2 }, + { hf_tn5250_soh_pf8to1, ett_tn5250_soh_pf8to1_mask, 1, byte3 }, + { 0, 0, 0, 0 }, + }; + + + offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, + outbound_text_header_fields); + + offset += dissect_unknown_data(tn5250_tree, tvb, offset, start, sf_length); + + return (offset - start); +} + +/* 14.6.10 Transparent Data */ +static gint +dissect_twobyte_length_and_data(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset) +{ + int start = offset; + int length = 0; + + length = tvb_get_ntohs(tvb, offset); + proto_tree_add_item(tn5250_tree, + hf_tn5250_length_twobyte, + tvb, offset, + 2, + FALSE); + offset+=2; + + if (tvb_length_remaining(tvb, offset) >= length) { + proto_tree_add_item(tn5250_tree, + hf_tn5250_field_data, + tvb, offset, + length, + FALSE); + offset+=length; + } else { + offset += dissect_unknown_data(tn5250_tree, tvb, offset, start, length); + } + + return (offset - start); +} + +/* 14.6.11 Write Extended Attribute Order */ +static gint +dissect_field_attribute_pair(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset) +{ + int start = offset; + int attribute_type; + + static const int *byte[] = { + &hf_tn5250_wea_prim_attr_flag, &hf_tn5250_wea_prim_attr_col, + &hf_tn5250_wea_prim_attr_blink, &hf_tn5250_wea_prim_attr_und, + &hf_tn5250_wea_prim_attr_int, &hf_tn5250_wea_prim_attr_rev, + NULL + }; + + attribute_type = tvb_get_guint8(tvb, offset); + proto_tree_add_item(tn5250_tree, + hf_tn5250_attribute_type, + tvb, offset, + 1, + FALSE); + offset++; + switch (attribute_type) { + case EXTENDED_PRIMARY_ATTRIBUTES: + proto_tree_add_bitmask(tn5250_tree, tvb, offset, hf_tn5250_wea_prim_attr, + hf_tn5250_wea_prim_attr_ett, byte, FALSE); + offset++; + break; + case EXTENDED_FOREGROUND_COLOR_ATTRIBUTES: + proto_tree_add_item(tn5250_tree, + hf_tn5250_foreground_color_attr, + tvb, offset, + 1, + FALSE); + offset++; + break; + case EXTENDED_IDEOGRAPHIC_ATTRIBUTES: + proto_tree_add_item(tn5250_tree, + hf_tn5250_ideographic_attr, + tvb, offset, + 1, + FALSE); + offset++; + break; + default: + /*TODO: Add invalid data statement here*/ + break; + } + + return (offset - start); +} + +/* 14.6.12 Start of Field Order */ +static gint +dissect_start_of_field(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset) +{ + int start = offset; + int length = 0; + int done = 0; + int ffw, fa; + + static const int *byte[] = { + &hf_tn5250_ffw_id, + &hf_tn5250_ffw_bypass, + &hf_tn5250_ffw_dup, + &hf_tn5250_ffw_mdt, + &hf_tn5250_ffw_shift, + NULL + }; + + static const int *byte1[] = { + &hf_tn5250_ffw_auto, + &hf_tn5250_ffw_fer, + &hf_tn5250_ffw_monocase, + &hf_tn5250_ffw_res, + &hf_tn5250_ffw_me, + &hf_tn5250_ffw_adjust, + NULL + }; + + static const int *fabyte[] = { + &hf_tn5250_sf_attr_flag, &hf_tn5250_wea_prim_attr_col, + &hf_tn5250_wea_prim_attr_blink, &hf_tn5250_wea_prim_attr_und, + &hf_tn5250_wea_prim_attr_int, &hf_tn5250_wea_prim_attr_rev, + NULL + }; + + hf_items outbound_text_header_fields[] = { + { hf_tn5250_ffw, ett_tn5250_soh_mask, 1, byte }, + { hf_tn5250_ffw, ett_tn5250_soh_mask, 1, byte1 }, + { 0, 0, 0, 0 }, + }; + + ffw = tvb_get_guint8(tvb, offset); + + if (ffw && FFW_ID) { + offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, + outbound_text_header_fields); + while (tvb_offset_exists(tvb, offset) && !done) { + fcw = tvb_get_guint8(tvb, offset); + switch (order_code) { + case SELECTOR: + case IDEOGRAPHIC: + case FORWARD_EDGE: + case CONTINUED_ENTRY: + case SELF_CHECK: + proto_tree_add_item(tn5250_tree, hf_tn5250_fcw, tvb, offset, + 2, FALSE); + offset+=2; + break; + case ENTRY_FIELD_RESEQUENCING: + case CURSOR_PROGRESSION_ENTRY_FIELD: + case HIGHLIGHTED_ENTRY_FIELD: + case POINTER_DEVICE_SELECTION_ENTRY_FIELD: + case TRANSPARENCY_ENTRY_FIELD: + proto_tree_add_item(tn5250_tree, hf_tn5250_fcw_onebyte, tvb, offset, + 1, FALSE); + offset++; + proto_tree_add_item(tn5250_tree, hf_tn5250_fcw_nn, tvb, offset, + 1, FALSE); + offset++; + break; + default: + done = 1; + break; + } + } + } + + fa = tvb_get_guint8(tvb, offset); + + if (ffw && FA_ID) { + proto_tree_add_bitmask(tn5250_tree, tvb, offset, hf_tn5250_sf_fa, + hf_tn5250_wea_prim_attr_ett, fabyte, FALSE); + offset++; + } else { + proto_tree_add_item(tn5250_tree, hf_tn5250_fa_color, tvb, offset, + 1, FALSE); + offset++; + } + proto_tree_add_item(tn5250_tree, hf_tn5250_length_twobyte, tvb, offset, + 1, FALSE); + offset++; + + return (offset - start); +} + +/* 14.6.13 Write To Display Structured Field Order */ +static gint +dissect_start_of_field(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset) +{ + +} + +static gint +dissect_row_column(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset) +{ + int start = offset; + proto_tree_add_item(tn5250_tree, + hf_tn5250_buffer_x, + tvb, offset, + 1, + FALSE); + offset++; + proto_tree_add_item(tn5250_tree, + hf_tn5250_buffer_y, + tvb, offset, + 1, + FALSE); + offset++; + + return (offset - start); +} + + +/* 14.6 WRITE TO DISPLAY Command - Orders and Data */ +gint +dissect_orders_and_data(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset) +{ + gint start = offset; + gint order_code; + + /* Order Code */ + + while (tvb_offset_exists(tvb, offset)) { + order_code = tvb_get_guint8(tvb, offset); + proto_tree_add_item(tn5250_tree, + hf_tn5250_order_code, + tvb, offset, + 1, + FALSE); + offset++; + switch (order_code) { + case IC: + case MC: + case SBA: + offset += dissect_row_column(tn5250_tree, tvb, offset); + break; + case RA: + offset += dissect_row_column(tn5250_tree, tvb, offset); + proto_tree_add_item(tn5250_tree, hf_tn5250_repeated_character, + tvb, offset, 1, FALSE); + offset++; + break; + case EA: + offset += dissect_erase_to_address(tn5250_tree, tvb, offset); + break; + case SOH: + offset += dissect_start_of_header(tn5250_tree, tvb, offset); + break; + case TD: + offset += dissect_twobyte_length_and_data(tn5250_tree, tvb, offset); + break; + case WEA: + offset += dissect_field_attribute_pair(tn5250_tree, tvb, offset); + break; + case SF: + offset += dissect_start_of_field(tn5250_tree, tvb, offset); + break; + case WDSF: + offset += dissect_structured_field(tn5250_tree, tvb, offset); + break; + + + + case MF: + case SFE: + offset += dissect_field_attribute_pairs(tn5250_tree, tvb, offset); + break; + case SA: + offset += dissect_field_attribute_pair(tn5250_tree, tvb, offset); + break; + case EUA: + case RA: + offset += dissect_stop_address(tn5250_tree, tvb, offset); + break; + case GE: + proto_tree_add_item(tn5250_tree, + hf_tn5250_character_code, + tvb, offset, + 1, + FALSE); + offset++; + break; + case EW: + case EWA: + break; + default: + proto_tree_add_text(tn5250_tree, tvb, offset, 1, "Bogus value: %u", order_code); + offset ++; + break; + } + offset += add_data_until_next_order_code(tn5250_tree, tvb, offset); + } + offset += add_data_until_next_order_code(tn5250_tree, tvb, offset); + return (offset - start); +} + +/* End: Handle WCC, Orders and Data */ + + +static gint +dissect_tn5250_header(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset) +{ + + int start=offset; + gint data_type; + int len = 0; + + static const int *byte[] = { + &hf_tn5250_ds_output_error, + &hf_tn5250_attn_key, + &hf_tn5250_sys_request_key, + &hf_tn5250_test_request_key, + &hf_tn5250_error_state, + NULL + }; + + + hf_items fields[] = { + { hf_tn5250_logical_record_length, 0, 2, 0 }, + { hf_tn5250_sna_record_type, 0, 2, 0 }, + { hf_tn5250_resbytes, 0, 2, 0 }, + { hf_tn5250_variable_record_length, 0, 1, 0 }, + { hf_tn5250_header_flags, ett_tn5250_header_flags, 1, byte }, + { hf_tn5250_resbyte, 0, 1, 0 }, + { hf_tn5250_operation_code, 0, 1, 0 }, + { 0, 0, 0, 0 }, + }; + + error_flag = tvb_get_guint8(tvb, offset+8); + + offset += tn5250_add_hf_items(tn5250_tree, tvb, offset, + fields); + + if (error_flag & 0x02) { /*HLP*/ + proto_tree_add_item(tn5250_tree, hf_tn5250_error_code, tvb, offset, 2, FALSE); + } + + return (offset - start); +} + +/* Detect and Handle Direction of Stream */ +static gint +dissect_outbound_stream(proto_tree *tn5250_tree, tvbuff_t *tvb, gint offset) +{ + gint command_code; + gint start = offset; + + /*Escape*/ + proto_tree_add_item(tn5250_tree, + hf_tn5250_escape_code, + tvb, offset, + 1, + FALSE); + offset++; + + /* Command Code*/ + command_code = tvb_get_guint8(tvb, offset); + switch (command_code) { + case CLEAR_UNIT: + case CLEAR_FORMAT_TABLE: + proto_tree_add_item(tn5250_tree, hf_tn5250_command_code, + tvb, offset, 1, FALSE); + offset++; + case CLEAR_UNIT_ALTERNATE: + proto_tree_add_item(tn5250_tree, hf_tn5250_command_code, + tvb, offset, 1, FALSE); + offset++; + proto_tree_add_item(tn5250_tree, hf_tn5250_cua_parm, + tvb, offset, 1, FALSE); + offset++; + case WRITE_TO_DISPLAY: + /* WCC */ + offset += dissect_wcc(tn5250_tree, tvb, offset); + offset += dissect_orders_and_data(tn5250_tree, tvb, offset); + break; + case WRITE_ERROR_CODE: + case WRITE_ERROR_CODE_TO_WINDOW: + case READ_INPUT_FIELDS: + case READ_MDT_FIELDS: + case READ_MDT_ALTERNATE: + case READ_SCREEN: + case READ_SCREEN_WITH_EXTENDED_ATTRIBUTES: + case READ_SCREEN_TO_PRINT: + case READ_SCREEN_TO_PRINT_WITH_EXTENDED_ATTRIBUTES: + case READ_SCREEN_TO_PRINT_WITH_GRIDLINES: + case READ_SCREEN_TO_PRINT_WITH_EXTENDED_ATTRIBUTES_AND_GRIDLINES: + case READ_IMMEDIATE: + case READ_MODIFIED_IMMEDIATE_ALTERNATE: + case SAVE_SCREEN: + case SAVE_PARTIAL_SCREEN: + case RESTORE_SCREEN: + case RESTORE_PARTIAL_SCREEN: + case ROLL: + case WRITE_STRUCTURED_FIELD: + case WRITE_SINGLE_STRUCTURED_FIELD: + case COPY-TO-PRINTER: + + case WSF: + case SNA_WSF: + proto_tree_add_item(tn5250_tree, + hf_tn5250_command_code, + tvb, offset, + 1, + FALSE); + offset++; + offset += dissect_outbound_structured_fields(tn5250_tree, tvb, offset); + break; + default: + proto_tree_add_text(tn5250_tree, tvb, offset, 1, "Bogus value: %u", command_code); + offset ++; + break; + } + return (offset - start); + +} + +static void +dissect_tn5250(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +{ + proto_tree *tn5250_tree; + proto_item *ti; + gint offset = 0; + gint tn5250_cmd = 0; + conversation_t *conversation; + tn5250_conv_info_t *tn5250_info = NULL; + + if (check_col(pinfo->cinfo, COL_PROTOCOL)) + col_set_str(pinfo->cinfo, COL_PROTOCOL, "TN5250"); + + pinfo->fd->flags.encoding = CHAR_EBCDIC; + + /* Do we have a conversation for this connection? */ + conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst, + pinfo->ptype, pinfo->srcport, + pinfo->destport, 0); + if (conversation != NULL) { + /* Do we already have a type and mechanism? */ + tn5250_info = conversation_get_proto_data(conversation, proto_tn5250); + } + + if (!tn5250_info) + return; + + if (tree) { + ti = proto_tree_add_item(tree, proto_tn5250, tvb, offset, -1, FALSE); + tn5250_tree = proto_item_add_subtree(ti, ett_tn5250); + if (check_col(pinfo->cinfo, COL_INFO)) + col_clear(pinfo->cinfo, COL_INFO); + + offset += dissect_tn5250_header(tn5250_tree, tvb, offset); + + while (tvb_offset_exists(tvb, offset)) { + tn5250_cmd = tvb_get_guint8(tvb, offset); + if (pinfo->srcport == tn5250_info->outbound_port) { + if (check_col(pinfo->cinfo, COL_INFO)) + col_set_str(pinfo->cinfo, COL_INFO, "TN5250 Data from Mainframe"); + offset += dissect_outbound_stream(tn5250_tree, tvb, offset); + }else{ + if (check_col(pinfo->cinfo, COL_INFO)) + col_set_str(pinfo->cinfo, COL_INFO, "TN5250 Data to Mainframe"); + offset += dissect_inbound_stream(tn5250_tree, tvb, offset); + } + } + } + +} + +void +proto_register_tn5250(void) +{ + static hf_register_info hf[] = { + { &hf_tn5250_escape_code, + { "Escape Code", "tn5250.escape_code", + FT_UINT8, BASE_HEX, VALS(vals_escape_codes), 0x0, + "Escape Code", HFILL }}, + { &hf_tn5250_command_code, + { "Command Code", "tn5250.command_code", + FT_UINT8, BASE_HEX, VALS(vals_command_codes), 0x0, + "Command Code", HFILL }}, + { &hf_tn5250_sf_length, + { "Structured Field Length", "tn5250.sf_length", + FT_UINT16, BASE_DEC, NULL, 0x0, + "Structured Field Length", HFILL }}, + + /* 14.4 - Clear Unit Alternate */ + { &hf_tn5250_cua_parm, + { "TN5250 CUA Parameter", "tn5250.cua_parm", + FT_UINT16, BASE_HEX, VALS(vals_cua_parms), 0x0, + "TN5250 CUA Parameter", HFILL }}, + + /* 14.6.1 WTD Control Code */ + { &hf_tn5250_wtd_ccc1, + {"Write To Display Command Control Character Byte 1", "tn5250.wtd_ccc1", + FT_UINT8, BASE_HEX, + VALS (vals_wtd_cc_byteone), CCBITS, "", HFILL}}, + { &hf_tn5250_wtd_ccc2, + { "Write To Display Command Control Character Byte 2", "tn5250.wtd_ccc2", + FT_UINT8, BASE_HEX, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wtd_ccc2_res, + { "Reserved", + "tn5250.wtd_ccc_reserved", FT_BOOLEAN, 8, NULL, 0x01, "", HFILL }}, + { &hf_tn5250_wtd_ccc2_cursor, + { "Cursor does not move when keyboard unlocks", + "tn5250.wtd_ccc_cursor", FT_BOOLEAN, 8, NULL, 0x02, "", HFILL }}, + { &hf_tn5250_wtd_ccc2_reset, + { "Reset blinking cursor", + "tn5250.wtd_ccc_reset", FT_BOOLEAN, 8, NULL, 0x04, "", HFILL }}, + { &hf_tn5250_wtd_ccc2_set, + { "Set blinking cursor", + "tn5250.wtd_ccc_set", FT_BOOLEAN, 8, NULL, 0x08, "", HFILL }}, + { &hf_tn5250_wtd_ccc2_unlock, + { "Unlock the keyboard and reset any pending AID bytes", + "tn5250.wtd_ccc_unlock", FT_BOOLEAN, 8, NULL, 0x10, "", HFILL }}, + { &hf_tn5250_wtd_ccc2_alarm, + { "Sound Alarm", + "tn5250.wtd_ccc_alarm", FT_BOOLEAN, 8, NULL, 0x20, "", HFILL }}, + { &hf_tn5250_wtd_ccc2_off, + { "Set Message Waiting indicator off", + "tn5250.wtd_ccc_off", FT_BOOLEAN, 8, NULL, 0x40, "", HFILL }}, + { &hf_tn5250_wtd_ccc2_on, + { "Set Message Waiting indicator on", + "tn5250.wtd_ccc_on", FT_BOOLEAN, 8, NULL, 0x80, "", HFILL }}, + + + /* 14.6.7 Repeat to Address Order */ + { &hf_tn5250_repeated_character, + { "Repeated Character", "tn5250.repeated_character", + FT_EBCDIC, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + /* 14.6.9 Start of Header Order */ + + { &hf_tn5250_soh_flags, + { "Start of Header Flags", "tn5250.soh_flags", + FT_UINT8, BASE_HEX, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_soh_cursor_direction, + { "Right To Left Screen-Level Cursor Direction", "tn5250.soh_cursor_direction", + FT_BOOLEAN, 8, NULL, 0x01, + NULL, HFILL }}, + { &hf_tn5250_soh_screen_reverse, + { "Automatic local screen reverse", "tn5250.soh_screen_reverse", + FT_BOOLEAN, 8, NULL, 0x04, + NULL, HFILL }}, + { &hf_tn5250_soh_input_capable_only, + { "The cursor is allowed to move only to input-capable positions", "tn5250.soh_input_capable_only", + FT_BOOLEAN, 8, NULL, 0x08, + NULL, HFILL }}, + + { &hf_tn5250_soh_pf24to17, + { "Command Key Switch 1", "tn5250.soh_pf24to17", + FT_UINT8, BASE_HEX, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_soh_pf24, + { "PF24", "tn5250.soh_pf24", + FT_BOOLEAN, 8, NULL, 0x01, + NULL, HFILL }}, + { &hf_tn5250_soh_pf23, + { "PF22", "tn5250.soh_pf23", + FT_BOOLEAN, 8, NULL, 0x02, + NULL, HFILL }}, + { &hf_tn5250_soh_pf22, + { "PF22", "tn5250.soh_pf22", + FT_BOOLEAN, 8, NULL, 0x04, + NULL, HFILL }}, + { &hf_tn5250_soh_pf21, + { "PF21", "tn5250.soh_pf21", + FT_BOOLEAN, 8, NULL, 0x08, + NULL, HFILL }}, + { &hf_tn5250_soh_pf20, + { "PF20", "tn5250.soh_pf20", + FT_BOOLEAN, 8, NULL, 0x10, + NULL, HFILL }}, + { &hf_tn5250_soh_pf19, + { "PF19", "tn5250.soh_pf19", + FT_BOOLEAN, 8, NULL, 0x20, + NULL, HFILL }}, + { &hf_tn5250_soh_pf18, + { "PF18", "tn5250.soh_pf18", + FT_BOOLEAN, 8, NULL, 0x40, + NULL, HFILL }}, + { &hf_tn5250_soh_pf17, + { "PF17", "tn5250.soh_pf17", + FT_BOOLEAN, 8, NULL, 0x80, + NULL, HFILL }}, + + { &hf_tn5250_soh_pf16to9, + { "Command Key Switch 2", "tn5250.soh_pf16to9", + FT_UINT8, BASE_HEX, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_soh_pf16, + { "PF16", "tn5250.soh_pf16", + FT_BOOLEAN, 8, NULL, 0x01, + NULL, HFILL }}, + { &hf_tn5250_soh_pf15, + { "PF15", "tn5250.soh_pf15", + FT_BOOLEAN, 8, NULL, 0x02, + NULL, HFILL }}, + { &hf_tn5250_soh_pf14, + { "PF14", "tn5250.soh_pf14", + FT_BOOLEAN, 8, NULL, 0x04, + NULL, HFILL }}, + { &hf_tn5250_soh_pf13, + { "PF13", "tn5250.soh_pf13", + FT_BOOLEAN, 8, NULL, 0x08, + NULL, HFILL }}, + { &hf_tn5250_soh_pf12, + { "PF12", "tn5250.soh_pf12", + FT_BOOLEAN, 8, NULL, 0x10, + NULL, HFILL }}, + { &hf_tn5250_soh_pf11, + { "PF11", "tn5250.soh_pf11", + FT_BOOLEAN, 8, NULL, 0x20, + NULL, HFILL }}, + { &hf_tn5250_soh_pf10, + { "PF10", "tn5250.soh_pf10", + FT_BOOLEAN, 8, NULL, 0x40, + NULL, HFILL }}, + { &hf_tn5250_soh_pf9, + { "PF9", "tn5250.soh_pf9", + FT_BOOLEAN, 8, NULL, 0x80, + NULL, HFILL }}, + + { &hf_tn5250_soh_pf8to1, + { "Command Key Switch 3", "tn5250.soh_pf8to1", + FT_UINT8, BASE_HEX, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_soh_pf8, + { "PF8", "tn5250.soh_pf8", + FT_BOOLEAN, 8, NULL, 0x01, + NULL, HFILL }}, + { &hf_tn5250_soh_pf7, + { "PF7", "tn5250.soh_pf7", + FT_BOOLEAN, 8, NULL, 0x02, + NULL, HFILL }}, + { &hf_tn5250_soh_pf6, + { "PF6", "tn5250.soh_pf6", + FT_BOOLEAN, 8, NULL, 0x04, + NULL, HFILL }}, + { &hf_tn5250_soh_pf5, + { "PF5", "tn5250.soh_pf5", + FT_BOOLEAN, 8, NULL, 0x08, + NULL, HFILL }}, + { &hf_tn5250_soh_pf4, + { "PF4", "tn5250.soh_pf4", + FT_BOOLEAN, 8, NULL, 0x10, + NULL, HFILL }}, + { &hf_tn5250_soh_pf3, + { "PF3", "tn5250.soh_pf3", + FT_BOOLEAN, 8, NULL, 0x20, + NULL, HFILL }}, + { &hf_tn5250_soh_pf2, + { "PF2", "tn5250.soh_pf2", + FT_BOOLEAN, 8, NULL, 0x40, + NULL, HFILL }}, + { &hf_tn5250_soh_pf1, + { "PF1", "tn5250.soh_pf1", + FT_BOOLEAN, 8, NULL, 0x80, + NULL, HFILL }}, + + { &hf_tn5250_soh_resq, + { "Resequence to Field", "tn5250.soh_resq", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + { &hf_tn5250_err, + { "Error Row", "tn5250.soh_err", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + + /* 14.6.11.1 Write Extended Attribute Order - Extended Primary Attribute*/ + /* 14.6.12.3 Start of Field Order - Field Attribute*/ + { &hf_tn5250_wea_prim_attr, + { "Extended Primary Attributes", "tn5250.wea_prim_attr", + FT_UINT8, BASE_HEX, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wea_prim_attr_flag, + { "Attribute Change", + "tn5250.wea_prim_attr_flag", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }}, + { &hf_tn5250_wea_prim_attr_col, + { "Column Separator", + "tn5250.wea_prim_attr_col", FT_BOOLEAN, 8, TFS(&tn5250_field_attr_col), 0x08, NULL, HFILL }}, + { &hf_tn5250_wea_prim_attr_blink, + { "Blink", + "tn5250.wea_prim_attr_blink", FT_BOOLEAN, 8, TFS(&tn5250_field_attr_blink, 0x10, NULL, HFILL }}, + { &hf_tn5250_wea_prim_attr_und, + { "Underscore", + "tn5250.wea_prim_attr_und", FT_BOOLEAN, 8, TFS(&tn5250_field_attr_und), 0x20, NULL, HFILL }}, + { &hf_tn5250_wea_prim_attr_int, + { "Intensity", + "tn5250.wea_prim_attr_int", FT_BOOLEAN, 8, TFS(&tn5250_field_attr_int), 0x40, NULL, HFILL }}, + { &hf_tn5250_wea_prim_attr_rev, + { "Reverse Image", + "tn5250.wea_prim_attr_rev", FT_BOOLEAN, 8, TFS(&tn5250_field_attr_rev), 0x80, NULL, HFILL }}, + + /* 14.6.11.2 Write Extended Attribute Order - Foreground Color Attribute*/ + { &hf_tn5250_foreground_color_attr, + { "Foreground Color Attribute", "tn5250.foreground_color_attr", + FT_UINT8, BASE_HEX, VALS(vals_foreground_color_attributes), 0x0, + NULL, HFILL }}, + /* 14.6.11.3 Write Extended Attribute Order - Ideographic Attribute*/ + { &hf_tn5250_ideographic_attr, + { "Ideographic Attribute", "tn5250.ideographic_attr", + FT_UINT8, BASE_HEX, VALS(vals_ideographic_attributes), 0x0, + NULL, HFILL }}, + + /* 14.6.12 Start of Field Order - Field Format Word */ + { &hf_tn5250_ffw, + { "Field Format Word", "tn5250.ffw", + FT_UINT8, BASE_HEX, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_ffw_id, + { "Field Format Word ID", "tn5250.ffw_id", FT_UINT8, BASE_HEX, + VALS(vals_ffw_id), FFW_ID_BITS, NULL, HFILL }}, + { &hf_tn5250_ffw_bypass, + { "Bypass", "tn5250.ffw_bypass", + FT_BOOLEAN, 8, TFS(&tn5250_field_ffw_bypass), + 0x04, NULL, HFILL }}, + { &hf_tn5250_ffw_dup, + { "Dupe or Field Mark Enable", "tn5250.ffw_dup", + FT_BOOLEAN, 8, TFS(&tn5250_field_ffw_dup), + 0x08, NULL, HFILL }}, + { &hf_tn5250_ffw_mdt, + { "Modified Data Tag", "tn5250.ffw_mdt", + FT_BOOLEAN, 8, TFS(&tn5250_field_ffw_mdt), + 0x10, NULL, HFILL }}, + { &hf_tn5250_ffw_shift, + { "Field Shift/Edit Specification", "tn5250.ffw_shift", FT_UINT8, BASE_HEX, + VALS(vals_ffw_shift), FFW_SHIFT_BITS, NULL, HFILL }}, + { &hf_tn5250_ffw_auto, + { "Auto Enter", "tn5250.ffw_auto", + FT_BOOLEAN, 8, TFS(&tn5250_field_ffw_auto), + 0x01, NULL, HFILL }}, + { &hf_tn5250_ffw_fer, + { "Field Exit Required", "tn5250.ffw_fer", + FT_BOOLEAN, 8, TFS(&tn5250_field_ffw_fer), + 0x02, NULL, HFILL }}, + { &hf_tn5250_ffw_monocase, + { "Monocase", "tn5250.ffw_monocase", + FT_BOOLEAN, 8, TFS(&tn5250_field_ffw_monocase), + 0x04, NULL, HFILL }}, + { &hf_tn5250_ffw_res, + { "Reserved", "tn5250.ffw_res", + FT_BOOLEAN, 8, NULL, + 0x08, NULL, HFILL }}, + { &hf_tn5250_ffw_me, + { "Mandatory Enter", "tn5250.ffw_me", + FT_BOOLEAN, 8, TFS(&tn5250_field_ffw_me), + 0x10, NULL, HFILL }}, + { &hf_tn5250_ffw_adjust, + { "Right Adjust/Mandatory Fill", "tn5250.ffw_adjust", FT_UINT8, BASE_HEX, + VALS(vals_ffw_adjust), FFW_ADJUST_BITS, NULL, HFILL }}, + + { &hf_tn5250_fcw, + { "Field Control Word", "tn5250.fcw", + FT_UINT16, BASE_HEX, VALS(vals_fcw), 0, + NULL, HFILL }}, + { &hf_tn5250_fcw_onebyte, + { "Field Control Word", "tn5250.fcw_onebyte", + FT_UINT8, BASE_HEX, VALS(vals_fcw), 0, + NULL, HFILL }}, + { &hf_tn5250_fcw_nn, + { "Field Control Word (NN):", "tn5250.fcw_nn", + FT_UINT8, BASE_HEX, NULL, 0, + NULL, HFILL }}, + + { &hf_tn5250_fa_color, + { "Field Attribute (Color)", "tn5250.fa_color", + FT_UINT8, BASE_HEX, VALS(vals_fa_color), 0, + NULL, HFILL }}, + { &hf_tn5250_sf_fa, + { "Field Attributes", "tn5250.sf_fa", + FT_UINT8, BASE_HEX, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_sf_attr_flag, + { "Attribute ID", + "tn5250.sf_attr_flag", FT_UINT8, BASE_HEX, VALS(vals_fa_id), FA_ID_BITS, NULL, HFILL }}, + /* Use Attribute Field fields from 14.6.11.1 for rest of attribute fields */ + + /* 14.6.13 Write to Display Structured Field Order */ + { &hf_tn5250_wdsf_class, + { "Structured Field Class", "tn5250.wdsf_class", + FT_UINT8, BASE_HEX, VALS(vals_wdsf_class), 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_type, + { "Structured Field Type", "tn5250.wdsf_type", + FT_UINT8, BASE_HEX, VALS(vals_wdsf_type), 0, + NULL, HFILL }}, + + /* 14.6.13.1 Write to Display Structured Field Order - Create Window */ + { &hf_tn5250_wdsf_cw_flag1, + { "Flags", "tn5250.wdsf_cw_flag1", + FT_UINT8, BASE_HEX, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_cw_flag1_1, + { "Flag 1", "tn5250.wdsf_cw_flag1_1", + FT_BOOLEAN, 8, TFS(&tn5250_field_wdscf_cw_flag1_1), + 0x01, NULL, HFILL }}, + { &hf_tn5250_wdsf_cw_flag1_2, + { "Flag 2", "tn5250.wdsf_cw_flag1_2", + FT_BOOLEAN, 8, TFS(&tn5250_field_wdscf_cw_flag1_2), + 0x02, NULL, HFILL }}, + { &hf_tn5250_wdsf_cw_flag1_reserved, + { "Reserved", "tn5250.wdsf_cw_flag1_reserved", FT_UINT8, BASE_HEX, + NULL, 0xFC, NULL, HFILL }}, + { &hf_tn5250_wdsf_cw_wd, + { "Window Depth", "tn5250.wdsf_cw_wd", + FT_UINT8, BASE_DEC, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_cw_ww, + { "Window Width", "tn5250.wdsf_cw_ww", + FT_UINT8, BASE_DEC, NULL, 0, + NULL, HFILL }}, + + { &hf_tn5250_wdsf_cw_minor_type, + { "Minor Structured Field Type", "tn5250.wdsf_cw_minor_type", + FT_UINT8, BASE_HEX, VALS(vals_wdsf_cw_minor_type), 0, + NULL, HFILL }}, + + /* 14.6.13.1 Write to Display Structured Field Order - Create Window - Border Presentation Minor Structure */ + { &hf_tn5250_wdsf_cw_bp_flag1, + { "Flags", "tn5250.wdsf_cw_bp_flag1", + FT_UINT8, BASE_HEX, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_cw_bp_flag1_1, + { "Flag 1", "tn5250.wdscf_cw_bp_flag1_1", + FT_BOOLEAN, 8, TFS(&tn5250_field_wdscf_cw_bp_flag1_1), + 0x01, NULL, HFILL }}, + { &hf_tn5250_wdscf_cw_bp_flag1_reserved, + { "Reserved", "tn5250.wdscf_cw_bp_flag1_reserved", FT_UINT8, BASE_HEX, + NULL, 0xFE, NULL, HFILL }}, + { &hf_tn5250_wdsf_cw_bp_mba, + { "Monochrome Border Attribute", "tn5250.wdsf_cw_bp_mba", + FT_UINT8, BASE_HEX, VALS(vals_fa_color), 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_cw_bp_cba, + { "Color Border Attribute", "tn5250.wdsf_cw_bp_cba", + FT_UINT8, BASE_HEX, VALS(vals_fa_color), 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_cw_bp_ulbc, + { "Upper Left Border Character", "tn5250.wdsf_cw_bp_ulbc", + FT_EBCDIC, BASE_NONE, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_cw_bp_tbc, + { "Top Border Character", "tn5250.wdsf_cw_bp_tbc", + FT_EBCDIC, BASE_NONE, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_cw_bp_urbc, + { "Upper Right Border Character", "tn5250.wdsf_cw_bp_urbc", + FT_EBCDIC, BASE_NONE, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_cw_bp_lbc, + { "Left Border Character", "tn5250.wdsf_cw_bp_lbc", + FT_EBCDIC, BASE_NONE, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_cw_bp_rbc, + { "Right Border Character", "tn5250.wdsf_cw_bp_rbc", + FT_EBCDIC, BASE_NONE, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_cw_bp_llbc, + { "Lower Left Border Character", "tn5250.wdsf_cw_bp_llbc", + FT_EBCDIC, BASE_NONE, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_cw_bp_bbc, + { "Bottom Border Character", "tn5250.wdsf_cw_bp_bbc", + FT_EBCDIC, BASE_NONE, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_cw_bp_lrbc, + { "Lower Right Border Character", "tn5250.wdsf_cw_bp_lrbc", + FT_EBCDIC, BASE_NONE, NULL, 0, + NULL, HFILL }}, + + /* 14.6.13.1 Write to Display Structured Field Order - Create Window - Window/Title Footer Minor Structure */ + { &hf_tn5250_wdsf_cw_tf_flag, + { "Flags", "tn5250.wdsf_cw_tf_flag", + FT_UINT8, BASE_HEX, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_cw_tf_flag_orientation, + { "Orientation", "tn5250.wdsf_cw_tf_flag_orientation", FT_UINT8, BASE_HEX, + VALS(vals_wdsf_cw_tf_flag_orientation), ORIENTATION_BITS, NULL, HFILL }}, + { &hf_tn5250_wdsf_cw_tf_flag_1, + { "Title/Footer Defined", "tn5250.wdsf_cw_tf_flag_1", + FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_cw_tf_flag_1), + 0x04, NULL, HFILL }}, + { &hf_tn5250_wdscf_cw_tf_flag_reserved, + { "Reserved", "tn5250.wdscf_cw_tf_flag_reserved", FT_UINT8, BASE_HEX, + NULL, 0xF8, NULL, HFILL }}, + { &hf_tn5250_wdsf_cw_tf_mba, + { "Monochrome Title/Footer Attribute", "tn5250.wdsf_cw_tf_mba", + FT_UINT8, BASE_HEX, VALS(vals_fa_color), 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_cw_tf_cba, + { "Color Title/Footer Attribute", "tn5250.wdsf_cw_tf_cba", + FT_UINT8, BASE_HEX, VALS(vals_fa_color), 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_cw_tf_text, + { "Title Text", "tn5250.wdsf_cw_tf_text", + FT_EBCDIC, BASE_NONE, NULL, 0, + NULL, HFILL }}, + + /* 14.6.13.2 Write to Display Structured Field Order - Unrestricted Window Cursor Movement */ + /* Consists of reserved fields only */ + + /* 14.6.13.3 Write to Display Structured Field Order - Remove GUI Window */ + { &hf_tn5250_wdsf_rgw_flag, + { "Flags", "tn5250.wdsf_rgw_flag", + FT_UINT8, BASE_HEX, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_rgw_flag_1, + { "Reserved", "tn5250.wdsf_rgw_flag_1", + FT_BOOLEAN, 8, NULL, + 0x01, NULL, HFILL }}, + { &hf_tn5250_wdsf_rgw_flag_1, + { "Window Pull-Down", "tn5250.wdsf_rgw_flag_1", + FT_BOOLEAN, 8, TFS(&tn5250_field_wdscf_cw_flag1_2), + 0x02, NULL, HFILL }}, + { &hf_tn5250_wdscf_rgw_reserved, + { "Reserved", "tn5250.wdscf_rgw_flag_reserved", FT_UINT8, BASE_HEX, + NULL, 0xFC, NULL, HFILL }}, + + /* 14.6.13.4 Write to Display Structured Field Order - Remove All GUI Constructs*/ + { &hf_tn5250_wdsf_ragc_flag, + { "Flags", "tn5250.wdsf_ragc_flag", + FT_UINT8, BASE_HEX, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_ragc_flag_1, + { "GUI-Like Characters", "tn5250.wdsf_ragc_flag_1", + FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ragc_flag_1), + 0x01, NULL, HFILL }}, + { &hf_tn5250_wdscf_ragc_reserved, + { "Reserved", "tn5250.wdscf_ragc_flag_reserved", FT_UINT8, BASE_HEX, + NULL, 0xFE, NULL, HFILL }}, + + /* 14.6.13.5 Write to Display Structured Field Order - Define Selection Field*/ + { &hf_tn5250_wdsf_ds_flag1, + { "Flags", "tn5250.wdsf_ds_flag1", + FT_UINT8, BASE_HEX, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_flag1_mouse_characteristics, + { "Mouse Characteristics", "tn5250.wdsf_ds_flag1_mouse_characteristics", FT_UINT8, BASE_HEX, + VALS(vals_wdsf_ds_flag_mouse_characteristics), MOUSE_CHARACTERISTICS_BITS, NULL, HFILL }}, + { &hf_tn5250_wdscf_ds_flag1_reserved, + { "Reserved", "tn5250.wdscf_ds_flag1_reserved", FT_UINT8, BASE_HEX, + NULL, 0x0C, NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_flag1_auto_enter, + { "Mouse Characteristics", "tn5250.wdsf_ds_flag1_auto_enter", FT_UINT8, BASE_HEX, + VALS(vals_wdsf_ds_flag_auto_enter), AUTO_ENTER_BITS, NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_flag1_1, + { "Auto Select", "tn5250.wdsf_ds_flag1_1", + FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_flag1_1), + 0x40, NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_flag1_2, + { "Field MDT", "tn5250.wdsf_ds_flag1_2", + FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_flag1_2), + 0x80, NULL, HFILL }}, + + { &hf_tn5250_wdsf_ds_flag2, + { "Flags", "tn5250.wdsf_ds_flag2", + FT_UINT8, BASE_HEX, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_flag2_1, + { "Bit 0", "tn5250.wdsf_ds_flag2_1", + FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_flag2_1), + 0x01, NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_flag2_2, + { "Bit 1", "tn5250.wdsf_ds_flag2_2", + FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_flag2_2), + 0x02, NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_flag2_3, + { "Bit 2", "tn5250.wdsf_ds_flag2_3", + FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_flag2_3), + 0x04, NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_flag2_4, + { "Bit 3", "tn5250.wdsf_ds_flag2_4", + FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_flag2_4), + 0x08, NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_flag2_5, + { "Bit 4", "tn5250.wdsf_ds_flag2_5", + FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_flag2_5), + 0x10, NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_flag2_6, + { "Bit 5", "tn5250.wdsf_ds_flag2_6", + FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_flag2_6), + 0x20, NULL, HFILL }}, + { &hf_tn5250_wdscf_ds_flag2_reserved, + { "Reserved", "tn5250.wdsf_ds_flag3_reserved", FT_UINT8, BASE_HEX, + NULL, 0xC0, NULL, HFILL }}, + + { &hf_tn5250_wdsf_ds_flag3, + { "Flags", "tn5250.wdsf_ds_flag3", + FT_UINT8, BASE_HEX, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_flag3_1, + { "Bit 0", "tn5250.wdsf_ds_flag3_1", + FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_flag3_1), + 0x01, NULL, HFILL }}, + { &hf_tn5250_wdscf_ds_flag3_reserved, + { "Reserved", "tn5250.wdsf_ds_flag3_reserved", FT_UINT8, BASE_HEX, + NULL, 0xFE, NULL, HFILL }}, + + { &hf_tn5250_wdsf_ds_type, + { "Type of Selection Field", "tn5250.wdsf_ds_type", + FT_UINT8, BASE_HEX, VALS(vals_wdsf_ds_type), 0, + NULL, HFILL }}, + + { &hf_tn5250_wdsf_ds_gdc, + { "GUI Device Characteristics", "tn5250.wdsf_ds_gdc", + FT_UINT8, BASE_HEX, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_gdc_indicators, + { "Indicators", "tn5250.wdsf_ds_gdc_indicators", FT_UINT8, BASE_HEX, + VALS(vals_wdsf_ds_gdc_indicators), DS_INDICATORS_BITS, NULL, HFILL }}, + { &hf_tn5250_wdscf_ds_gdc_reserved, + { "Reserved", "tn5250.wdscf_ds_gdc_reserved", FT_BOOLEAN, 8, + NULL, 0x10, NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_gdc_selection_techniques, + { "Selection Techniques", "tn5250.wdsf_ds_selection_techniques", FT_UINT8, BASE_HEX, + VALS(vals_wdsf_ds_gdc_selection_techniques), DS_SELECTION_TECHNIQUES_BITS, NULL, HFILL }}, + + { &hf_tn5250_wdsf_ds_nws, + { "NWS With Mnemonic Underscore Characteristics", "tn5250.wdsf_ds_nws", + FT_UINT8, BASE_HEX, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_nws_indicators, + { "Indicators", "tn5250.wdsf_ds_nws_indicators", FT_UINT8, BASE_HEX, + VALS(vals_wdsf_ds_nws_indicators), DS_NWS_INDICATORS_BITS, NULL, HFILL }}, + { &hf_tn5250_wdscf_ds_nws_reserved, + { "Reserved", "tn5250.wdscf_ds_nws_reserved", FT_BOOLEAN, 8, + NULL, 0x10, NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_nws_selection_techniques, + { "Selection Techniques", "tn5250.wdsf_ds_selection_techniques", FT_UINT8, BASE_HEX, + VALS(vals_wdsf_ds_nws_selection_techniques), DS_NWS_SELECTION_TECHNIQUES_BITS, NULL, HFILL }}, + + { &hf_tn5250_wdsf_ds_nws_wout, + { "NWS Without Mnemonic Underscore Characteristics", "tn5250.wdsf_ds_nws", + FT_UINT8, BASE_HEX, NULL, 0, + NULL, HFILL }}, + /* hf_tn5250_wdsf_ds_nws_wout uses same bitfields as hf_tn5250_wdsf_ds_nws */ + + { &hf_tn5250_wdsf_ds_textsize, + { "Text Size", "tn5250.wdsf_ds_textsize", + FT_UINT8, BASE_DEC, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_rows, + { "Rows", "tn5250.wdsf_ds_rows", + FT_UINT8, BASE_DEC, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_columns, + { "Columns/Menu Bar Choices", "tn5250.wdsf_ds_columns", + FT_UINT8, BASE_DEC, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_padding, + { "Padding Between Choices", "tn5250.wdsf_ds_padding", + FT_UINT8, BASE_DEC, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_numeric_sep, + { "Numeric Separator Character", "tn5250.wdsf_ds_numeric_sep", + FT_EBCDIC, BASE_NONE, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_country_sel, + { "Country Specific Selection Character", "tn5250.wdsf_ds_country_sel", + FT_EBCDIC, BASE_NONE, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_cancel_aid, + { "Mouse Pull-Down Cancel AID", "tn5250.wdsf_ds_cancel_aid", + FT_UINT8, BASE_HEX, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_totalrows, + { "Total Rows or Minor Structures That Can Be Scrolled", "tn5250.wdsf_ds_totalrows", + FT_UINT32, BASE_DEC, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_sliderpos, + { "Slider Positions That Can Be Scrolled", "tn5250.wdsf_ds_sliderpos", + FT_UINT32, BASE_DEC, NULL, 0, + NULL, HFILL }}, + + { &hf_tn5250_wdsf_ds_minor_type, + { "Minor Structured Field Type", "tn5250.wdsf_ds_minor_type", + FT_UINT8, BASE_HEX, VALS(vals_wdsf_ds_minor_type), 0, + NULL, HFILL }}, + + /* 14.6.13.5 Write to Display Structured Field Order - Define Selection Field - Choice Text Minor Structure*/ + { &hf_tn5250_wdsf_ds_ct_flag1, + { "Flag Byte 1", "tn5250.wdsf_ds_ct_flag1", + FT_UINT8, BASE_HEX, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_ct_flag1_choice_state, + { "Choice State", "tn5250.wdsf_ds_ct_flag1_choice_state", FT_UINT8, BASE_HEX, + VALS(vals_wdsf_ds_ct_flag1_choice_state), DS_CHOICE_STATE_BITS, NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_ct_flag1_2, + { "Bit 2", "tn5250.wdsf_ds_ct_flag1_2", + FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_ct_flag1_2), + 0x04, NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_ct_flag1_3, + { "Bit 3", "tn5250.wdsf_ds_ct_flag1_3", + FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_ct_flag1_3), + 0x08, NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_ct_flag1_4, + { "Bit 4", "tn5250.wdsf_ds_ct_flag1_4", + FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_ct_flag1_4), + 0x10, NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_ct_flag1_5, + { "Bit 5", "tn5250.wdsf_ds_ct_flag1_5", + FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_ct_flag1_5), + 0x20, NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_ct_flag1_numeric_selection, + { "Numeric Selection Characters", "tn5250.wdsf_ds_ct_flag1_numeric_selection", FT_UINT8, BASE_HEX, + VALS(vals_wdsf_ds_ct_flag1_numeric_selection), DS_NUMERIC_SELECTION_BITS, NULL, HFILL }}, + + { &hf_tn5250_wdsf_ds_ct_flag2, + { "Flag Byte 2", "tn5250.wdsf_ds_ct_flag2", + FT_UINT8, BASE_HEX, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_ct_flag2_0, + { "Bit 0", "tn5250.wdsf_ds_ct_flag2_0", + FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_ct_flag2_0), + 0x01, NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_ct_flag2_1, + { "Bit 1", "tn5250.wdsf_ds_ct_flag2_1", + FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_ct_flag2_1), + 0x02, NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_ct_flag2_2, + { "Bit 2", "tn5250.wdsf_ds_ct_flag2_2", + FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_ct_flag2_2), + 0x04, NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_ct_flag2_3, + { "Bit 3", "tn5250.wdsf_ds_ct_flag2_3", + FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_ct_flag2_3), + 0x08, NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_ct_flag2_4, + { "Bit 4", "tn5250.wdsf_ds_ct_flag2_4", + FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_ct_flag2_4), + 0x10, NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_ct_flag2_5, + { "Bit 5", "tn5250.wdsf_ds_ct_flag2_5", + FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_ct_flag2_5), + 0x20, NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_ct_flag2_6, + { "Bit 6", "tn5250.wdsf_ds_ct_flag2_6", + FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_ct_flag2_6), + 0x40, NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_ct_flag2_7, + { "Bit 7", "tn5250.wdsf_ds_ct_flag2_7", + FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_ct_flag2_7), + 0x80, NULL, HFILL }}, + + { &hf_tn5250_wdsf_ds_ct_flag3, + { "Flag Byte 3", "tn5250.wdsf_ds_ct_flag3", + FT_UINT8, BASE_HEX, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_ct_flag3_0, + { "Bit 0", "tn5250.wdsf_ds_ct_flag3_0", + FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_ct_flag3_0), + 0x01, NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_ct_flag3_1, + { "Bit 1", "tn5250.wdsf_ds_ct_flag3_1", + FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_ct_flag3_1), + 0x02, NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_ct_flag3_2, + { "Bit 2", "tn5250.wdsf_ds_ct_flag3_2", + FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_ct_flag3_2), + 0x04, NULL, HFILL }}, + { &hf_tn5250_wdscf_ds_ct_flag3_reserved, + { "Reserved", "tn5250.wdscf_ds_ct_flag3_reserved", FT_UINT8, BASE_HEX, + NULL, 0xF8, NULL, HFILL }}, + + { &hf_tn5250_wdsf_ds_ct_mnemonic_offset, + { "Mnemonic Offset", "tn5250.wdsf_ds_ct_mnemonic_offset", + FT_UINT8, BASE_DEC, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_ct_aid, + { "AID", "tn5250.wdsf_ds_ct_aid", + FT_UINT8, BASE_HEX, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_ct_numeric_onebyte, + { "Numeric Characters", "tn5250.wdsf_ds_ct_numeric", + FT_UINT8, BASE_HEX, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_ct_numeric_twobyte, + { "Numeric Characters", "tn5250.wdsf_ds_ct_numeric", + FT_UINT16, BASE_HEX, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_ct_text, + { "Choice Text", "tn5250.wdsf_ds_ct_text", + FT_EBCDIC, BASE_NONE, NULL, 0, + NULL, HFILL }}, + + /* 14.6.13.5 Write to Display Structured Field Order - Define Selection Field - Menu Bar Separator Minor Structure*/ + + { &hf_tn5250_wdsf_ds_mbs_flag, + { "Flags", "tn5250.wdsf_ds_mbs_flag", + FT_UINT8, BASE_HEX, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_mbs_flag_0, + { "Bit 0", "tn5250.wdsf_ds_mbs_flag_0", + FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_mbs_flag_0), + 0x01, NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_mbs_flag_1, + { "Bit 1", "tn5250.wdsf_ds_mbs_flag_1", + FT_BOOLEAN, 8, TFS(&tn5250_field_wdsf_ds_mbs_flag_1), + 0x02, NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_mbs_flag_reserved, + { "Reserved", "tn5250.wdsf_ds_mbs_flag_reserved", FT_UINT8, BASE_HEX, + NULL, 0xF8, NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_mbs_start_column, + { "Start Column", "tn5250.wdsf_ds_mbs_start_column", + FT_UINT8, BASE_DEC, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_mbs_end_column, + { "End Column", "tn5250.wdsf_ds_mbs_end_column", + FT_UINT8, BASE_DEC, NULL, 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_mbs_monochrome_sep, + { "Monochrome Separator Emphasis", "tn5250.wdsf_ds_mbs_monochrome_sep", + FT_UINT8, BASE_HEX, VALS(vals_fa_color), 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_mbs_color_sep, + { "Color Separator Emphasis", "tn5250.wdsf_ds_mbs_color_sep", + FT_UINT8, BASE_HEX, VALS(vals_fa_color), 0, + NULL, HFILL }}, + { &hf_tn5250_wdsf_ds_mbs_sep_char, + { "Separator Character", "tn5250.wdsf_ds_mbs_sep_char", + FT_EBCDIC, BASE_NONE, NULL, 0, + NULL, HFILL }}, + + /* 14.6.13.5 Write to Display Structured Field Order - Define Selection Field - Choice Presentation Display Attributes Minor Structure*/ + + + + + + + + /* Order Code */ + { &hf_tn5250_order_code, + { "Order Code", "tn5250.order_code", + FT_UINT8, BASE_HEX, VALS(vals_order_codes), 0x0, + "Order Code", HFILL }}, + { &hf_tn5250_character_code, + { "Character Code", "tn5250.character_code", + FT_UINT8, BASE_HEX, NULL, 0x0, + "Character Code", HFILL }}, + { &hf_tn5250_stop_address, + { "Stop Address", "tn5250.stop_address", + FT_UINT16, BASE_DEC, NULL, 0x0, + "Stop Address", HFILL }}, + { &hf_tn5250_attribute_type, + { "Attribute Type", "tn5250.attribute", + FT_UINT8, BASE_HEX, VALS(vals_attributes), 0x0, + NULL, HFILL }}, + { &hf_tn5250_aid, + { "Attention Identification", "hf_tn5250_aid", + FT_UINT8, BASE_HEX, VALS(vals_attention_identification_bytes), 0x0, + "hf_tn5250_aid", HFILL }}, + + /* Miscellaneous Fields */ + { &hf_tn5250_buffer_x, + { "Row Address", "hf_tn5250_buffer_x", + FT_UINT8, BASE_HEX, NULL, 0x0, + "hf_tn5250_buffer_x", HFILL }}, + { &hf_tn5250_buffer_y, + { "Column Address", "hf_tn5250_buffer_y", + FT_UINT8, BASE_HEX, NULL, 0x0, + "hf_tn5250_buffer_y", HFILL }}, + { &hf_tn5250_length, + { "Length", "tn5250.length", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + { &hf_tn5250_length_twobyte, + { "Length", "tn5250.length", + FT_UINT16, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + { &hf_tn5250_field_data, + { "Field Data", "tn5250.field_data", + FT_EBCDIC, BASE_NONE, NULL, 0x0, + "tn5250.field_data", HFILL }}, + { &hf_tn5250_resbyte, + { "Flags (Reserved):", "tn5250.resbyte", + FT_UINT8, BASE_HEX, NULL, 0x0, + "Flags (Reserved):", HFILL }}, + { &hf_tn5250_res_twobytes, + { "Flags (Reserved):", "tn5250.res_twobytes", + FT_UINT16, BASE_HEX, NULL, 0x0, + "Flags (Reserved):", HFILL }}, + { &hf_tn5250_null, + { "Trailing Null (Possible Mainframe/Emulator Bug)", "tn5250.null", + FT_UINT8, BASE_HEX, NULL, 0x0, + "Trailing Null (Possible Mainframe/Emulator Bug)", HFILL }}, + { &hf_tn5250_unknown_data, + { "Unknown Data (Possible Mainframe/Emulator Bug)", "tn5250.unknown_data", + FT_EBCDIC, BASE_HEX, NULL, 0x0, + "Unknown Data (Possible Mainframe/Emulator Bug)", HFILL }}, + + /*TN5250 - RFC1205 - SNA Header Fields */ + { &hf_tn5250_logical_record_length, + { "TN5250 Logical Record Length", "tn5250.logical_record_length", + FT_UINT16, BASE_DEC, NULL, 0x0, + "TN5250 Logical Record Length", HFILL }}, + { &hf_tn5250_sna_record_type, + { "TN5250 SNA Record Type", "tn5250.sna_record_type", + FT_UINT16, BASE_HEX, VALS(vals_tn5250_header_data_types), 0x0, + "TN5250 SNA Record Type", HFILL }}, + { &hf_tn5250_variable_record_length, + { "TN5250 Variable Record Length", "tn5250.variable_record_length", + FT_UINT8, BASE_DEC, NULL, 0x0, + "TN5250 Variable Record Length", HFILL }}, + { &hf_tn5250_header_flags, + { "TN5250 SNA Flags", "tn5250.header_flags", + FT_UINT8, BASE_HEX, NULL, 0x0, + "TN5250 SNA Flags", HFILL }}, + { &hf_tn5250_ds_output_error, + { "Data Stream Output Error", + "tn5250.ds_output_error", FT_BOOLEAN, 8, NULL, 0x80, "", HFILL }}, + { &hf_tn5250_attn_key, + { "5250 attention key was pressed.", + "tn5250.attn_key", FT_BOOLEAN, 8, NULL, 0x40, "", HFILL }}, + { &hf_tn5250_sys_request_key, + { "5250 System Request key was pressed", + "tn5250.sys_request_key", FT_BOOLEAN, 8, NULL, 0x08, "", HFILL }}, + { &hf_tn5250_test_request_key, + { "5250 Test Request key was pressed", + "tn5250.test_request_key", FT_BOOLEAN, 8, NULL, 0x04, "", HFILL }}, + { &hf_tn5250_error_state, + { "In Error State", + "tn5250.error_state", FT_BOOLEAN, 8, NULL, 0x02, "", HFILL }}, + { &hf_tn5250_operation_code, + { "TN5250 Operation Code", "tn5250.operation_code", + FT_UINT8, BASE_HEX, VALS(vals_tn5250_header_operation_code), 0x0, + "TN5250 Operation Code", HFILL }}, + { &hf_tn5250_error_code, + { "TN5250 Error Code", "tn5250.error_code", + FT_UINT16, BASE_HEX, VALS(vals_tn5250_header_error_codes), 0x0, + "TN5250 Error Code", HFILL }}, + }; + + static gint *ett[] = { + &ett_tn5250, + &ett_sf, + &ett_tn5250_field_attribute, + &ett_tn5250_field_validation, + &ett_tn5250_usable_area_flags1, + &ett_tn5250_usable_area_flags2, + &ett_tn5250_query_reply_alphanumeric_flags, + &ett_tn5250_character_sets_flags1, + &ett_tn5250_character_sets_flags2, + &ett_tn5250_character_sets_form, + &ett_tn5250_cs_descriptor_flags, + &ett_tn5250_color_flags, + &ett_tn5250_dc_dir_flags, + &ett_tn5250_wcc, + &ett_tn5250_ccc, + &ett_tn5250_msr_state_mask, + &ett_tn5250_header_flags + }; + module_t *tn5250_module; + + proto_tn5250 = proto_register_protocol("TN5250 Protocol", "TN5250", "tn5250"); + register_dissector("tn5250", dissect_tn5250, proto_tn5250); + proto_register_field_array(proto_tn5250, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); + + /* Preferences */ + tn5250_module = prefs_register_protocol(proto_tn5250, proto_reg_handoff_tn5250); + +} + +void +proto_reg_handoff_tn5250(void) +{ + dissector_handle_t tn5250_handle; + tn5250_handle = create_dissector_handle(dissect_tn5250, proto_tn5250); + dissector_add_handle("tcp.port", tn5250_handle); /* for "decode-as" */ +} + +void +add_tn5250_conversation(packet_info *pinfo _U_, int tn5250e) +{ + conversation_t *conversation; + tn5250_conv_info_t *tn5250_info = NULL; + + /* + * Do we have a conversation for this connection? + */ + conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst, + pinfo->ptype, pinfo->srcport, + pinfo->destport, 0); + if (conversation == NULL) { + /* We don't yet have a conversation, so create one. */ + conversation = conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst, + pinfo->ptype, pinfo->srcport, + pinfo->destport, 0); + } + + /* + * Do we already have a type and mechanism? + */ + tn5250_info = conversation_get_proto_data(conversation, proto_tn5250); + if (tn5250_info == NULL) { + /* No. Attach that information to the conversation, and add + * it to the list of information structures. + */ + tn5250_info = g_malloc(sizeof(tn5250_conv_info_t)); + COPY_ADDRESS(&(tn5250_info->outbound_addr),&(pinfo->dst)); + tn5250_info->outbound_port = pinfo->destport; + COPY_ADDRESS(&(tn5250_info->inbound_addr),&(pinfo->src)); + tn5250_info->inbound_port = pinfo->srcport; + conversation_add_proto_data(conversation, proto_tn5250, tn5250_info); + tn5250_info->next = tn5250_info_items; + tn5250_info_items = tn5250_info; + } + + tn5250_info->extended = tn5250e; + +} + +int +find_tn5250_conversation(packet_info *pinfo _U_) +{ + conversation_t *conversation = NULL; + tn5250_conv_info_t *tn5250_info = NULL; + + /* + * Do we have a conversation for this connection? + */ + conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst, + pinfo->ptype, pinfo->srcport, + pinfo->destport, 0); + if (conversation != NULL) { + tn5250_info = conversation_get_proto_data(conversation, proto_tn5250); + if (tn5250_info != NULL) { + /* + * Do we already have a type and mechanism? + */ + return 1; + } + } + return 0; +} Index: epan/dissectors/packet-tn5250.h =================================================================== --- epan/dissectors/packet-tn5250.h (revision 0) +++ epan/dissectors/packet-tn5250.h (revision 0) @@ -0,0 +1,1090 @@ +/* packet-tn5250.h + * Headers for tn5250.packet dissection + * + * Reference: + * 5250 Information Display System: Data Stream Programmer's Reference + * GA23-0059-07 + * + * Copyright 2009, Robert Hogan + * + * $Id: packet-tn5250.h 26356 2008-10-05 23:08:54Z wmeier $ + * + * Wireshark - Network traffic analyzer + * By Gerald Combs + * Copyright 1998 Gerald Combs + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * + * TODO: + * + * + */ + +#ifndef TN5250_H_INCLUDED +#define TN5250_H_INCLUDED + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include + + +/* OUTBOUND DATA STREAM (MAINFRAME PROGRAM -> DISPLAY) + + ________________ _____ __________________ +| Command Code |WCC | Orders and Data | +|________________|_____|__________________| + + or + ______ ______________________ +| WSF | Structured Field(s) | +|______|______________________| + +*/ +static const value_string vals_escape_codes[] = { + { 0x04 , "ESC"}, + { 0x00, NULL } +}; + +/*14.1 Workstation Data Stream Commands*/ +#define CLEAR_UNIT 0x40 +#define CLEAR_UNIT_ALTERNATE 0x20 +#define CLEAR_FORMAT_TABLE 0x50 +#define WRITE_TO_DISPLAY 0x11 +#define WRITE_ERROR_CODE 0x21 +#define WRITE_ERROR_CODE_TO_WINDOW 0x22 +#define READ_INPUT_FIELDS 0x42 +#define READ_MDT_FIELDS 0x52 +#define READ_MDT_ALTERNATE 0x82 +#define READ_SCREEN 0x62 +#define READ_SCREEN_WITH_EXTENDED_ATTRIBUTES 0x64 +#define READ_SCREEN_TO_PRINT 0x66 +#define READ_SCREEN_TO_PRINT_WITH_EXTENDED_ATTRIBUTES 0x68 +#define READ_SCREEN_TO_PRINT_WITH_GRIDLINES 0x6A +#define READ_SCREEN_TO_PRINT_WITH_EXTENDED_ATTRIBUTES_AND_GRIDLINES 0x6C +#define READ_IMMEDIATE 0x72 +#define READ_MODIFIED_IMMEDIATE_ALTERNATE 0x83 +#define SAVE_SCREEN 0x02 +#define SAVE_PARTIAL_SCREEN 0x03 +#define RESTORE_SCREEN 0x12 +#define RESTORE_PARTIAL_SCREEN 0x13 +#define ROLL 0x23 +#define WRITE_STRUCTURED_FIELD 0xF3 +#define WRITE_SINGLE_STRUCTURED_FIELD 0xF4 +#define COPY-TO-PRINTER 0x16 + +static const value_string vals_command_codes[] = { + { CLEAR_UNIT , "Clear Unit"}, + { CLEAR_UNIT_ALTERNATE , "Clear Unit Alternate"}, + { CLEAR_FORMAT_TABLE , "Clear Format Table"}, + { WRITE_TO_DISPLAY , "Write To Display"}, + { WRITE_ERROR_CODE , "Write Error Code"}, + { WRITE_ERROR_CODE_TO_WINDOW , "Write Error Code To Window"}, + { READ_INPUT_FIELDS , "Read Input Fields"}, + { READ_MDT_FIELDS , "Read Mdt Fields"}, + { READ_MDT_ALTERNATE , "Read Mdt Alternate"}, + { READ_SCREEN , "Read Screen"}, + { READ_SCREEN_WITH_EXTENDED_ATTRIBUTES , "Read Screen With Extended Attributes"}, + { READ_SCREEN_TO_PRINT , "Read Screen To Print"}, + { READ_SCREEN_TO_PRINT_WITH_EXTENDED_ATTRIBUTES , "Read Screen To Print With Extended Attributes"}, + { READ_SCREEN_TO_PRINT_WITH_GRIDLINES , "Read Screen To Print With Gridlines"}, + { READ_SCREEN_TO_PRINT_WITH_EXTENDED_ATTRIBUTES_AND_GRIDLINES , "Read Screen To Print With Extended Attributes And Gridlines"}, + { READ_IMMEDIATE , "Read Immediate"}, + { READ_MODIFIED_IMMEDIATE_ALTERNATE , "Read Modified Immediate Alternate"}, + { SAVE_SCREEN , "Save Screen"}, + { SAVE_PARTIAL_SCREEN , "Save Partial Screen"}, + { RESTORE_SCREEN , "Restore Screen"}, + { RESTORE_PARTIAL_SCREEN , "Restore Partial Screen"}, + { ROLL , "Roll"}, + { WRITE_STRUCTURED_FIELD , "Write Structured Field"}, + { WRITE_SINGLE_STRUCTURED_FIELD , "Write Single Structured Field"}, + { COPY-TO-PRINTER , "Copy-To-Printer"}, + { 0x00, NULL } +}; + +/*14.4 Clear Unit Alternate*/ +static const value_string vals_cua_parms[] = { + { 0x00 , "Set screen size to 27 rows by 132 columns"}, + { 0x80 , "Leave the screen size unchanged and do not erase image/fax data from the display memory."}, + { 0x00, NULL } +}; + + +/* 14.6 Order Codes */ +#define SBA 0x11 +#define IC 0x13 +#define MC 0x14 +#define RA 0x02 +#define EA 0x03 +#define SOH 0x01 +#define TD 0x10 +#define WEA 0x12 +#define SF 0x1D +#define WDSF 0x15 + +static const value_string vals_order_codes[] = { + { SBA, "Set Buffer Address (SBA)"}, + { IC , "Insert Cursor (IC)"}, + { MC , "Move Cursor (MC)"}, + { RA , "Repeat to Address (RA)"}, + { EA , "Erase to Address (EA)"}, + { SOH , "Start of Header (SOH)"}, + { TD , "Transparent Data (TD)"}, + { WEA, "Write Extended Attribute Order"}, + { SF , "Start Field (SF)"}, + { WDSF, "Write to Display Structured Field (WDSF)"}, + { 0x00, NULL } +}; + +/* 14.6.1 WTD Control Code */ +#define STATE0 0x00 +#define STATE1 0x40 +#define STATE2 0x20 +#define STATE3 0x60 +#define STATE4 0x10 +#define STATE5 0x50 +#define STATE6 0x30 +#define STATE7 0x70 +#define CCBITS 0x70 + +static const value_string vals_wtd_cc_byteone[] = { + { STATE0 , ""}, + { STATE1 , "Reset pending AID, lock keyboard"}, + { STATE2 , "Reset pending AID, lock keyboard, Reset MDT flags in non-bypass fields"}, + { STATE3 , "Reset pending AID, lock keyboard, Reset MDT flags in all fields"}, + { STATE4 , "Reset pending AID, lock keyboard, Null all non-bypass fields with MDT on"}, + { STATE5 , "Reset pending AID, lock keyboard, Reset MDT flags in non-bypass fields, Null all non-bypass fields"}, + { STATE6 , "Reset pending AID, lock keyboard, Reset MDT flags in non-bypass fields, Null all non-bypass fields with MDT on"}, + { STATE7 , "Reset pending AID, lock keyboard, Reset MDT flags in all fields, Null all non-bypass fields"}, + { 0x00, NULL } +}; + +/* 14.6.8 Erase to Address Order */ +/* 14.6.11 Write Extended Attribute Order */ + +#define DISPLAY_SCREEN 0x00 +#define EXTENDED_PRIMARY_ATTRIBUTES 0x01 +#define EXTENDED_TEXT_ATTRIBUTES_USED_IN_WP_MODE_ONLY 0x02 +#define EXTENDED_FOREGROUND_COLOR_ATTRIBUTES 0x03 +#define EXTENDED_IDEOGRAPHIC_ATTRIBUTES 0x05 +#define DISPLAY_SCREEN_AND_ALL_EXTENDED_ATTRIBUTE_TYPES_SUPPORTED 0xFF + +static const value_string vals_attributes[] = { + { DISPLAY_SCREEN , "Display screen"}, + { EXTENDED_PRIMARY_ATTRIBUTES , "Extended primary attributes"}, + { EXTENDED_TEXT_ATTRIBUTES_USED_IN_WP_MODE_ONLY , "Extended text attributes (use in WP mode only)"}, + { EXTENDED_FOREGROUND_COLOR_ATTRIBUTES , "Extended foreground color attributes"}, + { EXTENDED_IDEOGRAPHIC_ATTRIBUTES , "Extended ideographic attributes"}, + { DISPLAY_SCREEN_AND_ALL_EXTENDED_ATTRIBUTE_TYPES_SUPPORTED, "Display screen and all extended attribute types supported by this " + "workstation. Use X'FF' to clear all extended attribute types for " + "optimum performance, even if all types are not used."}, + { 0x00, NULL } +}; + + +/* 14.6.11.1 Write Extended Attribute Order - Extended Primary Attribute*/ +/* 14.6.12.3 Start of Field Order - Field Attribute*/ +#define FA_ID 0x04 +#define FA_ID_BITS 0x07 +static const value_string vals_fa_id[] = { + { FA_ID , "Identifies Field as Field Format Word"}, + { 0x00, NULL } +}; + +static const struct true_false_string tn5250_field_attr_col = { + "Column Separator On", + "Column Separator Off" +}; + +static const struct true_false_string tn5250_field_attr_blink = { + "Blink Field", + "Do Not Blink Field" +}; + +static const struct true_false_string tn5250_field_attr_und = { + "Underscore Field", + "Do Not Underscore Field" +}; + +static const struct true_false_string tn5250_field_attr_int = { + "High Intensity", + "Low Intensity" +}; + +static const struct true_false_string tn5250_field_attr_rev = { + "Reverse Image", + "Normal Image" +}; + + +/* 14.6.11.2 Write Extended Attribute Order - Valid Extended Foreground Color Attributes*/ + +#define NULL_CONTINUE_CURRENTLY_DEFINED_ATTRIBUTE 0x00 +#define COLOR_OF_THE_DISPLAY_BACKGROUND_MEDIUM_BLACK_ON_MOST_MODELS 0x80 +#define COLOR_OF_THE_DISPLAY_BACKGROUND_MEDIUM_BLACK_ON_MOST_MODELS 0x81 +#define BLUE 0x82 +#define BLUE_DIFFERENT_SHADE_OF_BLUE_THAN_X82_ON_SOME_DISPLAYS 0x83 +#define GREEN 0x84 +#define GREEN_DIFFERENT_SHADE_OF_GREEN_THAN_X84_ON_SOME_DISPLAYS 0x85 +#define TURQUOISE 0x86 +#define TURQUOISE_DIFFERENT_SHADE_OF_TURQUOISE_THAN_X86_ON_SOME_DISPLAYS 0x87 +#define RED 0x88 +#define RED_DIFFERENT_SHADE_OF_RED_THAN_X88_ON_SOME_DISPLAYS 0x89 +#define PINK 0x8A +#define PINK_DIFFERENT_SHADE_OF_PINK_THAN_X8A_ON_SOME_DISPLAYS 0x8B +#define YELLOW 0x8C +#define YELLOW_DIFFERENT_SHADE_OF_PINK_THAN_X8C_ON_SOME_DISPLAYS 0x8D +#define WHITE 0x8E +#define WHITE_DIFFERENT_SHADE_OF_WHITE_THAN_X8E_ON_SOME_DISPLAYS 0x8F + +static const value_string vals_foreground_color_attributes[] = { + { NULL_CONTINUE_CURRENTLY_DEFINED_ATTRIBUTE , "Null - continue currently defined attribute"}, + { COLOR_OF_THE_DISPLAY_BACKGROUND_MEDIUM_BLACK_ON_MOST_MODELS , "Color of the display background medium; black on most models"}, + { COLOR_OF_THE_DISPLAY_BACKGROUND_MEDIUM_BLACK_ON_MOST_MODELS , "Color of the display background medium; black on most models"}, + { BLUE , "blue"}, + { BLUE_DIFFERENT_SHADE_OF_BLUE_THAN_X82_ON_SOME_DISPLAYS , "blue; different shade of blue than X'82' on some displays"}, + { GREEN , "green"}, + { GREEN_DIFFERENT_SHADE_OF_GREEN_THAN_X84_ON_SOME_DISPLAYS , "green; different shade of green than X'84' on some displays"}, + { TURQUOISE , "turquoise"}, + { TURQUOISE_DIFFERENT_SHADE_OF_TURQUOISE_THAN_X86_ON_SOME_DISPLAYS, "turquoise; different shade of turquoise than X'86' on some displays"}, + { RED , "red"}, + { RED_DIFFERENT_SHADE_OF_RED_THAN_X88_ON_SOME_DISPLAYS , "red; different shade of red than X'88' on some displays"}, + { PINK , "pink"}, + { PINK_DIFFERENT_SHADE_OF_PINK_THAN_X8A_ON_SOME_DISPLAYS , "pink; different shade of pink than X'8A' on some displays"}, + { YELLOW , "yellow"}, + { YELLOW_DIFFERENT_SHADE_OF_PINK_THAN_X8C_ON_SOME_DISPLAYS , "yellow; different shade of pink than X'8C' on some displays"}, + { WHITE , "white"}, + { WHITE_DIFFERENT_SHADE_OF_WHITE_THAN_X8E_ON_SOME_DISPLAYS , "white; different shade of white than X'8E' on some displays"}, + { 0x00, NULL } +}; + + +/* 14.6.11.3 Write Extended Attribute Order - Valid Extended Ideographic Attributes*/ +#define NULL_CONTINUE_CURRENTLY_DEFINED_ATTRIBUTE 00 +#define NORMAL_DISPLAY_ATTRIBUTE_END_DOUBLE_BYTE_MODE_SI 80 +#define BEGIN_DOUBLE_BYTE_MODE_SO 81 + +static const value_string vals_ideographic_attributes[] = { + { NULL_CONTINUE_CURRENTLY_DEFINED_ATTRIBUTE , "Null - continue currently defined attribute"}, + { NORMAL_DISPLAY_ATTRIBUTE_END_DOUBLE_BYTE_MODE_SI, "Normal display attribute - end double byte mode (SI)"}, + { BEGIN_DOUBLE_BYTE_MODE_SO , "Begin double byte mode (SO)"}, + { 0x00, NULL } +}; + +/* 14.6.12.1 Start of Field Order - Field Format Word */ +#define FFW_ID 0x02 +#define FFW_ID_BITS 0x03 +static const value_string vals_ffw_id[] = { + { FFW_ID , "Identifies Field as Field Format Word"}, + { 0x00, NULL } +}; + +static const struct true_false_string tn5250_field_ffw_bypass = { + "This is a bypass field", + "This is not a bypass field" +}; + +static const struct true_false_string tn5250_field_ffw_dup = { + "Duplication or Field Mark is allowed in this field", + "Duplication or Field Mark is not allowed in this field" +}; + +static const struct true_false_string tn5250_field_ffw_mdt = { + "This field has been modified", + "This field has not been modified" +}; + +#define FFW_ALPHA_SHIFT 0x00 +#define FFW_ALPHA_ONLY 0x80 +#define FFW_NUMERIC_SHIFT 0x40 +#define FFW_NUMERIC_ONLY 0xC0 +#define FFW_KATAKANA_SHIFT 0x20 +#define FFW_DIGITS_ONLY 0xA0 +#define FFW_IO-FEATURE_INPUT_FIELD 0x60 +#define FFW_SIGNED_NUMERIC 0xE0 +#define FFW_SHIFT_BITS 0xE0 + +static const value_string vals_ffw_shift[] = { + { FFW_ALPHA_SHIFT , "Alpha shift"}, + { FFW_ALPHA_ONLY , "Alpha only"}, + { FFW_NUMERIC_SHIFT , "Numeric shift"}, + { FFW_NUMERIC_ONLY , "Numeric only"}, + { FFW_KATAKANA_SHIFT , "Katakana shift"}, + { FFW_DIGITS_ONLY , "Digits only"}, + { FFW_IO-FEATURE_INPUT_FIELD , "I/O-(feature input field)"}, + { FFW_SIGNED_NUMERIC , "Signed numeric"}, + { 0x00, NULL } +}; + +static const struct true_false_string tn5250_field_ffw_auto = { + "Auto Enter When Field is Exited", + "No Auto Enter" +}; + +static const struct true_false_string tn5250_field_ffw_fer = { + "Field Exit key is required", + "Field Exit key is not required" +}; + +static const struct true_false_string tn5250_field_ffw_monocase = { + "Translate operator keyed letters to uppercase", + "Accept lower case letters" +}; + +static const struct true_false_string tn5250_field_ffw_me = { + "Mandatory Enter Field", + "Not A Mandatory Enter Field" +}; + +#define FFW_NO_ADJUST_SPECIFIED 0x00 +#define FFW_RESERVED 0x80 +#define FFW_RESERVED 0x40 +#define FFW_RESERVED 0xC0 +#define FFW_RESERVED 0x20 +#define FFW_RIGHT_ADJUST_ZERO_FILL 0xA0 +#define FFW_RIGHT_ADJUST_BLANK_FILL 0x60 +#define FFW_MANDATORY_FILL 0xE0 +#define FFW_ADJUST_BITS 0xE0 + +static const value_string vals_ffw_shift[] = { + { FFW_NO_ADJUST_SPECIFIED , "No adjust specified"}, + { FFW_RESERVED , "Reserved"}, + { FFW_RESERVED , "Reserved"}, + { FFW_RESERVED , "Reserved"}, + { FFW_RESERVED , "Reserved"}, + { FFW_RIGHT_ADJUST_ZERO_FILL , "Right adjust, zero fill"}, + { FFW_RIGHT_ADJUST_BLANK_FILL, "Right adjust, blank fill"}, + { FFW_MANDATORY_FILL , "Mandatory fill"}, + { 0x00, NULL } +}; + +/* 14.6.12.2 Start of Field Order - Field Control Word */ + +#define SELECTOR 0x81 +#define IDEOGRAPHIC 0x82 +#define FORWARD_EDGE 0x85 +#define CONTINUED_ENTRY 0x86 +#define SELF_CHECK 0xB1 +#define ENTRY_FIELD_RESEQUENCING 0x80 +#define CURSOR_PROGRESSION_ENTRY_FIELD 0x88 +#define HIGHLIGHTED_ENTRY_FIELD 0x89 +#define POINTER_DEVICE_SELECTION_ENTRY_FIELD 0x8A +#define TRANSPARENCY_ENTRY_FIELD 0x84 + +#define MAGNETIC_STRIPE_READER_ENTRY_FIELD 0x8101 +#define SELECTOR_LIGHT_PEN_OR_CURSOR_SELECT_FIELD 0x8102 +#define MAGNETIC_STRIPE_READER_AND_SELECTOR_LIGHT_PEN_ENTRY_FIELD 0x8103 +#define SELECTOR_LIGHT_PEN_AND_SELECTABLE_ATTENTION_ENTRY_FIELD 0x8106 +#define IDEOGRAPHIC_ONLY_ENTRY_FIELD 0x8200 +#define IDEOGRAPHIC_DATA_TYPE_ENTRY_FIELD 0x8220 +#define IDEOGRAPHIC_EITHER_ENTRY_FIELD 0x8240 +#define IDEOGRAPHIC_OPEN_ENTRY_FIELD 0x8280 +#define IDEOGRAPHIC_OPEN_ENTRY_FIELD 0x82C0 +#define FORWARD_EDGE_TRIGGER_ENTRY_FIELD 0x8501 +#define CONTINUED_ENTRY_FIELD 0x8601 +#define CONTINUED_ENTRY_FIELD1 0x8602 +#define CONTINUED_ENTRY_FIELD2 0x8603 +#define WORD_WRAP_ENTRY_FIELD 0x8680 +#define SELF_CHECK_MODULUS_11_ENTRY_FIELD 0xB140 +#define SELF_CHECK_MODULUS_10_ENTRY_FIELD 0xB1A0 + +static const value_string vals_fcw[] = { + { ENTRY_FIELD_RESEQUENCING , "Entry field resequencing. The NN specifies the next entry field " + "in the sequence (X'00' to X'80')."}, + { MAGNETIC_STRIPE_READER_ENTRY_FIELD , "Magnetic stripe reader entry field"}, + { SELECTOR_LIGHT_PEN_OR_CURSOR_SELECT_FIELD , "Selector light pen or cursor select field"}, + { MAGNETIC_STRIPE_READER_AND_SELECTOR_LIGHT_PEN_ENTRY_FIELD, "Magnetic stripe reader and selector light pen entry field"}, + { SELECTOR_LIGHT_PEN_AND_SELECTABLE_ATTENTION_ENTRY_FIELD , "Selector light pen and selectable attention entry field"}, + { IDEOGRAPHIC_ONLY_ENTRY_FIELD , "Ideographic-only entry field"}, + { IDEOGRAPHIC_DATA_TYPE_ENTRY_FIELD , "Ideographic data type entry field"}, + { IDEOGRAPHIC_EITHER_ENTRY_FIELD , "Ideographic-either entry field"}, + { IDEOGRAPHIC_OPEN_ENTRY_FIELD , "Ideographic-open entry field"}, + { IDEOGRAPHIC_OPEN_ENTRY_FIELD , "Ideographic-open entry field"}, + { TRANSPARENCY_ENTRY_FIELD , "Transparency entry field. The NN can be any two digits."}, + { FORWARD_EDGE_TRIGGER_ENTRY_FIELD , "Forward edge trigger entry field"}, + { CONTINUED_ENTRY_FIELD , "Continued entry field"}, + { CONTINUED_ENTRY_FIELD1 , "Continued entry field"}, + { CONTINUED_ENTRY_FIELD2 , "Continued entry field"}, + { WORD_WRAP_ENTRY_FIELD , "Word Wrap entry field"}, + { CURSOR_PROGRESSION_ENTRY_FIELD , "Cursor progression entry field. The NN is the next entry field " + "in the specified application cursor progression sequence."}, + { HIGHLIGHTED_ENTRY_FIELD , "Highlighted entry field. The NN specifies the field attribute"}, + { POINTER_DEVICE_SELECTION_ENTRY_FIELD , "Pointer device selection entry field. If a user selects the " + "entry field, the NN specifies the AID to be returned."}, + { SELF_CHECK_MODULUS_11_ENTRY_FIELD , "Self-check modulus 11 entry field"}, + { SELF_CHECK_MODULUS_10_ENTRY_FIELD , "Self-check modulus 10 entry field"}, + { 0x00, NULL } +}; + +/* 14.6.12.3 Start of Field Order - Field Attribute */ + +#define GREEN 0x20 +#define GREEN_REVERSE_IMAGE 0x21 +#define WHITE 0x22 +#define WHITE_REVERSE_IMAGE 0x23 +#define GREEN_UNDERSCORE 0x24 +#define GREEN_UNDERSCORE_REVERSE_IMAGE 0x25 +#define WHITE_UNDERSCORE 0x26 +#define NONDISPLAY 0x27 +#define RED 0x28 +#define RED_REVERSE_IMAGE 0x29 +#define RED_BLINK 0x2A +#define RED_REVERSE_IMAGE_BLINK 0x2B +#define RED_UNDERSCORE 0x2C +#define RED_UNDERSCORE_REVERSE_IMAGE 0x2D +#define RED_UNDERSCORE_BLINK 0x2E +#define NONDISPLAY 0x2F +#define TURQUOISE_COLUMN SEPARATORS 0x30 +#define TURQUOISE_COLUMN SEPARATORS_REVERSE_IMAGE 0x31 +#define YELLOW_COLUMN SEPARATORS 0x32 +#define YELLOW_COLUMN SEPARATORS_REVERSE_IMAGE 0x33 +#define TURQUOISE_UNDERSCORE 0x34 +#define TURQUOISE_UNDERSCORE_REVERSE_IMAGE 0x35 +#define YELLOW_UNDERSCORE 0x36 +#define NONDISPLAY 0x37 +#define PINK 0x38 +#define PINK_REVERSE_IMAGE 0x39 +#define BLUE 0x3A +#define BLUE_REVERSE_IMAGE 0x3B +#define PINK_UNDERSCORE 0x3C +#define PINK_UNDERSCORE_REVERSE_IMAGE 0x3D +#define BLUE_UNDERSCORE 0x3E +#define NONDISPLAY 0x3F + +static const value_string vals_fa_color[] = { + { GREEN , "Green"}, + { GREEN_REVERSE_IMAGE , "Green/Reverse image"}, + { WHITE , "White"}, + { WHITE_REVERSE_IMAGE , "White/Reverse image"}, + { GREEN_UNDERSCORE , "Green/Underscore"}, + { GREEN_UNDERSCORE_REVERSE_IMAGE , "Green/Underscore/Reverse image"}, + { WHITE_UNDERSCORE , "White/Underscore"}, + { NONDISPLAY , "Nondisplay"}, + { RED , "Red"}, + { RED_REVERSE_IMAGE , "Red/Reverse image "}, + { RED_BLINK , "Red/Blink"}, + { RED_REVERSE_IMAGE_BLINK , "Red/Reverse image/Blink"}, + { RED_UNDERSCORE , "Red/Underscore"}, + { RED_UNDERSCORE_REVERSE_IMAGE , "Red/Underscore/Reverse image"}, + { RED_UNDERSCORE_BLINK , "Red/Underscore/Blink"}, + { NONDISPLAY , "Nondisplay"}, + { TURQUOISE_COLUMN SEPARATORS , "Turquoise/Column separators "}, + { TURQUOISE_COLUMN SEPARATORS_REVERSE_IMAGE, "Turquoise/Column separators/Reverse image"}, + { YELLOW_COLUMN SEPARATORS , "Yellow/Column separators"}, + { YELLOW_COLUMN SEPARATORS_REVERSE_IMAGE , "Yellow/Column separators/Reverse image"}, + { TURQUOISE_UNDERSCORE , "Turquoise/Underscore"}, + { TURQUOISE_UNDERSCORE_REVERSE_IMAGE , "Turquoise/Underscore/Reverse image"}, + { YELLOW_UNDERSCORE , "Yellow/Underscore"}, + { NONDISPLAY , "Nondisplay"}, + { PINK , "Pink"}, + { PINK_REVERSE_IMAGE , "Pink/Reverse image"}, + { BLUE , "Blue"}, + { BLUE_REVERSE_IMAGE , "Blue/Reverse image"}, + { PINK_UNDERSCORE , "Pink/Underscore"}, + { PINK_UNDERSCORE_REVERSE_IMAGE , "Pink/Underscore/Reverse image "}, + { BLUE_UNDERSCORE , "Blue/Underscore"}, + { NONDISPLAY , "Nondisplay"}, + { 0x00, NULL } +}; + +/* 14.6.13 Write to Display Structured Field Order */ +#define CLASS_5250 0xD9 + +static const value_string vals_wdsf_class[] = { + { CLASS_5250 , "5250 Class of Structured Field"}, + { 0x00, NULL } +}; + +/* 14.6.13 - Major Structure Types */ +#define DEFINE_SELECTION_FIELD 0x50 +#define CREATE_WINDOW 0x51 +#define UNRESTRICTED_WINDOW_CURSOR_MOVEMENT 0x52 +#define DEFINE_SCROLL_BAR_FIELD 0x53 +#define WRITE_DATA 0x54 +#define PROGRAMMABLE_MOUSE_BUTTONS 0x55 +#define REMOVE_GUI_SELECTION_FIELD 0x58 +#define REMOVE_GUI_WINDOW 0x59 +#define REMOVE_GUI_SCROLL_BAR_FIELD 0x5B +#define REMOVE_ALL_GUI_CONSTRUCTS 0x5F +#define DRAW_ERASE_GRID_LINES 0x60 +#define CLEAR_GRID_LINE_BUFFER 0x61 + +static const value_string vals_wdsf_type[] = { + { DEFINE_SELECTION_FIELD , "Define Selection Field"}, + { CREATE_WINDOW , "Create Window"}, + { UNRESTRICTED_WINDOW_CURSOR_MOVEMENT, "Unrestricted Window Cursor Movement"}, + { DEFINE_SCROLL_BAR_FIELD , "Define Scroll Bar Field"}, + { WRITE_DATA , "Write Data"}, + { PROGRAMMABLE_MOUSE_BUTTONS , "Programmable Mouse Buttons"}, + { REMOVE_GUI_SELECTION_FIELD , "Remove Gui Selection Field"}, + { REMOVE_GUI_WINDOW , "Remove Gui Window"}, + { REMOVE_GUI_SCROLL_BAR_FIELD , "Remove Gui Scroll Bar Field"}, + { REMOVE_ALL_GUI_CONSTRUCTS , "Remove All Gui Constructs"}, + { DRAW_ERASE_GRID_LINES , "Draw/Erase Grid Lines"}, + { CLEAR_GRID_LINE_BUFFER , "Clear Grid Line Buffer"}, + { 0x00, NULL } +}; + +/* 14.6.13.1 Write to Display Structured Field Order - Create Window */ +static const struct true_false_string tn5250_field_wdscf_cw_flag1_1 = { + "Cursor Restricted To Window", + "Cursor Not Restricted To Window" +}; + +static const struct true_false_string tn5250_field_wdscf_cw_flag1_2 = { + "Window Is A Pull-Down Menu Bar", + "Window Is Not A Pull-Down Menu Bar" +}; + +#define CW_BORDER_PRESENTATION 0x01 +#define CW_TITLE_FOOTER 0x10 + +static const value_string vals_wdsf_cw_minor_type[] = { + { CW_BORDER_PRESENTATION , "Border Presentation"}, + { CW_TITLE_FOOTER , "Window Title/Footer"}, + { 0x00, NULL } +}; + +/* 14.6.13.1 Write to Display Structured Field Order - Create Window - Border Presentation Minor Structure */ +static const struct true_false_string tn5250_field_wdscf_cw_bp_flag1_1 = { + "Use Border Presentation Characters on a GUI-like NWS", + "Do Not Use Border Presentation Characters on a GUI-like NWS" +}; + +/* 14.6.13.1 Write to Display Structured Field Order - Create Window - Window Title/Footer Minor Structure */ +#define WTF_CENTER 0x00 +#define WTF_RIGHT 0x02 +#define WTF_LEFT 0x01 +#define WTF_RESERVED 0x03 +#define WTF_BITS 0x03 + +static const value_string vals_wdsf_cw_tf_flag_orientation[] = { + { WTF_CENTER , "Window Title or Footer is Centered"}, + { WTF_RIGHT , "Window Title or Footer is Right Justified"}, + { WTF_LEFT , "Window Title or Footer is Left Justified"}, + { WTF_RESERVED, "Reserved (Window Title or Footer is Centered)"}, + { 0x00, NULL } +}; + +static const struct true_false_string tn5250_field_wdsf_cw_tf_flag_1 = { + "Window Footer is Defined", + "Window Title is Defined" +}; + + +/* 14.6.13.4 Write to Display Structured Field Order - Remove All GUI Constructs*/ +static const struct true_false_string tn5250_field_wdscf_ragc_flag1_1 = { + "5494 Maps GUI-like Characters", + "5494 Does Not Map GUI-like Characters" +}; + + +/* 14.6.13.5 Write to Display Structured Field Order - Define Selection Field*/ +#define DS_CHOICE_TEXT 0x10 +#define DS_MENU_BAR_SEPARATOR 0x09 + +static const value_string vals_wdsf_ds_minor_type[] = { + { DS_CHOICE_TEXT , "Choice Text"}, + { DS_MENU_BAR_SEPARATOR , "Menu Bar Separator"}, + { 0x00, NULL } +}; + +#define DS_USE_ALWAYS 0x00 +#define DS_USE_NO_MOUSE 0x02 +#define DS_USE_MOUSE 0x01 +#define DS_RESERVED 0x03 +#define MOUSE_CHARACTERISTICS_BITS 0x03 + +static const value_string vals_wdsf_ds_flag1_mouse_characteristics[] = { + { DS_USE_ALWAYS , "Use this selection field in all cases"}, + { DS_USE_NO_MOUSE , "Use this selection field only if the display does not have a mouse."}, + { DS_USE_MOUSE , "Use this selection field only if the display has a mouse."}, + { DS_RESERVED , "Reserved"}, + { 0x00, NULL } +}; + +#define DS_AUTO_ENTER1 0x00 +#define DS_AUTO_ENTER2 0x20 +#define DS_AUTO_ENTER3 0x10 +#define DS_AUTO_ENTER4 0x30 +#define DS_AUTO_ENTER_BITS 0x30 + +static const value_string vals_wdsf_ds_flag1_auto_enter[] = { + { DS_AUTO_ENTER1, "Selection field is not auto-enter"}, + { DS_AUTO_ENTER2, "Selection field is auto-enter on selection except if double-digit numeric selection is used."}, + { DS_AUTO_ENTER3, "Selection field is auto-enter on selection or deselection except if double-digit numeric selection is used. "}, + { DS_AUTO_ENTER4, "Selection field is auto-enter on selection except if single-digit or double-digit numeric selection is used."}, + { 0x00, NULL } +}; + +static const struct true_false_string tn5250_field_wdsf_ds_flag1_1 = { + "Auto-Select Enabled", + "Auto-Select Not Enabled" +}; + +static const struct true_false_string tn5250_field_wdsf_ds_flag1_2 = { + "Field MDT Enabled", + "Field MDT Not Enabled" +}; + +static const struct true_false_string tn5250_field_wdsf_ds_flag2_1 = { + "If set to on, a scroll bar should is created beside the selection field choices, and TotalRows and SliderPos that can " + "be scrolled are included in the major structure.", + "No Action" +}; + +static const struct true_false_string tn5250_field_wdsf_ds_flag2_2 = { + "If set to on, one blank is added after the numeric separator character.", + "No Action" +}; + +static const struct true_false_string tn5250_field_wdsf_ds_flag2_3 = { + "If set to on, an asterisk (*) replaces the first character of an unavailable choice on monochrome display.", + "No Action" +}; + +static const struct true_false_string tn5250_field_wdsf_ds_flag2_4 = { + "If set to on, cursor is limited to input-capable positions only.", + "No Action" +}; + +static const struct true_false_string tn5250_field_wdsf_ds_flag2_5 = { + "If set to on, the Field Advance/Field Backspace function is like the Character Advance/Character Backspace keys within " + "this selection field.", + "No Action" +}; + +static const struct true_false_string tn5250_field_wdsf_ds_flag2_6 = { + "If set to on, the cursor movement keys are not allowed to exit this selection field.", + "No Action" +}; + +static const struct true_false_string tn5250_field_wdsf_ds_flag3_1 = { + "If set to on, any selected choices are changed to available whenever the keyboard is unlocked.", + "No Action" +}; + +#define MENU_BAR 0x01 +#define SINGLE_CHOICE_SELECTION_FIELD 0x11 +#define MULTIPLE_CHOICE_SELECTION_FIELD 0x12 +#define SINGLE_CHOICE_SELECTION_LIST 0x21 +#define MULTIPLE_CHOICE_SELECTION_LIST 0x22 +#define SINGLE_CHOICE_SELECTION_FIELD_AND_A_PULL_DOWN_LIST 0x31 +#define MULTIPLE_CHOICE_SELECTION_FIELD_AND_A_PULL_DOWN_LIST 0x32 +#define PUSH_BUTTONS 0x41 +#define PUSH_BUTTONS_IN_A_PULL_DOWN_MENU_ 0x51 + +static const value_string vals_wdsf_ds_type[] = { + { MENU_BAR , "Menu bar"}, + { SINGLE_CHOICE_SELECTION_FIELD , "Single choice selection field"}, + { MULTIPLE_CHOICE_SELECTION_FIELD , "Multiple choice selection field"}, + { SINGLE_CHOICE_SELECTION_LIST , "Single choice selection list"}, + { MULTIPLE_CHOICE_SELECTION_LIST , "Multiple choice selection list"}, + { SINGLE_CHOICE_SELECTION_FIELD_AND_A_PULL_DOWN_LIST , "Single choice selection field and a pull-down list"}, + { MULTIPLE_CHOICE_SELECTION_FIELD_AND_A_PULL_DOWN_LIST, "Multiple choice selection field and a pull-down list"}, + { PUSH_BUTTONS , "Push buttons"}, + { PUSH_BUTTONS_IN_A_PULL_DOWN_MENU_ , "Push buttons in a pull-down menu "}, + { 0x00, NULL } +}; + +#define DS_INDICATOR1 0x00 +#define DS_INDICATOR2 0x02 +#define DS_INDICATOR3 0x03 +#define DS_INDICATOR4 0x04 +#define DS_INDICATOR5 0x05 +#define DS_INDICATOR6 0x06 +#define DS_INDICATOR7 0x0F +#define DS_INDICATORS_BITS 0x0F + +static const value_string vals_wdsf_ds_gdc_indicators[] = { + { DS_INDICATOR1, "An indicator to the left of each choice (check box or radio button) is created."}, + { DS_INDICATOR2, "A push button box is created around choice text and the choice text is padded with a blank on both sides."}, + { DS_INDICATOR3, "A push button indicator specifies each choice instead of a push button box on a GUI-like NWS. (A GUI " + "PWS treats this setting like B'0010'.)"}, + { DS_INDICATOR4, "A push button box is created around choice text and choice text is padded with a blank on both sides," + " and a leading choice text attribute is written on top of the previous choice text ending attribute."}, + { DS_INDICATOR5, "A push button indicator specifies each choice instead of a push button box on a GUI-like NWS, and a leading " + "choice text attribute is specified on top of the previous ending choice text attribute. (A GUI PWS treats " + "this setting like B'0100'.)"}, + { DS_INDICATOR6, "A push button box is created around choice text (with no padding)."}, + { DS_INDICATOR7, "There are no indicators for this value. It is valid for all types of selection."}, + { 0x00, NULL } +}; + +#define DS_SELECTION_TECHNIQUES1 0x20 +#define DS_SELECTION_TECHNIQUES2 0x40 +#define DS_SELECTION_TECHNIQUES3 0xE0 +#define DS_SELECTION_TECHNIQUES_BITS 0xE0 + +static const value_string vals_wdsf_ds_gdc_selection_techniques[] = { + { DS_SELECTION_TECHNIQUES1, "Defines a mnemonic (or numeric) selection for some or all of the choices. The mnemonic is underscored."}, + { DS_SELECTION_TECHNIQUES2, "Defines a mnemonic (or numeric) selection for some or all of the choices. " + "The mnemonic is not underscored."}, + { DS_SELECTION_TECHNIQUES3, "No mnemonic (or numeric) selection is specified."}, + { 0x00, NULL } +}; + + +#define DS_NWS_INDICATOR1 0x00 +#define DS_NWS_INDICATOR2 0x03 +#define DS_NWS_INDICATOR3 0x05 +#define DS_NWS_INDICATOR4 0x08 +#define DS_NWS_INDICATOR5 0x0F +#define DS_NWS_INDICATORS_BITS 0x0F + +static const value_string vals_wdsf_ds_nws_indicators[] = { + { DS_NWS_INDICATOR1, "An indicator to the left of each choice (for example, a slash (/)) is created. (1)"}, + { DS_NWS_INDICATOR2, "A push button indicator specifies each choice. (2)"}, + { DS_NWS_INDICATOR3, "A push button indicator specifies each choice, and a leading choice text attribute is " + "specified on top of a previous ending choice text attribute. (2)"}, + { DS_NWS_INDICATOR4, "A numeric field to the left of the first choice is created. (Single- or double-digit " + "numeric fields are determined by bits 5-7.) (3)"}, + { DS_NWS_INDICATOR5, "No indicators are specified for this value. This is valid for all types of selection fields."}, + { 0x00, NULL } +}; + +#define DS_NWS_SELECTION_TECHNIQUES1 0x20 +#define DS_NWS_SELECTION_TECHNIQUES2 0x40 +#define DS_NWS_SELECTION_TECHNIQUES3 0x80 +#define DS_NWS_SELECTION_TECHNIQUES4 0xA0 +#define DS_NWS_SELECTION_TECHNIQUES5 0xE0 +#define DS_NWS_SELECTION_TECHNIQUES_BITS 0xE0 + +static const value_string vals_wdsf_ds_nws_selection_techniques[] = { + { DS_NWS_SELECTION_TECHNIQUES1, "Defines a mnemonic (or numeric) selection for some or all of the choices. " + "The mnemonic is underscored."}, + { DS_NWS_SELECTION_TECHNIQUES2, "Defines a mnemonic (or numeric) selection for some or all of the choices. " + "The mnemonic is not underscored."}, + { DS_NWS_SELECTION_TECHNIQUES3, "Defines a single-digit numeric selection."}, + { DS_NWS_SELECTION_TECHNIQUES4, "Defines a double-digit numeric selection."}, + { DS_NWS_SELECTION_TECHNIQUES5, "No mnemonic or numeric selection is defined."}, + { 0x00, NULL } +}; + +/* 14.6.13.5 Write to Display Structured Field Order - Define Selection Field - Choice Text Minor Structure*/ +#define DS_CHOICE_STATE1 0x01 +#define DS_CHOICE_STATE2 0x02 +#define DS_CHOICE_STATE3 0x03 +#define DS_CHOICE_STATE_BITS 0x03 + +static const value_string vals_wdsf_ds_ct_flag1_choice_state[] = { + { DS_CHOICE_STATE1, "Available and not a default selection"}, + { DS_CHOICE_STATE2, "Available and is a default selection (selected state)"}, + { DS_CHOICE_STATE3, "Not available"}, + { 0x00, NULL } +}; + +static const struct true_false_string tn5250_field_wdsf_ds_ct_flag1_2 = { + "Set to on: specifies a menu bar choice that starts a new row.", + "Set to on: does not specify a menu bar choice that starts a new row." +}; + +static const struct true_false_string tn5250_field_wdsf_ds_ct_flag1_3 = { + "Reserved (incorrectely set to on).", + "Reserved (set to zero)." +}; + +static const struct true_false_string tn5250_field_wdsf_ds_ct_flag1_4 = { + "Set to on: specifies that a mnemonic offset is included in the minor structure.", + "Set to off: does not specify that a mnemonic offset is included in the minor structure." +}; + +static const struct true_false_string tn5250_field_wdsf_ds_ct_flag1_5 = { + "If set to on, specifies an AID if 'selected' is included in this minor structure.", + "No Action" +}; + +#define DS_NUMERIC_SELECTION1 0x00 +#define DS_NUMERIC_SELECTION2 0x40 +#define DS_NUMERIC_SELECTION3 0x80 +#define DS_NUMERIC_SELECTION_BITS 0xC0 + +static const value_string vals_wdsf_ds_ct_flag1_numeric_selection[] = { + { DS_NUMERIC_SELECTION1, "Numeric selection characters are not included in this minor structure."}, + { DS_NUMERIC_SELECTION2, "A single-digit numeric selection character is included in this minor structure."}, + { DS_NUMERIC_SELECTION3, "Double-digit numeric selection characters are included in this minor structure."}, + { 0x00, NULL } +}; + +static const struct true_false_string tn5250_field_wdsf_ds_ct_flag2_0 = { + "Set to on, the choice cannot accept a cursor.", + "Set to off, the choice can accept a cursor." +}; + +static const struct true_false_string tn5250_field_wdsf_ds_ct_flag2_1 = { + "Set to on, the application user desires a roll-down AID if the Cursor Up key is pressed on this choice.", + "Set to off, the application user does not desire a roll-down AID if the Cursor Up key is pressed on this choice." +}; + +static const struct true_false_string tn5250_field_wdsf_ds_ct_flag2_2 = { + "Set to on, the application user desires a roll-up AID if the Cursor Up key is pressed on this choice.", + "Set to off, the application user does not desire a roll-up AID if the Cursor Up key is pressed on this choice." +}; + +static const struct true_false_string tn5250_field_wdsf_ds_ct_flag2_3 = { + "Set to on, the application user desires a roll-left AID if the Cursor Up key is pressed on this choice.", + "Set to off, the application user does not desire a roll-left AID if the Cursor Up key is pressed on this choice." +}; + +static const struct true_false_string tn5250_field_wdsf_ds_ct_flag2_4 = { + "Set to on, the application user desires a roll-right AID if the Cursor Up key is pressed on this choice.", + "Set to off, the application user does not desire a roll-right AID if the Cursor Up key is pressed on this choice." +}; + +static const struct true_false_string tn5250_field_wdsf_ds_ct_flag2_5 = { + "Set to on, no push-button box is written for this choice.", + "Set to off, a push-button box is written for this choice." +}; + +static const struct true_false_string tn5250_field_wdsf_ds_ct_flag2_6 = { + "Reserved (incorrectely set to on).", + "Reserved (set to zero)." +}; + +static const struct true_false_string tn5250_field_wdsf_ds_ct_flag2_7 = { + "Set to on, cursor direction is right to left.", + "Set to off, cursor direction is left to right." +}; + +static const struct true_false_string tn5250_field_wdsf_ds_ct_flag3_0 = { + "Set to on, use this minor structure for GUI devices (including GUI-like NWSs).", + "Set to off, do not use this minor structure for GUI devices (including GUI-like NWSs)." +}; + +static const struct true_false_string tn5250_field_wdsf_ds_ct_flag3_1 = { + "Set to on, use this minor structure for non-GUI NWSs that are capable of creating mnemonic underscores.", + "Set to off, do not use this minor structure for non-GUI NWSs that are capable of creating mnemonic underscores." +}; + +static const struct true_false_string tn5250_field_wdsf_ds_ct_flag3_2 = { + "Set to on, use this minor structure for NWS display devices that are not capable of creating underscores.", + "Set to off, do not use this minor structure for NWS display devices that are not capable of creating underscores." +}; + +/* 14.6.13.5 Write to Display Structured Field Order - Define Selection Field - Menu Bar Separator Minor Structure*/ + +static const struct true_false_string tn5250_field_wdsf_ds_ct_flag_0 = { + "Use specified separator character on GUI-like NWSs.", + "Do not use specified separator character on GUI-like NWSs." +}; + +static const struct true_false_string tn5250_field_wdsf_ds_ct_flag_1 = { + "Suppress writing of leading and ending attributes.", + "Do not suppress writing of leading and ending attributes." +}; + + +/* TN5250 Header - Data Type */ +#define TN5250_5250_DATA 0x00 +#define TN5250_BIND_IMAGE 0x03 +#define TN5250_NVT_DATA 0x05 +#define TN5250_REQUEST 0x06 +#define TN5250_RESPONSE 0x02 +#define TN5250_SCS_DATA 0x01 +#define TN5250_SSCP_LU_DATA 0x07 +#define TN5250_UNBIND 0x04 + +static const value_string vals_tn5250_header_data_types[] = { + { TN5250_5250_DATA , "5250_DATA"}, + { TN5250_BIND_IMAGE , "BIND_IMAGE"}, + { TN5250_NVT_DATA , "NVT_DATA"}, + { TN5250_REQUEST , "REQUEST"}, + { TN5250_RESPONSE , "RESPONSE"}, + { TN5250_SCS_DATA , "SCS_DATA"}, + { TN5250_SSCP_LU_DATA, "SSCP_LU_DATA"}, + { TN5250_UNBIND , "UNBIND"}, + { 0x00, NULL } +}; + + +/* TN5250 Header - Record Type */ +#define GDS 0x12A0 + +static const value_string vals_tn5250_sna_record_type[] = { + { GDS , "General Data Stream"}, + { 0x00, NULL } +}; + +/* TN5250 Header - Operation Code */ +#define NO_OPERATION 0x00 +#define INVITE_OPERATION 0x01 +#define OUTPUT_ONLY 0x02 +#define PUT/GET_OPERATION 0x03 +#define SAVE_SCREEN_OPERATION 0x04 +#define RESTORE_SCREEN_OPERATION 0x05 +#define READ_IMMEDIATE_OPERATION 0x06 +#define RESERVED 0x07 +#define READ_SCREEN_OPERATION 0x08 +#define RESERVED 0x09 +#define CANCEL_INVITE_OPERATION 0x0A +#define TURN_ON_MESSAGE_LIGHT 0x0B +#define TURN_OFF_MESSAGE_LIGHT 0x0C + +static const value_string vals_tn5250_header_operation_code[] = { + { NO_OPERATION , "No Operation"}, + { INVITE_OPERATION , "Invite Operation"}, + { OUTPUT_ONLY , "Output Only"}, + { PUT/GET_OPERATION , "Put/Get Operation"}, + { SAVE_SCREEN_OPERATION , "Save Screen Operation"}, + { RESTORE_SCREEN_OPERATION, "Restore Screen Operation"}, + { READ_IMMEDIATE_OPERATION, "Read Immediate Operation"}, + { RESERVED , "Reserved"}, + { READ_SCREEN_OPERATION , "Read Screen Operation"}, + { RESERVED , "Reserved"}, + { CANCEL_INVITE_OPERATION , "Cancel Invite Operation"}, + { TURN_ON_MESSAGE_LIGHT , "Turn On Message Light"}, + { TURN_OFF_MESSAGE_LIGHT , "Turn Off Message Light"}, + { 0x00, NULL } +}; + +/* TN5250 Header _ Response Flags - Data Type Response */ +#define TN5250_POSITIVE_RESPONSE 0x00 +#define TN5250_NEGATIVE_RESPONSE 0x01 + +static const value_string vals_tn5250_header_response_flags_response[] = { + { TN5250_POSITIVE_RESPONSE, "POSITIVE-RESPONSE"}, + { TN5250_NEGATIVE_RESPONSE, "NEGATIVE-RESPONSE"}, + { 0x00, NULL } +}; + + +static const value_string vals_tn5250_header_error_codes[] = { + { 0x0000, "Help key not allowed."}, + { 0x0001, "Keyboard overrun."}, + { 0x0002, "Incorrect scan code."}, + { 0x0003, "Command or PF key not valid."}, + { 0x0004, "Data not allowed in this field."}, + { 0x0005, "Cursor in protected area of display."}, + { 0x0006, "Key following Sys Req Key is not valid."}, + { 0x0007, "Mandatory entry field; you must enter data."}, + { 0x0008, "This field must have alphabetic characters."}, + { 0x0009, "This field must have numeric characters."}, + { 0x0010, "Only characters 0 through 9 allowed."}, + { 0x0011, "You tried to enter data into the last position of a signed numeric field."}, + { 0x0012, "Insert mode; no room to insert data."}, + { 0x0013, "Insert mode; only data keys permitted."}, + { 0x0014, "Must fill field to exit."}, + { 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."}, + { 0x0016, "Field- not valid in this field."}, + { 0x0017, "Mandatory-fill field; key pressed is not valid."}, + { 0x0018, "Key used to exit this field not valid."}, + { 0x0019, "Dup or Field Mark not permitted in this field."}, + { 0x0020, "Function key not valid for right-adjust field."}, + { 0x0021, "Must enter data in mandatory entry field."}, + { 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."}, + { 0x0023, "Hexadecimal mode; entry not valid."}, + { 0x0024, "Decimal field; entry not valid."}, + { 0x0026, "Field- entry not allowed."}, + { 0x0027, "Cannot use undefined key."}, + { 0x0029, "Diacritic character not valid."}, + { 0x0031, "Data buffer overflow."}, + { 0x0032, "MSR error."}, + { 0x0033, "MSR data not authorized."}, + { 0x0034, "Magnetic stripe reader (MSR) data exceeds length of field."}, + { 0x0035, "MSR error."}, + { 0x0036, "Cursor select not allowed in field exit required state."}, + { 0x0037, "You pressed Cursor Select in a non-selectable field."}, + { 0x0038, "Light pen and magnetic stripe reader (MSR) not allowed."}, + { 0x0040, "The modem or data circuit-terminating equipment (DCE) is not ready for one of the following reasons:"}, + { 0x0041, "X.25: Idle condition has been detected. The receive line was idle for 15 or more contiguous bit-times."}, + { 0x0042, "The receive clock signal is not being received from the modem or data circuit-terminating equipment (DCE)."}, + { 0x0043, "The 5494 attempted to disconnect from the line, but the data set ready (DSR) signal was not deactivated by the modem or DCE."}, + { 0x0044, "Switched lines: This error indicates that no valid data has been received for 30 seconds. The 5494 disconnected the line."}, + { 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."}, + { 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."}, + { 0x0047, "X.25 or LAN: An unexpected Disconnect mode (DM) or a Disconnect (DISC) command was received while in information transfer state."}, + { 0x0048, "X.25: An unexpected unnumbered acknowledgment (UA) frame was received."}, + { 0x0049, "LAN: A set asynchronous balance mode extended (SABME) was received while the 5494 was in information transfer state."}, + { 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:"}, + { 0x0051, "The transmit clock from the modem or data circuit-terminating equipment (DCE) failed during a transmit operation."}, + { 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."}, + { 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."}, + { 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."}, + { 0x0055, "The 5494 ran a cable wrap test and determined that the communication cable is not attached to the 5494."}, + { 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."}, + { 0x0060, "Ideographic support SRC: You attempted to enter alphanumeric data into a field that accepts only double-byte data characters."}, + { 0x0061, "Ideographic support SRC: You attempted to enter a double-byte character into a field that accepts only alphanumeric data."}, + { 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."}, + { 0x0063, "You entered an ideographic character that is not valid while operating in Alternate Entry mode."}, + { 0x0064, "You pressed a key that is not valid for the current keyboard mode."}, + { 0x0065, "The cursor is positioned in a column reserved for shift-out or shift-in characters."}, + { 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."}, + { 0x0067, "The workstation extension character RAM is full. Any additional extension characters display as special default characters."}, + { 0x0068, "The output data stream to the 5494 is not valid for extension characters. Any additional extension characters display as special default characters."}, + { 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."}, + { 0x0070, "An error occurred during the word spill function or the carriage return function."}, + { 0x0071, "You attempted a start copy, move, or delete text operation while one of the previous operations was already in progress."}, + { 0x0072, "The key pressed is not valid when the cursor is in the current position."}, + { 0x0073, "An attempt was made to delete or replace an instruction or format change when the general prompt function was not active."}, + { 0x0074, "A key was pressed that is not valid when using the general prompt function."}, + { 0x0075, "The find function failed to find the keyed characters."}, + { 0x0076, "The insert function failed because the AS/400 system has not processed the text on the screen."}, + { 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."}, + { 0x0078, "The required scale line is not defined for your workstation. There is an error in the application program."}, + { 0x0081, "Too many workstations are attached to the 5494. The 5494 with LAN adapter installed allows a maximum of 80 devices."}, + { 0x0082, "Keyboard function is not valid within a selection field. These invalid functions include Dup, Erase EOF, and Field Mark."}, + { 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."}, + { 0x0084, "An attempt has been made to select an unavailable selection field."}, + { 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."}, + { 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."}, + { 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."}, + { 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)."}, + { 0x008D, "Printer port and station values are not valid. Valid ports for the Twinaxial Expansion Kit are 4-7. Valid stations are 0-7."}, + { 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."}, + { 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."}, + { 0x0091, "Reverse and Close keys are not supported in a Word Wrap entry field."}, + { 0x0092, "The reverse key is not supported on a display which is configured for shared addressing."}, + { 0x0097, "A test request function is not supported by the AS/400 system."}, + { 0x0098, "Undefined hardware error."}, + { 0x0099, "A key requiring AS/400 system action was pressed, but one of the following has occurred:"}, + { 0x009A, "An invalid password has been entered three times in an attempt to access concurrent diagnostics from a PWS."}, + { 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."}, + { 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."}, + { 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."}, + { 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:"}, + { 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:"}, + { 0x0000, NULL } +}; + + + +/* + * Data structure attached to a conversation, giving authentication + * information from a bind request. + * We keep a linked list of them, so that we can free up all the + * authentication mechanism strings. + */ +typedef struct tn5250_conv_info_t { + struct tn5250_conv_info_t *next; + address outbound_addr; + guint32 outbound_port; + address inbound_addr; + guint32 inbound_port; + gint extended; +} tn5250_conv_info_t; + +void add_tn5250_conversation(packet_info *pinfo _U_, int tn5250e); +int find_tn5250_conversation(packet_info *pinfo _U_); +#endif