2 * Routines for HP remote management protocol
3 * Gilbert Ramirez <jochen@scram.de>
5 * $Id: packet-rmp.c,v 1.2 2003/03/03 14:08:39 jmayer Exp $
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@ethereal.com>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 #include <epan/packet.h>
34 #include "packet-hpext.h"
36 static dissector_handle_t data_handle;
38 static int proto_rmp = -1;
40 static int hf_rmp_type = -1;
41 static int hf_rmp_retcode = -1;
42 static int hf_rmp_seqnum = -1;
43 static int hf_rmp_sessionid = -1;
44 static int hf_rmp_version = -1;
45 static int hf_rmp_machtype = -1;
46 static int hf_rmp_filename = -1;
47 static int hf_rmp_offset = -1;
48 static int hf_rmp_size = -1;
50 static gint ett_rmp = -1;
53 * Possible values for "rmp_type" fields.
56 #define RMP_BOOT_REQ 1 /* boot request packet */
57 #define RMP_BOOT_REPL 129 /* boot reply packet */
58 #define RMP_READ_REQ 2 /* read request packet */
59 #define RMP_READ_REPL 130 /* read reply packet */
60 #define RMP_BOOT_DONE 3 /* boot complete packet */
67 #define RMP_E_EOF 2 /* read reply: returned end of file */
68 #define RMP_E_ABORT 3 /* abort operation */
69 #define RMP_E_BUSY 4 /* boot reply: server busy */
70 #define RMP_E_TIMEOUT 5 /* lengthen time out (not implemented) */
71 #define RMP_E_NOFILE 16 /* boot reply: file does not exist */
72 #define RMP_E_OPENFILE 17 /* boot reply: file open failed */
73 #define RMP_E_NODFLT 18 /* boot reply: default file does not exist */
74 #define RMP_E_OPENDFLT 19 /* boot reply: default file open failed */
75 #define RMP_E_BADSID 25 /* read reply: bad session ID */
76 #define RMP_E_BADPACKET 27 /* Bad packet detected */
78 const value_string rmp_type_vals[] = {
79 { RMP_BOOT_REQ, "Boot Request" },
80 { RMP_BOOT_REPL, "Boot Reply" },
81 { RMP_READ_REQ, "Read Request" },
82 { RMP_READ_REPL, "Read Reply" },
83 { RMP_BOOT_DONE, "Boot Done" },
87 const value_string rmp_error_vals[] = {
89 { RMP_E_EOF, "End Of File" },
90 { RMP_E_ABORT, "Abort Operation" },
91 { RMP_E_BUSY, "Server Busy" },
92 { RMP_E_TIMEOUT, "Lengthen Time Out" },
93 { RMP_E_NOFILE, "File Does Not Exist" },
94 { RMP_E_OPENFILE, "File Open Failed" },
95 { RMP_E_NODFLT, "Default File Does Not Exist" },
96 { RMP_E_OPENDFLT, "Default File Open Failed" },
97 { RMP_E_BADSID, "Bad Session Id" },
98 { RMP_E_OPENDFLT, "Bad Packet Detected" },
103 dissect_rmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
105 proto_tree *rmp_tree = NULL;
106 proto_item *ti = NULL;
109 if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
110 col_set_str(pinfo->cinfo, COL_PROTOCOL, "RMP");
113 if (check_col(pinfo->cinfo, COL_INFO)) {
114 col_clear(pinfo->cinfo, COL_INFO);
117 type = tvb_get_guint8(tvb, 0);
119 if (check_col(pinfo->cinfo, COL_INFO)) {
120 col_set_str(pinfo->cinfo, COL_INFO,
121 val_to_str(type, rmp_type_vals, "Unknown Type"));
125 ti = proto_tree_add_item(tree, proto_rmp, tvb, 0, -1, FALSE);
126 rmp_tree = proto_item_add_subtree(ti, ett_rmp);
127 proto_tree_add_uint(rmp_tree, hf_rmp_type, tvb, 0, 1, type);
131 proto_tree_add_item(rmp_tree,
132 hf_rmp_retcode, tvb, 1, 1, FALSE);
133 proto_tree_add_item(rmp_tree,
134 hf_rmp_seqnum, tvb, 2, 4, FALSE);
135 proto_tree_add_item(rmp_tree,
136 hf_rmp_sessionid, tvb, 6, 2, FALSE);
137 proto_tree_add_item(rmp_tree,
138 hf_rmp_version, tvb, 8, 2, FALSE);
139 proto_tree_add_item(rmp_tree,
140 hf_rmp_machtype, tvb, 10, 20, FALSE);
141 /* The remaining fields are optional */
142 if(!tvb_offset_exists(tvb, 30))
144 len = tvb_get_guint8(tvb, 30);
145 proto_tree_add_item(rmp_tree,
146 hf_rmp_filename, tvb, 30, 1, FALSE);
147 if(tvb_offset_exists(tvb, len+31))
148 call_dissector(data_handle,
149 tvb_new_subset(tvb, len+31, -1, -1),
154 proto_tree_add_item(rmp_tree,
155 hf_rmp_retcode, tvb, 1, 1, FALSE);
156 proto_tree_add_item(rmp_tree,
157 hf_rmp_seqnum, tvb, 2, 4, FALSE);
158 proto_tree_add_item(rmp_tree,
159 hf_rmp_sessionid, tvb, 6, 2, FALSE);
160 proto_tree_add_item(rmp_tree,
161 hf_rmp_version, tvb, 8, 2, FALSE);
162 len = tvb_get_guint8(tvb, 10);
163 proto_tree_add_item(rmp_tree,
164 hf_rmp_filename, tvb, 10, 1, FALSE);
165 if(tvb_offset_exists(tvb, len+11))
166 call_dissector(data_handle,
167 tvb_new_subset(tvb, len+11, -1, -1),
172 proto_tree_add_item(rmp_tree,
173 hf_rmp_retcode, tvb, 1, 1, FALSE);
174 proto_tree_add_item(rmp_tree,
175 hf_rmp_offset, tvb, 2, 4, FALSE);
176 proto_tree_add_item(rmp_tree,
177 hf_rmp_sessionid, tvb, 6, 2, FALSE);
178 proto_tree_add_item(rmp_tree,
179 hf_rmp_size, tvb, 8, 2, FALSE);
180 if(tvb_offset_exists(tvb, 10))
181 call_dissector(data_handle,
182 tvb_new_subset(tvb, 10, -1, -1),
187 proto_tree_add_item(rmp_tree,
188 hf_rmp_retcode, tvb, 1, 1, FALSE);
189 proto_tree_add_item(rmp_tree,
190 hf_rmp_offset, tvb, 2, 4, FALSE);
191 proto_tree_add_item(rmp_tree,
192 hf_rmp_sessionid, tvb, 6, 2, FALSE);
193 call_dissector(data_handle, tvb_new_subset(tvb,
194 8, -1, -1), pinfo, rmp_tree);
198 proto_tree_add_item(rmp_tree,
199 hf_rmp_retcode, tvb, 1, 1, FALSE);
200 proto_tree_add_text(rmp_tree,
201 tvb, 2, 4, "Reserved");
202 proto_tree_add_item(rmp_tree,
203 hf_rmp_sessionid, tvb, 6, 2, FALSE);
204 if(tvb_offset_exists(tvb, 8))
205 call_dissector(data_handle,
206 tvb_new_subset(tvb, 6, -1, -1),
210 call_dissector(data_handle, tvb_new_subset(tvb,
211 1, -1, -1), pinfo, tree);
217 proto_register_rmp(void)
219 static hf_register_info hf[] = {
221 { "Type", "rmp.type", FT_UINT8, BASE_HEX,
222 VALS(rmp_type_vals), 0x0, "", HFILL }},
224 { "Returncode", "rmp.retcode", FT_UINT8, BASE_HEX,
225 VALS(rmp_error_vals), 0x0, "", HFILL }},
227 { "Sequence Number", "rmp.seqnum", FT_UINT32, BASE_HEX,
228 NULL, 0x0, "", HFILL }},
230 { "Session ID", "rmp.sessionid", FT_UINT16, BASE_HEX,
231 NULL, 0x0, "", HFILL }},
233 { "Version", "rmp.version", FT_UINT16, BASE_DEC,
234 NULL, 0x0, "", HFILL }},
236 { "Machine Type", "rmp.machtype", FT_STRING, BASE_DEC,
237 NULL, 0x0, "", HFILL }},
239 { "Filename", "rmp.filename", FT_UINT_STRING, BASE_DEC,
240 NULL, 0x0, "", HFILL }},
242 { "Offset", "rmp.offset", FT_UINT32, BASE_HEX,
243 NULL, 0x0, "", HFILL }},
245 { "Size", "rmp.size", FT_UINT16, BASE_DEC,
246 NULL, 0x0, "", HFILL }},
248 static gint *ett[] = {
252 proto_rmp = proto_register_protocol(
253 "HP Remote Maintenance Protocol", "RMP", "rmp");
254 proto_register_field_array(proto_rmp, hf, array_length(hf));
255 proto_register_subtree_array(ett, array_length(ett));
257 register_dissector("rmp", dissect_rmp, proto_rmp);
261 proto_reg_handoff_rmp(void)
263 dissector_handle_t rmp_handle;
265 data_handle = find_dissector("data");
267 rmp_handle = find_dissector("rmp");
268 dissector_add("hpext.dxsap", HPEXT_DXSAP, rmp_handle);
269 dissector_add("hpext.dxsap", HPEXT_SXSAP, rmp_handle);