2 * Common routines for smb packet dissection
3 * Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * Copied from packet-pop.c
11 * SPDX-License-Identifier: GPL-2.0-or-later
16 #include <epan/packet.h>
17 #include <epan/strutil.h>
18 #include "packet-smb-common.h"
20 #include "packet-dns.h"
23 * Share type values - used in LANMAN and in SRVSVC.
25 * XXX - should we dissect share type values, at least in SRVSVC, as
26 * a subtree with bitfields, as the 0x80000000 bit appears to be a
27 * hidden bit, with some number of bits at the bottom being the share
30 * Does LANMAN use that bit?
32 const value_string share_type_vals
[] = {
33 {0, "Directory tree"},
35 {2, "Communications device"},
37 {0x80000000, "Hidden Directory tree"},
38 {0x80000001, "Hidden Printer queue"},
39 {0x80000002, "Hidden Communications device"},
40 {0x80000003, "Hidden IPC"},
44 int display_ms_string(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, int offset
, int hf_index
, char **data
)
49 /* display a string from the tree and return the new offset */
51 str
= tvb_get_stringz_enc(pinfo
->pool
, tvb
, offset
, &len
, ENC_ASCII
);
52 proto_tree_add_string(tree
, hf_index
, tvb
, offset
, len
, str
);
54 /* Return a copy of the string if requested */
63 int display_unicode_string(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, int offset
, int hf_index
, char **data
)
68 /* display a unicode string from the tree and return new offset */
70 str
= tvb_get_stringz_enc(pinfo
->pool
, tvb
, offset
, &len
, ENC_UTF_16
|ENC_LITTLE_ENDIAN
);
71 proto_tree_add_string(tree
, hf_index
, tvb
, offset
, len
, str
);
73 /* Return a copy of the string if requested */
81 /* Max string length for displaying Unicode strings. */
82 #define MAX_UNICODE_STR_LEN 256
84 int dissect_ms_compressed_string(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, int offset
, int hf_index
,
89 const char *str
= NULL
;
91 /* The name data MUST start at offset 0 of the tvb */
92 compr_len
= get_dns_name(tvb
, offset
, MAX_UNICODE_STR_LEN
+3+1, 0, &str
, &str_len
);
93 proto_tree_add_string(tree
, hf_index
, tvb
, offset
, compr_len
, format_text(pinfo
->pool
, str
, str_len
));
98 return offset
+ compr_len
;
102 * Editor modelines - https://www.wireshark.org/tools/modelines.html
107 * indent-tabs-mode: t
110 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
111 * :indentSize=8:tabSize=8:noTabs=false: