2 * Routines for HP remote management protocol
3 * Gilbert Ramirez <jochen@scram.de>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
31 #include <epan/packet.h>
32 #include <epan/etypes.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 col_set_str(pinfo->cinfo, COL_PROTOCOL, "RMP");
111 col_clear(pinfo->cinfo, COL_INFO);
113 type = tvb_get_guint8(tvb, 0);
115 if (check_col(pinfo->cinfo, COL_INFO)) {
116 col_add_str(pinfo->cinfo, COL_INFO,
117 val_to_str(type, rmp_type_vals, "Unknown Type"));
121 ti = proto_tree_add_item(tree, proto_rmp, tvb, 0, -1, ENC_NA);
122 rmp_tree = proto_item_add_subtree(ti, ett_rmp);
123 proto_tree_add_uint(rmp_tree, hf_rmp_type, tvb, 0, 1, type);
127 proto_tree_add_item(rmp_tree,
128 hf_rmp_retcode, tvb, 1, 1, ENC_BIG_ENDIAN);
129 proto_tree_add_item(rmp_tree,
130 hf_rmp_seqnum, tvb, 2, 4, ENC_BIG_ENDIAN);
131 proto_tree_add_item(rmp_tree,
132 hf_rmp_sessionid, tvb, 6, 2, ENC_BIG_ENDIAN);
133 proto_tree_add_item(rmp_tree,
134 hf_rmp_version, tvb, 8, 2, ENC_BIG_ENDIAN);
135 proto_tree_add_item(rmp_tree,
136 hf_rmp_machtype, tvb, 10, 20, ENC_ASCII|ENC_NA);
137 /* The remaining fields are optional */
138 if(!tvb_offset_exists(tvb, 30))
140 len = tvb_get_guint8(tvb, 30);
141 proto_tree_add_item(rmp_tree,
142 hf_rmp_filename, tvb, 30, 1, ENC_ASCII|ENC_NA);
143 if(tvb_offset_exists(tvb, len+31))
144 call_dissector(data_handle,
145 tvb_new_subset_remaining(tvb, len+31),
150 proto_tree_add_item(rmp_tree,
151 hf_rmp_retcode, tvb, 1, 1, ENC_BIG_ENDIAN);
152 proto_tree_add_item(rmp_tree,
153 hf_rmp_seqnum, tvb, 2, 4, ENC_BIG_ENDIAN);
154 proto_tree_add_item(rmp_tree,
155 hf_rmp_sessionid, tvb, 6, 2, ENC_BIG_ENDIAN);
156 proto_tree_add_item(rmp_tree,
157 hf_rmp_version, tvb, 8, 2, ENC_BIG_ENDIAN);
158 len = tvb_get_guint8(tvb, 10);
159 proto_tree_add_item(rmp_tree,
160 hf_rmp_filename, tvb, 10, 1, ENC_ASCII|ENC_NA);
161 if(tvb_offset_exists(tvb, len+11))
162 call_dissector(data_handle,
163 tvb_new_subset_remaining(tvb, len+11),
168 proto_tree_add_item(rmp_tree,
169 hf_rmp_retcode, tvb, 1, 1, ENC_BIG_ENDIAN);
170 proto_tree_add_item(rmp_tree,
171 hf_rmp_offset, tvb, 2, 4, ENC_BIG_ENDIAN);
172 proto_tree_add_item(rmp_tree,
173 hf_rmp_sessionid, tvb, 6, 2, ENC_BIG_ENDIAN);
174 proto_tree_add_item(rmp_tree,
175 hf_rmp_size, tvb, 8, 2, ENC_BIG_ENDIAN);
176 if(tvb_offset_exists(tvb, 10))
177 call_dissector(data_handle,
178 tvb_new_subset_remaining(tvb, 10),
183 proto_tree_add_item(rmp_tree,
184 hf_rmp_retcode, tvb, 1, 1, ENC_BIG_ENDIAN);
185 proto_tree_add_item(rmp_tree,
186 hf_rmp_offset, tvb, 2, 4, ENC_BIG_ENDIAN);
187 proto_tree_add_item(rmp_tree,
188 hf_rmp_sessionid, tvb, 6, 2, ENC_BIG_ENDIAN);
189 call_dissector(data_handle, tvb_new_subset_remaining(tvb,
190 8), pinfo, rmp_tree);
194 proto_tree_add_item(rmp_tree,
195 hf_rmp_retcode, tvb, 1, 1, ENC_BIG_ENDIAN);
196 proto_tree_add_text(rmp_tree,
197 tvb, 2, 4, "Reserved");
198 proto_tree_add_item(rmp_tree,
199 hf_rmp_sessionid, tvb, 6, 2, ENC_BIG_ENDIAN);
200 if(tvb_offset_exists(tvb, 8))
201 call_dissector(data_handle,
202 tvb_new_subset_remaining(tvb, 6),
206 call_dissector(data_handle, tvb_new_subset_remaining(tvb,
213 proto_register_rmp(void)
215 static hf_register_info hf[] = {
217 { "Type", "rmp.type", FT_UINT8, BASE_HEX,
218 VALS(rmp_type_vals), 0x0, NULL, HFILL }},
220 { "Returncode", "rmp.retcode", FT_UINT8, BASE_HEX,
221 VALS(rmp_error_vals), 0x0, NULL, HFILL }},
223 { "Sequence Number", "rmp.seqnum", FT_UINT32, BASE_HEX,
224 NULL, 0x0, NULL, HFILL }},
226 { "Session ID", "rmp.sessionid", FT_UINT16, BASE_HEX,
227 NULL, 0x0, NULL, HFILL }},
229 { "Version", "rmp.version", FT_UINT16, BASE_DEC,
230 NULL, 0x0, NULL, HFILL }},
232 { "Machine Type", "rmp.machtype", FT_STRING, BASE_NONE,
233 NULL, 0x0, NULL, HFILL }},
235 { "Filename", "rmp.filename", FT_UINT_STRING, BASE_NONE,
236 NULL, 0x0, NULL, HFILL }},
238 { "Offset", "rmp.offset", FT_UINT32, BASE_HEX,
239 NULL, 0x0, NULL, HFILL }},
241 { "Size", "rmp.size", FT_UINT16, BASE_DEC,
242 NULL, 0x0, NULL, HFILL }},
244 static gint *ett[] = {
248 proto_rmp = proto_register_protocol(
249 "HP Remote Maintenance Protocol", "RMP", "rmp");
250 proto_register_field_array(proto_rmp, hf, array_length(hf));
251 proto_register_subtree_array(ett, array_length(ett));
253 register_dissector("rmp", dissect_rmp, proto_rmp);
257 proto_reg_handoff_rmp(void)
259 dissector_handle_t rmp_handle;
261 data_handle = find_dissector("data");
263 rmp_handle = find_dissector("rmp");
264 dissector_add_uint("hpext.dxsap", HPEXT_DXSAP, rmp_handle);
265 dissector_add_uint("hpext.dxsap", HPEXT_SXSAP, rmp_handle);