Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-smb-common.c
blob92d100ae5c0c24b4b593474830fe22d1b075e3e5
1 /* packet-smb-common.c
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
14 #include "config.h"
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
28 * type?
30 * Does LANMAN use that bit?
32 const value_string share_type_vals[] = {
33 {0, "Directory tree"},
34 {1, "Printer queue"},
35 {2, "Communications device"},
36 {3, "IPC"},
37 {0x80000000, "Hidden Directory tree"},
38 {0x80000001, "Hidden Printer queue"},
39 {0x80000002, "Hidden Communications device"},
40 {0x80000003, "Hidden IPC"},
41 {0, NULL}
44 int display_ms_string(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int hf_index, char **data)
46 char *str;
47 int len;
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 */
56 if (data)
57 *data = str;
59 return offset+len;
63 int display_unicode_string(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int hf_index, char **data)
65 char *str;
66 int len;
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 */
75 if (data)
76 *data = str;
78 return offset+len;
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,
85 const char **data)
87 int compr_len;
88 int str_len;
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));
95 if (data)
96 *data = str;
98 return offset + compr_len;
102 * Editor modelines - https://www.wireshark.org/tools/modelines.html
104 * Local variables:
105 * c-basic-offset: 8
106 * tab-width: 8
107 * indent-tabs-mode: t
108 * End:
110 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
111 * :indentSize=8:tabSize=8:noTabs=false: