2 * Routines for dsi packet dissection
3 * Copyright 2001, Randy McEoin <rmceoin@pe.com>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * Copied from packet-pop.c
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
33 #include <epan/packet.h>
35 #include <epan/prefs.h>
36 #include "packet-tcp.h"
37 #include "packet-afp.h"
39 /* The information in this module (DSI) comes from:
41 AFP 2.1 & 2.2 documentation, in PDF form, at
43 http://developer.apple.com/DOCUMENTATION/macos8/pdf/ASAppleTalkFiling2.1_2.2.pdf
45 The netatalk source code by Wesley Craig & Adrian Sun
47 The Data Stream Interface description from
48 http://developer.apple.com/documentation/Networking/Conceptual/AFPClient/AFPClient-6.html
50 (no longer available, apparently)
52 Also, AFP 3.3 documents parts of DSI at:
53 http://developer.apple.com/mac/library/documentation/Networking/Conceptual/AFP/Introduction/Introduction.html
55 * What a Data Stream Interface packet looks like:
57 * |-------------------------------|
58 * |flags |command| requestID |
59 * |-------------------------------|
60 * |error code/enclosed data offset|
61 * |-------------------------------|
62 * |total data length |
63 * |-------------------------------|
65 * |-------------------------------|
67 #define INET6_ADDRLEN 16
69 static int proto_dsi = -1;
70 static int hf_dsi_flags = -1;
71 static int hf_dsi_command = -1;
72 static int hf_dsi_requestid = -1;
73 static int hf_dsi_offset = -1;
74 static int hf_dsi_error = -1;
75 static int hf_dsi_length = -1;
76 static int hf_dsi_reserved = -1;
78 static gint ett_dsi = -1;
80 static int hf_dsi_open_type = -1;
81 static int hf_dsi_open_len = -1;
82 static int hf_dsi_open_quantum = -1;
83 static int hf_dsi_replay_cache_size = -1;
84 static int hf_dsi_open_option = -1;
86 static int hf_dsi_attn_flag = -1;
87 static int hf_dsi_attn_flag_shutdown = -1;
88 static int hf_dsi_attn_flag_crash = -1;
89 static int hf_dsi_attn_flag_msg = -1;
90 static int hf_dsi_attn_flag_reconnect = -1;
91 static int hf_dsi_attn_flag_time = -1;
92 static int hf_dsi_attn_flag_bitmap = -1;
94 static gint ett_dsi_open = -1;
95 static gint ett_dsi_attn = -1;
96 static gint ett_dsi_attn_flag = -1;
98 static const value_string dsi_attn_flag_vals[] = {
99 {0x0, "Reserved" }, /* 0000 */
100 {0x1, "Reserved" }, /* 0001 */
101 {0x2, "Server message" }, /* 0010 */
102 {0x3, "Server notification, cf. extended bitmap" }, /* 0011 */
103 {0x4, "Server is shutting down, internal error" }, /* 0100 */
104 {0x8, "Server is shutting down" }, /* 1000 */
105 {0x9, "Server disconnects user" }, /* 1001 */
106 {0x10,"Server is shutting down, message" }, /* 1010 */
107 {0x11,"Server is shutting down, message,no reconnect"}, /* 1011 */
109 static value_string_ext dsi_attn_flag_vals_ext = VALUE_STRING_EXT_INIT(dsi_attn_flag_vals);
111 static const value_string dsi_open_type_vals[] = {
112 {0, "Server quantum" },
113 {1, "Attention quantum" },
114 {2, "Replay cache size" },
117 /* status stuff same for asp and afp */
118 static int hf_dsi_server_name = -1;
119 static int hf_dsi_utf8_server_name_len = -1;
120 static int hf_dsi_utf8_server_name = -1;
121 static int hf_dsi_server_type = -1;
122 static int hf_dsi_server_vers = -1;
123 static int hf_dsi_server_uams = -1;
124 static int hf_dsi_server_icon = -1;
125 static int hf_dsi_server_directory = -1;
127 static int hf_dsi_server_flag = -1;
128 static int hf_dsi_server_flag_copyfile = -1;
129 static int hf_dsi_server_flag_passwd = -1;
130 static int hf_dsi_server_flag_no_save_passwd = -1;
131 static int hf_dsi_server_flag_srv_msg = -1;
132 static int hf_dsi_server_flag_srv_sig = -1;
133 static int hf_dsi_server_flag_tcpip = -1;
134 static int hf_dsi_server_flag_notify = -1;
135 static int hf_dsi_server_flag_reconnect = -1;
136 static int hf_dsi_server_flag_directory = -1;
137 static int hf_dsi_server_flag_utf8_name = -1;
138 static int hf_dsi_server_flag_uuid = -1;
139 static int hf_dsi_server_flag_ext_sleep = -1;
140 static int hf_dsi_server_flag_fast_copy = -1;
141 static int hf_dsi_server_signature = -1;
143 static int hf_dsi_server_addr_len = -1;
144 static int hf_dsi_server_addr_type = -1;
145 static int hf_dsi_server_addr_value = -1;
147 static gint ett_dsi_status = -1;
148 static gint ett_dsi_uams = -1;
149 static gint ett_dsi_vers = -1;
150 static gint ett_dsi_addr = -1;
151 static gint ett_dsi_addr_line = -1;
152 static gint ett_dsi_directory = -1;
153 static gint ett_dsi_utf8_name = -1;
154 static gint ett_dsi_status_server_flag = -1;
156 static const value_string afp_server_addr_type_vals[] = {
158 {2, "IP+port address" },
161 {5, "IP+port ssh tunnel" },
163 {7, "IP6+port address" },
165 value_string_ext afp_server_addr_type_vals_ext = VALUE_STRING_EXT_INIT(afp_server_addr_type_vals);
167 /* end status stuff */
169 /* desegmentation of DSI */
170 static gboolean dsi_desegment = TRUE;
172 static dissector_handle_t data_handle;
173 static dissector_handle_t afp_handle;
175 #define TCP_PORT_DSI 548
177 #define DSI_BLOCKSIZ 16
180 #define DSIFL_REQUEST 0x00
181 #define DSIFL_REPLY 0x01
182 #define DSIFL_MAX 0x01
185 #define DSIFUNC_CLOSE 1 /* DSICloseSession */
186 #define DSIFUNC_CMD 2 /* DSICommand */
187 #define DSIFUNC_STAT 3 /* DSIGetStatus */
188 #define DSIFUNC_OPEN 4 /* DSIOpenSession */
189 #define DSIFUNC_TICKLE 5 /* DSITickle */
190 #define DSIFUNC_WRITE 6 /* DSIWrite */
191 #define DSIFUNC_ATTN 8 /* DSIAttention */
192 #define DSIFUNC_MAX 8 /* largest command */
194 static const value_string flag_vals[] = {
195 {DSIFL_REQUEST, "Request" },
196 {DSIFL_REPLY, "Reply" },
199 static const value_string func_vals[] = {
200 {DSIFUNC_CLOSE, "CloseSession" },
201 {DSIFUNC_CMD, "Command" },
202 {DSIFUNC_STAT, "GetStatus" },
203 {DSIFUNC_OPEN, "OpenSession" },
204 {DSIFUNC_TICKLE, "Tickle" },
205 {DSIFUNC_WRITE, "Write" },
207 {DSIFUNC_ATTN, "Attention" },
209 static value_string_ext func_vals_ext = VALUE_STRING_EXT_INIT(func_vals);
212 dissect_dsi_open_session(tvbuff_t *tvb, proto_tree *dsi_tree, gint offset, gint dsi_length)
219 ti = proto_tree_add_text(dsi_tree, tvb, offset, -1, "Open Session");
220 tree = proto_item_add_subtree(ti, ett_dsi_open);
222 while( dsi_length >2 ) {
224 type = tvb_get_guint8(tvb, offset);
225 proto_tree_add_item(tree, hf_dsi_open_type, tvb, offset, 1, ENC_BIG_ENDIAN);
227 len = tvb_get_guint8(tvb, offset);
228 proto_tree_add_item(tree, hf_dsi_open_len, tvb, offset, 1, ENC_BIG_ENDIAN);
232 proto_tree_add_item(tree, hf_dsi_open_quantum, tvb, offset, 4, ENC_BIG_ENDIAN);
235 proto_tree_add_item(tree, hf_dsi_open_quantum, tvb, offset, 4, ENC_BIG_ENDIAN);
238 proto_tree_add_item(tree, hf_dsi_replay_cache_size, tvb, offset, 4, ENC_BIG_ENDIAN);
241 proto_tree_add_item(tree, hf_dsi_open_option, tvb, offset, len, ENC_NA);
244 dsi_length -= len + 2;
252 dissect_dsi_attention(tvbuff_t *tvb, proto_tree *dsi_tree, gint offset)
258 if (!tvb_reported_length_remaining(tvb,offset))
261 flag = tvb_get_ntohs(tvb, offset);
262 ti = proto_tree_add_text(dsi_tree, tvb, offset, -1, "Attention");
263 tree = proto_item_add_subtree(ti, ett_dsi_attn);
265 ti = proto_tree_add_item(tree, hf_dsi_attn_flag, tvb, offset, 2, ENC_BIG_ENDIAN);
266 tree = proto_item_add_subtree(ti, ett_dsi_attn_flag);
267 proto_tree_add_item(tree, hf_dsi_attn_flag_shutdown, tvb, offset, 2, ENC_BIG_ENDIAN);
268 proto_tree_add_item(tree, hf_dsi_attn_flag_crash, tvb, offset, 2, ENC_BIG_ENDIAN);
269 proto_tree_add_item(tree, hf_dsi_attn_flag_msg, tvb, offset, 2, ENC_BIG_ENDIAN);
270 proto_tree_add_item(tree, hf_dsi_attn_flag_reconnect, tvb, offset, 2, ENC_BIG_ENDIAN);
272 if ((flag & 0xf000) != 0x3000)
273 proto_tree_add_item(tree, hf_dsi_attn_flag_time, tvb, offset, 2, ENC_BIG_ENDIAN);
275 proto_tree_add_item(tree, hf_dsi_attn_flag_bitmap, tvb, offset, 2, ENC_BIG_ENDIAN);
280 /* -----------------------------
281 from netatalk/etc/afpd/status.c
284 dissect_dsi_reply_get_status(tvbuff_t *tvb, proto_tree *tree, gint offset)
286 proto_tree *sub_tree;
291 guint16 sign_ofs = 0;
302 ti = proto_tree_add_text(tree, tvb, offset, -1, "Get Status");
303 tree = proto_item_add_subtree(ti, ett_dsi_status);
305 ofs = tvb_get_ntohs(tvb, offset +AFPSTATUS_MACHOFF);
306 proto_tree_add_text(tree, tvb, offset +AFPSTATUS_MACHOFF, 2, "Machine offset: %d", ofs);
308 ofs = tvb_get_ntohs(tvb, offset +AFPSTATUS_VERSOFF);
309 proto_tree_add_text(tree, tvb, offset +AFPSTATUS_VERSOFF, 2, "Version offset: %d", ofs);
311 ofs = tvb_get_ntohs(tvb, offset +AFPSTATUS_UAMSOFF);
312 proto_tree_add_text(tree, tvb, offset +AFPSTATUS_UAMSOFF, 2, "UAMS offset: %d", ofs);
314 ofs = tvb_get_ntohs(tvb, offset +AFPSTATUS_ICONOFF);
315 proto_tree_add_text(tree, tvb, offset +AFPSTATUS_ICONOFF, 2, "Icon offset: %d", ofs);
317 ofs = offset +AFPSTATUS_FLAGOFF;
318 ti = proto_tree_add_item(tree, hf_dsi_server_flag, tvb, ofs, 2, ENC_BIG_ENDIAN);
319 sub_tree = proto_item_add_subtree(ti, ett_dsi_status_server_flag);
320 proto_tree_add_item(sub_tree, hf_dsi_server_flag_copyfile , tvb, ofs, 2, ENC_BIG_ENDIAN);
321 proto_tree_add_item(sub_tree, hf_dsi_server_flag_passwd , tvb, ofs, 2, ENC_BIG_ENDIAN);
322 proto_tree_add_item(sub_tree, hf_dsi_server_flag_no_save_passwd, tvb, ofs, 2, ENC_BIG_ENDIAN);
323 proto_tree_add_item(sub_tree, hf_dsi_server_flag_srv_msg , tvb, ofs, 2, ENC_BIG_ENDIAN);
324 proto_tree_add_item(sub_tree, hf_dsi_server_flag_srv_sig , tvb, ofs, 2, ENC_BIG_ENDIAN);
325 proto_tree_add_item(sub_tree, hf_dsi_server_flag_tcpip , tvb, ofs, 2, ENC_BIG_ENDIAN);
326 proto_tree_add_item(sub_tree, hf_dsi_server_flag_notify , tvb, ofs, 2, ENC_BIG_ENDIAN);
327 proto_tree_add_item(sub_tree, hf_dsi_server_flag_reconnect , tvb, ofs, 2, ENC_BIG_ENDIAN);
328 proto_tree_add_item(sub_tree, hf_dsi_server_flag_directory , tvb, ofs, 2, ENC_BIG_ENDIAN);
329 proto_tree_add_item(sub_tree, hf_dsi_server_flag_utf8_name , tvb, ofs, 2, ENC_BIG_ENDIAN);
330 proto_tree_add_item(sub_tree, hf_dsi_server_flag_uuid , tvb, ofs, 2, ENC_BIG_ENDIAN);
331 proto_tree_add_item(sub_tree, hf_dsi_server_flag_ext_sleep , tvb, ofs, 2, ENC_BIG_ENDIAN);
332 proto_tree_add_item(sub_tree, hf_dsi_server_flag_fast_copy , tvb, ofs, 2, ENC_BIG_ENDIAN);
334 proto_tree_add_item(tree, hf_dsi_server_name, tvb, offset +AFPSTATUS_PRELEN, 1, ENC_ASCII|ENC_BIG_ENDIAN);
336 flag = tvb_get_ntohs(tvb, ofs);
337 if ((flag & AFPSRVRINFO_SRVSIGNATURE)) {
338 ofs = offset +AFPSTATUS_PRELEN +tvb_get_guint8(tvb, offset +AFPSTATUS_PRELEN) +1;
342 sign_ofs = tvb_get_ntohs(tvb, ofs);
343 proto_tree_add_text(tree, tvb, ofs, 2, "Signature offset: %d", sign_ofs);
346 if ((flag & AFPSRVRINFO_TCPIP)) {
348 adr_ofs = tvb_get_ntohs(tvb, ofs);
349 proto_tree_add_text(tree, tvb, ofs, 2, "Network address offset: %d", adr_ofs);
353 if ((flag & AFPSRVRINFO_SRVDIRECTORY)) {
355 dir_ofs = tvb_get_ntohs(tvb, ofs);
356 proto_tree_add_text(tree, tvb, ofs, 2, "Directory services offset: %d", dir_ofs);
359 if ((flag & AFPSRVRINFO_SRVUTF8)) {
361 utf_ofs = tvb_get_ntohs(tvb, ofs);
362 proto_tree_add_text(tree, tvb, ofs, 2, "UTF8 server name offset: %d", utf_ofs);
367 ofs = offset +tvb_get_ntohs(tvb, offset +AFPSTATUS_MACHOFF);
369 proto_tree_add_item(tree, hf_dsi_server_type, tvb, ofs, 1, ENC_ASCII|ENC_BIG_ENDIAN);
371 ofs = offset +tvb_get_ntohs(tvb, offset +AFPSTATUS_VERSOFF);
373 nbe = tvb_get_guint8(tvb, ofs);
374 ti = proto_tree_add_text(tree, tvb, ofs, 1, "Version list: %d", nbe);
376 sub_tree = proto_item_add_subtree(ti, ett_dsi_vers);
377 for (i = 0; i < nbe; i++) {
378 len = tvb_get_guint8(tvb, ofs);
379 proto_tree_add_item(sub_tree, hf_dsi_server_vers, tvb, ofs, 1, ENC_ASCII|ENC_BIG_ENDIAN);
384 ofs = offset +tvb_get_ntohs(tvb, offset +AFPSTATUS_UAMSOFF);
386 nbe = tvb_get_guint8(tvb, ofs);
387 ti = proto_tree_add_text(tree, tvb, ofs, 1, "UAMS list: %d", nbe);
389 sub_tree = proto_item_add_subtree(ti, ett_dsi_uams);
390 for (i = 0; i < nbe; i++) {
391 len = tvb_get_guint8(tvb, ofs);
392 proto_tree_add_item(sub_tree, hf_dsi_server_uams, tvb, ofs, 1, ENC_ASCII|ENC_BIG_ENDIAN);
397 ofs = offset +tvb_get_ntohs(tvb, offset +AFPSTATUS_ICONOFF);
399 proto_tree_add_item(tree, hf_dsi_server_icon, tvb, ofs, 256, ENC_NA);
402 proto_tree_add_item(tree, hf_dsi_server_signature, tvb, sign_ofs, 16, ENC_NA);
406 proto_tree *adr_tree;
413 nbe = tvb_get_guint8(tvb, ofs);
414 ti = proto_tree_add_text(tree, tvb, ofs, 1, "Address list: %d", nbe);
416 adr_tree = proto_item_add_subtree(ti, ett_dsi_addr);
417 for (i = 0; i < nbe; i++) {
420 len = tvb_get_guint8(tvb, ofs);
421 type = tvb_get_guint8(tvb, ofs +1);
424 ti = proto_tree_add_text(adr_tree, tvb, ofs, len, "ip: %s", tvb_ip_to_str(tvb, ofs+2));
426 case 2: /* IP + port */
427 port = tvb_get_ntohs(tvb, ofs+6);
428 ti = proto_tree_add_text(adr_tree, tvb, ofs, len, "ip %s:%d", tvb_ip_to_str(tvb, ofs+2), port);
430 case 3: /* DDP, atalk_addr_to_str want host order not network */
431 net = tvb_get_ntohs(tvb, ofs+2);
432 node = tvb_get_guint8(tvb, ofs +4);
433 port = tvb_get_guint8(tvb, ofs +5);
434 ti = proto_tree_add_text(adr_tree, tvb, ofs, len, "ddp: %u.%u:%u",
438 case 5: /* SSH tunnel */
440 tmp = tvb_get_ephemeral_string(tvb, ofs +2, len -2);
441 ti = proto_tree_add_text(adr_tree, tvb, ofs, len, "%s: %s",
442 (type==4)?"dns":"ssh tunnel", tmp);
446 ti = proto_tree_add_text(adr_tree, tvb, ofs, len,"Malformed address type %d", type);
450 ti = proto_tree_add_text(adr_tree, tvb, ofs, len, "ip6: %s",
451 tvb_ip6_to_str(tvb, ofs+2));
453 case 7: /* IP6 + 2bytes port */
454 port = tvb_get_ntohs(tvb, ofs+ 2+INET6_ADDRLEN);
455 ti = proto_tree_add_text(adr_tree, tvb, ofs, len, "ip6 %s:%d",
456 tvb_ip6_to_str(tvb, ofs+2), port);
459 ti = proto_tree_add_text(adr_tree, tvb, ofs, len,"Unknown type : %d", type);
463 sub_tree = proto_item_add_subtree(ti,ett_dsi_addr_line);
464 proto_tree_add_item(sub_tree, hf_dsi_server_addr_len, tvb, ofs, 1, ENC_BIG_ENDIAN);
466 proto_tree_add_item(sub_tree, hf_dsi_server_addr_type, tvb, ofs, 1, ENC_BIG_ENDIAN);
468 proto_tree_add_item(sub_tree, hf_dsi_server_addr_value,tvb, ofs, len, ENC_NA);
475 nbe = tvb_get_guint8(tvb, ofs);
476 ti = proto_tree_add_text(tree, tvb, ofs, 1, "Directory services list: %d", nbe);
478 sub_tree = proto_item_add_subtree(ti, ett_dsi_directory);
479 for (i = 0; i < nbe; i++) {
480 len = tvb_get_guint8(tvb, ofs);
481 proto_tree_add_item(sub_tree, hf_dsi_server_directory, tvb, ofs, 1, ENC_ASCII|ENC_BIG_ENDIAN);
490 ulen = tvb_get_ntohs(tvb, ofs);
491 tmp = tvb_get_ephemeral_string(tvb, ofs + 2, ulen);
492 ti = proto_tree_add_text(tree, tvb, ofs, ulen + 2, "UTF8 server name: %s", tmp);
493 sub_tree = proto_item_add_subtree(ti, ett_dsi_utf8_name);
494 proto_tree_add_uint(sub_tree, hf_dsi_utf8_server_name_len, tvb, ofs, 2, ulen);
496 proto_tree_add_string(sub_tree, hf_dsi_utf8_server_name, tvb, ofs, ulen, tmp);
504 dissect_dsi_packet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
506 proto_tree *dsi_tree;
508 guint8 dsi_flags,dsi_command;
509 guint16 dsi_requestid;
512 guint32 dsi_reserved;
513 struct aspinfo aspinfo;
517 col_set_str(pinfo->cinfo, COL_PROTOCOL, "DSI");
518 col_info = check_col(pinfo->cinfo, COL_INFO);
520 col_clear(pinfo->cinfo, COL_INFO);
522 dsi_flags = tvb_get_guint8(tvb, 0);
523 dsi_command = tvb_get_guint8(tvb, 1);
524 dsi_requestid = tvb_get_ntohs(tvb, 2);
525 dsi_code = tvb_get_ntohl(tvb, 4);
526 dsi_length = tvb_get_ntohl(tvb, 8);
527 dsi_reserved = tvb_get_ntohl(tvb, 12);
530 col_add_fstr(pinfo->cinfo, COL_INFO, "%s %s (%u)",
531 val_to_str(dsi_flags, flag_vals,
532 "Unknown flag (0x%02x)"),
533 val_to_str_ext(dsi_command, &func_vals_ext,
534 "Unknown function (0x%02x)"),
540 ti = proto_tree_add_item(tree, proto_dsi, tvb, 0, -1, ENC_NA);
541 dsi_tree = proto_item_add_subtree(ti, ett_dsi);
543 proto_tree_add_uint(dsi_tree, hf_dsi_flags, tvb,
545 proto_tree_add_uint(dsi_tree, hf_dsi_command, tvb,
547 proto_tree_add_uint(dsi_tree, hf_dsi_requestid, tvb,
548 2, 2, dsi_requestid);
552 proto_tree_add_int(dsi_tree, hf_dsi_offset, tvb,
557 proto_tree_add_int(dsi_tree, hf_dsi_error, tvb,
561 proto_tree_add_uint_format(dsi_tree, hf_dsi_length, tvb,
563 "Length: %u bytes", dsi_length);
564 proto_tree_add_uint(dsi_tree, hf_dsi_reserved, tvb,
565 12, 4, dsi_reserved);
569 switch (dsi_command) {
572 dissect_dsi_open_session(tvb, dsi_tree, DSI_BLOCKSIZ, dsi_length);
577 dissect_dsi_attention(tvb, dsi_tree, DSI_BLOCKSIZ);
581 if (tree && (dsi_flags == DSIFL_REPLY)) {
582 dissect_dsi_reply_get_status(tvb, dsi_tree, DSI_BLOCKSIZ);
590 int len = tvb_reported_length_remaining(tvb,DSI_BLOCKSIZ);
592 aspinfo.reply = (dsi_flags == DSIFL_REPLY);
593 aspinfo.command = dsi_command;
594 aspinfo.seq = dsi_requestid;
595 aspinfo.code = dsi_code;
596 pd_save = pinfo->private_data;
597 pinfo->private_data = &aspinfo;
598 proto_item_set_len(dsi_tree, DSI_BLOCKSIZ);
600 new_tvb = tvb_new_subset(tvb, DSI_BLOCKSIZ,-1,len);
601 call_dissector(afp_handle, new_tvb, pinfo, tree);
602 pinfo->private_data = pd_save;
607 call_dissector(data_handle,
608 tvb_new_subset_remaining(tvb, DSI_BLOCKSIZ),
616 get_dsi_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset)
619 guint8 dsi_flags,dsi_command;
621 dsi_flags = tvb_get_guint8(tvb, offset);
622 dsi_command = tvb_get_guint8(tvb, offset+ 1);
623 if ( dsi_flags > DSIFL_MAX || !dsi_command || dsi_command > DSIFUNC_MAX)
625 /* it's not a known dsi pdu start sequence */
626 return tvb_length_remaining(tvb, offset);
630 * Get the length of the DSI packet.
632 plen = tvb_get_ntohl(tvb, offset+8);
635 * That length doesn't include the length of the header itself;
642 dissect_dsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
644 tcp_dissect_pdus(tvb, pinfo, tree, dsi_desegment, 12,
645 get_dsi_pdu_len, dissect_dsi_packet);
649 proto_register_dsi(void)
652 static hf_register_info hf[] = {
654 { "Flags", "dsi.flags",
655 FT_UINT8, BASE_HEX, VALS(flag_vals), 0x0,
656 "Indicates request or reply.", HFILL }},
659 { "Command", "dsi.command",
660 FT_UINT8, BASE_DEC|BASE_EXT_STRING, &func_vals_ext, 0x0,
661 "Represents a DSI command.", HFILL }},
664 { "Request ID", "dsi.requestid",
665 FT_UINT16, BASE_DEC, NULL, 0x0,
666 "Keeps track of which request this is. Replies must match a Request. IDs must be generated in sequential order.", HFILL }},
669 { "Data offset", "dsi.data_offset",
670 FT_INT32, BASE_DEC, NULL, 0x0,
674 { "Error code", "dsi.error_code",
675 FT_INT32, BASE_DEC|BASE_EXT_STRING, &asp_error_vals_ext, 0x0,
679 { "Length", "dsi.length",
680 FT_UINT32, BASE_DEC, NULL, 0x0,
681 "Total length of the data that follows the DSI header.", HFILL }},
684 { "Reserved", "dsi.reserved",
685 FT_UINT32, BASE_HEX, NULL, 0x0,
686 "Reserved for future use. Should be set to zero.", HFILL }},
688 { &hf_dsi_utf8_server_name_len,
689 { "Length", "dsi.utf8_server_name_len",
690 FT_UINT16, BASE_DEC, NULL, 0x0,
691 "UTF8 server name length.", HFILL }},
692 { &hf_dsi_utf8_server_name,
693 { "UTF8 Server name", "dsi.utf8_server_name",
694 FT_STRING, BASE_NONE, NULL, 0x0,
697 { &hf_dsi_server_name,
698 { "Server name", "dsi.server_name",
699 FT_UINT_STRING, BASE_NONE, NULL, 0x0,
702 { &hf_dsi_server_type,
703 { "Server type", "dsi.server_type",
704 FT_UINT_STRING, BASE_NONE, NULL, 0x0,
707 { &hf_dsi_server_vers,
708 { "AFP version", "dsi.server_vers",
709 FT_UINT_STRING, BASE_NONE, NULL, 0x0,
712 { &hf_dsi_server_uams,
713 { "UAM", "dsi.server_uams",
714 FT_UINT_STRING, BASE_NONE, NULL, 0x0,
717 { &hf_dsi_server_icon,
718 { "Icon bitmap", "dsi.server_icon",
719 FT_BYTES, BASE_NONE, NULL, 0x0,
720 "Server icon bitmap", HFILL }},
722 { &hf_dsi_server_directory,
723 { "Directory service", "dsi.server_directory",
724 FT_UINT_STRING, BASE_NONE, NULL, 0x0,
725 "Server directory service", HFILL }},
727 { &hf_dsi_server_signature,
728 { "Server signature", "dsi.server_signature",
729 FT_BYTES, BASE_NONE, NULL, 0x0,
732 { &hf_dsi_server_flag,
733 { "Flag", "dsi.server_flag",
734 FT_UINT16, BASE_HEX, NULL, 0x0,
735 "Server capabilities flag", HFILL }},
736 { &hf_dsi_server_flag_copyfile,
737 { "Support copyfile", "dsi.server_flag.copyfile",
738 FT_BOOLEAN, 16, NULL, AFPSRVRINFO_COPY,
739 "Server support copyfile", HFILL }},
740 { &hf_dsi_server_flag_passwd,
741 { "Support change password", "dsi.server_flag.passwd",
742 FT_BOOLEAN, 16, NULL, AFPSRVRINFO_PASSWD,
743 "Server support change password", HFILL }},
744 { &hf_dsi_server_flag_no_save_passwd,
745 { "Don't allow save password", "dsi.server_flag.no_save_passwd",
746 FT_BOOLEAN, 16, NULL, AFPSRVRINFO_NOSAVEPASSWD,
748 { &hf_dsi_server_flag_srv_msg,
749 { "Support server message", "dsi.server_flag.srv_msg",
750 FT_BOOLEAN, 16, NULL, AFPSRVRINFO_SRVMSGS,
752 { &hf_dsi_server_flag_srv_sig,
753 { "Support server signature", "dsi.server_flag.srv_sig",
754 FT_BOOLEAN, 16, NULL, AFPSRVRINFO_SRVSIGNATURE,
756 { &hf_dsi_server_flag_tcpip,
757 { "Support TCP/IP", "dsi.server_flag.tcpip",
758 FT_BOOLEAN, 16, NULL, AFPSRVRINFO_TCPIP,
759 "Server support TCP/IP", HFILL }},
760 { &hf_dsi_server_flag_notify,
761 { "Support server notifications", "dsi.server_flag.notify",
762 FT_BOOLEAN, 16, NULL, AFPSRVRINFO_SRVNOTIFY,
763 "Server support notifications", HFILL }},
764 { &hf_dsi_server_flag_reconnect,
765 { "Support server reconnect", "dsi.server_flag.reconnect",
766 FT_BOOLEAN, 16, NULL, AFPSRVRINFO_SRVRECONNECT,
767 "Server support reconnect", HFILL }},
768 { &hf_dsi_server_flag_directory,
769 { "Support directory services", "dsi.server_flag.directory",
770 FT_BOOLEAN, 16, NULL, AFPSRVRINFO_SRVDIRECTORY,
771 "Server support directory services", HFILL }},
772 { &hf_dsi_server_flag_utf8_name,
773 { "Support UTF8 server name", "dsi.server_flag.utf8_name",
774 FT_BOOLEAN, 16, NULL, AFPSRVRINFO_SRVUTF8,
775 "Server support UTF8 server name", HFILL }},
776 { &hf_dsi_server_flag_uuid,
777 { "Support UUIDs", "dsi.server_flag.uuids",
778 FT_BOOLEAN, 16, NULL, AFPSRVRINFO_UUID,
779 "Server supports UUIDs", HFILL }},
780 { &hf_dsi_server_flag_ext_sleep,
781 { "Support extended sleep", "dsi.server_flag.ext_sleep",
782 FT_BOOLEAN, 16, NULL, AFPSRVRINFO_EXT_SLEEP,
783 "Server supports extended sleep", HFILL }},
784 { &hf_dsi_server_flag_fast_copy,
785 { "Support fast copy", "dsi.server_flag.fast_copy",
786 FT_BOOLEAN, 16, NULL, AFPSRVRINFO_FASTBOZO,
787 "Server support fast copy", HFILL }},
790 { &hf_dsi_server_addr_len,
791 { "Length", "dsi.server_addr.len",
792 FT_UINT8, BASE_DEC, NULL, 0x0,
793 "Address length.", HFILL }},
795 { &hf_dsi_server_addr_type,
796 { "Type", "dsi.server_addr.type",
797 FT_UINT8, BASE_DEC|BASE_EXT_STRING, &afp_server_addr_type_vals_ext, 0x0,
798 "Address type.", HFILL }},
800 { &hf_dsi_server_addr_value,
801 { "Value", "dsi.server_addr.value",
802 FT_BYTES, BASE_NONE, NULL, 0x0,
803 "Address value", HFILL }},
806 { "Option", "dsi.open_type",
807 FT_UINT8, BASE_DEC, VALS(dsi_open_type_vals), 0x0,
808 "Open session option type.", HFILL }},
811 { "Length", "dsi.open_len",
812 FT_UINT8, BASE_DEC, NULL, 0x0,
813 "Open session option len", HFILL }},
815 { &hf_dsi_open_quantum,
816 { "Quantum", "dsi.open_quantum",
817 FT_UINT32, BASE_DEC, NULL, 0x0,
818 "Server/Attention quantum", HFILL }},
820 { &hf_dsi_replay_cache_size,
821 { "Replay", "dsi.replay_cache",
822 FT_UINT32, BASE_DEC, NULL, 0x0,
823 "Replay cache size", HFILL }},
825 { &hf_dsi_open_option,
826 { "Option", "dsi.open_option",
827 FT_BYTES, BASE_NONE, NULL, 0x0,
828 "Open session options (undecoded)", HFILL }},
831 { "Flags", "dsi.attn_flag",
832 FT_UINT16, BASE_HEX|BASE_EXT_STRING, &dsi_attn_flag_vals_ext, 0xf000,
833 "Server attention flag", HFILL }},
834 { &hf_dsi_attn_flag_shutdown,
835 { "Shutdown", "dsi.attn_flag.shutdown",
836 FT_BOOLEAN, 16, NULL, 1<<15,
837 "Attention flag, server is shutting down", HFILL }},
838 { &hf_dsi_attn_flag_crash,
839 { "Crash", "dsi.attn_flag.crash",
840 FT_BOOLEAN, 16, NULL, 1<<14,
841 "Attention flag, server crash bit", HFILL }},
842 { &hf_dsi_attn_flag_msg,
843 { "Message", "dsi.attn_flag.msg",
844 FT_BOOLEAN, 16, NULL, 1<<13,
845 "Attention flag, server message bit", HFILL }},
846 { &hf_dsi_attn_flag_reconnect,
847 { "Don't reconnect", "dsi.attn_flag.reconnect",
848 FT_BOOLEAN, 16, NULL, 1<<12,
849 "Attention flag, don't reconnect bit", HFILL }},
850 { &hf_dsi_attn_flag_time,
851 { "Minutes", "dsi.attn_flag.time",
852 FT_UINT16, BASE_DEC, NULL, 0xfff,
853 "Number of minutes", HFILL }},
854 { &hf_dsi_attn_flag_bitmap,
855 { "Bitmap", "dsi.attn_flag.time",
856 FT_UINT16, BASE_HEX, NULL, 0xfff,
857 "Attention extended bitmap", HFILL }},
861 static gint *ett[] = {
868 &ett_dsi_status_server_flag,
876 module_t *dsi_module;
878 proto_dsi = proto_register_protocol("Data Stream Interface", "DSI", "dsi");
879 proto_register_field_array(proto_dsi, hf, array_length(hf));
880 proto_register_subtree_array(ett, array_length(ett));
882 dsi_module = prefs_register_protocol(proto_dsi, NULL);
883 prefs_register_bool_preference(dsi_module, "desegment",
884 "Reassemble DSI messages spanning multiple TCP segments",
885 "Whether the DSI dissector should reassemble messages spanning multiple TCP segments."
886 " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
891 proto_reg_handoff_dsi(void)
893 dissector_handle_t dsi_handle;
895 dsi_handle = create_dissector_handle(dissect_dsi, proto_dsi);
896 dissector_add_uint("tcp.port", TCP_PORT_DSI, dsi_handle);
898 data_handle = find_dissector("data");
899 afp_handle = find_dissector("afp");