2 * Routines for bootparams dissection
4 * $Id: packet-bootparams.c,v 1.19 2001/06/18 02:17:45 guy 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.
31 #ifdef HAVE_SYS_TYPES_H
32 #include <sys/types.h>
35 #ifdef HAVE_NETINET_IN_H
36 # include <netinet/in.h>
42 #include "packet-rpc.h"
43 #include "packet-bootparams.h"
45 static int proto_bootparams = -1;
46 static int hf_bootparams_host = -1;
47 static int hf_bootparams_domain = -1;
48 static int hf_bootparams_fileid = -1;
49 static int hf_bootparams_filepath = -1;
50 static int hf_bootparams_hostaddr = -1;
51 static int hf_bootparams_routeraddr = -1;
52 static int hf_bootparams_addresstype = -1;
54 static gint ett_bootparams = -1;
57 static const value_string addr_type[] =
64 dissect_bp_address(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, int hfindex)
70 type = tvb_get_ntohl(tvb, offset);
72 offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_bootparams_addresstype, offset);
76 ipaddr = ((tvb_get_guint8(tvb, offset+3 )&0xff)<<24)
77 |((tvb_get_guint8(tvb, offset+7 )&0xff)<<16)
78 |((tvb_get_guint8(tvb, offset+11)&0xff)<<8 )
79 |((tvb_get_guint8(tvb, offset+15)&0xff) );
80 proto_tree_add_ipv4(tree, hfindex, tvb,
81 offset, 16, ntohl(ipaddr));
94 dissect_getfile_call(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
98 offset = dissect_rpc_string(tvb, pinfo, tree, hf_bootparams_host, offset, NULL);
99 offset = dissect_rpc_string(tvb, pinfo, tree, hf_bootparams_fileid, offset, NULL);
106 dissect_getfile_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
110 offset = dissect_rpc_string(tvb, pinfo, tree, hf_bootparams_host, offset, NULL);
111 offset = dissect_bp_address(tvb, offset, pinfo, tree, hf_bootparams_hostaddr);
112 offset = dissect_rpc_string(tvb, pinfo, tree, hf_bootparams_filepath, offset, NULL);
119 dissect_whoami_call(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
123 offset = dissect_bp_address(tvb, offset, pinfo, tree, hf_bootparams_hostaddr);
130 dissect_whoami_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
134 offset = dissect_rpc_string(tvb, pinfo, tree, hf_bootparams_host, offset, NULL);
135 offset = dissect_rpc_string(tvb, pinfo, tree, hf_bootparams_domain, offset, NULL);
136 offset = dissect_bp_address(tvb, offset, pinfo, tree, hf_bootparams_routeraddr);
142 /* proc number, "proc name", dissect_request, dissect_reply */
143 /* NULL as function pointer means: type of arguments is "void". */
144 static const vsff bootparams1_proc[] = {
145 { BOOTPARAMSPROC_NULL, "NULL",
147 { BOOTPARAMSPROC_WHOAMI, "WHOAMI",
148 dissect_whoami_call, dissect_whoami_reply },
149 { BOOTPARAMSPROC_GETFILE, "GETFILE",
150 dissect_getfile_call, dissect_getfile_reply },
151 { 0, NULL, NULL, NULL }
153 /* end of Bootparams version 1 */
157 proto_register_bootparams(void)
159 static hf_register_info hf[] = {
160 { &hf_bootparams_host, {
161 "Client Host", "bootparams.host", FT_STRING, BASE_DEC,
162 NULL, 0, "Client Host", HFILL }},
163 { &hf_bootparams_domain, {
164 "Client Domain", "bootparams.domain", FT_STRING, BASE_DEC,
165 NULL, 0, "Client Domain", HFILL }},
166 { &hf_bootparams_fileid, {
167 "File ID", "bootparams.fileid", FT_STRING, BASE_DEC,
168 NULL, 0, "File ID", HFILL }},
169 { &hf_bootparams_filepath, {
170 "File Path", "bootparams.filepath", FT_STRING, BASE_DEC,
171 NULL, 0, "File Path", HFILL }},
172 { &hf_bootparams_hostaddr, {
173 "Client Address", "bootparams.hostaddr", FT_IPv4, BASE_DEC,
174 NULL, 0, "Address", HFILL }},
175 { &hf_bootparams_routeraddr, {
176 "Router Address", "bootparams.routeraddr", FT_IPv4, BASE_DEC,
177 NULL, 0, "Router Address", HFILL }},
178 { &hf_bootparams_addresstype, {
179 "Address Type", "bootparams.type", FT_UINT32, BASE_DEC,
180 VALS(addr_type), 0, "Address Type", HFILL }},
182 static gint *ett[] = {
186 proto_bootparams = proto_register_protocol("Boot Parameters",
187 "BOOTPARAMS", "bootparams");
188 proto_register_field_array(proto_bootparams, hf, array_length(hf));
189 proto_register_subtree_array(ett, array_length(ett));
193 proto_reg_handoff_bootparams(void)
195 /* Register the protocol as RPC */
196 rpc_init_prog(proto_bootparams, BOOTPARAMS_PROGRAM, ett_bootparams);
197 /* Register the procedure tables */
198 rpc_init_proc_table(BOOTPARAMS_PROGRAM, 1, bootparams1_proc);