1999-11-29 19:43:26 +00:00
|
|
|
/* packet-tns.c
|
2001-02-03 08:21:47 +00:00
|
|
|
* Routines for Oracle TNS packet dissection
|
1999-11-29 19:43:26 +00:00
|
|
|
*
|
2001-04-19 23:02:44 +00:00
|
|
|
* $Id: packet-tns.c,v 1.14 2001/04/19 23:02:44 guy Exp $
|
1999-11-29 19:43:26 +00:00
|
|
|
*
|
|
|
|
* Ethereal - Network traffic analyzer
|
2000-01-07 22:05:43 +00:00
|
|
|
* By Gerald Combs <gerald@zing.org>
|
1999-11-29 19:43:26 +00:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#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 "packet.h"
|
|
|
|
#include "packet-tns.h"
|
|
|
|
|
|
|
|
static int proto_tns = -1;
|
|
|
|
static int hf_tns_request = -1;
|
|
|
|
static int hf_tns_response = -1;
|
|
|
|
static int hf_tns_length = -1;
|
|
|
|
static int hf_tns_packet_checksum = -1;
|
|
|
|
static int hf_tns_header_checksum = -1;
|
|
|
|
static int hf_tns_packet_type = -1;
|
|
|
|
static int hf_tns_reserved_byte = -1;
|
1999-11-30 17:58:32 +00:00
|
|
|
static int hf_tns_data_flag = -1;
|
|
|
|
static int hf_tns_sns = -1;
|
|
|
|
static int hf_tns_connect = -1;
|
|
|
|
static int hf_tns_version = -1;
|
|
|
|
static int hf_tns_compat_version = -1;
|
|
|
|
static int hf_tns_service_options = -1;
|
1999-11-29 19:43:26 +00:00
|
|
|
|
|
|
|
static gint ett_tns = -1;
|
1999-11-30 17:58:32 +00:00
|
|
|
static gint ett_tns_sns = -1;
|
|
|
|
static gint ett_tns_connect = -1;
|
|
|
|
static gint ett_sql = -1;
|
1999-11-29 19:43:26 +00:00
|
|
|
|
2000-04-08 07:07:42 +00:00
|
|
|
#define TCP_PORT_TNS 1521
|
|
|
|
|
1999-11-29 19:43:26 +00:00
|
|
|
static const value_string tns_type_vals[] = {
|
|
|
|
{TNS_TYPE_CONNECT, "Connect" },
|
|
|
|
{TNS_TYPE_ACCEPT, "Accept" },
|
|
|
|
{TNS_TYPE_DATA, "Data" },
|
|
|
|
{TNS_TYPE_RESEND, "Resend"},
|
2000-04-08 07:07:42 +00:00
|
|
|
{0, NULL}
|
1999-11-29 19:43:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-02-03 08:21:47 +00:00
|
|
|
static void dissect_tns_sns(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
1999-11-30 17:58:32 +00:00
|
|
|
proto_tree *tree, proto_tree *tns_tree)
|
|
|
|
{
|
|
|
|
proto_tree *sns_tree = NULL, *ti;
|
|
|
|
|
|
|
|
if ( tree )
|
|
|
|
{
|
2001-02-03 08:21:47 +00:00
|
|
|
ti = proto_tree_add_text(tns_tree, tvb, offset,
|
|
|
|
tvb_length_remaining(tvb, offset), "Secure Network Services");
|
1999-11-30 17:58:32 +00:00
|
|
|
sns_tree = proto_item_add_subtree(ti, ett_tns_sns);
|
|
|
|
|
2001-02-03 08:21:47 +00:00
|
|
|
proto_tree_add_boolean_hidden(tns_tree, hf_tns_sns, tvb, 0, 0,
|
|
|
|
TRUE);
|
1999-11-30 17:58:32 +00:00
|
|
|
}
|
2001-02-03 08:21:47 +00:00
|
|
|
|
|
|
|
if ( check_col(pinfo->fd, COL_INFO) )
|
1999-11-30 17:58:32 +00:00
|
|
|
{
|
2001-02-03 08:21:47 +00:00
|
|
|
col_append_fstr(pinfo->fd, COL_INFO, ", SNS");
|
1999-11-30 17:58:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( sns_tree )
|
|
|
|
{
|
2001-02-03 08:21:47 +00:00
|
|
|
dissect_data(tvb,offset,pinfo,sns_tree);
|
1999-11-30 17:58:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-03 08:21:47 +00:00
|
|
|
static void dissect_tns_data(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
1999-11-30 17:58:32 +00:00
|
|
|
proto_tree *tree, proto_tree *tns_tree)
|
1999-11-29 19:43:26 +00:00
|
|
|
{
|
1999-11-30 17:58:32 +00:00
|
|
|
|
|
|
|
if ( tree )
|
|
|
|
{
|
2001-02-03 08:21:47 +00:00
|
|
|
proto_tree_add_uint(tns_tree, hf_tns_data_flag, tvb,
|
|
|
|
offset, 2, FALSE);
|
1999-11-30 17:58:32 +00:00
|
|
|
}
|
|
|
|
offset += 2;
|
|
|
|
|
2001-02-03 08:21:47 +00:00
|
|
|
if ( tvb_bytes_exist(tvb, offset, 4) )
|
1999-11-30 17:58:32 +00:00
|
|
|
{
|
2001-02-03 08:21:47 +00:00
|
|
|
if ( tvb_get_guint8(tvb, offset) == 0xDE &&
|
|
|
|
tvb_get_guint8(tvb, offset+1) == 0xAD &&
|
|
|
|
tvb_get_guint8(tvb, offset+2) == 0xBE &&
|
|
|
|
tvb_get_guint8(tvb, offset+3) == 0xEF )
|
1999-11-30 17:58:32 +00:00
|
|
|
{
|
2001-02-03 08:21:47 +00:00
|
|
|
dissect_tns_sns(tvb,offset,pinfo,tree,tns_tree);
|
1999-11-30 17:58:32 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-03 08:21:47 +00:00
|
|
|
dissect_data(tvb,offset,pinfo,tree);
|
1999-11-29 19:43:26 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-02-03 08:21:47 +00:00
|
|
|
static void dissect_tns_connect(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
1999-11-30 17:58:32 +00:00
|
|
|
proto_tree *tree, proto_tree *tns_tree)
|
1999-11-29 19:43:26 +00:00
|
|
|
{
|
1999-11-30 17:58:32 +00:00
|
|
|
proto_tree *connect_tree = NULL, *ti;
|
|
|
|
|
|
|
|
if ( tree )
|
|
|
|
{
|
2001-02-03 08:21:47 +00:00
|
|
|
ti = proto_tree_add_text(tns_tree, tvb, offset,
|
|
|
|
tvb_length_remaining(tvb, offset), "Connect");
|
1999-11-30 17:58:32 +00:00
|
|
|
connect_tree = proto_item_add_subtree(ti, ett_tns_connect);
|
|
|
|
|
2001-02-03 08:21:47 +00:00
|
|
|
proto_tree_add_boolean_hidden(tns_tree, hf_tns_connect, tvb,
|
|
|
|
0, 0, TRUE);
|
1999-11-30 17:58:32 +00:00
|
|
|
}
|
|
|
|
|
2001-02-03 08:21:47 +00:00
|
|
|
if ( check_col(pinfo->fd, COL_INFO) )
|
1999-11-30 17:58:32 +00:00
|
|
|
{
|
2001-02-03 08:21:47 +00:00
|
|
|
col_append_str(pinfo->fd, COL_INFO, ", Connect");
|
1999-11-30 17:58:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( connect_tree )
|
|
|
|
{
|
2001-02-03 08:21:47 +00:00
|
|
|
proto_tree_add_item(connect_tree, hf_tns_version, tvb,
|
|
|
|
offset, 2, FALSE);
|
1999-11-30 17:58:32 +00:00
|
|
|
}
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
if ( connect_tree )
|
|
|
|
{
|
2001-02-03 08:21:47 +00:00
|
|
|
proto_tree_add_item(connect_tree, hf_tns_compat_version, tvb,
|
|
|
|
offset, 2, FALSE);
|
1999-11-30 17:58:32 +00:00
|
|
|
}
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
if ( connect_tree )
|
|
|
|
{
|
|
|
|
/* need to break down w/ bitfield */
|
2001-02-03 08:21:47 +00:00
|
|
|
proto_tree_add_uint(connect_tree, hf_tns_service_options, tvb,
|
|
|
|
offset, 2, tvb_get_ntohs(tvb, offset));
|
1999-11-30 17:58:32 +00:00
|
|
|
}
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
if ( connect_tree )
|
|
|
|
{
|
2001-02-03 08:21:47 +00:00
|
|
|
dissect_data(tvb,offset,pinfo,connect_tree);
|
1999-11-30 17:58:32 +00:00
|
|
|
}
|
1999-11-29 19:43:26 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-02-03 08:21:47 +00:00
|
|
|
static void dissect_tns_accept(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
1999-11-30 17:58:32 +00:00
|
|
|
proto_tree *tree, proto_tree *tns_tree)
|
1999-11-29 19:43:26 +00:00
|
|
|
{
|
2001-02-03 08:21:47 +00:00
|
|
|
dissect_data(tvb,offset,pinfo,tns_tree);
|
1999-11-29 19:43:26 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-04-08 07:07:42 +00:00
|
|
|
static void
|
2001-02-03 08:21:47 +00:00
|
|
|
dissect_tns(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
1999-11-29 19:43:26 +00:00
|
|
|
{
|
1999-11-30 09:48:31 +00:00
|
|
|
proto_tree *tns_tree = NULL, *ti;
|
2001-02-03 08:21:47 +00:00
|
|
|
int offset = 0;
|
1999-11-29 19:43:26 +00:00
|
|
|
guint16 length;
|
|
|
|
guint16 type;
|
|
|
|
|
2001-02-03 08:21:47 +00:00
|
|
|
if (check_col(pinfo->fd, COL_PROTOCOL))
|
|
|
|
col_set_str(pinfo->fd, COL_PROTOCOL, "TNS");
|
Add the "Edit:Protocols..." feature which currently only implements
the following:
It is now possible to enable/disable a particular protocol decoding
(i.e. the protocol dissector is void or not). When a protocol
is disabled, it is displayed as Data and of course, all linked
sub-protocols are disabled as well.
Disabling a protocol could be interesting:
- in case of buggy dissectors
- in case of wrong heuristics
- for performance reasons
- to decode the data as another protocol (TODO)
Currently (if I am not wrong), all dissectors but NFS can be disabled
(and dissectors that do not register protocols :-)
I do not like the way the RPC sub-dissectors are disabled (in the
sub-dissectors) since this could be done in the RPC dissector itself,
knowing the sub-protocol hfinfo entry (this is why, I've not modified
the NFS one yet).
Two functions are added in proto.c :
gboolean proto_is_protocol_enabled(int n);
void proto_set_decoding(int n, gboolean enabled);
and two MACROs which can be used in dissectors:
OLD_CHECK_DISPLAY_AS_DATA(index, pd, offset, fd, tree)
CHECK_DISPLAY_AS_DATA(index, tvb, pinfo, tree)
See also the XXX in proto_dlg.c and proto.c around the new functions.
svn path=/trunk/; revision=2267
2000-08-13 14:09:15 +00:00
|
|
|
|
2001-02-03 08:21:47 +00:00
|
|
|
if (check_col(pinfo->fd, COL_INFO))
|
1999-11-29 19:43:26 +00:00
|
|
|
{
|
2001-02-03 08:21:47 +00:00
|
|
|
col_add_str(pinfo->fd, COL_INFO,
|
|
|
|
(pinfo->match_port == pinfo->destport) ? "Request" : "Response");
|
1999-11-29 19:43:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (tree)
|
|
|
|
{
|
2001-02-03 08:21:47 +00:00
|
|
|
ti = proto_tree_add_item(tree, proto_tns, tvb, 0,
|
|
|
|
tvb_length(tvb), FALSE);
|
1999-11-29 19:43:26 +00:00
|
|
|
tns_tree = proto_item_add_subtree(ti, ett_tns);
|
|
|
|
|
2001-02-03 08:21:47 +00:00
|
|
|
if (pinfo->match_port == pinfo->destport)
|
1999-11-29 19:43:26 +00:00
|
|
|
{
|
2001-02-03 08:21:47 +00:00
|
|
|
proto_tree_add_boolean_hidden(tns_tree, hf_tns_request,
|
|
|
|
tvb, offset, tvb_length(tvb), TRUE);
|
|
|
|
proto_tree_add_text(tns_tree, tvb, offset,
|
|
|
|
tvb_length(tvb), "Request: <opaque data>");
|
1999-11-29 19:43:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-02-03 08:21:47 +00:00
|
|
|
proto_tree_add_boolean_hidden(tns_tree, hf_tns_response,
|
|
|
|
tvb, offset, tvb_length(tvb), TRUE);
|
|
|
|
proto_tree_add_text(tns_tree, tvb, offset,
|
|
|
|
tvb_length(tvb), "Response: <opaque data>");
|
1999-11-29 19:43:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-03 08:21:47 +00:00
|
|
|
length = tvb_get_ntohs(tvb, offset);
|
1999-11-29 19:43:26 +00:00
|
|
|
if (tree)
|
|
|
|
{
|
2001-02-03 08:21:47 +00:00
|
|
|
proto_tree_add_uint(tns_tree, hf_tns_length, tvb,
|
1999-11-29 19:43:26 +00:00
|
|
|
offset, 2, length);
|
|
|
|
}
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
if ( tree )
|
|
|
|
{
|
2001-02-03 08:21:47 +00:00
|
|
|
proto_tree_add_item(tns_tree, hf_tns_packet_checksum, tvb,
|
|
|
|
offset, 2, FALSE);
|
1999-11-29 19:43:26 +00:00
|
|
|
}
|
|
|
|
offset += 2;
|
|
|
|
|
2001-02-03 08:21:47 +00:00
|
|
|
type = tvb_get_guint8(tvb, offset);
|
1999-11-29 19:43:26 +00:00
|
|
|
if ( tree )
|
|
|
|
{
|
2001-02-03 08:21:47 +00:00
|
|
|
proto_tree_add_uint(tns_tree, hf_tns_packet_type, tvb,
|
1999-11-29 19:43:26 +00:00
|
|
|
offset, 1, type);
|
|
|
|
}
|
|
|
|
offset += 1;
|
|
|
|
|
2001-02-03 08:21:47 +00:00
|
|
|
if ( check_col(pinfo->fd, COL_INFO))
|
1999-11-29 19:43:26 +00:00
|
|
|
{
|
2001-02-03 08:21:47 +00:00
|
|
|
col_append_fstr(pinfo->fd, COL_INFO, ", %s (%u)",
|
1999-11-29 19:43:26 +00:00
|
|
|
val_to_str(type, tns_type_vals, "Unknown"), type);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( tree )
|
|
|
|
{
|
2001-02-03 08:21:47 +00:00
|
|
|
proto_tree_add_item(tns_tree, hf_tns_reserved_byte, tvb,
|
|
|
|
offset, 1, FALSE);
|
1999-11-29 19:43:26 +00:00
|
|
|
}
|
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
if ( tree )
|
|
|
|
{
|
2001-02-03 08:21:47 +00:00
|
|
|
proto_tree_add_item(tns_tree, hf_tns_header_checksum, tvb,
|
|
|
|
offset, 2, FALSE);
|
1999-11-29 19:43:26 +00:00
|
|
|
}
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case TNS_TYPE_CONNECT:
|
2001-02-03 08:21:47 +00:00
|
|
|
dissect_tns_connect(tvb,offset,pinfo,tree,tns_tree);
|
1999-11-29 19:43:26 +00:00
|
|
|
break;
|
|
|
|
case TNS_TYPE_ACCEPT:
|
2001-02-03 08:21:47 +00:00
|
|
|
dissect_tns_accept(tvb,offset,pinfo,tree,tns_tree);
|
1999-11-29 19:43:26 +00:00
|
|
|
break;
|
|
|
|
case TNS_TYPE_DATA:
|
2001-02-03 08:21:47 +00:00
|
|
|
dissect_tns_data(tvb,offset,pinfo,tree,tns_tree);
|
1999-11-29 19:43:26 +00:00
|
|
|
break;
|
|
|
|
default:
|
2001-02-03 08:21:47 +00:00
|
|
|
dissect_data(tvb,offset,pinfo,tns_tree);
|
1999-11-29 19:43:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void proto_register_tns(void)
|
|
|
|
{
|
|
|
|
static hf_register_info hf[] = {
|
1999-11-30 17:58:32 +00:00
|
|
|
{ &hf_tns_sns, {
|
|
|
|
"Secure Network Services", "tns.sns", FT_BOOLEAN, BASE_NONE,
|
|
|
|
NULL, 0x0, "Secure Network Services" }},
|
|
|
|
{ &hf_tns_connect, {
|
|
|
|
"Connect", "tns.connect", FT_BOOLEAN, BASE_NONE,
|
|
|
|
NULL, 0x0, "Connect" }},
|
1999-11-29 19:43:26 +00:00
|
|
|
{ &hf_tns_response, {
|
|
|
|
"Response", "tns.response", FT_BOOLEAN, BASE_NONE,
|
|
|
|
NULL, 0x0, "TRUE if TNS response" }},
|
|
|
|
{ &hf_tns_request, {
|
|
|
|
"Request", "tns.request", FT_BOOLEAN, BASE_NONE,
|
|
|
|
NULL, 0x0, "TRUE if TNS request" }},
|
|
|
|
{ &hf_tns_length, {
|
2001-04-19 23:02:44 +00:00
|
|
|
"Packet Length", "tns.length", FT_UINT32, BASE_DEC,
|
1999-11-29 19:43:26 +00:00
|
|
|
NULL, 0x0, "Length of TNS packet" }},
|
|
|
|
{ &hf_tns_packet_checksum, {
|
|
|
|
"Packet Checksum", "tns.packet_checksum", FT_UINT16, BASE_HEX,
|
|
|
|
NULL, 0x0, "Checksum of Packet Data" }},
|
|
|
|
{ &hf_tns_header_checksum, {
|
|
|
|
"Header Checksum", "tns.header_checksum", FT_UINT16, BASE_HEX,
|
|
|
|
NULL, 0x0, "Checksum of Header Data" }},
|
1999-11-30 17:58:32 +00:00
|
|
|
{ &hf_tns_data_flag, {
|
|
|
|
"Data Flag", "tns.data_flag", FT_UINT16, BASE_HEX,
|
|
|
|
NULL, 0x0, "Data Flag" }},
|
|
|
|
{ &hf_tns_version, {
|
|
|
|
"Version", "tns.version", FT_UINT16, BASE_DEC,
|
|
|
|
NULL, 0x0, "Version" }},
|
|
|
|
{ &hf_tns_compat_version, {
|
|
|
|
"Version (Compatible)", "tns.compat_version", FT_UINT16, BASE_DEC,
|
|
|
|
NULL, 0x0, "Version (Compatible)" }},
|
|
|
|
{ &hf_tns_service_options, {
|
|
|
|
"Service Options", "tns.service_options", FT_UINT16, BASE_HEX,
|
|
|
|
NULL, 0x0, "Service Options" }},
|
1999-11-29 19:43:26 +00:00
|
|
|
{ &hf_tns_reserved_byte, {
|
|
|
|
"Reserved Byte", "tns.reserved_byte", FT_BYTES, BASE_HEX,
|
|
|
|
NULL, 0x0, "Reserved Byte" }},
|
|
|
|
{ &hf_tns_packet_type, {
|
2001-04-19 23:02:44 +00:00
|
|
|
"Packet Type", "tns.type", FT_UINT8, BASE_DEC,
|
1999-11-29 19:43:26 +00:00
|
|
|
VALS(tns_type_vals), 0x0, "Type of TNS packet" }}
|
|
|
|
};
|
|
|
|
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_tns,
|
1999-11-30 17:58:32 +00:00
|
|
|
&ett_tns_sns,
|
|
|
|
&ett_tns_connect,
|
|
|
|
&ett_sql
|
1999-11-29 19:43:26 +00:00
|
|
|
};
|
|
|
|
proto_tns = proto_register_protocol(
|
2001-01-03 06:56:03 +00:00
|
|
|
"Transparent Network Substrate Protocol", "TNS", "tns");
|
1999-11-29 19:43:26 +00:00
|
|
|
proto_register_field_array(proto_tns, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
|
|
|
}
|
2000-04-08 07:07:42 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
proto_reg_handoff_tns(void)
|
|
|
|
{
|
2001-02-03 08:21:47 +00:00
|
|
|
dissector_add("tcp.port", TCP_PORT_TNS, dissect_tns, proto_tns);
|
2000-04-08 07:07:42 +00:00
|
|
|
}
|