1 /* packet-smb-mailslot.c
2 * Routines for SMB mailslot packet dissection
3 * Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com>
5 * $Id: packet-smb-mailslot.c,v 1.19 2001/11/03 00:58:49 guy Exp $
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@ethereal.com>
9 * Copyright 1998 Gerald Combs
11 * Copied from packet-pop.c
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.
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.
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.
28 #include "packet-smb-common.h"
29 #include "packet-smb-mailslot.h"
30 #include "packet-smb-browse.h"
31 #include "packet-smb-logon.h"
32 #include "packet-smb-pipe.h"
34 static int proto_smb_msp = -1;
35 static int hf_opcode = -1;
36 static int hf_priority = -1;
37 static int hf_class = -1;
38 static int hf_size = -1;
39 static int hf_name = -1;
41 static int ett_smb_msp = -1;
43 static const value_string opcode_vals[] = {
44 {1, "Write Mail Slot"},
48 static const value_string class_vals[] = {
50 {2, "Unreliable & Broadcast"},
54 /* decode the SMB mail slot protocol */
56 dissect_mailslot_smb(tvbuff_t *setup_tvb, tvbuff_t *tvb, packet_info *pinfo,
57 proto_tree *parent_tree)
59 struct smb_info *smb_info = pinfo->private_data;
62 tvbuff_t *next_tvb = NULL;
67 if (!proto_is_protocol_enabled(proto_smb_msp)) {
70 pinfo->current_proto = "SMB Mailslot";
72 if (check_col(pinfo->fd, COL_PROTOCOL)) {
73 col_set_str(pinfo->fd, COL_PROTOCOL, "SMB Mailslot");
76 if (smb_info->data_offset < 0) {
78 col_set_str(pinfo->fd, COL_INFO, "Interim reply");
82 /* do the opcode field */
83 opcode = tvb_get_letohs(setup_tvb, offset);
85 if (check_col(pinfo->fd, COL_INFO)) {
86 col_add_str(pinfo->fd, COL_INFO,
87 val_to_str(opcode, opcode_vals, "Unknown opcode:0x%04x"));
91 item = proto_tree_add_item(parent_tree, proto_smb_msp, setup_tvb,
92 offset, tvb_length_remaining(setup_tvb, offset), FALSE);
93 tree = proto_item_add_subtree(item, ett_smb_msp);
96 proto_tree_add_uint(tree, hf_opcode, setup_tvb, offset, 2,
101 proto_tree_add_item(tree, hf_priority, setup_tvb, offset, 2,
106 proto_tree_add_item(tree, hf_class, setup_tvb, offset, 2, TRUE);
110 proto_tree_add_item(tree, hf_size, setup_tvb, offset, 2, TRUE);
114 len = tvb_strsize(setup_tvb, offset);
115 proto_tree_add_item(tree, hf_name, setup_tvb, offset, len,
120 /* Quit if we don't have the transaction command name (mailslot path) */
121 if (smb_info->trans_cmd == NULL) {
122 /* Dump it as data */
123 dissect_data(tvb, smb_info->data_offset, pinfo, parent_tree);
127 /* create new tvb for subdissector */
128 next_tvb = tvb_new_subset(tvb, smb_info->data_offset, -1, -1);
130 /*** Decide what dissector to call based upon the command value ***/
131 if (strcmp(smb_info->trans_cmd, "BROWSE") == 0) {
132 if (dissect_mailslot_browse(next_tvb, pinfo, parent_tree))
134 } else if (strcmp(smb_info->trans_cmd, "LANMAN") == 0) {
135 /* Decode a LANMAN browse */
136 if (dissect_mailslot_lanman(next_tvb, pinfo, parent_tree))
138 } else if ((strncmp(smb_info->trans_cmd, "NET", strlen("NET")) == 0) ||
139 (strcmp(smb_info->trans_cmd, "TEMP\\NETLOGON") == 0) ||
140 (strcmp(smb_info->trans_cmd, "MSSP") == 0)) {
141 /* NOTE: use TEMP\\NETLOGON and MSSP because they seems very common, */
142 /* NOTE: may need a look up list to check for the mailslot names passed */
143 /* by the logon request packet */
144 if (dissect_smb_logon(next_tvb, pinfo, parent_tree))
147 /* Dump it as data */
148 dissect_data(next_tvb, 0, pinfo, parent_tree);
153 register_proto_smb_mailslot(void)
155 static hf_register_info hf[] = {
157 { "Opcode", "mailslot.opcode", FT_UINT16, BASE_DEC,
158 VALS(opcode_vals), 0, "MAILSLOT OpCode", HFILL }},
161 { "Priority", "mailslot.priority", FT_UINT16, BASE_DEC,
162 NULL, 0, "MAILSLOT Priority of transaction", HFILL }},
165 { "Class", "mailslot.class", FT_UINT16, BASE_DEC,
166 VALS(class_vals), 0, "MAILSLOT Class of transaction", HFILL }},
169 { "Size", "mailslot.size", FT_UINT16, BASE_DEC,
170 NULL, 0, "MAILSLOT Total size of mail data", HFILL }},
173 { "Mailslot Name", "mailslot.name", FT_STRING, BASE_NONE,
174 NULL, 0, "MAILSLOT Name of mailslot", HFILL }},
178 static gint *ett[] = {
182 proto_smb_msp = proto_register_protocol(
183 "SMB MailSlot Protocol", "SMB Mailslot", "mailslot");
185 proto_register_field_array(proto_smb_msp, hf, array_length(hf));
186 proto_register_subtree_array(ett, array_length(ett));