2 * Routines for ypbind dissection
4 * $Id: packet-ypbind.c,v 1.11 2002/04/03 13:24:13 girlich 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, added dissectors for the commands
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 #ifdef HAVE_SYS_TYPES_H
35 #include <sys/types.h>
39 #include "packet-rpc.h"
40 #include "packet-ypbind.h"
42 static int proto_ypbind = -1;
43 static int hf_ypbind_domain = -1;
44 static int hf_ypbind_resp_type = -1;
45 static int hf_ypbind_error = -1;
46 static int hf_ypbind_addr = -1;
47 static int hf_ypbind_port = -1;
48 static int hf_ypbind_setdom_version = -1;
50 static gint ett_ypbind = -1;
54 dissect_ypbind_domain_v2_request(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
57 offset = dissect_rpc_string(tvb, tree,
58 hf_ypbind_domain, offset, NULL);
63 #define YPBIND_RESP_TYPE_SUCC_VAL 1
64 #define YPBIND_RESP_TYPE_FAIL_VAL 2
65 static const value_string resp_type_vals[] = {
66 {YPBIND_RESP_TYPE_SUCC_VAL, "SUCC_VAL"},
67 {YPBIND_RESP_TYPE_FAIL_VAL, "FAIL_VAL"},
71 #define YPBIND_ERROR_ERR 1
72 #define YPBIND_ERROR_NOSERV 2
73 #define YPBIND_ERROR_RESC 3
74 static const value_string error_vals[] = {
75 {YPBIND_ERROR_ERR, "Internal error"},
76 {YPBIND_ERROR_NOSERV, "No bound server for passed domain"},
77 {YPBIND_ERROR_RESC, "System resource allocation failure"},
82 dissect_ypbind_domain_v2_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
87 type=tvb_get_ntohl(tvb, offset);
88 offset = dissect_rpc_uint32(tvb, tree, hf_ypbind_resp_type, offset);
91 case YPBIND_RESP_TYPE_SUCC_VAL:
93 proto_tree_add_item(tree, hf_ypbind_addr,
94 tvb, offset, 4, FALSE);
98 offset = dissect_rpc_uint32(tvb, tree,
99 hf_ypbind_port, offset);
102 case YPBIND_RESP_TYPE_FAIL_VAL:
104 offset = dissect_rpc_uint32(tvb, tree,
105 hf_ypbind_resp_type, offset);
113 dissect_ypbind_setdomain_v2_request(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
116 offset = dissect_rpc_string(tvb, tree,
117 hf_ypbind_domain, offset, NULL);
120 proto_tree_add_item(tree, hf_ypbind_addr,
121 tvb, offset, 4, FALSE);
125 offset = dissect_rpc_uint32(tvb, tree,
126 hf_ypbind_port, offset);
129 offset = dissect_rpc_uint32(tvb, tree,
130 hf_ypbind_setdom_version, offset);
137 /* proc number, "proc name", dissect_request, dissect_reply */
138 /* NULL as function pointer means: type of arguments is "void". */
139 static const vsff ypbind1_proc[] = {
140 { YPBINDPROC_NULL, "NULL", NULL, NULL },
141 { YPBINDPROC_DOMAIN, "DOMAIN", NULL, NULL },
142 { YPBINDPROC_SETDOM, "SETDOMAIN", NULL, NULL },
143 { 0, NULL, NULL, NULL }
145 /* end of YPBind version 1 */
147 static const vsff ypbind2_proc[] = {
148 { YPBINDPROC_NULL, "NULL", NULL, NULL },
149 { YPBINDPROC_DOMAIN, "DOMAIN",
150 dissect_ypbind_domain_v2_request, dissect_ypbind_domain_v2_reply},
151 { YPBINDPROC_SETDOM, "SETDOMAIN",
152 dissect_ypbind_setdomain_v2_request, NULL},
153 { 0, NULL, NULL, NULL }
155 /* end of YPBind version 2 */
159 proto_register_ypbind(void)
161 static hf_register_info hf[] = {
162 { &hf_ypbind_domain, {
163 "Domain", "ypbind.domain", FT_STRING, BASE_DEC,
164 NULL, 0, "Name of the NIS/YP Domain", HFILL }},
166 { &hf_ypbind_resp_type, {
167 "Response Type", "ypbind.resp_type", FT_UINT32, BASE_DEC,
168 VALS(resp_type_vals), 0, "Response type", HFILL }},
170 { &hf_ypbind_error, {
171 "Error", "ypbind.error", FT_UINT32, BASE_DEC,
172 VALS(error_vals), 0, "YPBIND Error code", HFILL }},
175 "IP Addr", "ypbind.addr", FT_IPv4, BASE_DEC,
176 NULL, 0, "IP Address of server", HFILL }},
179 "Port", "ypbind.port", FT_UINT32, BASE_DEC,
180 NULL, 0, "Port to use", HFILL }},
182 { &hf_ypbind_setdom_version, {
183 "Version", "ypbind.setdom.version", FT_UINT32, BASE_DEC,
184 NULL, 0, "Version of setdom", HFILL }},
188 static gint *ett[] = {
192 proto_ypbind = proto_register_protocol("Yellow Pages Bind",
194 proto_register_field_array(proto_ypbind, hf, array_length(hf));
195 proto_register_subtree_array(ett, array_length(ett));
199 proto_reg_handoff_ypbind(void)
201 /* Register the protocol as RPC */
202 rpc_init_prog(proto_ypbind, YPBIND_PROGRAM, ett_ypbind);
203 /* Register the procedure tables */
204 rpc_init_proc_table(YPBIND_PROGRAM, 1, ypbind1_proc);
205 rpc_init_proc_table(YPBIND_PROGRAM, 2, ypbind2_proc);