2 * Routines for ypbind dissection
4 * $Id: packet-ypbind.c,v 1.15 2002/11/01 00:48:39 sahlberg 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.
35 #include "packet-rpc.h"
36 #include "packet-ypbind.h"
38 static int proto_ypbind = -1;
39 static int hf_ypbind_procedure_v1 = -1;
40 static int hf_ypbind_procedure_v2 = -1;
41 static int hf_ypbind_domain = -1;
42 static int hf_ypbind_resp_type = -1;
43 static int hf_ypbind_error = -1;
44 static int hf_ypbind_addr = -1;
45 static int hf_ypbind_port = -1;
46 static int hf_ypbind_setdom_version = -1;
48 static gint ett_ypbind = -1;
52 dissect_ypbind_domain_v2_request(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
55 offset = dissect_rpc_string(tvb, tree,
56 hf_ypbind_domain, offset, NULL);
61 #define YPBIND_RESP_TYPE_SUCC_VAL 1
62 #define YPBIND_RESP_TYPE_FAIL_VAL 2
63 static const value_string resp_type_vals[] = {
64 {YPBIND_RESP_TYPE_SUCC_VAL, "SUCC_VAL"},
65 {YPBIND_RESP_TYPE_FAIL_VAL, "FAIL_VAL"},
69 #define YPBIND_ERROR_ERR 1
70 #define YPBIND_ERROR_NOSERV 2
71 #define YPBIND_ERROR_RESC 3
72 static const value_string error_vals[] = {
73 {YPBIND_ERROR_ERR, "Internal error"},
74 {YPBIND_ERROR_NOSERV, "No bound server for passed domain"},
75 {YPBIND_ERROR_RESC, "System resource allocation failure"},
80 dissect_ypbind_domain_v2_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
85 type=tvb_get_ntohl(tvb, offset);
86 offset = dissect_rpc_uint32(tvb, tree, hf_ypbind_resp_type, offset);
89 case YPBIND_RESP_TYPE_SUCC_VAL:
91 proto_tree_add_item(tree, hf_ypbind_addr,
92 tvb, offset, 4, FALSE);
96 offset = dissect_rpc_uint32(tvb, tree,
97 hf_ypbind_port, offset);
100 case YPBIND_RESP_TYPE_FAIL_VAL:
102 offset = dissect_rpc_uint32(tvb, tree,
103 hf_ypbind_resp_type, offset);
111 dissect_ypbind_setdomain_v2_request(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
114 offset = dissect_rpc_string(tvb, tree,
115 hf_ypbind_domain, offset, NULL);
118 proto_tree_add_item(tree, hf_ypbind_addr,
119 tvb, offset, 4, FALSE);
123 offset = dissect_rpc_uint32(tvb, tree,
124 hf_ypbind_port, offset);
127 offset = dissect_rpc_uint32(tvb, tree,
128 hf_ypbind_setdom_version, offset);
135 /* proc number, "proc name", dissect_request, dissect_reply */
136 /* NULL as function pointer means: type of arguments is "void". */
137 static const vsff ypbind1_proc[] = {
138 { YPBINDPROC_NULL, "NULL", NULL, NULL },
139 { YPBINDPROC_DOMAIN, "DOMAIN", NULL, NULL },
140 { YPBINDPROC_SETDOM, "SETDOMAIN", NULL, NULL },
141 { 0, NULL, NULL, NULL }
143 static const value_string ypbind1_proc_vals[] = {
144 { YPBINDPROC_NULL, "NULL" },
145 { YPBINDPROC_DOMAIN, "DOMAIN" },
146 { YPBINDPROC_SETDOM, "SETDOMAIN" },
149 /* end of YPBind version 1 */
151 static const vsff ypbind2_proc[] = {
152 { YPBINDPROC_NULL, "NULL", NULL, NULL },
153 { YPBINDPROC_DOMAIN, "DOMAIN",
154 dissect_ypbind_domain_v2_request, dissect_ypbind_domain_v2_reply},
155 { YPBINDPROC_SETDOM, "SETDOMAIN",
156 dissect_ypbind_setdomain_v2_request, NULL},
157 { 0, NULL, NULL, NULL }
159 static const value_string ypbind2_proc_vals[] = {
160 { YPBINDPROC_NULL, "NULL" },
161 { YPBINDPROC_DOMAIN, "DOMAIN" },
162 { YPBINDPROC_SETDOM, "SETDOMAIN" },
165 /* end of YPBind version 2 */
169 proto_register_ypbind(void)
171 static hf_register_info hf[] = {
172 { &hf_ypbind_procedure_v1, {
173 "V1 Procedure", "ypbind.procedure_v1", FT_UINT32, BASE_DEC,
174 VALS(ypbind1_proc_vals), 0, "V1 Procedure", HFILL }},
175 { &hf_ypbind_procedure_v2, {
176 "V2 Procedure", "ypbind.procedure_v2", FT_UINT32, BASE_DEC,
177 VALS(ypbind2_proc_vals), 0, "V2 Procedure", HFILL }},
178 { &hf_ypbind_domain, {
179 "Domain", "ypbind.domain", FT_STRING, BASE_DEC,
180 NULL, 0, "Name of the NIS/YP Domain", HFILL }},
182 { &hf_ypbind_resp_type, {
183 "Response Type", "ypbind.resp_type", FT_UINT32, BASE_DEC,
184 VALS(resp_type_vals), 0, "Response type", HFILL }},
186 { &hf_ypbind_error, {
187 "Error", "ypbind.error", FT_UINT32, BASE_DEC,
188 VALS(error_vals), 0, "YPBIND Error code", HFILL }},
191 "IP Addr", "ypbind.addr", FT_IPv4, BASE_DEC,
192 NULL, 0, "IP Address of server", HFILL }},
195 "Port", "ypbind.port", FT_UINT32, BASE_DEC,
196 NULL, 0, "Port to use", HFILL }},
198 { &hf_ypbind_setdom_version, {
199 "Version", "ypbind.setdom.version", FT_UINT32, BASE_DEC,
200 NULL, 0, "Version of setdom", HFILL }},
204 static gint *ett[] = {
208 proto_ypbind = proto_register_protocol("Yellow Pages Bind",
210 proto_register_field_array(proto_ypbind, hf, array_length(hf));
211 proto_register_subtree_array(ett, array_length(ett));
215 proto_reg_handoff_ypbind(void)
217 /* Register the protocol as RPC */
218 rpc_init_prog(proto_ypbind, YPBIND_PROGRAM, ett_ypbind);
219 /* Register the procedure tables */
220 rpc_init_proc_table(YPBIND_PROGRAM, 1, ypbind1_proc, hf_ypbind_procedure_v1);
221 rpc_init_proc_table(YPBIND_PROGRAM, 2, ypbind2_proc, hf_ypbind_procedure_v2);