2 * Routines for bootparams dissection
4 * $Id: packet-bootparams.c,v 1.9 2000/04/04 06:46:24 guy Exp $
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@zing.org>
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;
53 static gint ett_bootparams = -1;
55 int dissect_bp_address(const u_char *pd, int offset, frame_data *fd,
56 proto_tree *tree, int hfindex)
61 /* get the address type */
62 if ( !BYTES_ARE_IN_FRAME(offset, 1)) return offset;
63 type = pntohl(&pd[offset]); /* type of address */
65 proto_tree_add_item(tree, hf_bootparams_addresstype,
70 if ( type != 1 ) /* only know how to handle this type of address */
75 /* get the address itself - weird ass format */
76 if ( ! BYTES_ARE_IN_FRAME(offset, 16)) return offset;
77 ipaddr = (pd[offset+3]<<24) + (pd[offset+7]<<16) +
78 (pd[offset+11]<<8) + (pd[offset+15]);
79 proto_tree_add_item(tree, hfindex,
80 offset, 16, ntohl(ipaddr));
87 /* Dissect a getfile call */
88 int dissect_getfile_call(const u_char *pd, int offset, frame_data *fd,
93 offset = dissect_rpc_string(pd,offset,fd,tree,hf_bootparams_host,NULL);
94 offset = dissect_rpc_string(pd,offset,fd,tree,hf_bootparams_fileid,NULL);
100 /* Dissect a getfile reply */
101 int dissect_getfile_reply(const u_char *pd, int offset, frame_data *fd,
106 offset = dissect_rpc_string(pd,offset,fd,tree,hf_bootparams_host,NULL);
107 offset = dissect_bp_address(pd,offset,fd,tree,hf_bootparams_hostaddr);
108 offset = dissect_rpc_string(pd,offset,fd,tree,hf_bootparams_filepath,NULL);
114 /* Dissect a whoami call */
115 int dissect_whoami_call(const u_char *pd, int offset, frame_data *fd,
120 offset = dissect_bp_address(pd,offset,fd,tree,hf_bootparams_hostaddr);
126 /* Dissect a whoami reply */
127 int dissect_whoami_reply(const u_char *pd, int offset, frame_data *fd,
132 offset = dissect_rpc_string(pd,offset,fd,tree,hf_bootparams_host,NULL);
133 offset = dissect_rpc_string(pd,offset,fd,tree,hf_bootparams_domain,NULL);
134 offset = dissect_bp_address(pd,offset,fd,tree,hf_bootparams_routeraddr);
140 /* proc number, "proc name", dissect_request, dissect_reply */
141 /* NULL as function pointer means: take the generic one. */
142 const vsff bootparams1_proc[] = {
143 { BOOTPARAMSPROC_NULL, "NULL",
145 { BOOTPARAMSPROC_WHOAMI, "WHOAMI",
146 dissect_whoami_call, dissect_whoami_reply },
147 { BOOTPARAMSPROC_GETFILE, "GETFILE",
148 dissect_getfile_call, dissect_getfile_reply },
149 { 0, NULL, NULL, NULL }
151 /* end of Bootparams version 1 */
155 proto_register_bootparams(void)
157 static hf_register_info hf[] = {
158 { &hf_bootparams_host, {
159 "Client Host", "bootparams.host", FT_STRING, BASE_DEC,
160 NULL, 0, "Client Host" }},
161 { &hf_bootparams_domain, {
162 "Client Domain", "bootparams.domain", FT_STRING, BASE_DEC,
163 NULL, 0, "Client Domain" }},
164 { &hf_bootparams_fileid, {
165 "File ID", "bootparams.fileid", FT_STRING, BASE_DEC,
166 NULL, 0, "File ID" }},
167 { &hf_bootparams_filepath, {
168 "File Path", "bootparams.filepath", FT_STRING, BASE_DEC,
169 NULL, 0, "File Path" }},
170 { &hf_bootparams_hostaddr, {
171 "Client Address", "bootparams.hostaddr", FT_IPv4, BASE_DEC,
172 NULL, 0, "Address" }},
173 { &hf_bootparams_routeraddr, {
174 "Router Address", "bootparams.routeraddr", FT_IPv4, BASE_DEC,
175 NULL, 0, "Router Address" }},
177 static gint *ett[] = {
181 proto_bootparams = proto_register_protocol("Boot Parameters", "bootparams");
182 proto_register_field_array(proto_bootparams, hf, array_length(hf));
183 proto_register_subtree_array(ett, array_length(ett));
187 proto_reg_handoff_bootparams(void)
189 /* Register the protocol as RPC */
190 rpc_init_prog(proto_bootparams, BOOTPARAMS_PROGRAM, ett_bootparams);
191 /* Register the procedure tables */
192 rpc_init_proc_table(BOOTPARAMS_PROGRAM, 1, bootparams1_proc);