1 /* packet-smb-mailslot.c
2 * Routines for SMB mailslot 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
17 #include <epan/packet.h>
18 #include "packet-smb.h"
19 #include "packet-smb-mailslot.h"
21 void proto_register_smb_mailslot(void);
22 void proto_reg_handoff_smb_mailslot(void);
24 static int proto_smb_msp
;
26 static int hf_priority
;
31 static int ett_smb_msp
;
33 static dissector_handle_t mailslot_browse_handle
;
34 static dissector_handle_t mailslot_lanman_handle
;
35 static dissector_handle_t netlogon_handle
;
37 #define MAILSLOT_UNKNOWN 0
38 #define MAILSLOT_BROWSE 1
39 #define MAILSLOT_LANMAN 2
40 #define MAILSLOT_NET 3
41 #define MAILSLOT_TEMP_NETLOGON 4
42 #define MAILSLOT_MSSP 5
44 static const value_string opcode_vals
[] = {
45 {1, "Write Mail Slot"},
49 static const value_string class_vals
[] = {
51 {2, "Unreliable & Broadcast"},
55 /* decode the SMB mail slot protocol
57 mailslot is the name of the mailslot, e.g. BROWSE
58 si->trans_subcmd is set to the symbolic constant matching the mailslot name.
61 si->trans_subcmd gives us which mailslot this response refers to.
65 dissect_mailslot_smb(tvbuff_t
*mshdr_tvb
, tvbuff_t
*setup_tvb
,
66 tvbuff_t
*tvb
, const char *mailslot
, packet_info
*pinfo
,
67 proto_tree
*parent_tree
, smb_info_t
* smb_info
)
69 smb_transact_info_t
*tri
;
71 proto_tree
*tree
= NULL
;
72 proto_item
*item
= NULL
;
77 if (!proto_is_protocol_enabled(find_protocol_by_id(proto_smb_msp
))) {
80 pinfo
->current_proto
= "SMB Mailslot";
82 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "SMB Mailslot");
84 if ((tvb
==NULL
) || (tvb_reported_length(tvb
)==0)) {
86 col_set_str(pinfo
->cinfo
, COL_INFO
, "Interim reply");
90 col_clear(pinfo
->cinfo
, COL_INFO
);
92 if (smb_info
->sip
!= NULL
&& smb_info
->sip
->extra_info_type
== SMB_EI_TRI
)
93 tri
= (smb_transact_info_t
*)smb_info
->sip
->extra_info
;
97 /* check which mailslot this is about */
98 trans_subcmd
=MAILSLOT_UNKNOWN
;
99 if(smb_info
->request
){
100 if(strncmp(mailslot
,"BROWSE",6) == 0){
101 trans_subcmd
=MAILSLOT_BROWSE
;
102 } else if(strncmp(mailslot
,"LANMAN",6) == 0){
103 trans_subcmd
=MAILSLOT_LANMAN
;
104 } else if(strncmp(mailslot
,"NET",3) == 0){
105 trans_subcmd
=MAILSLOT_NET
;
106 } else if(strncmp(mailslot
,"TEMP\\NETLOGON",13) == 0){
107 trans_subcmd
=MAILSLOT_TEMP_NETLOGON
;
108 } else if(strncmp(mailslot
,"MSSP",4) == 0){
109 trans_subcmd
=MAILSLOT_MSSP
;
111 if (!pinfo
->fd
->visited
) {
113 tri
->trans_subcmd
= trans_subcmd
;
119 trans_subcmd
= tri
->trans_subcmd
;
123 /* Only do these ones if we have them. For fragmented SMB Transactions
124 we may only have the setup area for the first fragment
126 if(mshdr_tvb
&& setup_tvb
){
128 item
= proto_tree_add_item(parent_tree
, proto_smb_msp
,
129 mshdr_tvb
, 0, -1, ENC_NA
);
130 tree
= proto_item_add_subtree(item
, ett_smb_msp
);
133 /* do the opcode field */
134 opcode
= tvb_get_letohs(setup_tvb
, offset
);
136 col_add_str(pinfo
->cinfo
, COL_INFO
,
137 val_to_str(opcode
, opcode_vals
, "Unknown opcode: 0x%04x"));
140 /* These are in the setup words; use "setup_tvb". */
143 proto_tree_add_uint(tree
, hf_opcode
, setup_tvb
, offset
, 2,
148 proto_tree_add_item(tree
, hf_priority
, setup_tvb
, offset
, 2,
153 proto_tree_add_item(tree
, hf_class
, setup_tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
156 /* These are in the rest of the data; use "mshdr_tvb", which
157 starts at the same place "setup_tvb" does. */
160 /* this is actually bytecount in the SMB Transaction command */
161 proto_tree_add_item(tree
, hf_size
, mshdr_tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
165 len
= tvb_strsize(mshdr_tvb
, offset
);
166 proto_tree_add_item(tree
, hf_name
, mshdr_tvb
, offset
, len
, ENC_ASCII
);
168 proto_item_set_len(item
, offset
);
171 switch(trans_subcmd
){
172 case MAILSLOT_BROWSE
:
173 call_dissector(mailslot_browse_handle
, tvb
, pinfo
,
177 case MAILSLOT_LANMAN
:
178 call_dissector(mailslot_lanman_handle
, tvb
, pinfo
,
183 case MAILSLOT_TEMP_NETLOGON
:
185 call_dissector(netlogon_handle
, tvb
, pinfo
,
191 * We dissected the mailslot header, but we don't know
192 * how to dissect the message; dissect the latter as data,
193 * but indicate that we successfully dissected the mailslot
196 call_data_dissector(tvb
, pinfo
, parent_tree
);
203 proto_register_smb_mailslot(void)
205 static hf_register_info hf
[] = {
207 { "Opcode", "mailslot.opcode", FT_UINT16
, BASE_DEC
,
208 VALS(opcode_vals
), 0, "MAILSLOT OpCode", HFILL
}},
211 { "Priority", "mailslot.priority", FT_UINT16
, BASE_DEC
,
212 NULL
, 0, "MAILSLOT Priority of transaction", HFILL
}},
215 { "Class", "mailslot.class", FT_UINT16
, BASE_DEC
,
216 VALS(class_vals
), 0, "MAILSLOT Class of transaction", HFILL
}},
219 { "Size", "mailslot.size", FT_UINT16
, BASE_DEC
,
220 NULL
, 0, "MAILSLOT Total size of mail data", HFILL
}},
223 { "Mailslot Name", "mailslot.name", FT_STRING
, BASE_NONE
,
224 NULL
, 0, "MAILSLOT Name of mailslot", HFILL
}},
228 static int *ett
[] = {
232 proto_smb_msp
= proto_register_protocol("SMB MailSlot Protocol", "SMB Mailslot", "mailslot");
234 proto_register_field_array(proto_smb_msp
, hf
, array_length(hf
));
235 proto_register_subtree_array(ett
, array_length(ett
));
239 proto_reg_handoff_smb_mailslot(void)
241 mailslot_browse_handle
= find_dissector_add_dependency("mailslot_browse", proto_smb_msp
);
242 mailslot_lanman_handle
= find_dissector_add_dependency("mailslot_lanman", proto_smb_msp
);
243 netlogon_handle
= find_dissector_add_dependency("smb_netlogon", proto_smb_msp
);
247 * Editor modelines - https://www.wireshark.org/tools/modelines.html
252 * indent-tabs-mode: t
255 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
256 * :indentSize=8:tabSize=8:noTabs=false: