Include <string.h> to get "strcmp()" declared.
[obnox/wireshark/wip.git] / packet-tns.c
index 1b6558dcbb88317437f135f726821e70241dc91d..0a55bf947168a9e855fc0bee2188f09451bd0d96 100644 (file)
@@ -1,24 +1,24 @@
 /* packet-tns.c
  * Routines for Oracle TNS packet dissection
  *
- * $Id: packet-tns.c,v 1.33 2002/07/08 22:57:55 guy Exp $
+ * $Id: packet-tns.c,v 1.39 2003/02/05 08:06:40 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
  * Copyright 1998 Gerald Combs
  *
  * Copied from packet-tftp.c
- * 
+ *
  * 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.
 
 #include <stdio.h>
 
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#ifdef HAVE_NETINET_IN_H
-# include <netinet/in.h>
-#endif
-
 #include <string.h>
 #include <glib.h>
 #include <epan/packet.h>
@@ -233,7 +225,7 @@ static void dissect_tns_service_options(tvbuff_t *tvb, int offset,
                        offset, 2, FALSE);
        proto_tree_add_item(sopt_tree, hf_tns_sopt_flag_sa, tvb,
                        offset, 2, FALSE);
-       
+
 }
 
 static void dissect_tns_connect_flag(tvbuff_t *tvb, int offset,
@@ -252,7 +244,7 @@ static void dissect_tns_data(tvbuff_t *tvb, int offset, packet_info *pinfo,
 {
        proto_tree *data_tree = NULL, *ti;
        int is_sns = 0;
-       
+
        if ( tvb_bytes_exist(tvb, offset+2, 4) )
        {
                if ( tvb_get_guint8(tvb, offset+2) == 0xDE &&
@@ -274,7 +266,7 @@ static void dissect_tns_data(tvbuff_t *tvb, int offset, packet_info *pinfo,
                else
                {
                        ti = proto_tree_add_text(tns_tree, tvb, offset, -1,
-                           "Data");            
+                           "Data");
                }
                data_tree = proto_item_add_subtree(ti, ett_tns_data);
 
@@ -285,9 +277,9 @@ static void dissect_tns_data(tvbuff_t *tvb, int offset, packet_info *pinfo,
        if ( tree )
        {
                proto_tree *df_tree = NULL;
-               
+
                ti = proto_tree_add_item(data_tree, hf_tns_data_flag, tvb, offset, 2, FALSE);
-               
+
                df_tree = proto_item_add_subtree(ti, ett_tns_data_flag);
                proto_tree_add_item(df_tree, hf_tns_data_flag_send, tvb, offset, 2, FALSE);
                proto_tree_add_item(df_tree, hf_tns_data_flag_rc, tvb, offset, 2, FALSE);
@@ -310,9 +302,9 @@ static void dissect_tns_data(tvbuff_t *tvb, int offset, packet_info *pinfo,
                else
                {
                        col_append_fstr(pinfo->cinfo, COL_INFO, ", Data");
-               }       
+               }
        }
-       
+
        if ( data_tree )
        {
                call_dissector(data_handle,
@@ -339,7 +331,7 @@ static void dissect_tns_connect(tvbuff_t *tvb, int offset, packet_info *pinfo,
                proto_tree_add_boolean_hidden(tns_tree, hf_tns_connect, tvb,
                    0, 0, TRUE);
        }
-               
+
        if ( check_col(pinfo->cinfo, COL_INFO) )
        {
                col_append_str(pinfo->cinfo, COL_INFO, ", Connect");
@@ -351,7 +343,7 @@ static void dissect_tns_connect(tvbuff_t *tvb, int offset, packet_info *pinfo,
                        offset, 2, FALSE);
        }
        offset += 2;
-       
+
        if ( connect_tree )
        {
                proto_tree_add_item(connect_tree, hf_tns_compat_version, tvb,
@@ -362,14 +354,14 @@ static void dissect_tns_connect(tvbuff_t *tvb, int offset, packet_info *pinfo,
        if ( connect_tree )
        {
                proto_tree *sopt_tree = NULL;
-               
+
                ti = proto_tree_add_item(connect_tree, hf_tns_service_options, tvb,
                        offset, 2, FALSE);
 
                sopt_tree = proto_item_add_subtree(ti, ett_tns_sopt_flag);
 
                dissect_tns_service_options(tvb, offset, sopt_tree);
-               
+
 
        }
        offset += 2;
@@ -391,10 +383,10 @@ static void dissect_tns_connect(tvbuff_t *tvb, int offset, packet_info *pinfo,
        if ( connect_tree )
        {
                proto_tree *ntp_tree = NULL;
-               
+
                ti = proto_tree_add_item(connect_tree, hf_tns_nt_proto_characteristics, tvb,
                        offset, 2, FALSE);
-               
+
                ntp_tree = proto_item_add_subtree(ti, ett_tns_ntp_flag);
 
                proto_tree_add_item(ntp_tree, hf_tns_ntp_flag_hangon, tvb, offset, 2, FALSE);
@@ -456,7 +448,7 @@ static void dissect_tns_connect(tvbuff_t *tvb, int offset, packet_info *pinfo,
        if ( connect_tree )
        {
                proto_tree *cflag_tree = NULL;
-               
+
                ti = proto_tree_add_item(connect_tree, hf_tns_connect_flags0, tvb,
                        offset, 1, FALSE);
 
@@ -469,7 +461,7 @@ static void dissect_tns_connect(tvbuff_t *tvb, int offset, packet_info *pinfo,
        if ( connect_tree )
        {
                proto_tree *cflag_tree = NULL;
-               
+
                ti = proto_tree_add_item(connect_tree, hf_tns_connect_flags1, tvb,
                        offset, 1, FALSE);
 
@@ -479,26 +471,33 @@ static void dissect_tns_connect(tvbuff_t *tvb, int offset, packet_info *pinfo,
        }
        offset += 1;
 
-       if ( connect_tree )
+       /*
+        * XXX - sometimes it appears that this stuff isn't present
+        * in the packet.
+        */
+       if (offset + 16 <= tns_offset+cd_offset)
        {
-               proto_tree_add_item(connect_tree, hf_tns_trace_cf1, tvb,
-                       offset, 2, FALSE);
-       }
-       offset += 2;
+               if ( connect_tree )
+               {
+                       proto_tree_add_item(connect_tree, hf_tns_trace_cf1, tvb,
+                               offset, 4, FALSE);
+               }
+               offset += 4;
 
-       if ( connect_tree )
-       {
-               proto_tree_add_item(connect_tree, hf_tns_trace_cf2, tvb,
-                       offset, 2, FALSE);
-       }
-       offset += 2;
+               if ( connect_tree )
+               {
+                       proto_tree_add_item(connect_tree, hf_tns_trace_cf2, tvb,
+                               offset, 4, FALSE);
+               }
+               offset += 4;
 
-       if ( connect_tree )
-       {
-               proto_tree_add_item(connect_tree, hf_tns_trace_cid, tvb,
-                       offset, 2, FALSE);
+               if ( connect_tree )
+               {
+                       proto_tree_add_item(connect_tree, hf_tns_trace_cid, tvb,
+                               offset, 8, FALSE);
+               }
+               offset += 8;
        }
-       offset += 2;
 
        if ( connect_tree && cd_len > 0)
        {
@@ -525,7 +524,7 @@ static void dissect_tns_accept(tvbuff_t *tvb, int offset, packet_info *pinfo,
                proto_tree_add_boolean_hidden(tns_tree, hf_tns_accept, tvb,
                    0, 0, TRUE);
        }
-               
+
        if ( check_col(pinfo->cinfo, COL_INFO) )
        {
                col_append_str(pinfo->cinfo, COL_INFO, ", Accept");
@@ -537,18 +536,18 @@ static void dissect_tns_accept(tvbuff_t *tvb, int offset, packet_info *pinfo,
                        offset, 2, FALSE);
        }
        offset += 2;
-       
+
        if ( accept_tree )
        {
                proto_tree *sopt_tree = NULL;
-               
-               ti = proto_tree_add_item(accept_tree, hf_tns_service_options, 
+
+               ti = proto_tree_add_item(accept_tree, hf_tns_service_options,
                        tvb, offset, 2, FALSE);
 
                sopt_tree = proto_item_add_subtree(ti, ett_tns_sopt_flag);
 
                dissect_tns_service_options(tvb, offset, sopt_tree);
-       
+
        }
        offset += 2;
 
@@ -592,28 +591,28 @@ static void dissect_tns_accept(tvbuff_t *tvb, int offset, packet_info *pinfo,
        if ( accept_tree )
        {
                proto_tree *cflag_tree = NULL;
-               
+
                ti = proto_tree_add_item(accept_tree, hf_tns_connect_flags0, tvb,
                        offset, 1, FALSE);
 
                cflag_tree = proto_item_add_subtree(ti, ett_tns_conn_flag);
 
                dissect_tns_connect_flag(tvb, offset, cflag_tree);
-               
+
        }
        offset += 1;
 
        if ( accept_tree )
        {
                proto_tree *cflag_tree = NULL;
-               
+
                ti = proto_tree_add_item(accept_tree, hf_tns_connect_flags1, tvb,
                        offset, 1, FALSE);
 
                cflag_tree = proto_item_add_subtree(ti, ett_tns_conn_flag);
 
                dissect_tns_connect_flag(tvb, offset, cflag_tree);
-               
+
        }
        offset += 1;
 
@@ -640,7 +639,7 @@ static void dissect_tns_refuse(tvbuff_t *tvb, int offset, packet_info *pinfo,
                proto_tree_add_boolean_hidden(tns_tree, hf_tns_refuse, tvb,
                    0, 0, TRUE);
        }
-               
+
        if ( check_col(pinfo->cinfo, COL_INFO) )
        {
                col_append_str(pinfo->cinfo, COL_INFO, ", Refuse");
@@ -690,7 +689,7 @@ static void dissect_tns_abort(tvbuff_t *tvb, int offset, packet_info *pinfo,
                proto_tree_add_boolean_hidden(tns_tree, hf_tns_abort, tvb,
                    0, 0, TRUE);
        }
-               
+
        if ( check_col(pinfo->cinfo, COL_INFO) )
        {
                col_append_str(pinfo->cinfo, COL_INFO, ", Abort");
@@ -741,7 +740,7 @@ static void dissect_tns_marker(tvbuff_t *tvb, int offset, packet_info *pinfo,
                proto_tree_add_boolean_hidden(tns_tree, hf_tns_marker, tvb,
                    0, 0, TRUE);
        }
-               
+
        if ( check_col(pinfo->cinfo, COL_INFO) )
        {
                if ( is_attention )
@@ -792,7 +791,7 @@ static void dissect_tns_redirect(tvbuff_t *tvb, int offset, packet_info *pinfo,
                proto_tree_add_boolean_hidden(tns_tree, hf_tns_redirect, tvb,
                    0, 0, TRUE);
        }
-               
+
        if ( check_col(pinfo->cinfo, COL_INFO) )
        {
                col_append_str(pinfo->cinfo, COL_INFO, ", Redirect");
@@ -827,7 +826,7 @@ static void dissect_tns_control(tvbuff_t *tvb, int offset, packet_info *pinfo,
                proto_tree_add_boolean_hidden(tns_tree, hf_tns_control, tvb,
                    0, 0, TRUE);
        }
-               
+
        if ( check_col(pinfo->cinfo, COL_INFO) )
        {
                col_append_str(pinfo->cinfo, COL_INFO, ", Control");
@@ -857,11 +856,28 @@ get_tns_pdu_len(tvbuff_t *tvb, int offset)
         return tvb_get_ntohs(tvb, offset);
 }
 
-static void
+static int
 dissect_tns(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 {
+       guint8 type;
+
+       /*
+        * First, do a sanity check to make sure what we have
+        * starts with a TNS PDU.
+        */
+       if (tvb_bytes_exist(tvb, 4, 1)) {
+               /*
+                * Well, we have the packet type; let's make sure
+                * it's a known type.
+                */
+               type = tvb_get_guint8(tvb, 4);
+               if (type < TNS_TYPE_CONNECT || type > TNS_TYPE_MAX)
+                       return 0;       /* it's not a known type */
+       }
+
        tcp_dissect_pdus(tvb, pinfo, tree, tns_desegment, 2,
            get_tns_pdu_len, dissect_tns_pdu);
+       return tvb_length(tvb);
 }
 
 static void
@@ -878,10 +894,10 @@ dissect_tns_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        if (check_col(pinfo->cinfo, COL_INFO))
        {
                col_add_str(pinfo->cinfo, COL_INFO,
-                       (pinfo->match_port == pinfo->destport) ? "Request" : "Response");         
+                       (pinfo->match_port == pinfo->destport) ? "Request" : "Response");
        }
 
-       if (tree) 
+       if (tree)
        {
                ti = proto_tree_add_item(tree, proto_tns, tvb, 0, -1, FALSE);
                tns_tree = proto_item_add_subtree(ti, ett_tns);
@@ -981,305 +997,305 @@ dissect_tns_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 void proto_register_tns(void)
 {
        static hf_register_info hf[] = {
-               { &hf_tns_response, { 
-                       "Response", "tns.response", FT_BOOLEAN, BASE_NONE, 
+               { &hf_tns_response, {
+                       "Response", "tns.response", FT_BOOLEAN, BASE_NONE,
                        NULL, 0x0, "TRUE if TNS response", HFILL }},
-               { &hf_tns_request, { 
-                       "Request", "tns.request", FT_BOOLEAN, BASE_NONE, 
+               { &hf_tns_request, {
+                       "Request", "tns.request", FT_BOOLEAN, BASE_NONE,
                        NULL, 0x0, "TRUE if TNS request", HFILL }},
-               { &hf_tns_length, {     
-                       "Packet Length", "tns.length", FT_UINT16, BASE_DEC, 
+               { &hf_tns_length, {
+                       "Packet Length", "tns.length", FT_UINT16, BASE_DEC,
                        NULL, 0x0, "Length of TNS packet", HFILL }},
-               { &hf_tns_packet_checksum, {    
-                       "Packet Checksum", "tns.packet_checksum", FT_UINT16, BASE_HEX, 
+               { &hf_tns_packet_checksum, {
+                       "Packet Checksum", "tns.packet_checksum", FT_UINT16, BASE_HEX,
                        NULL, 0x0, "Checksum of Packet Data", HFILL }},
-               { &hf_tns_header_checksum, {    
-                       "Header Checksum", "tns.header_checksum", FT_UINT16, BASE_HEX, 
+               { &hf_tns_header_checksum, {
+                       "Header Checksum", "tns.header_checksum", FT_UINT16, BASE_HEX,
                        NULL, 0x0, "Checksum of Header Data", HFILL }},
-                       
-               { &hf_tns_version, {    
-                       "Version", "tns.version", FT_UINT16, BASE_DEC, 
+
+               { &hf_tns_version, {
+                       "Version", "tns.version", FT_UINT16, BASE_DEC,
                        NULL, 0x0, "Version", HFILL }},
-               { &hf_tns_compat_version, {     
-                       "Version (Compatible)", "tns.compat_version", FT_UINT16, BASE_DEC, 
+               { &hf_tns_compat_version, {
+                       "Version (Compatible)", "tns.compat_version", FT_UINT16, BASE_DEC,
                        NULL, 0x0, "Version (Compatible)", HFILL }},
 
-               { &hf_tns_service_options, {    
-                       "Service Options", "tns.service_options", FT_UINT16, BASE_HEX, 
+               { &hf_tns_service_options, {
+                       "Service Options", "tns.service_options", FT_UINT16, BASE_HEX,
                        NULL, 0x0, "Service Options", HFILL }},
 
-               { &hf_tns_sopt_flag_bconn, {    
-                       "Broken Connect Notify", "tns.so_flag.bconn", FT_UINT16, BASE_BIN, 
+               { &hf_tns_sopt_flag_bconn, {
+                       "Broken Connect Notify", "tns.so_flag.bconn", FT_BOOLEAN, 16,
                        NULL, 0x2000, "Broken Connect Notify", HFILL }},
-               { &hf_tns_sopt_flag_pc, {       
-                       "Packet Checksum", "tns.so_flag.pc", FT_UINT16, BASE_BIN, 
+               { &hf_tns_sopt_flag_pc, {
+                       "Packet Checksum", "tns.so_flag.pc", FT_BOOLEAN, 16,
                        NULL, 0x1000, "Packet Checksum", HFILL }},
-               { &hf_tns_sopt_flag_hc, {       
-                       "Header Checksum", "tns.so_flag.hc", FT_UINT16, BASE_BIN, 
+               { &hf_tns_sopt_flag_hc, {
+                       "Header Checksum", "tns.so_flag.hc", FT_BOOLEAN, 16,
                        NULL, 0x0800, "Header Checksum", HFILL }},
-               { &hf_tns_sopt_flag_fd, {       
-                       "Full Duplex", "tns.so_flag.fd", FT_UINT16, BASE_BIN, 
+               { &hf_tns_sopt_flag_fd, {
+                       "Full Duplex", "tns.so_flag.fd", FT_BOOLEAN, 16,
                        NULL, 0x0400, "Full Duplex", HFILL }},
-               { &hf_tns_sopt_flag_hd, {       
-                       "Half Duplex", "tns.so_flag.hd", FT_UINT16, BASE_BIN, 
+               { &hf_tns_sopt_flag_hd, {
+                       "Half Duplex", "tns.so_flag.hd", FT_BOOLEAN, 16,
                        NULL, 0x0200, "Half Duplex", HFILL }},
-               { &hf_tns_sopt_flag_dc1, {      
-                       "Don't Care", "tns.so_flag.dc1", FT_UINT16, BASE_BIN, 
+               { &hf_tns_sopt_flag_dc1, {
+                       "Don't Care", "tns.so_flag.dc1", FT_BOOLEAN, 16,
                        NULL, 0x0100, "Don't Care", HFILL }},
-               { &hf_tns_sopt_flag_dc2, {      
-                       "Don't Care", "tns.so_flag.dc2", FT_UINT16, BASE_BIN, 
-                       NULL, 0x0080, "Don't Care", HFILL }},           
-               { &hf_tns_sopt_flag_dio, {      
-                       "Direct IO to Transport", "tns.so_flag.dio", FT_UINT16, BASE_BIN, 
+               { &hf_tns_sopt_flag_dc2, {
+                       "Don't Care", "tns.so_flag.dc2", FT_BOOLEAN, 16,
+                       NULL, 0x0080, "Don't Care", HFILL }},
+               { &hf_tns_sopt_flag_dio, {
+                       "Direct IO to Transport", "tns.so_flag.dio", FT_BOOLEAN, 16,
                        NULL, 0x0010, "Direct IO to Transport", HFILL }},
-               { &hf_tns_sopt_flag_ap, {       
-                       "Attention Processing", "tns.so_flag.ap", FT_UINT16, BASE_BIN, 
+               { &hf_tns_sopt_flag_ap, {
+                       "Attention Processing", "tns.so_flag.ap", FT_BOOLEAN, 16,
                        NULL, 0x0008, "Attention Processing", HFILL }},
-               { &hf_tns_sopt_flag_ra, {       
-                       "Can Receive Attention", "tns.so_flag.ra", FT_UINT16, BASE_BIN, 
+               { &hf_tns_sopt_flag_ra, {
+                       "Can Receive Attention", "tns.so_flag.ra", FT_BOOLEAN, 16,
                        NULL, 0x0004, "Can Receive Attention", HFILL }},
-               { &hf_tns_sopt_flag_sa, {       
-                       "Can Send Attention", "tns.so_flag.sa", FT_UINT16, BASE_BIN, 
+               { &hf_tns_sopt_flag_sa, {
+                       "Can Send Attention", "tns.so_flag.sa", FT_BOOLEAN, 16,
                        NULL, 0x0002, "Can Send Attention", HFILL }},
 
 
-               { &hf_tns_sdu_size, {   
-                       "Session Data Unit Size", "tns.sdu_size", FT_UINT16, BASE_DEC, 
+               { &hf_tns_sdu_size, {
+                       "Session Data Unit Size", "tns.sdu_size", FT_UINT16, BASE_DEC,
                        NULL, 0x0, "Session Data Unit Size", HFILL }},
-               { &hf_tns_max_tdu_size, {       
-                       "Maximum Transmission Data Unit Size", "tns.max_tdu_size", FT_UINT16, BASE_DEC, 
+               { &hf_tns_max_tdu_size, {
+                       "Maximum Transmission Data Unit Size", "tns.max_tdu_size", FT_UINT16, BASE_DEC,
                        NULL, 0x0, "Maximum Transmission Data Unit Size", HFILL }},
 
-               { &hf_tns_nt_proto_characteristics, {   
-                       "NT Protocol Characteristics", "tns.nt_proto_characteristics", FT_UINT16, BASE_HEX, 
+               { &hf_tns_nt_proto_characteristics, {
+                       "NT Protocol Characteristics", "tns.nt_proto_characteristics", FT_UINT16, BASE_HEX,
                        NULL, 0x0, "NT Protocol Characteristics", HFILL }},
-               { &hf_tns_ntp_flag_hangon, {    
-                       "Hangon to listener connect", "tns.ntp_flag.hangon", FT_UINT16, BASE_BIN, 
+               { &hf_tns_ntp_flag_hangon, {
+                       "Hangon to listener connect", "tns.ntp_flag.hangon", FT_BOOLEAN, 16,
                        NULL, 0x8000, "Hangon to listener connect", HFILL }},
-               { &hf_tns_ntp_flag_crel, {      
-                       "Confirmed release", "tns.ntp_flag.crel", FT_UINT16, BASE_BIN, 
+               { &hf_tns_ntp_flag_crel, {
+                       "Confirmed release", "tns.ntp_flag.crel", FT_BOOLEAN, 16,
                        NULL, 0x4000, "Confirmed release", HFILL }},
-               { &hf_tns_ntp_flag_tduio, {     
-                       "TDU based IO", "tns.ntp_flag.tduio", FT_UINT16, BASE_BIN, 
+               { &hf_tns_ntp_flag_tduio, {
+                       "TDU based IO", "tns.ntp_flag.tduio", FT_BOOLEAN, 16,
                        NULL, 0x2000, "TDU based IO", HFILL }},
-               { &hf_tns_ntp_flag_srun, {      
-                       "Spawner running", "tns.ntp_flag.srun", FT_UINT16, BASE_BIN, 
+               { &hf_tns_ntp_flag_srun, {
+                       "Spawner running", "tns.ntp_flag.srun", FT_BOOLEAN, 16,
                        NULL, 0x1000, "Spawner running", HFILL }},
-               { &hf_tns_ntp_flag_dtest, {     
-                       "Data test", "tns.ntp_flag.dtest", FT_UINT16, BASE_BIN, 
+               { &hf_tns_ntp_flag_dtest, {
+                       "Data test", "tns.ntp_flag.dtest", FT_BOOLEAN, 16,
                        NULL, 0x0800, "Data Test", HFILL }},
-               { &hf_tns_ntp_flag_cbio, {      
-                       "Callback IO supported", "tns.ntp_flag.cbio", FT_UINT16, BASE_BIN, 
+               { &hf_tns_ntp_flag_cbio, {
+                       "Callback IO supported", "tns.ntp_flag.cbio", FT_BOOLEAN, 16,
                        NULL, 0x0400, "Callback IO supported", HFILL }},
-               { &hf_tns_ntp_flag_asio, {      
-                       "ASync IO Supported", "tns.ntp_flag.asio", FT_UINT16, BASE_BIN, 
+               { &hf_tns_ntp_flag_asio, {
+                       "ASync IO Supported", "tns.ntp_flag.asio", FT_BOOLEAN, 16,
                        NULL, 0x0200, "ASync IO Supported", HFILL }},
-               { &hf_tns_ntp_flag_pio, {       
-                       "Packet oriented IO", "tns.ntp_flag.pio", FT_UINT16, BASE_BIN, 
+               { &hf_tns_ntp_flag_pio, {
+                       "Packet oriented IO", "tns.ntp_flag.pio", FT_BOOLEAN, 16,
                        NULL, 0x0100, "Packet oriented IO", HFILL }},
-               { &hf_tns_ntp_flag_grant, {     
-                       "Can grant connection to another", "tns.ntp_flag.grant", FT_UINT16, BASE_BIN, 
+               { &hf_tns_ntp_flag_grant, {
+                       "Can grant connection to another", "tns.ntp_flag.grant", FT_BOOLEAN, 16,
                        NULL, 0x0080, "Can grant connection to another", HFILL }},
-               { &hf_tns_ntp_flag_handoff, {   
-                       "Can handoff connection to another", "tns.ntp_flag.handoff", FT_UINT16, BASE_BIN, 
+               { &hf_tns_ntp_flag_handoff, {
+                       "Can handoff connection to another", "tns.ntp_flag.handoff", FT_BOOLEAN, 16,
                        NULL, 0x0040, "Can handoff connection to another", HFILL }},
-               { &hf_tns_ntp_flag_sigio, {     
-                       "Generate SIGIO signal", "tns.ntp_flag.sigio", FT_UINT16, BASE_BIN, 
+               { &hf_tns_ntp_flag_sigio, {
+                       "Generate SIGIO signal", "tns.ntp_flag.sigio", FT_BOOLEAN, 16,
                        NULL, 0x0020, "Generate SIGIO signal", HFILL }},
-               { &hf_tns_ntp_flag_sigpipe, {   
-                       "Generate SIGPIPE signal", "tns.ntp_flag.sigpipe", FT_UINT16, BASE_BIN, 
+               { &hf_tns_ntp_flag_sigpipe, {
+                       "Generate SIGPIPE signal", "tns.ntp_flag.sigpipe", FT_BOOLEAN, 16,
                        NULL, 0x0010, "Generate SIGPIPE signal", HFILL }},
-               { &hf_tns_ntp_flag_sigurg, {    
-                       "Generate SIGURG signal", "tns.ntp_flag.sigurg", FT_UINT16, BASE_BIN, 
+               { &hf_tns_ntp_flag_sigurg, {
+                       "Generate SIGURG signal", "tns.ntp_flag.sigurg", FT_BOOLEAN, 16,
                        NULL, 0x0008, "Generate SIGURG signal", HFILL }},
-               { &hf_tns_ntp_flag_urgentio, {  
-                       "Urgent IO supported", "tns.ntp_flag.urgentio", FT_UINT16, BASE_BIN, 
+               { &hf_tns_ntp_flag_urgentio, {
+                       "Urgent IO supported", "tns.ntp_flag.urgentio", FT_BOOLEAN, 16,
                        NULL, 0x0004, "Urgent IO supported", HFILL }},
-               { &hf_tns_ntp_flag_fdio, {      
-                       "Full duplex IO supported", "tns.ntp_flag.dfio", FT_UINT16, BASE_BIN, 
+               { &hf_tns_ntp_flag_fdio, {
+                       "Full duplex IO supported", "tns.ntp_flag.dfio", FT_BOOLEAN, 16,
                        NULL, 0x0002, "Full duplex IO supported", HFILL }},
-               { &hf_tns_ntp_flag_testop, {    
-                       "Test operation", "tns.ntp_flag.testop", FT_UINT16, BASE_BIN, 
+               { &hf_tns_ntp_flag_testop, {
+                       "Test operation", "tns.ntp_flag.testop", FT_BOOLEAN, 16,
                        NULL, 0x0001, "Test operation", HFILL }},
 
 
 
 
-               { &hf_tns_line_turnaround, {    
-                       "Line Turnaround Value", "tns.line_turnaround", FT_UINT16, BASE_DEC, 
+               { &hf_tns_line_turnaround, {
+                       "Line Turnaround Value", "tns.line_turnaround", FT_UINT16, BASE_DEC,
                        NULL, 0x0, "Line Turnaround Value", HFILL }},
-               { &hf_tns_value_of_one, {       
-                       "Value of 1 in Hardware", "tns.value_of_one", FT_BYTES, BASE_NONE, 
-                       NULL, 0x0, "Value of 1 in Hardware", HFILL }},          
+               { &hf_tns_value_of_one, {
+                       "Value of 1 in Hardware", "tns.value_of_one", FT_BYTES, BASE_NONE,
+                       NULL, 0x0, "Value of 1 in Hardware", HFILL }},
 
-               { &hf_tns_connect, { 
-                       "Connect", "tns.connect", FT_BOOLEAN, BASE_NONE, 
+               { &hf_tns_connect, {
+                       "Connect", "tns.connect", FT_BOOLEAN, BASE_NONE,
                        NULL, 0x0, "Connect", HFILL }},
-               { &hf_tns_connect_data_length, {        
-                       "Length of Connect Data", "tns.connect_data_length", FT_UINT16, BASE_DEC, 
+               { &hf_tns_connect_data_length, {
+                       "Length of Connect Data", "tns.connect_data_length", FT_UINT16, BASE_DEC,
                        NULL, 0x0, "Length of Connect Data", HFILL }},
-               { &hf_tns_connect_data_offset, {        
-                       "Offset to Connect Data", "tns.connect_data_offset", FT_UINT16, BASE_DEC, 
+               { &hf_tns_connect_data_offset, {
+                       "Offset to Connect Data", "tns.connect_data_offset", FT_UINT16, BASE_DEC,
                        NULL, 0x0, "Offset to Connect Data", HFILL }},
-               { &hf_tns_connect_data_max, {   
-                       "Maximum Receivable Connect Data", "tns.connect_data_max", FT_UINT32, BASE_DEC, 
+               { &hf_tns_connect_data_max, {
+                       "Maximum Receivable Connect Data", "tns.connect_data_max", FT_UINT32, BASE_DEC,
                        NULL, 0x0, "Maximum Receivable Connect Data", HFILL }},
 
-               { &hf_tns_connect_flags0, {     
-                       "Connect Flags 0", "tns.connect_flags0", FT_UINT8, BASE_HEX, 
+               { &hf_tns_connect_flags0, {
+                       "Connect Flags 0", "tns.connect_flags0", FT_UINT8, BASE_HEX,
                        NULL, 0x0, "Connect Flags 0", HFILL }},
-               { &hf_tns_connect_flags1, {     
-                       "Connect Flags 1", "tns.connect_flags1", FT_UINT8, BASE_HEX, 
+               { &hf_tns_connect_flags1, {
+                       "Connect Flags 1", "tns.connect_flags1", FT_UINT8, BASE_HEX,
                        NULL, 0x0, "Connect Flags 1", HFILL }},
 
-               { &hf_tns_conn_flag_nareq, {    
-                       "NA services required", "tns.connect_flags.nareq", FT_UINT8, BASE_BIN, 
+               { &hf_tns_conn_flag_nareq, {
+                       "NA services required", "tns.connect_flags.nareq", FT_BOOLEAN, 8,
                        NULL, 0x10, "NA services required", HFILL }},
-               { &hf_tns_conn_flag_nalink, {   
-                       "NA services linked in", "tns.connect_flags.nalink", FT_UINT8, BASE_BIN, 
+               { &hf_tns_conn_flag_nalink, {
+                       "NA services linked in", "tns.connect_flags.nalink", FT_BOOLEAN, 8,
                        NULL, 0x08, "NA services linked in", HFILL }},
-               { &hf_tns_conn_flag_enablena, {         
-                       "NA services enabled", "tns.connect_flags.enablena", FT_UINT8, BASE_BIN, 
+               { &hf_tns_conn_flag_enablena, {
+                       "NA services enabled", "tns.connect_flags.enablena", FT_BOOLEAN, 8,
                        NULL, 0x04, "NA services enabled", HFILL }},
-               { &hf_tns_conn_flag_ichg, {     
-                       "Interchange is involved", "tns.connect_flags.ichg", FT_UINT8, BASE_BIN, 
+               { &hf_tns_conn_flag_ichg, {
+                       "Interchange is involved", "tns.connect_flags.ichg", FT_BOOLEAN, 8,
                        NULL, 0x02, "Interchange is involved", HFILL }},
-               { &hf_tns_conn_flag_wantna, {   
-                       "NA services wanted", "tns.connect_flags.wantna", FT_UINT8, BASE_BIN, 
+               { &hf_tns_conn_flag_wantna, {
+                       "NA services wanted", "tns.connect_flags.wantna", FT_BOOLEAN, 8,
                        NULL, 0x01, "NA services wanted", HFILL }},
 
 
-               { &hf_tns_trace_cf1, {  
-                       "Trace Cross Facility Item 1", "tns.trace_cf1", FT_UINT16, BASE_HEX, 
+               { &hf_tns_trace_cf1, {
+                       "Trace Cross Facility Item 1", "tns.trace_cf1", FT_UINT32, BASE_HEX,
                        NULL, 0x0, "Trace Cross Facility Item 1", HFILL }},
-               { &hf_tns_trace_cf2, {  
-                       "Trace Cross Facility Item 2", "tns.trace_cf2", FT_UINT16, BASE_HEX, 
+               { &hf_tns_trace_cf2, {
+                       "Trace Cross Facility Item 2", "tns.trace_cf2", FT_UINT32, BASE_HEX,
                        NULL, 0x0, "Trace Cross Facility Item 2", HFILL }},
-               { &hf_tns_trace_cid, {  
-                       "Trace Unique Connection ID", "tns.trace_cid", FT_UINT16, BASE_HEX, 
+               { &hf_tns_trace_cid, {
+                       "Trace Unique Connection ID", "tns.trace_cid", FT_UINT64, BASE_HEX,
                        NULL, 0x0, "Trace Unique Connection ID", HFILL }},
-               { &hf_tns_connect_data, {       
-                       "Connect Data", "tns.connect_data", FT_STRING, BASE_NONE, 
+               { &hf_tns_connect_data, {
+                       "Connect Data", "tns.connect_data", FT_STRING, BASE_NONE,
                        NULL, 0x0, "Connect Data", HFILL }},
 
-               { &hf_tns_accept, { 
-                       "Accept", "tns.accept", FT_BOOLEAN, BASE_NONE, 
-                       NULL, 0x0, "Accept", HFILL }},          
-               { &hf_tns_accept_data_length, {         
-                       "Accept Data Length", "tns.accept_data_length", FT_UINT16, BASE_HEX, 
+               { &hf_tns_accept, {
+                       "Accept", "tns.accept", FT_BOOLEAN, BASE_NONE,
+                       NULL, 0x0, "Accept", HFILL }},
+               { &hf_tns_accept_data_length, {
+                       "Accept Data Length", "tns.accept_data_length", FT_UINT16, BASE_DEC,
                        NULL, 0x0, "Length of Accept Data", HFILL }},
-               { &hf_tns_accept_data, {        
-                       "Accept Data", "tns.accept_data", FT_STRING, BASE_NONE, 
+               { &hf_tns_accept_data, {
+                       "Accept Data", "tns.accept_data", FT_STRING, BASE_NONE,
                        NULL, 0x0, "Accept Data", HFILL }},
-               { &hf_tns_accept_data_offset, {         
-                       "Offset to Accept Data", "tns.accept_data_offset", FT_UINT16, BASE_DEC, 
+               { &hf_tns_accept_data_offset, {
+                       "Offset to Accept Data", "tns.accept_data_offset", FT_UINT16, BASE_DEC,
                        NULL, 0x0, "Offset to Accept Data", HFILL }},
 
 
-               { &hf_tns_refuse, { 
-                       "Refuse", "tns.refuse", FT_BOOLEAN, BASE_NONE, 
-                       NULL, 0x0, "Refuse", HFILL }},          
-               { &hf_tns_refuse_reason_user, {         
-                       "Refuse Reason (User)", "tns.refuse_reason_user", FT_UINT8, BASE_HEX, 
+               { &hf_tns_refuse, {
+                       "Refuse", "tns.refuse", FT_BOOLEAN, BASE_NONE,
+                       NULL, 0x0, "Refuse", HFILL }},
+               { &hf_tns_refuse_reason_user, {
+                       "Refuse Reason (User)", "tns.refuse_reason_user", FT_UINT8, BASE_HEX,
                        NULL, 0x0, "Refuse Reason from Application", HFILL }},
-               { &hf_tns_refuse_reason_system, {       
-                       "Refuse Reason (User)", "tns.refuse_reason_system", FT_UINT8, BASE_HEX, 
+               { &hf_tns_refuse_reason_system, {
+                       "Refuse Reason (System)", "tns.refuse_reason_system", FT_UINT8, BASE_HEX,
                        NULL, 0x0, "Refuse Reason from System", HFILL }},
-               { &hf_tns_refuse_data_length, {         
-                       "Refuse Data Length", "tns.refuse_data_length", FT_UINT16, BASE_HEX, 
+               { &hf_tns_refuse_data_length, {
+                       "Refuse Data Length", "tns.refuse_data_length", FT_UINT16, BASE_DEC,
                        NULL, 0x0, "Length of Refuse Data", HFILL }},
-               { &hf_tns_refuse_data, {        
-                       "Refuse Data", "tns.refuse_data", FT_STRING, BASE_NONE, 
+               { &hf_tns_refuse_data, {
+                       "Refuse Data", "tns.refuse_data", FT_STRING, BASE_NONE,
                        NULL, 0x0, "Refuse Data", HFILL }},
 
-               { &hf_tns_abort, { 
-                       "Abort", "tns.abort", FT_BOOLEAN, BASE_NONE, 
-                       NULL, 0x0, "Abort", HFILL }},           
-               { &hf_tns_abort_reason_user, {  
-                       "Abort Reason (User)", "tns.abort_reason_user", FT_UINT8, BASE_HEX, 
+               { &hf_tns_abort, {
+                       "Abort", "tns.abort", FT_BOOLEAN, BASE_NONE,
+                       NULL, 0x0, "Abort", HFILL }},
+               { &hf_tns_abort_reason_user, {
+                       "Abort Reason (User)", "tns.abort_reason_user", FT_UINT8, BASE_HEX,
                        NULL, 0x0, "Abort Reason from Application", HFILL }},
-               { &hf_tns_abort_reason_system, {        
-                       "Abort Reason (User)", "tns.abort_reason_system", FT_UINT8, BASE_HEX, 
+               { &hf_tns_abort_reason_system, {
+                       "Abort Reason (User)", "tns.abort_reason_system", FT_UINT8, BASE_HEX,
                        NULL, 0x0, "Abort Reason from System", HFILL }},
-               { &hf_tns_abort_data, {         
-                       "Abort Data", "tns.abort_data", FT_STRING, BASE_NONE, 
+               { &hf_tns_abort_data, {
+                       "Abort Data", "tns.abort_data", FT_STRING, BASE_NONE,
                        NULL, 0x0, "Abort Data", HFILL }},
 
-               { &hf_tns_marker, { 
-                       "Marker", "tns.marker", FT_BOOLEAN, BASE_NONE, 
-                       NULL, 0x0, "Marker", HFILL }},                          
-               { &hf_tns_marker_type, {        
-                       "Marker Type", "tns.marker.type", FT_UINT8, BASE_HEX, 
+               { &hf_tns_marker, {
+                       "Marker", "tns.marker", FT_BOOLEAN, BASE_NONE,
+                       NULL, 0x0, "Marker", HFILL }},
+               { &hf_tns_marker_type, {
+                       "Marker Type", "tns.marker.type", FT_UINT8, BASE_HEX,
                        VALS(tns_marker_types), 0x0, "Marker Type", HFILL }},
-               { &hf_tns_marker_data_byte, {   
-                       "Marker Data Byte", "tns.marker.databyte", FT_UINT8, BASE_HEX, 
+               { &hf_tns_marker_data_byte, {
+                       "Marker Data Byte", "tns.marker.databyte", FT_UINT8, BASE_HEX,
                        NULL, 0x0, "Marker Data Byte", HFILL }},
-               { &hf_tns_marker_data, {        
-                       "Marker Data", "tns.marker.data", FT_UINT16, BASE_HEX, 
+               { &hf_tns_marker_data, {
+                       "Marker Data", "tns.marker.data", FT_UINT16, BASE_HEX,
                        NULL, 0x0, "Marker Data", HFILL }},
 
-               { &hf_tns_control, { 
-                       "Control", "tns.control", FT_BOOLEAN, BASE_NONE, 
-                       NULL, 0x0, "Control", HFILL }},         
-               { &hf_tns_control_cmd, {        
-                       "Control Command", "tns.control.cmd", FT_UINT16, BASE_HEX, 
+               { &hf_tns_control, {
+                       "Control", "tns.control", FT_BOOLEAN, BASE_NONE,
+                       NULL, 0x0, "Control", HFILL }},
+               { &hf_tns_control_cmd, {
+                       "Control Command", "tns.control.cmd", FT_UINT16, BASE_HEX,
                        VALS(tns_control_cmds), 0x0, "Control Command", HFILL }},
-               { &hf_tns_control_data, {       
-                       "Control Data", "tns.control.data", FT_BYTES, BASE_HEX, 
+               { &hf_tns_control_data, {
+                       "Control Data", "tns.control.data", FT_BYTES, BASE_HEX,
                        NULL, 0x0, "Control Data", HFILL }},
 
-               { &hf_tns_redirect, { 
-                       "Redirect", "tns.redirect", FT_BOOLEAN, BASE_NONE, 
-                       NULL, 0x0, "Redirect", HFILL }},                
-               { &hf_tns_redirect_data_length, {       
-                       "Redirect Data Length", "tns.redirect_data_length", FT_UINT16, BASE_HEX, 
+               { &hf_tns_redirect, {
+                       "Redirect", "tns.redirect", FT_BOOLEAN, BASE_NONE,
+                       NULL, 0x0, "Redirect", HFILL }},
+               { &hf_tns_redirect_data_length, {
+                       "Redirect Data Length", "tns.redirect_data_length", FT_UINT16, BASE_DEC,
                        NULL, 0x0, "Length of Redirect Data", HFILL }},
-               { &hf_tns_redirect_data, {      
-                       "Redirect Data", "tns.redirect_data", FT_STRING, BASE_NONE, 
+               { &hf_tns_redirect_data, {
+                       "Redirect Data", "tns.redirect_data", FT_STRING, BASE_NONE,
                        NULL, 0x0, "Redirect Data", HFILL }},
 
-               { &hf_tns_data, { 
-                       "Data", "tns.data", FT_BOOLEAN, BASE_NONE, 
-                       NULL, 0x0, "Data", HFILL }},    
-       
-               { &hf_tns_data_flag, {  
-                       "Data Flag", "tns.data_flag", FT_UINT16, BASE_HEX, 
+               { &hf_tns_data, {
+                       "Data", "tns.data", FT_BOOLEAN, BASE_NONE,
+                       NULL, 0x0, "Data", HFILL }},
+
+               { &hf_tns_data_flag, {
+                       "Data Flag", "tns.data_flag", FT_UINT16, BASE_HEX,
                        NULL, 0x0, "Data Flag", HFILL }},
-               { &hf_tns_data_flag_send, {     
-                       "Send Token", "tns.data_flag.send", FT_UINT16, BASE_BIN, 
+               { &hf_tns_data_flag_send, {
+                       "Send Token", "tns.data_flag.send", FT_BOOLEAN, 16,
                        NULL, 0x1, "Send Token", HFILL }},
-               { &hf_tns_data_flag_rc, {       
-                       "Request Confirmation", "tns.data_flag.rc", FT_UINT16, BASE_BIN, 
+               { &hf_tns_data_flag_rc, {
+                       "Request Confirmation", "tns.data_flag.rc", FT_BOOLEAN, 16,
                        NULL, 0x2, "Request Confirmation", HFILL }},
-               { &hf_tns_data_flag_c, {        
-                       "Confirmation", "tns.data_flag.c", FT_UINT16, BASE_BIN, 
+               { &hf_tns_data_flag_c, {
+                       "Confirmation", "tns.data_flag.c", FT_BOOLEAN, 16,
                        NULL, 0x4, "Confirmation", HFILL }},
-               { &hf_tns_data_flag_reserved, {         
-                       "Reserved", "tns.data_flag.reserved", FT_UINT16, BASE_BIN, 
+               { &hf_tns_data_flag_reserved, {
+                       "Reserved", "tns.data_flag.reserved", FT_BOOLEAN, 16,
                        NULL, 0x8, "Reserved", HFILL }},
-               { &hf_tns_data_flag_more, {     
-                       "More Data to Come", "tns.data_flag.more", FT_UINT16, BASE_BIN, 
+               { &hf_tns_data_flag_more, {
+                       "More Data to Come", "tns.data_flag.more", FT_BOOLEAN, 16,
                        NULL, 0x20, "More Data to Come", HFILL }},
-               { &hf_tns_data_flag_eof, {      
-                       "End of File", "tns.data_flag.eof", FT_UINT16, BASE_BIN, 
+               { &hf_tns_data_flag_eof, {
+                       "End of File", "tns.data_flag.eof", FT_BOOLEAN, 16,
                        NULL, 0x40, "End of File", HFILL }},
-               { &hf_tns_data_flag_dic, {      
-                       "Do Immediate Confirmation", "tns.data_flag.dic", FT_UINT16, BASE_BIN, 
+               { &hf_tns_data_flag_dic, {
+                       "Do Immediate Confirmation", "tns.data_flag.dic", FT_BOOLEAN, 16,
                        NULL, 0x80, "Do Immediate Confirmation", HFILL }},
-               { &hf_tns_data_flag_rts, {      
-                       "Request To Send", "tns.data_flag.rts", FT_UINT16, BASE_BIN, 
+               { &hf_tns_data_flag_rts, {
+                       "Request To Send", "tns.data_flag.rts", FT_BOOLEAN, 16,
                        NULL, 0x100, "Request To Send", HFILL }},
-               { &hf_tns_data_flag_sntt, {     
-                       "Send NT Trailer", "tns.data_flag.sntt", FT_UINT16, BASE_BIN, 
+               { &hf_tns_data_flag_sntt, {
+                       "Send NT Trailer", "tns.data_flag.sntt", FT_BOOLEAN, 16,
                        NULL, 0x200, "Send NT Trailer", HFILL }},
 
 
-               { &hf_tns_reserved_byte, {      
-                       "Reserved Byte", "tns.reserved_byte", FT_BYTES, BASE_HEX, 
+               { &hf_tns_reserved_byte, {
+                       "Reserved Byte", "tns.reserved_byte", FT_BYTES, BASE_HEX,
                        NULL, 0x0, "Reserved Byte", HFILL }},
-               { &hf_tns_packet_type, {        
-                       "Packet Type", "tns.type", FT_UINT8, BASE_DEC, 
-                       VALS(tns_type_vals), 0x0, "Type of TNS packet", HFILL }}        
+               { &hf_tns_packet_type, {
+                       "Packet Type", "tns.type", FT_UINT8, BASE_DEC,
+                       VALS(tns_type_vals), 0x0, "Type of TNS packet", HFILL }}
 
        };
 
@@ -1319,7 +1335,7 @@ proto_reg_handoff_tns(void)
 {
        dissector_handle_t tns_handle;
 
-       tns_handle = create_dissector_handle(dissect_tns, proto_tns);
+       tns_handle = new_create_dissector_handle(dissect_tns, proto_tns);
        dissector_add("tcp.port", TCP_PORT_TNS, tns_handle);
        data_handle = find_dissector("data");
 }