/* packet-tns.c
* Routines for Oracle TNS packet dissection
*
- * $Id: packet-tns.c,v 1.36 2002/08/28 21:00:36 jmayer 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>
}
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, 4, FALSE);
- }
- offset += 4;
+ 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, 4, FALSE);
- }
- offset += 4;
+ 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, 8, FALSE);
+ if ( connect_tree )
+ {
+ proto_tree_add_item(connect_tree, hf_tns_trace_cid, tvb,
+ offset, 8, FALSE);
+ }
+ offset += 8;
}
- offset += 8;
if ( connect_tree && cd_len > 0)
{
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
NULL, 0x0, "Service Options", HFILL }},
{ &hf_tns_sopt_flag_bconn, {
- "Broken Connect Notify", "tns.so_flag.bconn", FT_UINT16, BASE_BIN,
+ "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,
+ "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,
+ "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,
+ "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,
+ "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,
+ "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,
+ "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_UINT16, BASE_BIN,
+ "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,
+ "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,
+ "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,
+ "Can Send Attention", "tns.so_flag.sa", FT_BOOLEAN, 16,
NULL, 0x0002, "Can Send Attention", HFILL }},
"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,
+ "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,
+ "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,
+ "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,
+ "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,
+ "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,
+ "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,
+ "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,
+ "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,
+ "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,
+ "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,
+ "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,
+ "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,
+ "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,
+ "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,
+ "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,
+ "Test operation", "tns.ntp_flag.testop", FT_BOOLEAN, 16,
NULL, 0x0001, "Test operation", HFILL }},
NULL, 0x0, "Connect Flags 1", HFILL }},
{ &hf_tns_conn_flag_nareq, {
- "NA services required", "tns.connect_flags.nareq", FT_UINT8, BASE_BIN,
+ "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,
+ "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,
+ "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,
+ "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,
+ "NA services wanted", "tns.connect_flags.wantna", FT_BOOLEAN, 8,
NULL, 0x01, "NA services wanted", HFILL }},
"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,
+ "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,
+ "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,
+ "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,
+ "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,
+ "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,
+ "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,
+ "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,
+ "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,
+ "Send NT Trailer", "tns.data_flag.sntt", FT_BOOLEAN, 16,
NULL, 0x200, "Send NT Trailer", HFILL }},
{
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");
}