Require dissectors for all ONC RPC calls and replies.
[metze/wireshark/wip.git] / epan / dissectors / packet-yppasswd.c
1 /* packet-yppasswd.c
2  * Routines for yppasswd dissection
3  *
4  * Wireshark - Network traffic analyzer
5  * By Gerald Combs <gerald@wireshark.org>
6  * Copyright 1998 Gerald Combs
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22
23 #include "config.h"
24
25 #include "packet-rpc.h"
26 #include "packet-yppasswd.h"
27
28 void proto_register_yppasswd(void);
29 void proto_reg_handoff_yppasswd(void);
30
31 static int proto_yppasswd = -1;
32 static int hf_yppasswd_procedure_v1 = -1;
33 static int hf_yppasswd_status = -1;
34 static int hf_yppasswd_oldpass = -1;
35 static int hf_yppasswd_newpw = -1;
36 static int hf_yppasswd_newpw_name = -1;
37 static int hf_yppasswd_newpw_passwd = -1;
38 static int hf_yppasswd_newpw_uid = -1;
39 static int hf_yppasswd_newpw_gid = -1;
40 static int hf_yppasswd_newpw_gecos = -1;
41 static int hf_yppasswd_newpw_dir = -1;
42 static int hf_yppasswd_newpw_shell = -1;
43
44 static gint ett_yppasswd = -1;
45 static gint ett_yppasswd_newpw = -1;
46
47 static int
48 dissect_yppasswd_call(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
49 {
50         proto_item *lock_item = NULL;
51         proto_tree *lock_tree = NULL;
52         int offset = 0;
53
54         offset = dissect_rpc_string(tvb, tree, hf_yppasswd_oldpass,
55                         offset, NULL);
56
57         lock_item = proto_tree_add_item(tree, hf_yppasswd_newpw, tvb,
58                         offset, -1, ENC_NA);
59
60         lock_tree = proto_item_add_subtree(lock_item, ett_yppasswd_newpw);
61
62         offset = dissect_rpc_string(tvb, lock_tree,
63                         hf_yppasswd_newpw_name, offset, NULL);
64         offset = dissect_rpc_string(tvb, lock_tree,
65                         hf_yppasswd_newpw_passwd, offset, NULL);
66         offset = dissect_rpc_uint32(tvb, lock_tree,
67                         hf_yppasswd_newpw_uid, offset);
68         offset = dissect_rpc_uint32(tvb, lock_tree,
69                         hf_yppasswd_newpw_gid, offset);
70         offset = dissect_rpc_string(tvb, lock_tree,
71                         hf_yppasswd_newpw_gecos, offset, NULL);
72         offset = dissect_rpc_string(tvb, lock_tree,
73                         hf_yppasswd_newpw_dir, offset, NULL);
74         offset = dissect_rpc_string(tvb, lock_tree,
75                         hf_yppasswd_newpw_shell, offset, NULL);
76
77         return offset;
78 }
79
80 static int
81 dissect_yppasswd_reply(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
82 {
83         return dissect_rpc_uint32(tvb, tree, hf_yppasswd_status, 0);
84 }
85
86 /* proc number, "proc name", dissect_request, dissect_reply */
87 static const vsff yppasswd1_proc[] = {
88         { YPPASSWDPROC_NULL,    "NULL",
89                 dissect_rpc_void,       dissect_rpc_void },
90         { YPPASSWDPROC_UPDATE,  "UPDATE",
91                 dissect_yppasswd_call,  dissect_yppasswd_reply },
92         { 0,    NULL,           NULL,                           NULL }
93 };
94 static const value_string yppasswd1_proc_vals[] = {
95         { YPPASSWDPROC_NULL,    "NULL" },
96         { YPPASSWDPROC_UPDATE,  "UPDATE" },
97         { 0,    NULL }
98 };
99
100 void
101 proto_register_yppasswd(void)
102 {
103         static hf_register_info hf[] = {
104                 { &hf_yppasswd_procedure_v1, {
105                         "V1 Procedure", "yppasswd.procedure_v1", FT_UINT32, BASE_DEC,
106                         VALS(yppasswd1_proc_vals), 0, NULL, HFILL }},
107                 { &hf_yppasswd_status, {
108                         "status", "yppasswd.status", FT_UINT32, BASE_DEC,
109                         NULL, 0, "YPPasswd update status", HFILL }},
110
111                 { &hf_yppasswd_oldpass, {
112                         "oldpass", "yppasswd.oldpass", FT_STRING, BASE_NONE,
113                         NULL, 0, "Old encrypted password", HFILL }},
114
115                 { &hf_yppasswd_newpw, {
116                         "newpw", "yppasswd.newpw", FT_NONE, BASE_NONE,
117                         NULL, 0, "New passwd entry", HFILL }},
118
119                 { &hf_yppasswd_newpw_name, {
120                         "name", "yppasswd.newpw.name", FT_STRING, BASE_NONE,
121                         NULL, 0, "Username", HFILL }},
122
123                 { &hf_yppasswd_newpw_passwd, {
124                         "passwd", "yppasswd.newpw.passwd", FT_STRING, BASE_NONE,
125                         NULL, 0, "Encrypted passwd", HFILL }},
126
127                 { &hf_yppasswd_newpw_uid, {
128                         "uid", "yppasswd.newpw.uid", FT_UINT32, BASE_DEC,
129                         NULL, 0, "UserID", HFILL }},
130
131                 { &hf_yppasswd_newpw_gid, {
132                         "gid", "yppasswd.newpw.gid", FT_UINT32, BASE_DEC,
133                         NULL, 0, "GroupID", HFILL }},
134
135                 { &hf_yppasswd_newpw_gecos, {
136                         "gecos", "yppasswd.newpw.gecos", FT_STRING, BASE_NONE,
137                         NULL, 0, "In real life name", HFILL }},
138
139                 { &hf_yppasswd_newpw_dir, {
140                         "dir", "yppasswd.newpw.dir", FT_STRING, BASE_NONE,
141                         NULL, 0, "Home Directory", HFILL }},
142
143                 { &hf_yppasswd_newpw_shell, {
144                         "shell", "yppasswd.newpw.shell", FT_STRING, BASE_NONE,
145                         NULL, 0, "Default shell", HFILL }},
146
147         };
148
149         static gint *ett[] = {
150                 &ett_yppasswd,
151                 &ett_yppasswd_newpw,
152         };
153
154         proto_yppasswd = proto_register_protocol("Yellow Pages Passwd",
155             "YPPASSWD", "yppasswd");
156         proto_register_field_array(proto_yppasswd, hf, array_length(hf));
157         proto_register_subtree_array(ett, array_length(ett));
158 }
159
160 void
161 proto_reg_handoff_yppasswd(void)
162 {
163         /* Register the protocol as RPC */
164         rpc_init_prog(proto_yppasswd, YPPASSWD_PROGRAM, ett_yppasswd);
165         /* Register the procedure tables */
166         rpc_init_proc_table(proto_yppasswd, YPPASSWD_PROGRAM, 1, yppasswd1_proc, hf_yppasswd_procedure_v1);
167 }
168
169 /*
170  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
171  *
172  * Local variables:
173  * c-basic-offset: 8
174  * tab-width: 8
175  * indent-tabs-mode: t
176  * End:
177  *
178  * vi: set shiftwidth=8 tabstop=8 noexpandtab:
179  * :indentSize=8:tabSize=8:noTabs=false:
180  */