Add a inflateEnd() call to free up the stream in the re-init block.
[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/emem.h>
40 #include <epan/dissectors/packet-smb.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 true_false_string tfs_desire_backup = {
295         "Backup Browse Server",
296         "NOT Backup Browse Server"
297 };
298 static const true_false_string tfs_desire_standby = {
299         "Standby Browse Server",
300         "NOT Standby Browse Server"
301 };
302 static const true_false_string tfs_desire_master = {
303         "Master Browser",
304         "NOT Master Browser"
305 };
306 static const true_false_string tfs_desire_domain_master = {
307         "Domain Master Browse Server",
308         "NOT Domain Master Browse Server"
309 };
310 static const true_false_string tfs_desire_wins = {
311         "WINS Client",
312         "NOT WINS Client"
313 };
314 static const true_false_string tfs_desire_nt = {
315         "Windows NT Advanced Server",
316         "NOT Windows NT Advanced Server"
317 };
318
319 #define BROWSE_HOST_ANNOUNCE                    1
320 #define BROWSE_REQUEST_ANNOUNCE                 2
321 #define BROWSE_ELECTION_REQUEST                 8
322 #define BROWSE_BACKUP_LIST_REQUEST              9
323 #define BROWSE_BACKUP_LIST_RESPONSE             10
324 #define BROWSE_BECOME_BACKUP                    11
325 #define BROWSE_DOMAIN_ANNOUNCEMENT              12
326 #define BROWSE_MASTER_ANNOUNCEMENT              13
327 #define BROWSE_RESETBROWSERSTATE_ANNOUNCEMENT   14
328 #define BROWSE_LOCAL_MASTER_ANNOUNCEMENT        15
329
330 static const value_string commands[] = {
331         {BROWSE_HOST_ANNOUNCE,          "Host Announcement"},
332         {BROWSE_REQUEST_ANNOUNCE,       "Request Announcement"},
333         {BROWSE_ELECTION_REQUEST,       "Browser Election Request"},
334         {BROWSE_BACKUP_LIST_REQUEST,    "Get Backup List Request"},
335         {BROWSE_BACKUP_LIST_RESPONSE,   "Get Backup List Response"},
336         {BROWSE_BECOME_BACKUP,          "Become Backup Browser"},
337         {BROWSE_DOMAIN_ANNOUNCEMENT,    "Domain/Workgroup Announcement"},
338         {BROWSE_MASTER_ANNOUNCEMENT,    "Master Announcement"},
339         {BROWSE_RESETBROWSERSTATE_ANNOUNCEMENT, "Reset Browser State Announcement"},
340         {BROWSE_LOCAL_MASTER_ANNOUNCEMENT,"Local Master Announcement"},
341         {0,                             NULL}
342 };
343
344 #define OS_WFW                          0
345 #define OS_NTW                          4
346 #define OS_NTS                          5
347
348 static const true_false_string tfs_os_wfw = {
349         "Windows for Workgroups",
350         "Not Windows for Workgroups"
351 };
352 static const true_false_string tfs_os_ntw = {
353         "Windows NT Workstation",
354         "Not Windows NT Workstation"
355 };
356 static const true_false_string tfs_os_nts = {
357         "Windows NT Server",
358         "Not Windows NT Server"
359 };
360
361 static void
362 dissect_election_criterion_os(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
363 {
364         proto_tree *tree = NULL;
365         proto_item *item = NULL;
366         guint8 os;
367
368         os = tvb_get_guint8(tvb, offset);
369
370         if (parent_tree) {
371                 item = proto_tree_add_uint(parent_tree, hf_election_os, tvb, offset, 1, os);
372                 tree = proto_item_add_subtree(item, ett_browse_election_os);
373         }
374
375         proto_tree_add_boolean(tree, hf_election_os_wfw,
376                 tvb, offset, 1, os);
377         proto_tree_add_boolean(tree, hf_election_os_ntw,
378                 tvb, offset, 1, os);
379         proto_tree_add_boolean(tree, hf_election_os_nts,
380                 tvb, offset, 1, os);
381
382 }
383
384 static void
385 dissect_election_criterion_desire(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
386 {
387         proto_tree *tree = NULL;
388         proto_item *item = NULL;
389         guint8 desire;
390
391         desire = tvb_get_guint8(tvb, offset);
392
393         if (parent_tree) {
394                 item = proto_tree_add_uint(parent_tree, hf_election_desire, tvb, offset, 1, desire);
395                 tree = proto_item_add_subtree(item, ett_browse_election_desire);
396         }
397
398         proto_tree_add_boolean(tree, hf_election_desire_flags_backup,
399                 tvb, offset, 1, desire);
400         proto_tree_add_boolean(tree, hf_election_desire_flags_standby,
401                 tvb, offset, 1, desire);
402         proto_tree_add_boolean(tree, hf_election_desire_flags_master,
403                 tvb, offset, 1, desire);
404         proto_tree_add_boolean(tree, hf_election_desire_flags_domain_master,
405                 tvb, offset, 1, desire);
406         proto_tree_add_boolean(tree, hf_election_desire_flags_wins,
407                 tvb, offset, 1, desire);
408         proto_tree_add_boolean(tree, hf_election_desire_flags_nt,
409                 tvb, offset, 1, desire);
410
411 }
412
413 static void
414 dissect_election_criterion(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
415 {
416         proto_tree *tree = NULL;
417         proto_item *item = NULL;
418         guint32 criterion;
419
420         criterion = tvb_get_letohl(tvb, offset);
421
422         if (parent_tree) {
423                 item = proto_tree_add_uint(parent_tree, hf_election_criteria, tvb, offset, 4, criterion);
424                 tree = proto_item_add_subtree(item, ett_browse_election_criteria);
425         }
426
427         /* election desire */
428         dissect_election_criterion_desire(tvb, tree, offset);
429         offset += 1;
430
431         /* browser protocol major version */
432         proto_tree_add_item(tree, hf_proto_major, tvb, offset, 1, TRUE);
433         offset += 1;
434
435         /* browser protocol minor version */
436         proto_tree_add_item(tree, hf_proto_minor, tvb, offset, 1, TRUE);
437         offset += 1;
438
439         /* election os */
440         dissect_election_criterion_os(tvb, tree, offset);
441         offset += 1;
442
443 }
444
445 /*
446  * XXX - this causes non-browser packets to have browser fields.
447  */
448 int
449 dissect_smb_server_type_flags(tvbuff_t *tvb, int offset, packet_info *pinfo,
450                               proto_tree *parent_tree, guint8 *drep, 
451                               gboolean infoflag)
452 {
453         proto_tree *tree = NULL;
454         proto_item *item = NULL;
455         guint32 flags;
456         int i;
457
458         if (drep != NULL) {
459                 /*
460                  * Called from a DCE RPC protocol dissector, for a
461                  * protocol where a 32-bit NDR integer contains
462                  * an server type mask; extract the server type mask
463                  * with an NDR call (but don't put it into the
464                  * protocol tree, as we can't get a pointer to the
465                  * item it puts in, and thus can't put a tree below
466                  * it with the values of the individual bits).
467                  */
468                 offset = dissect_ndr_uint32(
469                         tvb, offset, pinfo, NULL, drep, hf_server_type, &flags);
470         } else {
471                 /*
472                  * Called from SMB browser or RAP, where the server type
473                  * mask is just a 4-byte little-endian quantity with no
474                  * special NDR alignment requirement; extract it with
475                  * "tvb_get_letohl()".
476                  */
477                 flags = tvb_get_letohl(tvb, offset);
478                 offset += 4;
479         }
480
481         if (parent_tree) {
482                 item = proto_tree_add_uint(parent_tree, hf_server_type, tvb, offset-4, 4, flags);
483                 tree = proto_item_add_subtree(item, ett_browse_flags);
484         }
485
486         if (infoflag) {
487                 /* Append the type(s) of the system to the COL_INFO line ... */
488                 if (check_col(pinfo->cinfo, COL_INFO)) {
489                         for (i = 0; i < 32; i++) {
490                                 if (flags & (1<<i)) {
491                                         col_append_fstr(pinfo->cinfo, COL_INFO, ", %s",
492                                                 val_to_str(i, server_types,
493                                                 "Unknown server type:%d"));
494                                 }
495                         }
496                 }
497         }
498
499         proto_tree_add_boolean(tree, hf_server_type_workstation,
500                 tvb, offset-4, 4, flags);
501         proto_tree_add_boolean(tree, hf_server_type_server,
502                 tvb, offset-4, 4, flags);
503         proto_tree_add_boolean(tree, hf_server_type_sql,
504                 tvb, offset-4, 4, flags);
505         proto_tree_add_boolean(tree, hf_server_type_domain,
506                 tvb, offset-4, 4, flags);
507         proto_tree_add_boolean(tree, hf_server_type_backup,
508                 tvb, offset-4, 4, flags);
509         proto_tree_add_boolean(tree, hf_server_type_time,
510                 tvb, offset-4, 4, flags);
511         proto_tree_add_boolean(tree, hf_server_type_apple,
512                 tvb, offset-4, 4, flags);
513         proto_tree_add_boolean(tree, hf_server_type_novell,
514                 tvb, offset-4, 4, flags);
515         proto_tree_add_boolean(tree, hf_server_type_member,
516                 tvb, offset-4, 4, flags);
517         proto_tree_add_boolean(tree, hf_server_type_print,
518                 tvb, offset-4, 4, flags);
519         proto_tree_add_boolean(tree, hf_server_type_dialin,
520                 tvb, offset-4, 4, flags);
521         proto_tree_add_boolean(tree, hf_server_type_xenix,
522                 tvb, offset-4, 4, flags);
523         proto_tree_add_boolean(tree, hf_server_type_ntw,
524                 tvb, offset-4, 4, flags);
525         proto_tree_add_boolean(tree, hf_server_type_wfw,
526                 tvb, offset-4, 4, flags);
527         proto_tree_add_boolean(tree, hf_server_type_nts,
528                 tvb, offset-4, 4, flags);
529         proto_tree_add_boolean(tree, hf_server_type_potentialb,
530                 tvb, offset-4, 4, flags);
531         proto_tree_add_boolean(tree, hf_server_type_backupb,
532                 tvb, offset-4, 4, flags);
533         proto_tree_add_boolean(tree, hf_server_type_masterb,
534                 tvb, offset-4, 4, flags);
535         proto_tree_add_boolean(tree, hf_server_type_domainmasterb,
536                 tvb, offset-4, 4, flags);
537         proto_tree_add_boolean(tree, hf_server_type_osf,
538                 tvb, offset-4, 4, flags);
539         proto_tree_add_boolean(tree, hf_server_type_vms,
540                 tvb, offset-4, 4, flags);
541         proto_tree_add_boolean(tree, hf_server_type_w95,
542                 tvb, offset-4, 4, flags);
543         proto_tree_add_boolean(tree, hf_server_type_local,
544                 tvb, offset-4, 4, flags);
545         proto_tree_add_boolean(tree, hf_server_type_domainenum,
546                 tvb, offset-4, 4, flags);
547
548         return offset;
549 }
550
551
552 static void
553 dissect_mailslot_browse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
554 {
555         int offset = 0;
556         guint8 cmd;
557         proto_tree *tree = NULL;
558         proto_item *item = NULL;
559         guint32 periodicity;
560         guint8 host_name[17];
561         gint namelen;
562         guint8 server_count, reset_cmd;
563         int i;
564         guint32 uptime;
565
566         if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
567                 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BROWSER");
568         }
569         if (check_col(pinfo->cinfo, COL_INFO)) {
570                 col_clear(pinfo->cinfo, COL_INFO);
571         }
572
573         cmd = tvb_get_guint8(tvb, offset);
574
575         if (check_col(pinfo->cinfo, COL_INFO)) {
576                 /* Put in something, and replace it later */
577                 col_add_str(pinfo->cinfo, COL_INFO, val_to_str(cmd, commands, "Unknown command:0x%02x"));
578         }
579
580
581         if (parent_tree) {
582                 item = proto_tree_add_item(parent_tree, proto_smb_browse, tvb, offset, -1, TRUE);
583
584                 tree = proto_item_add_subtree(item, ett_browse);
585         }
586
587         /* command */
588         proto_tree_add_uint(tree, hf_command, tvb, offset, 1, cmd);
589         offset += 1;
590
591         switch (cmd) {
592         case BROWSE_DOMAIN_ANNOUNCEMENT:
593         case BROWSE_LOCAL_MASTER_ANNOUNCEMENT:
594         case BROWSE_HOST_ANNOUNCE: {
595                 /* update count */
596                 proto_tree_add_item(tree, hf_update_count, tvb, offset, 1, TRUE);
597                 offset += 1;
598
599                 /* periodicity (in milliseconds) */
600                 periodicity = tvb_get_letohl(tvb, offset);
601                 proto_tree_add_uint_format(tree, hf_periodicity, tvb, offset, 4,
602                     periodicity,
603                     "Update Periodicity: %s",
604                     time_msecs_to_str(periodicity));
605                 offset += 4;
606
607                 /* server name */
608                 tvb_get_nstringz0(tvb, offset, sizeof(host_name), host_name);
609                 if (check_col(pinfo->cinfo, COL_INFO)) {
610                         col_append_fstr(pinfo->cinfo, COL_INFO, " %s", host_name);
611                 }
612                 proto_tree_add_string_format(tree, hf_server_name,
613                         tvb, offset, 16,
614                         host_name,
615                         (cmd==BROWSE_DOMAIN_ANNOUNCEMENT)?
616                                 "Domain/Workgroup: %s":
617                                 "Host Name: %s",
618                         host_name);
619                 offset += 16;
620
621                 /* OS major version */
622                 proto_tree_add_item(tree, hf_os_major, tvb, offset, 1, TRUE);
623                 offset += 1;
624
625                 /* OS minor version */
626                 proto_tree_add_item(tree, hf_os_minor, tvb, offset, 1, TRUE);
627                 offset += 1;
628
629                 /* server type flags */
630                 offset = dissect_smb_server_type_flags(
631                         tvb, offset, pinfo, tree, NULL, TRUE);
632
633                 if (cmd == BROWSE_DOMAIN_ANNOUNCEMENT) {
634                         /*
635                          * Network Monitor claims this is a "Comment
636                          * Pointer".  I don't believe it.
637                          *
638                          * It's not a browser protocol major/minor
639                          * version number, and signature constant,
640                          * however.
641                          */
642                         proto_tree_add_text(tree, tvb, offset, 4,
643                             "Mysterious Field: 0x%08x",
644                             tvb_get_letohl(tvb, offset));
645                         offset += 4;
646                 } else {
647                         /* browser protocol major version */
648                         proto_tree_add_item(tree, hf_proto_major, tvb, offset, 1, TRUE);
649                         offset += 1;
650
651                         /* browser protocol minor version */
652                         proto_tree_add_item(tree, hf_proto_minor, tvb, offset, 1, TRUE);
653                         offset += 1;
654
655                         /* signature constant */
656                         proto_tree_add_item(tree, hf_sig_const, tvb, offset, 2, TRUE);
657                         offset += 2;
658                 }
659
660                 /* master browser server name or server comment */
661                 namelen = tvb_strsize(tvb, offset);
662                 proto_tree_add_item(tree,
663                         (cmd==BROWSE_DOMAIN_ANNOUNCEMENT)?
664                             hf_mb_server_name : hf_server_comment,
665                         tvb, offset, namelen, TRUE);
666                 offset += namelen;
667                 break;
668         }
669         case BROWSE_REQUEST_ANNOUNCE: {
670                 guint8 *computer_name;
671
672                 /* unused/unknown flags */
673                 proto_tree_add_item(tree, hf_unused_flags,
674                         tvb, offset, 1, TRUE);
675                 offset += 1;
676
677                 /* name of computer to which to send reply */
678                 computer_name = tvb_get_ephemeral_stringz(tvb, offset, &namelen);
679                 proto_tree_add_string(tree, hf_response_computer_name,
680                         tvb, offset, namelen, computer_name);
681                 if (check_col(pinfo->cinfo, COL_INFO))
682                         col_append_fstr(
683                                 pinfo->cinfo, COL_INFO, " %s", computer_name);
684                 offset += namelen;
685                 break;
686         }
687
688         case BROWSE_ELECTION_REQUEST:
689                 /* election version */
690                 proto_tree_add_item(tree, hf_election_version, tvb, offset, 1, TRUE);
691                 offset += 1;
692
693                 /* criterion */
694                 dissect_election_criterion(tvb, tree, offset);
695                 offset += 4;
696
697                 /* server uptime */
698                 uptime = tvb_get_letohl(tvb, offset);
699                 proto_tree_add_uint_format(tree, hf_server_uptime,
700                     tvb, offset, 4, uptime,
701                     "Uptime: %s",
702                     time_msecs_to_str(uptime));
703                 offset += 4;
704
705                 /* next 4 bytes must be zero */
706                 offset += 4;
707
708                 /* server name */
709                 namelen = tvb_strsize(tvb, offset);
710                 proto_tree_add_item(tree, hf_server_name,
711                         tvb, offset, namelen, TRUE);
712                 offset += namelen;
713                 break;
714
715         case BROWSE_BACKUP_LIST_REQUEST:
716                 /* backup list requested count */
717                 proto_tree_add_item(tree, hf_backup_count, tvb, offset, 1, TRUE);
718                 offset += 1;
719
720                 /* backup requested token */
721                 proto_tree_add_item(tree, hf_backup_token, tvb, offset, 4, TRUE);
722                 offset += 4;
723                 break;
724
725         case BROWSE_BACKUP_LIST_RESPONSE:
726                 /* backup list requested count */
727                 server_count = tvb_get_guint8(tvb, offset);
728                 proto_tree_add_uint(tree, hf_backup_count, tvb, offset, 1,
729                     server_count);
730                 offset += 1;
731
732                 /* backup requested token */
733                 proto_tree_add_item(tree, hf_backup_token, tvb, offset, 4, TRUE);
734                 offset += 4;
735
736                 /* backup server names */
737                 for (i = 0; i < server_count; i++) {
738                         namelen = tvb_strsize(tvb, offset);
739                         proto_tree_add_item(tree, hf_backup_server,
740                                 tvb, offset, namelen, TRUE);
741                         offset += namelen;
742                 }
743                 break;
744
745         case BROWSE_MASTER_ANNOUNCEMENT:
746                 /* master browser server name */
747                 namelen = tvb_strsize(tvb, offset);
748                 proto_tree_add_item(tree, hf_mb_server_name,
749                         tvb, offset, namelen, TRUE);
750                 offset += namelen;
751                 break;
752
753         case BROWSE_RESETBROWSERSTATE_ANNOUNCEMENT: {
754                 proto_tree *sub_tree;
755                 proto_item *reset_item;
756
757                 /* the subcommand follows ... one of three values */
758
759                 reset_cmd = tvb_get_guint8(tvb, offset);
760                 reset_item = proto_tree_add_uint(tree, hf_mb_reset_command, tvb, 
761                                                  offset, 1, reset_cmd);
762                 sub_tree = proto_item_add_subtree(item, ett_browse_reset_cmd_flags);
763                 proto_tree_add_boolean(sub_tree, hf_mb_reset_demote, tvb, 
764                                        offset, 1, reset_cmd);
765                 proto_tree_add_boolean(sub_tree, hf_mb_reset_flush, tvb, 
766                                        offset, 1, reset_cmd);
767                 proto_tree_add_boolean(sub_tree, hf_mb_reset_stop, tvb, 
768                                        offset, 1, reset_cmd);
769                 offset += 1;
770                 break;
771         }
772
773         case BROWSE_BECOME_BACKUP:
774                 /* name of browser to promote */
775                 namelen = tvb_strsize(tvb, offset);
776                 proto_tree_add_item(tree, hf_browser_to_promote,
777                         tvb, offset, namelen, TRUE);
778                 offset += namelen;
779                 break;
780         }
781 }
782
783 /*
784  * It appears that browser announcements sent to \MAILSLOT\LANMAN aren't
785  * the same as browser announcements sent to \MAILSLOT\BROWSE.
786  * Was that an older version of the protocol?
787  *
788  * The document at
789  *
790  *      http://www.samba.org/samba/ftp/specs/brow_rev.txt
791  *
792  * gives both formats of host announcement packets, saying that
793  * "[The first] format seems wrong", that one being what appears to
794  * show up in \MAILSLOT\LANMAN packets, and that "[The second one]
795  * may be better", that one being what appears to show up in
796  * \MAILSLOT\BROWSE packets.
797  *
798  * XXX - what other browser packets go out to that mailslot?
799  */
800 static void
801 dissect_mailslot_lanman(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
802 {
803         int offset = 0;
804         guint8 cmd;
805         proto_tree *tree = NULL;
806         proto_item *item = NULL;
807         guint32 periodicity;
808         const guint8 *host_name;
809         guint namelen;
810
811         if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
812                 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BROWSER");
813         }
814         if (check_col(pinfo->cinfo, COL_INFO)) {
815                 col_clear(pinfo->cinfo, COL_INFO);
816         }
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                     "ResetBrowserState Command", HFILL }},
914                 { &hf_mb_reset_demote,
915                   { "Demote LMB", "browser.reset_cmd.demote", FT_BOOLEAN, 
916                     8, TFS(&tfs_demote_to_backup), 0x01, "Demote LMB", HFILL}}, 
917                 { &hf_mb_reset_flush,
918                   { "Flush Browse List", "browser.reset_cmd.flush", FT_BOOLEAN,
919                     8, TFS(&tfs_flush_browse_list), 0x02, "Flush Browse List", HFILL}},
920                 { &hf_mb_reset_stop,
921                   { "Stop Being LMB", "browser.reset_cmd.stop_lmb", FT_BOOLEAN,
922                     8, TFS(&tfs_stop_being_lmb), 0x04, "Stop Being LMB", 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_local,
1024                         { "Local", "browser.server_type.local", FT_BOOLEAN, 32,
1025                         TFS(&tfs_local), 1<<SERVER_LOCAL_LIST_ONLY, "Is This A Local List Only request?", HFILL }},
1026
1027                 { &hf_server_type_domainenum,
1028                         { "Domain Enum", "browser.server_type.domainenum", FT_BOOLEAN, 32,
1029                         TFS(&tfs_domainenum), 1<<SERVER_DOMAIN_ENUM, "Is This A Domain Enum request?", HFILL }},
1030
1031                 { &hf_election_version,
1032                         { "Election Version", "browser.election.version", FT_UINT8, BASE_DEC,
1033                         NULL, 0, "Election Version", HFILL }},
1034
1035                 { &hf_proto_major,
1036                         { "Browser Protocol Major Version", "browser.proto_major", FT_UINT8, BASE_DEC,
1037                         NULL, 0, "Browser Protocol Major Version", HFILL }},
1038
1039                 { &hf_proto_minor,
1040                         { "Browser Protocol Minor Version", "browser.proto_minor", FT_UINT8, BASE_DEC,
1041                         NULL, 0, "Browser Protocol Minor Version", HFILL }},
1042
1043                 { &hf_sig_const,
1044                         { "Signature", "browser.sig", FT_UINT16, BASE_HEX,
1045                         NULL, 0, "Signature Constant", HFILL }},
1046
1047                 { &hf_server_comment,
1048                         { "Host Comment", "browser.comment", FT_STRINGZ, BASE_NONE,
1049                         NULL, 0, "Server Comment", HFILL }},
1050
1051                 { &hf_unused_flags,
1052                         { "Unused flags", "browser.unused", FT_UINT8, BASE_HEX,
1053                         NULL, 0, "Unused/unknown flags", HFILL }},
1054
1055                 { &hf_response_computer_name,
1056                         { "Response Computer Name", "browser.response_computer_name", FT_STRINGZ, BASE_NONE,
1057                         NULL, 0, "Response Computer Name", HFILL }},
1058
1059                 { &hf_election_criteria,
1060                         { "Election Criteria", "browser.election.criteria", FT_UINT32, BASE_HEX,
1061                         NULL, 0, "Election Criteria", HFILL }},
1062
1063                 { &hf_election_desire,
1064                         { "Election Desire", "browser.election.desire", FT_UINT8, BASE_HEX,
1065                         NULL, 0, "Election Desire", HFILL }},
1066
1067                 { &hf_election_desire_flags_backup,
1068                         { "Backup", "browser.election.desire.backup", FT_BOOLEAN, 8,
1069                         TFS(&tfs_desire_backup), 1<<DESIRE_BACKUP, "Is this a backup server", HFILL }},
1070
1071                 { &hf_election_desire_flags_standby,
1072                         { "Standby", "browser.election.desire.standby", FT_BOOLEAN, 8,
1073                         TFS(&tfs_desire_standby), 1<<DESIRE_STANDBY, "Is this a standby server?", HFILL }},
1074
1075                 { &hf_election_desire_flags_master,
1076                         { "Master", "browser.election.desire.master", FT_BOOLEAN, 8,
1077                         TFS(&tfs_desire_master), 1<<DESIRE_MASTER, "Is this a master server", HFILL }},
1078
1079                 { &hf_election_desire_flags_domain_master,
1080                         { "Domain Master", "browser.election.desire.domain_master", FT_BOOLEAN, 8,
1081                         TFS(&tfs_desire_domain_master), 1<<DESIRE_DOMAIN_MASTER, "Is this a domain master", HFILL }},
1082
1083                 { &hf_election_desire_flags_wins,
1084                         { "WINS", "browser.election.desire.wins", FT_BOOLEAN, 8,
1085                         TFS(&tfs_desire_wins), 1<<DESIRE_WINS, "Is this a WINS server", HFILL }},
1086
1087                 { &hf_election_desire_flags_nt,
1088                         { "NT", "browser.election.desire.nt", FT_BOOLEAN, 8,
1089                         TFS(&tfs_desire_nt), 1<<DESIRE_NT, "Is this a NT server", HFILL }},
1090
1091                 { &hf_election_revision,
1092                         { "Election Revision", "browser.election.revision", FT_UINT16, BASE_DEC,
1093                         NULL, 0, "Election Revision", HFILL }},
1094
1095                 { &hf_election_os,
1096                         { "Election OS", "browser.election.os", FT_UINT8, BASE_HEX,
1097                         NULL, 0, "Election OS", HFILL }},
1098
1099                 { &hf_election_os_wfw,
1100                         { "WfW", "browser.election.os.wfw", FT_BOOLEAN, 8,
1101                         TFS(&tfs_os_wfw), 1<<OS_WFW, "Is this a WfW host?", HFILL }},
1102
1103                 { &hf_election_os_ntw,
1104                         { "NT Workstation", "browser.election.os.ntw", FT_BOOLEAN, 8,
1105                         TFS(&tfs_os_ntw), 1<<OS_NTW, "Is this a NT Workstation?", HFILL }},
1106
1107                 { &hf_election_os_nts,
1108                         { "NT Server", "browser.election.os.nts", FT_BOOLEAN, 8,
1109                         TFS(&tfs_os_nts), 1<<OS_NTS, "Is this a NT Server?", HFILL }},
1110
1111                 { &hf_server_uptime,
1112                         { "Uptime", "browser.uptime", FT_UINT32, BASE_DEC,
1113                         NULL, 0, "Server uptime in ms", HFILL }},
1114
1115                 { &hf_backup_count,
1116                         { "Backup List Requested Count", "browser.backup.count", FT_UINT8, BASE_DEC,
1117                         NULL, 0, "Backup list requested count", HFILL }},
1118
1119                 { &hf_backup_token,
1120                         { "Backup Request Token", "browser.backup.token", FT_UINT32, BASE_DEC,
1121                         NULL, 0, "Backup requested/response token", HFILL }},
1122
1123                 { &hf_backup_server,
1124                         { "Backup Server", "browser.backup.server", FT_STRING, BASE_NONE,
1125                         NULL, 0, "Backup Server Name", HFILL }},
1126
1127                 { &hf_browser_to_promote,
1128                         { "Browser to Promote", "browser.browser_to_promote", FT_STRINGZ, BASE_NONE,
1129                         NULL, 0, "Browser to Promote", HFILL }},
1130
1131         };
1132
1133         static gint *ett[] = {
1134                 &ett_browse,
1135                 &ett_browse_flags,
1136                 &ett_browse_election_criteria,
1137                 &ett_browse_election_os,
1138                 &ett_browse_election_desire,
1139                 &ett_browse_reset_cmd_flags,
1140         };
1141
1142         proto_smb_browse = proto_register_protocol("Microsoft Windows Browser Protocol",
1143             "BROWSER", "browser");
1144
1145         proto_register_field_array(proto_smb_browse, hf, array_length(hf));
1146         proto_register_subtree_array(ett, array_length(ett));
1147
1148         register_dissector("mailslot_browse", dissect_mailslot_browse,
1149             proto_smb_browse);
1150         register_dissector("mailslot_lanman", dissect_mailslot_lanman,
1151             proto_smb_browse);
1152 }