From Erwin Rol: update.
[obnox/wireshark/wip.git] / 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: packet-smb-browse.c,v 1.32 2003/09/03 20:58:09 guy Exp $
6  *
7  * Ethereal - Network traffic analyzer
8  * By Gerald Combs <gerald@ethereal.com>
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 "smb.h"
40 #include "alignment.h"
41
42 #include "packet-smb-browse.h"
43 #include "packet-dcerpc.h"
44
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;
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_LOCAL_LIST_ONLY          30
138 #define SERVER_DOMAIN_ENUM              31
139
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"},
160         {SERVER_OSF,                    "OSF"},
161         {SERVER_VMS,                    "VMS"},
162         {SERVER_WINDOWS_95,             "Windows 95 or above"},
163         {SERVER_LOCAL_LIST_ONLY,        "Local List Only"},
164         {SERVER_DOMAIN_ENUM,            "Domain Enum"},
165         {0,     NULL}
166 };
167
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"},
172   { 0, NULL}
173 };
174
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"
178 };
179
180 static true_false_string tfs_flush_browse_list = {
181         "Flush the Browse List",
182         "Do not Flush the Browse List"
183 };
184
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"
188 };
189
190 static const true_false_string tfs_workstation = {
191         "This is a Workstation",
192         "This is NOT a Workstation"
193 };
194 static const true_false_string tfs_server = {
195         "This is a Server",
196         "This is NOT a Server"
197 };
198 static const true_false_string tfs_sql = {
199         "This is an SQL server",
200         "This is NOT an SQL server"
201 };
202 static const true_false_string tfs_domain = {
203         "This is a Domain Controller",
204         "This is NOT a Domain Controller"
205 };
206 static const true_false_string tfs_backup = {
207         "This is a Backup Controller",
208         "This is NOT a Backup Controller"
209 };
210 static const true_false_string tfs_time = {
211         "This is a Time Source",
212         "This is NOT a Time Source"
213 };
214 static const true_false_string tfs_apple = {
215         "This is an Apple host",
216         "This is NOT an Apple host"
217 };
218 static const true_false_string tfs_novell = {
219         "This is a Novell server",
220         "This is NOT a Novell server"
221 };
222 static const true_false_string tfs_member = {
223         "This is a Domain Member server",
224         "This is NOT a Domain Member server"
225 };
226 static const true_false_string tfs_print = {
227         "This is a Print Queue server",
228         "This is NOT a Print Queue server"
229 };
230 static const true_false_string tfs_dialin = {
231         "This is a Dialin server",
232         "This is NOT a Dialin server"
233 };
234 static const true_false_string tfs_xenix = {
235         "This is a Xenix server",
236         "This is NOT a Xenix server"
237 };
238 static const true_false_string tfs_ntw = {
239         "This is an NT Workstation",
240         "This is NOT an NT Workstation"
241 };
242 static const true_false_string tfs_wfw = {
243         "This is a WfW host",
244         "This is NOT a WfW host"
245 };
246 static const true_false_string tfs_nts = {
247         "This is an NT Server",
248         "This is NOT an NT Server"
249 };
250 static const true_false_string tfs_potentialb = {
251         "This is a Potential Browser",
252         "This is NOT a Potential Browser"
253 };
254 static const true_false_string tfs_backupb = {
255         "This is a Backup Browser",
256         "This is NOT a Backup Browser"
257 };
258 static const true_false_string tfs_masterb = {
259         "This is a Master Browser",
260         "This is NOT a Master Browser"
261 };
262 static const true_false_string tfs_domainmasterb = {
263         "This is a Domain Master Browser",
264         "This is NOT a Domain Master Browser"
265 };
266 static const true_false_string tfs_osf = {
267         "This is an OSF host",
268         "This is NOT an OSF host"
269 };
270 static const true_false_string tfs_vms = {
271         "This is a VMS host",
272         "This is NOT a VMS host"
273 };
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"
277 };
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"
281 };
282 static const true_false_string tfs_domainenum = {
283         "This is a Domain Enum request",
284         "This is NOT a Domain Enum request"
285 };
286
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
292 #define DESIRE_NT                       7
293
294 static const value_string desire_flags[] = {
295         {DESIRE_BACKUP,         "Backup Browse Server"},
296         {DESIRE_STANDBY,        "Standby Browse Server"},
297         {DESIRE_MASTER,         "Master Browser"},
298         {DESIRE_DOMAIN_MASTER,  "Domain Master Browse Server"},
299         {DESIRE_WINS,           "WINS Client"},
300         {DESIRE_NT,             "Windows NT Advanced Server"},
301         {0,                     NULL}
302 };
303
304 static const true_false_string tfs_desire_backup = {
305         "Backup Browse Server",
306         "NOT Backup Browse Server"
307  };
308 static const true_false_string tfs_desire_standby = {
309         "Standby Browse Server",
310         "NOT Standby Browse Server"
311 };
312 static const true_false_string tfs_desire_master = {
313         "Master Browser",
314         "NOT Master Browser"
315 };
316 static const true_false_string tfs_desire_domain_master = {
317         "Domain Master Browse Server",
318         "NOT Domain Master Browse Server"
319 };
320 static const true_false_string tfs_desire_wins = {
321         "WINS Client",
322         "NOT WINS Client"
323 };
324 static const true_false_string tfs_desire_nt = {
325         "Windows NT Advanced Server",
326         "NOT Windows NT Advanced Server"
327 };
328
329 #define BROWSE_HOST_ANNOUNCE                    1
330 #define BROWSE_REQUEST_ANNOUNCE                 2
331 #define BROWSE_ELECTION_REQUEST                 8
332 #define BROWSE_BACKUP_LIST_REQUEST              9
333 #define BROWSE_BACKUP_LIST_RESPONSE             10
334 #define BROWSE_BECOME_BACKUP                    11
335 #define BROWSE_DOMAIN_ANNOUNCEMENT              12
336 #define BROWSE_MASTER_ANNOUNCEMENT              13
337 #define BROWSE_RESETBROWSERSTATE_ANNOUNCEMENT   14
338 #define BROWSE_LOCAL_MASTER_ANNOUNCEMENT        15
339
340 static const value_string commands[] = {
341         {BROWSE_HOST_ANNOUNCE,          "Host Announcement"},
342         {BROWSE_REQUEST_ANNOUNCE,       "Request Announcement"},
343         {BROWSE_ELECTION_REQUEST,       "Browser Election Request"},
344         {BROWSE_BACKUP_LIST_REQUEST,    "Get Backup List Request"},
345         {BROWSE_BACKUP_LIST_RESPONSE,   "Get Backup List Response"},
346         {BROWSE_BECOME_BACKUP,          "Become Backup Browser"},
347         {BROWSE_DOMAIN_ANNOUNCEMENT,    "Domain/Workgroup Announcement"},
348         {BROWSE_MASTER_ANNOUNCEMENT,    "Master Announcement"},
349         {BROWSE_RESETBROWSERSTATE_ANNOUNCEMENT, "Reset Browser State Announcement"},
350         {BROWSE_LOCAL_MASTER_ANNOUNCEMENT,"Local Master Announcement"},
351         {0,                             NULL}
352 };
353
354 #define OS_WFW                          0
355 #define OS_NTW                          4
356 #define OS_NTS                          5
357
358 static const value_string os_flags[] = {
359         {OS_WFW,                "Windows for Workgroups"},
360         {OS_NTW,                "Windows NT Workstation"},
361         {OS_NTS,                "Windows NT Server"},
362         {0,                     NULL}
363 };
364
365 static const true_false_string tfs_os_wfw = {
366         "Windows for Workgroups",
367         "Not Windows for Workgroups"
368 };
369 static const true_false_string tfs_os_ntw = {
370         "Windows NT Workstation",
371         "Not Windows NT Workstation"
372 };
373 static const true_false_string tfs_os_nts = {
374         "Windows NT Server",
375         "Not Windows NT Server"
376 };
377
378 static void
379 dissect_election_criterion_os(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
380 {
381         proto_tree *tree = NULL;
382         proto_item *item = NULL;
383         guint8 os;
384
385         os = tvb_get_guint8(tvb, offset);
386
387         if (parent_tree) {
388                 item = proto_tree_add_uint(parent_tree, hf_election_os, tvb, offset, 1, os);
389                 tree = proto_item_add_subtree(item, ett_browse_election_os);
390         }
391
392         proto_tree_add_boolean(tree, hf_election_os_wfw,
393                 tvb, offset, 1, os);
394         proto_tree_add_boolean(tree, hf_election_os_ntw,
395                 tvb, offset, 1, os);
396         proto_tree_add_boolean(tree, hf_election_os_nts,
397                 tvb, offset, 1, os);
398
399 }
400
401 static void
402 dissect_election_criterion_desire(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
403 {
404         proto_tree *tree = NULL;
405         proto_item *item = NULL;
406         guint8 desire;
407
408         desire = tvb_get_guint8(tvb, offset);
409
410         if (parent_tree) {
411                 item = proto_tree_add_uint(parent_tree, hf_election_desire, tvb, offset, 1, desire);
412                 tree = proto_item_add_subtree(item, ett_browse_election_desire);
413         }
414
415         proto_tree_add_boolean(tree, hf_election_desire_flags_backup,
416                 tvb, offset, 1, desire);
417         proto_tree_add_boolean(tree, hf_election_desire_flags_standby,
418                 tvb, offset, 1, desire);
419         proto_tree_add_boolean(tree, hf_election_desire_flags_master,
420                 tvb, offset, 1, desire);
421         proto_tree_add_boolean(tree, hf_election_desire_flags_domain_master,
422                 tvb, offset, 1, desire);
423         proto_tree_add_boolean(tree, hf_election_desire_flags_wins,
424                 tvb, offset, 1, desire);
425         proto_tree_add_boolean(tree, hf_election_desire_flags_nt,
426                 tvb, offset, 1, desire);
427
428 }
429
430 static void
431 dissect_election_criterion(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
432 {
433         proto_tree *tree = NULL;
434         proto_item *item = NULL;
435         guint32 criterion;
436
437         criterion = tvb_get_letohl(tvb, offset);
438
439         if (parent_tree) {
440                 item = proto_tree_add_uint(parent_tree, hf_election_criteria, tvb, offset, 4, criterion);
441                 tree = proto_item_add_subtree(item, ett_browse_election_criteria);
442         }
443
444         /* election desire */
445         dissect_election_criterion_desire(tvb, tree, offset);
446         offset += 1;
447
448         /* browser protocol major version */
449         proto_tree_add_item(tree, hf_proto_major, tvb, offset, 1, TRUE);
450         offset += 1;
451
452         /* browser protocol minor version */
453         proto_tree_add_item(tree, hf_proto_minor, tvb, offset, 1, TRUE);
454         offset += 1;
455
456         /* election os */
457         dissect_election_criterion_os(tvb, tree, offset);
458         offset += 1;
459
460 }
461
462 /*
463  * XXX - this causes non-browser packets to have browser fields.
464  */
465 int
466 dissect_smb_server_type_flags(tvbuff_t *tvb, int offset, packet_info *pinfo,
467                               proto_tree *parent_tree, char *drep, 
468                               gboolean infoflag)
469 {
470         proto_tree *tree = NULL;
471         proto_item *item = NULL;
472         guint32 flags;
473         int i;
474
475         if (drep != NULL) {
476                 /*
477                  * Called from a DCE RPC protocol dissector, for a
478                  * protocol where a 32-bit NDR integer contains
479                  * an server type mask; extract the server type mask
480                  * with an NDR call.
481                  */
482                 offset = dissect_ndr_uint32(
483                         tvb, offset, pinfo, tree, drep, hf_server_type, &flags);
484         } else {
485                 /*
486                  * Called from SMB browser or RAS, where the server type
487                  * mask is just a 4-byte little-endian quantity with no
488                  * special NDR alignment requirement; extract it with
489                  * "tvb_get_letohl()".
490                  */
491                 flags = tvb_get_letohl(tvb, offset);
492                 offset += 4;
493         }
494
495         if (parent_tree) {
496                 item = proto_tree_add_uint(parent_tree, hf_server_type, tvb, offset, 4, flags);
497                 tree = proto_item_add_subtree(item, ett_browse_flags);
498         }
499
500         if (infoflag) {
501                 /* Append the type(s) of the system to the COL_INFO line ... */
502                 if (check_col(pinfo->cinfo, COL_INFO)) {
503                         for (i = 0; i < 32; i++) {
504                                 if (flags & (1<<i)) {
505                                         col_append_fstr(pinfo->cinfo, COL_INFO, ", %s",
506                                                 val_to_str(i, server_types,
507                                                 "Unknown server type:%d"));
508                                 }
509                         }
510                 }
511         }
512
513         proto_tree_add_boolean(tree, hf_server_type_workstation,
514                 tvb, offset, 4, flags);
515         proto_tree_add_boolean(tree, hf_server_type_server,
516                 tvb, offset, 4, flags);
517         proto_tree_add_boolean(tree, hf_server_type_sql,
518                 tvb, offset, 4, flags);
519         proto_tree_add_boolean(tree, hf_server_type_domain,
520                 tvb, offset, 4, flags);
521         proto_tree_add_boolean(tree, hf_server_type_backup,
522                 tvb, offset, 4, flags);
523         proto_tree_add_boolean(tree, hf_server_type_time,
524                 tvb, offset, 4, flags);
525         proto_tree_add_boolean(tree, hf_server_type_apple,
526                 tvb, offset, 4, flags);
527         proto_tree_add_boolean(tree, hf_server_type_novell,
528                 tvb, offset, 4, flags);
529         proto_tree_add_boolean(tree, hf_server_type_member,
530                 tvb, offset, 4, flags);
531         proto_tree_add_boolean(tree, hf_server_type_print,
532                 tvb, offset, 4, flags);
533         proto_tree_add_boolean(tree, hf_server_type_dialin,
534                 tvb, offset, 4, flags);
535         proto_tree_add_boolean(tree, hf_server_type_xenix,
536                 tvb, offset, 4, flags);
537         proto_tree_add_boolean(tree, hf_server_type_ntw,
538                 tvb, offset, 4, flags);
539         proto_tree_add_boolean(tree, hf_server_type_wfw,
540                 tvb, offset, 4, flags);
541         proto_tree_add_boolean(tree, hf_server_type_nts,
542                 tvb, offset, 4, flags);
543         proto_tree_add_boolean(tree, hf_server_type_potentialb,
544                 tvb, offset, 4, flags);
545         proto_tree_add_boolean(tree, hf_server_type_backupb,
546                 tvb, offset, 4, flags);
547         proto_tree_add_boolean(tree, hf_server_type_masterb,
548                 tvb, offset, 4, flags);
549         proto_tree_add_boolean(tree, hf_server_type_domainmasterb,
550                 tvb, offset, 4, flags);
551         proto_tree_add_boolean(tree, hf_server_type_osf,
552                 tvb, offset, 4, flags);
553         proto_tree_add_boolean(tree, hf_server_type_vms,
554                 tvb, offset, 4, flags);
555         proto_tree_add_boolean(tree, hf_server_type_w95,
556                 tvb, offset, 4, flags);
557         proto_tree_add_boolean(tree, hf_server_type_local,
558                 tvb, offset, 4, flags);
559         proto_tree_add_boolean(tree, hf_server_type_domainenum,
560                 tvb, offset, 4, flags);
561
562         return offset;
563 }
564
565
566 gboolean
567 dissect_mailslot_browse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
568 {
569         int offset = 0;
570         guint8 cmd;
571         proto_tree *tree = NULL;
572         proto_item *item = NULL;
573         guint32 periodicity;
574         char host_name[17];
575         guint namelen;
576         guint8 server_count, reset_cmd;
577         int i;
578         guint32 uptime;
579
580         if (!proto_is_protocol_enabled(proto_smb_browse)) {
581                 return FALSE;
582         }
583
584         pinfo->current_proto = "BROWSER";
585
586         if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
587                 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BROWSER");
588         }
589         if (check_col(pinfo->cinfo, COL_INFO)) {
590                 col_clear(pinfo->cinfo, COL_INFO);
591         }
592
593         cmd = tvb_get_guint8(tvb, offset);
594
595         if (check_col(pinfo->cinfo, COL_INFO)) {
596                 /* Put in something, and replace it later */
597                 col_set_str(pinfo->cinfo, COL_INFO, val_to_str(cmd, commands, "Unknown command:0x%02x"));
598         }
599
600
601         if (parent_tree) {
602                 item = proto_tree_add_item(parent_tree, proto_smb_browse, tvb, offset, -1, TRUE);
603
604                 tree = proto_item_add_subtree(item, ett_browse);
605         }
606
607         /* command */
608         proto_tree_add_uint(tree, hf_command, tvb, offset, 1, cmd);
609         offset += 1;
610
611         switch (cmd) {
612         case BROWSE_DOMAIN_ANNOUNCEMENT:
613         case BROWSE_LOCAL_MASTER_ANNOUNCEMENT:
614         case BROWSE_HOST_ANNOUNCE: {
615                 /* update count */
616                 proto_tree_add_item(tree, hf_update_count, tvb, offset, 1, TRUE);
617                 offset += 1;
618
619                 /* periodicity (in milliseconds) */
620                 periodicity = tvb_get_letohl(tvb, offset);
621                 proto_tree_add_uint_format(tree, hf_periodicity, tvb, offset, 4,
622                     periodicity,
623                     "Update Periodicity: %s",
624                     time_msecs_to_str(periodicity));
625                 offset += 4;
626
627                 /* server name */
628                 tvb_get_nstringz0(tvb, offset, sizeof(host_name), host_name);
629                 if (check_col(pinfo->cinfo, COL_INFO)) {
630                         col_append_fstr(pinfo->cinfo, COL_INFO, " %s", host_name);
631                 }
632                 proto_tree_add_string_format(tree, hf_server_name,
633                         tvb, offset, 16,
634                         host_name,
635                         (cmd==BROWSE_DOMAIN_ANNOUNCEMENT)?
636                                 "Domain/Workgroup: %s":
637                                 "Host Name: %s",
638                         host_name);
639                 offset += 16;
640
641                 /* OS major version */
642                 proto_tree_add_item(tree, hf_os_major, tvb, offset, 1, TRUE);
643                 offset += 1;
644
645                 /* OS minor version */
646                 proto_tree_add_item(tree, hf_os_minor, tvb, offset, 1, TRUE);
647                 offset += 1;
648
649                 /* server type flags */
650                 offset = dissect_smb_server_type_flags(
651                         tvb, offset, pinfo, tree, NULL, TRUE);
652
653                 if (cmd == BROWSE_DOMAIN_ANNOUNCEMENT) {
654                         /*
655                          * Network Monitor claims this is a "Comment
656                          * Pointer".  I don't believe it.
657                          *
658                          * It's not a browser protocol major/minor
659                          * version number, and signature constant,
660                          * however.
661                          */
662                         proto_tree_add_text(tree, tvb, offset, 4,
663                             "Mysterious Field: 0x%08x",
664                             tvb_get_letohl(tvb, offset));
665                         offset += 4;
666                 } else {
667                         /* browser protocol major version */
668                         proto_tree_add_item(tree, hf_proto_major, tvb, offset, 1, TRUE);
669                         offset += 1;
670
671                         /* browser protocol minor version */
672                         proto_tree_add_item(tree, hf_proto_minor, tvb, offset, 1, TRUE);
673                         offset += 1;
674
675                         /* signature constant */
676                         proto_tree_add_item(tree, hf_sig_const, tvb, offset, 2, TRUE);
677                         offset += 2;
678                 }
679
680                 /* master browser server name or server comment */
681                 namelen = tvb_strsize(tvb, offset);
682                 proto_tree_add_item(tree,
683                         (cmd==BROWSE_DOMAIN_ANNOUNCEMENT)?
684                             hf_mb_server_name : hf_server_comment,
685                         tvb, offset, namelen, TRUE);
686                 offset += namelen;
687                 break;
688         }
689         case BROWSE_REQUEST_ANNOUNCE: {
690                 char *computer_name;
691
692                 /* unused/unknown flags */
693                 proto_tree_add_item(tree, hf_unused_flags,
694                         tvb, offset, 1, TRUE);
695                 offset += 1;
696
697                 /* name of computer to which to send reply */
698                 computer_name = tvb_get_stringz(tvb, offset, &namelen);
699                 proto_tree_add_string(tree, hf_response_computer_name,
700                         tvb, offset, namelen, computer_name);
701                 if (check_col(pinfo->cinfo, COL_INFO))
702                         col_append_fstr(
703                                 pinfo->cinfo, COL_INFO, " %s", computer_name);
704                 g_free(computer_name);
705                 offset += namelen;
706                 break;
707         }
708
709         case BROWSE_ELECTION_REQUEST:
710                 /* election version */
711                 proto_tree_add_item(tree, hf_election_version, tvb, offset, 1, TRUE);
712                 offset += 1;
713
714                 /* criterion */
715                 dissect_election_criterion(tvb, tree, offset);
716                 offset += 4;
717
718                 /* server uptime */
719                 uptime = tvb_get_letohl(tvb, offset);
720                 proto_tree_add_uint_format(tree, hf_server_uptime,
721                     tvb, offset, 4, uptime,
722                     "Uptime: %s",
723                     time_msecs_to_str(uptime));
724                 offset += 4;
725
726                 /* next 4 bytes must be zero */
727                 offset += 4;
728
729                 /* server name */
730                 namelen = tvb_strsize(tvb, offset);
731                 proto_tree_add_item(tree, hf_server_name,
732                         tvb, offset, namelen, TRUE);
733                 offset += namelen;
734                 break;
735
736         case BROWSE_BACKUP_LIST_REQUEST:
737                 /* backup list requested count */
738                 proto_tree_add_item(tree, hf_backup_count, tvb, offset, 1, TRUE);
739                 offset += 1;
740
741                 /* backup requested token */
742                 proto_tree_add_item(tree, hf_backup_token, tvb, offset, 4, TRUE);
743                 offset += 4;
744                 break;
745
746         case BROWSE_BACKUP_LIST_RESPONSE:
747                 /* backup list requested count */
748                 server_count = tvb_get_guint8(tvb, offset);
749                 proto_tree_add_uint(tree, hf_backup_count, tvb, offset, 1,
750                     server_count);
751                 offset += 1;
752
753                 /* backup requested token */
754                 proto_tree_add_item(tree, hf_backup_token, tvb, offset, 4, TRUE);
755                 offset += 4;
756
757                 /* backup server names */
758                 for (i = 0; i < server_count; i++) {
759                         namelen = tvb_strsize(tvb, offset);
760                         proto_tree_add_item(tree, hf_backup_server,
761                                 tvb, offset, namelen, TRUE);
762                         offset += namelen;
763                 }
764                 break;
765
766         case BROWSE_MASTER_ANNOUNCEMENT:
767                 /* master browser server name */
768                 namelen = tvb_strsize(tvb, offset);
769                 proto_tree_add_item(tree, hf_mb_server_name,
770                         tvb, offset, namelen, TRUE);
771                 offset += namelen;
772                 break;
773
774         case BROWSE_RESETBROWSERSTATE_ANNOUNCEMENT: {
775                 proto_tree *sub_tree;
776                 proto_item *reset_item;
777
778                 /* the subcommand follows ... one of three values */
779
780                 reset_cmd = tvb_get_guint8(tvb, offset);
781                 reset_item = proto_tree_add_uint(tree, hf_mb_reset_command, tvb, 
782                                                  offset, 1, reset_cmd);
783                 sub_tree = proto_item_add_subtree(item, ett_browse_reset_cmd_flags);
784                 proto_tree_add_boolean(sub_tree, hf_mb_reset_demote, tvb, 
785                                        offset, 1, reset_cmd);
786                 proto_tree_add_boolean(sub_tree, hf_mb_reset_flush, tvb, 
787                                        offset, 1, reset_cmd);
788                 proto_tree_add_boolean(sub_tree, hf_mb_reset_stop, tvb, 
789                                        offset, 1, reset_cmd);
790                 offset += 1;
791                 break;
792         }
793
794         case BROWSE_BECOME_BACKUP:
795                 /* name of browser to promote */
796                 namelen = tvb_strsize(tvb, offset);
797                 proto_tree_add_item(tree, hf_browser_to_promote,
798                         tvb, offset, namelen, TRUE);
799                 offset += namelen;
800                 break;
801         }
802
803         return TRUE;
804 }
805
806 /*
807  * It appears that browser announcements sent to \MAILSLOT\LANMAN aren't
808  * the same as browser announcements sent to \MAILSLOT\BROWSE.
809  * Was that an older version of the protocol?
810  *
811  * The document at
812  *
813  *      http://www.samba.org/samba/ftp/specs/brow_rev.txt
814  *
815  * gives both formats of host announcement packets, saying that
816  * "[The first] format seems wrong", that one being what appears to
817  * show up in \MAILSLOT\LANMAN packets, and that "[The second one]
818  * may be better", that one being what appears to show up in
819  * \MAILSLOT\BROWSE packets.
820  *
821  * XXX - what other browser packets go out to that mailslot?
822  */
823 gboolean
824 dissect_mailslot_lanman(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
825 {
826         int offset = 0;
827         guint8 cmd;
828         proto_tree *tree = NULL;
829         proto_item *item = NULL;
830         guint32 periodicity;
831         const char *host_name;
832         guint namelen;
833
834         if (!proto_is_protocol_enabled(proto_smb_browse)) {
835                 return FALSE;
836         }
837
838         pinfo->current_proto = "BROWSER";
839
840         if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
841                 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BROWSER");
842         }
843         if (check_col(pinfo->cinfo, COL_INFO)) {
844                 col_clear(pinfo->cinfo, COL_INFO);
845         }
846
847         cmd = tvb_get_guint8(tvb, offset);
848
849         if (check_col(pinfo->cinfo, COL_INFO)) {
850                 /* Put in something, and replace it later */
851                 col_set_str(pinfo->cinfo, COL_INFO, val_to_str(cmd, commands, "Unknown command:0x%02x"));
852         }
853
854
855         if (parent_tree) {
856                 item = proto_tree_add_item(parent_tree, proto_smb_browse, tvb, offset, -1, TRUE);
857
858                 tree = proto_item_add_subtree(item, ett_browse);
859         }
860
861         /* command */
862         proto_tree_add_uint(tree, hf_command, tvb, offset, 1, cmd);
863         offset += 1;
864
865         switch (cmd) {
866         case BROWSE_DOMAIN_ANNOUNCEMENT:
867         case BROWSE_LOCAL_MASTER_ANNOUNCEMENT:
868         case BROWSE_HOST_ANNOUNCE:
869
870                 /* update count */
871                 proto_tree_add_item(tree, hf_update_count, tvb, offset, 1, TRUE);
872                 offset += 1;
873
874                 /* server type flags */
875                 offset = dissect_smb_server_type_flags(
876                         tvb, offset, pinfo, tree, NULL, TRUE);
877
878                 /* OS major version */
879                 proto_tree_add_item(tree, hf_os_major, tvb, offset, 1, TRUE);
880                 offset += 1;
881
882                 /* OS minor version */
883                 proto_tree_add_item(tree, hf_os_minor, tvb, offset, 1, TRUE);
884                 offset += 1;
885
886                 /* periodicity (in seconds; convert to milliseconds) */
887                 periodicity = tvb_get_letohs(tvb, offset)*1000;
888                 proto_tree_add_uint_format(tree, hf_periodicity, tvb, offset, 2,
889                     periodicity,
890                     "Update Periodicity: %s",
891                     time_msecs_to_str(periodicity));
892                 offset += 2;
893
894                 /* server name */
895                 namelen = tvb_strsize(tvb, offset);
896                 host_name = tvb_get_ptr(tvb, offset, namelen);
897                 if (check_col(pinfo->cinfo, COL_INFO)) {
898                         col_append_fstr(pinfo->cinfo, COL_INFO, " %s", host_name);
899                 }
900                 proto_tree_add_item(tree, hf_server_name,
901                         tvb, offset, namelen, TRUE);
902                 offset += namelen;
903
904                 /* master browser server name or server comment */
905                 namelen = tvb_strsize(tvb, offset);
906                 proto_tree_add_item(tree,
907                         (cmd==BROWSE_DOMAIN_ANNOUNCEMENT)?
908                             hf_mb_server_name : hf_server_comment,
909                         tvb, offset, namelen, TRUE);
910                 offset += namelen;
911                 break;
912         }
913
914         return TRUE;
915 }
916
917 void
918 proto_register_smb_browse(void)
919 {
920         static hf_register_info hf[] = {
921                 { &hf_command,
922                         { "Command", "browser.command", FT_UINT8, BASE_HEX,
923                         VALS(commands), 0, "Browse command opcode", HFILL }},
924
925                 { &hf_update_count,
926                         { "Update Count", "browser.update_count", FT_UINT8, BASE_DEC,
927                         NULL, 0, "Browse Update Count", HFILL }},
928
929                 { &hf_periodicity,
930                         { "Update Periodicity", "browser.period", FT_UINT32, BASE_DEC,
931                         NULL, 0, "Update Periodicity in ms", HFILL }},
932
933                 { &hf_server_name,
934                         { "Server Name", "browser.server", FT_STRING, BASE_NONE,
935                         NULL, 0, "BROWSE Server Name", HFILL }},
936
937                 { &hf_mb_server_name,
938                         { "Master Browser Server Name", "browser.mb_server", FT_STRING, BASE_NONE,
939                         NULL, 0, "BROWSE Master Browser Server Name", HFILL }},
940
941                 { &hf_mb_reset_command,
942                   { "ResetBrowserState Command", "browser.reset_cmd", FT_UINT8,
943                     BASE_HEX, VALS(&resetbrowserstate_command_names), 0,
944                     "ResetBrowserState Command", HFILL }},
945                 { &hf_mb_reset_demote,
946                   { "Demote LMB", "browser.reset_cmd.demote", FT_BOOLEAN, 
947                     8, TFS(&tfs_demote_to_backup), 0x01, "Demote LMB", HFILL}}, 
948                 { &hf_mb_reset_flush,
949                   { "Flush Browse List", "browser.reset_cmd.flush", FT_BOOLEAN,
950                     8, TFS(&tfs_flush_browse_list), 0x02, "Flush Browse List", HFILL}},
951                 { &hf_mb_reset_stop,
952                   { "Stop Being LMB", "browser.reset_cmd.stop_lmb", FT_BOOLEAN,
953                     8, TFS(&tfs_stop_being_lmb), 0x04, "Stop Being LMB", HFILL}},
954                 { &hf_os_major,
955                         { "OS Major Version", "browser.os_major", FT_UINT8, BASE_DEC,
956                         NULL, 0, "Operating System Major Version", HFILL }},
957
958                 { &hf_os_minor,
959                         { "OS Minor Version", "browser.os_minor", FT_UINT8, BASE_DEC,
960                         NULL, 0, "Operating System Minor Version", HFILL }},
961
962                 { &hf_server_type,
963                         { "Server Type", "browser.server_type", FT_UINT32, BASE_HEX,
964                         NULL, 0, "Server Type Flags", HFILL }},
965
966                 { &hf_server_type_workstation,
967                         { "Workstation", "browser.server_type.workstation", FT_BOOLEAN, 32,
968                         TFS(&tfs_workstation), 1<<SERVER_WORKSTATION, "Is This A Workstation?", HFILL }},
969
970                 { &hf_server_type_server,
971                         { "Server", "browser.server_type.server", FT_BOOLEAN, 32,
972                         TFS(&tfs_server), 1<<SERVER_SERVER, "Is This A Server?", HFILL }},
973
974                 { &hf_server_type_sql,
975                         { "SQL", "browser.server_type.sql", FT_BOOLEAN, 32,
976                         TFS(&tfs_sql), 1<<SERVER_SQL_SERVER, "Is This A SQL Server?", HFILL }},
977
978                 { &hf_server_type_domain,
979                         { "Domain Controller", "browser.server_type.domain_controller", FT_BOOLEAN, 32,
980                         TFS(&tfs_domain), 1<<SERVER_DOMAIN_CONTROLLER, "Is This A Domain Controller?", HFILL }},
981
982                 { &hf_server_type_backup,
983                         { "Backup Controller", "browser.server_type.backup_controller", FT_BOOLEAN, 32,
984                         TFS(&tfs_backup), 1<<SERVER_BACKUP_CONTROLLER, "Is This A Backup Domain Controller?", HFILL }},
985
986                 { &hf_server_type_time,
987                         { "Time Source", "browser.server_type.time", FT_BOOLEAN, 32,
988                         TFS(&tfs_time), 1<<SERVER_TIME_SOURCE, "Is This A Time Source?", HFILL }},
989
990                 { &hf_server_type_apple,
991                         { "Apple", "browser.server_type.apple", FT_BOOLEAN, 32,
992                         TFS(&tfs_apple), 1<<SERVER_APPLE_SERVER, "Is This An Apple Server ?", HFILL }},
993
994                 { &hf_server_type_novell,
995                         { "Novell", "browser.server_type.novell", FT_BOOLEAN, 32,
996                         TFS(&tfs_novell), 1<<SERVER_NOVELL_SERVER, "Is This A Novell Server?", HFILL }},
997
998                 { &hf_server_type_member,
999                         { "Member", "browser.server_type.member", FT_BOOLEAN, 32,
1000                         TFS(&tfs_member), 1<<SERVER_DOMAIN_MEMBER_SERVER, "Is This A Domain Member Server?", HFILL }},
1001
1002                 { &hf_server_type_print,
1003                         { "Print", "browser.server_type.print", FT_BOOLEAN, 32,
1004                         TFS(&tfs_print), 1<<SERVER_PRINT_QUEUE_SERVER, "Is This A Print Server?", HFILL }},
1005
1006                 { &hf_server_type_dialin,
1007                         { "Dialin", "browser.server_type.dialin", FT_BOOLEAN, 32,
1008                         TFS(&tfs_dialin), 1<<SERVER_DIALIN_SERVER, "Is This A Dialin Server?", HFILL }},
1009
1010                 { &hf_server_type_xenix,
1011                         { "Xenix", "browser.server_type.xenix", FT_BOOLEAN, 32,
1012                         TFS(&tfs_xenix), 1<<SERVER_XENIX_SERVER, "Is This A Xenix Server?", HFILL }},
1013
1014                 { &hf_server_type_ntw,
1015                         { "NT Workstation", "browser.server_type.ntw", FT_BOOLEAN, 32,
1016                         TFS(&tfs_ntw), 1<<SERVER_NT_WORKSTATION, "Is This A NT Workstation?", HFILL }},
1017
1018                 { &hf_server_type_wfw,
1019                         { "WfW", "browser.server_type.wfw", FT_BOOLEAN, 32,
1020                         TFS(&tfs_wfw), 1<<SERVER_WINDOWS_FOR_WORKGROUPS, "Is This A Windows For Workgroups Server?", HFILL }},
1021
1022                 { &hf_server_type_nts,
1023                         { "NT Server", "browser.server_type.nts", FT_BOOLEAN, 32,
1024                         TFS(&tfs_nts), 1<<SERVER_NT_SERVER, "Is This A NT Server?", HFILL }},
1025
1026                 { &hf_server_type_potentialb,
1027                         { "Potential Browser", "browser.server_type.browser.potential", FT_BOOLEAN, 32,
1028                         TFS(&tfs_potentialb), 1<<SERVER_POTENTIAL_BROWSER, "Is This A Potential Browser?", HFILL }},
1029
1030                 { &hf_server_type_backupb,
1031                         { "Backup Browser", "browser.server_type.browser.backup", FT_BOOLEAN, 32,
1032                         TFS(&tfs_backupb), 1<<SERVER_BACKUP_BROWSER, "Is This A Backup Browser?", HFILL }},
1033
1034                 { &hf_server_type_masterb,
1035                         { "Master Browser", "browser.server_type.browser.master", FT_BOOLEAN, 32,
1036                         TFS(&tfs_masterb), 1<<SERVER_MASTER_BROWSER, "Is This A Master Browser?", HFILL }},
1037
1038                 { &hf_server_type_domainmasterb,
1039                         { "Domain Master Browser", "browser.server_type.browser.domain_master", FT_BOOLEAN, 32,
1040                         TFS(&tfs_domainmasterb), 1<<SERVER_DOMAIN_MASTER_BROWSER, "Is This A Domain Master Browser?", HFILL }},
1041
1042                 { &hf_server_type_osf,
1043                         { "OSF", "browser.server_type.osf", FT_BOOLEAN, 32,
1044                         TFS(&tfs_osf), 1<<SERVER_OSF, "Is This An OSF server ?", HFILL }},
1045
1046                 { &hf_server_type_vms,
1047                         { "VMS", "browser.server_type.vms", FT_BOOLEAN, 32,
1048                         TFS(&tfs_vms), 1<<SERVER_VMS, "Is This A VMS Server?", HFILL }},
1049
1050                 { &hf_server_type_w95,
1051                         { "Windows 95+", "browser.server_type.w95", FT_BOOLEAN, 32,
1052                         TFS(&tfs_w95), 1<<SERVER_WINDOWS_95, "Is This A Windows 95 or above server?", HFILL }},
1053
1054                 { &hf_server_type_local,
1055                         { "Local", "browser.server_type.local", FT_BOOLEAN, 32,
1056                         TFS(&tfs_local), 1<<SERVER_LOCAL_LIST_ONLY, "Is This A Local List Only request?", HFILL }},
1057
1058                 { &hf_server_type_domainenum,
1059                         { "Domain Enum", "browser.server_type.domainenum", FT_BOOLEAN, 32,
1060                         TFS(&tfs_domainenum), 1<<SERVER_DOMAIN_ENUM, "Is This A Domain Enum request?", HFILL }},
1061
1062                 { &hf_election_version,
1063                         { "Election Version", "browser.election.version", FT_UINT8, BASE_DEC,
1064                         NULL, 0, "Election Version", HFILL }},
1065
1066                 { &hf_proto_major,
1067                         { "Browser Protocol Major Version", "browser.proto_major", FT_UINT8, BASE_DEC,
1068                         NULL, 0, "Browser Protocol Major Version", HFILL }},
1069
1070                 { &hf_proto_minor,
1071                         { "Browser Protocol Minor Version", "browser.proto_minor", FT_UINT8, BASE_DEC,
1072                         NULL, 0, "Browser Protocol Minor Version", HFILL }},
1073
1074                 { &hf_sig_const,
1075                         { "Signature", "browser.sig", FT_UINT16, BASE_HEX,
1076                         NULL, 0, "Signature Constant", HFILL }},
1077
1078                 { &hf_server_comment,
1079                         { "Host Comment", "browser.comment", FT_STRINGZ, BASE_NONE,
1080                         NULL, 0, "Server Comment", HFILL }},
1081
1082                 { &hf_unused_flags,
1083                         { "Unused flags", "browser.unused", FT_UINT8, BASE_HEX,
1084                         NULL, 0, "Unused/unknown flags", HFILL }},
1085
1086                 { &hf_response_computer_name,
1087                         { "Response Computer Name", "browser.response_computer_name", FT_STRINGZ, BASE_NONE,
1088                         NULL, 0, "Response Computer Name", HFILL }},
1089
1090                 { &hf_election_criteria,
1091                         { "Election Criteria", "browser.election.criteria", FT_UINT32, BASE_HEX,
1092                         NULL, 0, "Election Criteria", HFILL }},
1093
1094                 { &hf_election_desire,
1095                         { "Election Desire", "browser.election.desire", FT_UINT8, BASE_HEX,
1096                         NULL, 0, "Election Desire", HFILL }},
1097
1098                 { &hf_election_desire_flags_backup,
1099                         { "Backup", "browser.election.desire.backup", FT_BOOLEAN, 8,
1100                         TFS(&tfs_desire_backup), 1<<DESIRE_BACKUP, "Is this a backup server", HFILL }},
1101
1102                 { &hf_election_desire_flags_standby,
1103                         { "Standby", "browser.election.desire.standby", FT_BOOLEAN, 8,
1104                         TFS(&tfs_desire_standby), 1<<DESIRE_STANDBY, "Is this a standby server?", HFILL }},
1105
1106                 { &hf_election_desire_flags_master,
1107                         { "Master", "browser.election.desire.master", FT_BOOLEAN, 8,
1108                         TFS(&tfs_desire_master), 1<<DESIRE_MASTER, "Is this a master server", HFILL }},
1109
1110                 { &hf_election_desire_flags_domain_master,
1111                         { "Domain Master", "browser.election.desire.domain_master", FT_BOOLEAN, 8,
1112                         TFS(&tfs_desire_domain_master), 1<<DESIRE_DOMAIN_MASTER, "Is this a domain master", HFILL }},
1113
1114                 { &hf_election_desire_flags_wins,
1115                         { "WINS", "browser.election.desire.wins", FT_BOOLEAN, 8,
1116                         TFS(&tfs_desire_wins), 1<<DESIRE_WINS, "Is this a WINS server", HFILL }},
1117
1118                 { &hf_election_desire_flags_nt,
1119                         { "NT", "browser.election.desire.nt", FT_BOOLEAN, 8,
1120                         TFS(&tfs_desire_nt), 1<<DESIRE_NT, "Is this a NT server", HFILL }},
1121
1122                 { &hf_election_revision,
1123                         { "Election Revision", "browser.election.revision", FT_UINT16, BASE_DEC,
1124                         NULL, 0, "Election Revision", HFILL }},
1125
1126                 { &hf_election_os,
1127                         { "Election OS", "browser.election.os", FT_UINT8, BASE_HEX,
1128                         NULL, 0, "Election OS", HFILL }},
1129
1130                 { &hf_election_os_wfw,
1131                         { "WfW", "browser.election.os.wfw", FT_BOOLEAN, 8,
1132                         TFS(&tfs_os_wfw), 1<<OS_WFW, "Is this a WfW host?", HFILL }},
1133
1134                 { &hf_election_os_ntw,
1135                         { "NT Workstation", "browser.election.os.ntw", FT_BOOLEAN, 8,
1136                         TFS(&tfs_os_ntw), 1<<OS_NTW, "Is this a NT Workstation?", HFILL }},
1137
1138                 { &hf_election_os_nts,
1139                         { "NT Server", "browser.election.os.nts", FT_BOOLEAN, 8,
1140                         TFS(&tfs_os_nts), 1<<OS_NTS, "Is this a NT Server?", HFILL }},
1141
1142                 { &hf_server_uptime,
1143                         { "Uptime", "browser.uptime", FT_UINT32, BASE_DEC,
1144                         NULL, 0, "Server uptime in ms", HFILL }},
1145
1146                 { &hf_backup_count,
1147                         { "Backup List Requested Count", "browser.backup.count", FT_UINT8, BASE_DEC,
1148                         NULL, 0, "Backup list requested count", HFILL }},
1149
1150                 { &hf_backup_token,
1151                         { "Backup Request Token", "browser.backup.token", FT_UINT32, BASE_DEC,
1152                         NULL, 0, "Backup requested/response token", HFILL }},
1153
1154                 { &hf_backup_server,
1155                         { "Backup Server", "browser.backup.server", FT_STRING, BASE_NONE,
1156                         NULL, 0, "Backup Server Name", HFILL }},
1157
1158                 { &hf_browser_to_promote,
1159                         { "Browser to Promote", "browser.browser_to_promote", FT_STRINGZ, BASE_NONE,
1160                         NULL, 0, "Browser to Promote", HFILL }},
1161
1162         };
1163
1164         static gint *ett[] = {
1165                 &ett_browse,
1166                 &ett_browse_flags,
1167                 &ett_browse_election_criteria,
1168                 &ett_browse_election_os,
1169                 &ett_browse_election_desire,
1170                 &ett_browse_reset_cmd_flags,
1171         };
1172
1173         proto_smb_browse = proto_register_protocol("Microsoft Windows Browser Protocol",
1174             "BROWSER", "browser");
1175
1176         proto_register_field_array(proto_smb_browse, hf, array_length(hf));
1177         proto_register_subtree_array(ett, array_length(ett));
1178 }