2 * Routines for TDS NetLib dissection
3 * Copyright 2000-2002, Brian Bruns <camber@ais.org>
4 * Copyright 2002, Steve Langasek <vorlon@netexpress.net>
6 * $Id: packet-tds.c,v 1.19 2003/08/28 04:19:29 guy Exp $
8 * Ethereal - Network traffic analyzer
9 * By Gerald Combs <gerald@ethereal.com>
10 * Copyright 1998 Gerald Combs
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.
28 * The NETLIB protocol is a small blocking protocol designed to allow TDS
29 * to be placed within different transports (TCP, DECNet, IPX/SPX). A
30 * NETLIB packet starts with an eight byte header containing:
32 * a one-byte packet type field;
34 * a one-byte status field;
36 * a two-byte big-endian size field giving the size of the packet,
37 * including the header;
39 * a two-byte big-endian channel number, used when multiple sessions
40 * are being multiplexed on a single connection;
42 * a one-byte packet number, giving "the frame number of a multiplexed
43 * message, modulo 256";
45 * a one-byte window, which is the number of frames to be sent
46 * before an acknowledgment message is received.
48 * followed by payload whose size is the value in the size field minus
51 * Microsoft Network Monitor 2.x dissects the 4 byte field (and indicates
52 * that the one-byte last packet indicator also contains other bits).
54 * The TDS protocol consists of a number of protocol data units (PDUs) that
55 * appear to be assembled from NETLIB packets, in the form of zero or more
56 * NETLIB packets with the last packet indicator clear and a final NETLIB
57 * packet with the last packet indicator set. The type of the TDS PDU is
58 * specified by the packet type field of the NETLIB header (presumably that
59 * field has the same value for all NETLIB packets that make up a TDS PDU).
61 * The "server response" PDU consists of a sequence of multiple items, each
62 * one beginning with a one byte type field at the start of the PDU. Some
63 * items are fixed length, some are variable length with a two byte size
64 * field following the item type, and then there is TDS_ROW_TOKEN in which
65 * size is determined by analyzing the result set returned from the server.
66 * This in effect means that we are hopelessly lost if we haven't seen the
67 * result set. Also, TDS 4/5 is byte order negotiable, which is specified
68 * in the login packet. We can attempt to determine it later on, but not
71 * Some preliminary documentation on the packet format can be found at
72 * http://www.freetds.org/tds.html
74 * Some more information can be found in
75 * http://download.nai.com/products/media/sniffer/support/sdos/sybase.pdf
77 * Much of this code was originally developed for the FreeTDS project.
78 * http://www.freetds.org
82 * Excerpts from Brian's posting to ethereal-dev:
84 * The TDS Protocol is actually a protocol within a protocol. On the outside
85 * there is netlib which is not so much a encapsulation as a blocking of the
86 * data, typically to 512 or 4096 bytes. Between this are the protocol data
87 * units for TDS. Netlib packets may be split over real packets, multiple
88 * netlib packets may appear in single real packets. TDS PDUs may be split
89 * over netlib packets (and real packets) and most certainly can appear
90 * multiple times within a netlib packet.
92 * Because of this, I abandoned my earlier attempt at making two dissectors,
93 * one for netlib and one for TDS. Counterintuitively, a single dissector
94 * turned out to be simpler than splitting it up.
96 * Here are some of the (hefty) limitations of the current code
98 * . We currently do not handle netlib headers that cross packet boundaries.
99 * This should be an easy fix.
100 * . I probably could have used the packet reassembly stuff, but I started
101 * this at version 0.8.20, so c'est la vie. It wouldn't have covered the
102 * netlib stuff anyway, so no big loss.
103 * . The older two layer version of the code dissected the PDU's, but the new
104 * version does not yet, it only labels the names. I need an elegant way to
105 * deal with dissecting data crossing (netlib and tcp) packet boundries. I
106 * think I have one, but ran out of time to do it.
107 * . It will only work on little endian platforms. Or rather I should say,
108 * the client that was captured must be little endian. TDS 7.0/8.0 is
109 * always LE; for TDS 4.2/5.0 look in the code for tvb_get_le*() functions,
110 * there are fields in the login packet which determine byte order.
111 * . result sets that span netlib packets are not working
112 * . TDS 7 and 4.2 result sets are not working yet
114 * All that said, the code does deal gracefully with different boudary
115 * conditions and what remains are the easier bits, IMHO.
117 * XXX - "real packets" means "TCP segments", for TCP.
119 * XXX - is it *REALLY* true that you can have more than one TDS PDU (as
120 * opposed to more than one server response item) per NETLIB packet? Or is
121 * all the data in a NETLIB packet put into a single TDS PDU? If so, then
122 * we can reassemble NETLIB packets using the standard TCP desegmentation
123 * code, and can reassemble TDS PDUs using "fragment_add_seq_check()",
124 * and more cleanly separate the NETLIB and TDS dissectors (although the
125 * "is this NETLIB" heuristic would have to look at TDS information past
126 * the NETLIB header, in order to make the heuristic strong enough not
127 * to get too many false positives; note that the heuristic should reject
128 * any putative NETLIB packet with a length field with a value < 8).
130 * That would substantially clean the dissector up, eliminating most of
131 * the per-packet data (we might still need information to handle
132 * TDS_ROW_TOKEN), getting rid of the stuff to handle data split across
133 * TCP segment boundaries in favor of simple reassembly code, and
134 * fixing some otherwise nasty-looking crashing bugs.
136 * NOTE: we assume that all the data in a NETLIB packet *can* be put into
137 * a single TDS PTU, so that we have separate reassembly of NETLIB
138 * packets and TDS PDUs; it seems to work, and it really did clean stuff
139 * up and fix crashes.
153 #include <epan/packet.h>
154 #include <epan/conversation.h>
156 #include "packet-smb-common.h"
157 #include "packet-frame.h"
158 #include "reassemble.h"
161 #define TDS_QUERY_PKT 1
162 #define TDS_LOGIN_PKT 2
163 #define TDS_RPC_PKT 3
164 #define TDS_RESP_PKT 4
165 #define TDS_RAW_PKT 5
166 #define TDS_CANCEL_PKT 6
167 #define TDS_BULK_DATA_PKT 7
168 #define TDS_OPEN_CHN_PKT 8
169 #define TDS_CLOSE_CHN_PKT 9
170 #define TDS_RES_ERROR_PKT 10
171 #define TDS_LOG_CHN_ACK_PKT 11
172 #define TDS_ECHO_PKT 12
173 #define TDS_LOGOUT_CHN_PKT 13
174 #define TDS_QUERY5_PKT 15 /* or "Normal tokenized request or response */
175 #define TDS_LOGIN7_PKT 16 /* or "Urgent tokenized request or response */
176 #define TDS_XXX7_PKT 18 /* seen in one capture */
178 #define is_valid_tds_type(x) ((x) >= TDS_QUERY_PKT && (x) <= TDS_XXX7_PKT)
180 /* The following constants are imported more or less directly from FreeTDS */
182 #define TDS5_DYN_TOKEN 231 /* 0xE7 TDS 5.0 only */
183 #define TDS5_DYNRES_TOKEN 236 /* 0xEC TDS 5.0 only */
184 #define TDS5_DYN3_TOKEN 215 /* 0xD7 TDS 5.0 only */
185 #define TDS_LANG_TOKEN 33 /* 0x21 TDS 5.0 only */
186 #define TDS_CLOSE_TOKEN 113 /* 0x71 TDS 5.0 only? ct_close() */
187 #define TDS_RET_STAT_TOKEN 121 /* 0x79 */
188 #define TDS_124_TOKEN 124 /* 0x7C TDS 4.2 only - TDS_PROCID */
189 #define TDS7_RESULT_TOKEN 129 /* 0x81 TDS 7.0 only */
190 #define TDS_COL_NAME_TOKEN 160 /* 0xA0 TDS 4.2 only */
191 #define TDS_COL_INFO_TOKEN 161 /* 0xA1 TDS 4.2 only - TDS_COLFMT */
192 /*#define TDS_TABNAME 164 */
193 /*#define TDS_COL_INFO 165 */
194 #define TDS_167_TOKEN 167 /* 0xA7 */
195 #define TDS_168_TOKEN 168 /* 0xA8 */
196 #define TDS_ORDER_BY_TOKEN 169 /* 0xA9 TDS_ORDER */
197 #define TDS_ERR_TOKEN 170 /* 0xAA */
198 #define TDS_MSG_TOKEN 171 /* 0xAB */
199 #define TDS_PARAM_TOKEN 172 /* 0xAC RETURNVALUE? */
200 #define TDS_LOGIN_ACK_TOKEN 173 /* 0xAD */
201 #define TDS_174_TOKEN 174 /* 0xAE TDS_CONTROL */
202 #define TDS_ROW_TOKEN 209 /* 0xD1 */
203 #define TDS_CMP_ROW_TOKEN 211 /* 0xD3 */
204 #define TDS_CAP_TOKEN 226 /* 0xE2 */
205 #define TDS_ENV_CHG_TOKEN 227 /* 0xE3 */
206 #define TDS_EED_TOKEN 229 /* 0xE5 */
207 #define TDS_AUTH_TOKEN 237 /* 0xED */
208 #define TDS_RESULT_TOKEN 238 /* 0xEE */
209 #define TDS_DONE_TOKEN 253 /* 0xFD TDS_DONE */
210 #define TDS_DONEPROC_TOKEN 254 /* 0xFE TDS_DONEPROC */
211 #define TDS_DONEINPROC_TOKEN 255 /* 0xFF TDS_DONEINPROC */
213 #define SYBCHAR 47 /* 0x2F */
214 #define SYBVARCHAR 39 /* 0x27 */
215 #define SYBINTN 38 /* 0x26 */
216 #define SYBINT1 48 /* 0x30 */
217 #define SYBINT2 52 /* 0x34 */
218 #define SYBINT4 56 /* 0x38 */
219 #define SYBINT8 127 /* 0x7F */
220 #define SYBFLT8 62 /* 0x3E */
221 #define SYBDATETIME 61 /* 0x3D */
222 #define SYBBIT 50 /* 0x32 */
223 #define SYBTEXT 35 /* 0x23 */
224 #define SYBNTEXT 99 /* 0x63 */
225 #define SYBIMAGE 34 /* 0x22 */
226 #define SYBMONEY4 122 /* 0x7A */
227 #define SYBMONEY 60 /* 0x3C */
228 #define SYBDATETIME4 58 /* 0x3A */
229 #define SYBREAL 59 /* 0x3B */
230 #define SYBBINARY 45 /* 0x2D */
231 #define SYBVOID 31 /* 0x1F */
232 #define SYBVARBINARY 37 /* 0x25 */
233 #define SYBNVARCHAR 103 /* 0x67 */
234 #define SYBBITN 104 /* 0x68 */
235 #define SYBNUMERIC 108 /* 0x6C */
236 #define SYBDECIMAL 106 /* 0x6A */
237 #define SYBFLTN 109 /* 0x6D */
238 #define SYBMONEYN 110 /* 0x6E */
239 #define SYBDATETIMN 111 /* 0x6F */
240 #define XSYBCHAR 167 /* 0xA7 */
241 #define XSYBVARCHAR 175 /* 0xAF */
242 #define XSYBNVARCHAR 231 /* 0xE7 */
243 #define XSYBNCHAR 239 /* 0xEF */
244 #define SYBUNIQUE 0x24
245 #define SYBVARIANT 0x62
247 #define is_fixed_coltype(x) (x==SYBINT1 || \
260 /* Initialize the protocol and registered fields */
261 static int proto_tds = -1;
262 static int hf_tds_type = -1;
263 static int hf_tds_status = -1;
264 static int hf_tds_size = -1;
265 static int hf_tds_channel = -1;
266 static int hf_tds_packet_number = -1;
267 static int hf_tds_window = -1;
268 static int hf_tds_reassembled_in = -1;
269 static int hf_tds_fragments = -1;
270 static int hf_tds_fragment = -1;
271 static int hf_tds_fragment_overlap = -1;
272 static int hf_tds_fragment_overlap_conflict = -1;
273 static int hf_tds_fragment_multiple_tails = -1;
274 static int hf_tds_fragment_too_long_fragment = -1;
275 static int hf_tds_fragment_error = -1;
277 static int hf_tds7_login_total_size = -1;
278 static int hf_tds7_version = -1;
279 static int hf_tds7_packet_size = -1;
280 static int hf_tds7_client_version = -1;
281 static int hf_tds7_client_pid = -1;
282 static int hf_tds7_connection_id = -1;
283 static int hf_tds7_option_flags1 = -1;
284 static int hf_tds7_option_flags2 = -1;
285 static int hf_tds7_sql_type_flags = -1;
286 static int hf_tds7_reserved_flags = -1;
287 static int hf_tds7_time_zone = -1;
288 static int hf_tds7_collation = -1;
290 /* Initialize the subtree pointers */
291 static gint ett_tds = -1;
292 static gint ett_tds_fragments = -1;
293 static gint ett_tds_fragment = -1;
294 static gint ett_tds_token = -1;
295 static gint ett_tds7_login = -1;
296 static gint ett_tds7_hdr = -1;
298 /* Desegmentation of Netlib buffers crossing TCP segment boundaries. */
299 static gboolean tds_desegment = TRUE;
301 static const fragment_items tds_frag_items = {
306 &hf_tds_fragment_overlap,
307 &hf_tds_fragment_overlap_conflict,
308 &hf_tds_fragment_multiple_tails,
309 &hf_tds_fragment_too_long_fragment,
310 &hf_tds_fragment_error,
311 &hf_tds_reassembled_in,
315 /* Tables for reassembly of fragments. */
316 static GHashTable *tds_fragment_table = NULL;
317 static GHashTable *tds_reassembled_table = NULL;
319 /* defragmentation of multi-buffer TDS PDUs */
320 static gboolean tds_defragment = TRUE;
322 static dissector_handle_t tds_tcp_handle;
323 static dissector_handle_t ntlmssp_handle;
324 static dissector_handle_t data_handle;
326 /* These correspond to the netlib packet type field */
327 static const value_string packet_type_names[] = {
328 {TDS_QUERY_PKT, "Query Packet"},
329 {TDS_LOGIN_PKT, "Login Packet"},
330 {TDS_RPC_PKT, "Remote Procedure Call Packet"},
331 {TDS_RESP_PKT, "Response Packet"},
332 {TDS_CANCEL_PKT, "Cancel Packet"},
333 {TDS_QUERY5_PKT, "TDS5 Query Packet"},
334 {TDS_LOGIN7_PKT, "TDS7/8 Login Packet"},
338 /* The status field */
340 #define is_valid_tds_status(x) ((x) <= STATUS_EVENT_NOTIFICATION)
342 #define STATUS_NOT_LAST_BUFFER 0x00
343 #define STATUS_LAST_BUFFER 0x01
344 #define STATUS_ATTN_REQUEST_ACK 0x02
345 #define STATUS_ATTN_REQUEST 0x03
346 #define STATUS_EVENT_NOTIFICATION 0x04
348 static const value_string status_names[] = {
349 {STATUS_NOT_LAST_BUFFER, "Not last buffer"},
350 {STATUS_LAST_BUFFER, "Last buffer in request or response"},
351 {STATUS_ATTN_REQUEST_ACK, "Acknowledgment of last attention request"},
352 {STATUS_ATTN_REQUEST, "Attention request"},
353 {STATUS_EVENT_NOTIFICATION, "Event notification"},
357 /* The one byte token at the start of each TDS PDU */
358 static const value_string token_names[] = {
359 {TDS5_DYN_TOKEN, "Dynamic SQL"},
360 {TDS5_DYNRES_TOKEN, "Dynamic Results"},
361 {TDS5_DYN3_TOKEN, "Dynamic (Unknown)"},
362 {TDS_LANG_TOKEN, "Language"},
363 {TDS_CLOSE_TOKEN, "Close Connection"},
364 {TDS_RET_STAT_TOKEN, "Return Status"},
365 {TDS_124_TOKEN, "Proc ID"},
366 {TDS7_RESULT_TOKEN, "Results"},
367 {TDS_COL_NAME_TOKEN, "Column Names"},
368 {TDS_COL_INFO_TOKEN, "Column Info"},
369 {TDS_167_TOKEN, "Unknown (167)"},
370 {TDS_168_TOKEN, "Unknown (168)"},
371 {TDS_ORDER_BY_TOKEN, "Order By"},
372 {TDS_ERR_TOKEN, "Error Message"},
373 {TDS_MSG_TOKEN, "Info Message"},
374 {TDS_PARAM_TOKEN, "Paramater"},
375 {TDS_LOGIN_ACK_TOKEN, "Login Acknowledgement"},
376 {TDS_174_TOKEN, "Unknown (174)"},
377 {TDS_ROW_TOKEN, "Row"},
378 {TDS_CMP_ROW_TOKEN, "Compute Row"},
379 {TDS_CAP_TOKEN, "Capabilities"},
380 {TDS_ENV_CHG_TOKEN, "Environment Change"},
381 {TDS_EED_TOKEN, "Extended Error"},
382 {TDS_AUTH_TOKEN, "Authentication"},
383 {TDS_RESULT_TOKEN, "Results"},
384 {TDS_DONE_TOKEN, "Done"},
385 {TDS_DONEPROC_TOKEN, "Done Proc"},
386 {TDS_DONEINPROC_TOKEN, "Done In Proc"},
390 static const value_string env_chg_names[] = {
395 {5, "Unicode Locale ID"},
396 {6, "Unicode Comparison Style"},
400 static const value_string login_field_names[] = {
414 #define MAX_COLUMNS 256
417 * This is where we store the column information to be used in decoding the
418 * TDS_ROW_TOKEN tokens.
427 struct _netlib_data {
429 struct _tds_col *columns[MAX_COLUMNS];
432 struct tds7_login_packet_hdr {
433 guint32 total_packet_size;
436 guint32 client_version;
438 guint32 connection_id;
439 guint8 option_flags1;
440 guint8 option_flags2;
441 guint8 sql_type_flags;
442 guint8 reserved_flags;
447 /* all the standard memory management stuff */
448 #define tds_column_length (sizeof(struct _tds_col))
449 #define tds_column_init_count 10
451 static GMemChunk *tds_column = NULL;
453 /* support routines */
455 dissect_tds_ntlmssp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
456 guint offset, guint length)
458 tvbuff_t *ntlmssp_tvb;
460 ntlmssp_tvb = tvb_new_subset(tvb, offset, length, length);
461 call_dissector(ntlmssp_handle, ntlmssp_tvb, pinfo, tree);
465 dissect_tds7_login(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
467 guint offset, i, offset2, len;
468 gboolean is_unicode = TRUE;
471 proto_item *login_hdr;
472 proto_tree *login_tree;
473 proto_item *header_hdr;
474 proto_tree *header_tree;
475 proto_item *length_hdr;
476 proto_tree *length_tree;
478 struct tds7_login_packet_hdr td7hdr;
479 gint length_remaining;
482 /* create display subtree for the protocol */
484 login_hdr = proto_tree_add_text(tree, tvb, offset, -1, "TDS7 Login Packet");
485 login_tree = proto_item_add_subtree(login_hdr, ett_tds7_login);
486 header_hdr = proto_tree_add_text(login_tree, tvb, offset, 36, "Login Packet Header");
487 header_tree = proto_item_add_subtree(header_hdr, ett_tds7_hdr);
489 td7hdr.total_packet_size = tvb_get_letohl(tvb, offset);
490 proto_tree_add_uint(header_tree, hf_tds7_login_total_size, tvb, offset, sizeof(td7hdr.total_packet_size), td7hdr.total_packet_size);
491 offset += sizeof(td7hdr.total_packet_size);
493 td7hdr.tds_version = tvb_get_ntohl(tvb, offset);
494 proto_tree_add_uint(header_tree, hf_tds7_version, tvb, offset, sizeof(td7hdr.tds_version), td7hdr.tds_version);
495 offset += sizeof(td7hdr.tds_version);
497 td7hdr.packet_size = tvb_get_ntohl(tvb, offset);
498 proto_tree_add_uint(header_tree, hf_tds7_packet_size, tvb, offset, sizeof(td7hdr.packet_size), td7hdr.packet_size);
499 offset += sizeof(td7hdr.packet_size);
501 td7hdr.client_version = tvb_get_ntohl(tvb, offset);
502 proto_tree_add_uint(header_tree, hf_tds7_client_version, tvb, offset, sizeof(td7hdr.client_version), td7hdr.client_version);
503 offset += sizeof(td7hdr.client_version);
505 td7hdr.client_pid = tvb_get_letohl(tvb, offset);
506 proto_tree_add_uint(header_tree, hf_tds7_client_pid, tvb, offset, sizeof(td7hdr.client_pid), td7hdr.client_pid);
507 offset += sizeof(td7hdr.client_pid);
509 td7hdr.connection_id= tvb_get_letohl(tvb, offset);
510 proto_tree_add_uint(header_tree, hf_tds7_connection_id, tvb, offset, sizeof(td7hdr.connection_id), td7hdr.connection_id);
511 offset += sizeof(td7hdr.connection_id);
513 td7hdr.option_flags1 = tvb_get_guint8(tvb, offset);
514 proto_tree_add_uint(header_tree, hf_tds7_option_flags1, tvb, offset, sizeof(td7hdr.option_flags1), td7hdr.option_flags1);
515 offset += sizeof(td7hdr.option_flags1);
517 td7hdr.option_flags2 = tvb_get_guint8(tvb, offset);
518 proto_tree_add_uint(header_tree, hf_tds7_option_flags2, tvb, offset, sizeof(td7hdr.option_flags2), td7hdr.option_flags2);
519 offset += sizeof(td7hdr.option_flags2);
521 td7hdr.sql_type_flags = tvb_get_guint8(tvb, offset);
522 proto_tree_add_uint(header_tree, hf_tds7_sql_type_flags, tvb, offset, sizeof(td7hdr.sql_type_flags), td7hdr.sql_type_flags);
523 offset += sizeof(td7hdr.sql_type_flags);
525 td7hdr.reserved_flags = tvb_get_guint8(tvb, offset);
526 proto_tree_add_uint(header_tree, hf_tds7_reserved_flags, tvb, offset, sizeof(td7hdr.reserved_flags), td7hdr.reserved_flags);
527 offset += sizeof(td7hdr.reserved_flags);
529 td7hdr.time_zone = tvb_get_ntohl(tvb, offset);
530 proto_tree_add_uint(header_tree, hf_tds7_time_zone, tvb, offset, sizeof(td7hdr.time_zone), td7hdr.time_zone);
531 offset += sizeof(td7hdr.time_zone);
533 td7hdr.collation = tvb_get_ntohl(tvb, offset);
534 proto_tree_add_uint(header_tree, hf_tds7_collation, tvb, offset, sizeof(td7hdr.collation), td7hdr.collation);
535 offset += sizeof(td7hdr.collation);
537 length_hdr = proto_tree_add_text(login_tree, tvb, offset, 50, "Lengths and offsets");
538 length_tree = proto_item_add_subtree(length_hdr, ett_tds7_hdr);
540 for (i = 0; i < 9; i++) {
541 offset2 = tvb_get_letohs(tvb, offset + i*4);
542 len = tvb_get_letohs(tvb, offset + i*4 + 2);
543 proto_tree_add_text(length_tree, tvb, offset + i*4, 2,
545 val_to_str(i, login_field_names, "Unknown"),
547 proto_tree_add_text(length_tree, tvb, offset + i*4 + 2, 2,
549 val_to_str(i, login_field_names, "Unknown"),
552 if (is_unicode == TRUE) {
553 val = tvb_fake_unicode(tvb, offset2, len,
557 val = tvb_get_string(tvb, offset2, len);
558 proto_tree_add_text(login_tree, tvb, offset2, len,
560 val_to_str(i, login_field_names, "Unknown"),
566 length_remaining = tvb_reported_length_remaining(tvb, offset2 + len);
567 if (length_remaining > 0) {
568 dissect_tds_ntlmssp(tvb, pinfo, login_tree, offset2 + len,
573 static int get_size_by_coltype(int servertype)
577 case SYBINT1: return 1; break;
578 case SYBINT2: return 2; break;
579 case SYBINT4: return 4; break;
580 case SYBINT8: return 8; break;
581 case SYBREAL: return 4; break;
582 case SYBFLT8: return 8; break;
583 case SYBDATETIME: return 8; break;
584 case SYBDATETIME4: return 4; break;
585 case SYBBIT: return 1; break;
586 case SYBBITN: return 1; break;
587 case SYBMONEY: return 8; break;
588 case SYBMONEY4: return 4; break;
589 case SYBUNIQUE: return 16; break;
590 default: return -1; break;
593 static int tds_is_fixed_token(int token)
597 case TDS_DONEPROC_TOKEN:
598 case TDS_DONEINPROC_TOKEN:
599 case TDS_RET_STAT_TOKEN:
605 static int tds_get_token_size(int token)
609 case TDS_DONEPROC_TOKEN:
610 case TDS_DONEINPROC_TOKEN:
612 case TDS_RET_STAT_TOKEN:
623 * data_to_string should take column data and turn it into something we can
624 * display on the tree.
626 static char *data_to_string(void *data, guint col_type, guint col_size)
628 static char result[256];
633 /* strncpy(result, (char *)data, col_size); */
634 for (i=0;i<col_size && i<(256-1);i++)
635 if (!isprint(((char *)data)[i])) result[i]='.';
636 else result[i]=((char *)data)[i];
640 sprintf(result, "%d", *(short *)data);
643 sprintf(result, "%d", *(int *)data);
646 sprintf(result, "Unexpected column_type %d", col_type);
654 * Since rows are special PDUs in that they are not fixed and lack a size field,
655 * the length must be computed using the column information seen in the result
656 * PDU. This function does just that.
659 tds_get_row_size(tvbuff_t *tvb, struct _netlib_data *nl_data, guint offset)
664 for (i = 0; i < nl_data->num_cols; i++) {
665 if (!is_fixed_coltype(nl_data->columns[i]->ctype)) {
666 csize = tvb_get_guint8(tvb, cur);
669 csize = get_size_by_coltype(nl_data->columns[i]->ctype);
673 return (cur - offset + 1);
677 * Read the results token and store the relevant information in the
678 * _netlib_data structure for later use (see tds_get_row_size).
681 read_results_tds5(tvbuff_t *tvb, struct _netlib_data *nl_data, guint offset)
687 len = tvb_get_letohs(tvb, offset+1);
691 * This would be the logical place to check for little/big endianess
692 * if we didn't see the login packet.
694 nl_data->num_cols = tvb_get_letohs(tvb, cur);
695 if (nl_data->num_cols > MAX_COLUMNS) {
696 nl_data->num_cols = 0;
702 for (i = 0; i < nl_data->num_cols; i++) {
703 nl_data->columns[i] = g_mem_chunk_alloc(tds_column);
704 name_len = tvb_get_guint8(tvb,cur);
710 nl_data->columns[i]->utype = tvb_get_letohs(tvb, cur);
713 cur += 2; /* unknown */
715 nl_data->columns[i]->ctype = tvb_get_guint8(tvb,cur);
718 if (!is_fixed_coltype(nl_data->columns[i]->ctype)) {
719 nl_data->columns[i]->csize = tvb_get_guint8(tvb,cur);
722 nl_data->columns[i]->csize =
723 get_size_by_coltype(nl_data->columns[i]->ctype);
731 * If the packet type from the netlib header is a login packet, then dig into
732 * the packet to see if this is a supported TDS version and verify the otherwise
733 * weak heuristics of the netlib check.
736 netlib_check_login_pkt(tvbuff_t *tvb, guint offset, packet_info *pinfo, guint8 type)
738 guint tds_major, bytes_avail;
740 bytes_avail = tvb_length(tvb) - offset;
742 * we have two login packet styles, one for TDS 4.2 and 5.0
744 if (type==TDS_LOGIN_PKT) {
745 /* Use major version number to validate TDS 4/5 login
748 /* Login packet is first in stream and should not be fragmented...
749 * if it is we are screwed */
750 if (bytes_avail < 467) return FALSE;
751 tds_major = tvb_get_guint8(tvb, 466);
752 if (tds_major != 4 && tds_major != 5) {
756 * and one added by Microsoft in SQL Server 7
758 } else if (type==TDS_LOGIN7_PKT) {
759 if (bytes_avail < 16) return FALSE;
760 tds_major = tvb_get_guint8(tvb, 15);
761 if (tds_major != 0x70 && tds_major != 0x80) {
764 } else if (type==TDS_QUERY5_PKT) {
765 if (bytes_avail < 9) return FALSE;
766 /* if this is a TDS 5.0 query check the token */
767 if (tvb_get_guint8(tvb, 8) != TDS_LANG_TOKEN) {
770 /* check if it is MS SQL default port */
771 } else if (pinfo->srcport != 1433 &&
772 pinfo->destport != 1433) {
773 /* otherwise, we can not ensure this is netlib */
774 /* beyond a reasonable doubt. */
781 dissect_tds_env_chg(tvbuff_t *tvb, guint offset, guint token_sz,
785 guint old_len, new_len, old_len_offset;
786 char *new_val = NULL, *old_val = NULL;
787 guint32 string_offset;
788 gboolean is_unicode = FALSE;
790 env_type = tvb_get_guint8(tvb, offset);
791 proto_tree_add_text(tree, tvb, offset, 1, "Type: %u (%s)", env_type,
792 val_to_str(env_type, env_chg_names, "Unknown"));
794 new_len = tvb_get_guint8(tvb, offset+1);
795 old_len_offset = offset + new_len + 2;
796 old_len = tvb_get_guint8(tvb, old_len_offset);
799 * If our lengths plus the lengths of the type and the lengths
800 * don't add up to the token size, it must be UCS2.
802 if (old_len + new_len + 3 != token_sz) {
804 old_len_offset = offset + (new_len * 2) + 2;
805 old_len = tvb_get_guint8(tvb, old_len_offset);
808 proto_tree_add_text(tree, tvb, offset + 1, 1, "New Value Length: %u",
811 string_offset = offset + 2;
812 if (is_unicode == TRUE) {
813 new_val = tvb_fake_unicode(tvb, string_offset,
817 new_val = tvb_get_string(tvb, string_offset, new_len);
818 proto_tree_add_text(tree, tvb, string_offset, new_len,
819 "New Value: %s", new_val);
823 proto_tree_add_text(tree, tvb, old_len_offset, 1, "Old Value Length: %u",
826 string_offset = old_len_offset + 1;
827 if (is_unicode == TRUE) {
828 old_val = tvb_fake_unicode(tvb, string_offset,
832 old_val = tvb_get_string(tvb, string_offset, old_len);
833 proto_tree_add_text(tree, tvb, string_offset, old_len,
834 "Old Value: %s", old_val);
840 dissect_tds_rpc(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
848 * XXX - how can we determine whether this is ASCII or Unicode?
850 len = tvb_get_letohs(tvb, offset);
851 proto_tree_add_text(tree, tvb, offset, 2, "RPC Name Length: %u", len);
854 val = tvb_fake_unicode(tvb, offset, len, TRUE);
856 proto_tree_add_text(tree, tvb, offset, len, "RPC Name: %s",
861 proto_tree_add_text(tree, tvb, offset, -1, "Unknown data");
865 dissect_tds_resp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
868 proto_item *token_item;
869 proto_tree *token_tree;
870 guint pos, token_sz = 0;
872 struct _netlib_data nl_data;
873 gint length_remaining;
875 memset(&nl_data, '\0', sizeof nl_data);
878 * Until we reach the end of the packet, read tokens.
881 while (tvb_reported_length_remaining(tvb, pos) > 0) {
883 token = tvb_get_guint8(tvb, pos);
885 if (tds_is_fixed_token(token)) {
886 token_sz = tds_get_token_size(token) + 1;
887 } else if (token == TDS_ROW_TOKEN) {
889 * Rows are special; they have no size field and
890 * aren't fixed length.
892 token_sz = tds_get_row_size(tvb, &nl_data, pos + 1);
894 token_sz = tvb_get_letohs(tvb, pos + 1) + 3;
896 length_remaining = tvb_ensure_length_remaining(tvb, pos);
897 if (token_sz > (guint)length_remaining)
898 token_sz = (guint)length_remaining;
900 token_item = proto_tree_add_text(tree, tvb, pos, token_sz,
901 "Token 0x%02x %s", token,
902 val_to_str(token, token_names, "Unknown Token Type"));
903 token_tree = proto_item_add_subtree(token_item, ett_tds_token);
906 * If it's a variable token, put the length field in here
907 * instead of replicating this for each token subdissector.
909 if (!tds_is_fixed_token(token) && token != TDS_ROW_TOKEN) {
910 proto_tree_add_text(token_tree, tvb, pos+1, 2,
911 "Length: %u", tvb_get_letohs(tvb, pos+1));
916 case TDS_RESULT_TOKEN:
918 * If it's a result token, we need to stash the
921 read_results_tds5(tvb, &nl_data, pos);
924 case TDS_ENV_CHG_TOKEN:
925 dissect_tds_env_chg(tvb, pos + 3, token_sz - 3,
930 dissect_tds_ntlmssp(tvb, pinfo, token_tree, pos + 3,
935 /* and step to the end of the token, rinse, lather, repeat */
941 dissect_netlib_buffer(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
944 proto_item *tds_item = NULL;
945 proto_tree *tds_tree = NULL;
950 guint8 packet_number;
951 gboolean save_fragmented;
953 fragment_data *fd_head;
957 /* create display subtree for the protocol */
958 tds_item = proto_tree_add_item(tree, proto_tds, tvb, offset, -1,
961 tds_tree = proto_item_add_subtree(tds_item, ett_tds);
963 type = tvb_get_guint8(tvb, offset);
965 proto_tree_add_uint(tds_tree, hf_tds_type, tvb, offset, 1,
968 status = tvb_get_guint8(tvb, offset + 1);
970 proto_tree_add_uint(tds_tree, hf_tds_status, tvb, offset + 1, 1,
973 size = tvb_get_ntohs(tvb, offset + 2);
975 proto_tree_add_uint(tds_tree, hf_tds_size, tvb, offset + 2, 2,
978 channel = tvb_get_ntohs(tvb, offset + 4);
980 proto_tree_add_uint(tds_tree, hf_tds_channel, tvb, offset + 4, 2,
983 packet_number = tvb_get_guint8(tvb, offset + 6);
985 proto_tree_add_uint(tds_tree, hf_tds_packet_number, tvb, offset + 6, 1,
987 proto_tree_add_item(tds_tree, hf_tds_window, tvb, offset + 7, 1,
990 offset += 8; /* skip Netlib header */
993 * Deal with fragmentation.
995 save_fragmented = pinfo->fragmented;
996 if (tds_defragment) {
997 if (status == STATUS_NOT_LAST_BUFFER) {
998 if (check_col(pinfo->cinfo, COL_INFO))
999 col_append_str(pinfo->cinfo, COL_INFO,
1000 " (Not last buffer)");
1002 len = tvb_reported_length_remaining(tvb, offset);
1003 fd_head = fragment_add_seq_check(tvb, offset, pinfo, channel,
1004 tds_fragment_table, tds_reassembled_table,
1005 packet_number - 1, len, status == STATUS_NOT_LAST_BUFFER);
1006 next_tvb = process_reassembled_data(tvb, offset, pinfo,
1007 "Reassembled TDS", fd_head, &tds_frag_items, NULL,
1011 * If this isn't the last buffer, just show it as a fragment.
1012 * (XXX - it'd be nice to dissect it if it's the first
1013 * buffer, but we'd need to do reassembly in order to
1016 * If this is the last buffer, dissect it.
1017 * (XXX - it'd be nice to show it as a fragment if it's part
1018 * of a fragmented message, but we'd need to do reassembly
1019 * in order to discover that.)
1021 if (status == STATUS_NOT_LAST_BUFFER)
1024 next_tvb = tvb_new_subset(tvb, offset, -1, -1);
1027 if (next_tvb != NULL) {
1031 dissect_tds_rpc(next_tvb, pinfo, tds_tree);
1035 dissect_tds_resp(next_tvb, pinfo, tds_tree);
1038 case TDS_LOGIN7_PKT:
1039 dissect_tds7_login(next_tvb, pinfo, tds_tree);
1043 proto_tree_add_text(tds_tree, next_tvb, 0, -1,
1048 next_tvb = tvb_new_subset (tvb, offset, -1, -1);
1049 call_dissector(data_handle, next_tvb, pinfo, tds_tree);
1054 dissect_tds_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1056 volatile gboolean first_time = TRUE;
1057 volatile int offset = 0;
1058 guint length_remaining;
1063 proto_item *tds_item = NULL;
1064 proto_tree *tds_tree = NULL;
1066 while (tvb_reported_length_remaining(tvb, offset) != 0) {
1067 length_remaining = tvb_ensure_length_remaining(tvb, offset);
1070 * Can we do reassembly?
1072 if (tds_desegment && pinfo->can_desegment) {
1074 * Yes - is the fixed-length part of the PDU
1075 * split across segment boundaries?
1077 if (length_remaining < 8) {
1079 * Yes. Tell the TCP dissector where the
1080 * data for this message starts in the data
1081 * it handed us, and how many more bytes we
1084 pinfo->desegment_offset = offset;
1085 pinfo->desegment_len = 8 - length_remaining;
1090 type = tvb_get_guint8(tvb, offset);
1093 * Get the length of the PDU.
1095 plen = tvb_get_ntohs(tvb, offset + 2);
1098 * The length is less than the header length.
1099 * Put in the type, status, and length, and
1100 * report the length as bogus.
1103 /* create display subtree for the protocol */
1104 tds_item = proto_tree_add_item(tree, proto_tds,
1105 tvb, offset, -1, FALSE);
1107 tds_tree = proto_item_add_subtree(tds_item,
1109 proto_tree_add_uint(tds_tree, hf_tds_type, tvb,
1111 proto_tree_add_item(tds_tree, hf_tds_status,
1112 tvb, offset + 1, 1, FALSE);
1113 proto_tree_add_uint_format(tds_tree,
1114 hf_tds_size, tvb, offset + 2, 2, plen,
1115 "Size: %u (bogus, should be >= 8)", plen);
1119 * Give up - we can't dissect any more of this
1126 * Can we do reassembly?
1128 if (tds_desegment && pinfo->can_desegment) {
1130 * Yes - is the PDU split across segment boundaries?
1132 if (length_remaining < plen) {
1134 * Yes. Tell the TCP dissector where the
1135 * data for this message starts in the data
1136 * it handed us, and how many more bytes we
1139 pinfo->desegment_offset = offset;
1140 pinfo->desegment_len = plen - length_remaining;
1146 if (check_col(pinfo->cinfo, COL_PROTOCOL))
1147 col_set_str(pinfo->cinfo, COL_PROTOCOL, "TDS");
1150 * Set the packet description based on its TDS packet
1153 if (check_col(pinfo->cinfo, COL_INFO)) {
1154 col_add_str(pinfo->cinfo, COL_INFO,
1155 val_to_str(type, packet_type_names,
1156 "Unknown Packet Type: %u"));
1162 * Construct a tvbuff containing the amount of the payload
1163 * we have available. Make its reported length the amount
1164 * of data in the PDU.
1166 * XXX - if reassembly isn't enabled. the subdissector will
1167 * throw a BoundsError exception, rather than a
1168 * ReportedBoundsError exception. We really want a tvbuff
1169 * where the length is "length", the reported length is
1170 * "plen", and the "if the snapshot length were infinite"
1171 * length is the minimum of the reported length of the tvbuff
1172 * handed to us and "plen", with a new type of exception
1173 * thrown if the offset is within the reported length but
1174 * beyond that third length, with that exception getting the
1175 * "Unreassembled Packet" error.
1177 length = length_remaining;
1180 next_tvb = tvb_new_subset(tvb, offset, length, plen);
1183 * Dissect the Netlib buffer.
1185 * Catch the ReportedBoundsError exception; if this
1186 * particular Netlib buffer happens to get a
1187 * ReportedBoundsError exception, that doesn't mean
1188 * that we should stop dissecting PDUs within this frame
1189 * or chunk of reassembled data.
1191 * If it gets a BoundsError, we can stop, as there's nothing
1192 * more to see, so we just re-throw it.
1195 dissect_netlib_buffer(next_tvb, pinfo, tree);
1197 CATCH(BoundsError) {
1200 CATCH(ReportedBoundsError) {
1201 show_reported_bounds_error(tvb, pinfo, tree);
1206 * Step to the next Netlib buffer.
1213 dissect_tds_tcp_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1219 conversation_t *conv;
1222 * If we don't have even enough data for a Netlib header,
1223 * just say it's not TDS.
1225 if (!tvb_bytes_exist(tvb, offset, 8))
1229 * Quickly scan all the data we have in order to see if
1230 * everything in it looks like Netlib traffic.
1232 while (tvb_bytes_exist(tvb, offset, 1)) {
1234 * Check the type field.
1236 type = tvb_get_guint8(tvb, offset);
1237 if (!is_valid_tds_type(type))
1241 * Check the status field, if it's present.
1243 if (!tvb_bytes_exist(tvb, offset + 1, 1))
1245 status = tvb_get_guint8(tvb, offset + 1);
1246 if (!is_valid_tds_status(status))
1250 * Get the length of the PDU.
1252 if (!tvb_bytes_exist(tvb, offset + 2, 2))
1254 plen = tvb_get_ntohs(tvb, offset + 2);
1257 * The length is less than the header length.
1264 * If we're at the beginning of the segment, check the
1265 * payload if it's a login packet.
1268 if (!netlib_check_login_pkt(tvb, offset, pinfo, type))
1273 * Step to the next Netlib buffer.
1279 * OK, it passes the test; assume the rest of this conversation
1282 conv = find_conversation(&pinfo->src, &pinfo->dst, pinfo->ptype,
1283 pinfo->srcport, pinfo->destport, 0);
1286 * No conversation exists yet - create one.
1288 conv = conversation_new(&pinfo->src, &pinfo->dst,
1289 pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
1291 conversation_set_dissector(conv, tds_tcp_handle);
1294 * Now dissect it as TDS.
1296 dissect_tds_tcp(tvb, pinfo, tree);
1304 * Initialize the fragment and reassembly tables.
1306 fragment_table_init(&tds_fragment_table);
1307 reassembled_table_init(&tds_reassembled_table);
1310 * Reinitialize the chunks of data for remembering row
1314 g_mem_chunk_destroy(tds_column);
1316 tds_column = g_mem_chunk_new("tds_column", tds_column_length,
1317 tds_column_init_count * tds_column_length,
1321 /* Register the protocol with Ethereal */
1323 /* this format is required because a script is used to build the C function
1324 that calls all the protocol registration.
1328 proto_register_netlib(void)
1330 static hf_register_info hf[] = {
1332 { "Type", "tds.type",
1333 FT_UINT8, BASE_HEX, VALS(packet_type_names), 0x0,
1334 "Packet Type", HFILL }
1337 { "Status", "tds.status",
1338 FT_UINT8, BASE_DEC, VALS(status_names), 0x0,
1339 "Frame status", HFILL }
1342 { "Size", "tds.size",
1343 FT_UINT16, BASE_DEC, NULL, 0x0,
1344 "Packet Size", HFILL }
1347 { "Channel", "tds.channel",
1348 FT_UINT16, BASE_DEC, NULL, 0x0,
1349 "Channel Number", HFILL }
1351 { &hf_tds_packet_number,
1352 { "Packet Number", "tds.packet_number",
1353 FT_UINT8, BASE_DEC, NULL, 0x0,
1354 "Packet Number", HFILL }
1357 { "Window", "tds.window",
1358 FT_UINT8, BASE_DEC, NULL, 0x0,
1361 { &hf_tds_fragment_overlap,
1362 { "Segment overlap", "tds.fragment.overlap",
1363 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
1364 "Fragment overlaps with other fragments", HFILL }
1366 { &hf_tds_fragment_overlap_conflict,
1367 { "Conflicting data in fragment overlap", "tds.fragment.overlap.conflict",
1368 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
1369 "Overlapping fragments contained conflicting data", HFILL }
1371 { &hf_tds_fragment_multiple_tails,
1372 { "Multiple tail fragments found", "tds.fragment.multipletails",
1373 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
1374 "Several tails were found when defragmenting the packet", HFILL }
1376 { &hf_tds_fragment_too_long_fragment,
1377 { "Segment too long", "tds.fragment.toolongfragment",
1378 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
1379 "Segment contained data past end of packet", HFILL }
1381 { &hf_tds_fragment_error,
1382 { "Defragmentation error", "tds.fragment.error",
1383 FT_FRAMENUM, BASE_NONE, NULL, 0x0,
1384 "Defragmentation error due to illegal fragments", HFILL }
1387 { "TDS Fragment", "tds.fragment",
1388 FT_FRAMENUM, BASE_NONE, NULL, 0x0,
1389 "TDS Fragment", HFILL }
1391 { &hf_tds_fragments,
1392 { "TDS Fragments", "tds.fragments",
1393 FT_NONE, BASE_NONE, NULL, 0x0,
1394 "TDS Fragments", HFILL }
1396 { &hf_tds_reassembled_in,
1397 { "Reassembled TDS in frame", "tds.reassembled_in",
1398 FT_FRAMENUM, BASE_NONE, NULL, 0x0,
1399 "This TDS packet is reassembled in this frame", HFILL }
1401 { &hf_tds7_login_total_size,
1402 { "Total Packet Length", "tds7login.total_len",
1403 FT_UINT32, BASE_DEC, NULL, 0x0,
1404 "TDS7 Login Packet total packet length", HFILL }
1407 { "TDS version", "tds7login.version",
1408 FT_UINT32, BASE_HEX, NULL, 0x0,
1409 "TDS version", HFILL }
1411 { &hf_tds7_packet_size,
1412 { "Packet Size", "tds7login.packet_size",
1413 FT_UINT32, BASE_DEC, NULL, 0x0,
1414 "Packet size", HFILL }
1416 { &hf_tds7_client_version,
1417 { "Client version", "tds7login.client_version",
1418 FT_UINT32, BASE_DEC, NULL, 0x0,
1419 "Client version", HFILL }
1421 { &hf_tds7_client_pid,
1422 { "Client PID", "tds7login.client_pid",
1423 FT_UINT32, BASE_DEC, NULL, 0x0,
1424 "Client PID", HFILL }
1426 { &hf_tds7_connection_id,
1427 { "Connection ID", "tds7login.connection_id",
1428 FT_UINT32, BASE_DEC, NULL, 0x0,
1429 "Connection ID", HFILL }
1431 { &hf_tds7_option_flags1,
1432 { "Option Flags 1", "tds7login.option_flags1",
1433 FT_UINT8, BASE_HEX, NULL, 0x0,
1434 "Option Flags 1", HFILL }
1436 { &hf_tds7_option_flags2,
1437 { "Option Flags 2", "tds7login.option_flags2",
1438 FT_UINT8, BASE_HEX, NULL, 0x0,
1439 "Option Flags 2", HFILL }
1441 { &hf_tds7_sql_type_flags,
1442 { "SQL Type Flags", "tds7login.sql_type_flags",
1443 FT_UINT8, BASE_HEX, NULL, 0x0,
1444 "SQL Type Flags", HFILL }
1446 { &hf_tds7_reserved_flags,
1447 { "Reserved Flags", "tds7login.reserved_flags",
1448 FT_UINT8, BASE_HEX, NULL, 0x0,
1449 "reserved flags", HFILL }
1451 { &hf_tds7_time_zone,
1452 { "Time Zone", "tds7login.time_zone",
1453 FT_UINT32, BASE_HEX, NULL, 0x0,
1454 "Time Zone", HFILL }
1456 { &hf_tds7_collation,
1457 { "Collation", "tds7login.collation",
1458 FT_UINT32, BASE_HEX, NULL, 0x0,
1459 "Collation", HFILL }
1462 static gint *ett[] = {
1470 module_t *tds_module;
1472 /* Register the protocol name and description */
1473 proto_tds = proto_register_protocol("Tabular Data Stream",
1476 /* Required function calls to register the header fields and subtrees used */
1477 proto_register_field_array(proto_tds, hf, array_length(hf));
1478 proto_register_subtree_array(ett, array_length(ett));
1480 tds_tcp_handle = create_dissector_handle(dissect_tds_tcp, proto_tds);
1482 tds_module = prefs_register_protocol(proto_tds, NULL);
1483 prefs_register_bool_preference(tds_module, "desegment_buffers",
1484 "Desegment all TDS buffers spanning multiple TCP segments",
1485 "Whether the TDS dissector should desegment all TDS buffers spanning multiple TCP segments",
1487 prefs_register_bool_preference(tds_module, "defragment",
1488 "Defragment all TDS messages with multiple buffers",
1489 "Whether the TDS dissector should defragment all messages spanning multiple Netlib buffers",
1492 register_init_routine(tds_init);
1495 /* If this dissector uses sub-dissector registration add a registration routine.
1496 This format is required because a script is used to find these routines and
1497 create the code that calls these routines.
1500 proto_reg_handoff_tds(void)
1502 /* dissector_add("tcp.port", 1433, dissect_tds,
1504 heur_dissector_add("tcp", dissect_tds_tcp_heur, proto_tds);
1506 ntlmssp_handle = find_dissector("ntlmssp");
1507 data_handle = find_dissector("data");