Document the new Copy Profile button.
[obnox/wireshark/wip.git] / epan / dissectors / packet-smb-browse.c
1 /* packet-smb-browse.c
2  * Routines for SMB Browser packet dissection
3  * Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
4  *
5  * $Id$
6  *
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
9  * Copyright 1998 Gerald Combs
10  *
11  * Copied from packet-pop.c
12  *
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.
17  *
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.
22  *
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.
26  */
27
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
31
32 #include <stdio.h>
33
34 #include <time.h>
35 #include <string.h>
36 #include <glib.h>
37 #include <ctype.h>
38 #include <epan/packet.h>
39 #include <epan/dissectors/packet-smb.h>
40
41 #include "packet-smb-browse.h"
42 #include "packet-dcerpc.h"
43
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;
107
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;
114
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
140
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"},
161         {SERVER_OSF,                    "OSF"},
162         {SERVER_VMS,                    "VMS"},
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"},
167         {0,     NULL}
168 };
169
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"},
174   { 0, NULL}
175 };
176
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"
180 };
181
182 static true_false_string tfs_flush_browse_list = {
183         "Flush the Browse List",
184         "Do not Flush the Browse List"
185 };
186
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"
190 };
191
192 static const true_false_string tfs_workstation = {
193         "This is a Workstation",
194         "This is NOT a Workstation"
195 };
196 static const true_false_string tfs_server = {
197         "This is a Server",
198         "This is NOT a Server"
199 };
200 static const true_false_string tfs_sql = {
201         "This is an SQL server",
202         "This is NOT an SQL server"
203 };
204 static const true_false_string tfs_domain = {
205         "This is a Domain Controller",
206         "This is NOT a Domain Controller"
207 };
208 static const true_false_string tfs_backup = {
209         "This is a Backup Controller",
210         "This is NOT a Backup Controller"
211 };
212 static const true_false_string tfs_time = {
213         "This is a Time Source",
214         "This is NOT a Time Source"
215 };
216 static const true_false_string tfs_apple = {
217         "This is an Apple host",
218         "This is NOT an Apple host"
219 };
220 static const true_false_string tfs_novell = {
221         "This is a Novell server",
222         "This is NOT a Novell server"
223 };
224 static const true_false_string tfs_member = {
225         "This is a Domain Member server",
226         "This is NOT a Domain Member server"
227 };
228 static const true_false_string tfs_print = {
229         "This is a Print Queue server",
230         "This is NOT a Print Queue server"
231 };
232 static const true_false_string tfs_dialin = {
233         "This is a Dialin server",
234         "This is NOT a Dialin server"
235 };
236 static const true_false_string tfs_xenix = {
237         "This is a Xenix server",
238         "This is NOT a Xenix server"
239 };
240 static const true_false_string tfs_ntw = {
241         "This is an NT Workstation",
242         "This is NOT an NT Workstation"
243 };
244 static const true_false_string tfs_wfw = {
245         "This is a WfW host",
246         "This is NOT a WfW host"
247 };
248 static const true_false_string tfs_nts = {
249         "This is an NT Server",
250         "This is NOT an NT Server"
251 };
252 static const true_false_string tfs_potentialb = {
253         "This is a Potential Browser",
254         "This is NOT a Potential Browser"
255 };
256 static const true_false_string tfs_backupb = {
257         "This is a Backup Browser",
258         "This is NOT a Backup Browser"
259 };
260 static const true_false_string tfs_masterb = {
261         "This is a Master Browser",
262         "This is NOT a Master Browser"
263 };
264 static const true_false_string tfs_domainmasterb = {
265         "This is a Domain Master Browser",
266         "This is NOT a Domain Master Browser"
267 };
268 static const true_false_string tfs_osf = {
269         "This is an OSF host",
270         "This is NOT an OSF host"
271 };
272 static const true_false_string tfs_vms = {
273         "This is a VMS host",
274         "This is NOT a VMS host"
275 };
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"
279 };
280 static const true_false_string tfs_dfs = {
281         "This is a DFS server",
282         "THis is NOT a DFS server"
283 };
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"
287 };
288 static const true_false_string tfs_domainenum = {
289         "This is a Domain Enum request",
290         "This is NOT a Domain Enum request"
291 };
292
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
298 #define DESIRE_NT                       7
299
300 static const true_false_string tfs_desire_backup = {
301         "Backup Browse Server",
302         "NOT Backup Browse Server"
303 };
304 static const true_false_string tfs_desire_standby = {
305         "Standby Browse Server",
306         "NOT Standby Browse Server"
307 };
308 static const true_false_string tfs_desire_master = {
309         "Master Browser",
310         "NOT Master Browser"
311 };
312 static const true_false_string tfs_desire_domain_master = {
313         "Domain Master Browse Server",
314         "NOT Domain Master Browse Server"
315 };
316 static const true_false_string tfs_desire_wins = {
317         "WINS Client",
318         "NOT WINS Client"
319 };
320 static const true_false_string tfs_desire_nt = {
321         "Windows NT Advanced Server",
322         "NOT Windows NT Advanced Server"
323 };
324
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
335
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"},
347         {0,                             NULL}
348 };
349
350 #define OS_WFW                          0
351 #define OS_NTW                          4
352 #define OS_NTS                          5
353
354 static const true_false_string tfs_os_wfw = {
355         "Windows for Workgroups",
356         "Not Windows for Workgroups"
357 };
358 static const true_false_string tfs_os_ntw = {
359         "Windows NT Workstation",
360         "Not Windows NT Workstation"
361 };
362 static const true_false_string tfs_os_nts = {
363         "Windows NT Server",
364         "Not Windows NT Server"
365 };
366
367 static void
368 dissect_election_criterion_os(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
369 {
370         proto_tree *tree = NULL;
371         proto_item *item = NULL;
372         guint8 os;
373
374         os = tvb_get_guint8(tvb, offset);
375
376         if (parent_tree) {
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);
379         }
380
381         proto_tree_add_boolean(tree, hf_election_os_wfw,
382                 tvb, offset, 1, os);
383         proto_tree_add_boolean(tree, hf_election_os_ntw,
384                 tvb, offset, 1, os);
385         proto_tree_add_boolean(tree, hf_election_os_nts,
386                 tvb, offset, 1, os);
387
388 }
389
390 static void
391 dissect_election_criterion_desire(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
392 {
393         proto_tree *tree = NULL;
394         proto_item *item = NULL;
395         guint8 desire;
396
397         desire = tvb_get_guint8(tvb, offset);
398
399         if (parent_tree) {
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);
402         }
403
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);
416
417 }
418
419 static void
420 dissect_election_criterion(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
421 {
422         proto_tree *tree = NULL;
423         proto_item *item = NULL;
424         guint32 criterion;
425
426         criterion = tvb_get_letohl(tvb, offset);
427
428         if (parent_tree) {
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);
431         }
432
433         /* election desire */
434         dissect_election_criterion_desire(tvb, tree, offset);
435         offset += 1;
436
437         /* browser protocol major version */
438         proto_tree_add_item(tree, hf_proto_major, tvb, offset, 1, TRUE);
439         offset += 1;
440
441         /* browser protocol minor version */
442         proto_tree_add_item(tree, hf_proto_minor, tvb, offset, 1, TRUE);
443         offset += 1;
444
445         /* election os */
446         dissect_election_criterion_os(tvb, tree, offset);
447         offset += 1;
448
449 }
450
451 /*
452  * XXX - this causes non-browser packets to have browser fields.
453  */
454 int
455 dissect_smb_server_type_flags(tvbuff_t *tvb, int offset, packet_info *pinfo,
456                               proto_tree *parent_tree, guint8 *drep, 
457                               gboolean infoflag)
458 {
459         proto_tree *tree = NULL;
460         proto_item *item = NULL;
461         guint32 flags;
462         int i;
463
464         if (drep != NULL) {
465                 /*
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).
473                  */
474                 offset = dissect_ndr_uint32(
475                         tvb, offset, pinfo, NULL, drep, hf_server_type, &flags);
476         } else {
477                 /*
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()".
482                  */
483                 flags = tvb_get_letohl(tvb, offset);
484                 offset += 4;
485         }
486
487         if (parent_tree) {
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);
490         }
491
492         if (infoflag) {
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"));
500                                 }
501                         }
502                 }
503         }
504
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);
555
556         return offset;
557 }
558
559
560 static void
561 dissect_mailslot_browse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
562 {
563         int offset = 0;
564         guint8 cmd;
565         proto_tree *tree = NULL;
566         proto_item *item = NULL;
567         guint32 periodicity;
568         guint8 host_name[17];
569         gint namelen;
570         guint8 server_count, reset_cmd;
571         int i;
572         guint32 uptime;
573
574         col_set_str(pinfo->cinfo, COL_PROTOCOL, "BROWSER");
575         col_clear(pinfo->cinfo, COL_INFO);
576
577         cmd = tvb_get_guint8(tvb, offset);
578
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"));
582         }
583
584
585         if (parent_tree) {
586                 item = proto_tree_add_item(parent_tree, proto_smb_browse, tvb, offset, -1, TRUE);
587
588                 tree = proto_item_add_subtree(item, ett_browse);
589         }
590
591         /* command */
592         proto_tree_add_uint(tree, hf_command, tvb, offset, 1, cmd);
593         offset += 1;
594
595         switch (cmd) {
596         case BROWSE_DOMAIN_ANNOUNCEMENT:
597         case BROWSE_LOCAL_MASTER_ANNOUNCEMENT:
598         case BROWSE_HOST_ANNOUNCE: {
599                 /* update count */
600                 proto_tree_add_item(tree, hf_update_count, tvb, offset, 1, TRUE);
601                 offset += 1;
602
603                 /* periodicity (in milliseconds) */
604                 periodicity = tvb_get_letohl(tvb, offset);
605                 proto_tree_add_uint_format(tree, hf_periodicity, tvb, offset, 4,
606                     periodicity,
607                     "Update Periodicity: %s",
608                     time_msecs_to_str(periodicity));
609                 offset += 4;
610
611                 /* server name */
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);
615                 }
616                 proto_tree_add_string_format(tree, hf_server_name,
617                         tvb, offset, 16,
618                         host_name,
619                         (cmd==BROWSE_DOMAIN_ANNOUNCEMENT)?
620                                 "Domain/Workgroup: %s":
621                                 "Host Name: %s",
622                         host_name);
623                 offset += 16;
624
625                 /* OS major version */
626                 proto_tree_add_item(tree, hf_os_major, tvb, offset, 1, TRUE);
627                 offset += 1;
628
629                 /* OS minor version */
630                 proto_tree_add_item(tree, hf_os_minor, tvb, offset, 1, TRUE);
631                 offset += 1;
632
633                 /* server type flags */
634                 offset = dissect_smb_server_type_flags(
635                         tvb, offset, pinfo, tree, NULL, TRUE);
636
637                 if (cmd == BROWSE_DOMAIN_ANNOUNCEMENT) {
638                         /*
639                          * Network Monitor claims this is a "Comment
640                          * Pointer".  I don't believe it.
641                          *
642                          * It's not a browser protocol major/minor
643                          * version number, and signature constant,
644                          * however.
645                          */
646                         proto_tree_add_text(tree, tvb, offset, 4,
647                             "Mysterious Field: 0x%08x",
648                             tvb_get_letohl(tvb, offset));
649                         offset += 4;
650                 } else {
651                         /* browser protocol major version */
652                         proto_tree_add_item(tree, hf_proto_major, tvb, offset, 1, TRUE);
653                         offset += 1;
654
655                         /* browser protocol minor version */
656                         proto_tree_add_item(tree, hf_proto_minor, tvb, offset, 1, TRUE);
657                         offset += 1;
658
659                         /* signature constant */
660                         proto_tree_add_item(tree, hf_sig_const, tvb, offset, 2, TRUE);
661                         offset += 2;
662                 }
663
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);
670                 offset += namelen;
671                 break;
672         }
673         case BROWSE_REQUEST_ANNOUNCE: {
674                 guint8 *computer_name;
675
676                 /* unused/unknown flags */
677                 proto_tree_add_item(tree, hf_unused_flags,
678                         tvb, offset, 1, TRUE);
679                 offset += 1;
680
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))
686                         col_append_fstr(
687                                 pinfo->cinfo, COL_INFO, " %s", computer_name);
688                 offset += namelen;
689                 break;
690         }
691
692         case BROWSE_ELECTION_REQUEST:
693                 /* election version */
694                 proto_tree_add_item(tree, hf_election_version, tvb, offset, 1, TRUE);
695                 offset += 1;
696
697                 /* criterion */
698                 dissect_election_criterion(tvb, tree, offset);
699                 offset += 4;
700
701                 /* server uptime */
702                 uptime = tvb_get_letohl(tvb, offset);
703                 proto_tree_add_uint_format(tree, hf_server_uptime,
704                     tvb, offset, 4, uptime,
705                     "Uptime: %s",
706                     time_msecs_to_str(uptime));
707                 offset += 4;
708
709                 /* next 4 bytes must be zero */
710                 offset += 4;
711
712                 /* server name */
713                 namelen = tvb_strsize(tvb, offset);
714                 proto_tree_add_item(tree, hf_server_name,
715                         tvb, offset, namelen, TRUE);
716                 offset += namelen;
717                 break;
718
719         case BROWSE_BACKUP_LIST_REQUEST:
720                 /* backup list requested count */
721                 proto_tree_add_item(tree, hf_backup_count, tvb, offset, 1, TRUE);
722                 offset += 1;
723
724                 /* backup requested token */
725                 proto_tree_add_item(tree, hf_backup_token, tvb, offset, 4, TRUE);
726                 offset += 4;
727                 break;
728
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,
733                     server_count);
734                 offset += 1;
735
736                 /* backup requested token */
737                 proto_tree_add_item(tree, hf_backup_token, tvb, offset, 4, TRUE);
738                 offset += 4;
739
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);
745                         offset += namelen;
746                 }
747                 break;
748
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);
754                 offset += namelen;
755                 break;
756
757         case BROWSE_RESETBROWSERSTATE_ANNOUNCEMENT: {
758                 proto_tree *sub_tree;
759                 proto_item *reset_item;
760
761                 /* the subcommand follows ... one of three values */
762
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);
773                 offset += 1;
774                 break;
775         }
776
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);
782                 offset += namelen;
783                 break;
784         }
785 }
786
787 /*
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?
791  *
792  * The document at
793  *
794  *      http://www.samba.org/samba/ftp/specs/brow_rev.txt
795  *
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.
801  *
802  * XXX - what other browser packets go out to that mailslot?
803  */
804 static void
805 dissect_mailslot_lanman(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
806 {
807         int offset = 0;
808         guint8 cmd;
809         proto_tree *tree = NULL;
810         proto_item *item = NULL;
811         guint32 periodicity;
812         const guint8 *host_name;
813         guint namelen;
814
815         col_set_str(pinfo->cinfo, COL_PROTOCOL, "BROWSER");
816         col_clear(pinfo->cinfo, COL_INFO);
817
818         cmd = tvb_get_guint8(tvb, offset);
819
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"));
823         }
824
825
826         if (parent_tree) {
827                 item = proto_tree_add_item(parent_tree, proto_smb_browse, tvb, offset, -1, TRUE);
828
829                 tree = proto_item_add_subtree(item, ett_browse);
830         }
831
832         /* command */
833         proto_tree_add_uint(tree, hf_command, tvb, offset, 1, cmd);
834         offset += 1;
835
836         switch (cmd) {
837         case BROWSE_DOMAIN_ANNOUNCEMENT:
838         case BROWSE_LOCAL_MASTER_ANNOUNCEMENT:
839         case BROWSE_HOST_ANNOUNCE:
840
841                 /* update count */
842                 proto_tree_add_item(tree, hf_update_count, tvb, offset, 1, TRUE);
843                 offset += 1;
844
845                 /* server type flags */
846                 offset = dissect_smb_server_type_flags(
847                         tvb, offset, pinfo, tree, NULL, TRUE);
848
849                 /* OS major version */
850                 proto_tree_add_item(tree, hf_os_major, tvb, offset, 1, TRUE);
851                 offset += 1;
852
853                 /* OS minor version */
854                 proto_tree_add_item(tree, hf_os_minor, tvb, offset, 1, TRUE);
855                 offset += 1;
856
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,
860                     periodicity,
861                     "Update Periodicity: %s",
862                     time_msecs_to_str(periodicity));
863                 offset += 2;
864
865                 /* server name */
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);
870                 }
871                 proto_tree_add_item(tree, hf_server_name,
872                         tvb, offset, namelen, TRUE);
873                 offset += namelen;
874
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);
881                 offset += namelen;
882                 break;
883         }
884 }
885
886 void
887 proto_register_smb_browse(void)
888 {
889         static hf_register_info hf[] = {
890                 { &hf_command,
891                         { "Command", "browser.command", FT_UINT8, BASE_HEX,
892                         VALS(commands), 0, "Browse command opcode", HFILL }},
893
894                 { &hf_update_count,
895                         { "Update Count", "browser.update_count", FT_UINT8, BASE_DEC,
896                         NULL, 0, "Browse Update Count", HFILL }},
897
898                 { &hf_periodicity,
899                         { "Update Periodicity", "browser.period", FT_UINT32, BASE_DEC,
900                         NULL, 0, "Update Periodicity in ms", HFILL }},
901
902                 { &hf_server_name,
903                         { "Server Name", "browser.server", FT_STRING, BASE_NONE,
904                         NULL, 0, "BROWSE Server Name", HFILL }},
905
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 }},
909
910                 { &hf_mb_reset_command,
911                   { "ResetBrowserState Command", "browser.reset_cmd", FT_UINT8,
912                     BASE_HEX, VALS(resetbrowserstate_command_names), 0,
913                     NULL, HFILL }},
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}},
920                 { &hf_mb_reset_stop,
921                   { "Stop Being LMB", "browser.reset_cmd.stop_lmb", FT_BOOLEAN,
922                     8, TFS(&tfs_stop_being_lmb), 0x04, NULL, HFILL}},
923                 { &hf_os_major,
924                         { "OS Major Version", "browser.os_major", FT_UINT8, BASE_DEC,
925                         NULL, 0, "Operating System Major Version", HFILL }},
926
927                 { &hf_os_minor,
928                         { "OS Minor Version", "browser.os_minor", FT_UINT8, BASE_DEC,
929                         NULL, 0, "Operating System Minor Version", HFILL }},
930
931                 { &hf_server_type,
932                         { "Server Type", "browser.server_type", FT_UINT32, BASE_HEX,
933                         NULL, 0, "Server Type Flags", HFILL }},
934
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 }},
938
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 }},
942
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 }},
946
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 }},
950
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 }},
954
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 }},
958
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 }},
962
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 }},
966
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 }},
970
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 }},
974
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 }},
978
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 }},
982
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 }},
986
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 }},
990
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 }},
994
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 }},
998
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 }},
1002
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 }},
1006
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 }},
1010
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 }},
1014
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 }},
1018
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 }},
1022
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 }},
1026
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 }},
1030
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 }},
1034
1035                 { &hf_election_version,
1036                         { "Election Version", "browser.election.version", FT_UINT8, BASE_DEC,
1037                         NULL, 0, NULL, HFILL }},
1038
1039                 { &hf_proto_major,
1040                         { "Browser Protocol Major Version", "browser.proto_major", FT_UINT8, BASE_DEC,
1041                         NULL, 0, NULL, HFILL }},
1042
1043                 { &hf_proto_minor,
1044                         { "Browser Protocol Minor Version", "browser.proto_minor", FT_UINT8, BASE_DEC,
1045                         NULL, 0, NULL, HFILL }},
1046
1047                 { &hf_sig_const,
1048                         { "Signature", "browser.sig", FT_UINT16, BASE_HEX,
1049                         NULL, 0, "Signature Constant", HFILL }},
1050
1051                 { &hf_server_comment,
1052                         { "Host Comment", "browser.comment", FT_STRINGZ, BASE_NONE,
1053                         NULL, 0, "Server Comment", HFILL }},
1054
1055                 { &hf_unused_flags,
1056                         { "Unused flags", "browser.unused", FT_UINT8, BASE_HEX,
1057                         NULL, 0, "Unused/unknown flags", HFILL }},
1058
1059                 { &hf_response_computer_name,
1060                         { "Response Computer Name", "browser.response_computer_name", FT_STRINGZ, BASE_NONE,
1061                         NULL, 0, NULL, HFILL }},
1062
1063                 { &hf_election_criteria,
1064                         { "Election Criteria", "browser.election.criteria", FT_UINT32, BASE_HEX,
1065                         NULL, 0, NULL, HFILL }},
1066
1067                 { &hf_election_desire,
1068                         { "Election Desire", "browser.election.desire", FT_UINT8, BASE_HEX,
1069                         NULL, 0, NULL, HFILL }},
1070
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 }},
1074
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 }},
1078
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 }},
1082
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 }},
1086
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 }},
1090
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 }},
1094
1095                 { &hf_election_revision,
1096                         { "Election Revision", "browser.election.revision", FT_UINT16, BASE_DEC,
1097                         NULL, 0, NULL, HFILL }},
1098
1099                 { &hf_election_os,
1100                         { "Election OS", "browser.election.os", FT_UINT8, BASE_HEX,
1101                         NULL, 0, NULL, HFILL }},
1102
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 }},
1106
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 }},
1110
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 }},
1114
1115                 { &hf_server_uptime,
1116                         { "Uptime", "browser.uptime", FT_UINT32, BASE_DEC,
1117                         NULL, 0, "Server uptime in ms", HFILL }},
1118
1119                 { &hf_backup_count,
1120                         { "Backup List Requested Count", "browser.backup.count", FT_UINT8, BASE_DEC,
1121                         NULL, 0, "Backup list requested count", HFILL }},
1122
1123                 { &hf_backup_token,
1124                         { "Backup Request Token", "browser.backup.token", FT_UINT32, BASE_DEC,
1125                         NULL, 0, "Backup requested/response token", HFILL }},
1126
1127                 { &hf_backup_server,
1128                         { "Backup Server", "browser.backup.server", FT_STRING, BASE_NONE,
1129                         NULL, 0, "Backup Server Name", HFILL }},
1130
1131                 { &hf_browser_to_promote,
1132                         { "Browser to Promote", "browser.browser_to_promote", FT_STRINGZ, BASE_NONE,
1133                         NULL, 0, NULL, HFILL }},
1134
1135         };
1136
1137         static gint *ett[] = {
1138                 &ett_browse,
1139                 &ett_browse_flags,
1140                 &ett_browse_election_criteria,
1141                 &ett_browse_election_os,
1142                 &ett_browse_election_desire,
1143                 &ett_browse_reset_cmd_flags,
1144         };
1145
1146         proto_smb_browse = proto_register_protocol("Microsoft Windows Browser Protocol",
1147             "BROWSER", "browser");
1148
1149         proto_register_field_array(proto_smb_browse, hf, array_length(hf));
1150         proto_register_subtree_array(ett, array_length(ett));
1151
1152         register_dissector("mailslot_browse", dissect_mailslot_browse,
1153             proto_smb_browse);
1154         register_dissector("mailslot_lanman", dissect_mailslot_lanman,
1155             proto_smb_browse);
1156 }