2 * Routines for Oracle TNS packet dissection
4 * $Id: packet-tns.c,v 1.39 2003/02/05 08:06:40 guy 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.
35 #include <epan/packet.h>
36 #include "packet-tcp.h"
37 #include "packet-tns.h"
41 /* desegmentation of TNS over TCP */
42 static gboolean tns_desegment = TRUE;
44 static int proto_tns = -1;
45 static int hf_tns_request = -1;
46 static int hf_tns_response = -1;
47 static int hf_tns_length = -1;
48 static int hf_tns_packet_checksum = -1;
49 static int hf_tns_header_checksum = -1;
50 static int hf_tns_packet_type = -1;
51 static int hf_tns_reserved_byte = -1;
52 static int hf_tns_connect = -1;
53 static int hf_tns_version = -1;
54 static int hf_tns_compat_version = -1;
56 static int hf_tns_service_options = -1;
57 static int hf_tns_sopt_flag_bconn = -1;
58 static int hf_tns_sopt_flag_pc = -1;
59 static int hf_tns_sopt_flag_hc = -1;
60 static int hf_tns_sopt_flag_fd = -1;
61 static int hf_tns_sopt_flag_hd = -1;
62 static int hf_tns_sopt_flag_dc1 = -1;
63 static int hf_tns_sopt_flag_dc2 = -1;
64 static int hf_tns_sopt_flag_dio = -1;
65 static int hf_tns_sopt_flag_ap = -1;
66 static int hf_tns_sopt_flag_ra = -1;
67 static int hf_tns_sopt_flag_sa = -1;
69 static int hf_tns_sdu_size = -1;
70 static int hf_tns_max_tdu_size = -1;
72 static int hf_tns_nt_proto_characteristics = -1;
73 static int hf_tns_ntp_flag_hangon = -1;
74 static int hf_tns_ntp_flag_crel = -1;
75 static int hf_tns_ntp_flag_tduio = -1;
76 static int hf_tns_ntp_flag_srun = -1;
77 static int hf_tns_ntp_flag_dtest = -1;
78 static int hf_tns_ntp_flag_cbio = -1;
79 static int hf_tns_ntp_flag_asio = -1;
80 static int hf_tns_ntp_flag_pio = -1;
81 static int hf_tns_ntp_flag_grant = -1;
82 static int hf_tns_ntp_flag_handoff = -1;
83 static int hf_tns_ntp_flag_sigio = -1;
84 static int hf_tns_ntp_flag_sigpipe = -1;
85 static int hf_tns_ntp_flag_sigurg = -1;
86 static int hf_tns_ntp_flag_urgentio = -1;
87 static int hf_tns_ntp_flag_fdio = -1;
88 static int hf_tns_ntp_flag_testop = -1;
90 static int hf_tns_line_turnaround = -1;
91 static int hf_tns_value_of_one = -1;
92 static int hf_tns_connect_data_length = -1;
93 static int hf_tns_connect_data_offset = -1;
94 static int hf_tns_connect_data_max = -1;
96 static int hf_tns_connect_flags0 = -1;
97 static int hf_tns_connect_flags1 = -1;
98 static int hf_tns_conn_flag_nareq = -1;
99 static int hf_tns_conn_flag_nalink = -1;
100 static int hf_tns_conn_flag_enablena = -1;
101 static int hf_tns_conn_flag_ichg = -1;
102 static int hf_tns_conn_flag_wantna = -1;
104 static int hf_tns_connect_data = -1;
105 static int hf_tns_trace_cf1 = -1;
106 static int hf_tns_trace_cf2 = -1;
107 static int hf_tns_trace_cid = -1;
109 static int hf_tns_accept = -1;
110 static int hf_tns_accept_data_length = -1;
111 static int hf_tns_accept_data_offset = -1;
112 static int hf_tns_accept_data = -1;
114 static int hf_tns_refuse = -1;
115 static int hf_tns_refuse_reason_user = -1;
116 static int hf_tns_refuse_reason_system = -1;
117 static int hf_tns_refuse_data_length = -1;
118 static int hf_tns_refuse_data = -1;
120 static int hf_tns_abort = -1;
121 static int hf_tns_abort_reason_user = -1;
122 static int hf_tns_abort_reason_system = -1;
123 static int hf_tns_abort_data = -1;
125 static int hf_tns_marker = -1;
126 static int hf_tns_marker_type = -1;
127 static int hf_tns_marker_data_byte = -1;
128 static int hf_tns_marker_data = -1;
130 static int hf_tns_redirect = -1;
131 static int hf_tns_redirect_data_length = -1;
132 static int hf_tns_redirect_data = -1;
134 static int hf_tns_control = -1;
135 static int hf_tns_control_cmd = -1;
136 static int hf_tns_control_data = -1;
138 static int hf_tns_data_flag = -1;
139 static int hf_tns_data_flag_send = -1;
140 static int hf_tns_data_flag_rc = -1;
141 static int hf_tns_data_flag_c = -1;
142 static int hf_tns_data_flag_reserved = -1;
143 static int hf_tns_data_flag_more = -1;
144 static int hf_tns_data_flag_eof = -1;
145 static int hf_tns_data_flag_dic = -1;
146 static int hf_tns_data_flag_rts = -1;
147 static int hf_tns_data_flag_sntt = -1;
148 static int hf_tns_data = -1;
150 static gint ett_tns = -1;
151 static gint ett_tns_connect = -1;
152 static gint ett_tns_accept = -1;
153 static gint ett_tns_refuse = -1;
154 static gint ett_tns_abort = -1;
155 static gint ett_tns_redirect = -1;
156 static gint ett_tns_marker = -1;
157 static gint ett_tns_attention = -1;
158 static gint ett_tns_control = -1;
159 static gint ett_tns_data = -1;
160 static gint ett_tns_data_flag = -1;
161 static gint ett_tns_sopt_flag = -1;
162 static gint ett_tns_ntp_flag = -1;
163 static gint ett_tns_conn_flag = -1;
164 static gint ett_sql = -1;
166 static dissector_handle_t data_handle;
168 #define TCP_PORT_TNS 1521
170 static const value_string tns_type_vals[] = {
171 {TNS_TYPE_CONNECT, "Connect" },
172 {TNS_TYPE_ACCEPT, "Accept" },
173 {TNS_TYPE_ACK, "Acknowledge" },
174 {TNS_TYPE_REFUSE, "Refuse" },
175 {TNS_TYPE_REDIRECT, "Redirect" },
176 {TNS_TYPE_DATA, "Data" },
177 {TNS_TYPE_NULL, "Null" },
178 {TNS_TYPE_ABORT, "Abort" },
179 {TNS_TYPE_RESEND, "Resend"},
180 {TNS_TYPE_MARKER, "Marker"},
181 {TNS_TYPE_ATTENTION, "Attention"},
182 {TNS_TYPE_CONTROL, "Control"},
186 static const value_string tns_marker_types[] = {
187 {0, "Data Marker - 0 Data Bytes"},
188 {1, "Data Marker - 1 Data Bytes"},
189 {2, "Attention Marker"},
193 static const value_string tns_control_cmds[] = {
194 {1, "Oracle Trace Command"},
198 void proto_reg_handoff_tns(void);
199 static guint get_tns_pdu_len(tvbuff_t *tvb, int offset);
200 static void dissect_tns_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
202 static void dissect_tns_service_options(tvbuff_t *tvb, int offset,
203 proto_tree *sopt_tree)
206 proto_tree_add_item(sopt_tree, hf_tns_sopt_flag_bconn, tvb,
208 proto_tree_add_item(sopt_tree, hf_tns_sopt_flag_pc, tvb,
210 proto_tree_add_item(sopt_tree, hf_tns_sopt_flag_hc, tvb,
212 proto_tree_add_item(sopt_tree, hf_tns_sopt_flag_fd, tvb,
214 proto_tree_add_item(sopt_tree, hf_tns_sopt_flag_hd, tvb,
216 proto_tree_add_item(sopt_tree, hf_tns_sopt_flag_dc1, tvb,
218 proto_tree_add_item(sopt_tree, hf_tns_sopt_flag_dc2, tvb,
220 proto_tree_add_item(sopt_tree, hf_tns_sopt_flag_dio, tvb,
222 proto_tree_add_item(sopt_tree, hf_tns_sopt_flag_ap, tvb,
224 proto_tree_add_item(sopt_tree, hf_tns_sopt_flag_ra, tvb,
226 proto_tree_add_item(sopt_tree, hf_tns_sopt_flag_sa, tvb,
231 static void dissect_tns_connect_flag(tvbuff_t *tvb, int offset,
232 proto_tree *cflag_tree)
235 proto_tree_add_item(cflag_tree, hf_tns_conn_flag_nareq, tvb, offset, 1, FALSE);
236 proto_tree_add_item(cflag_tree, hf_tns_conn_flag_nalink, tvb, offset, 1, FALSE);
237 proto_tree_add_item(cflag_tree, hf_tns_conn_flag_enablena, tvb, offset, 1, FALSE);
238 proto_tree_add_item(cflag_tree, hf_tns_conn_flag_ichg, tvb, offset, 1, FALSE);
239 proto_tree_add_item(cflag_tree, hf_tns_conn_flag_wantna, tvb, offset, 1, FALSE);
242 static void dissect_tns_data(tvbuff_t *tvb, int offset, packet_info *pinfo,
243 proto_tree *tree, proto_tree *tns_tree)
245 proto_tree *data_tree = NULL, *ti;
248 if ( tvb_bytes_exist(tvb, offset+2, 4) )
250 if ( tvb_get_guint8(tvb, offset+2) == 0xDE &&
251 tvb_get_guint8(tvb, offset+3) == 0xAD &&
252 tvb_get_guint8(tvb, offset+4) == 0xBE &&
253 tvb_get_guint8(tvb, offset+5) == 0xEF )
263 ti = proto_tree_add_text(tns_tree, tvb, offset, -1,
264 "Secure Network Services");
268 ti = proto_tree_add_text(tns_tree, tvb, offset, -1,
271 data_tree = proto_item_add_subtree(ti, ett_tns_data);
273 proto_tree_add_boolean_hidden(tns_tree, hf_tns_data, tvb, 0, 0,
279 proto_tree *df_tree = NULL;
281 ti = proto_tree_add_item(data_tree, hf_tns_data_flag, tvb, offset, 2, FALSE);
283 df_tree = proto_item_add_subtree(ti, ett_tns_data_flag);
284 proto_tree_add_item(df_tree, hf_tns_data_flag_send, tvb, offset, 2, FALSE);
285 proto_tree_add_item(df_tree, hf_tns_data_flag_rc, tvb, offset, 2, FALSE);
286 proto_tree_add_item(df_tree, hf_tns_data_flag_c, tvb, offset, 2, FALSE);
287 proto_tree_add_item(df_tree, hf_tns_data_flag_reserved, tvb, offset, 2, FALSE);
288 proto_tree_add_item(df_tree, hf_tns_data_flag_more, tvb, offset, 2, FALSE);
289 proto_tree_add_item(df_tree, hf_tns_data_flag_eof, tvb, offset, 2, FALSE);
290 proto_tree_add_item(df_tree, hf_tns_data_flag_dic, tvb, offset, 2, FALSE);
291 proto_tree_add_item(df_tree, hf_tns_data_flag_rts, tvb, offset, 2, FALSE);
292 proto_tree_add_item(df_tree, hf_tns_data_flag_sntt, tvb, offset, 2, FALSE);
296 if ( check_col(pinfo->cinfo, COL_INFO) )
300 col_append_fstr(pinfo->cinfo, COL_INFO, ", SNS");
304 col_append_fstr(pinfo->cinfo, COL_INFO, ", Data");
310 call_dissector(data_handle,
311 tvb_new_subset(tvb, offset, -1, -1), pinfo, data_tree);
317 static void dissect_tns_connect(tvbuff_t *tvb, int offset, packet_info *pinfo,
318 proto_tree *tree, proto_tree *tns_tree)
320 proto_tree *connect_tree = NULL, *ti;
323 int tns_offset = offset-8;
327 ti = proto_tree_add_text(tns_tree, tvb, offset, -1,
329 connect_tree = proto_item_add_subtree(ti, ett_tns_connect);
331 proto_tree_add_boolean_hidden(tns_tree, hf_tns_connect, tvb,
335 if ( check_col(pinfo->cinfo, COL_INFO) )
337 col_append_str(pinfo->cinfo, COL_INFO, ", Connect");
342 proto_tree_add_item(connect_tree, hf_tns_version, tvb,
349 proto_tree_add_item(connect_tree, hf_tns_compat_version, tvb,
356 proto_tree *sopt_tree = NULL;
358 ti = proto_tree_add_item(connect_tree, hf_tns_service_options, tvb,
361 sopt_tree = proto_item_add_subtree(ti, ett_tns_sopt_flag);
363 dissect_tns_service_options(tvb, offset, sopt_tree);
371 proto_tree_add_item(connect_tree, hf_tns_sdu_size, tvb,
378 proto_tree_add_item(connect_tree, hf_tns_max_tdu_size, tvb,
385 proto_tree *ntp_tree = NULL;
387 ti = proto_tree_add_item(connect_tree, hf_tns_nt_proto_characteristics, tvb,
390 ntp_tree = proto_item_add_subtree(ti, ett_tns_ntp_flag);
392 proto_tree_add_item(ntp_tree, hf_tns_ntp_flag_hangon, tvb, offset, 2, FALSE);
393 proto_tree_add_item(ntp_tree, hf_tns_ntp_flag_crel, tvb, offset, 2, FALSE);
394 proto_tree_add_item(ntp_tree, hf_tns_ntp_flag_tduio, tvb, offset, 2, FALSE);
395 proto_tree_add_item(ntp_tree, hf_tns_ntp_flag_srun, tvb, offset, 2, FALSE);
396 proto_tree_add_item(ntp_tree, hf_tns_ntp_flag_dtest, tvb, offset, 2, FALSE);
397 proto_tree_add_item(ntp_tree, hf_tns_ntp_flag_cbio, tvb, offset, 2, FALSE);
398 proto_tree_add_item(ntp_tree, hf_tns_ntp_flag_asio, tvb, offset, 2, FALSE);
399 proto_tree_add_item(ntp_tree, hf_tns_ntp_flag_pio, tvb, offset, 2, FALSE);
400 proto_tree_add_item(ntp_tree, hf_tns_ntp_flag_grant, tvb, offset, 2, FALSE);
401 proto_tree_add_item(ntp_tree, hf_tns_ntp_flag_handoff, tvb, offset, 2, FALSE);
402 proto_tree_add_item(ntp_tree, hf_tns_ntp_flag_sigio, tvb, offset, 2, FALSE);
403 proto_tree_add_item(ntp_tree, hf_tns_ntp_flag_sigpipe, tvb, offset, 2, FALSE);
404 proto_tree_add_item(ntp_tree, hf_tns_ntp_flag_sigurg, tvb, offset, 2, FALSE);
405 proto_tree_add_item(ntp_tree, hf_tns_ntp_flag_urgentio, tvb, offset, 2, FALSE);
406 proto_tree_add_item(ntp_tree, hf_tns_ntp_flag_fdio, tvb, offset, 2, FALSE);
407 proto_tree_add_item(ntp_tree, hf_tns_ntp_flag_testop, tvb, offset, 2, FALSE);
413 proto_tree_add_item(connect_tree, hf_tns_line_turnaround, tvb,
420 proto_tree_add_item(connect_tree, hf_tns_value_of_one, tvb,
425 cd_len = tvb_get_ntohs(tvb, offset);
428 proto_tree_add_uint(connect_tree, hf_tns_connect_data_length, tvb,
433 cd_offset = tvb_get_ntohs(tvb, offset);
436 proto_tree_add_uint(connect_tree, hf_tns_connect_data_offset, tvb,
437 offset, 2, cd_offset);
443 proto_tree_add_item(connect_tree, hf_tns_connect_data_max, tvb,
450 proto_tree *cflag_tree = NULL;
452 ti = proto_tree_add_item(connect_tree, hf_tns_connect_flags0, tvb,
455 cflag_tree = proto_item_add_subtree(ti, ett_tns_conn_flag);
457 dissect_tns_connect_flag(tvb, offset, cflag_tree);
463 proto_tree *cflag_tree = NULL;
465 ti = proto_tree_add_item(connect_tree, hf_tns_connect_flags1, tvb,
468 cflag_tree = proto_item_add_subtree(ti, ett_tns_conn_flag);
470 dissect_tns_connect_flag(tvb, offset, cflag_tree);
475 * XXX - sometimes it appears that this stuff isn't present
478 if (offset + 16 <= tns_offset+cd_offset)
482 proto_tree_add_item(connect_tree, hf_tns_trace_cf1, tvb,
489 proto_tree_add_item(connect_tree, hf_tns_trace_cf2, tvb,
496 proto_tree_add_item(connect_tree, hf_tns_trace_cid, tvb,
502 if ( connect_tree && cd_len > 0)
504 proto_tree_add_item(connect_tree, hf_tns_connect_data, tvb,
505 tns_offset+cd_offset, -1, FALSE);
510 static void dissect_tns_accept(tvbuff_t *tvb, int offset, packet_info *pinfo,
511 proto_tree *tree, proto_tree *tns_tree)
513 proto_tree *accept_tree = NULL, *ti;
516 int tns_offset = offset-8;
520 ti = proto_tree_add_text(tns_tree, tvb, offset, -1,
522 accept_tree = proto_item_add_subtree(ti, ett_tns_accept);
524 proto_tree_add_boolean_hidden(tns_tree, hf_tns_accept, tvb,
528 if ( check_col(pinfo->cinfo, COL_INFO) )
530 col_append_str(pinfo->cinfo, COL_INFO, ", Accept");
535 proto_tree_add_item(accept_tree, hf_tns_version, tvb,
542 proto_tree *sopt_tree = NULL;
544 ti = proto_tree_add_item(accept_tree, hf_tns_service_options,
545 tvb, offset, 2, FALSE);
547 sopt_tree = proto_item_add_subtree(ti, ett_tns_sopt_flag);
549 dissect_tns_service_options(tvb, offset, sopt_tree);
556 proto_tree_add_item(accept_tree, hf_tns_sdu_size, tvb,
563 proto_tree_add_item(accept_tree, hf_tns_max_tdu_size, tvb,
570 proto_tree_add_item(accept_tree, hf_tns_value_of_one, tvb,
575 accept_len = tvb_get_ntohs(tvb, offset);
578 proto_tree_add_uint(accept_tree, hf_tns_accept_data_length, tvb,
579 offset, 2, accept_len);
583 accept_offset = tvb_get_ntohs(tvb, offset);
586 proto_tree_add_uint(accept_tree, hf_tns_accept_data_offset, tvb,
587 offset, 2, accept_offset);
593 proto_tree *cflag_tree = NULL;
595 ti = proto_tree_add_item(accept_tree, hf_tns_connect_flags0, tvb,
598 cflag_tree = proto_item_add_subtree(ti, ett_tns_conn_flag);
600 dissect_tns_connect_flag(tvb, offset, cflag_tree);
607 proto_tree *cflag_tree = NULL;
609 ti = proto_tree_add_item(accept_tree, hf_tns_connect_flags1, tvb,
612 cflag_tree = proto_item_add_subtree(ti, ett_tns_conn_flag);
614 dissect_tns_connect_flag(tvb, offset, cflag_tree);
619 if ( accept_tree && accept_len > 0)
621 proto_tree_add_item(accept_tree, hf_tns_accept_data, tvb,
622 tns_offset+accept_offset, -1, FALSE);
628 static void dissect_tns_refuse(tvbuff_t *tvb, int offset, packet_info *pinfo,
629 proto_tree *tree, proto_tree *tns_tree)
631 proto_tree *refuse_tree = NULL, *ti;
635 ti = proto_tree_add_text(tns_tree, tvb, offset, -1,
637 refuse_tree = proto_item_add_subtree(ti, ett_tns_refuse);
639 proto_tree_add_boolean_hidden(tns_tree, hf_tns_refuse, tvb,
643 if ( check_col(pinfo->cinfo, COL_INFO) )
645 col_append_str(pinfo->cinfo, COL_INFO, ", Refuse");
650 proto_tree_add_item(refuse_tree, hf_tns_refuse_reason_user, tvb,
657 proto_tree_add_item(refuse_tree, hf_tns_refuse_reason_system, tvb,
664 proto_tree_add_item(refuse_tree, hf_tns_refuse_data_length, tvb,
671 proto_tree_add_item(refuse_tree, hf_tns_refuse_data, tvb,
678 static void dissect_tns_abort(tvbuff_t *tvb, int offset, packet_info *pinfo,
679 proto_tree *tree, proto_tree *tns_tree)
681 proto_tree *abort_tree = NULL, *ti;
685 ti = proto_tree_add_text(tns_tree, tvb, offset, -1,
687 abort_tree = proto_item_add_subtree(ti, ett_tns_abort);
689 proto_tree_add_boolean_hidden(tns_tree, hf_tns_abort, tvb,
693 if ( check_col(pinfo->cinfo, COL_INFO) )
695 col_append_str(pinfo->cinfo, COL_INFO, ", Abort");
700 proto_tree_add_item(abort_tree, hf_tns_abort_reason_user, tvb,
707 proto_tree_add_item(abort_tree, hf_tns_abort_reason_system, tvb,
714 proto_tree_add_item(abort_tree, hf_tns_abort_data, tvb,
721 static void dissect_tns_marker(tvbuff_t *tvb, int offset, packet_info *pinfo,
722 proto_tree *tree, proto_tree *tns_tree, int is_attention)
724 proto_tree *marker_tree = NULL, *ti;
730 ti = proto_tree_add_text(tns_tree, tvb, offset, -1,
735 ti = proto_tree_add_text(tns_tree, tvb, offset, -1,
739 marker_tree = proto_item_add_subtree(ti, ett_tns_marker);
740 proto_tree_add_boolean_hidden(tns_tree, hf_tns_marker, tvb,
744 if ( check_col(pinfo->cinfo, COL_INFO) )
748 col_append_str(pinfo->cinfo, COL_INFO, ", Marker");
752 col_append_str(pinfo->cinfo, COL_INFO, ", Attention");
758 proto_tree_add_item(marker_tree, hf_tns_marker_type, tvb,
765 proto_tree_add_item(marker_tree, hf_tns_marker_data_byte, tvb,
772 proto_tree_add_item(marker_tree, hf_tns_marker_data_byte, tvb,
780 static void dissect_tns_redirect(tvbuff_t *tvb, int offset, packet_info *pinfo,
781 proto_tree *tree, proto_tree *tns_tree)
783 proto_tree *redirect_tree = NULL, *ti;
787 ti = proto_tree_add_text(tns_tree, tvb, offset, -1,
789 redirect_tree = proto_item_add_subtree(ti, ett_tns_redirect);
791 proto_tree_add_boolean_hidden(tns_tree, hf_tns_redirect, tvb,
795 if ( check_col(pinfo->cinfo, COL_INFO) )
797 col_append_str(pinfo->cinfo, COL_INFO, ", Redirect");
802 proto_tree_add_item(redirect_tree, hf_tns_redirect_data_length, tvb,
809 proto_tree_add_item(redirect_tree, hf_tns_redirect_data, tvb,
815 static void dissect_tns_control(tvbuff_t *tvb, int offset, packet_info *pinfo,
816 proto_tree *tree, proto_tree *tns_tree)
818 proto_tree *control_tree = NULL, *ti;
822 ti = proto_tree_add_text(tns_tree, tvb, offset, -1,
824 control_tree = proto_item_add_subtree(ti, ett_tns_control);
826 proto_tree_add_boolean_hidden(tns_tree, hf_tns_control, tvb,
830 if ( check_col(pinfo->cinfo, COL_INFO) )
832 col_append_str(pinfo->cinfo, COL_INFO, ", Control");
837 proto_tree_add_item(control_tree, hf_tns_control_cmd, tvb,
844 proto_tree_add_item(control_tree, hf_tns_control_data, tvb,
851 get_tns_pdu_len(tvbuff_t *tvb, int offset)
854 * Get the length of the TNS message, including header
856 return tvb_get_ntohs(tvb, offset);
860 dissect_tns(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
865 * First, do a sanity check to make sure what we have
866 * starts with a TNS PDU.
868 if (tvb_bytes_exist(tvb, 4, 1)) {
870 * Well, we have the packet type; let's make sure
873 type = tvb_get_guint8(tvb, 4);
874 if (type < TNS_TYPE_CONNECT || type > TNS_TYPE_MAX)
875 return 0; /* it's not a known type */
878 tcp_dissect_pdus(tvb, pinfo, tree, tns_desegment, 2,
879 get_tns_pdu_len, dissect_tns_pdu);
880 return tvb_length(tvb);
884 dissect_tns_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
886 proto_tree *tns_tree = NULL, *ti;
891 if (check_col(pinfo->cinfo, COL_PROTOCOL))
892 col_set_str(pinfo->cinfo, COL_PROTOCOL, "TNS");
894 if (check_col(pinfo->cinfo, COL_INFO))
896 col_add_str(pinfo->cinfo, COL_INFO,
897 (pinfo->match_port == pinfo->destport) ? "Request" : "Response");
902 ti = proto_tree_add_item(tree, proto_tns, tvb, 0, -1, FALSE);
903 tns_tree = proto_item_add_subtree(ti, ett_tns);
905 if (pinfo->match_port == pinfo->destport)
907 proto_tree_add_boolean_hidden(tns_tree, hf_tns_request,
908 tvb, offset, 0, TRUE);
912 proto_tree_add_boolean_hidden(tns_tree, hf_tns_response,
913 tvb, offset, 0, TRUE);
917 length = tvb_get_ntohs(tvb, offset);
920 proto_tree_add_uint(tns_tree, hf_tns_length, tvb,
927 proto_tree_add_item(tns_tree, hf_tns_packet_checksum, tvb,
932 type = tvb_get_guint8(tvb, offset);
935 proto_tree_add_uint(tns_tree, hf_tns_packet_type, tvb,
940 if ( check_col(pinfo->cinfo, COL_INFO))
942 col_append_fstr(pinfo->cinfo, COL_INFO, ", %s (%u)",
943 val_to_str(type, tns_type_vals, "Unknown"), type);
948 proto_tree_add_item(tns_tree, hf_tns_reserved_byte, tvb,
955 proto_tree_add_item(tns_tree, hf_tns_header_checksum, tvb,
962 case TNS_TYPE_CONNECT:
963 dissect_tns_connect(tvb,offset,pinfo,tree,tns_tree);
965 case TNS_TYPE_ACCEPT:
966 dissect_tns_accept(tvb,offset,pinfo,tree,tns_tree);
968 case TNS_TYPE_REFUSE:
969 dissect_tns_refuse(tvb,offset,pinfo,tree,tns_tree);
971 case TNS_TYPE_REDIRECT:
972 dissect_tns_redirect(tvb,offset,pinfo,tree,tns_tree);
975 dissect_tns_abort(tvb,offset,pinfo,tree,tns_tree);
977 case TNS_TYPE_MARKER:
978 dissect_tns_marker(tvb,offset,pinfo,tree,tns_tree, 0);
980 case TNS_TYPE_ATTENTION:
981 dissect_tns_marker(tvb,offset,pinfo,tree,tns_tree, 1);
983 case TNS_TYPE_CONTROL:
984 dissect_tns_control(tvb,offset,pinfo,tree,tns_tree);
987 dissect_tns_data(tvb,offset,pinfo,tree,tns_tree);
990 call_dissector(data_handle,
991 tvb_new_subset(tvb, offset, -1, -1), pinfo,
997 void proto_register_tns(void)
999 static hf_register_info hf[] = {
1000 { &hf_tns_response, {
1001 "Response", "tns.response", FT_BOOLEAN, BASE_NONE,
1002 NULL, 0x0, "TRUE if TNS response", HFILL }},
1003 { &hf_tns_request, {
1004 "Request", "tns.request", FT_BOOLEAN, BASE_NONE,
1005 NULL, 0x0, "TRUE if TNS request", HFILL }},
1007 "Packet Length", "tns.length", FT_UINT16, BASE_DEC,
1008 NULL, 0x0, "Length of TNS packet", HFILL }},
1009 { &hf_tns_packet_checksum, {
1010 "Packet Checksum", "tns.packet_checksum", FT_UINT16, BASE_HEX,
1011 NULL, 0x0, "Checksum of Packet Data", HFILL }},
1012 { &hf_tns_header_checksum, {
1013 "Header Checksum", "tns.header_checksum", FT_UINT16, BASE_HEX,
1014 NULL, 0x0, "Checksum of Header Data", HFILL }},
1016 { &hf_tns_version, {
1017 "Version", "tns.version", FT_UINT16, BASE_DEC,
1018 NULL, 0x0, "Version", HFILL }},
1019 { &hf_tns_compat_version, {
1020 "Version (Compatible)", "tns.compat_version", FT_UINT16, BASE_DEC,
1021 NULL, 0x0, "Version (Compatible)", HFILL }},
1023 { &hf_tns_service_options, {
1024 "Service Options", "tns.service_options", FT_UINT16, BASE_HEX,
1025 NULL, 0x0, "Service Options", HFILL }},
1027 { &hf_tns_sopt_flag_bconn, {
1028 "Broken Connect Notify", "tns.so_flag.bconn", FT_BOOLEAN, 16,
1029 NULL, 0x2000, "Broken Connect Notify", HFILL }},
1030 { &hf_tns_sopt_flag_pc, {
1031 "Packet Checksum", "tns.so_flag.pc", FT_BOOLEAN, 16,
1032 NULL, 0x1000, "Packet Checksum", HFILL }},
1033 { &hf_tns_sopt_flag_hc, {
1034 "Header Checksum", "tns.so_flag.hc", FT_BOOLEAN, 16,
1035 NULL, 0x0800, "Header Checksum", HFILL }},
1036 { &hf_tns_sopt_flag_fd, {
1037 "Full Duplex", "tns.so_flag.fd", FT_BOOLEAN, 16,
1038 NULL, 0x0400, "Full Duplex", HFILL }},
1039 { &hf_tns_sopt_flag_hd, {
1040 "Half Duplex", "tns.so_flag.hd", FT_BOOLEAN, 16,
1041 NULL, 0x0200, "Half Duplex", HFILL }},
1042 { &hf_tns_sopt_flag_dc1, {
1043 "Don't Care", "tns.so_flag.dc1", FT_BOOLEAN, 16,
1044 NULL, 0x0100, "Don't Care", HFILL }},
1045 { &hf_tns_sopt_flag_dc2, {
1046 "Don't Care", "tns.so_flag.dc2", FT_BOOLEAN, 16,
1047 NULL, 0x0080, "Don't Care", HFILL }},
1048 { &hf_tns_sopt_flag_dio, {
1049 "Direct IO to Transport", "tns.so_flag.dio", FT_BOOLEAN, 16,
1050 NULL, 0x0010, "Direct IO to Transport", HFILL }},
1051 { &hf_tns_sopt_flag_ap, {
1052 "Attention Processing", "tns.so_flag.ap", FT_BOOLEAN, 16,
1053 NULL, 0x0008, "Attention Processing", HFILL }},
1054 { &hf_tns_sopt_flag_ra, {
1055 "Can Receive Attention", "tns.so_flag.ra", FT_BOOLEAN, 16,
1056 NULL, 0x0004, "Can Receive Attention", HFILL }},
1057 { &hf_tns_sopt_flag_sa, {
1058 "Can Send Attention", "tns.so_flag.sa", FT_BOOLEAN, 16,
1059 NULL, 0x0002, "Can Send Attention", HFILL }},
1062 { &hf_tns_sdu_size, {
1063 "Session Data Unit Size", "tns.sdu_size", FT_UINT16, BASE_DEC,
1064 NULL, 0x0, "Session Data Unit Size", HFILL }},
1065 { &hf_tns_max_tdu_size, {
1066 "Maximum Transmission Data Unit Size", "tns.max_tdu_size", FT_UINT16, BASE_DEC,
1067 NULL, 0x0, "Maximum Transmission Data Unit Size", HFILL }},
1069 { &hf_tns_nt_proto_characteristics, {
1070 "NT Protocol Characteristics", "tns.nt_proto_characteristics", FT_UINT16, BASE_HEX,
1071 NULL, 0x0, "NT Protocol Characteristics", HFILL }},
1072 { &hf_tns_ntp_flag_hangon, {
1073 "Hangon to listener connect", "tns.ntp_flag.hangon", FT_BOOLEAN, 16,
1074 NULL, 0x8000, "Hangon to listener connect", HFILL }},
1075 { &hf_tns_ntp_flag_crel, {
1076 "Confirmed release", "tns.ntp_flag.crel", FT_BOOLEAN, 16,
1077 NULL, 0x4000, "Confirmed release", HFILL }},
1078 { &hf_tns_ntp_flag_tduio, {
1079 "TDU based IO", "tns.ntp_flag.tduio", FT_BOOLEAN, 16,
1080 NULL, 0x2000, "TDU based IO", HFILL }},
1081 { &hf_tns_ntp_flag_srun, {
1082 "Spawner running", "tns.ntp_flag.srun", FT_BOOLEAN, 16,
1083 NULL, 0x1000, "Spawner running", HFILL }},
1084 { &hf_tns_ntp_flag_dtest, {
1085 "Data test", "tns.ntp_flag.dtest", FT_BOOLEAN, 16,
1086 NULL, 0x0800, "Data Test", HFILL }},
1087 { &hf_tns_ntp_flag_cbio, {
1088 "Callback IO supported", "tns.ntp_flag.cbio", FT_BOOLEAN, 16,
1089 NULL, 0x0400, "Callback IO supported", HFILL }},
1090 { &hf_tns_ntp_flag_asio, {
1091 "ASync IO Supported", "tns.ntp_flag.asio", FT_BOOLEAN, 16,
1092 NULL, 0x0200, "ASync IO Supported", HFILL }},
1093 { &hf_tns_ntp_flag_pio, {
1094 "Packet oriented IO", "tns.ntp_flag.pio", FT_BOOLEAN, 16,
1095 NULL, 0x0100, "Packet oriented IO", HFILL }},
1096 { &hf_tns_ntp_flag_grant, {
1097 "Can grant connection to another", "tns.ntp_flag.grant", FT_BOOLEAN, 16,
1098 NULL, 0x0080, "Can grant connection to another", HFILL }},
1099 { &hf_tns_ntp_flag_handoff, {
1100 "Can handoff connection to another", "tns.ntp_flag.handoff", FT_BOOLEAN, 16,
1101 NULL, 0x0040, "Can handoff connection to another", HFILL }},
1102 { &hf_tns_ntp_flag_sigio, {
1103 "Generate SIGIO signal", "tns.ntp_flag.sigio", FT_BOOLEAN, 16,
1104 NULL, 0x0020, "Generate SIGIO signal", HFILL }},
1105 { &hf_tns_ntp_flag_sigpipe, {
1106 "Generate SIGPIPE signal", "tns.ntp_flag.sigpipe", FT_BOOLEAN, 16,
1107 NULL, 0x0010, "Generate SIGPIPE signal", HFILL }},
1108 { &hf_tns_ntp_flag_sigurg, {
1109 "Generate SIGURG signal", "tns.ntp_flag.sigurg", FT_BOOLEAN, 16,
1110 NULL, 0x0008, "Generate SIGURG signal", HFILL }},
1111 { &hf_tns_ntp_flag_urgentio, {
1112 "Urgent IO supported", "tns.ntp_flag.urgentio", FT_BOOLEAN, 16,
1113 NULL, 0x0004, "Urgent IO supported", HFILL }},
1114 { &hf_tns_ntp_flag_fdio, {
1115 "Full duplex IO supported", "tns.ntp_flag.dfio", FT_BOOLEAN, 16,
1116 NULL, 0x0002, "Full duplex IO supported", HFILL }},
1117 { &hf_tns_ntp_flag_testop, {
1118 "Test operation", "tns.ntp_flag.testop", FT_BOOLEAN, 16,
1119 NULL, 0x0001, "Test operation", HFILL }},
1124 { &hf_tns_line_turnaround, {
1125 "Line Turnaround Value", "tns.line_turnaround", FT_UINT16, BASE_DEC,
1126 NULL, 0x0, "Line Turnaround Value", HFILL }},
1127 { &hf_tns_value_of_one, {
1128 "Value of 1 in Hardware", "tns.value_of_one", FT_BYTES, BASE_NONE,
1129 NULL, 0x0, "Value of 1 in Hardware", HFILL }},
1131 { &hf_tns_connect, {
1132 "Connect", "tns.connect", FT_BOOLEAN, BASE_NONE,
1133 NULL, 0x0, "Connect", HFILL }},
1134 { &hf_tns_connect_data_length, {
1135 "Length of Connect Data", "tns.connect_data_length", FT_UINT16, BASE_DEC,
1136 NULL, 0x0, "Length of Connect Data", HFILL }},
1137 { &hf_tns_connect_data_offset, {
1138 "Offset to Connect Data", "tns.connect_data_offset", FT_UINT16, BASE_DEC,
1139 NULL, 0x0, "Offset to Connect Data", HFILL }},
1140 { &hf_tns_connect_data_max, {
1141 "Maximum Receivable Connect Data", "tns.connect_data_max", FT_UINT32, BASE_DEC,
1142 NULL, 0x0, "Maximum Receivable Connect Data", HFILL }},
1144 { &hf_tns_connect_flags0, {
1145 "Connect Flags 0", "tns.connect_flags0", FT_UINT8, BASE_HEX,
1146 NULL, 0x0, "Connect Flags 0", HFILL }},
1147 { &hf_tns_connect_flags1, {
1148 "Connect Flags 1", "tns.connect_flags1", FT_UINT8, BASE_HEX,
1149 NULL, 0x0, "Connect Flags 1", HFILL }},
1151 { &hf_tns_conn_flag_nareq, {
1152 "NA services required", "tns.connect_flags.nareq", FT_BOOLEAN, 8,
1153 NULL, 0x10, "NA services required", HFILL }},
1154 { &hf_tns_conn_flag_nalink, {
1155 "NA services linked in", "tns.connect_flags.nalink", FT_BOOLEAN, 8,
1156 NULL, 0x08, "NA services linked in", HFILL }},
1157 { &hf_tns_conn_flag_enablena, {
1158 "NA services enabled", "tns.connect_flags.enablena", FT_BOOLEAN, 8,
1159 NULL, 0x04, "NA services enabled", HFILL }},
1160 { &hf_tns_conn_flag_ichg, {
1161 "Interchange is involved", "tns.connect_flags.ichg", FT_BOOLEAN, 8,
1162 NULL, 0x02, "Interchange is involved", HFILL }},
1163 { &hf_tns_conn_flag_wantna, {
1164 "NA services wanted", "tns.connect_flags.wantna", FT_BOOLEAN, 8,
1165 NULL, 0x01, "NA services wanted", HFILL }},
1168 { &hf_tns_trace_cf1, {
1169 "Trace Cross Facility Item 1", "tns.trace_cf1", FT_UINT32, BASE_HEX,
1170 NULL, 0x0, "Trace Cross Facility Item 1", HFILL }},
1171 { &hf_tns_trace_cf2, {
1172 "Trace Cross Facility Item 2", "tns.trace_cf2", FT_UINT32, BASE_HEX,
1173 NULL, 0x0, "Trace Cross Facility Item 2", HFILL }},
1174 { &hf_tns_trace_cid, {
1175 "Trace Unique Connection ID", "tns.trace_cid", FT_UINT64, BASE_HEX,
1176 NULL, 0x0, "Trace Unique Connection ID", HFILL }},
1177 { &hf_tns_connect_data, {
1178 "Connect Data", "tns.connect_data", FT_STRING, BASE_NONE,
1179 NULL, 0x0, "Connect Data", HFILL }},
1182 "Accept", "tns.accept", FT_BOOLEAN, BASE_NONE,
1183 NULL, 0x0, "Accept", HFILL }},
1184 { &hf_tns_accept_data_length, {
1185 "Accept Data Length", "tns.accept_data_length", FT_UINT16, BASE_DEC,
1186 NULL, 0x0, "Length of Accept Data", HFILL }},
1187 { &hf_tns_accept_data, {
1188 "Accept Data", "tns.accept_data", FT_STRING, BASE_NONE,
1189 NULL, 0x0, "Accept Data", HFILL }},
1190 { &hf_tns_accept_data_offset, {
1191 "Offset to Accept Data", "tns.accept_data_offset", FT_UINT16, BASE_DEC,
1192 NULL, 0x0, "Offset to Accept Data", HFILL }},
1196 "Refuse", "tns.refuse", FT_BOOLEAN, BASE_NONE,
1197 NULL, 0x0, "Refuse", HFILL }},
1198 { &hf_tns_refuse_reason_user, {
1199 "Refuse Reason (User)", "tns.refuse_reason_user", FT_UINT8, BASE_HEX,
1200 NULL, 0x0, "Refuse Reason from Application", HFILL }},
1201 { &hf_tns_refuse_reason_system, {
1202 "Refuse Reason (System)", "tns.refuse_reason_system", FT_UINT8, BASE_HEX,
1203 NULL, 0x0, "Refuse Reason from System", HFILL }},
1204 { &hf_tns_refuse_data_length, {
1205 "Refuse Data Length", "tns.refuse_data_length", FT_UINT16, BASE_DEC,
1206 NULL, 0x0, "Length of Refuse Data", HFILL }},
1207 { &hf_tns_refuse_data, {
1208 "Refuse Data", "tns.refuse_data", FT_STRING, BASE_NONE,
1209 NULL, 0x0, "Refuse Data", HFILL }},
1212 "Abort", "tns.abort", FT_BOOLEAN, BASE_NONE,
1213 NULL, 0x0, "Abort", HFILL }},
1214 { &hf_tns_abort_reason_user, {
1215 "Abort Reason (User)", "tns.abort_reason_user", FT_UINT8, BASE_HEX,
1216 NULL, 0x0, "Abort Reason from Application", HFILL }},
1217 { &hf_tns_abort_reason_system, {
1218 "Abort Reason (User)", "tns.abort_reason_system", FT_UINT8, BASE_HEX,
1219 NULL, 0x0, "Abort Reason from System", HFILL }},
1220 { &hf_tns_abort_data, {
1221 "Abort Data", "tns.abort_data", FT_STRING, BASE_NONE,
1222 NULL, 0x0, "Abort Data", HFILL }},
1225 "Marker", "tns.marker", FT_BOOLEAN, BASE_NONE,
1226 NULL, 0x0, "Marker", HFILL }},
1227 { &hf_tns_marker_type, {
1228 "Marker Type", "tns.marker.type", FT_UINT8, BASE_HEX,
1229 VALS(tns_marker_types), 0x0, "Marker Type", HFILL }},
1230 { &hf_tns_marker_data_byte, {
1231 "Marker Data Byte", "tns.marker.databyte", FT_UINT8, BASE_HEX,
1232 NULL, 0x0, "Marker Data Byte", HFILL }},
1233 { &hf_tns_marker_data, {
1234 "Marker Data", "tns.marker.data", FT_UINT16, BASE_HEX,
1235 NULL, 0x0, "Marker Data", HFILL }},
1237 { &hf_tns_control, {
1238 "Control", "tns.control", FT_BOOLEAN, BASE_NONE,
1239 NULL, 0x0, "Control", HFILL }},
1240 { &hf_tns_control_cmd, {
1241 "Control Command", "tns.control.cmd", FT_UINT16, BASE_HEX,
1242 VALS(tns_control_cmds), 0x0, "Control Command", HFILL }},
1243 { &hf_tns_control_data, {
1244 "Control Data", "tns.control.data", FT_BYTES, BASE_HEX,
1245 NULL, 0x0, "Control Data", HFILL }},
1247 { &hf_tns_redirect, {
1248 "Redirect", "tns.redirect", FT_BOOLEAN, BASE_NONE,
1249 NULL, 0x0, "Redirect", HFILL }},
1250 { &hf_tns_redirect_data_length, {
1251 "Redirect Data Length", "tns.redirect_data_length", FT_UINT16, BASE_DEC,
1252 NULL, 0x0, "Length of Redirect Data", HFILL }},
1253 { &hf_tns_redirect_data, {
1254 "Redirect Data", "tns.redirect_data", FT_STRING, BASE_NONE,
1255 NULL, 0x0, "Redirect Data", HFILL }},
1258 "Data", "tns.data", FT_BOOLEAN, BASE_NONE,
1259 NULL, 0x0, "Data", HFILL }},
1261 { &hf_tns_data_flag, {
1262 "Data Flag", "tns.data_flag", FT_UINT16, BASE_HEX,
1263 NULL, 0x0, "Data Flag", HFILL }},
1264 { &hf_tns_data_flag_send, {
1265 "Send Token", "tns.data_flag.send", FT_BOOLEAN, 16,
1266 NULL, 0x1, "Send Token", HFILL }},
1267 { &hf_tns_data_flag_rc, {
1268 "Request Confirmation", "tns.data_flag.rc", FT_BOOLEAN, 16,
1269 NULL, 0x2, "Request Confirmation", HFILL }},
1270 { &hf_tns_data_flag_c, {
1271 "Confirmation", "tns.data_flag.c", FT_BOOLEAN, 16,
1272 NULL, 0x4, "Confirmation", HFILL }},
1273 { &hf_tns_data_flag_reserved, {
1274 "Reserved", "tns.data_flag.reserved", FT_BOOLEAN, 16,
1275 NULL, 0x8, "Reserved", HFILL }},
1276 { &hf_tns_data_flag_more, {
1277 "More Data to Come", "tns.data_flag.more", FT_BOOLEAN, 16,
1278 NULL, 0x20, "More Data to Come", HFILL }},
1279 { &hf_tns_data_flag_eof, {
1280 "End of File", "tns.data_flag.eof", FT_BOOLEAN, 16,
1281 NULL, 0x40, "End of File", HFILL }},
1282 { &hf_tns_data_flag_dic, {
1283 "Do Immediate Confirmation", "tns.data_flag.dic", FT_BOOLEAN, 16,
1284 NULL, 0x80, "Do Immediate Confirmation", HFILL }},
1285 { &hf_tns_data_flag_rts, {
1286 "Request To Send", "tns.data_flag.rts", FT_BOOLEAN, 16,
1287 NULL, 0x100, "Request To Send", HFILL }},
1288 { &hf_tns_data_flag_sntt, {
1289 "Send NT Trailer", "tns.data_flag.sntt", FT_BOOLEAN, 16,
1290 NULL, 0x200, "Send NT Trailer", HFILL }},
1293 { &hf_tns_reserved_byte, {
1294 "Reserved Byte", "tns.reserved_byte", FT_BYTES, BASE_HEX,
1295 NULL, 0x0, "Reserved Byte", HFILL }},
1296 { &hf_tns_packet_type, {
1297 "Packet Type", "tns.type", FT_UINT8, BASE_DEC,
1298 VALS(tns_type_vals), 0x0, "Type of TNS packet", HFILL }}
1302 static gint *ett[] = {
1319 module_t *tns_module;
1321 proto_tns = proto_register_protocol(
1322 "Transparent Network Substrate Protocol", "TNS", "tns");
1323 proto_register_field_array(proto_tns, hf, array_length(hf));
1324 proto_register_subtree_array(ett, array_length(ett));
1326 tns_module = prefs_register_protocol(proto_tns, NULL);
1327 prefs_register_bool_preference(tns_module, "desegment_tns_messages",
1328 "Desegment all TNS messages spanning multiple TCP segments",
1329 "Whether the TNS dissector should desegment all messages spanning multiple TCP segments",
1334 proto_reg_handoff_tns(void)
1336 dissector_handle_t tns_handle;
1338 tns_handle = new_create_dissector_handle(dissect_tns, proto_tns);
1339 dissector_add("tcp.port", TCP_PORT_TNS, tns_handle);
1340 data_handle = find_dissector("data");