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
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
;
37 dissect_ypbind_domain_v2_request(tvbuff_t
*tvb
, packet_info
*pinfo _U_
, proto_tree
*tree
, void* data _U_
)
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"},
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"},
64 dissect_ypbind_domain_v2_reply(tvbuff_t
*tvb
, packet_info
*pinfo _U_
, proto_tree
*tree
, void* data _U_
)
70 type
=tvb_get_ntohl(tvb
, offset
);
71 offset
= dissect_rpc_uint32(tvb
, tree
, hf_ypbind_resp_type
, offset
);
74 case YPBIND_RESP_TYPE_SUCC_VAL
:
76 proto_tree_add_item(tree
, hf_ypbind_addr
,
77 tvb
, offset
, 4, ENC_BIG_ENDIAN
);
81 offset
= dissect_rpc_uint32(tvb
, tree
,
82 hf_ypbind_port
, offset
);
85 case YPBIND_RESP_TYPE_FAIL_VAL
:
87 offset
= dissect_rpc_uint32(tvb
, tree
,
88 hf_ypbind_resp_type
, offset
);
96 dissect_ypbind_setdomain_v2_request(tvbuff_t
*tvb
, packet_info
*pinfo _U_
, proto_tree
*tree
, void* data _U_
)
101 offset
= dissect_rpc_string(tvb
, tree
,
102 hf_ypbind_domain
, offset
, NULL
);
105 proto_tree_add_item(tree
, hf_ypbind_addr
,
106 tvb
, offset
, 4, ENC_BIG_ENDIAN
);
110 offset
= dissect_rpc_uint32(tvb
, tree
,
111 hf_ypbind_port
, offset
);
114 offset
= dissect_rpc_uint32(tvb
, tree
,
115 hf_ypbind_setdom_version
, 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" },
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" },
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
},
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
}},
180 { &hf_ypbind_error
, {
181 "Error", "ypbind.error", FT_UINT32
, BASE_DEC
,
182 VALS(error_vals
), 0, "YPBIND Error code", HFILL
}},
185 "IP Addr", "ypbind.addr", FT_IPv4
, BASE_NONE
,
186 NULL
, 0, "IP Address of server", HFILL
}},
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
[] = {
202 proto_ypbind
= proto_register_protocol("Yellow Pages Bind",
204 proto_register_field_array(proto_ypbind
, hf
, array_length(hf
));
205 proto_register_subtree_array(ett
, array_length(ett
));
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
222 * indent-tabs-mode: t
225 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
226 * :indentSize=8:tabSize=8:noTabs=false: