2 * Routines for PCNFSD dissection
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
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",
228 password_item = proto_tree_add_text(tree, tvb,
229 offset, -1, "Authentication Password");
231 password_tree = proto_item_add_subtree(
232 password_item, ett_pcnfsd_auth_password);
234 newoffset = dissect_rpc_string(tvb, password_tree,
235 hf_pcnfsd_auth_password_obscure, offset, &password);
237 proto_item_set_len(password_item, newoffset-offset);
241 pcnfsd_decode_obscure(password, strlen(password));
243 proto_tree_add_string(password_tree,
244 hf_pcnfsd_auth_password_clear,
245 tvb, offset+4, strlen(password), password);
248 proto_item_set_text(password_item, "Authentication Password: %s",
254 offset = dissect_rpc_string(tvb, tree,
255 hf_pcnfsd_comment, offset, NULL);
261 /* "NFS Illustrated" 14.7.13 */
263 dissect_pcnfsd2_auth_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
267 proto_item *gitem = NULL;
268 proto_tree *gtree = NULL;
271 offset = dissect_rpc_uint32(tvb, tree, hf_pcnfsd_status, offset);
272 offset = dissect_rpc_uint32(tvb, tree, hf_pcnfsd_uid, offset);
273 offset = dissect_rpc_uint32(tvb, tree, hf_pcnfsd_gid, offset);
274 gids_count = tvb_get_ntohl(tvb,offset+0);
276 gitem = proto_tree_add_text(tree, tvb,
277 offset, 4+gids_count*4, "Group IDs: %d", gids_count);
278 gtree = proto_item_add_subtree(gitem, ett_pcnfsd_gids);
281 proto_tree_add_item(gtree, hf_pcnfsd_gids_count, tvb, offset, 4, FALSE);
284 for (gids_i = 0 ; gids_i < gids_count ; gids_i++) {
285 offset = dissect_rpc_uint32(tvb, gtree,
286 hf_pcnfsd_gid, offset);
288 offset = dissect_rpc_string(tvb, tree,
289 hf_pcnfsd_homedir, offset, NULL);
290 /* should be signed int32 */
291 offset = dissect_rpc_uint32(tvb, tree, hf_pcnfsd_def_umask, offset);
292 offset = dissect_rpc_string(tvb, tree,
293 hf_pcnfsd_comment, offset, NULL);
299 /* "NFS Illustrated", 14.6 */
300 /* proc number, "proc name", dissect_request, dissect_reply */
301 /* NULL as function pointer means: type of arguments is "void". */
302 static const vsff pcnfsd1_proc[] = {
303 { 0, "NULL", NULL, NULL },
304 { 1, "AUTH", NULL, NULL },
305 { 2, "PR_INIT", NULL, NULL },
306 { 3, "PR_START", NULL, NULL },
307 { 0, NULL, NULL, NULL }
309 static const value_string pcnfsd1_proc_vals[] = {
316 /* end of PCNFS version 1 */
319 /* "NFS Illustrated", 14.7 */
320 static const vsff pcnfsd2_proc[] = {
321 { 0, "NULL", NULL, NULL },
322 { 1, "INFO", NULL, NULL },
323 { 2, "PR_INIT", NULL, NULL },
324 { 3, "PR_START", NULL, NULL },
325 { 4, "PR_LIST", NULL, NULL },
326 { 5, "PR_QUEUE", NULL, NULL },
327 { 6, "PR_STATUS", NULL, NULL },
328 { 7, "PR_CANCEL", NULL, NULL },
329 { 8, "PR_ADMIN", NULL, NULL },
330 { 9, "PR_REQUEUE", NULL, NULL },
331 { 10, "PR_HOLD", NULL, NULL },
332 { 11, "PR_RELEASE", NULL, NULL },
334 dissect_pcnfsd2_mapid_call, dissect_pcnfsd2_mapid_reply },
336 dissect_pcnfsd2_auth_call, dissect_pcnfsd2_auth_reply },
337 { 14, "ALERT", NULL, NULL },
338 { 0, NULL, NULL, NULL }
340 static const value_string pcnfsd2_proc_vals[] = {
352 { 11, "PR_RELEASE" },
358 /* end of PCNFS version 2 */
362 proto_register_pcnfsd(void)
364 static hf_register_info hf[] = {
365 { &hf_pcnfsd_procedure_v1, {
366 "V1 Procedure", "pcnfsd.procedure_v1", FT_UINT32, BASE_DEC,
367 VALS(pcnfsd1_proc_vals), 0, "V1 Procedure", HFILL }},
368 { &hf_pcnfsd_procedure_v2, {
369 "V2 Procedure", "pcnfsd.procedure_v2", FT_UINT32, BASE_DEC,
370 VALS(pcnfsd2_proc_vals), 0, "V2 Procedure", HFILL }},
371 { &hf_pcnfsd_auth_client, {
372 "Authentication Client", "pcnfsd.auth.client", FT_STRING, BASE_DEC,
373 NULL, 0, "Authentication Client", HFILL }},
374 { &hf_pcnfsd_auth_ident_obscure, {
375 "Obscure Ident", "pcnfsd.auth.ident.obscure", FT_STRING, BASE_DEC,
376 NULL, 0, "Authentication Obscure Ident", HFILL }},
377 { &hf_pcnfsd_auth_ident_clear, {
378 "Clear Ident", "pcnfsd.auth.ident.clear", FT_STRING, BASE_DEC,
379 NULL, 0, "Authentication Clear Ident", HFILL }},
380 { &hf_pcnfsd_auth_password_obscure, {
381 "Obscure Password", "pcnfsd.auth.password.obscure", FT_STRING, BASE_DEC,
382 NULL, 0, "Authentication Obscure Password", HFILL }},
383 { &hf_pcnfsd_auth_password_clear, {
384 "Clear Password", "pcnfsd.auth.password.clear", FT_STRING, BASE_DEC,
385 NULL, 0, "Authentication Clear Password", HFILL }},
386 { &hf_pcnfsd_comment, {
387 "Comment", "pcnfsd.comment", FT_STRING, BASE_DEC,
388 NULL, 0, "Comment", HFILL }},
389 { &hf_pcnfsd_status, {
390 "Reply Status", "pcnfsd.status", FT_UINT32, BASE_DEC,
391 NULL, 0, "Status", HFILL }},
393 "User ID", "pcnfsd.uid", FT_UINT32, BASE_DEC,
394 NULL, 0, "User ID", HFILL }},
396 "Group ID", "pcnfsd.gid", FT_UINT32, BASE_DEC,
397 NULL, 0, "Group ID", HFILL }},
398 { &hf_pcnfsd_gids_count, {
399 "Group ID Count", "pcnfsd.gids.count", FT_UINT32, BASE_DEC,
400 NULL, 0, "Group ID Count", HFILL }},
401 { &hf_pcnfsd_homedir, {
402 "Home Directory", "pcnfsd.homedir", FT_STRING, BASE_DEC,
403 NULL, 0, "Home Directory", HFILL }},
404 { &hf_pcnfsd_def_umask, {
405 "def_umask", "pcnfsd.def_umask", FT_UINT32, BASE_OCT,
406 NULL, 0, "def_umask", HFILL }},
407 { &hf_pcnfsd_username, {
408 "User name", "pcnfsd.username", FT_STRING, BASE_DEC,
409 NULL, 0, "pcnfsd.username", HFILL }},
412 static gint *ett[] = {
414 &ett_pcnfsd_auth_ident,
415 &ett_pcnfsd_auth_password,
419 proto_pcnfsd = proto_register_protocol("PC NFS",
421 proto_register_field_array(proto_pcnfsd, hf, array_length(hf));
422 proto_register_subtree_array(ett, array_length(ett));
426 proto_reg_handoff_pcnfsd(void)
428 /* Register the protocol as RPC */
429 rpc_init_prog(proto_pcnfsd, PCNFSD_PROGRAM, ett_pcnfsd);
430 /* Register the procedure tables */
431 rpc_init_proc_table(PCNFSD_PROGRAM, 1, pcnfsd1_proc, hf_pcnfsd_procedure_v1);
432 rpc_init_proc_table(PCNFSD_PROGRAM, 2, pcnfsd2_proc, hf_pcnfsd_procedure_v2);