2 * Routines for ypbind dissection
4 * $Id: packet-ypbind.c,v 1.13 2002/08/28 21:00:40 jmayer 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_domain = -1;
40 static int hf_ypbind_resp_type = -1;
41 static int hf_ypbind_error = -1;
42 static int hf_ypbind_addr = -1;
43 static int hf_ypbind_port = -1;
44 static int hf_ypbind_setdom_version = -1;
46 static gint ett_ypbind = -1;
50 dissect_ypbind_domain_v2_request(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
53 offset = dissect_rpc_string(tvb, tree,
54 hf_ypbind_domain, offset, NULL);
59 #define YPBIND_RESP_TYPE_SUCC_VAL 1
60 #define YPBIND_RESP_TYPE_FAIL_VAL 2
61 static const value_string resp_type_vals[] = {
62 {YPBIND_RESP_TYPE_SUCC_VAL, "SUCC_VAL"},
63 {YPBIND_RESP_TYPE_FAIL_VAL, "FAIL_VAL"},
67 #define YPBIND_ERROR_ERR 1
68 #define YPBIND_ERROR_NOSERV 2
69 #define YPBIND_ERROR_RESC 3
70 static const value_string error_vals[] = {
71 {YPBIND_ERROR_ERR, "Internal error"},
72 {YPBIND_ERROR_NOSERV, "No bound server for passed domain"},
73 {YPBIND_ERROR_RESC, "System resource allocation failure"},
78 dissect_ypbind_domain_v2_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
83 type=tvb_get_ntohl(tvb, offset);
84 offset = dissect_rpc_uint32(tvb, tree, hf_ypbind_resp_type, offset);
87 case YPBIND_RESP_TYPE_SUCC_VAL:
89 proto_tree_add_item(tree, hf_ypbind_addr,
90 tvb, offset, 4, FALSE);
94 offset = dissect_rpc_uint32(tvb, tree,
95 hf_ypbind_port, offset);
98 case YPBIND_RESP_TYPE_FAIL_VAL:
100 offset = dissect_rpc_uint32(tvb, tree,
101 hf_ypbind_resp_type, offset);
109 dissect_ypbind_setdomain_v2_request(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
112 offset = dissect_rpc_string(tvb, tree,
113 hf_ypbind_domain, offset, NULL);
116 proto_tree_add_item(tree, hf_ypbind_addr,
117 tvb, offset, 4, FALSE);
121 offset = dissect_rpc_uint32(tvb, tree,
122 hf_ypbind_port, offset);
125 offset = dissect_rpc_uint32(tvb, tree,
126 hf_ypbind_setdom_version, offset);
133 /* proc number, "proc name", dissect_request, dissect_reply */
134 /* NULL as function pointer means: type of arguments is "void". */
135 static const vsff ypbind1_proc[] = {
136 { YPBINDPROC_NULL, "NULL", NULL, NULL },
137 { YPBINDPROC_DOMAIN, "DOMAIN", NULL, NULL },
138 { YPBINDPROC_SETDOM, "SETDOMAIN", NULL, NULL },
139 { 0, NULL, NULL, NULL }
141 /* end of YPBind version 1 */
143 static const vsff ypbind2_proc[] = {
144 { YPBINDPROC_NULL, "NULL", NULL, NULL },
145 { YPBINDPROC_DOMAIN, "DOMAIN",
146 dissect_ypbind_domain_v2_request, dissect_ypbind_domain_v2_reply},
147 { YPBINDPROC_SETDOM, "SETDOMAIN",
148 dissect_ypbind_setdomain_v2_request, NULL},
149 { 0, NULL, NULL, NULL }
151 /* end of YPBind version 2 */
155 proto_register_ypbind(void)
157 static hf_register_info hf[] = {
158 { &hf_ypbind_domain, {
159 "Domain", "ypbind.domain", FT_STRING, BASE_DEC,
160 NULL, 0, "Name of the NIS/YP Domain", HFILL }},
162 { &hf_ypbind_resp_type, {
163 "Response Type", "ypbind.resp_type", FT_UINT32, BASE_DEC,
164 VALS(resp_type_vals), 0, "Response type", HFILL }},
166 { &hf_ypbind_error, {
167 "Error", "ypbind.error", FT_UINT32, BASE_DEC,
168 VALS(error_vals), 0, "YPBIND Error code", HFILL }},
171 "IP Addr", "ypbind.addr", FT_IPv4, BASE_DEC,
172 NULL, 0, "IP Address of server", HFILL }},
175 "Port", "ypbind.port", FT_UINT32, BASE_DEC,
176 NULL, 0, "Port to use", HFILL }},
178 { &hf_ypbind_setdom_version, {
179 "Version", "ypbind.setdom.version", FT_UINT32, BASE_DEC,
180 NULL, 0, "Version of setdom", HFILL }},
184 static gint *ett[] = {
188 proto_ypbind = proto_register_protocol("Yellow Pages Bind",
190 proto_register_field_array(proto_ypbind, hf, array_length(hf));
191 proto_register_subtree_array(ett, array_length(ett));
195 proto_reg_handoff_ypbind(void)
197 /* Register the protocol as RPC */
198 rpc_init_prog(proto_ypbind, YPBIND_PROGRAM, ett_ypbind);
199 /* Register the procedure tables */
200 rpc_init_proc_table(YPBIND_PROGRAM, 1, ypbind1_proc);
201 rpc_init_proc_table(YPBIND_PROGRAM, 2, ypbind2_proc);