2 * Routines for Oracle TNS packet dissection
4 * $Id: packet-tns.c,v 1.32 2002/06/06 13:17:49 nneul Exp $
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@ethereal.com>
8 * Copyright 1998 Gerald Combs
10 * Copied from packet-tftp.c
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
33 #ifdef HAVE_SYS_TYPES_H
34 # include <sys/types.h>
37 #ifdef HAVE_NETINET_IN_H
38 # include <netinet/in.h>
43 #include <epan/packet.h>
44 #include "packet-tns.h"
46 static int proto_tns = -1;
47 static int hf_tns_request = -1;
48 static int hf_tns_response = -1;
49 static int hf_tns_length = -1;
50 static int hf_tns_packet_checksum = -1;
51 static int hf_tns_header_checksum = -1;
52 static int hf_tns_packet_type = -1;
53 static int hf_tns_reserved_byte = -1;
54 static int hf_tns_connect = -1;
55 static int hf_tns_version = -1;
56 static int hf_tns_compat_version = -1;
58 static int hf_tns_service_options = -1;
59 static int hf_tns_sopt_flag_bconn = -1;
60 static int hf_tns_sopt_flag_pc = -1;
61 static int hf_tns_sopt_flag_hc = -1;
62 static int hf_tns_sopt_flag_fd = -1;
63 static int hf_tns_sopt_flag_hd = -1;
64 static int hf_tns_sopt_flag_dc1 = -1;
65 static int hf_tns_sopt_flag_dc2 = -1;
66 static int hf_tns_sopt_flag_dio = -1;
67 static int hf_tns_sopt_flag_ap = -1;
68 static int hf_tns_sopt_flag_ra = -1;
69 static int hf_tns_sopt_flag_sa = -1;
71 static int hf_tns_sdu_size = -1;
72 static int hf_tns_max_tdu_size = -1;
74 static int hf_tns_nt_proto_characteristics = -1;
75 static int hf_tns_ntp_flag_hangon = -1;
76 static int hf_tns_ntp_flag_crel = -1;
77 static int hf_tns_ntp_flag_tduio = -1;
78 static int hf_tns_ntp_flag_srun = -1;
79 static int hf_tns_ntp_flag_dtest = -1;
80 static int hf_tns_ntp_flag_cbio = -1;
81 static int hf_tns_ntp_flag_asio = -1;
82 static int hf_tns_ntp_flag_pio = -1;
83 static int hf_tns_ntp_flag_grant = -1;
84 static int hf_tns_ntp_flag_handoff = -1;
85 static int hf_tns_ntp_flag_sigio = -1;
86 static int hf_tns_ntp_flag_sigpipe = -1;
87 static int hf_tns_ntp_flag_sigurg = -1;
88 static int hf_tns_ntp_flag_urgentio = -1;
89 static int hf_tns_ntp_flag_fdio = -1;
90 static int hf_tns_ntp_flag_testop = -1;
92 static int hf_tns_line_turnaround = -1;
93 static int hf_tns_value_of_one = -1;
94 static int hf_tns_connect_data_length = -1;
95 static int hf_tns_connect_data_offset = -1;
96 static int hf_tns_connect_data_max = -1;
98 static int hf_tns_connect_flags0 = -1;
99 static int hf_tns_connect_flags1 = -1;
100 static int hf_tns_conn_flag_nareq = -1;
101 static int hf_tns_conn_flag_nalink = -1;
102 static int hf_tns_conn_flag_enablena = -1;
103 static int hf_tns_conn_flag_ichg = -1;
104 static int hf_tns_conn_flag_wantna = -1;
106 static int hf_tns_connect_data = -1;
107 static int hf_tns_trace_cf1 = -1;
108 static int hf_tns_trace_cf2 = -1;
109 static int hf_tns_trace_cid = -1;
111 static int hf_tns_accept = -1;
112 static int hf_tns_accept_data_length = -1;
113 static int hf_tns_accept_data_offset = -1;
114 static int hf_tns_accept_data = -1;
116 static int hf_tns_refuse = -1;
117 static int hf_tns_refuse_reason_user = -1;
118 static int hf_tns_refuse_reason_system = -1;
119 static int hf_tns_refuse_data_length = -1;
120 static int hf_tns_refuse_data = -1;
122 static int hf_tns_abort = -1;
123 static int hf_tns_abort_reason_user = -1;
124 static int hf_tns_abort_reason_system = -1;
125 static int hf_tns_abort_data = -1;
127 static int hf_tns_marker = -1;
128 static int hf_tns_marker_type = -1;
129 static int hf_tns_marker_data_byte = -1;
130 static int hf_tns_marker_data = -1;
132 static int hf_tns_redirect = -1;
133 static int hf_tns_redirect_data_length = -1;
134 static int hf_tns_redirect_data = -1;
136 static int hf_tns_control = -1;
137 static int hf_tns_control_cmd = -1;
138 static int hf_tns_control_data = -1;
140 static int hf_tns_data_flag = -1;
141 static int hf_tns_data_flag_send = -1;
142 static int hf_tns_data_flag_rc = -1;
143 static int hf_tns_data_flag_c = -1;
144 static int hf_tns_data_flag_reserved = -1;
145 static int hf_tns_data_flag_more = -1;
146 static int hf_tns_data_flag_eof = -1;
147 static int hf_tns_data_flag_dic = -1;
148 static int hf_tns_data_flag_rts = -1;
149 static int hf_tns_data_flag_sntt = -1;
150 static int hf_tns_data = -1;
152 static gint ett_tns = -1;
153 static gint ett_tns_connect = -1;
154 static gint ett_tns_accept = -1;
155 static gint ett_tns_refuse = -1;
156 static gint ett_tns_abort = -1;
157 static gint ett_tns_redirect = -1;
158 static gint ett_tns_marker = -1;
159 static gint ett_tns_attention = -1;
160 static gint ett_tns_control = -1;
161 static gint ett_tns_data = -1;
162 static gint ett_tns_data_flag = -1;
163 static gint ett_tns_sopt_flag = -1;
164 static gint ett_tns_ntp_flag = -1;
165 static gint ett_tns_conn_flag = -1;
166 static gint ett_sql = -1;
168 static dissector_handle_t data_handle;
170 #define TCP_PORT_TNS 1521
172 static const value_string tns_type_vals[] = {
173 {TNS_TYPE_CONNECT, "Connect" },
174 {TNS_TYPE_ACCEPT, "Accept" },
175 {TNS_TYPE_ACK, "Acknowledge" },
176 {TNS_TYPE_REFUSE, "Refuse" },
177 {TNS_TYPE_REDIRECT, "Redirect" },
178 {TNS_TYPE_DATA, "Data" },
179 {TNS_TYPE_NULL, "Null" },
180 {TNS_TYPE_ABORT, "Abort" },
181 {TNS_TYPE_RESEND, "Resend"},
182 {TNS_TYPE_MARKER, "Marker"},
183 {TNS_TYPE_ATTENTION, "Attention"},
184 {TNS_TYPE_CONTROL, "Control"},
188 static const value_string tns_marker_types[] = {
189 {0, "Data Marker - 0 Data Bytes"},
190 {1, "Data Marker - 1 Data Bytes"},
191 {2, "Attention Marker"},
195 static const value_string tns_control_cmds[] = {
196 {1, "Oracle Trace Command"},
200 static void dissect_tns_service_options(tvbuff_t *tvb, int offset,
201 proto_tree *sopt_tree)
204 proto_tree_add_item(sopt_tree, hf_tns_sopt_flag_bconn, tvb,
206 proto_tree_add_item(sopt_tree, hf_tns_sopt_flag_pc, tvb,
208 proto_tree_add_item(sopt_tree, hf_tns_sopt_flag_hc, tvb,
210 proto_tree_add_item(sopt_tree, hf_tns_sopt_flag_fd, tvb,
212 proto_tree_add_item(sopt_tree, hf_tns_sopt_flag_hd, tvb,
214 proto_tree_add_item(sopt_tree, hf_tns_sopt_flag_dc1, tvb,
216 proto_tree_add_item(sopt_tree, hf_tns_sopt_flag_dc2, tvb,
218 proto_tree_add_item(sopt_tree, hf_tns_sopt_flag_dio, tvb,
220 proto_tree_add_item(sopt_tree, hf_tns_sopt_flag_ap, tvb,
222 proto_tree_add_item(sopt_tree, hf_tns_sopt_flag_ra, tvb,
224 proto_tree_add_item(sopt_tree, hf_tns_sopt_flag_sa, tvb,
229 static void dissect_tns_connect_flag(tvbuff_t *tvb, int offset,
230 proto_tree *cflag_tree)
233 proto_tree_add_item(cflag_tree, hf_tns_conn_flag_nareq, tvb, offset, 1, FALSE);
234 proto_tree_add_item(cflag_tree, hf_tns_conn_flag_nalink, tvb, offset, 1, FALSE);
235 proto_tree_add_item(cflag_tree, hf_tns_conn_flag_enablena, tvb, offset, 1, FALSE);
236 proto_tree_add_item(cflag_tree, hf_tns_conn_flag_ichg, tvb, offset, 1, FALSE);
237 proto_tree_add_item(cflag_tree, hf_tns_conn_flag_wantna, tvb, offset, 1, FALSE);
240 static void dissect_tns_data(tvbuff_t *tvb, int offset, packet_info *pinfo,
241 proto_tree *tree, proto_tree *tns_tree)
243 proto_tree *data_tree = NULL, *ti;
246 if ( tvb_bytes_exist(tvb, offset+2, 4) )
248 if ( tvb_get_guint8(tvb, offset+2) == 0xDE &&
249 tvb_get_guint8(tvb, offset+3) == 0xAD &&
250 tvb_get_guint8(tvb, offset+4) == 0xBE &&
251 tvb_get_guint8(tvb, offset+5) == 0xEF )
261 ti = proto_tree_add_text(tns_tree, tvb, offset, -1,
262 "Secure Network Services");
266 ti = proto_tree_add_text(tns_tree, tvb, offset, -1,
269 data_tree = proto_item_add_subtree(ti, ett_tns_data);
271 proto_tree_add_boolean_hidden(tns_tree, hf_tns_data, tvb, 0, 0,
277 proto_tree *df_tree = NULL;
279 ti = proto_tree_add_item(data_tree, hf_tns_data_flag, tvb, offset, 2, FALSE);
281 df_tree = proto_item_add_subtree(ti, ett_tns_data_flag);
282 proto_tree_add_item(df_tree, hf_tns_data_flag_send, tvb, offset, 2, FALSE);
283 proto_tree_add_item(df_tree, hf_tns_data_flag_rc, tvb, offset, 2, FALSE);
284 proto_tree_add_item(df_tree, hf_tns_data_flag_c, tvb, offset, 2, FALSE);
285 proto_tree_add_item(df_tree, hf_tns_data_flag_reserved, tvb, offset, 2, FALSE);
286 proto_tree_add_item(df_tree, hf_tns_data_flag_more, tvb, offset, 2, FALSE);
287 proto_tree_add_item(df_tree, hf_tns_data_flag_eof, tvb, offset, 2, FALSE);
288 proto_tree_add_item(df_tree, hf_tns_data_flag_dic, tvb, offset, 2, FALSE);
289 proto_tree_add_item(df_tree, hf_tns_data_flag_rts, tvb, offset, 2, FALSE);
290 proto_tree_add_item(df_tree, hf_tns_data_flag_sntt, tvb, offset, 2, FALSE);
294 if ( check_col(pinfo->cinfo, COL_INFO) )
298 col_append_fstr(pinfo->cinfo, COL_INFO, ", SNS");
302 col_append_fstr(pinfo->cinfo, COL_INFO, ", Data");
308 call_dissector(data_handle,
309 tvb_new_subset(tvb, offset, -1, -1), pinfo, data_tree);
315 static void dissect_tns_connect(tvbuff_t *tvb, int offset, packet_info *pinfo,
316 proto_tree *tree, proto_tree *tns_tree)
318 proto_tree *connect_tree = NULL, *ti;
321 int tns_offset = offset-8;
325 ti = proto_tree_add_text(tns_tree, tvb, offset, -1,
327 connect_tree = proto_item_add_subtree(ti, ett_tns_connect);
329 proto_tree_add_boolean_hidden(tns_tree, hf_tns_connect, tvb,
333 if ( check_col(pinfo->cinfo, COL_INFO) )
335 col_append_str(pinfo->cinfo, COL_INFO, ", Connect");
340 proto_tree_add_item(connect_tree, hf_tns_version, tvb,
347 proto_tree_add_item(connect_tree, hf_tns_compat_version, tvb,
354 proto_tree *sopt_tree = NULL;
356 ti = proto_tree_add_item(connect_tree, hf_tns_service_options, tvb,
359 sopt_tree = proto_item_add_subtree(ti, ett_tns_sopt_flag);
361 dissect_tns_service_options(tvb, offset, sopt_tree);
369 proto_tree_add_item(connect_tree, hf_tns_sdu_size, tvb,
376 proto_tree_add_item(connect_tree, hf_tns_max_tdu_size, tvb,
383 proto_tree *ntp_tree = NULL;
385 ti = proto_tree_add_item(connect_tree, hf_tns_nt_proto_characteristics, tvb,
388 ntp_tree = proto_item_add_subtree(ti, ett_tns_ntp_flag);
390 proto_tree_add_item(ntp_tree, hf_tns_ntp_flag_hangon, tvb, offset, 2, FALSE);
391 proto_tree_add_item(ntp_tree, hf_tns_ntp_flag_crel, tvb, offset, 2, FALSE);
392 proto_tree_add_item(ntp_tree, hf_tns_ntp_flag_tduio, tvb, offset, 2, FALSE);
393 proto_tree_add_item(ntp_tree, hf_tns_ntp_flag_srun, tvb, offset, 2, FALSE);
394 proto_tree_add_item(ntp_tree, hf_tns_ntp_flag_dtest, tvb, offset, 2, FALSE);
395 proto_tree_add_item(ntp_tree, hf_tns_ntp_flag_cbio, tvb, offset, 2, FALSE);
396 proto_tree_add_item(ntp_tree, hf_tns_ntp_flag_asio, tvb, offset, 2, FALSE);
397 proto_tree_add_item(ntp_tree, hf_tns_ntp_flag_pio, tvb, offset, 2, FALSE);
398 proto_tree_add_item(ntp_tree, hf_tns_ntp_flag_grant, tvb, offset, 2, FALSE);
399 proto_tree_add_item(ntp_tree, hf_tns_ntp_flag_handoff, tvb, offset, 2, FALSE);
400 proto_tree_add_item(ntp_tree, hf_tns_ntp_flag_sigio, tvb, offset, 2, FALSE);
401 proto_tree_add_item(ntp_tree, hf_tns_ntp_flag_sigpipe, tvb, offset, 2, FALSE);
402 proto_tree_add_item(ntp_tree, hf_tns_ntp_flag_sigurg, tvb, offset, 2, FALSE);
403 proto_tree_add_item(ntp_tree, hf_tns_ntp_flag_urgentio, tvb, offset, 2, FALSE);
404 proto_tree_add_item(ntp_tree, hf_tns_ntp_flag_fdio, tvb, offset, 2, FALSE);
405 proto_tree_add_item(ntp_tree, hf_tns_ntp_flag_testop, tvb, offset, 2, FALSE);
411 proto_tree_add_item(connect_tree, hf_tns_line_turnaround, tvb,
418 proto_tree_add_item(connect_tree, hf_tns_value_of_one, tvb,
423 cd_len = tvb_get_ntohs(tvb, offset);
426 proto_tree_add_uint(connect_tree, hf_tns_connect_data_length, tvb,
431 cd_offset = tvb_get_ntohs(tvb, offset);
434 proto_tree_add_uint(connect_tree, hf_tns_connect_data_offset, tvb,
435 offset, 2, cd_offset);
441 proto_tree_add_item(connect_tree, hf_tns_connect_data_max, tvb,
448 proto_tree *cflag_tree = NULL;
450 ti = proto_tree_add_item(connect_tree, hf_tns_connect_flags0, tvb,
453 cflag_tree = proto_item_add_subtree(ti, ett_tns_conn_flag);
455 dissect_tns_connect_flag(tvb, offset, cflag_tree);
461 proto_tree *cflag_tree = NULL;
463 ti = proto_tree_add_item(connect_tree, hf_tns_connect_flags1, tvb,
466 cflag_tree = proto_item_add_subtree(ti, ett_tns_conn_flag);
468 dissect_tns_connect_flag(tvb, offset, cflag_tree);
474 proto_tree_add_item(connect_tree, hf_tns_trace_cf1, tvb,
481 proto_tree_add_item(connect_tree, hf_tns_trace_cf2, tvb,
488 proto_tree_add_item(connect_tree, hf_tns_trace_cid, tvb,
493 if ( connect_tree && cd_len > 0)
495 proto_tree_add_item(connect_tree, hf_tns_connect_data, tvb,
496 tns_offset+cd_offset, -1, FALSE);
501 static void dissect_tns_accept(tvbuff_t *tvb, int offset, packet_info *pinfo,
502 proto_tree *tree, proto_tree *tns_tree)
504 proto_tree *accept_tree = NULL, *ti;
507 int tns_offset = offset-8;
511 ti = proto_tree_add_text(tns_tree, tvb, offset, -1,
513 accept_tree = proto_item_add_subtree(ti, ett_tns_accept);
515 proto_tree_add_boolean_hidden(tns_tree, hf_tns_accept, tvb,
519 if ( check_col(pinfo->cinfo, COL_INFO) )
521 col_append_str(pinfo->cinfo, COL_INFO, ", Accept");
526 proto_tree_add_item(accept_tree, hf_tns_version, tvb,
533 proto_tree *sopt_tree = NULL;
535 ti = proto_tree_add_item(accept_tree, hf_tns_service_options,
536 tvb, offset, 2, FALSE);
538 sopt_tree = proto_item_add_subtree(ti, ett_tns_sopt_flag);
540 dissect_tns_service_options(tvb, offset, sopt_tree);
547 proto_tree_add_item(accept_tree, hf_tns_sdu_size, tvb,
554 proto_tree_add_item(accept_tree, hf_tns_max_tdu_size, tvb,
561 proto_tree_add_item(accept_tree, hf_tns_value_of_one, tvb,
566 accept_len = tvb_get_ntohs(tvb, offset);
569 proto_tree_add_uint(accept_tree, hf_tns_accept_data_length, tvb,
570 offset, 2, accept_len);
574 accept_offset = tvb_get_ntohs(tvb, offset);
577 proto_tree_add_uint(accept_tree, hf_tns_accept_data_offset, tvb,
578 offset, 2, accept_offset);
584 proto_tree *cflag_tree = NULL;
586 ti = proto_tree_add_item(accept_tree, hf_tns_connect_flags0, tvb,
589 cflag_tree = proto_item_add_subtree(ti, ett_tns_conn_flag);
591 dissect_tns_connect_flag(tvb, offset, cflag_tree);
598 proto_tree *cflag_tree = NULL;
600 ti = proto_tree_add_item(accept_tree, hf_tns_connect_flags1, tvb,
603 cflag_tree = proto_item_add_subtree(ti, ett_tns_conn_flag);
605 dissect_tns_connect_flag(tvb, offset, cflag_tree);
610 if ( accept_tree && accept_len > 0)
612 proto_tree_add_item(accept_tree, hf_tns_accept_data, tvb,
613 tns_offset+accept_offset, -1, FALSE);
619 static void dissect_tns_refuse(tvbuff_t *tvb, int offset, packet_info *pinfo,
620 proto_tree *tree, proto_tree *tns_tree)
622 proto_tree *refuse_tree = NULL, *ti;
626 ti = proto_tree_add_text(tns_tree, tvb, offset, -1,
628 refuse_tree = proto_item_add_subtree(ti, ett_tns_refuse);
630 proto_tree_add_boolean_hidden(tns_tree, hf_tns_refuse, tvb,
634 if ( check_col(pinfo->cinfo, COL_INFO) )
636 col_append_str(pinfo->cinfo, COL_INFO, ", Refuse");
641 proto_tree_add_item(refuse_tree, hf_tns_refuse_reason_user, tvb,
648 proto_tree_add_item(refuse_tree, hf_tns_refuse_reason_system, tvb,
655 proto_tree_add_item(refuse_tree, hf_tns_refuse_data_length, tvb,
662 proto_tree_add_item(refuse_tree, hf_tns_refuse_data, tvb,
669 static void dissect_tns_abort(tvbuff_t *tvb, int offset, packet_info *pinfo,
670 proto_tree *tree, proto_tree *tns_tree)
672 proto_tree *abort_tree = NULL, *ti;
676 ti = proto_tree_add_text(tns_tree, tvb, offset, -1,
678 abort_tree = proto_item_add_subtree(ti, ett_tns_abort);
680 proto_tree_add_boolean_hidden(tns_tree, hf_tns_abort, tvb,
684 if ( check_col(pinfo->cinfo, COL_INFO) )
686 col_append_str(pinfo->cinfo, COL_INFO, ", Abort");
691 proto_tree_add_item(abort_tree, hf_tns_abort_reason_user, tvb,
698 proto_tree_add_item(abort_tree, hf_tns_abort_reason_system, tvb,
705 proto_tree_add_item(abort_tree, hf_tns_abort_data, tvb,
712 static void dissect_tns_marker(tvbuff_t *tvb, int offset, packet_info *pinfo,
713 proto_tree *tree, proto_tree *tns_tree, int is_attention)
715 proto_tree *marker_tree = NULL, *ti;
721 ti = proto_tree_add_text(tns_tree, tvb, offset, -1,
726 ti = proto_tree_add_text(tns_tree, tvb, offset, -1,
730 marker_tree = proto_item_add_subtree(ti, ett_tns_marker);
731 proto_tree_add_boolean_hidden(tns_tree, hf_tns_marker, tvb,
735 if ( check_col(pinfo->cinfo, COL_INFO) )
739 col_append_str(pinfo->cinfo, COL_INFO, ", Marker");
743 col_append_str(pinfo->cinfo, COL_INFO, ", Attention");
749 proto_tree_add_item(marker_tree, hf_tns_marker_type, tvb,
756 proto_tree_add_item(marker_tree, hf_tns_marker_data_byte, tvb,
763 proto_tree_add_item(marker_tree, hf_tns_marker_data_byte, tvb,
771 static void dissect_tns_redirect(tvbuff_t *tvb, int offset, packet_info *pinfo,
772 proto_tree *tree, proto_tree *tns_tree)
774 proto_tree *redirect_tree = NULL, *ti;
778 ti = proto_tree_add_text(tns_tree, tvb, offset, -1,
780 redirect_tree = proto_item_add_subtree(ti, ett_tns_redirect);
782 proto_tree_add_boolean_hidden(tns_tree, hf_tns_redirect, tvb,
786 if ( check_col(pinfo->cinfo, COL_INFO) )
788 col_append_str(pinfo->cinfo, COL_INFO, ", Redirect");
793 proto_tree_add_item(redirect_tree, hf_tns_redirect_data_length, tvb,
800 proto_tree_add_item(redirect_tree, hf_tns_redirect_data, tvb,
806 static void dissect_tns_control(tvbuff_t *tvb, int offset, packet_info *pinfo,
807 proto_tree *tree, proto_tree *tns_tree)
809 proto_tree *control_tree = NULL, *ti;
813 ti = proto_tree_add_text(tns_tree, tvb, offset, -1,
815 control_tree = proto_item_add_subtree(ti, ett_tns_control);
817 proto_tree_add_boolean_hidden(tns_tree, hf_tns_control, tvb,
821 if ( check_col(pinfo->cinfo, COL_INFO) )
823 col_append_str(pinfo->cinfo, COL_INFO, ", Control");
828 proto_tree_add_item(control_tree, hf_tns_control_cmd, tvb,
835 proto_tree_add_item(control_tree, hf_tns_control_data, tvb,
844 dissect_tns(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
846 proto_tree *tns_tree = NULL, *ti;
851 if (check_col(pinfo->cinfo, COL_PROTOCOL))
852 col_set_str(pinfo->cinfo, COL_PROTOCOL, "TNS");
854 if (check_col(pinfo->cinfo, COL_INFO))
856 col_add_str(pinfo->cinfo, COL_INFO,
857 (pinfo->match_port == pinfo->destport) ? "Request" : "Response");
862 ti = proto_tree_add_item(tree, proto_tns, tvb, 0, -1, FALSE);
863 tns_tree = proto_item_add_subtree(ti, ett_tns);
865 if (pinfo->match_port == pinfo->destport)
867 proto_tree_add_boolean_hidden(tns_tree, hf_tns_request,
868 tvb, offset, 0, TRUE);
872 proto_tree_add_boolean_hidden(tns_tree, hf_tns_response,
873 tvb, offset, 0, TRUE);
877 length = tvb_get_ntohs(tvb, offset);
880 proto_tree_add_uint(tns_tree, hf_tns_length, tvb,
887 proto_tree_add_item(tns_tree, hf_tns_packet_checksum, tvb,
892 type = tvb_get_guint8(tvb, offset);
895 proto_tree_add_uint(tns_tree, hf_tns_packet_type, tvb,
900 if ( check_col(pinfo->cinfo, COL_INFO))
902 col_append_fstr(pinfo->cinfo, COL_INFO, ", %s (%u)",
903 val_to_str(type, tns_type_vals, "Unknown"), type);
908 proto_tree_add_item(tns_tree, hf_tns_reserved_byte, tvb,
915 proto_tree_add_item(tns_tree, hf_tns_header_checksum, tvb,
922 case TNS_TYPE_CONNECT:
923 dissect_tns_connect(tvb,offset,pinfo,tree,tns_tree);
925 case TNS_TYPE_ACCEPT:
926 dissect_tns_accept(tvb,offset,pinfo,tree,tns_tree);
928 case TNS_TYPE_REFUSE:
929 dissect_tns_refuse(tvb,offset,pinfo,tree,tns_tree);
931 case TNS_TYPE_REDIRECT:
932 dissect_tns_redirect(tvb,offset,pinfo,tree,tns_tree);
935 dissect_tns_abort(tvb,offset,pinfo,tree,tns_tree);
937 case TNS_TYPE_MARKER:
938 dissect_tns_marker(tvb,offset,pinfo,tree,tns_tree, 0);
940 case TNS_TYPE_ATTENTION:
941 dissect_tns_marker(tvb,offset,pinfo,tree,tns_tree, 1);
943 case TNS_TYPE_CONTROL:
944 dissect_tns_control(tvb,offset,pinfo,tree,tns_tree);
947 dissect_tns_data(tvb,offset,pinfo,tree,tns_tree);
950 call_dissector(data_handle,
951 tvb_new_subset(tvb, offset, -1, -1), pinfo,
957 void proto_register_tns(void)
959 static hf_register_info hf[] = {
960 { &hf_tns_response, {
961 "Response", "tns.response", FT_BOOLEAN, BASE_NONE,
962 NULL, 0x0, "TRUE if TNS response", HFILL }},
964 "Request", "tns.request", FT_BOOLEAN, BASE_NONE,
965 NULL, 0x0, "TRUE if TNS request", HFILL }},
967 "Packet Length", "tns.length", FT_UINT16, BASE_DEC,
968 NULL, 0x0, "Length of TNS packet", HFILL }},
969 { &hf_tns_packet_checksum, {
970 "Packet Checksum", "tns.packet_checksum", FT_UINT16, BASE_HEX,
971 NULL, 0x0, "Checksum of Packet Data", HFILL }},
972 { &hf_tns_header_checksum, {
973 "Header Checksum", "tns.header_checksum", FT_UINT16, BASE_HEX,
974 NULL, 0x0, "Checksum of Header Data", HFILL }},
977 "Version", "tns.version", FT_UINT16, BASE_DEC,
978 NULL, 0x0, "Version", HFILL }},
979 { &hf_tns_compat_version, {
980 "Version (Compatible)", "tns.compat_version", FT_UINT16, BASE_DEC,
981 NULL, 0x0, "Version (Compatible)", HFILL }},
983 { &hf_tns_service_options, {
984 "Service Options", "tns.service_options", FT_UINT16, BASE_HEX,
985 NULL, 0x0, "Service Options", HFILL }},
987 { &hf_tns_sopt_flag_bconn, {
988 "Broken Connect Notify", "tns.so_flag.bconn", FT_UINT16, BASE_BIN,
989 NULL, 0x2000, "Broken Connect Notify", HFILL }},
990 { &hf_tns_sopt_flag_pc, {
991 "Packet Checksum", "tns.so_flag.pc", FT_UINT16, BASE_BIN,
992 NULL, 0x1000, "Packet Checksum", HFILL }},
993 { &hf_tns_sopt_flag_hc, {
994 "Header Checksum", "tns.so_flag.hc", FT_UINT16, BASE_BIN,
995 NULL, 0x0800, "Header Checksum", HFILL }},
996 { &hf_tns_sopt_flag_fd, {
997 "Full Duplex", "tns.so_flag.fd", FT_UINT16, BASE_BIN,
998 NULL, 0x0400, "Full Duplex", HFILL }},
999 { &hf_tns_sopt_flag_hd, {
1000 "Half Duplex", "tns.so_flag.hd", FT_UINT16, BASE_BIN,
1001 NULL, 0x0200, "Half Duplex", HFILL }},
1002 { &hf_tns_sopt_flag_dc1, {
1003 "Don't Care", "tns.so_flag.dc1", FT_UINT16, BASE_BIN,
1004 NULL, 0x0100, "Don't Care", HFILL }},
1005 { &hf_tns_sopt_flag_dc2, {
1006 "Don't Care", "tns.so_flag.dc2", FT_UINT16, BASE_BIN,
1007 NULL, 0x0080, "Don't Care", HFILL }},
1008 { &hf_tns_sopt_flag_dio, {
1009 "Direct IO to Transport", "tns.so_flag.dio", FT_UINT16, BASE_BIN,
1010 NULL, 0x0010, "Direct IO to Transport", HFILL }},
1011 { &hf_tns_sopt_flag_ap, {
1012 "Attention Processing", "tns.so_flag.ap", FT_UINT16, BASE_BIN,
1013 NULL, 0x0008, "Attention Processing", HFILL }},
1014 { &hf_tns_sopt_flag_ra, {
1015 "Can Receive Attention", "tns.so_flag.ra", FT_UINT16, BASE_BIN,
1016 NULL, 0x0004, "Can Receive Attention", HFILL }},
1017 { &hf_tns_sopt_flag_sa, {
1018 "Can Send Attention", "tns.so_flag.sa", FT_UINT16, BASE_BIN,
1019 NULL, 0x0002, "Can Send Attention", HFILL }},
1022 { &hf_tns_sdu_size, {
1023 "Session Data Unit Size", "tns.sdu_size", FT_UINT16, BASE_DEC,
1024 NULL, 0x0, "Session Data Unit Size", HFILL }},
1025 { &hf_tns_max_tdu_size, {
1026 "Maximum Transmission Data Unit Size", "tns.max_tdu_size", FT_UINT16, BASE_DEC,
1027 NULL, 0x0, "Maximum Transmission Data Unit Size", HFILL }},
1029 { &hf_tns_nt_proto_characteristics, {
1030 "NT Protocol Characteristics", "tns.nt_proto_characteristics", FT_UINT16, BASE_HEX,
1031 NULL, 0x0, "NT Protocol Characteristics", HFILL }},
1032 { &hf_tns_ntp_flag_hangon, {
1033 "Hangon to listener connect", "tns.ntp_flag.hangon", FT_UINT16, BASE_BIN,
1034 NULL, 0x8000, "Hangon to listener connect", HFILL }},
1035 { &hf_tns_ntp_flag_crel, {
1036 "Confirmed release", "tns.ntp_flag.crel", FT_UINT16, BASE_BIN,
1037 NULL, 0x4000, "Confirmed release", HFILL }},
1038 { &hf_tns_ntp_flag_tduio, {
1039 "TDU based IO", "tns.ntp_flag.tduio", FT_UINT16, BASE_BIN,
1040 NULL, 0x2000, "TDU based IO", HFILL }},
1041 { &hf_tns_ntp_flag_srun, {
1042 "Spawner running", "tns.ntp_flag.srun", FT_UINT16, BASE_BIN,
1043 NULL, 0x1000, "Spawner running", HFILL }},
1044 { &hf_tns_ntp_flag_dtest, {
1045 "Data test", "tns.ntp_flag.dtest", FT_UINT16, BASE_BIN,
1046 NULL, 0x0800, "Data Test", HFILL }},
1047 { &hf_tns_ntp_flag_cbio, {
1048 "Callback IO supported", "tns.ntp_flag.cbio", FT_UINT16, BASE_BIN,
1049 NULL, 0x0400, "Callback IO supported", HFILL }},
1050 { &hf_tns_ntp_flag_asio, {
1051 "ASync IO Supported", "tns.ntp_flag.asio", FT_UINT16, BASE_BIN,
1052 NULL, 0x0200, "ASync IO Supported", HFILL }},
1053 { &hf_tns_ntp_flag_pio, {
1054 "Packet oriented IO", "tns.ntp_flag.pio", FT_UINT16, BASE_BIN,
1055 NULL, 0x0100, "Packet oriented IO", HFILL }},
1056 { &hf_tns_ntp_flag_grant, {
1057 "Can grant connection to another", "tns.ntp_flag.grant", FT_UINT16, BASE_BIN,
1058 NULL, 0x0080, "Can grant connection to another", HFILL }},
1059 { &hf_tns_ntp_flag_handoff, {
1060 "Can handoff connection to another", "tns.ntp_flag.handoff", FT_UINT16, BASE_BIN,
1061 NULL, 0x0040, "Can handoff connection to another", HFILL }},
1062 { &hf_tns_ntp_flag_sigio, {
1063 "Generate SIGIO signal", "tns.ntp_flag.sigio", FT_UINT16, BASE_BIN,
1064 NULL, 0x0020, "Generate SIGIO signal", HFILL }},
1065 { &hf_tns_ntp_flag_sigpipe, {
1066 "Generate SIGPIPE signal", "tns.ntp_flag.sigpipe", FT_UINT16, BASE_BIN,
1067 NULL, 0x0010, "Generate SIGPIPE signal", HFILL }},
1068 { &hf_tns_ntp_flag_sigurg, {
1069 "Generate SIGURG signal", "tns.ntp_flag.sigurg", FT_UINT16, BASE_BIN,
1070 NULL, 0x0008, "Generate SIGURG signal", HFILL }},
1071 { &hf_tns_ntp_flag_urgentio, {
1072 "Urgent IO supported", "tns.ntp_flag.urgentio", FT_UINT16, BASE_BIN,
1073 NULL, 0x0004, "Urgent IO supported", HFILL }},
1074 { &hf_tns_ntp_flag_fdio, {
1075 "Full duplex IO supported", "tns.ntp_flag.dfio", FT_UINT16, BASE_BIN,
1076 NULL, 0x0002, "Full duplex IO supported", HFILL }},
1077 { &hf_tns_ntp_flag_testop, {
1078 "Test operation", "tns.ntp_flag.testop", FT_UINT16, BASE_BIN,
1079 NULL, 0x0001, "Test operation", HFILL }},
1084 { &hf_tns_line_turnaround, {
1085 "Line Turnaround Value", "tns.line_turnaround", FT_UINT16, BASE_DEC,
1086 NULL, 0x0, "Line Turnaround Value", HFILL }},
1087 { &hf_tns_value_of_one, {
1088 "Value of 1 in Hardware", "tns.value_of_one", FT_BYTES, BASE_NONE,
1089 NULL, 0x0, "Value of 1 in Hardware", HFILL }},
1091 { &hf_tns_connect, {
1092 "Connect", "tns.connect", FT_BOOLEAN, BASE_NONE,
1093 NULL, 0x0, "Connect", HFILL }},
1094 { &hf_tns_connect_data_length, {
1095 "Length of Connect Data", "tns.connect_data_length", FT_UINT16, BASE_DEC,
1096 NULL, 0x0, "Length of Connect Data", HFILL }},
1097 { &hf_tns_connect_data_offset, {
1098 "Offset to Connect Data", "tns.connect_data_offset", FT_UINT16, BASE_DEC,
1099 NULL, 0x0, "Offset to Connect Data", HFILL }},
1100 { &hf_tns_connect_data_max, {
1101 "Maximum Receivable Connect Data", "tns.connect_data_max", FT_UINT32, BASE_DEC,
1102 NULL, 0x0, "Maximum Receivable Connect Data", HFILL }},
1104 { &hf_tns_connect_flags0, {
1105 "Connect Flags 0", "tns.connect_flags0", FT_UINT8, BASE_HEX,
1106 NULL, 0x0, "Connect Flags 0", HFILL }},
1107 { &hf_tns_connect_flags1, {
1108 "Connect Flags 1", "tns.connect_flags1", FT_UINT8, BASE_HEX,
1109 NULL, 0x0, "Connect Flags 1", HFILL }},
1111 { &hf_tns_conn_flag_nareq, {
1112 "NA services required", "tns.connect_flags.nareq", FT_UINT8, BASE_BIN,
1113 NULL, 0x10, "NA services required", HFILL }},
1114 { &hf_tns_conn_flag_nalink, {
1115 "NA services linked in", "tns.connect_flags.nalink", FT_UINT8, BASE_BIN,
1116 NULL, 0x08, "NA services linked in", HFILL }},
1117 { &hf_tns_conn_flag_enablena, {
1118 "NA services enabled", "tns.connect_flags.enablena", FT_UINT8, BASE_BIN,
1119 NULL, 0x04, "NA services enabled", HFILL }},
1120 { &hf_tns_conn_flag_ichg, {
1121 "Interchange is involved", "tns.connect_flags.ichg", FT_UINT8, BASE_BIN,
1122 NULL, 0x02, "Interchange is involved", HFILL }},
1123 { &hf_tns_conn_flag_wantna, {
1124 "NA services wanted", "tns.connect_flags.wantna", FT_UINT8, BASE_BIN,
1125 NULL, 0x01, "NA services wanted", HFILL }},
1128 { &hf_tns_trace_cf1, {
1129 "Trace Cross Facility Item 1", "tns.trace_cf1", FT_UINT16, BASE_HEX,
1130 NULL, 0x0, "Trace Cross Facility Item 1", HFILL }},
1131 { &hf_tns_trace_cf2, {
1132 "Trace Cross Facility Item 2", "tns.trace_cf2", FT_UINT16, BASE_HEX,
1133 NULL, 0x0, "Trace Cross Facility Item 2", HFILL }},
1134 { &hf_tns_trace_cid, {
1135 "Trace Unique Connection ID", "tns.trace_cid", FT_UINT16, BASE_HEX,
1136 NULL, 0x0, "Trace Unique Connection ID", HFILL }},
1137 { &hf_tns_connect_data, {
1138 "Connect Data", "tns.connect_data", FT_STRING, BASE_NONE,
1139 NULL, 0x0, "Connect Data", HFILL }},
1142 "Accept", "tns.accept", FT_BOOLEAN, BASE_NONE,
1143 NULL, 0x0, "Accept", HFILL }},
1144 { &hf_tns_accept_data_length, {
1145 "Accept Data Length", "tns.accept_data_length", FT_UINT16, BASE_HEX,
1146 NULL, 0x0, "Length of Accept Data", HFILL }},
1147 { &hf_tns_accept_data, {
1148 "Accept Data", "tns.accept_data", FT_STRING, BASE_NONE,
1149 NULL, 0x0, "Accept Data", HFILL }},
1150 { &hf_tns_accept_data_offset, {
1151 "Offset to Accept Data", "tns.accept_data_offset", FT_UINT16, BASE_DEC,
1152 NULL, 0x0, "Offset to Accept Data", HFILL }},
1156 "Refuse", "tns.refuse", FT_BOOLEAN, BASE_NONE,
1157 NULL, 0x0, "Refuse", HFILL }},
1158 { &hf_tns_refuse_reason_user, {
1159 "Refuse Reason (User)", "tns.refuse_reason_user", FT_UINT8, BASE_HEX,
1160 NULL, 0x0, "Refuse Reason from Application", HFILL }},
1161 { &hf_tns_refuse_reason_system, {
1162 "Refuse Reason (User)", "tns.refuse_reason_system", FT_UINT8, BASE_HEX,
1163 NULL, 0x0, "Refuse Reason from System", HFILL }},
1164 { &hf_tns_refuse_data_length, {
1165 "Refuse Data Length", "tns.refuse_data_length", FT_UINT16, BASE_HEX,
1166 NULL, 0x0, "Length of Refuse Data", HFILL }},
1167 { &hf_tns_refuse_data, {
1168 "Refuse Data", "tns.refuse_data", FT_STRING, BASE_NONE,
1169 NULL, 0x0, "Refuse Data", HFILL }},
1172 "Abort", "tns.abort", FT_BOOLEAN, BASE_NONE,
1173 NULL, 0x0, "Abort", HFILL }},
1174 { &hf_tns_abort_reason_user, {
1175 "Abort Reason (User)", "tns.abort_reason_user", FT_UINT8, BASE_HEX,
1176 NULL, 0x0, "Abort Reason from Application", HFILL }},
1177 { &hf_tns_abort_reason_system, {
1178 "Abort Reason (User)", "tns.abort_reason_system", FT_UINT8, BASE_HEX,
1179 NULL, 0x0, "Abort Reason from System", HFILL }},
1180 { &hf_tns_abort_data, {
1181 "Abort Data", "tns.abort_data", FT_STRING, BASE_NONE,
1182 NULL, 0x0, "Abort Data", HFILL }},
1185 "Marker", "tns.marker", FT_BOOLEAN, BASE_NONE,
1186 NULL, 0x0, "Marker", HFILL }},
1187 { &hf_tns_marker_type, {
1188 "Marker Type", "tns.marker.type", FT_UINT8, BASE_HEX,
1189 VALS(tns_marker_types), 0x0, "Marker Type", HFILL }},
1190 { &hf_tns_marker_data_byte, {
1191 "Marker Data Byte", "tns.marker.databyte", FT_UINT8, BASE_HEX,
1192 NULL, 0x0, "Marker Data Byte", HFILL }},
1193 { &hf_tns_marker_data, {
1194 "Marker Data", "tns.marker.data", FT_UINT16, BASE_HEX,
1195 NULL, 0x0, "Marker Data", HFILL }},
1197 { &hf_tns_control, {
1198 "Control", "tns.control", FT_BOOLEAN, BASE_NONE,
1199 NULL, 0x0, "Control", HFILL }},
1200 { &hf_tns_control_cmd, {
1201 "Control Command", "tns.control.cmd", FT_UINT16, BASE_HEX,
1202 VALS(tns_control_cmds), 0x0, "Control Command", HFILL }},
1203 { &hf_tns_control_data, {
1204 "Control Data", "tns.control.data", FT_BYTES, BASE_HEX,
1205 NULL, 0x0, "Control Data", HFILL }},
1207 { &hf_tns_redirect, {
1208 "Redirect", "tns.redirect", FT_BOOLEAN, BASE_NONE,
1209 NULL, 0x0, "Redirect", HFILL }},
1210 { &hf_tns_redirect_data_length, {
1211 "Redirect Data Length", "tns.redirect_data_length", FT_UINT16, BASE_HEX,
1212 NULL, 0x0, "Length of Redirect Data", HFILL }},
1213 { &hf_tns_redirect_data, {
1214 "Redirect Data", "tns.redirect_data", FT_STRING, BASE_NONE,
1215 NULL, 0x0, "Redirect Data", HFILL }},
1218 "Data", "tns.data", FT_BOOLEAN, BASE_NONE,
1219 NULL, 0x0, "Data", HFILL }},
1221 { &hf_tns_data_flag, {
1222 "Data Flag", "tns.data_flag", FT_UINT16, BASE_HEX,
1223 NULL, 0x0, "Data Flag", HFILL }},
1224 { &hf_tns_data_flag_send, {
1225 "Send Token", "tns.data_flag.send", FT_UINT16, BASE_BIN,
1226 NULL, 0x1, "Send Token", HFILL }},
1227 { &hf_tns_data_flag_rc, {
1228 "Request Confirmation", "tns.data_flag.rc", FT_UINT16, BASE_BIN,
1229 NULL, 0x2, "Request Confirmation", HFILL }},
1230 { &hf_tns_data_flag_c, {
1231 "Confirmation", "tns.data_flag.c", FT_UINT16, BASE_BIN,
1232 NULL, 0x4, "Confirmation", HFILL }},
1233 { &hf_tns_data_flag_reserved, {
1234 "Reserved", "tns.data_flag.reserved", FT_UINT16, BASE_BIN,
1235 NULL, 0x8, "Reserved", HFILL }},
1236 { &hf_tns_data_flag_more, {
1237 "More Data to Come", "tns.data_flag.more", FT_UINT16, BASE_BIN,
1238 NULL, 0x20, "More Data to Come", HFILL }},
1239 { &hf_tns_data_flag_eof, {
1240 "End of File", "tns.data_flag.eof", FT_UINT16, BASE_BIN,
1241 NULL, 0x40, "End of File", HFILL }},
1242 { &hf_tns_data_flag_dic, {
1243 "Do Immediate Confirmation", "tns.data_flag.dic", FT_UINT16, BASE_BIN,
1244 NULL, 0x80, "Do Immediate Confirmation", HFILL }},
1245 { &hf_tns_data_flag_rts, {
1246 "Request To Send", "tns.data_flag.rts", FT_UINT16, BASE_BIN,
1247 NULL, 0x100, "Request To Send", HFILL }},
1248 { &hf_tns_data_flag_sntt, {
1249 "Send NT Trailer", "tns.data_flag.sntt", FT_UINT16, BASE_BIN,
1250 NULL, 0x200, "Send NT Trailer", HFILL }},
1253 { &hf_tns_reserved_byte, {
1254 "Reserved Byte", "tns.reserved_byte", FT_BYTES, BASE_HEX,
1255 NULL, 0x0, "Reserved Byte", HFILL }},
1256 { &hf_tns_packet_type, {
1257 "Packet Type", "tns.type", FT_UINT8, BASE_DEC,
1258 VALS(tns_type_vals), 0x0, "Type of TNS packet", HFILL }}
1262 static gint *ett[] = {
1279 proto_tns = proto_register_protocol(
1280 "Transparent Network Substrate Protocol", "TNS", "tns");
1281 proto_register_field_array(proto_tns, hf, array_length(hf));
1282 proto_register_subtree_array(ett, array_length(ett));
1286 proto_reg_handoff_tns(void)
1288 dissector_handle_t tns_handle;
1290 tns_handle = create_dissector_handle(dissect_tns, proto_tns);
1291 dissector_add("tcp.port", TCP_PORT_TNS, tns_handle);
1292 data_handle = find_dissector("data");