2 * Routines for ypbind dissection
4 * $Id: packet-ypbind.c,v 1.9 2002/01/05 21:49:36 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 * 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, proto_tree *tree)
57 offset = dissect_rpc_string(tvb, pinfo, 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, proto_tree *tree)
88 type=tvb_get_ntohl(tvb, offset);
89 offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_ypbind_resp_type, offset);
92 case YPBIND_RESP_TYPE_SUCC_VAL:
94 tid=tvb_get_ntohl(tvb,offset);
95 tid=((tid&0x000000ff)<<24)|((tid&0x0000ff00)<<8)
96 |((tid&0x00ff0000)>>8)|((tid&0xff000000)>>24);
97 proto_tree_add_ipv4(tree, hf_ypbind_addr,
102 offset = dissect_rpc_uint32(tvb, pinfo, tree,
103 hf_ypbind_port, offset);
106 case YPBIND_RESP_TYPE_FAIL_VAL:
108 offset = dissect_rpc_uint32(tvb, pinfo, tree,
109 hf_ypbind_resp_type, offset);
117 dissect_ypbind_setdomain_v2_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
122 offset = dissect_rpc_string(tvb, pinfo, tree,
123 hf_ypbind_domain, offset, NULL);
126 tid=tvb_get_ntohl(tvb,offset);
127 tid=((tid&0x000000ff)<<24)|((tid&0x0000ff00)<<8)
128 |((tid&0x00ff0000)>>8)|((tid&0xff000000)>>24);
129 proto_tree_add_ipv4(tree, hf_ypbind_addr,
130 tvb, offset, 4, tid);
134 offset = dissect_rpc_uint32(tvb, pinfo, tree,
135 hf_ypbind_port, offset);
138 offset = dissect_rpc_uint32(tvb, pinfo, tree,
139 hf_ypbind_setdom_version, offset);
146 /* proc number, "proc name", dissect_request, dissect_reply */
147 /* NULL as function pointer means: type of arguments is "void". */
148 static const vsff ypbind1_proc[] = {
149 { YPBINDPROC_NULL, "NULL", NULL, NULL },
150 { YPBINDPROC_DOMAIN, "DOMAIN", NULL, NULL },
151 { YPBINDPROC_SETDOM, "SETDOMAIN", NULL, NULL },
152 { 0, NULL, NULL, NULL }
154 /* end of YPBind version 1 */
156 static const vsff ypbind2_proc[] = {
157 { YPBINDPROC_NULL, "NULL", NULL, NULL },
158 { YPBINDPROC_DOMAIN, "DOMAIN",
159 dissect_ypbind_domain_v2_request, dissect_ypbind_domain_v2_reply},
160 { YPBINDPROC_SETDOM, "SETDOMAIN",
161 dissect_ypbind_setdomain_v2_request, NULL},
162 { 0, NULL, NULL, NULL }
164 /* end of YPBind version 2 */
168 proto_register_ypbind(void)
170 static hf_register_info hf[] = {
171 { &hf_ypbind_domain, {
172 "Domain", "ypbind.domain", FT_STRING, BASE_DEC,
173 NULL, 0, "Name of the NIS/YP Domain", HFILL }},
175 { &hf_ypbind_resp_type, {
176 "Response Type", "ypbind.resp_type", FT_UINT32, BASE_DEC,
177 VALS(resp_type_vals), 0, "Response type", HFILL }},
179 { &hf_ypbind_error, {
180 "Error", "ypbind.error", FT_UINT32, BASE_DEC,
181 VALS(error_vals), 0, "YPBIND Error code", HFILL }},
184 "IP Addr", "ypbind.addr", FT_IPv4, BASE_DEC,
185 NULL, 0, "IP Address of server", HFILL }},
188 "Port", "ypbind.port", FT_UINT32, BASE_DEC,
189 NULL, 0, "Port to use", HFILL }},
191 { &hf_ypbind_setdom_version, {
192 "Version", "ypbind.setdom.version", FT_UINT32, BASE_DEC,
193 NULL, 0, "Version of setdom", HFILL }},
197 static gint *ett[] = {
201 proto_ypbind = proto_register_protocol("Yellow Pages Bind",
203 proto_register_field_array(proto_ypbind, hf, array_length(hf));
204 proto_register_subtree_array(ett, array_length(ett));
208 proto_reg_handoff_ypbind(void)
210 /* Register the protocol as RPC */
211 rpc_init_prog(proto_ypbind, YPBIND_PROGRAM, ett_ypbind);
212 /* Register the procedure tables */
213 rpc_init_proc_table(YPBIND_PROGRAM, 1, ypbind1_proc);
214 rpc_init_proc_table(YPBIND_PROGRAM, 2, ypbind2_proc);