/src/wireshark/epan/dissectors/packet-bootparams.c
Line | Count | Source |
1 | | /* packet-bootparams.c |
2 | | * Routines for bootparams 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 | | * SPDX-License-Identifier: GPL-2.0-or-later |
11 | | */ |
12 | | |
13 | | #include "config.h" |
14 | | |
15 | | |
16 | | #include "packet-rpc.h" |
17 | | |
18 | | #define BOOTPARAMSPROC_NULL 0 |
19 | | #define BOOTPARAMSPROC_WHOAMI 1 |
20 | | #define BOOTPARAMSPROC_GETFILE 2 |
21 | | |
22 | 15 | #define BOOTPARAMS_PROGRAM 100026 |
23 | | |
24 | | void proto_register_bootparams(void); |
25 | | void proto_reg_handoff_bootparams(void); |
26 | | |
27 | | static int proto_bootparams; |
28 | | static int hf_bootparams_procedure_v1; |
29 | | static int hf_bootparams_host; |
30 | | static int hf_bootparams_domain; |
31 | | static int hf_bootparams_fileid; |
32 | | static int hf_bootparams_filepath; |
33 | | static int hf_bootparams_hostaddr; |
34 | | static int hf_bootparams_routeraddr; |
35 | | static int hf_bootparams_addresstype; |
36 | | |
37 | | static int ett_bootparams; |
38 | | |
39 | | |
40 | | static const value_string addr_type[] = |
41 | | { |
42 | | { 1, "IPv4-ADDR" }, |
43 | | { 0, NULL } |
44 | | }; |
45 | | |
46 | | static int |
47 | | dissect_bp_address(tvbuff_t *tvb, int offset, proto_tree *tree, int hfindex) |
48 | 0 | { |
49 | 0 | uint32_t type; |
50 | 0 | uint32_t ipaddr; |
51 | | |
52 | |
|
53 | 0 | type = tvb_get_ntohl(tvb, offset); |
54 | |
|
55 | 0 | offset = dissect_rpc_uint32(tvb, tree, hf_bootparams_addresstype, offset); |
56 | |
|
57 | 0 | switch(type){ |
58 | 0 | case 1: |
59 | 0 | ipaddr = ((tvb_get_uint8(tvb, offset+3 )&0xff)<<24) |
60 | 0 | |((tvb_get_uint8(tvb, offset+7 )&0xff)<<16) |
61 | 0 | |((tvb_get_uint8(tvb, offset+11)&0xff)<<8 ) |
62 | 0 | |((tvb_get_uint8(tvb, offset+15)&0xff) ); |
63 | 0 | proto_tree_add_ipv4(tree, hfindex, tvb, |
64 | 0 | offset, 16, g_ntohl(ipaddr)); |
65 | 0 | offset += 16; |
66 | 0 | break; |
67 | | |
68 | 0 | default: |
69 | 0 | break; |
70 | 0 | } |
71 | | |
72 | 0 | return offset; |
73 | 0 | } |
74 | | |
75 | | |
76 | | static int |
77 | | dissect_getfile_call(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) |
78 | 0 | { |
79 | 0 | int offset = 0; |
80 | |
|
81 | 0 | offset = dissect_rpc_string(tvb, pinfo, tree, hf_bootparams_host, offset, NULL); |
82 | 0 | offset = dissect_rpc_string(tvb, pinfo, tree, hf_bootparams_fileid, offset, NULL); |
83 | |
|
84 | 0 | return offset; |
85 | 0 | } |
86 | | |
87 | | static int |
88 | | dissect_getfile_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) |
89 | 0 | { |
90 | 0 | int offset = 0; |
91 | |
|
92 | 0 | offset = dissect_rpc_string(tvb, pinfo, tree, hf_bootparams_host, offset, NULL); |
93 | 0 | offset = dissect_bp_address(tvb, offset, tree, hf_bootparams_hostaddr); |
94 | 0 | offset = dissect_rpc_string(tvb, pinfo, tree, hf_bootparams_filepath, offset, NULL); |
95 | |
|
96 | 0 | return offset; |
97 | 0 | } |
98 | | |
99 | | static int |
100 | | dissect_whoami_call(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_) |
101 | 0 | { |
102 | 0 | int offset = dissect_bp_address(tvb, 0, tree, hf_bootparams_hostaddr); |
103 | |
|
104 | 0 | return offset; |
105 | 0 | } |
106 | | |
107 | | static int |
108 | | dissect_whoami_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) |
109 | 0 | { |
110 | 0 | int offset = 0; |
111 | |
|
112 | 0 | offset = dissect_rpc_string(tvb, pinfo, tree, hf_bootparams_host, offset, NULL); |
113 | 0 | offset = dissect_rpc_string(tvb, pinfo, tree, hf_bootparams_domain, offset, NULL); |
114 | 0 | offset = dissect_bp_address(tvb, offset, tree, hf_bootparams_routeraddr); |
115 | |
|
116 | 0 | return offset; |
117 | 0 | } |
118 | | |
119 | | /* proc number, "proc name", dissect_request, dissect_reply */ |
120 | | static const vsff bootparams1_proc[] = { |
121 | | { BOOTPARAMSPROC_NULL, "NULL", |
122 | | dissect_rpc_void, dissect_rpc_void }, |
123 | | { BOOTPARAMSPROC_WHOAMI, "WHOAMI", |
124 | | dissect_whoami_call, dissect_whoami_reply }, |
125 | | { BOOTPARAMSPROC_GETFILE, "GETFILE", |
126 | | dissect_getfile_call, dissect_getfile_reply }, |
127 | | { 0, NULL, NULL, NULL } |
128 | | }; |
129 | | |
130 | | static const value_string bootparams1_proc_vals[] = { |
131 | | { BOOTPARAMSPROC_NULL, "NULL" }, |
132 | | { BOOTPARAMSPROC_WHOAMI, "WHOAMI" }, |
133 | | { BOOTPARAMSPROC_GETFILE, "GETFILE" }, |
134 | | { 0, NULL } |
135 | | }; |
136 | | /* end of Bootparams version 1 */ |
137 | | |
138 | | static const rpc_prog_vers_info bootparams_vers_info[] = { |
139 | | { 1, bootparams1_proc, &hf_bootparams_procedure_v1 }, |
140 | | }; |
141 | | |
142 | | void |
143 | | proto_register_bootparams(void) |
144 | 15 | { |
145 | 15 | static hf_register_info hf[] = { |
146 | 15 | { &hf_bootparams_procedure_v1, { |
147 | 15 | "V1 Procedure", "bootparams.procedure_v1", FT_UINT32, BASE_DEC, |
148 | 15 | VALS(bootparams1_proc_vals), 0, NULL, HFILL }}, |
149 | 15 | { &hf_bootparams_host, { |
150 | 15 | "Client Host", "bootparams.host", FT_STRING, BASE_NONE, |
151 | 15 | NULL, 0, NULL, HFILL }}, |
152 | 15 | { &hf_bootparams_domain, { |
153 | 15 | "Client Domain", "bootparams.domain", FT_STRING, BASE_NONE, |
154 | 15 | NULL, 0, NULL, HFILL }}, |
155 | 15 | { &hf_bootparams_fileid, { |
156 | 15 | "File ID", "bootparams.fileid", FT_STRING, BASE_NONE, |
157 | 15 | NULL, 0, NULL, HFILL }}, |
158 | 15 | { &hf_bootparams_filepath, { |
159 | 15 | "File Path", "bootparams.filepath", FT_STRING, BASE_NONE, |
160 | 15 | NULL, 0, NULL, HFILL }}, |
161 | 15 | { &hf_bootparams_hostaddr, { |
162 | 15 | "Client Address", "bootparams.hostaddr", FT_IPv4, BASE_NONE, |
163 | 15 | NULL, 0, NULL, HFILL }}, |
164 | 15 | { &hf_bootparams_routeraddr, { |
165 | 15 | "Router Address", "bootparams.routeraddr", FT_IPv4, BASE_NONE, |
166 | 15 | NULL, 0, NULL, HFILL }}, |
167 | 15 | { &hf_bootparams_addresstype, { |
168 | 15 | "Address Type", "bootparams.type", FT_UINT32, BASE_DEC, |
169 | 15 | VALS(addr_type), 0, NULL, HFILL }}, |
170 | 15 | }; |
171 | 15 | static int *ett[] = { |
172 | 15 | &ett_bootparams, |
173 | 15 | }; |
174 | | |
175 | 15 | proto_bootparams = proto_register_protocol("Boot Parameters", |
176 | 15 | "BOOTPARAMS", "bootparams"); |
177 | 15 | proto_register_field_array(proto_bootparams, hf, array_length(hf)); |
178 | 15 | proto_register_subtree_array(ett, array_length(ett)); |
179 | 15 | } |
180 | | |
181 | | void |
182 | | proto_reg_handoff_bootparams(void) |
183 | 15 | { |
184 | | /* Register the protocol as RPC */ |
185 | 15 | rpc_init_prog(proto_bootparams, BOOTPARAMS_PROGRAM, ett_bootparams, |
186 | | G_N_ELEMENTS(bootparams_vers_info), bootparams_vers_info); |
187 | 15 | } |
188 | | |
189 | | /* |
190 | | * Editor modelines - https://www.wireshark.org/tools/modelines.html |
191 | | * |
192 | | * Local variables: |
193 | | * c-basic-offset: 8 |
194 | | * tab-width: 8 |
195 | | * indent-tabs-mode: t |
196 | | * End: |
197 | | * |
198 | | * vi: set shiftwidth=8 tabstop=8 noexpandtab: |
199 | | * :indentSize=8:tabSize=8:noTabs=false: |
200 | | */ |