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/dissectors/packet-smb.h>
41 #include "packet-smb-browse.h"
42 #include "packet-dcerpc.h"
44 static int proto_smb_browse = -1;
45 static int hf_command = -1;
46 static int hf_update_count = -1;
47 static int hf_periodicity = -1;
48 static int hf_server_name = -1;
49 static int hf_mb_server_name = -1;
50 static int hf_mb_reset_command = -1;
51 static int hf_mb_reset_demote = -1;
52 static int hf_mb_reset_flush = -1;
53 static int hf_mb_reset_stop = -1;
54 static int hf_os_major = -1;
55 static int hf_os_minor = -1;
56 static int hf_server_type = -1;
57 static int hf_server_type_workstation = -1;
58 static int hf_server_type_server = -1;
59 static int hf_server_type_sql = -1;
60 static int hf_server_type_domain = -1;
61 static int hf_server_type_backup = -1;
62 static int hf_server_type_time = -1;
63 static int hf_server_type_apple = -1;
64 static int hf_server_type_novell = -1;
65 static int hf_server_type_member = -1;
66 static int hf_server_type_print = -1;
67 static int hf_server_type_dialin = -1;
68 static int hf_server_type_xenix = -1;
69 static int hf_server_type_ntw = -1;
70 static int hf_server_type_wfw = -1;
71 static int hf_server_type_nts = -1;
72 static int hf_server_type_potentialb = -1;
73 static int hf_server_type_backupb = -1;
74 static int hf_server_type_masterb = -1;
75 static int hf_server_type_domainmasterb = -1;
76 static int hf_server_type_osf = -1;
77 static int hf_server_type_vms = -1;
78 static int hf_server_type_w95 = -1;
79 static int hf_server_type_dfs = -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_DFS_SERVER 23
138 #define SERVER_LOCAL_LIST_ONLY 30
139 #define SERVER_DOMAIN_ENUM 31
141 static const value_string server_types[] = {
142 {SERVER_WORKSTATION, "Workstation"},
143 {SERVER_SERVER, "Server"},
144 {SERVER_SQL_SERVER, "SQL Server"},
145 {SERVER_DOMAIN_CONTROLLER, "Domain Controller"},
146 {SERVER_BACKUP_CONTROLLER, "Backup Controller"},
147 {SERVER_TIME_SOURCE, "Time Source"},
148 {SERVER_APPLE_SERVER, "Apple Server"},
149 {SERVER_NOVELL_SERVER, "Novell Server"},
150 {SERVER_DOMAIN_MEMBER_SERVER, "Domain Member Server"},
151 {SERVER_PRINT_QUEUE_SERVER, "Print Queue Server"},
152 {SERVER_DIALIN_SERVER, "Dialin Server"},
153 {SERVER_XENIX_SERVER, "Xenix Server"},
154 {SERVER_NT_WORKSTATION, "NT Workstation"},
155 {SERVER_WINDOWS_FOR_WORKGROUPS, "Windows for Workgroups"},
156 {SERVER_NT_SERVER, "NT Server"},
157 {SERVER_POTENTIAL_BROWSER, "Potential Browser"},
158 {SERVER_BACKUP_BROWSER, "Backup Browser"},
159 {SERVER_MASTER_BROWSER, "Master Browser"},
160 {SERVER_DOMAIN_MASTER_BROWSER, "Domain Master Browser"},
163 {SERVER_WINDOWS_95, "Windows 95 or above"},
164 {SERVER_DFS_SERVER, "DFS server"},
165 {SERVER_LOCAL_LIST_ONLY, "Local List Only"},
166 {SERVER_DOMAIN_ENUM, "Domain Enum"},
170 static const value_string resetbrowserstate_command_names[] = {
171 { 0x01, "Stop being a master browser and become a backup browser"},
172 { 0x02, "Discard browse lists, stop being a master browser, and try again"},
173 { 0x04, "Stop being a master browser for ever"},
177 static true_false_string tfs_demote_to_backup = {
178 "Demote an LMB to a Backup Browser",
179 "Do not demote an LMB to a Backup Browser"
182 static true_false_string tfs_flush_browse_list = {
183 "Flush the Browse List",
184 "Do not Flush the Browse List"
187 static true_false_string tfs_stop_being_lmb = {
188 "Stop Being a Local Master Browser",
189 "Do not Stop Being a Local Master Browser"
192 static const true_false_string tfs_workstation = {
193 "This is a Workstation",
194 "This is NOT a Workstation"
196 static const true_false_string tfs_server = {
198 "This is NOT a Server"
200 static const true_false_string tfs_sql = {
201 "This is an SQL server",
202 "This is NOT an SQL server"
204 static const true_false_string tfs_domain = {
205 "This is a Domain Controller",
206 "This is NOT a Domain Controller"
208 static const true_false_string tfs_backup = {
209 "This is a Backup Controller",
210 "This is NOT a Backup Controller"
212 static const true_false_string tfs_time = {
213 "This is a Time Source",
214 "This is NOT a Time Source"
216 static const true_false_string tfs_apple = {
217 "This is an Apple host",
218 "This is NOT an Apple host"
220 static const true_false_string tfs_novell = {
221 "This is a Novell server",
222 "This is NOT a Novell server"
224 static const true_false_string tfs_member = {
225 "This is a Domain Member server",
226 "This is NOT a Domain Member server"
228 static const true_false_string tfs_print = {
229 "This is a Print Queue server",
230 "This is NOT a Print Queue server"
232 static const true_false_string tfs_dialin = {
233 "This is a Dialin server",
234 "This is NOT a Dialin server"
236 static const true_false_string tfs_xenix = {
237 "This is a Xenix server",
238 "This is NOT a Xenix server"
240 static const true_false_string tfs_ntw = {
241 "This is an NT Workstation",
242 "This is NOT an NT Workstation"
244 static const true_false_string tfs_wfw = {
245 "This is a WfW host",
246 "This is NOT a WfW host"
248 static const true_false_string tfs_nts = {
249 "This is an NT Server",
250 "This is NOT an NT Server"
252 static const true_false_string tfs_potentialb = {
253 "This is a Potential Browser",
254 "This is NOT a Potential Browser"
256 static const true_false_string tfs_backupb = {
257 "This is a Backup Browser",
258 "This is NOT a Backup Browser"
260 static const true_false_string tfs_masterb = {
261 "This is a Master Browser",
262 "This is NOT a Master Browser"
264 static const true_false_string tfs_domainmasterb = {
265 "This is a Domain Master Browser",
266 "This is NOT a Domain Master Browser"
268 static const true_false_string tfs_osf = {
269 "This is an OSF host",
270 "This is NOT an OSF host"
272 static const true_false_string tfs_vms = {
273 "This is a VMS host",
274 "This is NOT a VMS host"
276 static const true_false_string tfs_w95 = {
277 "This is a Windows 95 or above host",
278 "This is NOT a Windows 95 or above host"
280 static const true_false_string tfs_dfs = {
281 "This is a DFS server",
282 "THis is NOT a DFS server"
284 static const true_false_string tfs_local = {
285 "This is a local list only request",
286 "This is NOT a local list only request"
288 static const true_false_string tfs_domainenum = {
289 "This is a Domain Enum request",
290 "This is NOT a Domain Enum request"
293 #define DESIRE_BACKUP 0
294 #define DESIRE_STANDBY 1
295 #define DESIRE_MASTER 2
296 #define DESIRE_DOMAIN_MASTER 3
297 #define DESIRE_WINS 5
300 static const true_false_string tfs_desire_backup = {
301 "Backup Browse Server",
302 "NOT Backup Browse Server"
304 static const true_false_string tfs_desire_standby = {
305 "Standby Browse Server",
306 "NOT Standby Browse Server"
308 static const true_false_string tfs_desire_master = {
312 static const true_false_string tfs_desire_domain_master = {
313 "Domain Master Browse Server",
314 "NOT Domain Master Browse Server"
316 static const true_false_string tfs_desire_wins = {
320 static const true_false_string tfs_desire_nt = {
321 "Windows NT Advanced Server",
322 "NOT Windows NT Advanced Server"
325 #define BROWSE_HOST_ANNOUNCE 1
326 #define BROWSE_REQUEST_ANNOUNCE 2
327 #define BROWSE_ELECTION_REQUEST 8
328 #define BROWSE_BACKUP_LIST_REQUEST 9
329 #define BROWSE_BACKUP_LIST_RESPONSE 10
330 #define BROWSE_BECOME_BACKUP 11
331 #define BROWSE_DOMAIN_ANNOUNCEMENT 12
332 #define BROWSE_MASTER_ANNOUNCEMENT 13
333 #define BROWSE_RESETBROWSERSTATE_ANNOUNCEMENT 14
334 #define BROWSE_LOCAL_MASTER_ANNOUNCEMENT 15
336 static const value_string commands[] = {
337 {BROWSE_HOST_ANNOUNCE, "Host Announcement"},
338 {BROWSE_REQUEST_ANNOUNCE, "Request Announcement"},
339 {BROWSE_ELECTION_REQUEST, "Browser Election Request"},
340 {BROWSE_BACKUP_LIST_REQUEST, "Get Backup List Request"},
341 {BROWSE_BACKUP_LIST_RESPONSE, "Get Backup List Response"},
342 {BROWSE_BECOME_BACKUP, "Become Backup Browser"},
343 {BROWSE_DOMAIN_ANNOUNCEMENT, "Domain/Workgroup Announcement"},
344 {BROWSE_MASTER_ANNOUNCEMENT, "Master Announcement"},
345 {BROWSE_RESETBROWSERSTATE_ANNOUNCEMENT, "Reset Browser State Announcement"},
346 {BROWSE_LOCAL_MASTER_ANNOUNCEMENT,"Local Master Announcement"},
354 static const true_false_string tfs_os_wfw = {
355 "Windows for Workgroups",
356 "Not Windows for Workgroups"
358 static const true_false_string tfs_os_ntw = {
359 "Windows NT Workstation",
360 "Not Windows NT Workstation"
362 static const true_false_string tfs_os_nts = {
364 "Not Windows NT Server"
368 dissect_election_criterion_os(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
370 proto_tree *tree = NULL;
371 proto_item *item = NULL;
374 os = tvb_get_guint8(tvb, offset);
377 item = proto_tree_add_uint(parent_tree, hf_election_os, tvb, offset, 1, os);
378 tree = proto_item_add_subtree(item, ett_browse_election_os);
381 proto_tree_add_boolean(tree, hf_election_os_wfw,
383 proto_tree_add_boolean(tree, hf_election_os_ntw,
385 proto_tree_add_boolean(tree, hf_election_os_nts,
391 dissect_election_criterion_desire(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
393 proto_tree *tree = NULL;
394 proto_item *item = NULL;
397 desire = tvb_get_guint8(tvb, offset);
400 item = proto_tree_add_uint(parent_tree, hf_election_desire, tvb, offset, 1, desire);
401 tree = proto_item_add_subtree(item, ett_browse_election_desire);
404 proto_tree_add_boolean(tree, hf_election_desire_flags_backup,
405 tvb, offset, 1, desire);
406 proto_tree_add_boolean(tree, hf_election_desire_flags_standby,
407 tvb, offset, 1, desire);
408 proto_tree_add_boolean(tree, hf_election_desire_flags_master,
409 tvb, offset, 1, desire);
410 proto_tree_add_boolean(tree, hf_election_desire_flags_domain_master,
411 tvb, offset, 1, desire);
412 proto_tree_add_boolean(tree, hf_election_desire_flags_wins,
413 tvb, offset, 1, desire);
414 proto_tree_add_boolean(tree, hf_election_desire_flags_nt,
415 tvb, offset, 1, desire);
420 dissect_election_criterion(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
422 proto_tree *tree = NULL;
423 proto_item *item = NULL;
426 criterion = tvb_get_letohl(tvb, offset);
429 item = proto_tree_add_uint(parent_tree, hf_election_criteria, tvb, offset, 4, criterion);
430 tree = proto_item_add_subtree(item, ett_browse_election_criteria);
433 /* election desire */
434 dissect_election_criterion_desire(tvb, tree, offset);
437 /* browser protocol major version */
438 proto_tree_add_item(tree, hf_proto_major, tvb, offset, 1, TRUE);
441 /* browser protocol minor version */
442 proto_tree_add_item(tree, hf_proto_minor, tvb, offset, 1, TRUE);
446 dissect_election_criterion_os(tvb, tree, offset);
452 * XXX - this causes non-browser packets to have browser fields.
455 dissect_smb_server_type_flags(tvbuff_t *tvb, int offset, packet_info *pinfo,
456 proto_tree *parent_tree, guint8 *drep,
459 proto_tree *tree = NULL;
460 proto_item *item = NULL;
466 * Called from a DCE RPC protocol dissector, for a
467 * protocol where a 32-bit NDR integer contains
468 * an server type mask; extract the server type mask
469 * with an NDR call (but don't put it into the
470 * protocol tree, as we can't get a pointer to the
471 * item it puts in, and thus can't put a tree below
472 * it with the values of the individual bits).
474 offset = dissect_ndr_uint32(
475 tvb, offset, pinfo, NULL, drep, hf_server_type, &flags);
478 * Called from SMB browser or RAP, where the server type
479 * mask is just a 4-byte little-endian quantity with no
480 * special NDR alignment requirement; extract it with
481 * "tvb_get_letohl()".
483 flags = tvb_get_letohl(tvb, offset);
488 item = proto_tree_add_uint(parent_tree, hf_server_type, tvb, offset-4, 4, flags);
489 tree = proto_item_add_subtree(item, ett_browse_flags);
493 /* Append the type(s) of the system to the COL_INFO line ... */
494 if (check_col(pinfo->cinfo, COL_INFO)) {
495 for (i = 0; i < 32; i++) {
496 if (flags & (1<<i)) {
497 col_append_fstr(pinfo->cinfo, COL_INFO, ", %s",
498 val_to_str(i, server_types,
499 "Unknown server type:%d"));
505 proto_tree_add_boolean(tree, hf_server_type_workstation,
506 tvb, offset-4, 4, flags);
507 proto_tree_add_boolean(tree, hf_server_type_server,
508 tvb, offset-4, 4, flags);
509 proto_tree_add_boolean(tree, hf_server_type_sql,
510 tvb, offset-4, 4, flags);
511 proto_tree_add_boolean(tree, hf_server_type_domain,
512 tvb, offset-4, 4, flags);
513 proto_tree_add_boolean(tree, hf_server_type_backup,
514 tvb, offset-4, 4, flags);
515 proto_tree_add_boolean(tree, hf_server_type_time,
516 tvb, offset-4, 4, flags);
517 proto_tree_add_boolean(tree, hf_server_type_apple,
518 tvb, offset-4, 4, flags);
519 proto_tree_add_boolean(tree, hf_server_type_novell,
520 tvb, offset-4, 4, flags);
521 proto_tree_add_boolean(tree, hf_server_type_member,
522 tvb, offset-4, 4, flags);
523 proto_tree_add_boolean(tree, hf_server_type_print,
524 tvb, offset-4, 4, flags);
525 proto_tree_add_boolean(tree, hf_server_type_dialin,
526 tvb, offset-4, 4, flags);
527 proto_tree_add_boolean(tree, hf_server_type_xenix,
528 tvb, offset-4, 4, flags);
529 proto_tree_add_boolean(tree, hf_server_type_ntw,
530 tvb, offset-4, 4, flags);
531 proto_tree_add_boolean(tree, hf_server_type_wfw,
532 tvb, offset-4, 4, flags);
533 proto_tree_add_boolean(tree, hf_server_type_nts,
534 tvb, offset-4, 4, flags);
535 proto_tree_add_boolean(tree, hf_server_type_potentialb,
536 tvb, offset-4, 4, flags);
537 proto_tree_add_boolean(tree, hf_server_type_backupb,
538 tvb, offset-4, 4, flags);
539 proto_tree_add_boolean(tree, hf_server_type_masterb,
540 tvb, offset-4, 4, flags);
541 proto_tree_add_boolean(tree, hf_server_type_domainmasterb,
542 tvb, offset-4, 4, flags);
543 proto_tree_add_boolean(tree, hf_server_type_osf,
544 tvb, offset-4, 4, flags);
545 proto_tree_add_boolean(tree, hf_server_type_vms,
546 tvb, offset-4, 4, flags);
547 proto_tree_add_boolean(tree, hf_server_type_w95,
548 tvb, offset-4, 4, flags);
549 proto_tree_add_boolean(tree, hf_server_type_dfs,
550 tvb, offset-4, 4, flags);
551 proto_tree_add_boolean(tree, hf_server_type_local,
552 tvb, offset-4, 4, flags);
553 proto_tree_add_boolean(tree, hf_server_type_domainenum,
554 tvb, offset-4, 4, flags);
561 dissect_mailslot_browse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
565 proto_tree *tree = NULL;
566 proto_item *item = NULL;
568 guint8 host_name[17];
570 guint8 server_count, reset_cmd;
574 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BROWSER");
575 col_clear(pinfo->cinfo, COL_INFO);
577 cmd = tvb_get_guint8(tvb, offset);
579 if (check_col(pinfo->cinfo, COL_INFO)) {
580 /* Put in something, and replace it later */
581 col_add_str(pinfo->cinfo, COL_INFO, val_to_str(cmd, commands, "Unknown command:0x%02x"));
586 item = proto_tree_add_item(parent_tree, proto_smb_browse, tvb, offset, -1, TRUE);
588 tree = proto_item_add_subtree(item, ett_browse);
592 proto_tree_add_uint(tree, hf_command, tvb, offset, 1, cmd);
596 case BROWSE_DOMAIN_ANNOUNCEMENT:
597 case BROWSE_LOCAL_MASTER_ANNOUNCEMENT:
598 case BROWSE_HOST_ANNOUNCE: {
600 proto_tree_add_item(tree, hf_update_count, tvb, offset, 1, TRUE);
603 /* periodicity (in milliseconds) */
604 periodicity = tvb_get_letohl(tvb, offset);
605 proto_tree_add_uint_format(tree, hf_periodicity, tvb, offset, 4,
607 "Update Periodicity: %s",
608 time_msecs_to_str(periodicity));
612 tvb_get_nstringz0(tvb, offset, sizeof(host_name), host_name);
613 if (check_col(pinfo->cinfo, COL_INFO)) {
614 col_append_fstr(pinfo->cinfo, COL_INFO, " %s", host_name);
616 proto_tree_add_string_format(tree, hf_server_name,
619 (cmd==BROWSE_DOMAIN_ANNOUNCEMENT)?
620 "Domain/Workgroup: %s":
625 /* OS major version */
626 proto_tree_add_item(tree, hf_os_major, tvb, offset, 1, TRUE);
629 /* OS minor version */
630 proto_tree_add_item(tree, hf_os_minor, tvb, offset, 1, TRUE);
633 /* server type flags */
634 offset = dissect_smb_server_type_flags(
635 tvb, offset, pinfo, tree, NULL, TRUE);
637 if (cmd == BROWSE_DOMAIN_ANNOUNCEMENT) {
639 * Network Monitor claims this is a "Comment
640 * Pointer". I don't believe it.
642 * It's not a browser protocol major/minor
643 * version number, and signature constant,
646 proto_tree_add_text(tree, tvb, offset, 4,
647 "Mysterious Field: 0x%08x",
648 tvb_get_letohl(tvb, offset));
651 /* browser protocol major version */
652 proto_tree_add_item(tree, hf_proto_major, tvb, offset, 1, TRUE);
655 /* browser protocol minor version */
656 proto_tree_add_item(tree, hf_proto_minor, tvb, offset, 1, TRUE);
659 /* signature constant */
660 proto_tree_add_item(tree, hf_sig_const, tvb, offset, 2, TRUE);
664 /* master browser server name or server comment */
665 namelen = tvb_strsize(tvb, offset);
666 proto_tree_add_item(tree,
667 (cmd==BROWSE_DOMAIN_ANNOUNCEMENT)?
668 hf_mb_server_name : hf_server_comment,
669 tvb, offset, namelen, TRUE);
673 case BROWSE_REQUEST_ANNOUNCE: {
674 guint8 *computer_name;
676 /* unused/unknown flags */
677 proto_tree_add_item(tree, hf_unused_flags,
678 tvb, offset, 1, TRUE);
681 /* name of computer to which to send reply */
682 computer_name = tvb_get_ephemeral_stringz(tvb, offset, &namelen);
683 proto_tree_add_string(tree, hf_response_computer_name,
684 tvb, offset, namelen, computer_name);
685 if (check_col(pinfo->cinfo, COL_INFO))
687 pinfo->cinfo, COL_INFO, " %s", computer_name);
692 case BROWSE_ELECTION_REQUEST:
693 /* election version */
694 proto_tree_add_item(tree, hf_election_version, tvb, offset, 1, TRUE);
698 dissect_election_criterion(tvb, tree, offset);
702 uptime = tvb_get_letohl(tvb, offset);
703 proto_tree_add_uint_format(tree, hf_server_uptime,
704 tvb, offset, 4, uptime,
706 time_msecs_to_str(uptime));
709 /* next 4 bytes must be zero */
713 namelen = tvb_strsize(tvb, offset);
714 proto_tree_add_item(tree, hf_server_name,
715 tvb, offset, namelen, TRUE);
719 case BROWSE_BACKUP_LIST_REQUEST:
720 /* backup list requested count */
721 proto_tree_add_item(tree, hf_backup_count, tvb, offset, 1, TRUE);
724 /* backup requested token */
725 proto_tree_add_item(tree, hf_backup_token, tvb, offset, 4, TRUE);
729 case BROWSE_BACKUP_LIST_RESPONSE:
730 /* backup list requested count */
731 server_count = tvb_get_guint8(tvb, offset);
732 proto_tree_add_uint(tree, hf_backup_count, tvb, offset, 1,
736 /* backup requested token */
737 proto_tree_add_item(tree, hf_backup_token, tvb, offset, 4, TRUE);
740 /* backup server names */
741 for (i = 0; i < server_count; i++) {
742 namelen = tvb_strsize(tvb, offset);
743 proto_tree_add_item(tree, hf_backup_server,
744 tvb, offset, namelen, TRUE);
749 case BROWSE_MASTER_ANNOUNCEMENT:
750 /* master browser server name */
751 namelen = tvb_strsize(tvb, offset);
752 proto_tree_add_item(tree, hf_mb_server_name,
753 tvb, offset, namelen, TRUE);
757 case BROWSE_RESETBROWSERSTATE_ANNOUNCEMENT: {
758 proto_tree *sub_tree;
759 proto_item *reset_item;
761 /* the subcommand follows ... one of three values */
763 reset_cmd = tvb_get_guint8(tvb, offset);
764 reset_item = proto_tree_add_uint(tree, hf_mb_reset_command, tvb,
765 offset, 1, reset_cmd);
766 sub_tree = proto_item_add_subtree(item, ett_browse_reset_cmd_flags);
767 proto_tree_add_boolean(sub_tree, hf_mb_reset_demote, tvb,
768 offset, 1, reset_cmd);
769 proto_tree_add_boolean(sub_tree, hf_mb_reset_flush, tvb,
770 offset, 1, reset_cmd);
771 proto_tree_add_boolean(sub_tree, hf_mb_reset_stop, tvb,
772 offset, 1, reset_cmd);
777 case BROWSE_BECOME_BACKUP:
778 /* name of browser to promote */
779 namelen = tvb_strsize(tvb, offset);
780 proto_tree_add_item(tree, hf_browser_to_promote,
781 tvb, offset, namelen, TRUE);
788 * It appears that browser announcements sent to \MAILSLOT\LANMAN aren't
789 * the same as browser announcements sent to \MAILSLOT\BROWSE.
790 * Was that an older version of the protocol?
794 * http://www.samba.org/samba/ftp/specs/brow_rev.txt
796 * gives both formats of host announcement packets, saying that
797 * "[The first] format seems wrong", that one being what appears to
798 * show up in \MAILSLOT\LANMAN packets, and that "[The second one]
799 * may be better", that one being what appears to show up in
800 * \MAILSLOT\BROWSE packets.
802 * XXX - what other browser packets go out to that mailslot?
805 dissect_mailslot_lanman(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
809 proto_tree *tree = NULL;
810 proto_item *item = NULL;
812 const guint8 *host_name;
815 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BROWSER");
816 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,
914 { &hf_mb_reset_demote,
915 { "Demote LMB", "browser.reset_cmd.demote", FT_BOOLEAN,
916 8, TFS(&tfs_demote_to_backup), 0x01, NULL, HFILL}},
917 { &hf_mb_reset_flush,
918 { "Flush Browse List", "browser.reset_cmd.flush", FT_BOOLEAN,
919 8, TFS(&tfs_flush_browse_list), 0x02, NULL, HFILL}},
921 { "Stop Being LMB", "browser.reset_cmd.stop_lmb", FT_BOOLEAN,
922 8, TFS(&tfs_stop_being_lmb), 0x04, NULL, 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_dfs,
1024 { "DFS", "browser.server_type.dfs", FT_BOOLEAN, 32,
1025 TFS(&tfs_dfs), 1<<SERVER_DFS_SERVER, "Is This A DFS server?", HFILL }},
1027 { &hf_server_type_local,
1028 { "Local", "browser.server_type.local", FT_BOOLEAN, 32,
1029 TFS(&tfs_local), 1<<SERVER_LOCAL_LIST_ONLY, "Is This A Local List Only request?", HFILL }},
1031 { &hf_server_type_domainenum,
1032 { "Domain Enum", "browser.server_type.domainenum", FT_BOOLEAN, 32,
1033 TFS(&tfs_domainenum), 1<<SERVER_DOMAIN_ENUM, "Is This A Domain Enum request?", HFILL }},
1035 { &hf_election_version,
1036 { "Election Version", "browser.election.version", FT_UINT8, BASE_DEC,
1037 NULL, 0, NULL, HFILL }},
1040 { "Browser Protocol Major Version", "browser.proto_major", FT_UINT8, BASE_DEC,
1041 NULL, 0, NULL, HFILL }},
1044 { "Browser Protocol Minor Version", "browser.proto_minor", FT_UINT8, BASE_DEC,
1045 NULL, 0, NULL, HFILL }},
1048 { "Signature", "browser.sig", FT_UINT16, BASE_HEX,
1049 NULL, 0, "Signature Constant", HFILL }},
1051 { &hf_server_comment,
1052 { "Host Comment", "browser.comment", FT_STRINGZ, BASE_NONE,
1053 NULL, 0, "Server Comment", HFILL }},
1056 { "Unused flags", "browser.unused", FT_UINT8, BASE_HEX,
1057 NULL, 0, "Unused/unknown flags", HFILL }},
1059 { &hf_response_computer_name,
1060 { "Response Computer Name", "browser.response_computer_name", FT_STRINGZ, BASE_NONE,
1061 NULL, 0, NULL, HFILL }},
1063 { &hf_election_criteria,
1064 { "Election Criteria", "browser.election.criteria", FT_UINT32, BASE_HEX,
1065 NULL, 0, NULL, HFILL }},
1067 { &hf_election_desire,
1068 { "Election Desire", "browser.election.desire", FT_UINT8, BASE_HEX,
1069 NULL, 0, NULL, HFILL }},
1071 { &hf_election_desire_flags_backup,
1072 { "Backup", "browser.election.desire.backup", FT_BOOLEAN, 8,
1073 TFS(&tfs_desire_backup), 1<<DESIRE_BACKUP, "Is this a backup server", HFILL }},
1075 { &hf_election_desire_flags_standby,
1076 { "Standby", "browser.election.desire.standby", FT_BOOLEAN, 8,
1077 TFS(&tfs_desire_standby), 1<<DESIRE_STANDBY, "Is this a standby server?", HFILL }},
1079 { &hf_election_desire_flags_master,
1080 { "Master", "browser.election.desire.master", FT_BOOLEAN, 8,
1081 TFS(&tfs_desire_master), 1<<DESIRE_MASTER, "Is this a master server", HFILL }},
1083 { &hf_election_desire_flags_domain_master,
1084 { "Domain Master", "browser.election.desire.domain_master", FT_BOOLEAN, 8,
1085 TFS(&tfs_desire_domain_master), 1<<DESIRE_DOMAIN_MASTER, "Is this a domain master", HFILL }},
1087 { &hf_election_desire_flags_wins,
1088 { "WINS", "browser.election.desire.wins", FT_BOOLEAN, 8,
1089 TFS(&tfs_desire_wins), 1<<DESIRE_WINS, "Is this a WINS server", HFILL }},
1091 { &hf_election_desire_flags_nt,
1092 { "NT", "browser.election.desire.nt", FT_BOOLEAN, 8,
1093 TFS(&tfs_desire_nt), 1<<DESIRE_NT, "Is this a NT server", HFILL }},
1095 { &hf_election_revision,
1096 { "Election Revision", "browser.election.revision", FT_UINT16, BASE_DEC,
1097 NULL, 0, NULL, HFILL }},
1100 { "Election OS", "browser.election.os", FT_UINT8, BASE_HEX,
1101 NULL, 0, NULL, HFILL }},
1103 { &hf_election_os_wfw,
1104 { "WfW", "browser.election.os.wfw", FT_BOOLEAN, 8,
1105 TFS(&tfs_os_wfw), 1<<OS_WFW, "Is this a WfW host?", HFILL }},
1107 { &hf_election_os_ntw,
1108 { "NT Workstation", "browser.election.os.ntw", FT_BOOLEAN, 8,
1109 TFS(&tfs_os_ntw), 1<<OS_NTW, "Is this a NT Workstation?", HFILL }},
1111 { &hf_election_os_nts,
1112 { "NT Server", "browser.election.os.nts", FT_BOOLEAN, 8,
1113 TFS(&tfs_os_nts), 1<<OS_NTS, "Is this a NT Server?", HFILL }},
1115 { &hf_server_uptime,
1116 { "Uptime", "browser.uptime", FT_UINT32, BASE_DEC,
1117 NULL, 0, "Server uptime in ms", HFILL }},
1120 { "Backup List Requested Count", "browser.backup.count", FT_UINT8, BASE_DEC,
1121 NULL, 0, "Backup list requested count", HFILL }},
1124 { "Backup Request Token", "browser.backup.token", FT_UINT32, BASE_DEC,
1125 NULL, 0, "Backup requested/response token", HFILL }},
1127 { &hf_backup_server,
1128 { "Backup Server", "browser.backup.server", FT_STRING, BASE_NONE,
1129 NULL, 0, "Backup Server Name", HFILL }},
1131 { &hf_browser_to_promote,
1132 { "Browser to Promote", "browser.browser_to_promote", FT_STRINGZ, BASE_NONE,
1133 NULL, 0, NULL, HFILL }},
1137 static gint *ett[] = {
1140 &ett_browse_election_criteria,
1141 &ett_browse_election_os,
1142 &ett_browse_election_desire,
1143 &ett_browse_reset_cmd_flags,
1146 proto_smb_browse = proto_register_protocol("Microsoft Windows Browser Protocol",
1147 "BROWSER", "browser");
1149 proto_register_field_array(proto_smb_browse, hf, array_length(hf));
1150 proto_register_subtree_array(ett, array_length(ett));
1152 register_dissector("mailslot_browse", dissect_mailslot_browse,
1154 register_dissector("mailslot_lanman", dissect_mailslot_lanman,