epan/dissectors/pidl/samr/samr.cnf cnf_dissect_lsa_BinaryString => lsarpc_dissect_str...
[wireshark-sm.git] / epan / dissectors / packet-ypbind.c
blob40979d899dd598a830c2e21a2c0d60daae2b17bc
1 /* packet-ypbind.c
2 * Routines for ypbind dissection
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * Copied from packet-smb.c
10 * 2001 Ronnie Sahlberg, added dissectors for the commands
12 * SPDX-License-Identifier: GPL-2.0-or-later
15 #include "config.h"
17 #include "packet-rpc.h"
18 #include "packet-ypbind.h"
20 void proto_register_ypbind(void);
21 void proto_reg_handoff_ypbind(void);
23 static int proto_ypbind;
24 static int hf_ypbind_procedure_v1;
25 static int hf_ypbind_procedure_v2;
26 static int hf_ypbind_domain;
27 static int hf_ypbind_resp_type;
28 /* static int hf_ypbind_error; */
29 static int hf_ypbind_addr;
30 static int hf_ypbind_port;
31 static int hf_ypbind_setdom_version;
33 static int ett_ypbind;
36 static int
37 dissect_ypbind_domain_v2_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
39 /* domain */
40 return dissect_rpc_string(tvb, tree, hf_ypbind_domain, 0, NULL);
43 #define YPBIND_RESP_TYPE_SUCC_VAL 1
44 #define YPBIND_RESP_TYPE_FAIL_VAL 2
45 static const value_string resp_type_vals[] = {
46 {YPBIND_RESP_TYPE_SUCC_VAL, "SUCC_VAL"},
47 {YPBIND_RESP_TYPE_FAIL_VAL, "FAIL_VAL"},
48 {0, NULL}
51 #if 0
52 #define YPBIND_ERROR_ERR 1
53 #define YPBIND_ERROR_NOSERV 2
54 #define YPBIND_ERROR_RESC 3
55 static const value_string error_vals[] = {
56 {YPBIND_ERROR_ERR, "Internal error"},
57 {YPBIND_ERROR_NOSERV, "No bound server for passed domain"},
58 {YPBIND_ERROR_RESC, "System resource allocation failure"},
59 {0, NULL}
61 #endif
63 static int
64 dissect_ypbind_domain_v2_reply(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
66 uint32_t type;
67 int offset = 0;
69 /* response type */
70 type=tvb_get_ntohl(tvb, offset);
71 offset = dissect_rpc_uint32(tvb, tree, hf_ypbind_resp_type, offset);
73 switch(type){
74 case YPBIND_RESP_TYPE_SUCC_VAL:
75 /* ip address */
76 proto_tree_add_item(tree, hf_ypbind_addr,
77 tvb, offset, 4, ENC_BIG_ENDIAN);
78 offset += 4;
80 /* port */
81 offset = dissect_rpc_uint32(tvb, tree,
82 hf_ypbind_port, offset);
84 break;
85 case YPBIND_RESP_TYPE_FAIL_VAL:
86 /* error */
87 offset = dissect_rpc_uint32(tvb, tree,
88 hf_ypbind_resp_type, offset);
89 break;
92 return offset;
95 static int
96 dissect_ypbind_setdomain_v2_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
98 int offset = 0;
100 /* domain */
101 offset = dissect_rpc_string(tvb, tree,
102 hf_ypbind_domain, offset, NULL);
104 /* ip address */
105 proto_tree_add_item(tree, hf_ypbind_addr,
106 tvb, offset, 4, ENC_BIG_ENDIAN);
107 offset += 4;
109 /* port */
110 offset = dissect_rpc_uint32(tvb, tree,
111 hf_ypbind_port, offset);
113 /* version */
114 offset = dissect_rpc_uint32(tvb, tree,
115 hf_ypbind_setdom_version, offset);
117 return offset;
122 /* proc number, "proc name", dissect_request, dissect_reply */
123 static const vsff ypbind1_proc[] = {
124 { YPBINDPROC_NULL, "NULL",
125 dissect_rpc_void, dissect_rpc_void },
126 { YPBINDPROC_DOMAIN, "DOMAIN", dissect_rpc_unknown, dissect_rpc_unknown },
127 { YPBINDPROC_SETDOM, "SETDOMAIN", dissect_rpc_unknown, dissect_rpc_unknown },
128 { 0, NULL, NULL, NULL }
130 static const value_string ypbind1_proc_vals[] = {
131 { YPBINDPROC_NULL, "NULL" },
132 { YPBINDPROC_DOMAIN, "DOMAIN" },
133 { YPBINDPROC_SETDOM, "SETDOMAIN" },
134 { 0, NULL }
136 /* end of YPBind version 1 */
138 static const vsff ypbind2_proc[] = {
139 { YPBINDPROC_NULL, "NULL",
140 dissect_rpc_void, dissect_rpc_void },
141 { YPBINDPROC_DOMAIN, "DOMAIN",
142 dissect_ypbind_domain_v2_request, dissect_ypbind_domain_v2_reply},
143 { YPBINDPROC_SETDOM, "SETDOMAIN",
144 dissect_ypbind_setdomain_v2_request, dissect_rpc_void },
145 { 0, NULL, NULL, NULL }
147 static const value_string ypbind2_proc_vals[] = {
148 { YPBINDPROC_NULL, "NULL" },
149 { YPBINDPROC_DOMAIN, "DOMAIN" },
150 { YPBINDPROC_SETDOM, "SETDOMAIN" },
151 { 0, NULL }
153 /* end of YPBind version 2 */
156 static const rpc_prog_vers_info ypbind_vers_info[] = {
157 { 1, ypbind1_proc, &hf_ypbind_procedure_v1 },
158 { 2, ypbind2_proc, &hf_ypbind_procedure_v2 },
161 void
162 proto_register_ypbind(void)
164 static hf_register_info hf[] = {
165 { &hf_ypbind_procedure_v1, {
166 "V1 Procedure", "ypbind.procedure_v1", FT_UINT32, BASE_DEC,
167 VALS(ypbind1_proc_vals), 0, NULL, HFILL }},
168 { &hf_ypbind_procedure_v2, {
169 "V2 Procedure", "ypbind.procedure_v2", FT_UINT32, BASE_DEC,
170 VALS(ypbind2_proc_vals), 0, NULL, HFILL }},
171 { &hf_ypbind_domain, {
172 "Domain", "ypbind.domain", FT_STRING, BASE_NONE,
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, NULL, HFILL }},
179 #if 0
180 { &hf_ypbind_error, {
181 "Error", "ypbind.error", FT_UINT32, BASE_DEC,
182 VALS(error_vals), 0, "YPBIND Error code", HFILL }},
183 #endif
184 { &hf_ypbind_addr, {
185 "IP Addr", "ypbind.addr", FT_IPv4, BASE_NONE,
186 NULL, 0, "IP Address of server", HFILL }},
188 { &hf_ypbind_port, {
189 "Port", "ypbind.port", FT_UINT32, BASE_DEC,
190 NULL, 0, "Port to use", HFILL }},
192 { &hf_ypbind_setdom_version, {
193 "Version", "ypbind.setdom.version", FT_UINT32, BASE_DEC,
194 NULL, 0, "Version of setdom", HFILL }},
198 static int *ett[] = {
199 &ett_ypbind,
202 proto_ypbind = proto_register_protocol("Yellow Pages Bind",
203 "YPBIND", "ypbind");
204 proto_register_field_array(proto_ypbind, hf, array_length(hf));
205 proto_register_subtree_array(ett, array_length(ett));
208 void
209 proto_reg_handoff_ypbind(void)
211 /* Register the protocol as RPC */
212 rpc_init_prog(proto_ypbind, YPBIND_PROGRAM, ett_ypbind,
213 G_N_ELEMENTS(ypbind_vers_info), ypbind_vers_info);
217 * Editor modelines - https://www.wireshark.org/tools/modelines.html
219 * Local variables:
220 * c-basic-offset: 8
221 * tab-width: 8
222 * indent-tabs-mode: t
223 * End:
225 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
226 * :indentSize=8:tabSize=8:noTabs=false: