2 * Routines for PCNFSD dissection
4 * $Id: packet-pcnfsd.c,v 1.5 2002/01/30 23:08:26 guy Exp $
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@ethereal.com>
8 * Copyright 1998 Gerald Combs
10 * Copied from packet-ypbind.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.
29 Protocol information comes from the book
30 "NFS Illustrated" by Brent Callaghan, ISBN 0-201-32570-5
38 #ifdef HAVE_SYS_TYPES_H
39 #include <sys/types.h>
44 #include "packet-rpc.h"
45 #include "packet-pcnfsd.h"
47 static int proto_pcnfsd = -1;
49 static int hf_pcnfsd_auth_client = -1;
50 static int hf_pcnfsd_auth_ident_obscure = -1;
51 static int hf_pcnfsd_auth_ident_clear = -1;
52 static int hf_pcnfsd_auth_password_obscure = -1;
53 static int hf_pcnfsd_auth_password_clear = -1;
54 static int hf_pcnfsd_comment = -1;
55 static int hf_pcnfsd_status = -1;
56 static int hf_pcnfsd_uid = -1;
57 static int hf_pcnfsd_gid = -1;
58 static int hf_pcnfsd_gids_count = -1;
59 static int hf_pcnfsd_homedir = -1;
60 static int hf_pcnfsd_def_umask = -1;
63 static gint ett_pcnfsd = -1;
64 static gint ett_pcnfsd_auth_ident = -1;
65 static gint ett_pcnfsd_auth_password = -1;
66 static gint ett_pcnfsd_gids = -1;
68 /* "NFS Illustrated 14.7.13 */
70 pcnfsd_decode_obscure(char* data, int len)
72 for ( ; len>0 ; len--, data++) {
73 *data = (*data ^ 0x5b) & 0x7f;
78 /* "NFS Illustrated" 14.7.13 */
80 dissect_pcnfsd2_auth_call(tvbuff_t *tvb, int offset, packet_info *pinfo,
85 proto_item *ident_item = NULL;
86 proto_tree *ident_tree = NULL;
87 char *password = NULL;
88 proto_item *password_item = NULL;
89 proto_tree *password_tree = NULL;
91 offset = dissect_rpc_string(tvb, pinfo, tree,
92 hf_pcnfsd_auth_client, offset, NULL);
95 ident_item = proto_tree_add_text(tree, tvb,
96 offset, -1, "Authentication Ident");
98 ident_tree = proto_item_add_subtree(
99 ident_item, ett_pcnfsd_auth_ident);
101 newoffset = dissect_rpc_string(tvb, pinfo, ident_tree,
102 hf_pcnfsd_auth_ident_obscure, offset, &ident);
104 proto_item_set_len(ident_item, newoffset-offset);
108 pcnfsd_decode_obscure(ident, strlen(ident));
110 proto_tree_add_string(ident_tree,
111 hf_pcnfsd_auth_ident_clear,
112 tvb, offset+4, strlen(ident), ident);
115 proto_item_set_text(ident_item, "Authentication Ident: %s",
126 password_item = proto_tree_add_text(tree, tvb,
127 offset, -1, "Authentication Password");
129 password_tree = proto_item_add_subtree(
130 password_item, ett_pcnfsd_auth_password);
132 newoffset = dissect_rpc_string(tvb, pinfo, password_tree,
133 hf_pcnfsd_auth_password_obscure, offset, &password);
135 proto_item_set_len(password_item, newoffset-offset);
139 pcnfsd_decode_obscure(password, strlen(password));
141 proto_tree_add_string(password_tree,
142 hf_pcnfsd_auth_password_clear,
143 tvb, offset+4, strlen(password), password);
146 proto_item_set_text(password_item, "Authentication Password: %s",
156 offset = dissect_rpc_string(tvb, pinfo, tree,
157 hf_pcnfsd_comment, offset, NULL);
163 /* "NFS Illustrated" 14.7.13 */
165 dissect_pcnfsd2_auth_reply(tvbuff_t *tvb, int offset, packet_info *pinfo,
169 proto_item *gitem = NULL;
170 proto_tree *gtree = NULL;
173 offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_pcnfsd_status, offset);
174 offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_pcnfsd_uid, offset);
175 offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_pcnfsd_gid, offset);
176 gids_count = tvb_get_ntohl(tvb,offset+0);
178 gitem = proto_tree_add_text(tree, tvb,
179 offset, 4+gids_count*4, "Group IDs: %d", gids_count);
180 gtree = proto_item_add_subtree(gitem, ett_pcnfsd_gids);
183 proto_tree_add_item(gtree, hf_pcnfsd_gids_count, tvb, offset, 4, FALSE);
186 for (gids_i = 0 ; gids_i < gids_count ; gids_i++) {
187 offset = dissect_rpc_uint32(tvb, pinfo, gtree,
188 hf_pcnfsd_gid, offset);
190 offset = dissect_rpc_string(tvb, pinfo, tree,
191 hf_pcnfsd_homedir, offset, NULL);
192 /* should be signed int32 */
193 offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_pcnfsd_def_umask, offset);
194 offset = dissect_rpc_string(tvb, pinfo, tree,
195 hf_pcnfsd_comment, offset, NULL);
201 /* "NFS Illustrated", 14.6 */
202 /* proc number, "proc name", dissect_request, dissect_reply */
203 /* NULL as function pointer means: type of arguments is "void". */
204 static const vsff pcnfsd1_proc[] = {
205 { 0, "NULL", NULL, NULL },
206 { 1, "AUTH", NULL, NULL },
207 { 2, "PR_INIT", NULL, NULL },
208 { 3, "PR_START", NULL, NULL },
209 { 0, NULL, NULL, NULL }
211 /* end of PCNFS version 1 */
214 /* "NFS Illustrated", 14.7 */
215 static const vsff pcnfsd2_proc[] = {
216 { 0, "NULL", NULL, NULL },
217 { 1, "INFO", NULL, NULL },
218 { 2, "PR_INIT", NULL, NULL },
219 { 3, "PR_START", NULL, NULL },
220 { 4, "PR_LIST", NULL, NULL },
221 { 5, "PR_QUEUE", NULL, NULL },
222 { 6, "PR_STATUS", NULL, NULL },
223 { 7, "PR_CANCEL", NULL, NULL },
224 { 8, "PR_ADMIN", NULL, NULL },
225 { 9, "PR_REQUEUE", NULL, NULL },
226 { 10, "PR_HOLD", NULL, NULL },
227 { 11, "PR_RELEASE", NULL, NULL },
228 { 12, "MAPID", NULL, NULL },
230 dissect_pcnfsd2_auth_call, dissect_pcnfsd2_auth_reply },
231 { 14, "ALERT", NULL, NULL },
232 { 0, NULL, NULL, NULL }
234 /* end of PCNFS version 2 */
238 proto_register_pcnfsd(void)
240 static hf_register_info hf[] = {
241 { &hf_pcnfsd_auth_client, {
242 "Authentication Client", "pcnfsd.auth.client", FT_STRING, BASE_DEC,
243 NULL, 0, "Authentication Client", HFILL }},
244 { &hf_pcnfsd_auth_ident_obscure, {
245 "Obscure Ident", "pcnfsd.auth.ident.obscure", FT_STRING, BASE_DEC,
246 NULL, 0, "Athentication Obscure Ident", HFILL }},
247 { &hf_pcnfsd_auth_ident_clear, {
248 "Clear Ident", "pcnfsd.auth.ident.clear", FT_STRING, BASE_DEC,
249 NULL, 0, "Authentication Clear Ident", HFILL }},
250 { &hf_pcnfsd_auth_password_obscure, {
251 "Obscure Password", "pcnfsd.auth.password.obscure", FT_STRING, BASE_DEC,
252 NULL, 0, "Athentication Obscure Password", HFILL }},
253 { &hf_pcnfsd_auth_password_clear, {
254 "Clear Password", "pcnfsd.auth.password.clear", FT_STRING, BASE_DEC,
255 NULL, 0, "Authentication Clear Password", HFILL }},
256 { &hf_pcnfsd_comment, {
257 "Comment", "pcnfsd.comment", FT_STRING, BASE_DEC,
258 NULL, 0, "Comment", HFILL }},
259 { &hf_pcnfsd_status, {
260 "Reply Status", "pcnfsd.status", FT_UINT32, BASE_DEC,
261 NULL, 0, "Status", HFILL }},
263 "User ID", "pcnfsd.uid", FT_UINT32, BASE_DEC,
264 NULL, 0, "User ID", HFILL }},
266 "Group ID", "pcnfsd.gid", FT_UINT32, BASE_DEC,
267 NULL, 0, "Group ID", HFILL }},
268 { &hf_pcnfsd_gids_count, {
269 "Group ID Count", "pcnfsd.gids.count", FT_UINT32, BASE_DEC,
270 NULL, 0, "Group ID Count", HFILL }},
271 { &hf_pcnfsd_homedir, {
272 "Home Directory", "pcnfsd.homedir", FT_STRING, BASE_DEC,
273 NULL, 0, "Home Directory", HFILL }},
274 { &hf_pcnfsd_def_umask, {
275 "def_umask", "pcnfsd.def_umask", FT_INT32, BASE_OCT,
276 NULL, 0, "def_umask", HFILL }},
279 static gint *ett[] = {
281 &ett_pcnfsd_auth_ident,
282 &ett_pcnfsd_auth_password,
286 proto_pcnfsd = proto_register_protocol("PC NFS",
288 proto_register_field_array(proto_pcnfsd, hf, array_length(hf));
289 proto_register_subtree_array(ett, array_length(ett));
293 proto_reg_handoff_pcnfsd(void)
295 /* Register the protocol as RPC */
296 rpc_init_prog(proto_pcnfsd, PCNFSD_PROGRAM, ett_pcnfsd);
297 /* Register the procedure tables */
298 rpc_init_proc_table(PCNFSD_PROGRAM, 1, pcnfsd1_proc);
299 rpc_init_proc_table(PCNFSD_PROGRAM, 2, pcnfsd2_proc);