2 * Routines for bootparams dissection
4 * $Id: packet-bootparams.c,v 1.24 2002/11/01 00:48:38 sahlberg Exp $
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@ethereal.com>
8 * Copyright 1998 Gerald Combs
10 * Copied from packet-smb.c
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 #include "packet-rpc.h"
35 #include "packet-bootparams.h"
37 static int proto_bootparams = -1;
38 static int hf_bootparams_procedure_v1 = -1;
39 static int hf_bootparams_host = -1;
40 static int hf_bootparams_domain = -1;
41 static int hf_bootparams_fileid = -1;
42 static int hf_bootparams_filepath = -1;
43 static int hf_bootparams_hostaddr = -1;
44 static int hf_bootparams_routeraddr = -1;
45 static int hf_bootparams_addresstype = -1;
47 static gint ett_bootparams = -1;
50 static const value_string addr_type[] =
57 dissect_bp_address(tvbuff_t *tvb, int offset, proto_tree *tree, int hfindex)
63 type = tvb_get_ntohl(tvb, offset);
65 offset = dissect_rpc_uint32(tvb, tree, hf_bootparams_addresstype, offset);
69 ipaddr = ((tvb_get_guint8(tvb, offset+3 )&0xff)<<24)
70 |((tvb_get_guint8(tvb, offset+7 )&0xff)<<16)
71 |((tvb_get_guint8(tvb, offset+11)&0xff)<<8 )
72 |((tvb_get_guint8(tvb, offset+15)&0xff) );
73 proto_tree_add_ipv4(tree, hfindex, tvb,
74 offset, 16, g_ntohl(ipaddr));
87 dissect_getfile_call(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
91 offset = dissect_rpc_string(tvb, tree, hf_bootparams_host, offset, NULL);
92 offset = dissect_rpc_string(tvb, tree, hf_bootparams_fileid, offset, NULL);
99 dissect_getfile_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
103 offset = dissect_rpc_string(tvb, tree, hf_bootparams_host, offset, NULL);
104 offset = dissect_bp_address(tvb, offset, tree, hf_bootparams_hostaddr);
105 offset = dissect_rpc_string(tvb, tree, hf_bootparams_filepath, offset, NULL);
112 dissect_whoami_call(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
116 offset = dissect_bp_address(tvb, offset, tree, hf_bootparams_hostaddr);
123 dissect_whoami_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
127 offset = dissect_rpc_string(tvb, tree, hf_bootparams_host, offset, NULL);
128 offset = dissect_rpc_string(tvb, tree, hf_bootparams_domain, offset, NULL);
129 offset = dissect_bp_address(tvb, offset, tree, hf_bootparams_routeraddr);
135 /* proc number, "proc name", dissect_request, dissect_reply */
136 /* NULL as function pointer means: type of arguments is "void". */
137 static const vsff bootparams1_proc[] = {
138 { BOOTPARAMSPROC_NULL, "NULL",
140 { BOOTPARAMSPROC_WHOAMI, "WHOAMI",
141 dissect_whoami_call, dissect_whoami_reply },
142 { BOOTPARAMSPROC_GETFILE, "GETFILE",
143 dissect_getfile_call, dissect_getfile_reply },
144 { 0, NULL, NULL, NULL }
146 /* end of Bootparams version 1 */
148 static const value_string bootparams1_proc_vals[] = {
149 { BOOTPARAMSPROC_NULL, "NULL" },
150 { BOOTPARAMSPROC_WHOAMI, "WHOAMI" },
151 { BOOTPARAMSPROC_GETFILE, "GETFILE" },
156 proto_register_bootparams(void)
158 static hf_register_info hf[] = {
159 { &hf_bootparams_procedure_v1, {
160 "V1 Procedure", "bootparams.procedure_v1", FT_UINT32, BASE_DEC,
161 VALS(bootparams1_proc_vals), 0, "V1 Procedure", HFILL }},
162 { &hf_bootparams_host, {
163 "Client Host", "bootparams.host", FT_STRING, BASE_DEC,
164 NULL, 0, "Client Host", HFILL }},
165 { &hf_bootparams_domain, {
166 "Client Domain", "bootparams.domain", FT_STRING, BASE_DEC,
167 NULL, 0, "Client Domain", HFILL }},
168 { &hf_bootparams_fileid, {
169 "File ID", "bootparams.fileid", FT_STRING, BASE_DEC,
170 NULL, 0, "File ID", HFILL }},
171 { &hf_bootparams_filepath, {
172 "File Path", "bootparams.filepath", FT_STRING, BASE_DEC,
173 NULL, 0, "File Path", HFILL }},
174 { &hf_bootparams_hostaddr, {
175 "Client Address", "bootparams.hostaddr", FT_IPv4, BASE_DEC,
176 NULL, 0, "Address", HFILL }},
177 { &hf_bootparams_routeraddr, {
178 "Router Address", "bootparams.routeraddr", FT_IPv4, BASE_DEC,
179 NULL, 0, "Router Address", HFILL }},
180 { &hf_bootparams_addresstype, {
181 "Address Type", "bootparams.type", FT_UINT32, BASE_DEC,
182 VALS(addr_type), 0, "Address Type", HFILL }},
184 static gint *ett[] = {
188 proto_bootparams = proto_register_protocol("Boot Parameters",
189 "BOOTPARAMS", "bootparams");
190 proto_register_field_array(proto_bootparams, hf, array_length(hf));
191 proto_register_subtree_array(ett, array_length(ett));
195 proto_reg_handoff_bootparams(void)
197 /* Register the protocol as RPC */
198 rpc_init_prog(proto_bootparams, BOOTPARAMS_PROGRAM, ett_bootparams);
199 /* Register the procedure tables */
200 rpc_init_proc_table(BOOTPARAMS_PROGRAM, 1, bootparams1_proc, hf_bootparams_procedure_v1);