2 * Routines for ypserv dissection
4 * $Id: packet-ypserv.c,v 1.7 2000/01/07 22:05:42 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);
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_item(tree, hf_ypserv_servesdomain,
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);
84 offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_map);
85 offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_key);
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);
97 offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_map);
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);
109 offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_map);
110 offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_key);
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_item(tree, hf_ypserv_status,
124 offset, 4, pntohl(&pd[offset]));
127 offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_value);
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_item(tree, hf_ypserv_status,
141 offset, 4, pntohl(&pd[offset]));
144 offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_value);
145 offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_key); }
151 /* proc number, "proc name", dissect_request, dissect_reply */
152 /* NULL as function pointer means: take the generic one. */
154 /* someone please get me a version 1 trace */
155 const vsff ypserv1_proc[] = {
156 { 0, "NULL", NULL, NULL },
159 { YPPROC_CLEAR, "CLEAR",
161 { YPPROC_DOMAIN, "DOMAIN",
163 { YPPROC_DOMAIN_NONACK, "DOMAIN_NONACK",
165 { YPPROC_FIRST, "FIRST",
167 { YPPROC_MAPLIST, "MAPLIST",
169 { YPPROC_MASTER, "MASTER",
171 { YPPROC_MATCH, "MATCH",
173 { YPPROC_NEXT, "NEXT",
175 { YPPROC_ORDER, "ORDER",
179 { 0, NULL, NULL, NULL }
181 /* end of YPServ version 2 */
183 const vsff ypserv2_proc[] = {
184 { 0, "NULL", NULL, NULL },
187 { YPPROC_CLEAR, "CLEAR",
189 { YPPROC_DOMAIN, "DOMAIN",
190 dissect_domain_call, dissect_domain_reply },
191 { YPPROC_DOMAIN_NONACK, "DOMAIN_NONACK",
192 dissect_domain_call, dissect_domain_reply },
193 { YPPROC_FIRST, "FIRST",
194 dissect_first_call, dissect_firstnext_reply },
195 { YPPROC_MAPLIST, "MAPLIST",
197 { YPPROC_MASTER, "MASTER",
199 { YPPROC_MATCH, "MATCH",
200 dissect_match_call, dissect_match_reply },
201 { YPPROC_NEXT, "NEXT",
202 dissect_next_call, dissect_firstnext_reply },
203 { YPPROC_ORDER, "ORDER",
207 { 0, NULL, NULL, NULL }
209 /* end of YPServ version 2 */
213 proto_register_ypserv(void)
215 static struct true_false_string okfailed = { "Ok", "Failed" };
216 static struct true_false_string yesno = { "Yes", "No" };
218 static hf_register_info hf[] = {
219 { &hf_ypserv_domain, {
220 "Domain", "ypserv.domain", FT_STRING, BASE_DEC,
221 NULL, 0, "Domain" }},
222 { &hf_ypserv_servesdomain, {
223 "Serves Domain", "ypserv.servesdomain", FT_BOOLEAN, BASE_DEC,
224 &yesno, 0, "Serves Domain" }},
226 "Map Name", "ypserv.map", FT_STRING, BASE_DEC,
227 NULL, 0, "Map Name" }},
229 "Key", "ypserv.key", FT_STRING, BASE_DEC,
231 { &hf_ypserv_value, {
232 "Value", "ypserv.value", FT_STRING, BASE_DEC,
234 { &hf_ypserv_status, {
235 "Status", "ypserv.status", FT_BOOLEAN, BASE_DEC,
236 &okfailed , 0, "Status" }},
238 static gint *ett[] = {
242 proto_ypserv = proto_register_protocol("Yellow Pages Service", "ypserv");
243 proto_register_field_array(proto_ypserv, hf, array_length(hf));
244 proto_register_subtree_array(ett, array_length(ett));
246 /* Register the protocol as RPC */
247 rpc_init_prog(proto_ypserv, YPSERV_PROGRAM, ett_ypserv);
248 /* Register the procedure tables */
249 rpc_init_proc_table(YPSERV_PROGRAM, 1, ypserv1_proc);
250 rpc_init_proc_table(YPSERV_PROGRAM, 2, ypserv2_proc);