2 * Routines for PCNFSD dissection
4 * $Id: packet-pcnfsd.c,v 1.8 2002/05/14 21:22:39 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;
61 static int hf_pcnfsd_username = -1;
64 static gint ett_pcnfsd = -1;
65 static gint ett_pcnfsd_auth_ident = -1;
66 static gint ett_pcnfsd_auth_password = -1;
67 static gint ett_pcnfsd_gids = -1;
70 dissect_pcnfsd_username(tvbuff_t *tvb, int offset, proto_tree *tree)
72 return dissect_rpc_string(tvb, tree, hf_pcnfsd_username, offset, NULL);
77 #define MAP_REQ_UNAME 2
78 #define MAP_REQ_GNAME 3
80 static const value_string names_mapreq[] =
82 { MAP_REQ_UID, "MAP_REQ_UID" },
83 { MAP_REQ_GID, "MAP_REQ_GID" },
84 { MAP_REQ_UNAME, "MAP_REQ_UNAME" },
85 { MAP_REQ_GNAME, "MAP_REQ_GNAME" },
90 dissect_pcnfsd_mapreq(tvbuff_t *tvb, int offset, proto_tree *tree)
94 mapreq = tvb_get_ntohl(tvb, offset + 0);
97 proto_tree_add_text(tree, tvb, offset, 4, "Request: %s (%u)",
98 val_to_str(mapreq, names_mapreq, "%u"), mapreq);
106 dissect_pcnfsd2_dissect_mapreq_arg_item(tvbuff_t *tvb, int offset,
107 packet_info *pinfo _U_, proto_tree *tree)
109 offset = dissect_pcnfsd_mapreq(tvb, offset, tree);
111 offset = dissect_rpc_uint32(tvb, tree, hf_pcnfsd_uid, offset);
113 offset = dissect_pcnfsd_username(tvb, offset, tree);
119 dissect_pcnfsd2_mapid_call(tvbuff_t *tvb, int offset, packet_info *pinfo,
122 offset = dissect_rpc_string(tvb, tree, hf_pcnfsd_comment, offset, NULL);
124 offset = dissect_rpc_list(tvb, pinfo, tree, offset,
125 dissect_pcnfsd2_dissect_mapreq_arg_item);
131 #define MAP_RES_UNKNOWN 1
132 #define MAP_RES_DENIED 2
134 static const value_string names_maprstat[] =
136 { MAP_RES_OK, "MAP_RES_OK" },
137 { MAP_RES_UNKNOWN, "MAP_RES_UNKNOWN" },
138 { MAP_RES_DENIED, "MAP_RES_DENIED" },
143 dissect_pcnfsd2_dissect_mapreq_res_item(tvbuff_t *tvb, int offset,
144 packet_info *pinfo _U_, proto_tree *tree)
148 offset = dissect_pcnfsd_mapreq(tvb, offset, tree);
150 maprstat = tvb_get_ntohl(tvb, offset + 0);
153 proto_tree_add_text(tree, tvb, offset, 4, "Status: %s (%u)",
154 val_to_str(maprstat, names_maprstat, "%u"), maprstat);
158 offset = dissect_rpc_uint32(tvb, tree, hf_pcnfsd_uid, offset);
160 offset = dissect_pcnfsd_username(tvb, offset, tree);
166 dissect_pcnfsd2_mapid_reply(tvbuff_t *tvb, int offset, packet_info *pinfo,
169 offset = dissect_rpc_string(tvb, tree, hf_pcnfsd_comment, offset, NULL);
171 offset = dissect_rpc_list(tvb, pinfo, tree, offset,
172 dissect_pcnfsd2_dissect_mapreq_res_item);
177 /* "NFS Illustrated 14.7.13 */
179 pcnfsd_decode_obscure(char* data, int len)
181 for ( ; len>0 ; len--, data++) {
182 *data = (*data ^ 0x5b) & 0x7f;
187 /* "NFS Illustrated" 14.7.13 */
189 dissect_pcnfsd2_auth_call(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
194 proto_item *ident_item = NULL;
195 proto_tree *ident_tree = NULL;
196 char *password = NULL;
197 proto_item *password_item = NULL;
198 proto_tree *password_tree = NULL;
200 offset = dissect_rpc_string(tvb, tree,
201 hf_pcnfsd_auth_client, offset, NULL);
204 ident_item = proto_tree_add_text(tree, tvb,
205 offset, -1, "Authentication Ident");
207 ident_tree = proto_item_add_subtree(
208 ident_item, ett_pcnfsd_auth_ident);
210 newoffset = dissect_rpc_string(tvb, ident_tree,
211 hf_pcnfsd_auth_ident_obscure, offset, &ident);
213 proto_item_set_len(ident_item, newoffset-offset);
217 pcnfsd_decode_obscure(ident, strlen(ident));
219 proto_tree_add_string(ident_tree,
220 hf_pcnfsd_auth_ident_clear,
221 tvb, offset+4, strlen(ident), ident);
224 proto_item_set_text(ident_item, "Authentication Ident: %s",
235 password_item = proto_tree_add_text(tree, tvb,
236 offset, -1, "Authentication Password");
238 password_tree = proto_item_add_subtree(
239 password_item, ett_pcnfsd_auth_password);
241 newoffset = dissect_rpc_string(tvb, password_tree,
242 hf_pcnfsd_auth_password_obscure, offset, &password);
244 proto_item_set_len(password_item, newoffset-offset);
248 pcnfsd_decode_obscure(password, strlen(password));
250 proto_tree_add_string(password_tree,
251 hf_pcnfsd_auth_password_clear,
252 tvb, offset+4, strlen(password), password);
255 proto_item_set_text(password_item, "Authentication Password: %s",
265 offset = dissect_rpc_string(tvb, tree,
266 hf_pcnfsd_comment, offset, NULL);
272 /* "NFS Illustrated" 14.7.13 */
274 dissect_pcnfsd2_auth_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
278 proto_item *gitem = NULL;
279 proto_tree *gtree = NULL;
282 offset = dissect_rpc_uint32(tvb, tree, hf_pcnfsd_status, offset);
283 offset = dissect_rpc_uint32(tvb, tree, hf_pcnfsd_uid, offset);
284 offset = dissect_rpc_uint32(tvb, tree, hf_pcnfsd_gid, offset);
285 gids_count = tvb_get_ntohl(tvb,offset+0);
287 gitem = proto_tree_add_text(tree, tvb,
288 offset, 4+gids_count*4, "Group IDs: %d", gids_count);
289 gtree = proto_item_add_subtree(gitem, ett_pcnfsd_gids);
292 proto_tree_add_item(gtree, hf_pcnfsd_gids_count, tvb, offset, 4, FALSE);
295 for (gids_i = 0 ; gids_i < gids_count ; gids_i++) {
296 offset = dissect_rpc_uint32(tvb, gtree,
297 hf_pcnfsd_gid, offset);
299 offset = dissect_rpc_string(tvb, tree,
300 hf_pcnfsd_homedir, offset, NULL);
301 /* should be signed int32 */
302 offset = dissect_rpc_uint32(tvb, tree, hf_pcnfsd_def_umask, offset);
303 offset = dissect_rpc_string(tvb, tree,
304 hf_pcnfsd_comment, offset, NULL);
310 /* "NFS Illustrated", 14.6 */
311 /* proc number, "proc name", dissect_request, dissect_reply */
312 /* NULL as function pointer means: type of arguments is "void". */
313 static const vsff pcnfsd1_proc[] = {
314 { 0, "NULL", NULL, NULL },
315 { 1, "AUTH", NULL, NULL },
316 { 2, "PR_INIT", NULL, NULL },
317 { 3, "PR_START", NULL, NULL },
318 { 0, NULL, NULL, NULL }
320 /* end of PCNFS version 1 */
323 /* "NFS Illustrated", 14.7 */
324 static const vsff pcnfsd2_proc[] = {
325 { 0, "NULL", NULL, NULL },
326 { 1, "INFO", NULL, NULL },
327 { 2, "PR_INIT", NULL, NULL },
328 { 3, "PR_START", NULL, NULL },
329 { 4, "PR_LIST", NULL, NULL },
330 { 5, "PR_QUEUE", NULL, NULL },
331 { 6, "PR_STATUS", NULL, NULL },
332 { 7, "PR_CANCEL", NULL, NULL },
333 { 8, "PR_ADMIN", NULL, NULL },
334 { 9, "PR_REQUEUE", NULL, NULL },
335 { 10, "PR_HOLD", NULL, NULL },
336 { 11, "PR_RELEASE", NULL, NULL },
338 dissect_pcnfsd2_mapid_call, dissect_pcnfsd2_mapid_reply },
340 dissect_pcnfsd2_auth_call, dissect_pcnfsd2_auth_reply },
341 { 14, "ALERT", NULL, NULL },
342 { 0, NULL, NULL, NULL }
344 /* end of PCNFS version 2 */
348 proto_register_pcnfsd(void)
350 static hf_register_info hf[] = {
351 { &hf_pcnfsd_auth_client, {
352 "Authentication Client", "pcnfsd.auth.client", FT_STRING, BASE_DEC,
353 NULL, 0, "Authentication Client", HFILL }},
354 { &hf_pcnfsd_auth_ident_obscure, {
355 "Obscure Ident", "pcnfsd.auth.ident.obscure", FT_STRING, BASE_DEC,
356 NULL, 0, "Athentication Obscure Ident", HFILL }},
357 { &hf_pcnfsd_auth_ident_clear, {
358 "Clear Ident", "pcnfsd.auth.ident.clear", FT_STRING, BASE_DEC,
359 NULL, 0, "Authentication Clear Ident", HFILL }},
360 { &hf_pcnfsd_auth_password_obscure, {
361 "Obscure Password", "pcnfsd.auth.password.obscure", FT_STRING, BASE_DEC,
362 NULL, 0, "Athentication Obscure Password", HFILL }},
363 { &hf_pcnfsd_auth_password_clear, {
364 "Clear Password", "pcnfsd.auth.password.clear", FT_STRING, BASE_DEC,
365 NULL, 0, "Authentication Clear Password", HFILL }},
366 { &hf_pcnfsd_comment, {
367 "Comment", "pcnfsd.comment", FT_STRING, BASE_DEC,
368 NULL, 0, "Comment", HFILL }},
369 { &hf_pcnfsd_status, {
370 "Reply Status", "pcnfsd.status", FT_UINT32, BASE_DEC,
371 NULL, 0, "Status", HFILL }},
373 "User ID", "pcnfsd.uid", FT_UINT32, BASE_DEC,
374 NULL, 0, "User ID", HFILL }},
376 "Group ID", "pcnfsd.gid", FT_UINT32, BASE_DEC,
377 NULL, 0, "Group ID", HFILL }},
378 { &hf_pcnfsd_gids_count, {
379 "Group ID Count", "pcnfsd.gids.count", FT_UINT32, BASE_DEC,
380 NULL, 0, "Group ID Count", HFILL }},
381 { &hf_pcnfsd_homedir, {
382 "Home Directory", "pcnfsd.homedir", FT_STRING, BASE_DEC,
383 NULL, 0, "Home Directory", HFILL }},
384 { &hf_pcnfsd_def_umask, {
385 "def_umask", "pcnfsd.def_umask", FT_INT32, BASE_OCT,
386 NULL, 0, "def_umask", HFILL }},
387 { &hf_pcnfsd_username, {
388 "User name", "pcnfsd.username", FT_STRING, BASE_DEC,
389 NULL, 0, "pcnfsd.username", HFILL }},
392 static gint *ett[] = {
394 &ett_pcnfsd_auth_ident,
395 &ett_pcnfsd_auth_password,
399 proto_pcnfsd = proto_register_protocol("PC NFS",
401 proto_register_field_array(proto_pcnfsd, hf, array_length(hf));
402 proto_register_subtree_array(ett, array_length(ett));
406 proto_reg_handoff_pcnfsd(void)
408 /* Register the protocol as RPC */
409 rpc_init_prog(proto_pcnfsd, PCNFSD_PROGRAM, ett_pcnfsd);
410 /* Register the procedure tables */
411 rpc_init_proc_table(PCNFSD_PROGRAM, 1, pcnfsd1_proc);
412 rpc_init_proc_table(PCNFSD_PROGRAM, 2, pcnfsd2_proc);