aboutsummaryrefslogtreecommitdiffstats
path: root/packet-smb-mailslot.c
blob: 9d37b6b2dd29bb36b09c34a71af71c0949acb0ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/* packet-smb-mailslot.c
 * Routines for smb mailslot packet dissection
 * Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com>
 *
 * $Id: packet-smb-mailslot.c,v 1.3 2000/02/14 04:21:04 guy Exp $
 *
 * Ethereal - Network traffic analyzer
 * By Gerald Combs <gerald@zing.org>
 * Copyright 1998 Gerald Combs
 *
 * Copied from packet-pop.c
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */


#include "packet-smb-common.h"

static int proto_smb_msp = -1;

static int ett_smb_msp = -1;


/***  External dissectors called from here	*/

extern guint32 
dissect_mailslot_browse(const u_char *pd, int offset, frame_data *fd,
	proto_tree *parent, proto_tree *tree, struct smb_info si, int max_data,
	int SMB_offset, int errcode, int dirn, const u_char *command,
	int DataOffset, int DataCount);

extern guint32 
dissect_pipe_lanman(const u_char *pd, int offset, frame_data *fd,
	proto_tree *parent, proto_tree *tree, struct smb_info si, int max_data,
	int SMB_offset, int errcode, int dirn, const u_char *command,
	int DataOffset, int DataCount, int ParameterOffset, int ParameterCount);

extern guint32 
dissect_smb_ntlogon(const u_char *pd, int offset, frame_data *fd,
	proto_tree *parent, proto_tree *tree, struct smb_info si, int max_data,
	int SMB_offset, int errcode, int dirn, const u_char *command,
	int DataOffset, int DataCount);


extern guint32 
dissect_smb_logon(const u_char *pd, int offset, frame_data *fd,
	proto_tree *parent, proto_tree *tree, struct smb_info si, int max_data,
	int SMB_offset, int errcode, int dirn, const u_char *command,
	int DataOffset, int DataCount);



guint32
dissect_mailslot_smb(const u_char *pd, int offset, frame_data *fd,
	proto_tree *parent, proto_tree *tree, struct smb_info si, int max_data,
	int SMB_offset, int errcode, int dirn, const u_char *command,
	int DataOffset, int DataCount, int ParameterOffset, int ParameterCount){


/* decode the SMB mail slot protocol */


   	proto_tree      *smb_msp_tree = 0;
   	proto_item      *ti;

   	guint16  Temp16; 
   	const char *StrPtr;
   
 /* do the Op code field */
 
    	Temp16 = GSHORT(pd, offset);		/* get Op code */

	if (check_col(fd, COL_PROTOCOL))
		col_add_str(fd, COL_PROTOCOL, "SMB Mailslot");

	if (check_col(fd, COL_INFO))
		  col_add_fstr(fd, COL_INFO, "%s",
		      ( Temp16 == 1 ? "Write Mail slot" : "Unknown"));


    	if (tree) {
		ti = proto_tree_add_item( parent, proto_smb_msp, offset,
			END_OF_FRAME, NULL);
		smb_msp_tree = proto_item_add_subtree(ti, ett_smb_msp);

 		proto_tree_add_text(smb_msp_tree, offset, 2, "Op code: %u (%s)",
 			Temp16, ( Temp16 == 1 ? "Write Mail slot" : "Unknown"));

	  	offset += 2;
 
   						/* do the Priority field */
     		Temp16 = GSHORT(pd, offset);
     		proto_tree_add_text(smb_msp_tree, offset, 2,
     			"Priority of transaction: %u", Temp16);
    	
   		offset += 2;

    						/* do the Class field */
      		Temp16 = GSHORT(pd, offset);
     
      		proto_tree_add_text(smb_msp_tree, offset, 2, "Class: %u (%s)",
      			Temp16, ( Temp16 == 1) ? "Reliable" : (( Temp16 == 2) ?
      			"Unreliable & Broadcast" : "Unknown"));
	
	   	offset += 2;

     			 			/* do the data size field */
     		Temp16 = GSHORT(pd, offset);
     		proto_tree_add_text(smb_msp_tree, offset, 2,
     			"Total size of mail data: %u", Temp16);

	   	offset += 2;
	}else {					/* no tree value adjust offset*/
		offset += 8;
	}	   	

    					/* Build display for: MailSlot Name */

    	StrPtr = &pd[offset];		/* load pointer to name	*/

 	if (smb_msp_tree) {
		proto_tree_add_text(smb_msp_tree, offset, strlen( StrPtr) + 1,
			"Mailslot Name: %s", StrPtr);
    	}

	offset += strlen( StrPtr) + 1;
 
/*** Decide what dissector to call based upon the command value ***/
 
  	if (strcmp(command, "BROWSE") == 0) { /* Decode a browse */

    		return dissect_mailslot_browse(pd, offset, fd, parent, tree,
    			si, max_data, SMB_offset, errcode, dirn, command,
    			DataOffset, DataCount);
  	}

  	else if (strcmp(command, "LANMAN") == 0) {

    		return dissect_pipe_lanman(pd, offset, fd, parent, tree, si,
    			max_data, SMB_offset, errcode, dirn, command,
    			DataOffset, DataCount, ParameterOffset, ParameterCount);
  	}

/* NOTE: use TEMP\\NETLOGON and MSSP because they seems very common,	*/
/* NOTE: may need a look up list to check for the mailslot names passed	*/
/*		by the logon request packet */
	
  	else if ((strncmp(command, "NET", strlen("NET")) == 0) 
			|| (strcmp(command, "TEMP\\NETLOGON") == 0)
			|| (strcmp(command, "MSSP") == 0)){

		return dissect_smb_logon(pd, DataOffset, fd, parent, tree,
			si, max_data, SMB_offset, errcode, dirn,
			command, DataOffset, DataCount);
		
	 }
  	return 1;
}


void
register_proto_smb_mailslot( void){


	static gint *ett[] = {
		&ett_smb_msp
	};

   	proto_smb_msp = proto_register_protocol(
   		"SMB MailSlot Protocol", "mailslot");

	proto_register_subtree_array(ett, array_length(ett));
}