MSWSP: add two more Property Sets
[wireshark-wip.git] / epan / dissectors / packet-rmp.c
blob11237b4c78e6ddd58f7da37a8edb982d45627d24
1 /* packet-rmp.c
2 * Routines for HP remote management protocol
3 * Gilbert Ramirez <jochen@scram.de>
5 * $Id$
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.
26 #include "config.h"
28 #include <glib.h>
29 #include <epan/packet.h>
30 #include <epan/etypes.h>
32 #include "packet-hpext.h"
34 static dissector_handle_t data_handle;
36 static int proto_rmp = -1;
38 static int hf_rmp_type = -1;
39 static int hf_rmp_retcode = -1;
40 static int hf_rmp_seqnum = -1;
41 static int hf_rmp_sessionid = -1;
42 static int hf_rmp_version = -1;
43 static int hf_rmp_machtype = -1;
44 static int hf_rmp_filename = -1;
45 static int hf_rmp_offset = -1;
46 static int hf_rmp_size = -1;
48 static gint ett_rmp = -1;
51 * Possible values for "rmp_type" fields.
54 #define RMP_BOOT_REQ 1 /* boot request packet */
55 #define RMP_BOOT_REPL 129 /* boot reply packet */
56 #define RMP_READ_REQ 2 /* read request packet */
57 #define RMP_READ_REPL 130 /* read reply packet */
58 #define RMP_BOOT_DONE 3 /* boot complete packet */
61 * RMP error codes
64 #define RMP_E_OKAY 0
65 #define RMP_E_EOF 2 /* read reply: returned end of file */
66 #define RMP_E_ABORT 3 /* abort operation */
67 #define RMP_E_BUSY 4 /* boot reply: server busy */
68 #define RMP_E_TIMEOUT 5 /* lengthen time out (not implemented) */
69 #define RMP_E_NOFILE 16 /* boot reply: file does not exist */
70 #define RMP_E_OPENFILE 17 /* boot reply: file open failed */
71 #define RMP_E_NODFLT 18 /* boot reply: default file does not exist */
72 #define RMP_E_OPENDFLT 19 /* boot reply: default file open failed */
73 #define RMP_E_BADSID 25 /* read reply: bad session ID */
74 #define RMP_E_BADPACKET 27 /* Bad packet detected */
76 const value_string rmp_type_vals[] = {
77 { RMP_BOOT_REQ, "Boot Request" },
78 { RMP_BOOT_REPL, "Boot Reply" },
79 { RMP_READ_REQ, "Read Request" },
80 { RMP_READ_REPL, "Read Reply" },
81 { RMP_BOOT_DONE, "Boot Done" },
82 { 0x00, NULL }
85 const value_string rmp_error_vals[] = {
86 { RMP_E_OKAY, "OK" },
87 { RMP_E_EOF, "End Of File" },
88 { RMP_E_ABORT, "Abort Operation" },
89 { RMP_E_BUSY, "Server Busy" },
90 { RMP_E_TIMEOUT, "Lengthen Time Out" },
91 { RMP_E_NOFILE, "File Does Not Exist" },
92 { RMP_E_OPENFILE, "File Open Failed" },
93 { RMP_E_NODFLT, "Default File Does Not Exist" },
94 { RMP_E_OPENDFLT, "Default File Open Failed" },
95 { RMP_E_BADSID, "Bad Session Id" },
96 { RMP_E_OPENDFLT, "Bad Packet Detected" },
97 { 0x00, NULL }
100 static void
101 dissect_rmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
103 proto_tree *rmp_tree = NULL;
104 proto_item *ti = NULL;
105 guint8 type, len;
107 col_set_str(pinfo->cinfo, COL_PROTOCOL, "RMP");
109 col_clear(pinfo->cinfo, COL_INFO);
111 type = tvb_get_guint8(tvb, 0);
113 col_set_str(pinfo->cinfo, COL_INFO,
114 val_to_str_const(type, rmp_type_vals, "Unknown Type"));
116 if (tree) {
117 ti = proto_tree_add_item(tree, proto_rmp, tvb, 0, -1, ENC_NA);
118 rmp_tree = proto_item_add_subtree(ti, ett_rmp);
119 proto_tree_add_uint(rmp_tree, hf_rmp_type, tvb, 0, 1, type);
121 switch (type) {
122 case RMP_BOOT_REQ:
123 proto_tree_add_item(rmp_tree,
124 hf_rmp_retcode, tvb, 1, 1, ENC_BIG_ENDIAN);
125 proto_tree_add_item(rmp_tree,
126 hf_rmp_seqnum, tvb, 2, 4, ENC_BIG_ENDIAN);
127 proto_tree_add_item(rmp_tree,
128 hf_rmp_sessionid, tvb, 6, 2, ENC_BIG_ENDIAN);
129 proto_tree_add_item(rmp_tree,
130 hf_rmp_version, tvb, 8, 2, ENC_BIG_ENDIAN);
131 proto_tree_add_item(rmp_tree,
132 hf_rmp_machtype, tvb, 10, 20, ENC_ASCII|ENC_NA);
133 /* The remaining fields are optional */
134 if(!tvb_offset_exists(tvb, 30))
135 return;
136 len = tvb_get_guint8(tvb, 30);
137 proto_tree_add_item(rmp_tree,
138 hf_rmp_filename, tvb, 30, 1, ENC_ASCII|ENC_NA);
139 if(tvb_offset_exists(tvb, len+31))
140 call_dissector(data_handle,
141 tvb_new_subset_remaining(tvb, len+31),
142 pinfo, tree);
143 break;
145 case RMP_BOOT_REPL:
146 proto_tree_add_item(rmp_tree,
147 hf_rmp_retcode, tvb, 1, 1, ENC_BIG_ENDIAN);
148 proto_tree_add_item(rmp_tree,
149 hf_rmp_seqnum, tvb, 2, 4, ENC_BIG_ENDIAN);
150 proto_tree_add_item(rmp_tree,
151 hf_rmp_sessionid, tvb, 6, 2, ENC_BIG_ENDIAN);
152 proto_tree_add_item(rmp_tree,
153 hf_rmp_version, tvb, 8, 2, ENC_BIG_ENDIAN);
154 len = tvb_get_guint8(tvb, 10);
155 proto_tree_add_item(rmp_tree,
156 hf_rmp_filename, tvb, 10, 1, ENC_ASCII|ENC_NA);
157 if(tvb_offset_exists(tvb, len+11))
158 call_dissector(data_handle,
159 tvb_new_subset_remaining(tvb, len+11),
160 pinfo, tree);
161 break;
163 case RMP_READ_REQ:
164 proto_tree_add_item(rmp_tree,
165 hf_rmp_retcode, tvb, 1, 1, ENC_BIG_ENDIAN);
166 proto_tree_add_item(rmp_tree,
167 hf_rmp_offset, tvb, 2, 4, ENC_BIG_ENDIAN);
168 proto_tree_add_item(rmp_tree,
169 hf_rmp_sessionid, tvb, 6, 2, ENC_BIG_ENDIAN);
170 proto_tree_add_item(rmp_tree,
171 hf_rmp_size, tvb, 8, 2, ENC_BIG_ENDIAN);
172 if(tvb_offset_exists(tvb, 10))
173 call_dissector(data_handle,
174 tvb_new_subset_remaining(tvb, 10),
175 pinfo, tree);
176 break;
178 case RMP_READ_REPL:
179 proto_tree_add_item(rmp_tree,
180 hf_rmp_retcode, tvb, 1, 1, ENC_BIG_ENDIAN);
181 proto_tree_add_item(rmp_tree,
182 hf_rmp_offset, tvb, 2, 4, ENC_BIG_ENDIAN);
183 proto_tree_add_item(rmp_tree,
184 hf_rmp_sessionid, tvb, 6, 2, ENC_BIG_ENDIAN);
185 call_dissector(data_handle, tvb_new_subset_remaining(tvb,
186 8), pinfo, rmp_tree);
187 break;
189 case RMP_BOOT_DONE:
190 proto_tree_add_item(rmp_tree,
191 hf_rmp_retcode, tvb, 1, 1, ENC_BIG_ENDIAN);
192 proto_tree_add_text(rmp_tree,
193 tvb, 2, 4, "Reserved");
194 proto_tree_add_item(rmp_tree,
195 hf_rmp_sessionid, tvb, 6, 2, ENC_BIG_ENDIAN);
196 if(tvb_offset_exists(tvb, 8))
197 call_dissector(data_handle,
198 tvb_new_subset_remaining(tvb, 6),
199 pinfo, tree);
200 break;
201 default:
202 call_dissector(data_handle, tvb_new_subset_remaining(tvb,
203 1), pinfo, tree);
208 void
209 proto_register_rmp(void)
211 static hf_register_info hf[] = {
212 { &hf_rmp_type,
213 { "Type", "rmp.type", FT_UINT8, BASE_HEX,
214 VALS(rmp_type_vals), 0x0, NULL, HFILL }},
215 { &hf_rmp_retcode,
216 { "Returncode", "rmp.retcode", FT_UINT8, BASE_HEX,
217 VALS(rmp_error_vals), 0x0, NULL, HFILL }},
218 { &hf_rmp_seqnum,
219 { "Sequence Number", "rmp.seqnum", FT_UINT32, BASE_HEX,
220 NULL, 0x0, NULL, HFILL }},
221 { &hf_rmp_sessionid,
222 { "Session ID", "rmp.sessionid", FT_UINT16, BASE_HEX,
223 NULL, 0x0, NULL, HFILL }},
224 { &hf_rmp_version,
225 { "Version", "rmp.version", FT_UINT16, BASE_DEC,
226 NULL, 0x0, NULL, HFILL }},
227 { &hf_rmp_machtype,
228 { "Machine Type", "rmp.machtype", FT_STRING, BASE_NONE,
229 NULL, 0x0, NULL, HFILL }},
230 { &hf_rmp_filename,
231 { "Filename", "rmp.filename", FT_UINT_STRING, BASE_NONE,
232 NULL, 0x0, NULL, HFILL }},
233 { &hf_rmp_offset,
234 { "Offset", "rmp.offset", FT_UINT32, BASE_HEX,
235 NULL, 0x0, NULL, HFILL }},
236 { &hf_rmp_size,
237 { "Size", "rmp.size", FT_UINT16, BASE_DEC,
238 NULL, 0x0, NULL, HFILL }},
240 static gint *ett[] = {
241 &ett_rmp,
244 proto_rmp = proto_register_protocol(
245 "HP Remote Maintenance Protocol", "RMP", "rmp");
246 proto_register_field_array(proto_rmp, hf, array_length(hf));
247 proto_register_subtree_array(ett, array_length(ett));
249 register_dissector("rmp", dissect_rmp, proto_rmp);
252 void
253 proto_reg_handoff_rmp(void)
255 dissector_handle_t rmp_handle;
257 data_handle = find_dissector("data");
259 rmp_handle = find_dissector("rmp");
260 dissector_add_uint("hpext.dxsap", HPEXT_DXSAP, rmp_handle);
261 dissector_add_uint("hpext.dxsap", HPEXT_SXSAP, rmp_handle);