2 * Routines for mount dissection
4 * $Id: packet-mount.c,v 1.6 1999/11/19 23:23:41 guy Exp $
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@unicom.net>
8 * Copyright 1998 Gerald Combs
10 * Copied from packet-smb.c
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 #ifdef HAVE_SYS_TYPES_H
33 #include <sys/types.h>
37 #include "packet-rpc.h"
38 #include "packet-mount.h"
39 #include "packet-nfs.h"
42 static int proto_mount = -1;
43 static int hf_mount_path = -1;
44 static int hf_mount_status = -1;
45 static int hf_mount_flavors = -1;
46 static int hf_mount_flavor = -1;
48 static gint ett_mount = -1;
50 int dissect_mount_dirpath_call(const u_char *pd, int offset, frame_data *fd,
55 offset = dissect_rpc_string(pd,offset,fd,tree,hf_mount_path);
62 /* proc number, "proc name", dissect_request, dissect_reply */
63 /* NULL as function pointer means: take the generic one. */
64 /* Mount protocol version 1, RFC 1094 */
65 const vsff mount1_proc[] = {
66 { 0, "NULL", NULL, NULL },
67 { MOUNTPROC_MNT, "MNT",
68 dissect_mount_dirpath_call, NULL },
69 { MOUNTPROC_DUMP, "DUMP",
71 { MOUNTPROC_UMNT, "UMNT",
72 dissect_mount_dirpath_call, NULL },
73 { MOUNTPROC_UMNTALL, "UMNTALL",
75 { MOUNTPROC_EXPORT, "EXPORT",
77 { 0, NULL, NULL, NULL }
79 /* end of mount version 1 */
82 /* RFC 1813, Page 107 */
83 static const value_string mount3_mountstat3[] =
92 { 63, "ERR_NAMETOOLONG" },
93 { 10004, "ERR_NOTSUPP" },
94 { 10006, "ERR_SERVERFAULT" },
99 /* RFC 1813, Page 107 */
101 dissect_mountstat3(const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
102 int hfindex, guint32* status)
106 if (!BYTES_ARE_IN_FRAME(offset,4)) return offset;
107 mountstat3 = EXTRACT_UINT(pd, offset+0);
110 proto_tree_add_item(tree, hfindex, offset, 4, mountstat3);
114 *status = mountstat3;
119 /* RFC 1831, Page 109 */
120 int dissect_mount3_mnt_reply(const u_char *pd, int offset, frame_data *fd,
124 guint32 auth_flavors;
126 guint32 auth_flavor_i;
128 offset = dissect_mountstat3(pd, offset, fd, tree, hf_mount_status, &status);
131 offset = dissect_nfs_fh3(pd,offset,fd,tree,"fhandle");
132 if (!BYTES_ARE_IN_FRAME(offset,4)) return offset;
133 auth_flavors = EXTRACT_UINT(pd,offset+0);
134 proto_tree_add_item(tree,hf_mount_flavors,
135 offset, 4, auth_flavors);
137 for (auth_flavor_i = 0 ; auth_flavor_i < hf_mount_flavors ; auth_flavor_i++) {
138 if (!BYTES_ARE_IN_FRAME(offset,4)) return offset;
139 auth_flavor = EXTRACT_UINT(pd,offset+0);
140 proto_tree_add_item(tree,hf_mount_flavor,
141 offset, 4, auth_flavor);
153 /* Mount protocol version 3, RFC 1813 */
154 const vsff mount3_proc[] = {
155 { 0, "NULL", NULL, NULL },
156 { MOUNTPROC_MNT, "MNT",
157 dissect_mount_dirpath_call, dissect_mount3_mnt_reply },
158 { MOUNTPROC_DUMP, "DUMP",
160 { MOUNTPROC_UMNT, "UMNT",
161 dissect_mount_dirpath_call, NULL },
162 { MOUNTPROC_UMNTALL, "UMNTALL",
164 { MOUNTPROC_EXPORT, "EXPORT",
166 { 0, NULL, NULL, NULL }
168 /* end of Mount protocol version 3 */
172 proto_register_mount(void)
174 static hf_register_info hf[] = {
176 "Path", "mount.path", FT_STRING, BASE_DEC,
178 { &hf_mount_status, {
179 "Status", "mount.status", FT_UINT32, BASE_DEC,
180 VALS(mount3_mountstat3), 0, "Status" }},
181 { &hf_mount_flavors, {
182 "Flavors", "mount.flavors", FT_UINT32, BASE_DEC,
183 NULL, 0, "Flavors" }},
184 { &hf_mount_flavor, {
185 "Flavor", "mount.flavor", FT_UINT32, BASE_DEC,
186 VALS(rpc_auth_flavor), 0, "Flavor" }},
188 static gint *ett[] = {
192 proto_mount = proto_register_protocol("Mount Service", "mount");
193 proto_register_field_array(proto_mount, hf, array_length(hf));
194 proto_register_subtree_array(ett, array_length(ett));
196 /* Register the protocol as RPC */
197 rpc_init_prog(proto_mount, MOUNT_PROGRAM, ett_mount);
198 /* Register the procedure tables */
199 rpc_init_proc_table(MOUNT_PROGRAM, 1, mount1_proc);
200 rpc_init_proc_table(MOUNT_PROGRAM, 3, mount3_proc);