2 * Routines for PCNFSD dissection
4 * $Id: packet-pcnfsd.c,v 1.3 2001/11/07 07:05:58 girlich Exp $
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@zing.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
39 #ifdef HAVE_SYS_TYPES_H
40 #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, tvb_length_remaining(tvb, offset),
97 "Authentication Ident");
99 ident_tree = proto_item_add_subtree(
100 ident_item, ett_pcnfsd_auth_ident);
102 newoffset = dissect_rpc_string(tvb, pinfo, ident_tree,
103 hf_pcnfsd_auth_ident_obscure, offset, &ident);
105 proto_item_set_len(ident_item, newoffset-offset);
109 pcnfsd_decode_obscure(ident, strlen(ident));
111 proto_tree_add_string(ident_tree,
112 hf_pcnfsd_auth_ident_clear,
113 tvb, offset+4, strlen(ident), ident);
116 proto_item_set_text(ident_item, "Authentication Ident: %s",
127 password_item = proto_tree_add_text(tree, tvb,
128 offset, tvb_length_remaining(tvb, offset),
129 "Authentication Password");
131 password_tree = proto_item_add_subtree(
132 password_item, ett_pcnfsd_auth_password);
134 newoffset = dissect_rpc_string(tvb, pinfo, password_tree,
135 hf_pcnfsd_auth_password_obscure, offset, &password);
137 proto_item_set_len(password_item, newoffset-offset);
141 pcnfsd_decode_obscure(password, strlen(password));
143 proto_tree_add_string(password_tree,
144 hf_pcnfsd_auth_password_clear,
145 tvb, offset+4, strlen(password), password);
148 proto_item_set_text(password_item, "Authentication Password: %s",
158 offset = dissect_rpc_string(tvb, pinfo, tree,
159 hf_pcnfsd_comment, offset, NULL);
165 /* "NFS Illustrated" 14.7.13 */
167 dissect_pcnfsd2_auth_reply(tvbuff_t *tvb, int offset, packet_info *pinfo,
171 proto_item *gitem = NULL;
172 proto_tree *gtree = NULL;
175 offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_pcnfsd_status, offset);
176 offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_pcnfsd_uid, offset);
177 offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_pcnfsd_gid, offset);
178 gids_count = tvb_get_ntohl(tvb,offset+0);
180 gitem = proto_tree_add_text(tree, tvb,
181 offset, 4+gids_count*4, "Group IDs: %d", gids_count);
182 gtree = proto_item_add_subtree(gitem, ett_pcnfsd_gids);
185 proto_tree_add_item(gtree, hf_pcnfsd_gids_count, tvb, offset, 4, FALSE);
188 for (gids_i = 0 ; gids_i < gids_count ; gids_i++) {
189 offset = dissect_rpc_uint32(tvb, pinfo, gtree,
190 hf_pcnfsd_gid, offset);
192 offset = dissect_rpc_string(tvb, pinfo, tree,
193 hf_pcnfsd_homedir, offset, NULL);
194 /* should be signed int32 */
195 offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_pcnfsd_def_umask, offset);
196 offset = dissect_rpc_string(tvb, pinfo, tree,
197 hf_pcnfsd_comment, offset, NULL);
203 /* "NFS Illustrated", 14.6 */
204 /* proc number, "proc name", dissect_request, dissect_reply */
205 /* NULL as function pointer means: type of arguments is "void". */
206 static const vsff pcnfsd1_proc[] = {
207 { 0, "NULL", NULL, NULL },
208 { 1, "AUTH", NULL, NULL },
209 { 2, "PR_INIT", NULL, NULL },
210 { 3, "PR_START", NULL, NULL },
211 { 0, NULL, NULL, NULL }
213 /* end of PCNFS version 1 */
216 /* "NFS Illustrated", 14.7 */
217 static const vsff pcnfsd2_proc[] = {
218 { 0, "NULL", NULL, NULL },
219 { 1, "INFO", NULL, NULL },
220 { 2, "PR_INIT", NULL, NULL },
221 { 3, "PR_START", NULL, NULL },
222 { 4, "PR_LIST", NULL, NULL },
223 { 5, "PR_QUEUE", NULL, NULL },
224 { 6, "PR_STATUS", NULL, NULL },
225 { 7, "PR_CANCEL", NULL, NULL },
226 { 8, "PR_ADMIN", NULL, NULL },
227 { 9, "PR_REQUEUE", NULL, NULL },
228 { 10, "PR_HOLD", NULL, NULL },
229 { 11, "PR_RELEASE", NULL, NULL },
230 { 12, "MAPID", NULL, NULL },
232 dissect_pcnfsd2_auth_call, dissect_pcnfsd2_auth_reply },
233 { 14, "ALERT", NULL, NULL },
234 { 0, NULL, NULL, NULL }
236 /* end of PCNFS version 2 */
240 proto_register_pcnfsd(void)
242 static hf_register_info hf[] = {
243 { &hf_pcnfsd_auth_client, {
244 "Authentication Client", "pcnfsd.auth.client", FT_STRING, BASE_DEC,
245 NULL, 0, "Authentication Client", HFILL }},
246 { &hf_pcnfsd_auth_ident_obscure, {
247 "Obscure Ident", "pcnfsd.auth.ident.obscure", FT_STRING, BASE_DEC,
248 NULL, 0, "Athentication Obscure Ident", HFILL }},
249 { &hf_pcnfsd_auth_ident_clear, {
250 "Clear Ident", "pcnfsd.auth.ident.clear", FT_STRING, BASE_DEC,
251 NULL, 0, "Authentication Clear Ident", HFILL }},
252 { &hf_pcnfsd_auth_password_obscure, {
253 "Obscure Password", "pcnfsd.auth.password.obscure", FT_STRING, BASE_DEC,
254 NULL, 0, "Athentication Obscure Password", HFILL }},
255 { &hf_pcnfsd_auth_password_clear, {
256 "Clear Password", "pcnfsd.auth.password.clear", FT_STRING, BASE_DEC,
257 NULL, 0, "Authentication Clear Password", HFILL }},
258 { &hf_pcnfsd_comment, {
259 "Comment", "pcnfsd.comment", FT_STRING, BASE_DEC,
260 NULL, 0, "Comment", HFILL }},
261 { &hf_pcnfsd_status, {
262 "Reply Status", "pcnfsd.status", FT_UINT32, BASE_DEC,
263 NULL, 0, "Status", HFILL }},
265 "User ID", "pcnfsd.uid", FT_UINT32, BASE_DEC,
266 NULL, 0, "User ID", HFILL }},
268 "Group ID", "pcnfsd.gid", FT_UINT32, BASE_DEC,
269 NULL, 0, "Group ID", HFILL }},
270 { &hf_pcnfsd_gids_count, {
271 "Group ID Count", "pcnfsd.gids.count", FT_UINT32, BASE_DEC,
272 NULL, 0, "Group ID Count", HFILL }},
273 { &hf_pcnfsd_homedir, {
274 "Home Directory", "pcnfsd.homedir", FT_STRING, BASE_DEC,
275 NULL, 0, "Home Directory", HFILL }},
276 { &hf_pcnfsd_def_umask, {
277 "def_umask", "pcnfsd.def_umask", FT_INT32, BASE_OCT,
278 NULL, 0, "def_umask", HFILL }},
281 static gint *ett[] = {
283 &ett_pcnfsd_auth_ident,
284 &ett_pcnfsd_auth_password,
288 proto_pcnfsd = proto_register_protocol("PC NFS",
290 proto_register_field_array(proto_pcnfsd, hf, array_length(hf));
291 proto_register_subtree_array(ett, array_length(ett));
295 proto_reg_handoff_pcnfsd(void)
297 /* Register the protocol as RPC */
298 rpc_init_prog(proto_pcnfsd, PCNFSD_PROGRAM, ett_pcnfsd);
299 /* Register the procedure tables */
300 rpc_init_proc_table(PCNFSD_PROGRAM, 1, pcnfsd1_proc);
301 rpc_init_proc_table(PCNFSD_PROGRAM, 2, pcnfsd2_proc);