2 * Routines for ypserv dissection
4 * $Id: packet-ypserv.c,v 1.17 2001/06/18 02:17:58 guy Exp $
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@ethereal.com>
8 * Copyright 1998 Gerald Combs
10 * Copied from packet-smb.c
12 * 2001 Ronnie Sahlberg <rsahlber@bigpond.net.au>
13 * Added all remaining dissectors for this protocol
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
35 #ifdef HAVE_SYS_TYPES_H
36 #include <sys/types.h>
40 #include "packet-rpc.h"
41 #include "packet-ypserv.h"
43 static int proto_ypserv = -1;
44 static int hf_ypserv_domain = -1;
45 static int hf_ypserv_servesdomain = -1;
46 static int hf_ypserv_map = -1;
47 static int hf_ypserv_key = -1;
48 static int hf_ypserv_peer = -1;
49 static int hf_ypserv_more = -1;
50 static int hf_ypserv_ordernum = -1;
51 static int hf_ypserv_transid = -1;
52 static int hf_ypserv_prog = -1;
53 static int hf_ypserv_port = -1;
54 static int hf_ypserv_value = -1;
55 static int hf_ypserv_status = -1;
56 static int hf_ypserv_map_parms = -1;
57 static int hf_ypserv_xfrstat = -1;
59 static gint ett_ypserv = -1;
60 static gint ett_ypserv_map_parms = -1;
62 static const value_string ypstat[] =
78 static const value_string xfrstat[] =
82 { -1, "YPXFR_NOMAP" },
83 { -2, "YPXFR_NODOM" },
86 { -5, "YPXFR_MADDR" },
87 { -6, "YPXFR_YPERR" },
88 { -7, "YPXFR_BADARGS" },
91 { -10, "YPXFR_SKEW" },
92 { -11, "YPXFR_CLEAR" },
93 { -12, "YPXFR_FORCE" },
94 { -13, "YPXFR_XFRERR" },
95 { -14, "YPXFR_REFUSED" },
100 dissect_domain_call(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
104 offset = dissect_rpc_string(tvb,pinfo,tree,hf_ypserv_domain,offset,NULL);
111 dissect_domain_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
115 proto_tree_add_boolean(tree, hf_ypserv_servesdomain, tvb,
116 offset, 4, tvb_get_ntohl(tvb,offset));
124 dissect_match_call(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
128 offset = dissect_rpc_string(tvb, pinfo, tree, hf_ypserv_domain, offset, NULL);
129 offset = dissect_rpc_string(tvb, pinfo, tree, hf_ypserv_map, offset, NULL);
130 offset = dissect_rpc_string(tvb, pinfo, tree, hf_ypserv_key, offset, NULL);
137 dissect_match_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
141 offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_ypserv_status, offset);
143 offset = dissect_rpc_string(tvb, pinfo, tree, hf_ypserv_value,offset, NULL);
151 dissect_first_call(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
155 offset = dissect_rpc_string(tvb, pinfo, tree, hf_ypserv_domain, offset, NULL);
156 offset = dissect_rpc_string(tvb, pinfo, tree, hf_ypserv_map, offset, NULL);
157 offset = dissect_rpc_string(tvb, pinfo, tree, hf_ypserv_key, offset, NULL);
165 dissect_firstnext_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
169 offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_ypserv_status, offset);
171 offset = dissect_rpc_string(tvb, pinfo, tree, hf_ypserv_value, offset, NULL);
172 offset = dissect_rpc_string(tvb, pinfo, tree, hf_ypserv_key, offset, NULL);
180 dissect_next_call(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
184 offset = dissect_rpc_string(tvb, pinfo, tree, hf_ypserv_domain, offset, NULL);
185 offset = dissect_rpc_string(tvb, pinfo, tree, hf_ypserv_map, offset, NULL);
186 offset = dissect_rpc_string(tvb, pinfo, tree, hf_ypserv_key, offset, NULL);
193 dissect_xfr_call(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
195 proto_item *lock_item=NULL;
196 proto_tree *lock_tree=NULL;
200 lock_item = proto_tree_add_item(tree, hf_ypserv_map_parms, tvb,
201 offset, tvb_length_remaining(tvb, offset)-12, FALSE);
203 lock_tree = proto_item_add_subtree(lock_item, ett_ypserv_map_parms);
206 offset = dissect_rpc_string(tvb, pinfo, lock_tree, hf_ypserv_domain, offset, NULL);
208 offset = dissect_rpc_string(tvb, pinfo, lock_tree, hf_ypserv_map, offset, NULL);
210 offset = dissect_rpc_uint32(tvb, pinfo, lock_tree, hf_ypserv_ordernum, offset);
212 offset = dissect_rpc_string(tvb, pinfo, lock_tree, hf_ypserv_peer, offset, NULL);
215 tid=tvb_get_ntohl(tvb,offset);
216 tid=((tid&0x000000ff)<<24)|((tid&0x0000ff00)<<8)|((tid&0x00ff0000)>>8)|((tid&0xff000000)>>24);
217 proto_tree_add_ipv4(tree, hf_ypserv_transid, tvb, offset, 4, tid);
220 offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_ypserv_prog, offset);
221 offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_ypserv_port, offset);
227 dissect_xfr_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
231 tid=tvb_get_ntohl(tvb,offset);
232 tid=((tid&0x000000ff)<<24)|((tid&0x0000ff00)<<8)|((tid&0x00ff0000)>>8)|((tid&0xff000000)>>24);
233 proto_tree_add_ipv4(tree, hf_ypserv_transid, tvb, offset, 4, tid);
236 offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_ypserv_xfrstat, offset);
242 dissect_ypreq_nokey(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
245 offset = dissect_rpc_string(tvb, pinfo, tree, hf_ypserv_domain, offset, NULL);
247 offset = dissect_rpc_string(tvb, pinfo, tree, hf_ypserv_map, offset, NULL);
253 dissect_ypresp_all(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
257 more = tvb_get_ntohl(tvb, offset);
259 offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_ypserv_more, offset);
261 offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_ypserv_status, offset);
262 offset = dissect_rpc_string(tvb, pinfo, tree, hf_ypserv_value, offset, NULL);
263 offset = dissect_rpc_string(tvb, pinfo, tree, hf_ypserv_key, offset, NULL);
270 dissect_ypresp_master(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
273 offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_ypserv_status, offset);
275 offset = dissect_rpc_string(tvb, pinfo, tree, hf_ypserv_peer, offset, NULL);
282 dissect_ypresp_order(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
285 offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_ypserv_status, offset);
287 offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_ypserv_ordernum, offset);
294 dissect_ypresp_maplist(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
296 offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_ypserv_status, offset);
297 while(tvb_get_ntohl(tvb,offset)){
298 offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_ypserv_more, offset);
299 offset = dissect_rpc_string(tvb, pinfo, tree, hf_ypserv_map, offset, NULL);
302 offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_ypserv_more, offset);
307 /* proc number, "proc name", dissect_request, dissect_reply */
308 /* NULL as function pointer means: type of arguments is "void". */
310 /* someone please get me a version 1 trace */
311 static const vsff ypserv1_proc[] = {
312 { 0, "NULL", NULL, NULL },
313 { YPPROC_DOMAIN, "DOMAIN",
315 { YPPROC_DOMAIN_NONACK, "DOMAIN_NONACK",
317 { YPPROC_MATCH, "MATCH",
319 { YPPROC_FIRST, "FIRST",
321 { YPPROC_NEXT, "NEXT",
325 { YPPROC_CLEAR, "CLEAR",
329 { YPPROC_MASTER, "MASTER",
331 { YPPROC_ORDER, "ORDER",
333 { YPPROC_MAPLIST, "MAPLIST",
335 { 0, NULL, NULL, NULL }
337 /* end of YPServ version 2 */
339 static const vsff ypserv2_proc[] = {
340 { 0, "NULL", NULL, NULL },
341 { YPPROC_DOMAIN, "DOMAIN",
342 dissect_domain_call, dissect_domain_reply },
343 { YPPROC_DOMAIN_NONACK, "DOMAIN_NONACK",
344 dissect_domain_call, dissect_domain_reply },
345 { YPPROC_MATCH, "MATCH",
346 dissect_match_call, dissect_match_reply },
347 { YPPROC_FIRST, "FIRST",
348 dissect_first_call, dissect_firstnext_reply },
349 { YPPROC_NEXT, "NEXT",
350 dissect_next_call, dissect_firstnext_reply },
352 dissect_xfr_call, dissect_xfr_reply },
353 { YPPROC_CLEAR, "CLEAR",
356 dissect_ypreq_nokey, dissect_ypresp_all },
357 { YPPROC_MASTER, "MASTER",
358 dissect_ypreq_nokey, dissect_ypresp_master },
359 { YPPROC_ORDER, "ORDER",
360 dissect_ypreq_nokey, dissect_ypresp_order },
361 { YPPROC_MAPLIST, "MAPLIST",
362 dissect_domain_call, dissect_ypresp_maplist },
363 { 0, NULL, NULL, NULL }
365 /* end of YPServ version 2 */
369 proto_register_ypserv(void)
371 /*static struct true_false_string okfailed = { "Ok", "Failed" };*/
372 static struct true_false_string yesno = { "Yes", "No" };
374 static hf_register_info hf[] = {
375 { &hf_ypserv_domain, {
376 "Domain", "ypserv.domain", FT_STRING, BASE_DEC,
377 NULL, 0, "Domain", HFILL }},
378 { &hf_ypserv_servesdomain, {
379 "Serves Domain", "ypserv.servesdomain", FT_BOOLEAN, BASE_DEC,
380 &yesno, 0, "Serves Domain", HFILL }},
382 "Map Name", "ypserv.map", FT_STRING, BASE_DEC,
383 NULL, 0, "Map Name", HFILL }},
385 "Peer Name", "ypserv.peer", FT_STRING, BASE_DEC,
386 NULL, 0, "Peer Name", HFILL }},
388 "More", "ypserv.more", FT_BOOLEAN, BASE_NONE,
389 &yesno, 0, "More", HFILL }},
390 { &hf_ypserv_ordernum, {
391 "Order Number", "ypserv.ordernum", FT_UINT32, BASE_DEC,
392 NULL, 0, "Order Number for XFR", HFILL }},
393 { &hf_ypserv_transid, {
394 "Host Transport ID", "ypserv.transid", FT_IPv4, BASE_DEC,
395 NULL, 0, "Host Transport ID to use for XFR Callback", HFILL }},
397 "Program Number", "ypserv.prog", FT_UINT32, BASE_DEC,
398 NULL, 0, "Program Number to use for XFR Callback", HFILL }},
400 "Port", "ypserv.port", FT_UINT32, BASE_DEC,
401 NULL, 0, "Port to use for XFR Callback", HFILL }},
403 "Key", "ypserv.key", FT_STRING, BASE_DEC,
404 NULL, 0, "Key", HFILL }},
405 { &hf_ypserv_value, {
406 "Value", "ypserv.value", FT_STRING, BASE_DEC,
407 NULL, 0, "Value", HFILL }},
408 { &hf_ypserv_status, {
409 "Status", "ypserv.status", FT_INT32, BASE_DEC,
410 VALS(ypstat) , 0, "Status", HFILL }},
411 { &hf_ypserv_map_parms, {
412 "YP Map Parameters", "ypserv.map_parms", FT_NONE, BASE_DEC,
413 NULL, 0, "YP Map Parameters", HFILL }},
414 { &hf_ypserv_xfrstat, {
415 "Xfrstat", "ypserv.xfrstat", FT_INT32, BASE_DEC,
416 VALS(xfrstat), 0, "Xfrstat", HFILL }},
418 static gint *ett[] = {
420 &ett_ypserv_map_parms,
423 proto_ypserv = proto_register_protocol("Yellow Pages Service",
425 proto_register_field_array(proto_ypserv, hf, array_length(hf));
426 proto_register_subtree_array(ett, array_length(ett));
430 proto_reg_handoff_ypserv(void)
432 /* Register the protocol as RPC */
433 rpc_init_prog(proto_ypserv, YPSERV_PROGRAM, ett_ypserv);
434 /* Register the procedure tables */
435 rpc_init_proc_table(YPSERV_PROGRAM, 1, ypserv1_proc);
436 rpc_init_proc_table(YPSERV_PROGRAM, 2, ypserv2_proc);