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.11 2001/03/18 03:34:22 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-browse.h"
32 #include "packet-smb-logon.h"
33 #include "packet-smb-pipe.h"
35 static int proto_smb_msp = -1;
37 static int ett_smb_msp = -1;
40 dissect_mailslot_smb(const u_char *pd, int offset, frame_data *fd,
41 proto_tree *parent, proto_tree *tree, struct smb_info si, int max_data,
42 int SMB_offset, int errcode, int dirn, const u_char *command,
43 int DataOffset, int DataCount, int ParameterOffset, int ParameterCount){
46 /* decode the SMB mail slot protocol */
48 proto_tree *smb_msp_tree = 0;
54 if (!proto_is_protocol_enabled(proto_smb_msp))
57 if (check_col(fd, COL_PROTOCOL))
58 col_set_str(fd, COL_PROTOCOL, "SMB Mailslot");
62 col_set_str(fd, COL_INFO, "Interim reply");
66 /* do the Op code field */
68 Temp16 = GSHORT(pd, offset); /* get Op code */
70 if (check_col(fd, COL_INFO))
71 col_set_str(fd, COL_INFO,
72 ( Temp16 == 1 ? "Write Mail slot" : "Unknown"));
76 ti = proto_tree_add_item( parent, proto_smb_msp, NullTVB, offset,
78 smb_msp_tree = proto_item_add_subtree(ti, ett_smb_msp);
80 proto_tree_add_text(smb_msp_tree, NullTVB, offset, 2, "Op code: %u (%s)",
81 Temp16, ( Temp16 == 1 ? "Write Mail slot" : "Unknown"));
85 /* do the Priority field */
86 Temp16 = GSHORT(pd, offset);
87 proto_tree_add_text(smb_msp_tree, NullTVB, offset, 2,
88 "Priority of transaction: %u", Temp16);
92 /* do the Class field */
93 Temp16 = GSHORT(pd, offset);
95 proto_tree_add_text(smb_msp_tree, NullTVB, offset, 2, "Class: %u (%s)",
96 Temp16, ( Temp16 == 1) ? "Reliable" : (( Temp16 == 2) ?
97 "Unreliable & Broadcast" : "Unknown"));
101 /* do the data size field */
102 Temp16 = GSHORT(pd, offset);
103 proto_tree_add_text(smb_msp_tree, NullTVB, offset, 2,
104 "Total size of mail data: %u", Temp16);
107 }else { /* no tree value adjust offset*/
111 /* Build display for: MailSlot Name */
113 StrPtr = &pd[offset]; /* load pointer to name */
116 proto_tree_add_text(smb_msp_tree, NullTVB, offset, strlen( StrPtr) + 1,
117 "Mailslot Name: %s", StrPtr);
120 offset += strlen( StrPtr) + 1;
122 /*** Decide what dissector to call based upon the command value ***/
124 if (command != NULL && strcmp(command, "BROWSE") == 0) { /* Decode a browse */
126 return dissect_mailslot_browse(pd, offset, fd, parent, tree,
127 si, max_data, SMB_offset, errcode, dirn, command,
128 DataOffset, DataCount);
131 else if (command != NULL && strcmp(command, "LANMAN") == 0) {
133 return dissect_pipe_lanman(pd, offset, fd, parent, tree, si,
134 max_data, SMB_offset, errcode, dirn, command,
135 DataOffset, DataCount, ParameterOffset, ParameterCount);
138 /* NOTE: use TEMP\\NETLOGON and MSSP because they seems very common, */
139 /* NOTE: may need a look up list to check for the mailslot names passed */
140 /* by the logon request packet */
142 else if (((command != NULL) &&
143 strncmp(command, "NET", strlen("NET")) == 0) ||
144 (strcmp(command, "TEMP\\NETLOGON") == 0) ||
145 (strcmp(command, "MSSP") == 0)){
147 return dissect_smb_logon(pd, DataOffset, fd, parent, tree,
148 si, max_data, SMB_offset, errcode, dirn,
149 command, DataOffset, DataCount);
157 register_proto_smb_mailslot( void){
160 static gint *ett[] = {
164 proto_smb_msp = proto_register_protocol(
165 "SMB MailSlot Protocol", "SMB Mailslot", "mailslot");
167 proto_register_subtree_array(ett, array_length(ett));