2 * Routines for SMB Browser packet dissection
3 * Copyright 1999, Richard Sharpe <rsharpe@ns.aus.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.
35 #include <epan/packet.h>
36 #include <epan/dissectors/packet-smb.h>
39 #include "packet-smb-browse.h"
40 #include "packet-dcerpc.h"
42 static int proto_smb_browse = -1;
43 static int hf_command = -1;
44 static int hf_update_count = -1;
45 static int hf_periodicity = -1;
46 static int hf_server_name = -1;
47 static int hf_mb_server_name = -1;
48 static int hf_mb_reset_command = -1;
49 static int hf_mb_reset_demote = -1;
50 static int hf_mb_reset_flush = -1;
51 static int hf_mb_reset_stop = -1;
52 static int hf_os_major = -1;
53 static int hf_os_minor = -1;
54 static int hf_server_type = -1;
55 static int hf_server_type_workstation = -1;
56 static int hf_server_type_server = -1;
57 static int hf_server_type_sql = -1;
58 static int hf_server_type_domain = -1;
59 static int hf_server_type_backup = -1;
60 static int hf_server_type_time = -1;
61 static int hf_server_type_apple = -1;
62 static int hf_server_type_novell = -1;
63 static int hf_server_type_member = -1;
64 static int hf_server_type_print = -1;
65 static int hf_server_type_dialin = -1;
66 static int hf_server_type_xenix = -1;
67 static int hf_server_type_ntw = -1;
68 static int hf_server_type_wfw = -1;
69 static int hf_server_type_nts = -1;
70 static int hf_server_type_potentialb = -1;
71 static int hf_server_type_backupb = -1;
72 static int hf_server_type_masterb = -1;
73 static int hf_server_type_domainmasterb = -1;
74 static int hf_server_type_osf = -1;
75 static int hf_server_type_vms = -1;
76 static int hf_server_type_w95 = -1;
77 static int hf_server_type_dfs = -1;
78 static int hf_server_type_local = -1;
79 static int hf_server_type_domainenum = -1;
80 static int hf_election_version = -1;
81 static int hf_proto_major = -1;
82 static int hf_proto_minor = -1;
83 static int hf_sig_const = -1;
84 static int hf_server_comment = -1;
85 static int hf_unused_flags = -1;
86 static int hf_response_computer_name = -1;
87 static int hf_election_criteria = -1;
88 static int hf_election_desire = -1;
89 static int hf_election_desire_flags_backup = -1;
90 static int hf_election_desire_flags_standby = -1;
91 static int hf_election_desire_flags_master = -1;
92 static int hf_election_desire_flags_domain_master = -1;
93 static int hf_election_desire_flags_wins = -1;
94 static int hf_election_desire_flags_nt = -1;
95 static int hf_election_revision = -1;
96 static int hf_election_os = -1;
97 static int hf_election_os_wfw = -1;
98 static int hf_election_os_ntw = -1;
99 static int hf_election_os_nts = -1;
100 static int hf_server_uptime = -1;
101 static int hf_backup_count = -1;
102 static int hf_backup_token = -1;
103 static int hf_backup_server = -1;
104 static int hf_browser_to_promote = -1;
106 static gint ett_browse = -1;
107 static gint ett_browse_flags = -1;
108 static gint ett_browse_election_criteria = -1;
109 static gint ett_browse_election_os = -1;
110 static gint ett_browse_election_desire = -1;
111 static gint ett_browse_reset_cmd_flags = -1;
113 #define SERVER_WORKSTATION 0
114 #define SERVER_SERVER 1
115 #define SERVER_SQL_SERVER 2
116 #define SERVER_DOMAIN_CONTROLLER 3
117 #define SERVER_BACKUP_CONTROLLER 4
118 #define SERVER_TIME_SOURCE 5
119 #define SERVER_APPLE_SERVER 6
120 #define SERVER_NOVELL_SERVER 7
121 #define SERVER_DOMAIN_MEMBER_SERVER 8
122 #define SERVER_PRINT_QUEUE_SERVER 9
123 #define SERVER_DIALIN_SERVER 10
124 #define SERVER_XENIX_SERVER 11
125 #define SERVER_NT_WORKSTATION 12
126 #define SERVER_WINDOWS_FOR_WORKGROUPS 13
127 #define SERVER_NT_SERVER 15
128 #define SERVER_POTENTIAL_BROWSER 16
129 #define SERVER_BACKUP_BROWSER 17
130 #define SERVER_MASTER_BROWSER 18
131 #define SERVER_DOMAIN_MASTER_BROWSER 19
132 #define SERVER_OSF 20
133 #define SERVER_VMS 21
134 #define SERVER_WINDOWS_95 22
135 #define SERVER_DFS_SERVER 23
136 #define SERVER_LOCAL_LIST_ONLY 30
137 #define SERVER_DOMAIN_ENUM 31
139 static const value_string server_types[] = {
140 {SERVER_WORKSTATION, "Workstation"},
141 {SERVER_SERVER, "Server"},
142 {SERVER_SQL_SERVER, "SQL Server"},
143 {SERVER_DOMAIN_CONTROLLER, "Domain Controller"},
144 {SERVER_BACKUP_CONTROLLER, "Backup Controller"},
145 {SERVER_TIME_SOURCE, "Time Source"},
146 {SERVER_APPLE_SERVER, "Apple Server"},
147 {SERVER_NOVELL_SERVER, "Novell Server"},
148 {SERVER_DOMAIN_MEMBER_SERVER, "Domain Member Server"},
149 {SERVER_PRINT_QUEUE_SERVER, "Print Queue Server"},
150 {SERVER_DIALIN_SERVER, "Dialin Server"},
151 {SERVER_XENIX_SERVER, "Xenix Server"},
152 {SERVER_NT_WORKSTATION, "NT Workstation"},
153 {SERVER_WINDOWS_FOR_WORKGROUPS, "Windows for Workgroups"},
154 {SERVER_NT_SERVER, "NT Server"},
155 {SERVER_POTENTIAL_BROWSER, "Potential Browser"},
156 {SERVER_BACKUP_BROWSER, "Backup Browser"},
157 {SERVER_MASTER_BROWSER, "Master Browser"},
158 {SERVER_DOMAIN_MASTER_BROWSER, "Domain Master Browser"},
161 {SERVER_WINDOWS_95, "Windows 95 or above"},
162 {SERVER_DFS_SERVER, "DFS server"},
163 {SERVER_LOCAL_LIST_ONLY, "Local List Only"},
164 {SERVER_DOMAIN_ENUM, "Domain Enum"},
168 #define SET_WINDOWS_VERSION_STRING(os_major_ver, os_minor_ver, windows_version) \
169 if(os_major_ver == 6 && os_minor_ver == 1) \
170 windows_version = "Windows 7 or Windows Server 2008 R2"; \
172 else if(os_major_ver == 6 && os_minor_ver == 0) \
173 windows_version = "Windows Vista or Windows Server 2008"; \
175 else if(os_major_ver == 5 && os_minor_ver == 2) \
176 windows_version = "Windows Server 2003 R2 or Windows Server 2003"; \
178 else if(os_major_ver == 5 && os_minor_ver == 1) \
179 windows_version = "Windows XP"; \
181 else if(os_major_ver == 5 && os_minor_ver == 0) \
182 windows_version = "Windows 2000"; \
185 windows_version = NULL;
187 static const value_string resetbrowserstate_command_names[] = {
188 { 0x01, "Stop being a master browser and become a backup browser"},
189 { 0x02, "Discard browse lists, stop being a master browser, and try again"},
190 { 0x04, "Stop being a master browser for ever"},
194 static true_false_string tfs_demote_to_backup = {
195 "Demote an LMB to a Backup Browser",
196 "Do not demote an LMB to a Backup Browser"
199 static true_false_string tfs_flush_browse_list = {
200 "Flush the Browse List",
201 "Do not Flush the Browse List"
204 static true_false_string tfs_stop_being_lmb = {
205 "Stop Being a Local Master Browser",
206 "Do not Stop Being a Local Master Browser"
209 static const true_false_string tfs_workstation = {
210 "This is a Workstation",
211 "This is NOT a Workstation"
213 static const true_false_string tfs_server = {
215 "This is NOT a Server"
217 static const true_false_string tfs_sql = {
218 "This is an SQL server",
219 "This is NOT an SQL server"
221 static const true_false_string tfs_domain = {
222 "This is a Domain Controller",
223 "This is NOT a Domain Controller"
225 static const true_false_string tfs_backup = {
226 "This is a Backup Controller",
227 "This is NOT a Backup Controller"
229 static const true_false_string tfs_time = {
230 "This is a Time Source",
231 "This is NOT a Time Source"
233 static const true_false_string tfs_apple = {
234 "This is an Apple host",
235 "This is NOT an Apple host"
237 static const true_false_string tfs_novell = {
238 "This is a Novell server",
239 "This is NOT a Novell server"
241 static const true_false_string tfs_member = {
242 "This is a Domain Member server",
243 "This is NOT a Domain Member server"
245 static const true_false_string tfs_print = {
246 "This is a Print Queue server",
247 "This is NOT a Print Queue server"
249 static const true_false_string tfs_dialin = {
250 "This is a Dialin server",
251 "This is NOT a Dialin server"
253 static const true_false_string tfs_xenix = {
254 "This is a Xenix server",
255 "This is NOT a Xenix server"
257 static const true_false_string tfs_ntw = {
258 "This is an NT Workstation",
259 "This is NOT an NT Workstation"
261 static const true_false_string tfs_wfw = {
262 "This is a WfW host",
263 "This is NOT a WfW host"
265 static const true_false_string tfs_nts = {
266 "This is an NT Server",
267 "This is NOT an NT Server"
269 static const true_false_string tfs_potentialb = {
270 "This is a Potential Browser",
271 "This is NOT a Potential Browser"
273 static const true_false_string tfs_backupb = {
274 "This is a Backup Browser",
275 "This is NOT a Backup Browser"
277 static const true_false_string tfs_masterb = {
278 "This is a Master Browser",
279 "This is NOT a Master Browser"
281 static const true_false_string tfs_domainmasterb = {
282 "This is a Domain Master Browser",
283 "This is NOT a Domain Master Browser"
285 static const true_false_string tfs_osf = {
286 "This is an OSF host",
287 "This is NOT an OSF host"
289 static const true_false_string tfs_vms = {
290 "This is a VMS host",
291 "This is NOT a VMS host"
293 static const true_false_string tfs_w95 = {
294 "This is a Windows 95 or above host",
295 "This is NOT a Windows 95 or above host"
297 static const true_false_string tfs_dfs = {
298 "This is a DFS server",
299 "THis is NOT a DFS server"
301 static const true_false_string tfs_local = {
302 "This is a local list only request",
303 "This is NOT a local list only request"
305 static const true_false_string tfs_domainenum = {
306 "This is a Domain Enum request",
307 "This is NOT a Domain Enum request"
310 #define DESIRE_BACKUP 0
311 #define DESIRE_STANDBY 1
312 #define DESIRE_MASTER 2
313 #define DESIRE_DOMAIN_MASTER 3
314 #define DESIRE_WINS 5
317 static const true_false_string tfs_desire_backup = {
318 "Backup Browse Server",
319 "NOT Backup Browse Server"
321 static const true_false_string tfs_desire_standby = {
322 "Standby Browse Server",
323 "NOT Standby Browse Server"
325 static const true_false_string tfs_desire_master = {
329 static const true_false_string tfs_desire_domain_master = {
330 "Domain Master Browse Server",
331 "NOT Domain Master Browse Server"
333 static const true_false_string tfs_desire_wins = {
337 static const true_false_string tfs_desire_nt = {
338 "Windows NT Advanced Server",
339 "NOT Windows NT Advanced Server"
342 #define BROWSE_HOST_ANNOUNCE 1
343 #define BROWSE_REQUEST_ANNOUNCE 2
344 #define BROWSE_ELECTION_REQUEST 8
345 #define BROWSE_BACKUP_LIST_REQUEST 9
346 #define BROWSE_BACKUP_LIST_RESPONSE 10
347 #define BROWSE_BECOME_BACKUP 11
348 #define BROWSE_DOMAIN_ANNOUNCEMENT 12
349 #define BROWSE_MASTER_ANNOUNCEMENT 13
350 #define BROWSE_RESETBROWSERSTATE_ANNOUNCEMENT 14
351 #define BROWSE_LOCAL_MASTER_ANNOUNCEMENT 15
353 static const value_string commands[] = {
354 {BROWSE_HOST_ANNOUNCE, "Host Announcement"},
355 {BROWSE_REQUEST_ANNOUNCE, "Request Announcement"},
356 {BROWSE_ELECTION_REQUEST, "Browser Election Request"},
357 {BROWSE_BACKUP_LIST_REQUEST, "Get Backup List Request"},
358 {BROWSE_BACKUP_LIST_RESPONSE, "Get Backup List Response"},
359 {BROWSE_BECOME_BACKUP, "Become Backup Browser"},
360 {BROWSE_DOMAIN_ANNOUNCEMENT, "Domain/Workgroup Announcement"},
361 {BROWSE_MASTER_ANNOUNCEMENT, "Master Announcement"},
362 {BROWSE_RESETBROWSERSTATE_ANNOUNCEMENT, "Reset Browser State Announcement"},
363 {BROWSE_LOCAL_MASTER_ANNOUNCEMENT,"Local Master Announcement"},
371 static const true_false_string tfs_os_wfw = {
372 "Windows for Workgroups",
373 "Not Windows for Workgroups"
375 static const true_false_string tfs_os_ntw = {
376 "Windows NT Workstation",
377 "Not Windows NT Workstation"
379 static const true_false_string tfs_os_nts = {
381 "Not Windows NT Server"
385 dissect_election_criterion_os(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
387 proto_tree *tree = NULL;
388 proto_item *item = NULL;
391 os = tvb_get_guint8(tvb, offset);
394 item = proto_tree_add_uint(parent_tree, hf_election_os, tvb, offset, 1, os);
395 tree = proto_item_add_subtree(item, ett_browse_election_os);
398 proto_tree_add_boolean(tree, hf_election_os_wfw,
400 proto_tree_add_boolean(tree, hf_election_os_ntw,
402 proto_tree_add_boolean(tree, hf_election_os_nts,
408 dissect_election_criterion_desire(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
410 proto_tree *tree = NULL;
411 proto_item *item = NULL;
414 desire = tvb_get_guint8(tvb, offset);
417 item = proto_tree_add_uint(parent_tree, hf_election_desire, tvb, offset, 1, desire);
418 tree = proto_item_add_subtree(item, ett_browse_election_desire);
421 proto_tree_add_boolean(tree, hf_election_desire_flags_backup,
422 tvb, offset, 1, desire);
423 proto_tree_add_boolean(tree, hf_election_desire_flags_standby,
424 tvb, offset, 1, desire);
425 proto_tree_add_boolean(tree, hf_election_desire_flags_master,
426 tvb, offset, 1, desire);
427 proto_tree_add_boolean(tree, hf_election_desire_flags_domain_master,
428 tvb, offset, 1, desire);
429 proto_tree_add_boolean(tree, hf_election_desire_flags_wins,
430 tvb, offset, 1, desire);
431 proto_tree_add_boolean(tree, hf_election_desire_flags_nt,
432 tvb, offset, 1, desire);
437 dissect_election_criterion(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
439 proto_tree *tree = NULL;
440 proto_item *item = NULL;
443 criterion = tvb_get_letohl(tvb, offset);
446 item = proto_tree_add_uint(parent_tree, hf_election_criteria, tvb, offset, 4, criterion);
447 tree = proto_item_add_subtree(item, ett_browse_election_criteria);
450 /* election desire */
451 dissect_election_criterion_desire(tvb, tree, offset);
454 /* browser protocol major version */
455 proto_tree_add_item(tree, hf_proto_major, tvb, offset, 1, TRUE);
458 /* browser protocol minor version */
459 proto_tree_add_item(tree, hf_proto_minor, tvb, offset, 1, TRUE);
463 dissect_election_criterion_os(tvb, tree, offset);
469 * XXX - this causes non-browser packets to have browser fields.
472 dissect_smb_server_type_flags(tvbuff_t *tvb, int offset, packet_info *pinfo,
473 proto_tree *parent_tree, guint8 *drep,
476 proto_tree *tree = NULL;
477 proto_item *item = NULL;
483 * Called from a DCE RPC protocol dissector, for a
484 * protocol where a 32-bit NDR integer contains
485 * an server type mask; extract the server type mask
486 * with an NDR call (but don't put it into the
487 * protocol tree, as we can't get a pointer to the
488 * item it puts in, and thus can't put a tree below
489 * it with the values of the individual bits).
491 offset = dissect_ndr_uint32(
492 tvb, offset, pinfo, NULL, drep, hf_server_type, &flags);
495 * Called from SMB browser or RAP, where the server type
496 * mask is just a 4-byte little-endian quantity with no
497 * special NDR alignment requirement; extract it with
498 * "tvb_get_letohl()".
500 flags = tvb_get_letohl(tvb, offset);
505 item = proto_tree_add_uint(parent_tree, hf_server_type, tvb, offset-4, 4, flags);
506 tree = proto_item_add_subtree(item, ett_browse_flags);
510 /* Append the type(s) of the system to the COL_INFO line ... */
511 if (check_col(pinfo->cinfo, COL_INFO)) {
512 for (i = 0; i < 32; i++) {
513 if (flags & (1<<i)) {
514 col_append_fstr(pinfo->cinfo, COL_INFO, ", %s",
515 val_to_str(i, server_types,
516 "Unknown server type:%d"));
522 proto_tree_add_boolean(tree, hf_server_type_workstation,
523 tvb, offset-4, 4, flags);
524 proto_tree_add_boolean(tree, hf_server_type_server,
525 tvb, offset-4, 4, flags);
526 proto_tree_add_boolean(tree, hf_server_type_sql,
527 tvb, offset-4, 4, flags);
528 proto_tree_add_boolean(tree, hf_server_type_domain,
529 tvb, offset-4, 4, flags);
530 proto_tree_add_boolean(tree, hf_server_type_backup,
531 tvb, offset-4, 4, flags);
532 proto_tree_add_boolean(tree, hf_server_type_time,
533 tvb, offset-4, 4, flags);
534 proto_tree_add_boolean(tree, hf_server_type_apple,
535 tvb, offset-4, 4, flags);
536 proto_tree_add_boolean(tree, hf_server_type_novell,
537 tvb, offset-4, 4, flags);
538 proto_tree_add_boolean(tree, hf_server_type_member,
539 tvb, offset-4, 4, flags);
540 proto_tree_add_boolean(tree, hf_server_type_print,
541 tvb, offset-4, 4, flags);
542 proto_tree_add_boolean(tree, hf_server_type_dialin,
543 tvb, offset-4, 4, flags);
544 proto_tree_add_boolean(tree, hf_server_type_xenix,
545 tvb, offset-4, 4, flags);
546 proto_tree_add_boolean(tree, hf_server_type_ntw,
547 tvb, offset-4, 4, flags);
548 proto_tree_add_boolean(tree, hf_server_type_wfw,
549 tvb, offset-4, 4, flags);
550 proto_tree_add_boolean(tree, hf_server_type_nts,
551 tvb, offset-4, 4, flags);
552 proto_tree_add_boolean(tree, hf_server_type_potentialb,
553 tvb, offset-4, 4, flags);
554 proto_tree_add_boolean(tree, hf_server_type_backupb,
555 tvb, offset-4, 4, flags);
556 proto_tree_add_boolean(tree, hf_server_type_masterb,
557 tvb, offset-4, 4, flags);
558 proto_tree_add_boolean(tree, hf_server_type_domainmasterb,
559 tvb, offset-4, 4, flags);
560 proto_tree_add_boolean(tree, hf_server_type_osf,
561 tvb, offset-4, 4, flags);
562 proto_tree_add_boolean(tree, hf_server_type_vms,
563 tvb, offset-4, 4, flags);
564 proto_tree_add_boolean(tree, hf_server_type_w95,
565 tvb, offset-4, 4, flags);
566 proto_tree_add_boolean(tree, hf_server_type_dfs,
567 tvb, offset-4, 4, flags);
568 proto_tree_add_boolean(tree, hf_server_type_local,
569 tvb, offset-4, 4, flags);
570 proto_tree_add_boolean(tree, hf_server_type_domainenum,
571 tvb, offset-4, 4, flags);
578 dissect_mailslot_browse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
582 proto_tree *tree = NULL;
583 proto_item *item = NULL;
586 gchar *utf8_host_name;
588 guint8 server_count, reset_cmd;
589 guint8 os_major_ver, os_minor_ver;
590 gchar *windows_version = NULL;
594 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BROWSER");
595 col_clear(pinfo->cinfo, COL_INFO);
597 cmd = tvb_get_guint8(tvb, offset);
599 if (check_col(pinfo->cinfo, COL_INFO)) {
600 /* Put in something, and replace it later */
601 col_add_str(pinfo->cinfo, COL_INFO, val_to_str(cmd, commands, "Unknown command:0x%02x"));
606 item = proto_tree_add_item(parent_tree, proto_smb_browse, tvb, offset, -1, TRUE);
608 tree = proto_item_add_subtree(item, ett_browse);
612 proto_tree_add_uint(tree, hf_command, tvb, offset, 1, cmd);
616 case BROWSE_DOMAIN_ANNOUNCEMENT:
617 case BROWSE_LOCAL_MASTER_ANNOUNCEMENT:
618 case BROWSE_HOST_ANNOUNCE: {
620 proto_tree_add_item(tree, hf_update_count, tvb, offset, 1, TRUE);
623 /* periodicity (in milliseconds) */
624 periodicity = tvb_get_letohl(tvb, offset);
625 proto_tree_add_uint_format(tree, hf_periodicity, tvb, offset, 4,
627 "Update Periodicity: %s",
628 time_msecs_to_str(periodicity));
632 tvb_get_nstringz0(tvb, offset, sizeof(host_name), host_name);
633 utf8_host_name = g_convert(host_name, strlen(host_name),
634 "UTF-8", "CP437", NULL, NULL, NULL);
635 if (utf8_host_name == NULL)
636 utf8_host_name = host_name;
637 if (check_col(pinfo->cinfo, COL_INFO)) {
638 col_append_fstr(pinfo->cinfo, COL_INFO, " %s", utf8_host_name);
640 proto_tree_add_string_format(tree, hf_server_name,
643 (cmd==BROWSE_DOMAIN_ANNOUNCEMENT)?
644 "Domain/Workgroup: %s":
647 if (utf8_host_name != host_name)
648 g_free(utf8_host_name);
651 /* Windows version (See "OSVERSIONINFO Structure" on MSDN) */
652 os_major_ver = tvb_get_guint8(tvb, offset);
653 os_minor_ver = tvb_get_guint8(tvb, offset+1);
655 SET_WINDOWS_VERSION_STRING(os_major_ver, os_minor_ver, windows_version);
658 proto_tree_add_text(tree, tvb, offset, 2, "Windows version: %s", windows_version);
660 /* OS major version */
661 proto_tree_add_item(tree, hf_os_major, tvb, offset, 1, TRUE);
664 /* OS minor version */
665 proto_tree_add_item(tree, hf_os_minor, tvb, offset, 1, TRUE);
668 /* server type flags */
669 offset = dissect_smb_server_type_flags(
670 tvb, offset, pinfo, tree, NULL, TRUE);
672 if (cmd == BROWSE_DOMAIN_ANNOUNCEMENT && tvb_get_letohs (tvb, offset + 2) != 0xAA55) {
674 * Network Monitor claims this is a "Comment
675 * Pointer". I don't believe it.
677 * It's not a browser protocol major/minor
678 * version number, and signature constant,
681 proto_tree_add_text(tree, tvb, offset, 4,
682 "Mysterious Field: 0x%08x",
683 tvb_get_letohl(tvb, offset));
686 /* browser protocol major version */
687 proto_tree_add_item(tree, hf_proto_major, tvb, offset, 1, TRUE);
690 /* browser protocol minor version */
691 proto_tree_add_item(tree, hf_proto_minor, tvb, offset, 1, TRUE);
694 /* signature constant */
695 proto_tree_add_item(tree, hf_sig_const, tvb, offset, 2, TRUE);
699 /* master browser server name or server comment */
700 namelen = tvb_strsize(tvb, offset);
701 proto_tree_add_item(tree,
702 (cmd==BROWSE_DOMAIN_ANNOUNCEMENT)?
703 hf_mb_server_name : hf_server_comment,
704 tvb, offset, namelen, TRUE);
708 case BROWSE_REQUEST_ANNOUNCE: {
709 guint8 *computer_name;
711 /* unused/unknown flags */
712 proto_tree_add_item(tree, hf_unused_flags,
713 tvb, offset, 1, TRUE);
716 /* name of computer to which to send reply */
717 computer_name = tvb_get_ephemeral_stringz(tvb, offset, &namelen);
718 proto_tree_add_string(tree, hf_response_computer_name,
719 tvb, offset, namelen, computer_name);
720 if (check_col(pinfo->cinfo, COL_INFO))
722 pinfo->cinfo, COL_INFO, " %s", computer_name);
727 case BROWSE_ELECTION_REQUEST:
728 /* election version */
729 proto_tree_add_item(tree, hf_election_version, tvb, offset, 1, TRUE);
733 dissect_election_criterion(tvb, tree, offset);
737 uptime = tvb_get_letohl(tvb, offset);
738 proto_tree_add_uint_format(tree, hf_server_uptime,
739 tvb, offset, 4, uptime,
741 time_msecs_to_str(uptime));
744 /* next 4 bytes must be zero */
748 namelen = tvb_strsize(tvb, offset);
749 proto_tree_add_item(tree, hf_server_name,
750 tvb, offset, namelen, TRUE);
754 case BROWSE_BACKUP_LIST_REQUEST:
755 /* backup list requested count */
756 proto_tree_add_item(tree, hf_backup_count, tvb, offset, 1, TRUE);
759 /* backup requested token */
760 proto_tree_add_item(tree, hf_backup_token, tvb, offset, 4, TRUE);
764 case BROWSE_BACKUP_LIST_RESPONSE:
765 /* backup list requested count */
766 server_count = tvb_get_guint8(tvb, offset);
767 proto_tree_add_uint(tree, hf_backup_count, tvb, offset, 1,
771 /* backup requested token */
772 proto_tree_add_item(tree, hf_backup_token, tvb, offset, 4, TRUE);
775 /* backup server names */
776 for (i = 0; i < server_count; i++) {
777 namelen = tvb_strsize(tvb, offset);
778 proto_tree_add_item(tree, hf_backup_server,
779 tvb, offset, namelen, TRUE);
784 case BROWSE_MASTER_ANNOUNCEMENT:
785 /* master browser server name */
786 namelen = tvb_strsize(tvb, offset);
787 proto_tree_add_item(tree, hf_mb_server_name,
788 tvb, offset, namelen, TRUE);
792 case BROWSE_RESETBROWSERSTATE_ANNOUNCEMENT: {
793 proto_tree *sub_tree;
794 proto_item *reset_item;
796 /* the subcommand follows ... one of three values */
798 reset_cmd = tvb_get_guint8(tvb, offset);
799 reset_item = proto_tree_add_uint(tree, hf_mb_reset_command, tvb,
800 offset, 1, reset_cmd);
801 sub_tree = proto_item_add_subtree(item, ett_browse_reset_cmd_flags);
802 proto_tree_add_boolean(sub_tree, hf_mb_reset_demote, tvb,
803 offset, 1, reset_cmd);
804 proto_tree_add_boolean(sub_tree, hf_mb_reset_flush, tvb,
805 offset, 1, reset_cmd);
806 proto_tree_add_boolean(sub_tree, hf_mb_reset_stop, tvb,
807 offset, 1, reset_cmd);
812 case BROWSE_BECOME_BACKUP:
813 /* name of browser to promote */
814 namelen = tvb_strsize(tvb, offset);
815 proto_tree_add_item(tree, hf_browser_to_promote,
816 tvb, offset, namelen, TRUE);
823 * It appears that browser announcements sent to \MAILSLOT\LANMAN aren't
824 * the same as browser announcements sent to \MAILSLOT\BROWSE.
825 * Was that an older version of the protocol?
829 * http://www.samba.org/samba/ftp/specs/brow_rev.txt
831 * gives both formats of host announcement packets, saying that
832 * "[The first] format seems wrong", that one being what appears to
833 * show up in \MAILSLOT\LANMAN packets, and that "[The second one]
834 * may be better", that one being what appears to show up in
835 * \MAILSLOT\BROWSE packets.
837 * XXX - what other browser packets go out to that mailslot?
840 dissect_mailslot_lanman(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
844 proto_tree *tree = NULL;
845 proto_item *item = NULL;
847 const guint8 *host_name;
848 guint8 os_major_ver, os_minor_ver;
849 gchar *windows_version = NULL;
852 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BROWSER");
853 col_clear(pinfo->cinfo, COL_INFO);
855 cmd = tvb_get_guint8(tvb, offset);
857 if (check_col(pinfo->cinfo, COL_INFO)) {
858 /* Put in something, and replace it later */
859 col_add_str(pinfo->cinfo, COL_INFO, val_to_str(cmd, commands, "Unknown command:0x%02x"));
864 item = proto_tree_add_item(parent_tree, proto_smb_browse, tvb, offset, -1, TRUE);
866 tree = proto_item_add_subtree(item, ett_browse);
870 proto_tree_add_uint(tree, hf_command, tvb, offset, 1, cmd);
874 case BROWSE_DOMAIN_ANNOUNCEMENT:
875 case BROWSE_LOCAL_MASTER_ANNOUNCEMENT:
876 case BROWSE_HOST_ANNOUNCE:
879 proto_tree_add_item(tree, hf_update_count, tvb, offset, 1, TRUE);
882 /* server type flags */
883 offset = dissect_smb_server_type_flags(
884 tvb, offset, pinfo, tree, NULL, TRUE);
886 /* OS version string (See "OSVERSIONINFO Structure" on MSDN) */
887 os_major_ver = tvb_get_guint8(tvb, offset);
888 os_minor_ver = tvb_get_guint8(tvb, offset+1);
890 SET_WINDOWS_VERSION_STRING(os_major_ver, os_minor_ver, windows_version);
893 proto_tree_add_text(tree, tvb, offset, 2, "Windows version: %s", windows_version);
895 /* OS major version */
896 proto_tree_add_item(tree, hf_os_major, tvb, offset, 1, TRUE);
899 /* OS minor version */
900 proto_tree_add_item(tree, hf_os_minor, tvb, offset, 1, TRUE);
903 /* periodicity (in seconds; convert to milliseconds) */
904 periodicity = tvb_get_letohs(tvb, offset)*1000;
905 proto_tree_add_uint_format(tree, hf_periodicity, tvb, offset, 2,
907 "Update Periodicity: %s",
908 time_msecs_to_str(periodicity));
912 namelen = tvb_strsize(tvb, offset);
913 host_name = tvb_get_ptr(tvb, offset, namelen);
914 if (check_col(pinfo->cinfo, COL_INFO)) {
915 col_append_fstr(pinfo->cinfo, COL_INFO, " %s", host_name);
917 proto_tree_add_item(tree, hf_server_name,
918 tvb, offset, namelen, TRUE);
921 /* master browser server name or server comment */
922 namelen = tvb_strsize(tvb, offset);
923 proto_tree_add_item(tree,
924 (cmd==BROWSE_DOMAIN_ANNOUNCEMENT)?
925 hf_mb_server_name : hf_server_comment,
926 tvb, offset, namelen, TRUE);
933 proto_register_smb_browse(void)
935 static hf_register_info hf[] = {
937 { "Command", "browser.command", FT_UINT8, BASE_HEX,
938 VALS(commands), 0, "Browse command opcode", HFILL }},
941 { "Update Count", "browser.update_count", FT_UINT8, BASE_DEC,
942 NULL, 0, "Browse Update Count", HFILL }},
945 { "Update Periodicity", "browser.period", FT_UINT32, BASE_DEC,
946 NULL, 0, "Update Periodicity in ms", HFILL }},
949 { "Server Name", "browser.server", FT_STRING, BASE_NONE,
950 NULL, 0, "BROWSE Server Name", HFILL }},
952 { &hf_mb_server_name,
953 { "Master Browser Server Name", "browser.mb_server", FT_STRING, BASE_NONE,
954 NULL, 0, "BROWSE Master Browser Server Name", HFILL }},
956 { &hf_mb_reset_command,
957 { "ResetBrowserState Command", "browser.reset_cmd", FT_UINT8,
958 BASE_HEX, VALS(resetbrowserstate_command_names), 0,
960 { &hf_mb_reset_demote,
961 { "Demote LMB", "browser.reset_cmd.demote", FT_BOOLEAN,
962 8, TFS(&tfs_demote_to_backup), 0x01, NULL, HFILL}},
963 { &hf_mb_reset_flush,
964 { "Flush Browse List", "browser.reset_cmd.flush", FT_BOOLEAN,
965 8, TFS(&tfs_flush_browse_list), 0x02, NULL, HFILL}},
967 { "Stop Being LMB", "browser.reset_cmd.stop_lmb", FT_BOOLEAN,
968 8, TFS(&tfs_stop_being_lmb), 0x04, NULL, HFILL}},
970 { "OS Major Version", "browser.os_major", FT_UINT8, BASE_DEC,
971 NULL, 0, "Operating System Major Version", HFILL }},
974 { "OS Minor Version", "browser.os_minor", FT_UINT8, BASE_DEC,
975 NULL, 0, "Operating System Minor Version", HFILL }},
978 { "Server Type", "browser.server_type", FT_UINT32, BASE_HEX,
979 NULL, 0, "Server Type Flags", HFILL }},
981 { &hf_server_type_workstation,
982 { "Workstation", "browser.server_type.workstation", FT_BOOLEAN, 32,
983 TFS(&tfs_workstation), 1<<SERVER_WORKSTATION, "Is This A Workstation?", HFILL }},
985 { &hf_server_type_server,
986 { "Server", "browser.server_type.server", FT_BOOLEAN, 32,
987 TFS(&tfs_server), 1<<SERVER_SERVER, "Is This A Server?", HFILL }},
989 { &hf_server_type_sql,
990 { "SQL", "browser.server_type.sql", FT_BOOLEAN, 32,
991 TFS(&tfs_sql), 1<<SERVER_SQL_SERVER, "Is This A SQL Server?", HFILL }},
993 { &hf_server_type_domain,
994 { "Domain Controller", "browser.server_type.domain_controller", FT_BOOLEAN, 32,
995 TFS(&tfs_domain), 1<<SERVER_DOMAIN_CONTROLLER, "Is This A Domain Controller?", HFILL }},
997 { &hf_server_type_backup,
998 { "Backup Controller", "browser.server_type.backup_controller", FT_BOOLEAN, 32,
999 TFS(&tfs_backup), 1<<SERVER_BACKUP_CONTROLLER, "Is This A Backup Domain Controller?", HFILL }},
1001 { &hf_server_type_time,
1002 { "Time Source", "browser.server_type.time", FT_BOOLEAN, 32,
1003 TFS(&tfs_time), 1<<SERVER_TIME_SOURCE, "Is This A Time Source?", HFILL }},
1005 { &hf_server_type_apple,
1006 { "Apple", "browser.server_type.apple", FT_BOOLEAN, 32,
1007 TFS(&tfs_apple), 1<<SERVER_APPLE_SERVER, "Is This An Apple Server ?", HFILL }},
1009 { &hf_server_type_novell,
1010 { "Novell", "browser.server_type.novell", FT_BOOLEAN, 32,
1011 TFS(&tfs_novell), 1<<SERVER_NOVELL_SERVER, "Is This A Novell Server?", HFILL }},
1013 { &hf_server_type_member,
1014 { "Member", "browser.server_type.member", FT_BOOLEAN, 32,
1015 TFS(&tfs_member), 1<<SERVER_DOMAIN_MEMBER_SERVER, "Is This A Domain Member Server?", HFILL }},
1017 { &hf_server_type_print,
1018 { "Print", "browser.server_type.print", FT_BOOLEAN, 32,
1019 TFS(&tfs_print), 1<<SERVER_PRINT_QUEUE_SERVER, "Is This A Print Server?", HFILL }},
1021 { &hf_server_type_dialin,
1022 { "Dialin", "browser.server_type.dialin", FT_BOOLEAN, 32,
1023 TFS(&tfs_dialin), 1<<SERVER_DIALIN_SERVER, "Is This A Dialin Server?", HFILL }},
1025 { &hf_server_type_xenix,
1026 { "Xenix", "browser.server_type.xenix", FT_BOOLEAN, 32,
1027 TFS(&tfs_xenix), 1<<SERVER_XENIX_SERVER, "Is This A Xenix Server?", HFILL }},
1029 { &hf_server_type_ntw,
1030 { "NT Workstation", "browser.server_type.ntw", FT_BOOLEAN, 32,
1031 TFS(&tfs_ntw), 1<<SERVER_NT_WORKSTATION, "Is This A NT Workstation?", HFILL }},
1033 { &hf_server_type_wfw,
1034 { "WfW", "browser.server_type.wfw", FT_BOOLEAN, 32,
1035 TFS(&tfs_wfw), 1<<SERVER_WINDOWS_FOR_WORKGROUPS, "Is This A Windows For Workgroups Server?", HFILL }},
1037 { &hf_server_type_nts,
1038 { "NT Server", "browser.server_type.nts", FT_BOOLEAN, 32,
1039 TFS(&tfs_nts), 1<<SERVER_NT_SERVER, "Is This A NT Server?", HFILL }},
1041 { &hf_server_type_potentialb,
1042 { "Potential Browser", "browser.server_type.browser.potential", FT_BOOLEAN, 32,
1043 TFS(&tfs_potentialb), 1<<SERVER_POTENTIAL_BROWSER, "Is This A Potential Browser?", HFILL }},
1045 { &hf_server_type_backupb,
1046 { "Backup Browser", "browser.server_type.browser.backup", FT_BOOLEAN, 32,
1047 TFS(&tfs_backupb), 1<<SERVER_BACKUP_BROWSER, "Is This A Backup Browser?", HFILL }},
1049 { &hf_server_type_masterb,
1050 { "Master Browser", "browser.server_type.browser.master", FT_BOOLEAN, 32,
1051 TFS(&tfs_masterb), 1<<SERVER_MASTER_BROWSER, "Is This A Master Browser?", HFILL }},
1053 { &hf_server_type_domainmasterb,
1054 { "Domain Master Browser", "browser.server_type.browser.domain_master", FT_BOOLEAN, 32,
1055 TFS(&tfs_domainmasterb), 1<<SERVER_DOMAIN_MASTER_BROWSER, "Is This A Domain Master Browser?", HFILL }},
1057 { &hf_server_type_osf,
1058 { "OSF", "browser.server_type.osf", FT_BOOLEAN, 32,
1059 TFS(&tfs_osf), 1<<SERVER_OSF, "Is This An OSF server ?", HFILL }},
1061 { &hf_server_type_vms,
1062 { "VMS", "browser.server_type.vms", FT_BOOLEAN, 32,
1063 TFS(&tfs_vms), 1<<SERVER_VMS, "Is This A VMS Server?", HFILL }},
1065 { &hf_server_type_w95,
1066 { "Windows 95+", "browser.server_type.w95", FT_BOOLEAN, 32,
1067 TFS(&tfs_w95), 1<<SERVER_WINDOWS_95, "Is This A Windows 95 or above server?", HFILL }},
1069 { &hf_server_type_dfs,
1070 { "DFS", "browser.server_type.dfs", FT_BOOLEAN, 32,
1071 TFS(&tfs_dfs), 1<<SERVER_DFS_SERVER, "Is This A DFS server?", HFILL }},
1073 { &hf_server_type_local,
1074 { "Local", "browser.server_type.local", FT_BOOLEAN, 32,
1075 TFS(&tfs_local), 1<<SERVER_LOCAL_LIST_ONLY, "Is This A Local List Only request?", HFILL }},
1077 { &hf_server_type_domainenum,
1078 { "Domain Enum", "browser.server_type.domainenum", FT_BOOLEAN, 32,
1079 TFS(&tfs_domainenum), 1<<SERVER_DOMAIN_ENUM, "Is This A Domain Enum request?", HFILL }},
1081 { &hf_election_version,
1082 { "Election Version", "browser.election.version", FT_UINT8, BASE_DEC,
1083 NULL, 0, NULL, HFILL }},
1086 { "Browser Protocol Major Version", "browser.proto_major", FT_UINT8, BASE_DEC,
1087 NULL, 0, NULL, HFILL }},
1090 { "Browser Protocol Minor Version", "browser.proto_minor", FT_UINT8, BASE_DEC,
1091 NULL, 0, NULL, HFILL }},
1094 { "Signature", "browser.sig", FT_UINT16, BASE_HEX,
1095 NULL, 0, "Signature Constant", HFILL }},
1097 { &hf_server_comment,
1098 { "Host Comment", "browser.comment", FT_STRINGZ, BASE_NONE,
1099 NULL, 0, "Server Comment", HFILL }},
1102 { "Unused flags", "browser.unused", FT_UINT8, BASE_HEX,
1103 NULL, 0, "Unused/unknown flags", HFILL }},
1105 { &hf_response_computer_name,
1106 { "Response Computer Name", "browser.response_computer_name", FT_STRINGZ, BASE_NONE,
1107 NULL, 0, NULL, HFILL }},
1109 { &hf_election_criteria,
1110 { "Election Criteria", "browser.election.criteria", FT_UINT32, BASE_HEX,
1111 NULL, 0, NULL, HFILL }},
1113 { &hf_election_desire,
1114 { "Election Desire", "browser.election.desire", FT_UINT8, BASE_HEX,
1115 NULL, 0, NULL, HFILL }},
1117 { &hf_election_desire_flags_backup,
1118 { "Backup", "browser.election.desire.backup", FT_BOOLEAN, 8,
1119 TFS(&tfs_desire_backup), 1<<DESIRE_BACKUP, "Is this a backup server", HFILL }},
1121 { &hf_election_desire_flags_standby,
1122 { "Standby", "browser.election.desire.standby", FT_BOOLEAN, 8,
1123 TFS(&tfs_desire_standby), 1<<DESIRE_STANDBY, "Is this a standby server?", HFILL }},
1125 { &hf_election_desire_flags_master,
1126 { "Master", "browser.election.desire.master", FT_BOOLEAN, 8,
1127 TFS(&tfs_desire_master), 1<<DESIRE_MASTER, "Is this a master server", HFILL }},
1129 { &hf_election_desire_flags_domain_master,
1130 { "Domain Master", "browser.election.desire.domain_master", FT_BOOLEAN, 8,
1131 TFS(&tfs_desire_domain_master), 1<<DESIRE_DOMAIN_MASTER, "Is this a domain master", HFILL }},
1133 { &hf_election_desire_flags_wins,
1134 { "WINS", "browser.election.desire.wins", FT_BOOLEAN, 8,
1135 TFS(&tfs_desire_wins), 1<<DESIRE_WINS, "Is this a WINS server", HFILL }},
1137 { &hf_election_desire_flags_nt,
1138 { "NT", "browser.election.desire.nt", FT_BOOLEAN, 8,
1139 TFS(&tfs_desire_nt), 1<<DESIRE_NT, "Is this a NT server", HFILL }},
1141 { &hf_election_revision,
1142 { "Election Revision", "browser.election.revision", FT_UINT16, BASE_DEC,
1143 NULL, 0, NULL, HFILL }},
1146 { "Election OS", "browser.election.os", FT_UINT8, BASE_HEX,
1147 NULL, 0, NULL, HFILL }},
1149 { &hf_election_os_wfw,
1150 { "WfW", "browser.election.os.wfw", FT_BOOLEAN, 8,
1151 TFS(&tfs_os_wfw), 1<<OS_WFW, "Is this a WfW host?", HFILL }},
1153 { &hf_election_os_ntw,
1154 { "NT Workstation", "browser.election.os.ntw", FT_BOOLEAN, 8,
1155 TFS(&tfs_os_ntw), 1<<OS_NTW, "Is this a NT Workstation?", HFILL }},
1157 { &hf_election_os_nts,
1158 { "NT Server", "browser.election.os.nts", FT_BOOLEAN, 8,
1159 TFS(&tfs_os_nts), 1<<OS_NTS, "Is this a NT Server?", HFILL }},
1161 { &hf_server_uptime,
1162 { "Uptime", "browser.uptime", FT_UINT32, BASE_DEC,
1163 NULL, 0, "Server uptime in ms", HFILL }},
1166 { "Backup List Requested Count", "browser.backup.count", FT_UINT8, BASE_DEC,
1167 NULL, 0, NULL, HFILL }},
1170 { "Backup Request Token", "browser.backup.token", FT_UINT32, BASE_DEC,
1171 NULL, 0, "Backup requested/response token", HFILL }},
1173 { &hf_backup_server,
1174 { "Backup Server", "browser.backup.server", FT_STRING, BASE_NONE,
1175 NULL, 0, "Backup Server Name", HFILL }},
1177 { &hf_browser_to_promote,
1178 { "Browser to Promote", "browser.browser_to_promote", FT_STRINGZ, BASE_NONE,
1179 NULL, 0, NULL, HFILL }},
1183 static gint *ett[] = {
1186 &ett_browse_election_criteria,
1187 &ett_browse_election_os,
1188 &ett_browse_election_desire,
1189 &ett_browse_reset_cmd_flags,
1192 proto_smb_browse = proto_register_protocol("Microsoft Windows Browser Protocol",
1193 "BROWSER", "browser");
1195 proto_register_field_array(proto_smb_browse, hf, array_length(hf));
1196 proto_register_subtree_array(ett, array_length(ett));
1198 register_dissector("mailslot_browse", dissect_mailslot_browse,
1200 register_dissector("mailslot_lanman", dissect_mailslot_lanman,