2 * Routines for PCNFSD dissection
4 * $Id: packet-pcnfsd.c,v 1.12 2002/11/01 00:48:38 sahlberg 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
40 #include "packet-rpc.h"
41 #include "packet-pcnfsd.h"
43 static int proto_pcnfsd = -1;
44 static int hf_pcnfsd_procedure_v1 = -1;
45 static int hf_pcnfsd_procedure_v2 = -1;
46 static int hf_pcnfsd_auth_client = -1;
47 static int hf_pcnfsd_auth_ident_obscure = -1;
48 static int hf_pcnfsd_auth_ident_clear = -1;
49 static int hf_pcnfsd_auth_password_obscure = -1;
50 static int hf_pcnfsd_auth_password_clear = -1;
51 static int hf_pcnfsd_comment = -1;
52 static int hf_pcnfsd_status = -1;
53 static int hf_pcnfsd_uid = -1;
54 static int hf_pcnfsd_gid = -1;
55 static int hf_pcnfsd_gids_count = -1;
56 static int hf_pcnfsd_homedir = -1;
57 static int hf_pcnfsd_def_umask = -1;
58 static int hf_pcnfsd_username = -1;
61 static gint ett_pcnfsd = -1;
62 static gint ett_pcnfsd_auth_ident = -1;
63 static gint ett_pcnfsd_auth_password = -1;
64 static gint ett_pcnfsd_gids = -1;
67 dissect_pcnfsd_username(tvbuff_t *tvb, int offset, proto_tree *tree)
69 return dissect_rpc_string(tvb, tree, hf_pcnfsd_username, offset, NULL);
74 #define MAP_REQ_UNAME 2
75 #define MAP_REQ_GNAME 3
77 static const value_string names_mapreq[] =
79 { MAP_REQ_UID, "MAP_REQ_UID" },
80 { MAP_REQ_GID, "MAP_REQ_GID" },
81 { MAP_REQ_UNAME, "MAP_REQ_UNAME" },
82 { MAP_REQ_GNAME, "MAP_REQ_GNAME" },
87 dissect_pcnfsd_mapreq(tvbuff_t *tvb, int offset, proto_tree *tree)
91 mapreq = tvb_get_ntohl(tvb, offset + 0);
94 proto_tree_add_text(tree, tvb, offset, 4, "Request: %s (%u)",
95 val_to_str(mapreq, names_mapreq, "%u"), mapreq);
103 dissect_pcnfsd2_dissect_mapreq_arg_item(tvbuff_t *tvb, int offset,
104 packet_info *pinfo _U_, proto_tree *tree)
106 offset = dissect_pcnfsd_mapreq(tvb, offset, tree);
108 offset = dissect_rpc_uint32(tvb, tree, hf_pcnfsd_uid, offset);
110 offset = dissect_pcnfsd_username(tvb, offset, tree);
116 dissect_pcnfsd2_mapid_call(tvbuff_t *tvb, int offset, packet_info *pinfo,
119 offset = dissect_rpc_string(tvb, tree, hf_pcnfsd_comment, offset, NULL);
121 offset = dissect_rpc_list(tvb, pinfo, tree, offset,
122 dissect_pcnfsd2_dissect_mapreq_arg_item);
128 #define MAP_RES_UNKNOWN 1
129 #define MAP_RES_DENIED 2
131 static const value_string names_maprstat[] =
133 { MAP_RES_OK, "MAP_RES_OK" },
134 { MAP_RES_UNKNOWN, "MAP_RES_UNKNOWN" },
135 { MAP_RES_DENIED, "MAP_RES_DENIED" },
140 dissect_pcnfsd2_dissect_mapreq_res_item(tvbuff_t *tvb, int offset,
141 packet_info *pinfo _U_, proto_tree *tree)
145 offset = dissect_pcnfsd_mapreq(tvb, offset, tree);
147 maprstat = tvb_get_ntohl(tvb, offset + 0);
150 proto_tree_add_text(tree, tvb, offset, 4, "Status: %s (%u)",
151 val_to_str(maprstat, names_maprstat, "%u"), maprstat);
155 offset = dissect_rpc_uint32(tvb, tree, hf_pcnfsd_uid, offset);
157 offset = dissect_pcnfsd_username(tvb, offset, tree);
163 dissect_pcnfsd2_mapid_reply(tvbuff_t *tvb, int offset, packet_info *pinfo,
166 offset = dissect_rpc_string(tvb, tree, hf_pcnfsd_comment, offset, NULL);
168 offset = dissect_rpc_list(tvb, pinfo, tree, offset,
169 dissect_pcnfsd2_dissect_mapreq_res_item);
174 /* "NFS Illustrated 14.7.13 */
176 pcnfsd_decode_obscure(char* data, int len)
178 for ( ; len>0 ; len--, data++) {
179 *data = (*data ^ 0x5b) & 0x7f;
184 /* "NFS Illustrated" 14.7.13 */
186 dissect_pcnfsd2_auth_call(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
191 proto_item *ident_item = NULL;
192 proto_tree *ident_tree = NULL;
193 char *password = NULL;
194 proto_item *password_item = NULL;
195 proto_tree *password_tree = NULL;
197 offset = dissect_rpc_string(tvb, tree,
198 hf_pcnfsd_auth_client, offset, NULL);
201 ident_item = proto_tree_add_text(tree, tvb,
202 offset, -1, "Authentication Ident");
204 ident_tree = proto_item_add_subtree(
205 ident_item, ett_pcnfsd_auth_ident);
207 newoffset = dissect_rpc_string(tvb, ident_tree,
208 hf_pcnfsd_auth_ident_obscure, offset, &ident);
210 proto_item_set_len(ident_item, newoffset-offset);
214 pcnfsd_decode_obscure(ident, strlen(ident));
216 proto_tree_add_string(ident_tree,
217 hf_pcnfsd_auth_ident_clear,
218 tvb, offset+4, strlen(ident), ident);
221 proto_item_set_text(ident_item, "Authentication Ident: %s",
232 password_item = proto_tree_add_text(tree, tvb,
233 offset, -1, "Authentication Password");
235 password_tree = proto_item_add_subtree(
236 password_item, ett_pcnfsd_auth_password);
238 newoffset = dissect_rpc_string(tvb, password_tree,
239 hf_pcnfsd_auth_password_obscure, offset, &password);
241 proto_item_set_len(password_item, newoffset-offset);
245 pcnfsd_decode_obscure(password, strlen(password));
247 proto_tree_add_string(password_tree,
248 hf_pcnfsd_auth_password_clear,
249 tvb, offset+4, strlen(password), password);
252 proto_item_set_text(password_item, "Authentication Password: %s",
262 offset = dissect_rpc_string(tvb, tree,
263 hf_pcnfsd_comment, offset, NULL);
269 /* "NFS Illustrated" 14.7.13 */
271 dissect_pcnfsd2_auth_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
275 proto_item *gitem = NULL;
276 proto_tree *gtree = NULL;
279 offset = dissect_rpc_uint32(tvb, tree, hf_pcnfsd_status, offset);
280 offset = dissect_rpc_uint32(tvb, tree, hf_pcnfsd_uid, offset);
281 offset = dissect_rpc_uint32(tvb, tree, hf_pcnfsd_gid, offset);
282 gids_count = tvb_get_ntohl(tvb,offset+0);
284 gitem = proto_tree_add_text(tree, tvb,
285 offset, 4+gids_count*4, "Group IDs: %d", gids_count);
286 gtree = proto_item_add_subtree(gitem, ett_pcnfsd_gids);
289 proto_tree_add_item(gtree, hf_pcnfsd_gids_count, tvb, offset, 4, FALSE);
292 for (gids_i = 0 ; gids_i < gids_count ; gids_i++) {
293 offset = dissect_rpc_uint32(tvb, gtree,
294 hf_pcnfsd_gid, offset);
296 offset = dissect_rpc_string(tvb, tree,
297 hf_pcnfsd_homedir, offset, NULL);
298 /* should be signed int32 */
299 offset = dissect_rpc_uint32(tvb, tree, hf_pcnfsd_def_umask, offset);
300 offset = dissect_rpc_string(tvb, tree,
301 hf_pcnfsd_comment, offset, NULL);
307 /* "NFS Illustrated", 14.6 */
308 /* proc number, "proc name", dissect_request, dissect_reply */
309 /* NULL as function pointer means: type of arguments is "void". */
310 static const vsff pcnfsd1_proc[] = {
311 { 0, "NULL", NULL, NULL },
312 { 1, "AUTH", NULL, NULL },
313 { 2, "PR_INIT", NULL, NULL },
314 { 3, "PR_START", NULL, NULL },
315 { 0, NULL, NULL, NULL }
317 static const value_string pcnfsd1_proc_vals[] = {
324 /* end of PCNFS version 1 */
327 /* "NFS Illustrated", 14.7 */
328 static const vsff pcnfsd2_proc[] = {
329 { 0, "NULL", NULL, NULL },
330 { 1, "INFO", NULL, NULL },
331 { 2, "PR_INIT", NULL, NULL },
332 { 3, "PR_START", NULL, NULL },
333 { 4, "PR_LIST", NULL, NULL },
334 { 5, "PR_QUEUE", NULL, NULL },
335 { 6, "PR_STATUS", NULL, NULL },
336 { 7, "PR_CANCEL", NULL, NULL },
337 { 8, "PR_ADMIN", NULL, NULL },
338 { 9, "PR_REQUEUE", NULL, NULL },
339 { 10, "PR_HOLD", NULL, NULL },
340 { 11, "PR_RELEASE", NULL, NULL },
342 dissect_pcnfsd2_mapid_call, dissect_pcnfsd2_mapid_reply },
344 dissect_pcnfsd2_auth_call, dissect_pcnfsd2_auth_reply },
345 { 14, "ALERT", NULL, NULL },
346 { 0, NULL, NULL, NULL }
348 static const value_string pcnfsd2_proc_vals[] = {
360 { 11, "PR_RELEASE" },
366 /* end of PCNFS version 2 */
370 proto_register_pcnfsd(void)
372 static hf_register_info hf[] = {
373 { &hf_pcnfsd_procedure_v1, {
374 "V1 Procedure", "pcnfsd.procedure_v1", FT_UINT32, BASE_DEC,
375 VALS(pcnfsd1_proc_vals), 0, "V1 Procedure", HFILL }},
376 { &hf_pcnfsd_procedure_v2, {
377 "V2 Procedure", "pcnfsd.procedure_v2", FT_UINT32, BASE_DEC,
378 VALS(pcnfsd2_proc_vals), 0, "V2 Procedure", HFILL }},
379 { &hf_pcnfsd_auth_client, {
380 "Authentication Client", "pcnfsd.auth.client", FT_STRING, BASE_DEC,
381 NULL, 0, "Authentication Client", HFILL }},
382 { &hf_pcnfsd_auth_ident_obscure, {
383 "Obscure Ident", "pcnfsd.auth.ident.obscure", FT_STRING, BASE_DEC,
384 NULL, 0, "Athentication Obscure Ident", HFILL }},
385 { &hf_pcnfsd_auth_ident_clear, {
386 "Clear Ident", "pcnfsd.auth.ident.clear", FT_STRING, BASE_DEC,
387 NULL, 0, "Authentication Clear Ident", HFILL }},
388 { &hf_pcnfsd_auth_password_obscure, {
389 "Obscure Password", "pcnfsd.auth.password.obscure", FT_STRING, BASE_DEC,
390 NULL, 0, "Athentication Obscure Password", HFILL }},
391 { &hf_pcnfsd_auth_password_clear, {
392 "Clear Password", "pcnfsd.auth.password.clear", FT_STRING, BASE_DEC,
393 NULL, 0, "Authentication Clear Password", HFILL }},
394 { &hf_pcnfsd_comment, {
395 "Comment", "pcnfsd.comment", FT_STRING, BASE_DEC,
396 NULL, 0, "Comment", HFILL }},
397 { &hf_pcnfsd_status, {
398 "Reply Status", "pcnfsd.status", FT_UINT32, BASE_DEC,
399 NULL, 0, "Status", HFILL }},
401 "User ID", "pcnfsd.uid", FT_UINT32, BASE_DEC,
402 NULL, 0, "User ID", HFILL }},
404 "Group ID", "pcnfsd.gid", FT_UINT32, BASE_DEC,
405 NULL, 0, "Group ID", HFILL }},
406 { &hf_pcnfsd_gids_count, {
407 "Group ID Count", "pcnfsd.gids.count", FT_UINT32, BASE_DEC,
408 NULL, 0, "Group ID Count", HFILL }},
409 { &hf_pcnfsd_homedir, {
410 "Home Directory", "pcnfsd.homedir", FT_STRING, BASE_DEC,
411 NULL, 0, "Home Directory", HFILL }},
412 { &hf_pcnfsd_def_umask, {
413 "def_umask", "pcnfsd.def_umask", FT_INT32, BASE_OCT,
414 NULL, 0, "def_umask", HFILL }},
415 { &hf_pcnfsd_username, {
416 "User name", "pcnfsd.username", FT_STRING, BASE_DEC,
417 NULL, 0, "pcnfsd.username", HFILL }},
420 static gint *ett[] = {
422 &ett_pcnfsd_auth_ident,
423 &ett_pcnfsd_auth_password,
427 proto_pcnfsd = proto_register_protocol("PC NFS",
429 proto_register_field_array(proto_pcnfsd, hf, array_length(hf));
430 proto_register_subtree_array(ett, array_length(ett));
434 proto_reg_handoff_pcnfsd(void)
436 /* Register the protocol as RPC */
437 rpc_init_prog(proto_pcnfsd, PCNFSD_PROGRAM, ett_pcnfsd);
438 /* Register the procedure tables */
439 rpc_init_proc_table(PCNFSD_PROGRAM, 1, pcnfsd1_proc, hf_pcnfsd_procedure_v1);
440 rpc_init_proc_table(PCNFSD_PROGRAM, 2, pcnfsd2_proc, hf_pcnfsd_procedure_v2);