Get rid of a now-unused variable; it's the only variable of type
[obnox/wireshark/wip.git] / packet-smb-mailslot.c
1 /* packet-smb-mailslot.c
2  * Routines for SMB mailslot packet dissection
3  * Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com>
4  *
5  * $Id: packet-smb-mailslot.c,v 1.11 2001/03/18 03:34:22 guy Exp $
6  *
7  * Ethereal - Network traffic analyzer
8  * By Gerald Combs <gerald@zing.org>
9  * Copyright 1998 Gerald Combs
10  *
11  * Copied from packet-pop.c
12  * 
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.
17  * 
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.
22  * 
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.
26  */
27
28
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"
34
35 static int proto_smb_msp = -1;
36
37 static int ett_smb_msp = -1;
38
39 gboolean
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){
44
45
46 /* decode the SMB mail slot protocol */
47
48         proto_tree      *smb_msp_tree = 0;
49         proto_item      *ti;
50
51         guint16  Temp16; 
52         const char *StrPtr;
53
54         if (!proto_is_protocol_enabled(proto_smb_msp))
55                 return FALSE;
56    
57         if (check_col(fd, COL_PROTOCOL))
58                 col_set_str(fd, COL_PROTOCOL, "SMB Mailslot");
59
60         if (DataOffset < 0) {
61                 /* Interim reply */
62                 col_set_str(fd, COL_INFO, "Interim reply");
63                 return TRUE;
64         }
65
66  /* do the Op code field */
67  
68         Temp16 = GSHORT(pd, offset);            /* get Op code */
69
70         if (check_col(fd, COL_INFO))
71                   col_set_str(fd, COL_INFO,
72                       ( Temp16 == 1 ? "Write Mail slot" : "Unknown"));
73
74
75         if (tree) {
76                 ti = proto_tree_add_item( parent, proto_smb_msp, NullTVB, offset,
77                         END_OF_FRAME, FALSE);
78                 smb_msp_tree = proto_item_add_subtree(ti, ett_smb_msp);
79
80                 proto_tree_add_text(smb_msp_tree, NullTVB, offset, 2, "Op code: %u (%s)",
81                         Temp16, ( Temp16 == 1 ? "Write Mail slot" : "Unknown"));
82
83                 offset += 2;
84  
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);
89         
90                 offset += 2;
91
92                                                 /* do the Class field */
93                 Temp16 = GSHORT(pd, offset);
94      
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"));
98         
99                 offset += 2;
100
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);
105
106                 offset += 2;
107         }else {                                 /* no tree value adjust offset*/
108                 offset += 8;
109         }               
110
111                                         /* Build display for: MailSlot Name */
112
113         StrPtr = &pd[offset];           /* load pointer to name */
114
115         if (smb_msp_tree) {
116                 proto_tree_add_text(smb_msp_tree, NullTVB, offset, strlen( StrPtr) + 1,
117                         "Mailslot Name: %s", StrPtr);
118         }
119
120         offset += strlen( StrPtr) + 1;
121  
122 /*** Decide what dissector to call based upon the command value ***/
123  
124         if (command != NULL && strcmp(command, "BROWSE") == 0) { /* Decode a browse */
125
126                 return dissect_mailslot_browse(pd, offset, fd, parent, tree,
127                         si, max_data, SMB_offset, errcode, dirn, command,
128                         DataOffset, DataCount);
129         }
130
131         else if (command != NULL && strcmp(command, "LANMAN") == 0) {
132
133                 return dissect_pipe_lanman(pd, offset, fd, parent, tree, si,
134                         max_data, SMB_offset, errcode, dirn, command,
135                         DataOffset, DataCount, ParameterOffset, ParameterCount);
136         }
137
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 */
141         
142         else if (((command != NULL) &&
143                   strncmp(command, "NET", strlen("NET")) == 0) ||
144                  (strcmp(command, "TEMP\\NETLOGON") == 0) ||
145                  (strcmp(command, "MSSP") == 0)){
146
147                 return dissect_smb_logon(pd, DataOffset, fd, parent, tree,
148                         si, max_data, SMB_offset, errcode, dirn,
149                         command, DataOffset, DataCount);
150                 
151          }
152         return TRUE;
153 }
154
155
156 void
157 register_proto_smb_mailslot( void){
158
159
160         static gint *ett[] = {
161                 &ett_smb_msp
162         };
163
164         proto_smb_msp = proto_register_protocol(
165                 "SMB MailSlot Protocol", "SMB Mailslot", "mailslot");
166
167         proto_register_subtree_array(ett, array_length(ett));
168 }