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.
38 #include <epan/packet.h>
39 #include <epan/emem.h>
40 #include <epan/dissectors/packet-smb.h>
42 #include "packet-smb-browse.h"
43 #include "packet-dcerpc.h"
45 static int proto_smb_browse = -1;
46 static int hf_command = -1;
47 static int hf_update_count = -1;
48 static int hf_periodicity = -1;
49 static int hf_server_name = -1;
50 static int hf_mb_server_name = -1;
51 static int hf_mb_reset_command = -1;
52 static int hf_mb_reset_demote = -1;
53 static int hf_mb_reset_flush = -1;
54 static int hf_mb_reset_stop = -1;
55 static int hf_os_major = -1;
56 static int hf_os_minor = -1;
57 static int hf_server_type = -1;
58 static int hf_server_type_workstation = -1;
59 static int hf_server_type_server = -1;
60 static int hf_server_type_sql = -1;
61 static int hf_server_type_domain = -1;
62 static int hf_server_type_backup = -1;
63 static int hf_server_type_time = -1;
64 static int hf_server_type_apple = -1;
65 static int hf_server_type_novell = -1;
66 static int hf_server_type_member = -1;
67 static int hf_server_type_print = -1;
68 static int hf_server_type_dialin = -1;
69 static int hf_server_type_xenix = -1;
70 static int hf_server_type_ntw = -1;
71 static int hf_server_type_wfw = -1;
72 static int hf_server_type_nts = -1;
73 static int hf_server_type_potentialb = -1;
74 static int hf_server_type_backupb = -1;
75 static int hf_server_type_masterb = -1;
76 static int hf_server_type_domainmasterb = -1;
77 static int hf_server_type_osf = -1;
78 static int hf_server_type_vms = -1;
79 static int hf_server_type_w95 = -1;
80 static int hf_server_type_local = -1;
81 static int hf_server_type_domainenum = -1;
82 static int hf_election_version = -1;
83 static int hf_proto_major = -1;
84 static int hf_proto_minor = -1;
85 static int hf_sig_const = -1;
86 static int hf_server_comment = -1;
87 static int hf_unused_flags = -1;
88 static int hf_response_computer_name = -1;
89 static int hf_election_criteria = -1;
90 static int hf_election_desire = -1;
91 static int hf_election_desire_flags_backup = -1;
92 static int hf_election_desire_flags_standby = -1;
93 static int hf_election_desire_flags_master = -1;
94 static int hf_election_desire_flags_domain_master = -1;
95 static int hf_election_desire_flags_wins = -1;
96 static int hf_election_desire_flags_nt = -1;
97 static int hf_election_revision = -1;
98 static int hf_election_os = -1;
99 static int hf_election_os_wfw = -1;
100 static int hf_election_os_ntw = -1;
101 static int hf_election_os_nts = -1;
102 static int hf_server_uptime = -1;
103 static int hf_backup_count = -1;
104 static int hf_backup_token = -1;
105 static int hf_backup_server = -1;
106 static int hf_browser_to_promote = -1;
108 static gint ett_browse = -1;
109 static gint ett_browse_flags = -1;
110 static gint ett_browse_election_criteria = -1;
111 static gint ett_browse_election_os = -1;
112 static gint ett_browse_election_desire = -1;
113 static gint ett_browse_reset_cmd_flags = -1;
115 #define SERVER_WORKSTATION 0
116 #define SERVER_SERVER 1
117 #define SERVER_SQL_SERVER 2
118 #define SERVER_DOMAIN_CONTROLLER 3
119 #define SERVER_BACKUP_CONTROLLER 4
120 #define SERVER_TIME_SOURCE 5
121 #define SERVER_APPLE_SERVER 6
122 #define SERVER_NOVELL_SERVER 7
123 #define SERVER_DOMAIN_MEMBER_SERVER 8
124 #define SERVER_PRINT_QUEUE_SERVER 9
125 #define SERVER_DIALIN_SERVER 10
126 #define SERVER_XENIX_SERVER 11
127 #define SERVER_NT_WORKSTATION 12
128 #define SERVER_WINDOWS_FOR_WORKGROUPS 13
129 #define SERVER_NT_SERVER 15
130 #define SERVER_POTENTIAL_BROWSER 16
131 #define SERVER_BACKUP_BROWSER 17
132 #define SERVER_MASTER_BROWSER 18
133 #define SERVER_DOMAIN_MASTER_BROWSER 19
134 #define SERVER_OSF 20
135 #define SERVER_VMS 21
136 #define SERVER_WINDOWS_95 22
137 #define SERVER_LOCAL_LIST_ONLY 30
138 #define SERVER_DOMAIN_ENUM 31
140 static const value_string server_types[] = {
141 {SERVER_WORKSTATION, "Workstation"},
142 {SERVER_SERVER, "Server"},
143 {SERVER_SQL_SERVER, "SQL Server"},
144 {SERVER_DOMAIN_CONTROLLER, "Domain Controller"},
145 {SERVER_BACKUP_CONTROLLER, "Backup Controller"},
146 {SERVER_TIME_SOURCE, "Time Source"},
147 {SERVER_APPLE_SERVER, "Apple Server"},
148 {SERVER_NOVELL_SERVER, "Novell Server"},
149 {SERVER_DOMAIN_MEMBER_SERVER, "Domain Member Server"},
150 {SERVER_PRINT_QUEUE_SERVER, "Print Queue Server"},
151 {SERVER_DIALIN_SERVER, "Dialin Server"},
152 {SERVER_XENIX_SERVER, "Xenix Server"},
153 {SERVER_NT_WORKSTATION, "NT Workstation"},
154 {SERVER_WINDOWS_FOR_WORKGROUPS, "Windows for Workgroups"},
155 {SERVER_NT_SERVER, "NT Server"},
156 {SERVER_POTENTIAL_BROWSER, "Potential Browser"},
157 {SERVER_BACKUP_BROWSER, "Backup Browser"},
158 {SERVER_MASTER_BROWSER, "Master Browser"},
159 {SERVER_DOMAIN_MASTER_BROWSER, "Domain Master Browser"},
162 {SERVER_WINDOWS_95, "Windows 95 or above"},
163 {SERVER_LOCAL_LIST_ONLY, "Local List Only"},
164 {SERVER_DOMAIN_ENUM, "Domain Enum"},
168 static const value_string resetbrowserstate_command_names[] = {
169 { 0x01, "Stop being a master browser and become a backup browser"},
170 { 0x02, "Discard browse lists, stop being a master browser, and try again"},
171 { 0x04, "Stop being a master browser for ever"},
175 static true_false_string tfs_demote_to_backup = {
176 "Demote an LMB to a Backup Browser",
177 "Do not demote an LMB to a Backup Browser"
180 static true_false_string tfs_flush_browse_list = {
181 "Flush the Browse List",
182 "Do not Flush the Browse List"
185 static true_false_string tfs_stop_being_lmb = {
186 "Stop Being a Local Master Browser",
187 "Do not Stop Being a Local Master Browser"
190 static const true_false_string tfs_workstation = {
191 "This is a Workstation",
192 "This is NOT a Workstation"
194 static const true_false_string tfs_server = {
196 "This is NOT a Server"
198 static const true_false_string tfs_sql = {
199 "This is an SQL server",
200 "This is NOT an SQL server"
202 static const true_false_string tfs_domain = {
203 "This is a Domain Controller",
204 "This is NOT a Domain Controller"
206 static const true_false_string tfs_backup = {
207 "This is a Backup Controller",
208 "This is NOT a Backup Controller"
210 static const true_false_string tfs_time = {
211 "This is a Time Source",
212 "This is NOT a Time Source"
214 static const true_false_string tfs_apple = {
215 "This is an Apple host",
216 "This is NOT an Apple host"
218 static const true_false_string tfs_novell = {
219 "This is a Novell server",
220 "This is NOT a Novell server"
222 static const true_false_string tfs_member = {
223 "This is a Domain Member server",
224 "This is NOT a Domain Member server"
226 static const true_false_string tfs_print = {
227 "This is a Print Queue server",
228 "This is NOT a Print Queue server"
230 static const true_false_string tfs_dialin = {
231 "This is a Dialin server",
232 "This is NOT a Dialin server"
234 static const true_false_string tfs_xenix = {
235 "This is a Xenix server",
236 "This is NOT a Xenix server"
238 static const true_false_string tfs_ntw = {
239 "This is an NT Workstation",
240 "This is NOT an NT Workstation"
242 static const true_false_string tfs_wfw = {
243 "This is a WfW host",
244 "This is NOT a WfW host"
246 static const true_false_string tfs_nts = {
247 "This is an NT Server",
248 "This is NOT an NT Server"
250 static const true_false_string tfs_potentialb = {
251 "This is a Potential Browser",
252 "This is NOT a Potential Browser"
254 static const true_false_string tfs_backupb = {
255 "This is a Backup Browser",
256 "This is NOT a Backup Browser"
258 static const true_false_string tfs_masterb = {
259 "This is a Master Browser",
260 "This is NOT a Master Browser"
262 static const true_false_string tfs_domainmasterb = {
263 "This is a Domain Master Browser",
264 "This is NOT a Domain Master Browser"
266 static const true_false_string tfs_osf = {
267 "This is an OSF host",
268 "This is NOT an OSF host"
270 static const true_false_string tfs_vms = {
271 "This is a VMS host",
272 "This is NOT a VMS host"
274 static const true_false_string tfs_w95 = {
275 "This is a Windows 95 or above host",
276 "This is NOT a Windows 95 or above host"
278 static const true_false_string tfs_local = {
279 "This is a local list only request",
280 "This is NOT a local list only request"
282 static const true_false_string tfs_domainenum = {
283 "This is a Domain Enum request",
284 "This is NOT a Domain Enum request"
287 #define DESIRE_BACKUP 0
288 #define DESIRE_STANDBY 1
289 #define DESIRE_MASTER 2
290 #define DESIRE_DOMAIN_MASTER 3
291 #define DESIRE_WINS 5
294 static const true_false_string tfs_desire_backup = {
295 "Backup Browse Server",
296 "NOT Backup Browse Server"
298 static const true_false_string tfs_desire_standby = {
299 "Standby Browse Server",
300 "NOT Standby Browse Server"
302 static const true_false_string tfs_desire_master = {
306 static const true_false_string tfs_desire_domain_master = {
307 "Domain Master Browse Server",
308 "NOT Domain Master Browse Server"
310 static const true_false_string tfs_desire_wins = {
314 static const true_false_string tfs_desire_nt = {
315 "Windows NT Advanced Server",
316 "NOT Windows NT Advanced Server"
319 #define BROWSE_HOST_ANNOUNCE 1
320 #define BROWSE_REQUEST_ANNOUNCE 2
321 #define BROWSE_ELECTION_REQUEST 8
322 #define BROWSE_BACKUP_LIST_REQUEST 9
323 #define BROWSE_BACKUP_LIST_RESPONSE 10
324 #define BROWSE_BECOME_BACKUP 11
325 #define BROWSE_DOMAIN_ANNOUNCEMENT 12
326 #define BROWSE_MASTER_ANNOUNCEMENT 13
327 #define BROWSE_RESETBROWSERSTATE_ANNOUNCEMENT 14
328 #define BROWSE_LOCAL_MASTER_ANNOUNCEMENT 15
330 static const value_string commands[] = {
331 {BROWSE_HOST_ANNOUNCE, "Host Announcement"},
332 {BROWSE_REQUEST_ANNOUNCE, "Request Announcement"},
333 {BROWSE_ELECTION_REQUEST, "Browser Election Request"},
334 {BROWSE_BACKUP_LIST_REQUEST, "Get Backup List Request"},
335 {BROWSE_BACKUP_LIST_RESPONSE, "Get Backup List Response"},
336 {BROWSE_BECOME_BACKUP, "Become Backup Browser"},
337 {BROWSE_DOMAIN_ANNOUNCEMENT, "Domain/Workgroup Announcement"},
338 {BROWSE_MASTER_ANNOUNCEMENT, "Master Announcement"},
339 {BROWSE_RESETBROWSERSTATE_ANNOUNCEMENT, "Reset Browser State Announcement"},
340 {BROWSE_LOCAL_MASTER_ANNOUNCEMENT,"Local Master Announcement"},
348 static const true_false_string tfs_os_wfw = {
349 "Windows for Workgroups",
350 "Not Windows for Workgroups"
352 static const true_false_string tfs_os_ntw = {
353 "Windows NT Workstation",
354 "Not Windows NT Workstation"
356 static const true_false_string tfs_os_nts = {
358 "Not Windows NT Server"
362 dissect_election_criterion_os(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
364 proto_tree *tree = NULL;
365 proto_item *item = NULL;
368 os = tvb_get_guint8(tvb, offset);
371 item = proto_tree_add_uint(parent_tree, hf_election_os, tvb, offset, 1, os);
372 tree = proto_item_add_subtree(item, ett_browse_election_os);
375 proto_tree_add_boolean(tree, hf_election_os_wfw,
377 proto_tree_add_boolean(tree, hf_election_os_ntw,
379 proto_tree_add_boolean(tree, hf_election_os_nts,
385 dissect_election_criterion_desire(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
387 proto_tree *tree = NULL;
388 proto_item *item = NULL;
391 desire = tvb_get_guint8(tvb, offset);
394 item = proto_tree_add_uint(parent_tree, hf_election_desire, tvb, offset, 1, desire);
395 tree = proto_item_add_subtree(item, ett_browse_election_desire);
398 proto_tree_add_boolean(tree, hf_election_desire_flags_backup,
399 tvb, offset, 1, desire);
400 proto_tree_add_boolean(tree, hf_election_desire_flags_standby,
401 tvb, offset, 1, desire);
402 proto_tree_add_boolean(tree, hf_election_desire_flags_master,
403 tvb, offset, 1, desire);
404 proto_tree_add_boolean(tree, hf_election_desire_flags_domain_master,
405 tvb, offset, 1, desire);
406 proto_tree_add_boolean(tree, hf_election_desire_flags_wins,
407 tvb, offset, 1, desire);
408 proto_tree_add_boolean(tree, hf_election_desire_flags_nt,
409 tvb, offset, 1, desire);
414 dissect_election_criterion(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
416 proto_tree *tree = NULL;
417 proto_item *item = NULL;
420 criterion = tvb_get_letohl(tvb, offset);
423 item = proto_tree_add_uint(parent_tree, hf_election_criteria, tvb, offset, 4, criterion);
424 tree = proto_item_add_subtree(item, ett_browse_election_criteria);
427 /* election desire */
428 dissect_election_criterion_desire(tvb, tree, offset);
431 /* browser protocol major version */
432 proto_tree_add_item(tree, hf_proto_major, tvb, offset, 1, TRUE);
435 /* browser protocol minor version */
436 proto_tree_add_item(tree, hf_proto_minor, tvb, offset, 1, TRUE);
440 dissect_election_criterion_os(tvb, tree, offset);
446 * XXX - this causes non-browser packets to have browser fields.
449 dissect_smb_server_type_flags(tvbuff_t *tvb, int offset, packet_info *pinfo,
450 proto_tree *parent_tree, guint8 *drep,
453 proto_tree *tree = NULL;
454 proto_item *item = NULL;
460 * Called from a DCE RPC protocol dissector, for a
461 * protocol where a 32-bit NDR integer contains
462 * an server type mask; extract the server type mask
463 * with an NDR call (but don't put it into the
464 * protocol tree, as we can't get a pointer to the
465 * item it puts in, and thus can't put a tree below
466 * it with the values of the individual bits).
468 offset = dissect_ndr_uint32(
469 tvb, offset, pinfo, NULL, drep, hf_server_type, &flags);
472 * Called from SMB browser or RAP, where the server type
473 * mask is just a 4-byte little-endian quantity with no
474 * special NDR alignment requirement; extract it with
475 * "tvb_get_letohl()".
477 flags = tvb_get_letohl(tvb, offset);
482 item = proto_tree_add_uint(parent_tree, hf_server_type, tvb, offset-4, 4, flags);
483 tree = proto_item_add_subtree(item, ett_browse_flags);
487 /* Append the type(s) of the system to the COL_INFO line ... */
488 if (check_col(pinfo->cinfo, COL_INFO)) {
489 for (i = 0; i < 32; i++) {
490 if (flags & (1<<i)) {
491 col_append_fstr(pinfo->cinfo, COL_INFO, ", %s",
492 val_to_str(i, server_types,
493 "Unknown server type:%d"));
499 proto_tree_add_boolean(tree, hf_server_type_workstation,
500 tvb, offset-4, 4, flags);
501 proto_tree_add_boolean(tree, hf_server_type_server,
502 tvb, offset-4, 4, flags);
503 proto_tree_add_boolean(tree, hf_server_type_sql,
504 tvb, offset-4, 4, flags);
505 proto_tree_add_boolean(tree, hf_server_type_domain,
506 tvb, offset-4, 4, flags);
507 proto_tree_add_boolean(tree, hf_server_type_backup,
508 tvb, offset-4, 4, flags);
509 proto_tree_add_boolean(tree, hf_server_type_time,
510 tvb, offset-4, 4, flags);
511 proto_tree_add_boolean(tree, hf_server_type_apple,
512 tvb, offset-4, 4, flags);
513 proto_tree_add_boolean(tree, hf_server_type_novell,
514 tvb, offset-4, 4, flags);
515 proto_tree_add_boolean(tree, hf_server_type_member,
516 tvb, offset-4, 4, flags);
517 proto_tree_add_boolean(tree, hf_server_type_print,
518 tvb, offset-4, 4, flags);
519 proto_tree_add_boolean(tree, hf_server_type_dialin,
520 tvb, offset-4, 4, flags);
521 proto_tree_add_boolean(tree, hf_server_type_xenix,
522 tvb, offset-4, 4, flags);
523 proto_tree_add_boolean(tree, hf_server_type_ntw,
524 tvb, offset-4, 4, flags);
525 proto_tree_add_boolean(tree, hf_server_type_wfw,
526 tvb, offset-4, 4, flags);
527 proto_tree_add_boolean(tree, hf_server_type_nts,
528 tvb, offset-4, 4, flags);
529 proto_tree_add_boolean(tree, hf_server_type_potentialb,
530 tvb, offset-4, 4, flags);
531 proto_tree_add_boolean(tree, hf_server_type_backupb,
532 tvb, offset-4, 4, flags);
533 proto_tree_add_boolean(tree, hf_server_type_masterb,
534 tvb, offset-4, 4, flags);
535 proto_tree_add_boolean(tree, hf_server_type_domainmasterb,
536 tvb, offset-4, 4, flags);
537 proto_tree_add_boolean(tree, hf_server_type_osf,
538 tvb, offset-4, 4, flags);
539 proto_tree_add_boolean(tree, hf_server_type_vms,
540 tvb, offset-4, 4, flags);
541 proto_tree_add_boolean(tree, hf_server_type_w95,
542 tvb, offset-4, 4, flags);
543 proto_tree_add_boolean(tree, hf_server_type_local,
544 tvb, offset-4, 4, flags);
545 proto_tree_add_boolean(tree, hf_server_type_domainenum,
546 tvb, offset-4, 4, flags);
553 dissect_mailslot_browse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
557 proto_tree *tree = NULL;
558 proto_item *item = NULL;
560 guint8 host_name[17];
562 guint8 server_count, reset_cmd;
566 if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
567 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BROWSER");
569 if (check_col(pinfo->cinfo, COL_INFO)) {
570 col_clear(pinfo->cinfo, COL_INFO);
573 cmd = tvb_get_guint8(tvb, offset);
575 if (check_col(pinfo->cinfo, COL_INFO)) {
576 /* Put in something, and replace it later */
577 col_add_str(pinfo->cinfo, COL_INFO, val_to_str(cmd, commands, "Unknown command:0x%02x"));
582 item = proto_tree_add_item(parent_tree, proto_smb_browse, tvb, offset, -1, TRUE);
584 tree = proto_item_add_subtree(item, ett_browse);
588 proto_tree_add_uint(tree, hf_command, tvb, offset, 1, cmd);
592 case BROWSE_DOMAIN_ANNOUNCEMENT:
593 case BROWSE_LOCAL_MASTER_ANNOUNCEMENT:
594 case BROWSE_HOST_ANNOUNCE: {
596 proto_tree_add_item(tree, hf_update_count, tvb, offset, 1, TRUE);
599 /* periodicity (in milliseconds) */
600 periodicity = tvb_get_letohl(tvb, offset);
601 proto_tree_add_uint_format(tree, hf_periodicity, tvb, offset, 4,
603 "Update Periodicity: %s",
604 time_msecs_to_str(periodicity));
608 tvb_get_nstringz0(tvb, offset, sizeof(host_name), host_name);
609 if (check_col(pinfo->cinfo, COL_INFO)) {
610 col_append_fstr(pinfo->cinfo, COL_INFO, " %s", host_name);
612 proto_tree_add_string_format(tree, hf_server_name,
615 (cmd==BROWSE_DOMAIN_ANNOUNCEMENT)?
616 "Domain/Workgroup: %s":
621 /* OS major version */
622 proto_tree_add_item(tree, hf_os_major, tvb, offset, 1, TRUE);
625 /* OS minor version */
626 proto_tree_add_item(tree, hf_os_minor, tvb, offset, 1, TRUE);
629 /* server type flags */
630 offset = dissect_smb_server_type_flags(
631 tvb, offset, pinfo, tree, NULL, TRUE);
633 if (cmd == BROWSE_DOMAIN_ANNOUNCEMENT) {
635 * Network Monitor claims this is a "Comment
636 * Pointer". I don't believe it.
638 * It's not a browser protocol major/minor
639 * version number, and signature constant,
642 proto_tree_add_text(tree, tvb, offset, 4,
643 "Mysterious Field: 0x%08x",
644 tvb_get_letohl(tvb, offset));
647 /* browser protocol major version */
648 proto_tree_add_item(tree, hf_proto_major, tvb, offset, 1, TRUE);
651 /* browser protocol minor version */
652 proto_tree_add_item(tree, hf_proto_minor, tvb, offset, 1, TRUE);
655 /* signature constant */
656 proto_tree_add_item(tree, hf_sig_const, tvb, offset, 2, TRUE);
660 /* master browser server name or server comment */
661 namelen = tvb_strsize(tvb, offset);
662 proto_tree_add_item(tree,
663 (cmd==BROWSE_DOMAIN_ANNOUNCEMENT)?
664 hf_mb_server_name : hf_server_comment,
665 tvb, offset, namelen, TRUE);
669 case BROWSE_REQUEST_ANNOUNCE: {
670 guint8 *computer_name;
672 /* unused/unknown flags */
673 proto_tree_add_item(tree, hf_unused_flags,
674 tvb, offset, 1, TRUE);
677 /* name of computer to which to send reply */
678 computer_name = tvb_get_ephemeral_stringz(tvb, offset, &namelen);
679 proto_tree_add_string(tree, hf_response_computer_name,
680 tvb, offset, namelen, computer_name);
681 if (check_col(pinfo->cinfo, COL_INFO))
683 pinfo->cinfo, COL_INFO, " %s", computer_name);
688 case BROWSE_ELECTION_REQUEST:
689 /* election version */
690 proto_tree_add_item(tree, hf_election_version, tvb, offset, 1, TRUE);
694 dissect_election_criterion(tvb, tree, offset);
698 uptime = tvb_get_letohl(tvb, offset);
699 proto_tree_add_uint_format(tree, hf_server_uptime,
700 tvb, offset, 4, uptime,
702 time_msecs_to_str(uptime));
705 /* next 4 bytes must be zero */
709 namelen = tvb_strsize(tvb, offset);
710 proto_tree_add_item(tree, hf_server_name,
711 tvb, offset, namelen, TRUE);
715 case BROWSE_BACKUP_LIST_REQUEST:
716 /* backup list requested count */
717 proto_tree_add_item(tree, hf_backup_count, tvb, offset, 1, TRUE);
720 /* backup requested token */
721 proto_tree_add_item(tree, hf_backup_token, tvb, offset, 4, TRUE);
725 case BROWSE_BACKUP_LIST_RESPONSE:
726 /* backup list requested count */
727 server_count = tvb_get_guint8(tvb, offset);
728 proto_tree_add_uint(tree, hf_backup_count, tvb, offset, 1,
732 /* backup requested token */
733 proto_tree_add_item(tree, hf_backup_token, tvb, offset, 4, TRUE);
736 /* backup server names */
737 for (i = 0; i < server_count; i++) {
738 namelen = tvb_strsize(tvb, offset);
739 proto_tree_add_item(tree, hf_backup_server,
740 tvb, offset, namelen, TRUE);
745 case BROWSE_MASTER_ANNOUNCEMENT:
746 /* master browser server name */
747 namelen = tvb_strsize(tvb, offset);
748 proto_tree_add_item(tree, hf_mb_server_name,
749 tvb, offset, namelen, TRUE);
753 case BROWSE_RESETBROWSERSTATE_ANNOUNCEMENT: {
754 proto_tree *sub_tree;
755 proto_item *reset_item;
757 /* the subcommand follows ... one of three values */
759 reset_cmd = tvb_get_guint8(tvb, offset);
760 reset_item = proto_tree_add_uint(tree, hf_mb_reset_command, tvb,
761 offset, 1, reset_cmd);
762 sub_tree = proto_item_add_subtree(item, ett_browse_reset_cmd_flags);
763 proto_tree_add_boolean(sub_tree, hf_mb_reset_demote, tvb,
764 offset, 1, reset_cmd);
765 proto_tree_add_boolean(sub_tree, hf_mb_reset_flush, tvb,
766 offset, 1, reset_cmd);
767 proto_tree_add_boolean(sub_tree, hf_mb_reset_stop, tvb,
768 offset, 1, reset_cmd);
773 case BROWSE_BECOME_BACKUP:
774 /* name of browser to promote */
775 namelen = tvb_strsize(tvb, offset);
776 proto_tree_add_item(tree, hf_browser_to_promote,
777 tvb, offset, namelen, TRUE);
784 * It appears that browser announcements sent to \MAILSLOT\LANMAN aren't
785 * the same as browser announcements sent to \MAILSLOT\BROWSE.
786 * Was that an older version of the protocol?
790 * http://www.samba.org/samba/ftp/specs/brow_rev.txt
792 * gives both formats of host announcement packets, saying that
793 * "[The first] format seems wrong", that one being what appears to
794 * show up in \MAILSLOT\LANMAN packets, and that "[The second one]
795 * may be better", that one being what appears to show up in
796 * \MAILSLOT\BROWSE packets.
798 * XXX - what other browser packets go out to that mailslot?
801 dissect_mailslot_lanman(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
805 proto_tree *tree = NULL;
806 proto_item *item = NULL;
808 const guint8 *host_name;
811 if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
812 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BROWSER");
814 if (check_col(pinfo->cinfo, COL_INFO)) {
815 col_clear(pinfo->cinfo, COL_INFO);
818 cmd = tvb_get_guint8(tvb, offset);
820 if (check_col(pinfo->cinfo, COL_INFO)) {
821 /* Put in something, and replace it later */
822 col_add_str(pinfo->cinfo, COL_INFO, val_to_str(cmd, commands, "Unknown command:0x%02x"));
827 item = proto_tree_add_item(parent_tree, proto_smb_browse, tvb, offset, -1, TRUE);
829 tree = proto_item_add_subtree(item, ett_browse);
833 proto_tree_add_uint(tree, hf_command, tvb, offset, 1, cmd);
837 case BROWSE_DOMAIN_ANNOUNCEMENT:
838 case BROWSE_LOCAL_MASTER_ANNOUNCEMENT:
839 case BROWSE_HOST_ANNOUNCE:
842 proto_tree_add_item(tree, hf_update_count, tvb, offset, 1, TRUE);
845 /* server type flags */
846 offset = dissect_smb_server_type_flags(
847 tvb, offset, pinfo, tree, NULL, TRUE);
849 /* OS major version */
850 proto_tree_add_item(tree, hf_os_major, tvb, offset, 1, TRUE);
853 /* OS minor version */
854 proto_tree_add_item(tree, hf_os_minor, tvb, offset, 1, TRUE);
857 /* periodicity (in seconds; convert to milliseconds) */
858 periodicity = tvb_get_letohs(tvb, offset)*1000;
859 proto_tree_add_uint_format(tree, hf_periodicity, tvb, offset, 2,
861 "Update Periodicity: %s",
862 time_msecs_to_str(periodicity));
866 namelen = tvb_strsize(tvb, offset);
867 host_name = tvb_get_ptr(tvb, offset, namelen);
868 if (check_col(pinfo->cinfo, COL_INFO)) {
869 col_append_fstr(pinfo->cinfo, COL_INFO, " %s", host_name);
871 proto_tree_add_item(tree, hf_server_name,
872 tvb, offset, namelen, TRUE);
875 /* master browser server name or server comment */
876 namelen = tvb_strsize(tvb, offset);
877 proto_tree_add_item(tree,
878 (cmd==BROWSE_DOMAIN_ANNOUNCEMENT)?
879 hf_mb_server_name : hf_server_comment,
880 tvb, offset, namelen, TRUE);
887 proto_register_smb_browse(void)
889 static hf_register_info hf[] = {
891 { "Command", "browser.command", FT_UINT8, BASE_HEX,
892 VALS(commands), 0, "Browse command opcode", HFILL }},
895 { "Update Count", "browser.update_count", FT_UINT8, BASE_DEC,
896 NULL, 0, "Browse Update Count", HFILL }},
899 { "Update Periodicity", "browser.period", FT_UINT32, BASE_DEC,
900 NULL, 0, "Update Periodicity in ms", HFILL }},
903 { "Server Name", "browser.server", FT_STRING, BASE_NONE,
904 NULL, 0, "BROWSE Server Name", HFILL }},
906 { &hf_mb_server_name,
907 { "Master Browser Server Name", "browser.mb_server", FT_STRING, BASE_NONE,
908 NULL, 0, "BROWSE Master Browser Server Name", HFILL }},
910 { &hf_mb_reset_command,
911 { "ResetBrowserState Command", "browser.reset_cmd", FT_UINT8,
912 BASE_HEX, VALS(&resetbrowserstate_command_names), 0,
913 "ResetBrowserState Command", HFILL }},
914 { &hf_mb_reset_demote,
915 { "Demote LMB", "browser.reset_cmd.demote", FT_BOOLEAN,
916 8, TFS(&tfs_demote_to_backup), 0x01, "Demote LMB", HFILL}},
917 { &hf_mb_reset_flush,
918 { "Flush Browse List", "browser.reset_cmd.flush", FT_BOOLEAN,
919 8, TFS(&tfs_flush_browse_list), 0x02, "Flush Browse List", HFILL}},
921 { "Stop Being LMB", "browser.reset_cmd.stop_lmb", FT_BOOLEAN,
922 8, TFS(&tfs_stop_being_lmb), 0x04, "Stop Being LMB", HFILL}},
924 { "OS Major Version", "browser.os_major", FT_UINT8, BASE_DEC,
925 NULL, 0, "Operating System Major Version", HFILL }},
928 { "OS Minor Version", "browser.os_minor", FT_UINT8, BASE_DEC,
929 NULL, 0, "Operating System Minor Version", HFILL }},
932 { "Server Type", "browser.server_type", FT_UINT32, BASE_HEX,
933 NULL, 0, "Server Type Flags", HFILL }},
935 { &hf_server_type_workstation,
936 { "Workstation", "browser.server_type.workstation", FT_BOOLEAN, 32,
937 TFS(&tfs_workstation), 1<<SERVER_WORKSTATION, "Is This A Workstation?", HFILL }},
939 { &hf_server_type_server,
940 { "Server", "browser.server_type.server", FT_BOOLEAN, 32,
941 TFS(&tfs_server), 1<<SERVER_SERVER, "Is This A Server?", HFILL }},
943 { &hf_server_type_sql,
944 { "SQL", "browser.server_type.sql", FT_BOOLEAN, 32,
945 TFS(&tfs_sql), 1<<SERVER_SQL_SERVER, "Is This A SQL Server?", HFILL }},
947 { &hf_server_type_domain,
948 { "Domain Controller", "browser.server_type.domain_controller", FT_BOOLEAN, 32,
949 TFS(&tfs_domain), 1<<SERVER_DOMAIN_CONTROLLER, "Is This A Domain Controller?", HFILL }},
951 { &hf_server_type_backup,
952 { "Backup Controller", "browser.server_type.backup_controller", FT_BOOLEAN, 32,
953 TFS(&tfs_backup), 1<<SERVER_BACKUP_CONTROLLER, "Is This A Backup Domain Controller?", HFILL }},
955 { &hf_server_type_time,
956 { "Time Source", "browser.server_type.time", FT_BOOLEAN, 32,
957 TFS(&tfs_time), 1<<SERVER_TIME_SOURCE, "Is This A Time Source?", HFILL }},
959 { &hf_server_type_apple,
960 { "Apple", "browser.server_type.apple", FT_BOOLEAN, 32,
961 TFS(&tfs_apple), 1<<SERVER_APPLE_SERVER, "Is This An Apple Server ?", HFILL }},
963 { &hf_server_type_novell,
964 { "Novell", "browser.server_type.novell", FT_BOOLEAN, 32,
965 TFS(&tfs_novell), 1<<SERVER_NOVELL_SERVER, "Is This A Novell Server?", HFILL }},
967 { &hf_server_type_member,
968 { "Member", "browser.server_type.member", FT_BOOLEAN, 32,
969 TFS(&tfs_member), 1<<SERVER_DOMAIN_MEMBER_SERVER, "Is This A Domain Member Server?", HFILL }},
971 { &hf_server_type_print,
972 { "Print", "browser.server_type.print", FT_BOOLEAN, 32,
973 TFS(&tfs_print), 1<<SERVER_PRINT_QUEUE_SERVER, "Is This A Print Server?", HFILL }},
975 { &hf_server_type_dialin,
976 { "Dialin", "browser.server_type.dialin", FT_BOOLEAN, 32,
977 TFS(&tfs_dialin), 1<<SERVER_DIALIN_SERVER, "Is This A Dialin Server?", HFILL }},
979 { &hf_server_type_xenix,
980 { "Xenix", "browser.server_type.xenix", FT_BOOLEAN, 32,
981 TFS(&tfs_xenix), 1<<SERVER_XENIX_SERVER, "Is This A Xenix Server?", HFILL }},
983 { &hf_server_type_ntw,
984 { "NT Workstation", "browser.server_type.ntw", FT_BOOLEAN, 32,
985 TFS(&tfs_ntw), 1<<SERVER_NT_WORKSTATION, "Is This A NT Workstation?", HFILL }},
987 { &hf_server_type_wfw,
988 { "WfW", "browser.server_type.wfw", FT_BOOLEAN, 32,
989 TFS(&tfs_wfw), 1<<SERVER_WINDOWS_FOR_WORKGROUPS, "Is This A Windows For Workgroups Server?", HFILL }},
991 { &hf_server_type_nts,
992 { "NT Server", "browser.server_type.nts", FT_BOOLEAN, 32,
993 TFS(&tfs_nts), 1<<SERVER_NT_SERVER, "Is This A NT Server?", HFILL }},
995 { &hf_server_type_potentialb,
996 { "Potential Browser", "browser.server_type.browser.potential", FT_BOOLEAN, 32,
997 TFS(&tfs_potentialb), 1<<SERVER_POTENTIAL_BROWSER, "Is This A Potential Browser?", HFILL }},
999 { &hf_server_type_backupb,
1000 { "Backup Browser", "browser.server_type.browser.backup", FT_BOOLEAN, 32,
1001 TFS(&tfs_backupb), 1<<SERVER_BACKUP_BROWSER, "Is This A Backup Browser?", HFILL }},
1003 { &hf_server_type_masterb,
1004 { "Master Browser", "browser.server_type.browser.master", FT_BOOLEAN, 32,
1005 TFS(&tfs_masterb), 1<<SERVER_MASTER_BROWSER, "Is This A Master Browser?", HFILL }},
1007 { &hf_server_type_domainmasterb,
1008 { "Domain Master Browser", "browser.server_type.browser.domain_master", FT_BOOLEAN, 32,
1009 TFS(&tfs_domainmasterb), 1<<SERVER_DOMAIN_MASTER_BROWSER, "Is This A Domain Master Browser?", HFILL }},
1011 { &hf_server_type_osf,
1012 { "OSF", "browser.server_type.osf", FT_BOOLEAN, 32,
1013 TFS(&tfs_osf), 1<<SERVER_OSF, "Is This An OSF server ?", HFILL }},
1015 { &hf_server_type_vms,
1016 { "VMS", "browser.server_type.vms", FT_BOOLEAN, 32,
1017 TFS(&tfs_vms), 1<<SERVER_VMS, "Is This A VMS Server?", HFILL }},
1019 { &hf_server_type_w95,
1020 { "Windows 95+", "browser.server_type.w95", FT_BOOLEAN, 32,
1021 TFS(&tfs_w95), 1<<SERVER_WINDOWS_95, "Is This A Windows 95 or above server?", HFILL }},
1023 { &hf_server_type_local,
1024 { "Local", "browser.server_type.local", FT_BOOLEAN, 32,
1025 TFS(&tfs_local), 1<<SERVER_LOCAL_LIST_ONLY, "Is This A Local List Only request?", HFILL }},
1027 { &hf_server_type_domainenum,
1028 { "Domain Enum", "browser.server_type.domainenum", FT_BOOLEAN, 32,
1029 TFS(&tfs_domainenum), 1<<SERVER_DOMAIN_ENUM, "Is This A Domain Enum request?", HFILL }},
1031 { &hf_election_version,
1032 { "Election Version", "browser.election.version", FT_UINT8, BASE_DEC,
1033 NULL, 0, "Election Version", HFILL }},
1036 { "Browser Protocol Major Version", "browser.proto_major", FT_UINT8, BASE_DEC,
1037 NULL, 0, "Browser Protocol Major Version", HFILL }},
1040 { "Browser Protocol Minor Version", "browser.proto_minor", FT_UINT8, BASE_DEC,
1041 NULL, 0, "Browser Protocol Minor Version", HFILL }},
1044 { "Signature", "browser.sig", FT_UINT16, BASE_HEX,
1045 NULL, 0, "Signature Constant", HFILL }},
1047 { &hf_server_comment,
1048 { "Host Comment", "browser.comment", FT_STRINGZ, BASE_NONE,
1049 NULL, 0, "Server Comment", HFILL }},
1052 { "Unused flags", "browser.unused", FT_UINT8, BASE_HEX,
1053 NULL, 0, "Unused/unknown flags", HFILL }},
1055 { &hf_response_computer_name,
1056 { "Response Computer Name", "browser.response_computer_name", FT_STRINGZ, BASE_NONE,
1057 NULL, 0, "Response Computer Name", HFILL }},
1059 { &hf_election_criteria,
1060 { "Election Criteria", "browser.election.criteria", FT_UINT32, BASE_HEX,
1061 NULL, 0, "Election Criteria", HFILL }},
1063 { &hf_election_desire,
1064 { "Election Desire", "browser.election.desire", FT_UINT8, BASE_HEX,
1065 NULL, 0, "Election Desire", HFILL }},
1067 { &hf_election_desire_flags_backup,
1068 { "Backup", "browser.election.desire.backup", FT_BOOLEAN, 8,
1069 TFS(&tfs_desire_backup), 1<<DESIRE_BACKUP, "Is this a backup server", HFILL }},
1071 { &hf_election_desire_flags_standby,
1072 { "Standby", "browser.election.desire.standby", FT_BOOLEAN, 8,
1073 TFS(&tfs_desire_standby), 1<<DESIRE_STANDBY, "Is this a standby server?", HFILL }},
1075 { &hf_election_desire_flags_master,
1076 { "Master", "browser.election.desire.master", FT_BOOLEAN, 8,
1077 TFS(&tfs_desire_master), 1<<DESIRE_MASTER, "Is this a master server", HFILL }},
1079 { &hf_election_desire_flags_domain_master,
1080 { "Domain Master", "browser.election.desire.domain_master", FT_BOOLEAN, 8,
1081 TFS(&tfs_desire_domain_master), 1<<DESIRE_DOMAIN_MASTER, "Is this a domain master", HFILL }},
1083 { &hf_election_desire_flags_wins,
1084 { "WINS", "browser.election.desire.wins", FT_BOOLEAN, 8,
1085 TFS(&tfs_desire_wins), 1<<DESIRE_WINS, "Is this a WINS server", HFILL }},
1087 { &hf_election_desire_flags_nt,
1088 { "NT", "browser.election.desire.nt", FT_BOOLEAN, 8,
1089 TFS(&tfs_desire_nt), 1<<DESIRE_NT, "Is this a NT server", HFILL }},
1091 { &hf_election_revision,
1092 { "Election Revision", "browser.election.revision", FT_UINT16, BASE_DEC,
1093 NULL, 0, "Election Revision", HFILL }},
1096 { "Election OS", "browser.election.os", FT_UINT8, BASE_HEX,
1097 NULL, 0, "Election OS", HFILL }},
1099 { &hf_election_os_wfw,
1100 { "WfW", "browser.election.os.wfw", FT_BOOLEAN, 8,
1101 TFS(&tfs_os_wfw), 1<<OS_WFW, "Is this a WfW host?", HFILL }},
1103 { &hf_election_os_ntw,
1104 { "NT Workstation", "browser.election.os.ntw", FT_BOOLEAN, 8,
1105 TFS(&tfs_os_ntw), 1<<OS_NTW, "Is this a NT Workstation?", HFILL }},
1107 { &hf_election_os_nts,
1108 { "NT Server", "browser.election.os.nts", FT_BOOLEAN, 8,
1109 TFS(&tfs_os_nts), 1<<OS_NTS, "Is this a NT Server?", HFILL }},
1111 { &hf_server_uptime,
1112 { "Uptime", "browser.uptime", FT_UINT32, BASE_DEC,
1113 NULL, 0, "Server uptime in ms", HFILL }},
1116 { "Backup List Requested Count", "browser.backup.count", FT_UINT8, BASE_DEC,
1117 NULL, 0, "Backup list requested count", HFILL }},
1120 { "Backup Request Token", "browser.backup.token", FT_UINT32, BASE_DEC,
1121 NULL, 0, "Backup requested/response token", HFILL }},
1123 { &hf_backup_server,
1124 { "Backup Server", "browser.backup.server", FT_STRING, BASE_NONE,
1125 NULL, 0, "Backup Server Name", HFILL }},
1127 { &hf_browser_to_promote,
1128 { "Browser to Promote", "browser.browser_to_promote", FT_STRINGZ, BASE_NONE,
1129 NULL, 0, "Browser to Promote", HFILL }},
1133 static gint *ett[] = {
1136 &ett_browse_election_criteria,
1137 &ett_browse_election_os,
1138 &ett_browse_election_desire,
1139 &ett_browse_reset_cmd_flags,
1142 proto_smb_browse = proto_register_protocol("Microsoft Windows Browser Protocol",
1143 "BROWSER", "browser");
1145 proto_register_field_array(proto_smb_browse, hf, array_length(hf));
1146 proto_register_subtree_array(ett, array_length(ett));
1148 register_dissector("mailslot_browse", dissect_mailslot_browse,
1150 register_dissector("mailslot_lanman", dissect_mailslot_lanman,