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.8 2000/11/22 21:19:37 sharpe 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"
31 static int proto_smb_msp = -1;
33 static int ett_smb_msp = -1;
36 /*** External dissectors called from here */
39 dissect_mailslot_browse(const u_char *pd, int offset, frame_data *fd,
40 proto_tree *parent, proto_tree *tree, struct smb_info si, int max_data,
41 int SMB_offset, int errcode, int dirn, const u_char *command,
42 int DataOffset, int DataCount);
45 dissect_pipe_lanman(const u_char *pd, int offset, frame_data *fd,
46 proto_tree *parent, proto_tree *tree, struct smb_info si, int max_data,
47 int SMB_offset, int errcode, int dirn, const u_char *command,
48 int DataOffset, int DataCount, int ParameterOffset, int ParameterCount);
51 dissect_smb_ntlogon(const u_char *pd, int offset, frame_data *fd,
52 proto_tree *parent, proto_tree *tree, struct smb_info si, int max_data,
53 int SMB_offset, int errcode, int dirn, const u_char *command,
54 int DataOffset, int DataCount);
58 dissect_smb_logon(const u_char *pd, int offset, frame_data *fd,
59 proto_tree *parent, proto_tree *tree, struct smb_info si, int max_data,
60 int SMB_offset, int errcode, int dirn, const u_char *command,
61 int DataOffset, int DataCount);
66 dissect_mailslot_smb(const u_char *pd, int offset, frame_data *fd,
67 proto_tree *parent, proto_tree *tree, struct smb_info si, int max_data,
68 int SMB_offset, int errcode, int dirn, const u_char *command,
69 int DataOffset, int DataCount, int ParameterOffset, int ParameterCount){
72 /* decode the SMB mail slot protocol */
74 proto_tree *smb_msp_tree = 0;
80 if (!proto_is_protocol_enabled(proto_smb_msp))
83 /* do the Op code field */
85 Temp16 = GSHORT(pd, offset); /* get Op code */
87 if (check_col(fd, COL_PROTOCOL))
88 col_set_str(fd, COL_PROTOCOL, "SMB Mailslot");
90 if (check_col(fd, COL_INFO))
91 col_add_fstr(fd, COL_INFO, "%s",
92 ( Temp16 == 1 ? "Write Mail slot" : "Unknown"));
96 ti = proto_tree_add_item( parent, proto_smb_msp, NullTVB, offset,
98 smb_msp_tree = proto_item_add_subtree(ti, ett_smb_msp);
100 proto_tree_add_text(smb_msp_tree, NullTVB, offset, 2, "Op code: %u (%s)",
101 Temp16, ( Temp16 == 1 ? "Write Mail slot" : "Unknown"));
105 /* do the Priority field */
106 Temp16 = GSHORT(pd, offset);
107 proto_tree_add_text(smb_msp_tree, NullTVB, offset, 2,
108 "Priority of transaction: %u", Temp16);
112 /* do the Class field */
113 Temp16 = GSHORT(pd, offset);
115 proto_tree_add_text(smb_msp_tree, NullTVB, offset, 2, "Class: %u (%s)",
116 Temp16, ( Temp16 == 1) ? "Reliable" : (( Temp16 == 2) ?
117 "Unreliable & Broadcast" : "Unknown"));
121 /* do the data size field */
122 Temp16 = GSHORT(pd, offset);
123 proto_tree_add_text(smb_msp_tree, NullTVB, offset, 2,
124 "Total size of mail data: %u", Temp16);
127 }else { /* no tree value adjust offset*/
131 /* Build display for: MailSlot Name */
133 StrPtr = &pd[offset]; /* load pointer to name */
136 proto_tree_add_text(smb_msp_tree, NullTVB, offset, strlen( StrPtr) + 1,
137 "Mailslot Name: %s", StrPtr);
140 offset += strlen( StrPtr) + 1;
142 /*** Decide what dissector to call based upon the command value ***/
144 if (command != NULL && strcmp(command, "BROWSE") == 0) { /* Decode a browse */
146 return dissect_mailslot_browse(pd, offset, fd, parent, tree,
147 si, max_data, SMB_offset, errcode, dirn, command,
148 DataOffset, DataCount);
151 else if (command != NULL && strcmp(command, "LANMAN") == 0) {
153 return dissect_pipe_lanman(pd, offset, fd, parent, tree, si,
154 max_data, SMB_offset, errcode, dirn, command,
155 DataOffset, DataCount, ParameterOffset, ParameterCount);
158 /* NOTE: use TEMP\\NETLOGON and MSSP because they seems very common, */
159 /* NOTE: may need a look up list to check for the mailslot names passed */
160 /* by the logon request packet */
162 else if (((command != NULL) &&
163 strncmp(command, "NET", strlen("NET")) == 0) ||
164 (strcmp(command, "TEMP\\NETLOGON") == 0) ||
165 (strcmp(command, "MSSP") == 0)){
167 return dissect_smb_logon(pd, DataOffset, fd, parent, tree,
168 si, max_data, SMB_offset, errcode, dirn,
169 command, DataOffset, DataCount);
177 register_proto_smb_mailslot( void){
180 static gint *ett[] = {
184 proto_smb_msp = proto_register_protocol(
185 "SMB MailSlot Protocol", "mailslot");
187 proto_register_subtree_array(ett, array_length(ett));