HACK: pinfo->private_data points to smb_info again
[wireshark-wip.git] / epan / dissectors / packet-ypbind.c
blobc4b97527e99b177d0cdc4afbd57b8829368c591e
1 /* packet-ypbind.c
2 * Routines for ypbind dissection
4 * $Id$
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 #include "config.h"
33 #include "packet-rpc.h"
34 #include "packet-ypbind.h"
36 static int proto_ypbind = -1;
37 static int hf_ypbind_procedure_v1 = -1;
38 static int hf_ypbind_procedure_v2 = -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;
49 static int
50 dissect_ypbind_domain_v2_request(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
52 /* domain */
53 offset = dissect_rpc_string(tvb, tree,
54 hf_ypbind_domain, offset, NULL);
56 return offset;
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"},
64 {0, NULL}
67 #if 0
68 #define YPBIND_ERROR_ERR 1
69 #define YPBIND_ERROR_NOSERV 2
70 #define YPBIND_ERROR_RESC 3
71 static const value_string error_vals[] = {
72 {YPBIND_ERROR_ERR, "Internal error"},
73 {YPBIND_ERROR_NOSERV, "No bound server for passed domain"},
74 {YPBIND_ERROR_RESC, "System resource allocation failure"},
75 {0, NULL}
77 #endif
79 static int
80 dissect_ypbind_domain_v2_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
82 guint32 type;
84 /* response type */
85 type=tvb_get_ntohl(tvb, offset);
86 offset = dissect_rpc_uint32(tvb, tree, hf_ypbind_resp_type, offset);
88 switch(type){
89 case YPBIND_RESP_TYPE_SUCC_VAL:
90 /* ip address */
91 proto_tree_add_item(tree, hf_ypbind_addr,
92 tvb, offset, 4, ENC_BIG_ENDIAN);
93 offset += 4;
95 /* port */
96 offset = dissect_rpc_uint32(tvb, tree,
97 hf_ypbind_port, offset);
99 break;
100 case YPBIND_RESP_TYPE_FAIL_VAL:
101 /* error */
102 offset = dissect_rpc_uint32(tvb, tree,
103 hf_ypbind_resp_type, offset);
104 break;
107 return offset;
110 static int
111 dissect_ypbind_setdomain_v2_request(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
113 /* domain */
114 offset = dissect_rpc_string(tvb, tree,
115 hf_ypbind_domain, offset, NULL);
117 /* ip address */
118 proto_tree_add_item(tree, hf_ypbind_addr,
119 tvb, offset, 4, ENC_BIG_ENDIAN);
120 offset += 4;
122 /* port */
123 offset = dissect_rpc_uint32(tvb, tree,
124 hf_ypbind_port, offset);
126 /* version */
127 offset = dissect_rpc_uint32(tvb, tree,
128 hf_ypbind_setdom_version, offset);
130 return 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" },
147 { 0, NULL }
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" },
163 { 0, NULL }
165 /* end of YPBind version 2 */
168 void
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, NULL, HFILL }},
175 { &hf_ypbind_procedure_v2, {
176 "V2 Procedure", "ypbind.procedure_v2", FT_UINT32, BASE_DEC,
177 VALS(ypbind2_proc_vals), 0, NULL, HFILL }},
178 { &hf_ypbind_domain, {
179 "Domain", "ypbind.domain", FT_STRING, BASE_NONE,
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, NULL, HFILL }},
186 #if 0
187 { &hf_ypbind_error, {
188 "Error", "ypbind.error", FT_UINT32, BASE_DEC,
189 VALS(error_vals), 0, "YPBIND Error code", HFILL }},
190 #endif
191 { &hf_ypbind_addr, {
192 "IP Addr", "ypbind.addr", FT_IPv4, BASE_NONE,
193 NULL, 0, "IP Address of server", HFILL }},
195 { &hf_ypbind_port, {
196 "Port", "ypbind.port", FT_UINT32, BASE_DEC,
197 NULL, 0, "Port to use", HFILL }},
199 { &hf_ypbind_setdom_version, {
200 "Version", "ypbind.setdom.version", FT_UINT32, BASE_DEC,
201 NULL, 0, "Version of setdom", HFILL }},
205 static gint *ett[] = {
206 &ett_ypbind,
209 proto_ypbind = proto_register_protocol("Yellow Pages Bind",
210 "YPBIND", "ypbind");
211 proto_register_field_array(proto_ypbind, hf, array_length(hf));
212 proto_register_subtree_array(ett, array_length(ett));
215 void
216 proto_reg_handoff_ypbind(void)
218 /* Register the protocol as RPC */
219 rpc_init_prog(proto_ypbind, YPBIND_PROGRAM, ett_ypbind);
220 /* Register the procedure tables */
221 rpc_init_proc_table(YPBIND_PROGRAM, 1, ypbind1_proc, hf_ypbind_procedure_v1);
222 rpc_init_proc_table(YPBIND_PROGRAM, 2, ypbind2_proc, hf_ypbind_procedure_v2);