2 * Routines for ypserv dissection
4 * $Id: packet-ypserv.c,v 1.12 2001/01/03 06:55:34 guy Exp $
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@zing.org>
8 * Copyright 1998 Gerald Combs
10 * Copied from packet-smb.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.
32 #ifdef HAVE_SYS_TYPES_H
33 #include <sys/types.h>
37 #include "packet-rpc.h"
38 #include "packet-ypserv.h"
40 static int proto_ypserv = -1;
41 static int hf_ypserv_domain = -1;
42 static int hf_ypserv_servesdomain = -1;
43 static int hf_ypserv_map = -1;
44 static int hf_ypserv_key = -1;
45 static int hf_ypserv_value = -1;
46 static int hf_ypserv_status = -1;
48 static gint ett_ypserv = -1;
50 /* Dissect a domain call */
51 int dissect_domain_call(const u_char *pd, int offset, frame_data *fd,
56 offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_domain,NULL);
62 int dissect_domain_reply(const u_char *pd, int offset, frame_data *fd,
65 if ( !BYTES_ARE_IN_FRAME(offset, 4)) return offset;
69 proto_tree_add_boolean(tree, hf_ypserv_servesdomain, NullTVB,
70 offset, 4, pntohl(&pd[offset]));
77 /* Dissect a next call */
78 int dissect_next_call(const u_char *pd, int offset, frame_data *fd,
83 offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_domain,NULL);
84 offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_map,NULL);
85 offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_key,NULL);
91 int dissect_first_call(const u_char *pd, int offset, frame_data *fd,
96 offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_domain,NULL);
97 offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_map,NULL);
103 int dissect_match_call(const u_char *pd, int offset, frame_data *fd,
108 offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_domain,NULL);
109 offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_map,NULL);
110 offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_key,NULL);
116 int dissect_match_reply(const u_char *pd, int offset, frame_data *fd,
119 if ( !BYTES_ARE_IN_FRAME(offset, 4)) return offset;
123 proto_tree_add_boolean(tree, hf_ypserv_status, NullTVB,
124 offset, 4, pntohl(&pd[offset]));
127 offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_value,NULL);
133 int dissect_firstnext_reply(const u_char *pd, int offset, frame_data *fd,
136 if ( !BYTES_ARE_IN_FRAME(offset, 4)) return offset;
140 proto_tree_add_boolean(tree, hf_ypserv_status, NullTVB,
141 offset, 4, pntohl(&pd[offset]));
144 offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_value,NULL);
145 offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_key,NULL);
152 /* proc number, "proc name", dissect_request, dissect_reply */
153 /* NULL as function pointer means: take the generic one. */
155 /* someone please get me a version 1 trace */
156 const vsff ypserv1_proc[] = {
157 { 0, "NULL", NULL, NULL },
160 { YPPROC_CLEAR, "CLEAR",
162 { YPPROC_DOMAIN, "DOMAIN",
164 { YPPROC_DOMAIN_NONACK, "DOMAIN_NONACK",
166 { YPPROC_FIRST, "FIRST",
168 { YPPROC_MAPLIST, "MAPLIST",
170 { YPPROC_MASTER, "MASTER",
172 { YPPROC_MATCH, "MATCH",
174 { YPPROC_NEXT, "NEXT",
176 { YPPROC_ORDER, "ORDER",
180 { 0, NULL, NULL, NULL }
182 /* end of YPServ version 2 */
184 const vsff ypserv2_proc[] = {
185 { 0, "NULL", NULL, NULL },
188 { YPPROC_CLEAR, "CLEAR",
190 { YPPROC_DOMAIN, "DOMAIN",
191 dissect_domain_call, dissect_domain_reply },
192 { YPPROC_DOMAIN_NONACK, "DOMAIN_NONACK",
193 dissect_domain_call, dissect_domain_reply },
194 { YPPROC_FIRST, "FIRST",
195 dissect_first_call, dissect_firstnext_reply },
196 { YPPROC_MAPLIST, "MAPLIST",
198 { YPPROC_MASTER, "MASTER",
200 { YPPROC_MATCH, "MATCH",
201 dissect_match_call, dissect_match_reply },
202 { YPPROC_NEXT, "NEXT",
203 dissect_next_call, dissect_firstnext_reply },
204 { YPPROC_ORDER, "ORDER",
208 { 0, NULL, NULL, NULL }
210 /* end of YPServ version 2 */
214 proto_register_ypserv(void)
216 static struct true_false_string okfailed = { "Ok", "Failed" };
217 static struct true_false_string yesno = { "Yes", "No" };
219 static hf_register_info hf[] = {
220 { &hf_ypserv_domain, {
221 "Domain", "ypserv.domain", FT_STRING, BASE_DEC,
222 NULL, 0, "Domain" }},
223 { &hf_ypserv_servesdomain, {
224 "Serves Domain", "ypserv.servesdomain", FT_BOOLEAN, BASE_DEC,
225 &yesno, 0, "Serves Domain" }},
227 "Map Name", "ypserv.map", FT_STRING, BASE_DEC,
228 NULL, 0, "Map Name" }},
230 "Key", "ypserv.key", FT_STRING, BASE_DEC,
232 { &hf_ypserv_value, {
233 "Value", "ypserv.value", FT_STRING, BASE_DEC,
235 { &hf_ypserv_status, {
236 "Status", "ypserv.status", FT_BOOLEAN, BASE_DEC,
237 &okfailed , 0, "Status" }},
239 static gint *ett[] = {
243 proto_ypserv = proto_register_protocol("Yellow Pages Service",
245 proto_register_field_array(proto_ypserv, hf, array_length(hf));
246 proto_register_subtree_array(ett, array_length(ett));
250 proto_reg_handoff_ypserv(void)
252 /* Register the protocol as RPC */
253 rpc_init_prog(proto_ypserv, YPSERV_PROGRAM, ett_ypserv);
254 /* Register the procedure tables */
255 rpc_init_proc_table(YPSERV_PROGRAM, 1, ypserv1_proc);
256 rpc_init_proc_table(YPSERV_PROGRAM, 2, ypserv2_proc);