HACK: 2nd try to match RowsetProperties
[wireshark-wip.git] / epan / dissectors / packet-dtpt.c
blob1d8f9104e893dcb468502af2c749ad1d3599f1b1
1 /* packet-dtpt.c
2 * Routines for Microsoft ActiveSync Desktop Pass-Through (DTPT) packet
3 * dissection
5 * Uwe Girlich <uwe@planetquake.com>
6 * http://www.synce.org/moin/ProtocolDocumentation/DesktopPassThrough
8 * $Id$
10 * Wireshark - Network traffic analyzer
11 * By Gerald Combs <gerald@wireshark.org>
12 * Copyright 1998 Gerald Combs
14 * Copied from packet-quake.c
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation; either version 2
19 * of the License, or (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
31 #include "config.h"
33 #include <string.h>
35 #include <glib.h>
36 #include <epan/packet.h>
37 #include <epan/conversation.h>
38 #include <epan/prefs.h>
39 #include <epan/aftypes.h>
40 #include <epan/ipproto.h>
42 void proto_register_dtpt(void);
44 static int proto_dtpt = -1;
46 static int hf_dtpt_version = -1;
47 static int hf_dtpt_message_type = -1;
48 static int hf_dtpt_flags = -1;
49 static int hf_dtpt_flags_deep = -1;
50 static int hf_dtpt_flags_containers = -1;
51 static int hf_dtpt_flags_nocontainers = -1;
52 static int hf_dtpt_flags_nearest = -1;
53 static int hf_dtpt_flags_return_name = -1;
54 static int hf_dtpt_flags_return_type = -1;
55 static int hf_dtpt_flags_return_version = -1;
56 static int hf_dtpt_flags_return_comment = -1;
57 static int hf_dtpt_flags_return_addr = -1;
58 static int hf_dtpt_flags_return_blob = -1;
59 static int hf_dtpt_flags_return_aliases = -1;
60 static int hf_dtpt_flags_return_query_string = -1;
61 static int hf_dtpt_flags_flushcache = -1;
62 static int hf_dtpt_flags_flushprevious = -1;
63 static int hf_dtpt_flags_res_service = -1;
64 static int hf_dtpt_payload_size = -1;
65 static int hf_dtpt_handle = -1;
66 static int hf_dtpt_error = -1;
67 static int hf_dtpt_buffer_size = -1;
68 static int hf_dtpt_data_size = -1;
69 static int hf_dtpt_queryset_rawsize = -1;
70 static int hf_dtpt_queryset_size = -1;
71 static int hf_dtpt_queryset_service_instance_name_pointer = -1;
72 static int hf_dtpt_queryset_service_class_id_pointer = -1;
73 static int hf_dtpt_queryset_version = -1;
74 static int hf_dtpt_queryset_comment_pointer = -1;
75 static int hf_dtpt_queryset_namespace = -1;
76 static int hf_dtpt_queryset_provider_id_pointer = -1;
77 static int hf_dtpt_queryset_context_pointer = -1;
78 static int hf_dtpt_queryset_protocols_number = -1;
79 static int hf_dtpt_queryset_protocols_pointer = -1;
80 static int hf_dtpt_queryset_query_string_pointer = -1;
81 static int hf_dtpt_queryset_cs_addrs_number = -1;
82 static int hf_dtpt_queryset_cs_addrs_pointer = -1;
83 static int hf_dtpt_queryset_output_flags = -1;
84 static int hf_dtpt_queryset_blob_pointer = -1;
85 static int hf_dtpt_wstring_length = -1;
86 static int hf_dtpt_wstring_data = -1;
87 static int hf_dtpt_guid_length = -1;
88 static int hf_dtpt_guid_data = -1;
89 static int hf_dtpt_service_instance_name = -1;
90 static int hf_dtpt_service_class_id = -1;
91 static int hf_dtpt_comment = -1;
92 static int hf_dtpt_ns_provider_id = -1;
93 static int hf_dtpt_context = -1;
94 static int hf_dtpt_protocols_number = -1;
95 static int hf_dtpt_protocols_length = -1;
96 static int hf_dtpt_protocol_family = -1;
97 static int hf_dtpt_protocol_protocol = -1;
98 static int hf_dtpt_query_string = -1;
99 static int hf_dtpt_cs_addrs_number = -1;
100 static int hf_dtpt_cs_addrs_length1 = -1;
101 static int hf_dtpt_cs_addr_socket_type = -1;
102 static int hf_dtpt_cs_addr_protocol = -1;
103 static int hf_dtpt_cs_addr_local_pointer = -1;
104 static int hf_dtpt_cs_addr_local_length = -1;
105 static int hf_dtpt_cs_addr_local = -1;
106 static int hf_dtpt_cs_addr_remote_pointer = -1;
107 static int hf_dtpt_cs_addr_remote_length = -1;
108 static int hf_dtpt_cs_addr_remote = -1;
109 static int hf_dtpt_sockaddr_length = -1;
110 static int hf_dtpt_sockaddr_family = -1;
111 static int hf_dtpt_sockaddr_port = -1;
112 static int hf_dtpt_sockaddr_address = -1;
113 static int hf_dtpt_blob_rawsize = -1;
114 static int hf_dtpt_blob_size = -1;
115 static int hf_dtpt_blob_data_pointer = -1;
116 static int hf_dtpt_blob_data_length = -1;
117 static int hf_dtpt_blob_data = -1;
118 static int hf_dtpt_connect_addr = -1;
120 static gint ett_dtpt = -1;
121 static gint ett_dtpt_flags = -1;
122 static gint ett_dtpt_queryset = -1;
123 static gint ett_dtpt_wstring = -1;
124 static gint ett_dtpt_guid = -1;
125 static gint ett_dtpt_protocols = -1;
126 static gint ett_dtpt_protocol = -1;
127 static gint ett_dtpt_cs_addrs = -1;
128 static gint ett_dtpt_cs_addr1 = -1;
129 static gint ett_dtpt_cs_addr2 = -1;
130 static gint ett_dtpt_sockaddr = -1;
131 static gint ett_dtpt_blobraw = -1;
132 static gint ett_dtpt_blob = -1;
136 static dissector_handle_t dtpt_conversation_handle;
137 /** static dissector_handle_t dtpt_data_handle; **/
138 static dissector_handle_t data_handle;
141 /* Server port */
142 static unsigned int gbl_dtptServerPort=5721;
144 static const value_string names_message_type[] = {
145 #define LookupBeginRequest 9
146 { LookupBeginRequest, "LookupBeginRequest" },
147 #define LookupBeginResponse 10
148 { LookupBeginResponse, "LookupBeginResponse" },
149 #define LookupNextRequest 11
150 { LookupNextRequest, "LookupNextRequest" },
151 #define LookupNextResponse 12
152 { LookupNextResponse, "LookupNextResponse" },
153 #define LookupEndRequest 13
154 { LookupEndRequest, "LookupEndRequest" },
155 #define ConnectRequest 1
156 { ConnectRequest, "ConnectRequest" },
157 #define ConnectResponseOK 0x5A
158 { ConnectResponseOK, "ConnectResponseOK" },
159 #define ConnectResponseERR 0x5B
160 { ConnectResponseERR, "ConnectResponseERR" },
161 { 0, NULL }
164 static const value_string names_error[] = {
165 { 0, "OK" },
166 { 10014, "WSAEFAULT" },
167 { 10060, "WSAETIMEDOUT" },
168 { 10108, "WSASERVICE_NOT_FOUND" },
169 { 11001, "WSAHOST_NOT_FOUND" },
170 { 0, NULL }
173 static const value_string names_family[] = {
174 { WINSOCK_AF_INET, "AF_INET" },
175 { 0, NULL }
179 * Winsock's SOCK_ values. These are probably the same as they are on
180 * other OSes, as they probably all come from 4.2BSD, but it's still
181 * best to define them ourselves (to avoid problems if other OSes
182 * define them differently, and to avoid having to include system
183 * header files that might require a bunch of other includes).
185 #define WINSOCK_SOCK_STREAM 1
186 #define WINSOCK_SOCK_DGRAM 2
187 #define WINSOCK_SOCK_RAW 3
189 static const value_string names_socket_type[] = {
190 { WINSOCK_SOCK_STREAM, "SOCK_STREAM" },
191 { WINSOCK_SOCK_DGRAM, "SOCK_DGRAM" },
192 { WINSOCK_SOCK_RAW, "SOCK_RAW" },
193 { 0, NULL }
196 static const value_string names_protocol[] = {
197 { IP_PROTO_IP, "IPPROTO_IP" },
198 { IP_PROTO_TCP, "IPPROTO_TCP" },
199 { IP_PROTO_UDP, "IPPROTP_UDP" },
200 { 0, NULL }
203 #define LUP_DEEP 0x0001
204 #define LUP_CONTAINERS 0x0002
205 #define LUP_NOCONTAINERS 0x0004
206 #define LUP_NEAREST 0x0008
207 #define LUP_RETURN_NAME 0x0010
208 #define LUP_RETURN_TYPE 0x0020
209 #define LUP_RETURN_VERSION 0x0040
210 #define LUP_RETURN_COMMENT 0x0080
211 #define LUP_RETURN_ADDR 0x0100
212 #define LUP_RETURN_BLOB 0x0200
213 #define LUP_RETURN_ALIASES 0x0400
214 #define LUP_RETURN_QUERY_STRING 0x0800
215 #define LUP_FLUSHCACHE 0x1000
216 #define LUP_FLUSHPREVIOUS 0x2000
217 #define LUP_RES_SERVICE 0x8000
219 #define SOCKADDR_WITH_LEN 1
220 #define SOCKADDR_CONNECT 2
222 static int
223 dissect_dtpt_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
224 static int
225 dissect_dtpt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_);
228 static int
229 dissect_dtpt_wstring(tvbuff_t *tvb, guint offset, proto_tree *tree, int hfindex)
231 guint32 wstring_length;
232 guint32 wstring_size;
233 char *wstring_data = NULL;
234 guint32 wstring_padding = 0;
236 wstring_length = tvb_get_letohl(tvb, offset);
237 wstring_data = tvb_get_unicode_string(wmem_packet_scope(), tvb, offset+4, wstring_length, ENC_LITTLE_ENDIAN);
238 wstring_size = wstring_length;
239 if (wstring_size%4) {
240 wstring_padding = (4-wstring_size%4);
241 wstring_size += wstring_padding;
243 if (tree) {
244 proto_item *dtpt_wstring_item = NULL;
245 proto_tree *dtpt_wstring_tree = NULL;
246 dtpt_wstring_item = proto_tree_add_string(tree, hfindex,
247 tvb, offset+0, 4+wstring_size, wstring_data);
248 if (dtpt_wstring_item)
249 dtpt_wstring_tree = proto_item_add_subtree(dtpt_wstring_item, ett_dtpt_wstring);
250 if (dtpt_wstring_tree) {
251 proto_tree_add_uint(dtpt_wstring_tree, hf_dtpt_wstring_length,
252 tvb, offset+0, 4, wstring_length);
253 if (wstring_length)
254 proto_tree_add_string(dtpt_wstring_tree, hf_dtpt_wstring_data,
255 tvb, offset+4, wstring_length, wstring_data);
256 if (wstring_padding)
257 proto_tree_add_text(dtpt_wstring_tree, tvb,
258 offset+4+wstring_length,wstring_padding, "Padding");
261 offset += 4+wstring_size;
262 return offset;
265 static int
266 dissect_dtpt_guid(tvbuff_t *tvb, guint offset, proto_tree *tree, int hfindex)
268 guint32 guid_length;
270 guid_length = tvb_get_letohl(tvb, offset);
271 if (tree) {
272 e_guid_t guid;
273 proto_item *dtpt_guid_item = NULL;
274 proto_tree *dtpt_guid_tree = NULL;
275 const gchar *guid_name = NULL;
277 if (guid_length) {
278 tvb_get_guid(tvb, offset+4, &guid, ENC_LITTLE_ENDIAN);
280 else {
281 memset(&guid, 0, sizeof(guid));
283 dtpt_guid_item = proto_tree_add_guid(tree, hfindex, tvb, offset, 4 + guid_length, &guid);
284 if (dtpt_guid_item) {
285 guid_name = guids_get_guid_name(&guid);
286 if (guid_name != NULL)
287 proto_item_set_text(dtpt_guid_item, "%s: %s (%s)",
288 proto_registrar_get_name(hfindex), guid_name, guid_to_str(&guid));
289 dtpt_guid_tree = proto_item_add_subtree(dtpt_guid_item, ett_dtpt_guid);
291 if (dtpt_guid_tree) {
292 proto_item *dtpt_guid_data_item = NULL;
294 proto_tree_add_uint(dtpt_guid_tree, hf_dtpt_guid_length,
295 tvb, offset, 4, guid_length);
296 if (guid_length) {
297 dtpt_guid_data_item = proto_tree_add_guid(dtpt_guid_tree, hf_dtpt_guid_data,
298 tvb, offset+4, guid_length, &guid);
299 if (guid_name != NULL && dtpt_guid_data_item != NULL) {
300 proto_item_set_text(dtpt_guid_data_item, "%s: %s (%s)",
301 proto_registrar_get_name(hf_dtpt_guid_data),
302 guid_name, guid_to_str(&guid));
307 offset+=4;
308 offset+=guid_length;
310 return offset;
313 static int
314 dissect_dtpt_sockaddr(tvbuff_t *tvb, guint offset, proto_tree *tree, int hfindex, int sockaddr_type)
316 guint32 sockaddr_length = 0;
317 proto_item *sockaddr_item = NULL;
318 proto_tree *sockaddr_tree = NULL;
319 guint32 sockaddr_len1 = 0;
320 guint32 sockaddr_len2 = 0;
322 switch (sockaddr_type) {
323 case SOCKADDR_WITH_LEN:
324 sockaddr_len1=4;
325 sockaddr_len2=16;
326 break;
327 case SOCKADDR_CONNECT:
328 sockaddr_len1=0;
329 sockaddr_len2=30;
330 break;
333 if (sockaddr_type == SOCKADDR_WITH_LEN)
334 sockaddr_length = tvb_get_letohl(tvb, offset + 0);
336 if (tree) {
337 sockaddr_item = proto_tree_add_text(tree,
338 tvb, offset, sockaddr_len1+sockaddr_len2, "%s", proto_registrar_get_name(hfindex));
340 if (sockaddr_item)
341 sockaddr_tree = proto_item_add_subtree(sockaddr_item, ett_dtpt_sockaddr);
342 if (sockaddr_tree) {
343 if (sockaddr_type == SOCKADDR_WITH_LEN)
344 proto_tree_add_uint(sockaddr_tree, hf_dtpt_sockaddr_length,
345 tvb, offset+0, 4, sockaddr_length);
349 offset += sockaddr_len1;
351 if (sockaddr_tree) {
352 switch (sockaddr_type) {
353 case SOCKADDR_WITH_LEN: {
354 guint16 family;
356 family = tvb_get_letohs(tvb, offset);
357 proto_tree_add_uint(sockaddr_tree, hf_dtpt_sockaddr_family,
358 tvb, offset, 2, family);
359 switch (family) {
360 case WINSOCK_AF_INET: {
361 guint16 port;
362 guint32 addr;
364 port = tvb_get_ntohs(tvb,offset+2);
365 proto_tree_add_uint(sockaddr_tree, hf_dtpt_sockaddr_port,
366 tvb, offset+2,2,port);
367 addr = tvb_get_ipv4(tvb,offset+4);
368 proto_tree_add_ipv4(sockaddr_tree, hf_dtpt_sockaddr_address,
369 tvb, offset+4,4,addr);
370 proto_tree_add_text(sockaddr_tree, tvb, offset+8, 8, "Padding");
371 proto_item_append_text(sockaddr_item, ": %s:%d", ip_to_str((guint8*)&addr), port);
373 break;
376 break;
377 case SOCKADDR_CONNECT: {
378 guint32 family;
380 family = tvb_get_letohl(tvb, offset+0);
381 proto_tree_add_uint(sockaddr_tree, hf_dtpt_sockaddr_family,
382 tvb, offset+0, 4, family);
383 switch (family) {
384 case WINSOCK_AF_INET: {
385 guint16 port;
386 guint32 addr;
388 proto_tree_add_text(sockaddr_tree, tvb, offset+4, 4, "Padding");
389 port = tvb_get_ntohs(tvb,offset+8);
390 proto_tree_add_uint(sockaddr_tree, hf_dtpt_sockaddr_port,
391 tvb, offset+8,2,port);
392 addr = tvb_get_ipv4(tvb,offset+10);
393 proto_tree_add_ipv4(sockaddr_tree, hf_dtpt_sockaddr_address,
394 tvb, offset+10,4,addr);
395 proto_tree_add_text(sockaddr_tree, tvb, offset+14, 16, "Padding");
396 proto_item_append_text(sockaddr_item, ": %s:%d", ip_to_str((guint8*)&addr), port);
398 break;
401 break;
405 offset += sockaddr_len2;
406 return offset;
409 static int
410 dissect_dtpt_conversation(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
412 guint offset = 0;
414 /* First try to decode it as "normal" DTPT packets. */
415 offset = dissect_dtpt(tvb, pinfo, tree, NULL);
417 if (offset == 0) {
418 /* No, maybe it was a DTPT data packet. */
419 offset = dissect_dtpt_data(tvb, pinfo, tree);
422 /* Handle any remaining bytes ... */
423 if (tvb_reported_length_remaining(tvb, offset) > 0) {
424 /* ... as data. */
425 call_dissector(data_handle,
426 tvb_new_subset_remaining(tvb, offset), pinfo, tree);
428 return tvb_reported_length(tvb);
432 static int
433 dissect_dtpt_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
435 proto_item *dtpt_item = NULL;
436 proto_tree *dtpt_tree = NULL;
437 proto_item *dtpt_queryset_item = NULL;
438 proto_tree *dtpt_queryset_tree = NULL;
439 guint offset = 0;
440 guint32 queryset_rawsize;
441 guint32 queryset_size;
442 guint32 num_protocols;
443 guint32 protocols_length = 0;
444 guint32 addrs_start;
445 guint32 num_addrs;
446 guint32 addrs_length1 = 0;
447 proto_item *dtpt_addrs_item = NULL;
448 proto_tree *dtpt_addrs_tree = NULL;
449 guint32 blob_rawsize = 0;
450 guint32 blob_size = 0;
451 guint32 blob_data_length = 0;
453 queryset_rawsize = tvb_get_letohl(tvb, offset + 0);
454 if (queryset_rawsize != 60) return 0;
455 queryset_size = tvb_get_letohl(tvb, offset + 4);
456 if (queryset_size != 60) return 0;
458 col_set_str(pinfo->cinfo, COL_PROTOCOL, "DTPT");
459 col_set_str(pinfo->cinfo, COL_INFO, "QuerySet");
461 if (tree) {
462 dtpt_item = proto_tree_add_item(tree, proto_dtpt,
463 tvb, 0, -1, ENC_NA);
464 if (dtpt_item)
465 dtpt_tree = proto_item_add_subtree(dtpt_item, ett_dtpt);
468 if (dtpt_tree) {
469 proto_tree_add_uint(dtpt_tree, hf_dtpt_queryset_rawsize,
470 tvb, 0, 4, queryset_rawsize);
472 dtpt_queryset_item = proto_tree_add_text(dtpt_tree,
473 tvb, 4, 60, "QuerySet raw");
474 if (dtpt_queryset_item)
475 dtpt_queryset_tree = proto_item_add_subtree(dtpt_queryset_item, ett_dtpt_queryset);
477 if (dtpt_queryset_tree) {
478 proto_tree_add_uint(dtpt_queryset_tree, hf_dtpt_queryset_size,
479 tvb, offset+4+0, 4, queryset_size);
480 proto_tree_add_uint(dtpt_queryset_tree, hf_dtpt_queryset_service_instance_name_pointer,
481 tvb, offset+4+4, 4, tvb_get_letohl(tvb, offset+4+ 4));
482 proto_tree_add_uint(dtpt_queryset_tree, hf_dtpt_queryset_service_class_id_pointer,
483 tvb, offset+4+8, 4, tvb_get_letohl(tvb, offset+4+ 8));
484 proto_tree_add_uint(dtpt_queryset_tree, hf_dtpt_queryset_version,
485 tvb, offset+4+12, 4, tvb_get_letohl(tvb, offset+4+12));
486 proto_tree_add_uint(dtpt_queryset_tree, hf_dtpt_queryset_comment_pointer,
487 tvb, offset+4+16, 4, tvb_get_letohl(tvb, offset+4+16));
488 proto_tree_add_uint(dtpt_queryset_tree, hf_dtpt_queryset_namespace,
489 tvb, offset+4+20, 4, tvb_get_letohl(tvb, offset+4+20));
490 proto_tree_add_uint(dtpt_queryset_tree, hf_dtpt_queryset_provider_id_pointer,
491 tvb, offset+4+24, 4, tvb_get_letohl(tvb, offset+4+24));
492 proto_tree_add_uint(dtpt_queryset_tree, hf_dtpt_queryset_context_pointer,
493 tvb, offset+4+28, 4, tvb_get_letohl(tvb, offset+4+28));
494 proto_tree_add_uint(dtpt_queryset_tree, hf_dtpt_queryset_protocols_number,
495 tvb, offset+4+32, 4, tvb_get_letohl(tvb, offset+4+32));
496 proto_tree_add_uint(dtpt_queryset_tree, hf_dtpt_queryset_protocols_pointer,
497 tvb, offset+4+36, 4, tvb_get_letohl(tvb, offset+4+36));
498 proto_tree_add_uint(dtpt_queryset_tree, hf_dtpt_queryset_query_string_pointer,
499 tvb, offset+4+40, 4, tvb_get_letohl(tvb, offset+4+40));
500 proto_tree_add_uint(dtpt_queryset_tree, hf_dtpt_queryset_cs_addrs_number,
501 tvb, offset+4+44, 4, tvb_get_letohl(tvb, offset+4+44));
502 proto_tree_add_uint(dtpt_queryset_tree, hf_dtpt_queryset_cs_addrs_pointer,
503 tvb, offset+4+48, 4, tvb_get_letohl(tvb, offset+4+48));
504 proto_tree_add_uint(dtpt_queryset_tree, hf_dtpt_queryset_output_flags,
505 tvb, offset+4+52, 4, tvb_get_letohl(tvb, offset+4+52));
506 proto_tree_add_uint(dtpt_queryset_tree, hf_dtpt_queryset_blob_pointer,
507 tvb, offset+4+56, 4, tvb_get_letohl(tvb, offset+4+56));
511 offset += 4;
512 offset += 60;
514 offset = dissect_dtpt_wstring(tvb, offset, dtpt_tree, hf_dtpt_service_instance_name);
515 offset = dissect_dtpt_guid (tvb, offset, dtpt_tree, hf_dtpt_service_class_id );
516 offset = dissect_dtpt_wstring(tvb, offset, dtpt_tree, hf_dtpt_comment );
517 offset = dissect_dtpt_guid (tvb, offset, dtpt_tree, hf_dtpt_ns_provider_id );
518 offset = dissect_dtpt_wstring(tvb, offset, dtpt_tree, hf_dtpt_context );
519 num_protocols = tvb_get_letohl(tvb, offset);
520 if (num_protocols>0) {
521 protocols_length = tvb_get_letohl(tvb, offset+4);
523 if (dtpt_tree) {
524 proto_item *dtpt_protocols_item = NULL;
525 proto_tree *dtpt_protocols_tree = NULL;
526 guint32 i;
528 dtpt_protocols_item = proto_tree_add_text(dtpt_tree,
529 tvb, offset, 4+(num_protocols>0?4:0)+num_protocols*8,
530 "Protocols: %d", num_protocols);
531 if (dtpt_protocols_item)
532 dtpt_protocols_tree = proto_item_add_subtree(dtpt_protocols_item, ett_dtpt_protocols);
533 if (dtpt_protocols_tree) {
534 proto_tree_add_uint(dtpt_protocols_tree, hf_dtpt_protocols_number,
535 tvb, offset, 4, num_protocols);
536 if (num_protocols>0)
537 proto_tree_add_uint(dtpt_protocols_tree, hf_dtpt_protocols_length,
538 tvb, offset+4, 4, protocols_length);
539 for (i=0;i<num_protocols;i++) {
540 proto_item *dtpt_protocol_item = NULL;
541 proto_tree *dtpt_protocol_tree = NULL;
543 dtpt_protocol_item = proto_tree_add_text(dtpt_protocols_tree,
544 tvb, offset+4+4+i*8, 8, "Protocol[%d]", i+1);
545 if (dtpt_protocol_item)
546 dtpt_protocol_tree = proto_item_add_subtree(dtpt_protocol_item, ett_dtpt_protocol);
547 if (dtpt_protocol_tree) {
548 proto_tree_add_uint(dtpt_protocol_tree, hf_dtpt_protocol_family,
549 tvb, offset+4+4+i*8, 4, tvb_get_letohl(tvb, offset+4+4+i*8));
550 proto_tree_add_uint(dtpt_protocol_tree, hf_dtpt_protocol_protocol,
551 tvb, offset+4+4+i*8+4, 4, tvb_get_letohl(tvb, offset+4+4+i*8+4));
556 offset += 4 + (num_protocols>0?4:0) + num_protocols*8;
557 offset = dissect_dtpt_wstring(tvb, offset, dtpt_tree, hf_dtpt_query_string );
559 addrs_start = offset;
560 num_addrs = tvb_get_letohl(tvb, offset);
561 if (num_addrs>0) {
562 addrs_length1 = tvb_get_letohl(tvb, offset+4);
564 if (dtpt_tree) {
565 dtpt_addrs_item = proto_tree_add_text(dtpt_tree,
566 tvb, offset, -1, "Addresses");
567 if (dtpt_addrs_item)
568 dtpt_addrs_tree = proto_item_add_subtree(dtpt_addrs_item, ett_dtpt_cs_addrs);
569 if (dtpt_addrs_tree) {
570 proto_tree_add_uint(dtpt_addrs_tree, hf_dtpt_cs_addrs_number,
571 tvb, offset, 4, num_addrs);
572 if (num_addrs>0)
573 proto_tree_add_uint(dtpt_addrs_tree, hf_dtpt_cs_addrs_length1,
574 tvb, offset+4, 4, addrs_length1);
577 offset += 4 + (num_addrs>0?4:0);
579 if (num_addrs>0) {
580 guint32 i;
581 guint32 offset2;
583 offset2 = offset + 24*num_addrs;
585 for (i=0;i<num_addrs;i++,offset+=24) {
586 proto_item *dtpt_addr1_item = NULL;
587 proto_tree *dtpt_addr1_tree = NULL;
588 proto_item *dtpt_addr2_item = NULL;
589 proto_tree *dtpt_addr2_tree = NULL;
590 guint32 offset2_start;
592 if (dtpt_addrs_tree) {
593 dtpt_addr1_item = proto_tree_add_text(dtpt_addrs_tree,
594 tvb, offset, 24, "Address[%u] Part 1", i+1);
595 if (dtpt_addr1_item)
596 dtpt_addr1_tree = proto_item_add_subtree(dtpt_addr1_item,
597 ett_dtpt_cs_addr1);
598 if (dtpt_addr1_tree) {
599 proto_tree_add_uint(dtpt_addr1_tree, hf_dtpt_cs_addr_local_pointer,
600 tvb, offset+ 0, 4, tvb_get_letohl(tvb, offset+ 0));
601 proto_tree_add_uint(dtpt_addr1_tree, hf_dtpt_cs_addr_local_length,
602 tvb, offset+ 4, 4, tvb_get_letohl(tvb, offset+ 4));
603 proto_tree_add_uint(dtpt_addr1_tree, hf_dtpt_cs_addr_remote_pointer,
604 tvb, offset+ 8, 4, tvb_get_letohl(tvb, offset+ 8));
605 proto_tree_add_uint(dtpt_addr1_tree, hf_dtpt_cs_addr_remote_length,
606 tvb, offset+12, 4, tvb_get_letohl(tvb, offset+12));
607 proto_tree_add_uint(dtpt_addr1_tree, hf_dtpt_cs_addr_socket_type,
608 tvb, offset+16, 4, tvb_get_letohl(tvb, offset+16));
609 proto_tree_add_uint(dtpt_addr1_tree, hf_dtpt_cs_addr_protocol,
610 tvb, offset+20, 4, tvb_get_letohl(tvb, offset+20));
613 dtpt_addr2_item = proto_tree_add_text(dtpt_addrs_tree,
614 tvb, offset2, -1, "Address[%u] Part 2", i+1);
615 if (dtpt_addr2_item)
616 dtpt_addr2_tree = proto_item_add_subtree(dtpt_addr2_item,
617 ett_dtpt_cs_addr2);
620 offset2_start = offset2;
622 offset2 = dissect_dtpt_sockaddr(tvb, offset2, dtpt_addr2_tree, hf_dtpt_cs_addr_local, SOCKADDR_WITH_LEN);
623 offset2 = dissect_dtpt_sockaddr(tvb, offset2, dtpt_addr2_tree, hf_dtpt_cs_addr_remote, SOCKADDR_WITH_LEN);
625 if (dtpt_addr2_item)
626 proto_item_set_len(dtpt_addr2_item,
627 offset2 - offset2_start);
629 offset = offset2;
632 if (dtpt_addrs_item)
633 proto_item_set_len(dtpt_addrs_item, offset - addrs_start);
635 if (dtpt_item)
636 proto_item_set_len(dtpt_item, offset);
638 blob_rawsize = tvb_get_letohl(tvb, offset);
639 if (blob_rawsize>=4) {
640 blob_size = tvb_get_letohl(tvb,offset+4+0);
642 if (dtpt_tree) {
643 proto_item *dtpt_blobraw_item = NULL;
644 proto_tree *dtpt_blobraw_tree = NULL;
646 proto_tree_add_uint(dtpt_tree, hf_dtpt_blob_rawsize,
647 tvb, offset+0, 4, blob_rawsize);
648 if (blob_rawsize>0) {
649 dtpt_blobraw_item = proto_tree_add_text(dtpt_tree,
650 tvb, offset+4, blob_rawsize, "Blob raw");
651 if (dtpt_blobraw_item)
652 dtpt_blobraw_tree = proto_item_add_subtree(dtpt_blobraw_item,
653 ett_dtpt_blobraw);
654 if (dtpt_blobraw_tree) {
655 proto_tree_add_uint(dtpt_blobraw_tree, hf_dtpt_blob_size,
656 tvb, offset+4+0, 4, blob_size);
657 proto_tree_add_uint(dtpt_blobraw_tree, hf_dtpt_blob_data_pointer,
658 tvb, offset+4+4, 4, tvb_get_letohl(tvb,offset+4+4));
663 offset += 4+blob_rawsize;
665 if (dtpt_item)
666 proto_item_set_len(dtpt_item, offset);
668 if (blob_size>0) {
669 proto_item *dtpt_blob_item = NULL;
670 proto_tree *dtpt_blob_tree = NULL;
672 blob_data_length = tvb_get_letohl(tvb,offset);
674 if (dtpt_tree) {
675 dtpt_blob_item = proto_tree_add_text(dtpt_tree,
676 tvb, offset, 4+blob_data_length, "Blob");
677 if (dtpt_blob_item)
678 dtpt_blob_tree = proto_item_add_subtree(dtpt_blob_item,
679 ett_dtpt_blob);
680 if (dtpt_blob_tree) {
681 proto_tree_add_uint(dtpt_blob_tree, hf_dtpt_blob_data_length,
682 tvb, offset+0, 4, blob_data_length);
683 proto_tree_add_item(dtpt_blob_tree, hf_dtpt_blob_data,
684 tvb, offset+4, blob_data_length, ENC_NA);
687 offset += 4+blob_data_length;
688 if (dtpt_item)
689 proto_item_set_len(dtpt_item, offset);
692 return offset;
695 static int
696 dissect_dtpt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
698 proto_tree *dtpt_tree = NULL;
699 proto_item *dtpt_item = NULL;
700 guint8 version;
701 guint8 message_type;
702 guint32 flags;
703 guint32 payload_size;
705 version = tvb_get_guint8(tvb, 0);
706 if (version != 1) return 0;
707 message_type = tvb_get_guint8(tvb, 1);
708 switch (message_type) {
709 case LookupBeginRequest:
710 case LookupBeginResponse:
711 case LookupNextRequest:
712 case LookupNextResponse:
713 case LookupEndRequest:
714 if (tvb_reported_length(tvb) != 20) return 0;
715 break;
716 case ConnectRequest:
717 case ConnectResponseOK:
718 case ConnectResponseERR:
719 if (tvb_reported_length(tvb) != 36) return 0;
720 break;
721 default:
722 return 0;
725 col_set_str(pinfo->cinfo, COL_PROTOCOL, "DTPT");
726 col_add_str(pinfo->cinfo, COL_INFO, val_to_str(message_type, names_message_type, "Unknown (%d)"));
728 if (message_type == LookupBeginRequest) {
729 conversation_t *c;
730 c = find_or_create_conversation(pinfo);
731 conversation_set_dissector(c, dtpt_conversation_handle);
734 if (tree) {
735 dtpt_item = proto_tree_add_item(tree, proto_dtpt,
736 tvb, 0, -1, ENC_NA);
737 if (dtpt_item)
738 dtpt_tree = proto_item_add_subtree(dtpt_item, ett_dtpt);
741 if (dtpt_tree) {
742 proto_tree_add_uint(dtpt_tree, hf_dtpt_version,
743 tvb, 0, 1, version);
744 proto_tree_add_uint(dtpt_tree, hf_dtpt_message_type,
745 tvb, 1, 1, message_type);
747 switch (message_type) {
748 case LookupBeginRequest: {
749 proto_item* flags_item = NULL;
750 proto_tree* flags_tree = NULL;
752 flags = tvb_get_letohl(tvb, 12);
754 flags_item = proto_tree_add_uint(dtpt_tree, hf_dtpt_flags,
755 tvb, 12, 4, flags);
756 if (flags_item) {
757 flags_tree = proto_item_add_subtree(flags_item, ett_dtpt_flags);
759 if (flags_tree) {
760 proto_tree_add_boolean(flags_tree, hf_dtpt_flags_res_service, tvb, 12, 4, flags);
761 proto_tree_add_boolean(flags_tree, hf_dtpt_flags_flushprevious, tvb, 12, 4, flags);
762 proto_tree_add_boolean(flags_tree, hf_dtpt_flags_flushcache, tvb, 12, 4, flags);
763 proto_tree_add_boolean(flags_tree, hf_dtpt_flags_return_query_string, tvb, 12, 4, flags);
764 proto_tree_add_boolean(flags_tree, hf_dtpt_flags_return_aliases, tvb, 12, 4, flags);
765 proto_tree_add_boolean(flags_tree, hf_dtpt_flags_return_blob, tvb, 12, 4, flags);
766 proto_tree_add_boolean(flags_tree, hf_dtpt_flags_return_addr, tvb, 12, 4, flags);
767 proto_tree_add_boolean(flags_tree, hf_dtpt_flags_return_comment, tvb, 12, 4, flags);
768 proto_tree_add_boolean(flags_tree, hf_dtpt_flags_return_version, tvb, 12, 4, flags);
769 proto_tree_add_boolean(flags_tree, hf_dtpt_flags_return_type, tvb, 12, 4, flags);
770 proto_tree_add_boolean(flags_tree, hf_dtpt_flags_return_name, tvb, 12, 4, flags);
771 proto_tree_add_boolean(flags_tree, hf_dtpt_flags_nearest, tvb, 12, 4, flags);
772 proto_tree_add_boolean(flags_tree, hf_dtpt_flags_nocontainers, tvb, 12, 4, flags);
773 proto_tree_add_boolean(flags_tree, hf_dtpt_flags_containers, tvb, 12, 4, flags);
774 proto_tree_add_boolean(flags_tree, hf_dtpt_flags_deep, tvb, 12, 4, flags);
776 payload_size = tvb_get_letohl(tvb, 16);
777 proto_tree_add_uint(dtpt_tree, hf_dtpt_payload_size,
778 tvb, 16, 4, payload_size);
780 break;
781 case LookupBeginResponse: {
782 proto_tree_add_uint64(dtpt_tree, hf_dtpt_handle,
783 tvb, 4, 8, tvb_get_letoh64(tvb, 4));
784 proto_tree_add_uint(dtpt_tree, hf_dtpt_error,
785 tvb, 12, 4, tvb_get_letohl(tvb, 12));
787 break;
788 case LookupNextRequest: {
789 proto_tree_add_uint64(dtpt_tree, hf_dtpt_handle,
790 tvb, 4, 8, tvb_get_letoh64(tvb, 4));
791 proto_tree_add_uint(dtpt_tree, hf_dtpt_buffer_size,
792 tvb, 16, 4, tvb_get_letohl(tvb, 16));
794 break;
795 case LookupNextResponse: {
796 proto_tree_add_uint(dtpt_tree, hf_dtpt_error,
797 tvb, 12, 4, tvb_get_letohl(tvb, 12));
798 proto_tree_add_uint(dtpt_tree, hf_dtpt_data_size,
799 tvb, 16, 4, tvb_get_letohl(tvb, 16));
801 break;
802 case LookupEndRequest: {
803 proto_tree_add_uint64(dtpt_tree, hf_dtpt_handle,
804 tvb, 4, 8, tvb_get_letoh64(tvb, 4));
806 break;
807 case ConnectRequest: {
808 dissect_dtpt_sockaddr(tvb, 2, dtpt_tree, hf_dtpt_connect_addr, SOCKADDR_CONNECT);
809 proto_tree_add_uint(dtpt_tree, hf_dtpt_error,
810 tvb, 32, 4, tvb_get_letohl(tvb, 32));
812 break;
813 case ConnectResponseOK: {
814 dissect_dtpt_sockaddr(tvb, 2, dtpt_tree, hf_dtpt_connect_addr, SOCKADDR_CONNECT);
815 proto_tree_add_uint(dtpt_tree, hf_dtpt_error,
816 tvb, 32, 4, tvb_get_letohl(tvb, 32));
818 break;
819 case ConnectResponseERR: {
820 dissect_dtpt_sockaddr(tvb, 2, dtpt_tree, hf_dtpt_connect_addr, SOCKADDR_CONNECT);
821 proto_tree_add_uint(dtpt_tree, hf_dtpt_error,
822 tvb, 32, 4, tvb_get_letohl(tvb, 32));
824 break;
828 return tvb_length(tvb);
831 void proto_reg_handoff_dtpt(void);
833 void
834 proto_register_dtpt(void)
836 static hf_register_info hf[] = {
837 { &hf_dtpt_version,
838 { "Version", "dtpt.version",
839 FT_UINT8, BASE_DEC, NULL, 0x0,
840 "Protocol Version", HFILL }},
842 { &hf_dtpt_message_type,
843 { "Message Type", "dtpt.message_type",
844 FT_UINT8, BASE_DEC, VALS(names_message_type), 0x0,
845 "Packet Message Type", HFILL }},
847 { &hf_dtpt_flags,
848 { "ControlFlags", "dtpt.flags",
849 FT_UINT32, BASE_HEX, NULL, 0x0,
850 "ControlFlags as documented for WSALookupServiceBegin", HFILL }},
852 { &hf_dtpt_flags_deep,
853 { "DEEP", "dtpt.flags.deep",
854 FT_BOOLEAN, 32, TFS(&tfs_set_notset), LUP_DEEP,
855 NULL, HFILL }},
857 { &hf_dtpt_flags_containers,
858 { "CONTAINERS", "dtpt.flags.containers",
859 FT_BOOLEAN, 32, TFS(&tfs_set_notset), LUP_CONTAINERS,
860 NULL, HFILL }},
862 { &hf_dtpt_flags_nocontainers,
863 { "NOCONTAINERS", "dtpt.flags.nocontainers",
864 FT_BOOLEAN, 32, TFS(&tfs_set_notset), LUP_NOCONTAINERS,
865 NULL, HFILL }},
867 { &hf_dtpt_flags_nearest,
868 { "NEAREST", "dtpt.flags.nearest",
869 FT_BOOLEAN, 32, TFS(&tfs_set_notset), LUP_NEAREST,
870 NULL, HFILL }},
872 { &hf_dtpt_flags_return_name,
873 { "RETURN_NAME", "dtpt.flags.return_name",
874 FT_BOOLEAN, 32, TFS(&tfs_set_notset), LUP_RETURN_NAME,
875 NULL, HFILL }},
877 { &hf_dtpt_flags_return_type,
878 { "RETURN_TYPE", "dtpt.flags.return_type",
879 FT_BOOLEAN, 32, TFS(&tfs_set_notset), LUP_RETURN_TYPE,
880 NULL, HFILL }},
882 { &hf_dtpt_flags_return_version,
883 { "RETURN_VERSION", "dtpt.flags.return_version",
884 FT_BOOLEAN, 32, TFS(&tfs_set_notset), LUP_RETURN_VERSION,
885 NULL, HFILL }},
887 { &hf_dtpt_flags_return_comment,
888 { "RETURN_COMMENT", "dtpt.flags.return_comment",
889 FT_BOOLEAN, 32, TFS(&tfs_set_notset), LUP_RETURN_COMMENT,
890 NULL, HFILL }},
892 { &hf_dtpt_flags_return_addr,
893 { "RETURN_ADDR", "dtpt.flags.return_addr",
894 FT_BOOLEAN, 32, TFS(&tfs_set_notset), LUP_RETURN_ADDR,
895 NULL, HFILL }},
897 { &hf_dtpt_flags_return_blob,
898 { "RETURN_BLOB", "dtpt.flags.return_blob",
899 FT_BOOLEAN, 32, TFS(&tfs_set_notset), LUP_RETURN_BLOB,
900 NULL, HFILL }},
902 { &hf_dtpt_flags_return_aliases,
903 { "RETURN_ALIASES", "dtpt.flags.return_aliases",
904 FT_BOOLEAN, 32, TFS(&tfs_set_notset), LUP_RETURN_ALIASES,
905 NULL, HFILL }},
907 { &hf_dtpt_flags_return_query_string,
908 { "RETURN_QUERY_STRING", "dtpt.flags.return_query_string",
909 FT_BOOLEAN, 32, TFS(&tfs_set_notset), LUP_RETURN_QUERY_STRING,
910 NULL, HFILL }},
912 { &hf_dtpt_flags_flushcache,
913 { "FLUSHCACHE", "dtpt.flags.flushcache",
914 FT_BOOLEAN, 32, TFS(&tfs_set_notset), LUP_FLUSHCACHE,
915 NULL, HFILL }},
917 { &hf_dtpt_flags_flushprevious,
918 { "FLUSHPREVIOUS", "dtpt.flags.flushprevious",
919 FT_BOOLEAN, 32, TFS(&tfs_set_notset), LUP_FLUSHPREVIOUS,
920 NULL, HFILL }},
922 { &hf_dtpt_flags_res_service,
923 { "RES_SERVICE", "dtpt.flags.res_service",
924 FT_BOOLEAN, 32, TFS(&tfs_set_notset), LUP_RES_SERVICE,
925 NULL, HFILL }},
927 { &hf_dtpt_payload_size,
928 { "Payload Size", "dtpt.payload_size",
929 FT_UINT32, BASE_DEC, NULL, 0x0,
930 "Payload Size of the following packet containing a serialized WSAQUERYSET", HFILL }},
932 { &hf_dtpt_handle,
933 { "Handle", "dtpt.handle",
934 FT_UINT64, BASE_HEX, NULL, 0x0,
935 "Lookup handle", HFILL }},
937 { &hf_dtpt_error,
938 { "Last Error", "dtpt.error",
939 FT_UINT32, BASE_DEC, VALS(names_error), 0x0,
940 NULL, HFILL }},
942 { &hf_dtpt_buffer_size,
943 { "Buffer Size", "dtpt.buffer_size",
944 FT_UINT32, BASE_DEC, NULL, 0x0,
945 NULL, HFILL }},
947 { &hf_dtpt_data_size,
948 { "Data Size", "dtpt.data_size",
949 FT_UINT32, BASE_DEC, NULL, 0x0,
950 NULL, HFILL }},
952 { &hf_dtpt_queryset_rawsize,
953 { "QuerySet Size", "dtpt.queryset_size",
954 FT_UINT32, BASE_DEC, NULL, 0x0,
955 "Size of the binary WSAQUERYSET", HFILL }},
957 { &hf_dtpt_queryset_size,
958 { "dwSize", "dtpt.queryset.dwSize",
959 FT_UINT32, BASE_DEC, NULL, 0x0,
960 "dwSize field in WSAQUERYSET", HFILL }},
962 { &hf_dtpt_queryset_service_instance_name_pointer,
963 { "lpszServiceInstanceName", "dtpt.queryset.lpszServiceInstanceName",
964 FT_UINT32, BASE_HEX, NULL, 0x0,
965 "lpszServiceInstanceName field in WSAQUERYSET", HFILL }},
967 { &hf_dtpt_queryset_service_class_id_pointer,
968 { "lpServiceClassId", "dtpt.queryset.lpServiceClassId",
969 FT_UINT32, BASE_HEX, NULL, 0x0,
970 "lpServiceClassId in the WSAQUERYSET", HFILL }},
972 { &hf_dtpt_queryset_version,
973 { "lpVersion", "dtpt.queryset.lpVersion",
974 FT_UINT32, BASE_DEC, NULL, 0x0,
975 "lpVersion in WSAQUERYSET", HFILL }},
977 { &hf_dtpt_queryset_comment_pointer,
978 { "lpszComment", "dtpt.lpszComment",
979 FT_UINT32, BASE_HEX, NULL, 0x0,
980 "lpszComment field in WSAQUERYSET", HFILL }},
982 { &hf_dtpt_queryset_namespace,
983 { "dwNameSpace", "dtpt.queryset.dwNameSpace",
984 FT_UINT32, BASE_DEC, NULL, 0x0,
985 "dwNameSpace field in WSAQUERYSE", HFILL }},
987 { &hf_dtpt_queryset_provider_id_pointer,
988 { "lpNSProviderId", "dtpt.queryset.lpNSProviderId",
989 FT_UINT32, BASE_HEX, NULL, 0x0,
990 "lpNSProviderId field in WSAQUERYSET", HFILL }},
992 { &hf_dtpt_queryset_context_pointer,
993 { "lpszContext", "dtpt.queryset.lpszContext",
994 FT_UINT32, BASE_HEX, NULL, 0x0,
995 "lpszContext field in WSAQUERYSET", HFILL }},
997 { &hf_dtpt_queryset_protocols_number,
998 { "dwNumberOfProtocols", "dtpt.queryset.dwNumberOfProtocols",
999 FT_UINT32, BASE_DEC, NULL, 0x0,
1000 "dwNumberOfProtocols field in WSAQUERYSET", HFILL }},
1002 { &hf_dtpt_queryset_protocols_pointer,
1003 { "lpafpProtocols", "dtpt.queryset.lpafpProtocols",
1004 FT_UINT32, BASE_HEX, NULL, 0x0,
1005 "lpafpProtocols field in WSAQUERYSET", HFILL }},
1007 { &hf_dtpt_queryset_query_string_pointer,
1008 { "lpszQueryString", "dtpt.queryset.lpszQueryString",
1009 FT_UINT32, BASE_HEX, NULL, 0x0,
1010 "lpszQueryString field in WSAQUERYSET", HFILL }},
1012 { &hf_dtpt_queryset_cs_addrs_number,
1013 { "dwNumberOfCsAddrs", "dtpt.queryset.dwNumberOfCsAddrs",
1014 FT_UINT32, BASE_DEC, NULL, 0x0,
1015 "dwNumberOfCsAddrs field in WSAQUERYSET", HFILL }},
1017 { &hf_dtpt_queryset_cs_addrs_pointer,
1018 { "lpcsaBuffer", "dtpt.queryset.lpcsaBuffer",
1019 FT_UINT32, BASE_HEX, NULL, 0x0,
1020 "lpcsaBuffer field in WSAQUERYSET", HFILL }},
1022 { &hf_dtpt_queryset_output_flags,
1023 { "dwOutputFlags", "dtpt.queryset.dwOutputFlags",
1024 FT_UINT32, BASE_HEX, NULL, 0x0,
1025 "dwOutputFlags field in WSAQUERYSET", HFILL }},
1027 { &hf_dtpt_queryset_blob_pointer,
1028 { "lpBlob", "dtpt.queryset.lpBlob",
1029 FT_UINT32, BASE_HEX, NULL, 0x0,
1030 "lpBlob field in WSAQUERYSET", HFILL }},
1032 { &hf_dtpt_wstring_length,
1033 { "Length", "dtpt.wstring.length",
1034 FT_UINT32, BASE_DEC, NULL, 0x0,
1035 "String Length", HFILL }},
1037 { &hf_dtpt_wstring_data,
1038 { "Data", "dtpt.wstring.data",
1039 FT_STRING, BASE_NONE, NULL, 0x0,
1040 "String Data", HFILL }},
1042 { &hf_dtpt_guid_length,
1043 { "Length", "dtpt.guid.length",
1044 FT_UINT32, BASE_DEC, NULL, 0x0,
1045 "GUID Length", HFILL }},
1047 { &hf_dtpt_guid_data,
1048 { "Data", "dtpt.guid.data",
1049 FT_GUID, BASE_NONE, NULL, 0x0,
1050 "GUID Data", HFILL }},
1052 { &hf_dtpt_service_instance_name,
1053 { "Service Instance Name", "dtpt.service_instance_name",
1054 FT_STRINGZ, BASE_NONE, NULL, 0x0,
1055 NULL, HFILL }},
1057 { &hf_dtpt_service_class_id,
1058 { "Service Class ID", "dtpt.service_class_id",
1059 FT_GUID, BASE_NONE, NULL, 0x0,
1060 NULL, HFILL }},
1062 { &hf_dtpt_comment,
1063 { "Comment", "dtpt.comment",
1064 FT_STRINGZ, BASE_NONE, NULL, 0x0,
1065 NULL, HFILL }},
1067 { &hf_dtpt_ns_provider_id,
1068 { "NS Provider ID", "dtpt.ns_provider_id",
1069 FT_GUID, BASE_NONE, NULL, 0x0,
1070 NULL, HFILL }},
1072 { &hf_dtpt_context,
1073 { "Context", "dtpt.context",
1074 FT_STRINGZ, BASE_NONE, NULL, 0x0,
1075 NULL, HFILL }},
1077 { &hf_dtpt_protocols_number,
1078 { "Number of Protocols", "dtpt.protocols.number",
1079 FT_UINT32, BASE_DEC, NULL, 0x0,
1080 NULL, HFILL }},
1082 { &hf_dtpt_protocols_length,
1083 { "Length of Protocols", "dtpt.protocols.length",
1084 FT_UINT32, BASE_DEC, NULL, 0x0,
1085 NULL, HFILL }},
1087 { &hf_dtpt_protocol_family,
1088 { "Family", "dtpt.protocol.family",
1089 FT_UINT32, BASE_DEC, VALS(names_family), 0x0,
1090 "Protocol Family", HFILL }},
1092 { &hf_dtpt_protocol_protocol,
1093 { "Protocol", "dtpt.protocol.protocol",
1094 FT_UINT32, BASE_DEC, VALS(names_protocol), 0x0,
1095 "Protocol Protocol", HFILL }},
1097 { &hf_dtpt_query_string,
1098 { "Query String", "dtpt.query_string",
1099 FT_STRINGZ, BASE_NONE, NULL, 0x0,
1100 NULL, HFILL }},
1102 { &hf_dtpt_cs_addrs_number,
1103 { "Number of CS Addresses", "dtpt.cs_addrs.number",
1104 FT_UINT32, BASE_DEC, NULL, 0x0,
1105 NULL, HFILL }},
1107 { &hf_dtpt_cs_addrs_length1,
1108 { "Length of CS Addresses Part 1", "dtpt.cs_addrs.length1",
1109 FT_UINT32, BASE_DEC, NULL, 0x0,
1110 NULL, HFILL }},
1112 { &hf_dtpt_cs_addr_socket_type,
1113 { "Socket Type", "dtpt.cs_addrs.socket_type",
1114 FT_UINT32, BASE_DEC, VALS(names_socket_type), 0x0,
1115 NULL, HFILL }},
1117 { &hf_dtpt_cs_addr_protocol,
1118 { "Protocol", "dtpt.cs_addrs.protocol",
1119 FT_UINT32, BASE_DEC, VALS(names_protocol), 0x0,
1120 NULL, HFILL }},
1122 { &hf_dtpt_cs_addr_local_pointer,
1123 { "Local Address Pointer", "dtpt.cs_addr.local_pointer",
1124 FT_UINT32, BASE_HEX, NULL, 0x0,
1125 NULL, HFILL }},
1127 { &hf_dtpt_cs_addr_local_length,
1128 { "Local Address Length", "dtpt.cs_addr.local_length",
1129 FT_UINT32, BASE_DEC, NULL, 0x0,
1130 "Local Address Pointer", HFILL }},
1132 { &hf_dtpt_cs_addr_local,
1133 { "Local Address", "dtpt.cs_addr.local",
1134 FT_UINT32, BASE_DEC, NULL, 0x0,
1135 NULL, HFILL }},
1137 { &hf_dtpt_cs_addr_remote_pointer,
1138 { "Remote Address Pointer", "dtpt.cs_addr.remote_pointer",
1139 FT_UINT32, BASE_HEX, NULL, 0x0,
1140 NULL, HFILL }},
1142 { &hf_dtpt_cs_addr_remote_length,
1143 { "Remote Address Length", "dtpt.cs_addr.remote_length",
1144 FT_UINT32, BASE_DEC, NULL, 0x0,
1145 "Remote Address Pointer", HFILL }},
1147 { &hf_dtpt_cs_addr_remote,
1148 { "Remote Address", "dtpt.cs_addr.remote",
1149 FT_UINT32, BASE_DEC, NULL, 0x0,
1150 NULL, HFILL }},
1152 { &hf_dtpt_sockaddr_length,
1153 { "Length", "dtpt.sockaddr.length",
1154 FT_UINT16, BASE_DEC, NULL, 0x0,
1155 "Socket Address Length", HFILL }},
1157 { &hf_dtpt_sockaddr_family,
1158 { "Family", "dtpt.sockaddr.family",
1159 FT_UINT16, BASE_DEC, VALS(names_family), 0x0,
1160 "Socket Address Family", HFILL }},
1162 { &hf_dtpt_sockaddr_port,
1163 { "Port", "dtpt.sockaddr.port",
1164 FT_UINT16, BASE_DEC, NULL, 0x0,
1165 "Socket Address Port", HFILL }},
1167 { &hf_dtpt_sockaddr_address,
1168 { "Address", "dtpt.sockaddr.address",
1169 FT_IPv4, BASE_NONE, NULL, 0x0,
1170 "Socket Address Address", HFILL }},
1172 { &hf_dtpt_blob_rawsize,
1173 { "Blob Size", "dtpt.blob_size",
1174 FT_UINT32, BASE_DEC, NULL, 0x0,
1175 "Size of the binary BLOB", HFILL }},
1177 { &hf_dtpt_blob_size,
1178 { "cbSize", "dtpt.blob.cbSize",
1179 FT_UINT32, BASE_DEC, NULL, 0x0,
1180 "cbSize field in BLOB", HFILL }},
1182 { &hf_dtpt_blob_data_pointer,
1183 { "pBlobData", "dtpt.blob.pBlobData",
1184 FT_UINT32, BASE_HEX, NULL, 0x0,
1185 "pBlobData field in BLOB", HFILL }},
1187 { &hf_dtpt_blob_data_length,
1188 { "Length", "dtpt.blob.data_length",
1189 FT_UINT32, BASE_DEC, NULL, 0x0,
1190 "Length of the Blob Data Block", HFILL }},
1192 { &hf_dtpt_blob_data,
1193 { "Data", "dtpt.blob.data",
1194 FT_BYTES, BASE_NONE, NULL, 0x0,
1195 "Blob Data Block", HFILL }},
1197 { &hf_dtpt_connect_addr,
1198 { "Address", "dtpt.connect_addr",
1199 FT_UINT32, BASE_DEC, NULL, 0x0,
1200 "Connect to Address", HFILL }},
1202 static gint *ett[] = {
1203 &ett_dtpt,
1204 &ett_dtpt_flags,
1205 &ett_dtpt_queryset,
1206 &ett_dtpt_wstring,
1207 &ett_dtpt_guid,
1208 &ett_dtpt_protocols,
1209 &ett_dtpt_protocol,
1210 &ett_dtpt_cs_addrs,
1211 &ett_dtpt_cs_addr1,
1212 &ett_dtpt_cs_addr2,
1213 &ett_dtpt_sockaddr,
1214 &ett_dtpt_blobraw,
1215 &ett_dtpt_blob,
1217 module_t *dtpt_module;
1218 e_guid_t guid_svcid_inet_hostaddrbyname = {0x0002A803, 0x0000, 0x0000, {0xC0,0,0,0,0,0,0,0x46}};
1219 e_guid_t guid_svcid_inet_hostaddrbyinetstring = {0x0002A801, 0x0000, 0x0000, {0xC0,0,0,0,0,0,0,0x46}};
1220 guids_add_guid(&guid_svcid_inet_hostaddrbyname, "SVCID_INET_HOSTADDRBYNAME");
1221 guids_add_guid(&guid_svcid_inet_hostaddrbyinetstring, "SVCID_INET_HOSTADDRBYINETSTRING");
1223 proto_dtpt = proto_register_protocol("DeskTop PassThrough Protocol",
1224 "DTPT", "dtpt");
1225 proto_register_field_array(proto_dtpt, hf, array_length(hf));
1226 proto_register_subtree_array(ett, array_length(ett));
1228 /* Register a configuration option for port */
1229 dtpt_module = prefs_register_protocol(proto_dtpt,
1230 proto_reg_handoff_dtpt);
1231 prefs_register_uint_preference(dtpt_module, "tcp.port",
1232 "DTPT Server TCP Port",
1233 "Set the TDP port for the DTPT Server",
1234 10, &gbl_dtptServerPort);
1238 void
1239 proto_reg_handoff_dtpt(void)
1241 static dissector_handle_t dtpt_handle;
1242 static gboolean Initialized=FALSE;
1243 static int ServerPort;
1245 if (!Initialized) {
1246 dtpt_handle = new_create_dissector_handle(dissect_dtpt, proto_dtpt);
1247 dtpt_conversation_handle = new_create_dissector_handle(dissect_dtpt_conversation, proto_dtpt);
1248 /** dtpt_data_handle = new_create_dissector_handle(dissect_dtpt_data, proto_dtpt); **/
1250 data_handle = find_dissector("data");
1251 Initialized=TRUE;
1252 } else {
1253 dissector_delete_uint("tcp.port", ServerPort, dtpt_handle);
1256 /* set port for future deletes */
1257 ServerPort=gbl_dtptServerPort;
1259 dissector_add_uint("tcp.port", gbl_dtptServerPort, dtpt_handle);