2 * Routines for HP remote management protocol
3 * Gilbert Ramirez <jochen@scram.de>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
14 #include <epan/packet.h>
16 #include "packet-hpext.h"
18 void proto_register_rmp(void);
19 void proto_reg_handoff_rmp(void);
23 static int hf_rmp_type
;
24 static int hf_rmp_retcode
;
25 static int hf_rmp_seqnum
;
26 static int hf_rmp_sessionid
;
27 static int hf_rmp_version
;
28 static int hf_rmp_machtype
;
29 static int hf_rmp_filename
;
30 static int hf_rmp_offset
;
31 static int hf_rmp_size
;
32 static int hf_rmp_reserved
;
36 static dissector_handle_t rmp_handle
;
39 * Possible values for "rmp_type" fields.
42 #define RMP_BOOT_REQ 1 /* boot request packet */
43 #define RMP_BOOT_REPL 129 /* boot reply packet */
44 #define RMP_READ_REQ 2 /* read request packet */
45 #define RMP_READ_REPL 130 /* read reply packet */
46 #define RMP_BOOT_DONE 3 /* boot complete packet */
53 #define RMP_E_EOF 2 /* read reply: returned end of file */
54 #define RMP_E_ABORT 3 /* abort operation */
55 #define RMP_E_BUSY 4 /* boot reply: server busy */
56 #define RMP_E_TIMEOUT 5 /* lengthen time out (not implemented) */
57 #define RMP_E_NOFILE 16 /* boot reply: file does not exist */
58 #define RMP_E_OPENFILE 17 /* boot reply: file open failed */
59 #define RMP_E_NODFLT 18 /* boot reply: default file does not exist */
60 #define RMP_E_OPENDFLT 19 /* boot reply: default file open failed */
61 #define RMP_E_BADSID 25 /* read reply: bad session ID */
62 #define RMP_E_BADPACKET 27 /* Bad packet detected */
64 static const value_string rmp_type_vals
[] = {
65 { RMP_BOOT_REQ
, "Boot Request" },
66 { RMP_BOOT_REPL
, "Boot Reply" },
67 { RMP_READ_REQ
, "Read Request" },
68 { RMP_READ_REPL
, "Read Reply" },
69 { RMP_BOOT_DONE
, "Boot Done" },
73 static const value_string rmp_error_vals
[] = {
75 { RMP_E_EOF
, "End Of File" },
76 { RMP_E_ABORT
, "Abort Operation" },
77 { RMP_E_BUSY
, "Server Busy" },
78 { RMP_E_TIMEOUT
, "Lengthen Time Out" },
79 { RMP_E_NOFILE
, "File Does Not Exist" },
80 { RMP_E_OPENFILE
, "File Open Failed" },
81 { RMP_E_NODFLT
, "Default File Does Not Exist" },
82 { RMP_E_OPENDFLT
, "Default File Open Failed" },
83 { RMP_E_BADSID
, "Bad Session Id" },
84 { RMP_E_BADPACKET
, "Bad Packet Detected" },
89 dissect_rmp(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
91 proto_tree
*rmp_tree
= NULL
;
92 proto_item
*ti
= NULL
;
95 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "RMP");
97 col_clear(pinfo
->cinfo
, COL_INFO
);
99 type
= tvb_get_uint8(tvb
, 0);
101 col_set_str(pinfo
->cinfo
, COL_INFO
,
102 val_to_str_const(type
, rmp_type_vals
, "Unknown Type"));
104 ti
= proto_tree_add_item(tree
, proto_rmp
, tvb
, 0, -1, ENC_NA
);
105 rmp_tree
= proto_item_add_subtree(ti
, ett_rmp
);
106 proto_tree_add_uint(rmp_tree
, hf_rmp_type
, tvb
, 0, 1, type
);
110 proto_tree_add_item(rmp_tree
,
111 hf_rmp_retcode
, tvb
, 1, 1, ENC_BIG_ENDIAN
);
112 proto_tree_add_item(rmp_tree
,
113 hf_rmp_seqnum
, tvb
, 2, 4, ENC_BIG_ENDIAN
);
114 proto_tree_add_item(rmp_tree
,
115 hf_rmp_sessionid
, tvb
, 6, 2, ENC_BIG_ENDIAN
);
116 proto_tree_add_item(rmp_tree
,
117 hf_rmp_version
, tvb
, 8, 2, ENC_BIG_ENDIAN
);
118 proto_tree_add_item(rmp_tree
,
119 hf_rmp_machtype
, tvb
, 10, 20, ENC_ASCII
);
120 /* The remaining fields are optional */
121 if(!tvb_offset_exists(tvb
, 30))
123 len
= tvb_get_uint8(tvb
, 30);
124 proto_tree_add_item(rmp_tree
,
125 hf_rmp_filename
, tvb
, 30, 1, ENC_ASCII
|ENC_BIG_ENDIAN
);
126 if(tvb_offset_exists(tvb
, len
+31))
127 call_data_dissector(tvb_new_subset_remaining(tvb
, len
+31),
132 proto_tree_add_item(rmp_tree
,
133 hf_rmp_retcode
, tvb
, 1, 1, ENC_BIG_ENDIAN
);
134 proto_tree_add_item(rmp_tree
,
135 hf_rmp_seqnum
, tvb
, 2, 4, ENC_BIG_ENDIAN
);
136 proto_tree_add_item(rmp_tree
,
137 hf_rmp_sessionid
, tvb
, 6, 2, ENC_BIG_ENDIAN
);
138 proto_tree_add_item(rmp_tree
,
139 hf_rmp_version
, tvb
, 8, 2, ENC_BIG_ENDIAN
);
140 len
= tvb_get_uint8(tvb
, 10);
141 proto_tree_add_item(rmp_tree
,
142 hf_rmp_filename
, tvb
, 10, 1, ENC_ASCII
|ENC_BIG_ENDIAN
);
143 if(tvb_offset_exists(tvb
, len
+11))
144 call_data_dissector(tvb_new_subset_remaining(tvb
, len
+11),
149 proto_tree_add_item(rmp_tree
,
150 hf_rmp_retcode
, tvb
, 1, 1, ENC_BIG_ENDIAN
);
151 proto_tree_add_item(rmp_tree
,
152 hf_rmp_offset
, tvb
, 2, 4, ENC_BIG_ENDIAN
);
153 proto_tree_add_item(rmp_tree
,
154 hf_rmp_sessionid
, tvb
, 6, 2, ENC_BIG_ENDIAN
);
155 proto_tree_add_item(rmp_tree
,
156 hf_rmp_size
, tvb
, 8, 2, ENC_BIG_ENDIAN
);
157 if(tvb_offset_exists(tvb
, 10))
158 call_data_dissector(tvb_new_subset_remaining(tvb
, 10),
163 proto_tree_add_item(rmp_tree
,
164 hf_rmp_retcode
, tvb
, 1, 1, ENC_BIG_ENDIAN
);
165 proto_tree_add_item(rmp_tree
,
166 hf_rmp_offset
, tvb
, 2, 4, ENC_BIG_ENDIAN
);
167 proto_tree_add_item(rmp_tree
,
168 hf_rmp_sessionid
, tvb
, 6, 2, ENC_BIG_ENDIAN
);
169 call_data_dissector(tvb_new_subset_remaining(tvb
,
170 8), pinfo
, rmp_tree
);
174 proto_tree_add_item(rmp_tree
,
175 hf_rmp_retcode
, tvb
, 1, 1, ENC_BIG_ENDIAN
);
176 proto_tree_add_item(rmp_tree
,
177 hf_rmp_reserved
, tvb
, 2, 4, ENC_BIG_ENDIAN
);
178 proto_tree_add_item(rmp_tree
,
179 hf_rmp_sessionid
, tvb
, 6, 2, ENC_BIG_ENDIAN
);
180 if(tvb_offset_exists(tvb
, 8))
181 call_data_dissector(tvb_new_subset_remaining(tvb
, 6),
185 call_data_dissector(tvb_new_subset_remaining(tvb
, 1), pinfo
, tree
);
187 return tvb_captured_length(tvb
);
191 proto_register_rmp(void)
193 static hf_register_info hf
[] = {
195 { "Type", "rmp.type", FT_UINT8
, BASE_HEX
,
196 VALS(rmp_type_vals
), 0x0, NULL
, HFILL
}},
198 { "Returncode", "rmp.retcode", FT_UINT8
, BASE_HEX
,
199 VALS(rmp_error_vals
), 0x0, NULL
, HFILL
}},
201 { "Sequence Number", "rmp.seqnum", FT_UINT32
, BASE_HEX
,
202 NULL
, 0x0, NULL
, HFILL
}},
204 { "Session ID", "rmp.sessionid", FT_UINT16
, BASE_HEX
,
205 NULL
, 0x0, NULL
, HFILL
}},
207 { "Version", "rmp.version", FT_UINT16
, BASE_DEC
,
208 NULL
, 0x0, NULL
, HFILL
}},
210 { "Machine Type", "rmp.machtype", FT_STRING
, BASE_NONE
,
211 NULL
, 0x0, NULL
, HFILL
}},
213 { "Filename", "rmp.filename", FT_UINT_STRING
, BASE_NONE
,
214 NULL
, 0x0, NULL
, HFILL
}},
216 { "Offset", "rmp.offset", FT_UINT32
, BASE_HEX
,
217 NULL
, 0x0, NULL
, HFILL
}},
219 { "Size", "rmp.size", FT_UINT16
, BASE_DEC
,
220 NULL
, 0x0, NULL
, HFILL
}},
222 { "Reserved", "rmp.reserved", FT_UINT32
, BASE_HEX
,
223 NULL
, 0x0, NULL
, HFILL
}},
226 static int *ett
[] = {
230 proto_rmp
= proto_register_protocol("HP Remote Maintenance Protocol", "RMP", "rmp");
231 proto_register_field_array(proto_rmp
, hf
, array_length(hf
));
232 proto_register_subtree_array(ett
, array_length(ett
));
234 rmp_handle
= register_dissector("rmp", dissect_rmp
, proto_rmp
);
238 proto_reg_handoff_rmp(void)
240 dissector_add_uint("hpext.dxsap", HPEXT_DXSAP
, rmp_handle
);
241 dissector_add_uint("hpext.dxsap", HPEXT_SXSAP
, rmp_handle
);
245 * Editor modelines - https://www.wireshark.org/tools/modelines.html
250 * indent-tabs-mode: t
253 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
254 * :indentSize=8:tabSize=8:noTabs=false: