Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-bootparams.c
blob179deaf549ff83226b89218abe3e4f5d88b5163f
1 /* packet-bootparams.c
2 * Routines for bootparams 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 * SPDX-License-Identifier: GPL-2.0-or-later
13 #include "config.h"
16 #include "packet-rpc.h"
18 #define BOOTPARAMSPROC_NULL 0
19 #define BOOTPARAMSPROC_WHOAMI 1
20 #define BOOTPARAMSPROC_GETFILE 2
22 #define BOOTPARAMS_PROGRAM 100026
24 void proto_register_bootparams(void);
25 void proto_reg_handoff_bootparams(void);
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;
37 static int ett_bootparams;
40 static const value_string addr_type[] =
42 { 1, "IPv4-ADDR" },
43 { 0, NULL }
46 static int
47 dissect_bp_address(tvbuff_t *tvb, int offset, proto_tree *tree, int hfindex)
49 uint32_t type;
50 uint32_t ipaddr;
53 type = tvb_get_ntohl(tvb, offset);
55 offset = dissect_rpc_uint32(tvb, tree, hf_bootparams_addresstype, offset);
57 switch(type){
58 case 1:
59 ipaddr = ((tvb_get_uint8(tvb, offset+3 )&0xff)<<24)
60 |((tvb_get_uint8(tvb, offset+7 )&0xff)<<16)
61 |((tvb_get_uint8(tvb, offset+11)&0xff)<<8 )
62 |((tvb_get_uint8(tvb, offset+15)&0xff) );
63 proto_tree_add_ipv4(tree, hfindex, tvb,
64 offset, 16, g_ntohl(ipaddr));
65 offset += 16;
66 break;
68 default:
69 break;
72 return offset;
76 static int
77 dissect_getfile_call(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
79 int offset = 0;
81 offset = dissect_rpc_string(tvb, tree, hf_bootparams_host, offset, NULL);
82 offset = dissect_rpc_string(tvb, tree, hf_bootparams_fileid, offset, NULL);
84 return offset;
87 static int
88 dissect_getfile_reply(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
90 int offset = 0;
92 offset = dissect_rpc_string(tvb, tree, hf_bootparams_host, offset, NULL);
93 offset = dissect_bp_address(tvb, offset, tree, hf_bootparams_hostaddr);
94 offset = dissect_rpc_string(tvb, tree, hf_bootparams_filepath, offset, NULL);
96 return offset;
99 static int
100 dissect_whoami_call(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
102 int offset = dissect_bp_address(tvb, 0, tree, hf_bootparams_hostaddr);
104 return offset;
107 static int
108 dissect_whoami_reply(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
110 int offset = 0;
112 offset = dissect_rpc_string(tvb, tree, hf_bootparams_host, offset, NULL);
113 offset = dissect_rpc_string(tvb, tree, hf_bootparams_domain, offset, NULL);
114 offset = dissect_bp_address(tvb, offset, tree, hf_bootparams_routeraddr);
116 return offset;
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 }
130 static const value_string bootparams1_proc_vals[] = {
131 { BOOTPARAMSPROC_NULL, "NULL" },
132 { BOOTPARAMSPROC_WHOAMI, "WHOAMI" },
133 { BOOTPARAMSPROC_GETFILE, "GETFILE" },
134 { 0, NULL }
136 /* end of Bootparams version 1 */
138 static const rpc_prog_vers_info bootparams_vers_info[] = {
139 { 1, bootparams1_proc, &hf_bootparams_procedure_v1 },
142 void
143 proto_register_bootparams(void)
145 static hf_register_info hf[] = {
146 { &hf_bootparams_procedure_v1, {
147 "V1 Procedure", "bootparams.procedure_v1", FT_UINT32, BASE_DEC,
148 VALS(bootparams1_proc_vals), 0, NULL, HFILL }},
149 { &hf_bootparams_host, {
150 "Client Host", "bootparams.host", FT_STRING, BASE_NONE,
151 NULL, 0, NULL, HFILL }},
152 { &hf_bootparams_domain, {
153 "Client Domain", "bootparams.domain", FT_STRING, BASE_NONE,
154 NULL, 0, NULL, HFILL }},
155 { &hf_bootparams_fileid, {
156 "File ID", "bootparams.fileid", FT_STRING, BASE_NONE,
157 NULL, 0, NULL, HFILL }},
158 { &hf_bootparams_filepath, {
159 "File Path", "bootparams.filepath", FT_STRING, BASE_NONE,
160 NULL, 0, NULL, HFILL }},
161 { &hf_bootparams_hostaddr, {
162 "Client Address", "bootparams.hostaddr", FT_IPv4, BASE_NONE,
163 NULL, 0, NULL, HFILL }},
164 { &hf_bootparams_routeraddr, {
165 "Router Address", "bootparams.routeraddr", FT_IPv4, BASE_NONE,
166 NULL, 0, NULL, HFILL }},
167 { &hf_bootparams_addresstype, {
168 "Address Type", "bootparams.type", FT_UINT32, BASE_DEC,
169 VALS(addr_type), 0, NULL, HFILL }},
171 static int *ett[] = {
172 &ett_bootparams,
175 proto_bootparams = proto_register_protocol("Boot Parameters",
176 "BOOTPARAMS", "bootparams");
177 proto_register_field_array(proto_bootparams, hf, array_length(hf));
178 proto_register_subtree_array(ett, array_length(ett));
181 void
182 proto_reg_handoff_bootparams(void)
184 /* Register the protocol as RPC */
185 rpc_init_prog(proto_bootparams, BOOTPARAMS_PROGRAM, ett_bootparams,
186 G_N_ELEMENTS(bootparams_vers_info), bootparams_vers_info);
190 * Editor modelines - https://www.wireshark.org/tools/modelines.html
192 * Local variables:
193 * c-basic-offset: 8
194 * tab-width: 8
195 * indent-tabs-mode: t
196 * End:
198 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
199 * :indentSize=8:tabSize=8:noTabs=false: