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.10 2001/03/18 03:23:30 guy Exp $
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@zing.org>
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.
29 #include "packet-smb-common.h"
30 #include "packet-smb-mailslot.h"
31 #include "packet-smb-pipe.h"
33 static int proto_smb_msp = -1;
35 static int ett_smb_msp = -1;
38 /*** External dissectors called from here */
41 dissect_mailslot_browse(const u_char *pd, int offset, frame_data *fd,
42 proto_tree *parent, proto_tree *tree, struct smb_info si, int max_data,
43 int SMB_offset, int errcode, int dirn, const u_char *command,
44 int DataOffset, int DataCount);
47 dissect_smb_ntlogon(const u_char *pd, int offset, frame_data *fd,
48 proto_tree *parent, proto_tree *tree, struct smb_info si, int max_data,
49 int SMB_offset, int errcode, int dirn, const u_char *command,
50 int DataOffset, int DataCount);
54 dissect_smb_logon(const u_char *pd, int offset, frame_data *fd,
55 proto_tree *parent, proto_tree *tree, struct smb_info si, int max_data,
56 int SMB_offset, int errcode, int dirn, const u_char *command,
57 int DataOffset, int DataCount);
62 dissect_mailslot_smb(const u_char *pd, int offset, frame_data *fd,
63 proto_tree *parent, proto_tree *tree, struct smb_info si, int max_data,
64 int SMB_offset, int errcode, int dirn, const u_char *command,
65 int DataOffset, int DataCount, int ParameterOffset, int ParameterCount){
68 /* decode the SMB mail slot protocol */
70 proto_tree *smb_msp_tree = 0;
76 if (!proto_is_protocol_enabled(proto_smb_msp))
79 if (check_col(fd, COL_PROTOCOL))
80 col_set_str(fd, COL_PROTOCOL, "SMB Mailslot");
84 col_set_str(fd, COL_INFO, "Interim reply");
88 /* do the Op code field */
90 Temp16 = GSHORT(pd, offset); /* get Op code */
92 if (check_col(fd, COL_INFO))
93 col_set_str(fd, COL_INFO,
94 ( Temp16 == 1 ? "Write Mail slot" : "Unknown"));
98 ti = proto_tree_add_item( parent, proto_smb_msp, NullTVB, offset,
100 smb_msp_tree = proto_item_add_subtree(ti, ett_smb_msp);
102 proto_tree_add_text(smb_msp_tree, NullTVB, offset, 2, "Op code: %u (%s)",
103 Temp16, ( Temp16 == 1 ? "Write Mail slot" : "Unknown"));
107 /* do the Priority field */
108 Temp16 = GSHORT(pd, offset);
109 proto_tree_add_text(smb_msp_tree, NullTVB, offset, 2,
110 "Priority of transaction: %u", Temp16);
114 /* do the Class field */
115 Temp16 = GSHORT(pd, offset);
117 proto_tree_add_text(smb_msp_tree, NullTVB, offset, 2, "Class: %u (%s)",
118 Temp16, ( Temp16 == 1) ? "Reliable" : (( Temp16 == 2) ?
119 "Unreliable & Broadcast" : "Unknown"));
123 /* do the data size field */
124 Temp16 = GSHORT(pd, offset);
125 proto_tree_add_text(smb_msp_tree, NullTVB, offset, 2,
126 "Total size of mail data: %u", Temp16);
129 }else { /* no tree value adjust offset*/
133 /* Build display for: MailSlot Name */
135 StrPtr = &pd[offset]; /* load pointer to name */
138 proto_tree_add_text(smb_msp_tree, NullTVB, offset, strlen( StrPtr) + 1,
139 "Mailslot Name: %s", StrPtr);
142 offset += strlen( StrPtr) + 1;
144 /*** Decide what dissector to call based upon the command value ***/
146 if (command != NULL && strcmp(command, "BROWSE") == 0) { /* Decode a browse */
148 return dissect_mailslot_browse(pd, offset, fd, parent, tree,
149 si, max_data, SMB_offset, errcode, dirn, command,
150 DataOffset, DataCount);
153 else if (command != NULL && strcmp(command, "LANMAN") == 0) {
155 return dissect_pipe_lanman(pd, offset, fd, parent, tree, si,
156 max_data, SMB_offset, errcode, dirn, command,
157 DataOffset, DataCount, ParameterOffset, ParameterCount);
160 /* NOTE: use TEMP\\NETLOGON and MSSP because they seems very common, */
161 /* NOTE: may need a look up list to check for the mailslot names passed */
162 /* by the logon request packet */
164 else if (((command != NULL) &&
165 strncmp(command, "NET", strlen("NET")) == 0) ||
166 (strcmp(command, "TEMP\\NETLOGON") == 0) ||
167 (strcmp(command, "MSSP") == 0)){
169 return dissect_smb_logon(pd, DataOffset, fd, parent, tree,
170 si, max_data, SMB_offset, errcode, dirn,
171 command, DataOffset, DataCount);
179 register_proto_smb_mailslot( void){
182 static gint *ett[] = {
186 proto_smb_msp = proto_register_protocol(
187 "SMB MailSlot Protocol", "SMB Mailslot", "mailslot");
189 proto_register_subtree_array(ett, array_length(ett));