Coverage Report

Created: 2026-09-28 06:52

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-ypbind.c
Line
Count
Source
1
/* packet-ypbind.c
2
 * Routines for ypbind dissection
3
 *
4
 * Wireshark - Network traffic analyzer
5
 * By Gerald Combs <gerald@wireshark.org>
6
 * Copyright 1998 Gerald Combs
7
 *
8
 * Copied from packet-smb.c
9
 *
10
 *    2001  Ronnie Sahlberg, added dissectors for the commands
11
 *
12
 * SPDX-License-Identifier: GPL-2.0-or-later
13
 */
14
15
#include "config.h"
16
17
#include "packet-rpc.h"
18
#include "packet-ypbind.h"
19
20
void proto_register_ypbind(void);
21
void proto_reg_handoff_ypbind(void);
22
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;
32
33
static int ett_ypbind;
34
35
36
static int
37
dissect_ypbind_domain_v2_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
38
0
{
39
  /* domain */
40
0
  return dissect_rpc_string(tvb, pinfo, tree, hf_ypbind_domain, 0, NULL);
41
0
}
42
43
0
#define YPBIND_RESP_TYPE_SUCC_VAL 1
44
0
#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}
49
};
50
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}
60
};
61
#endif
62
63
static int
64
dissect_ypbind_domain_v2_reply(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
65
0
{
66
0
  uint32_t type;
67
0
  unsigned offset = 0;
68
69
  /* response type */
70
0
  type=tvb_get_ntohl(tvb, offset);
71
0
  offset = dissect_rpc_uint32(tvb, tree, hf_ypbind_resp_type, offset);
72
73
0
  switch(type){
74
0
  case YPBIND_RESP_TYPE_SUCC_VAL:
75
    /* ip address */
76
0
    proto_tree_add_item(tree, hf_ypbind_addr,
77
0
      tvb, offset, 4, ENC_BIG_ENDIAN);
78
0
    offset += 4;
79
80
    /* port */
81
0
    offset = dissect_rpc_uint32(tvb, tree,
82
0
        hf_ypbind_port, offset);
83
84
0
    break;
85
0
  case YPBIND_RESP_TYPE_FAIL_VAL:
86
    /* error */
87
0
    offset = dissect_rpc_uint32(tvb, tree,
88
0
        hf_ypbind_resp_type, offset);
89
0
    break;
90
0
  }
91
92
0
  return offset;
93
0
}
94
95
static int
96
dissect_ypbind_setdomain_v2_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
97
0
{
98
0
  unsigned offset = 0;
99
100
  /* domain */
101
0
  offset = dissect_rpc_string(tvb, pinfo, tree,
102
0
      hf_ypbind_domain, offset, NULL);
103
104
  /* ip address */
105
0
  proto_tree_add_item(tree, hf_ypbind_addr,
106
0
    tvb, offset, 4, ENC_BIG_ENDIAN);
107
0
  offset += 4;
108
109
  /* port */
110
0
  offset = dissect_rpc_uint32(tvb, tree,
111
0
      hf_ypbind_port, offset);
112
113
  /* version */
114
0
  offset = dissect_rpc_uint32(tvb, tree,
115
0
      hf_ypbind_setdom_version, offset);
116
117
0
  return offset;
118
0
}
119
120
121
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 }
129
};
130
static const value_string ypbind_proc_vals[] = {
131
  { YPBINDPROC_NULL,  "NULL" },
132
  { YPBINDPROC_DOMAIN,  "DOMAIN" },
133
  { YPBINDPROC_SETDOM,  "SETDOMAIN" },
134
  { 0,  NULL }
135
};
136
/* end of YPBind version 1 */
137
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 }
146
};
147
/* end of YPBind version 2 */
148
149
150
static const rpc_prog_vers_info ypbind_vers_info[] = {
151
  { 1, ypbind1_proc, &hf_ypbind_procedure_v1 },
152
  { 2, ypbind2_proc, &hf_ypbind_procedure_v2 },
153
};
154
155
void
156
proto_register_ypbind(void)
157
16
{
158
16
  static hf_register_info hf[] = {
159
16
    { &hf_ypbind_procedure_v1, {
160
16
      "V1 Procedure", "ypbind.procedure_v1", FT_UINT32, BASE_DEC,
161
16
      VALS(ypbind_proc_vals), 0, NULL, HFILL }},
162
16
    { &hf_ypbind_procedure_v2, {
163
16
      "V2 Procedure", "ypbind.procedure_v2", FT_UINT32, BASE_DEC,
164
16
      VALS(ypbind_proc_vals), 0, NULL, HFILL }},
165
16
    { &hf_ypbind_domain, {
166
16
      "Domain", "ypbind.domain", FT_STRING, BASE_NONE,
167
16
      NULL, 0, "Name of the NIS/YP Domain", HFILL }},
168
169
16
    { &hf_ypbind_resp_type, {
170
16
      "Response Type", "ypbind.resp_type", FT_UINT32, BASE_DEC,
171
16
      VALS(resp_type_vals), 0, NULL, HFILL }},
172
173
#if 0
174
    { &hf_ypbind_error, {
175
      "Error", "ypbind.error", FT_UINT32, BASE_DEC,
176
      VALS(error_vals), 0, "YPBIND Error code", HFILL }},
177
#endif
178
16
    { &hf_ypbind_addr, {
179
16
      "IP Addr", "ypbind.addr", FT_IPv4, BASE_NONE,
180
16
      NULL, 0, "IP Address of server", HFILL }},
181
182
16
    { &hf_ypbind_port, {
183
16
      "Port", "ypbind.port", FT_UINT32, BASE_DEC,
184
16
      NULL, 0, "Port to use", HFILL }},
185
186
16
    { &hf_ypbind_setdom_version, {
187
16
      "Version", "ypbind.setdom.version", FT_UINT32, BASE_DEC,
188
16
      NULL, 0, "Version of setdom", HFILL }},
189
190
16
  };
191
192
16
  static int *ett[] = {
193
16
    &ett_ypbind,
194
16
  };
195
196
16
  proto_ypbind = proto_register_protocol("Yellow Pages Bind",
197
16
      "YPBIND", "ypbind");
198
16
  proto_register_field_array(proto_ypbind, hf, array_length(hf));
199
16
  proto_register_subtree_array(ett, array_length(ett));
200
16
}
201
202
void
203
proto_reg_handoff_ypbind(void)
204
16
{
205
  /* Register the protocol as RPC */
206
16
  rpc_init_prog(proto_ypbind, YPBIND_PROGRAM, ett_ypbind,
207
      G_N_ELEMENTS(ypbind_vers_info), ypbind_vers_info);
208
16
}
209
210
/*
211
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
212
 *
213
 * Local variables:
214
 * c-basic-offset: 8
215
 * tab-width: 8
216
 * indent-tabs-mode: t
217
 * End:
218
 *
219
 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
220
 * :indentSize=8:tabSize=8:noTabs=false:
221
 */