/src/wireshark/epan/dissectors/packet-mdb.c
Line | Count | Source |
1 | | /* |
2 | | * packet-mdb.c |
3 | | * Routines for MDB dissection |
4 | | * Copyright 2023 Martin Kaiser for PayTec AG (www.paytec.ch) |
5 | | * |
6 | | * Wireshark - Network traffic analyzer |
7 | | * By Gerald Combs <gerald@wireshark.org> |
8 | | * Copyright 1998 Gerald Combs |
9 | | * |
10 | | * SPDX-License-Identifier: GPL-2.0-or-later |
11 | | */ |
12 | | |
13 | | /* |
14 | | * The MDB (Multi-Drop Bus) protocol is used inside a vending machine. MDB |
15 | | * defines the communication between the main control board (VMC = Vending |
16 | | * Machine Controller) and peripheral components, e.g. a payment terminal |
17 | | * or a bill validator. |
18 | | * |
19 | | * The VMC acts as bus master and sends a request to one peripheral at a time. |
20 | | * A peripheral may send data only in response to such a request. |
21 | | * |
22 | | * The MDB specification is maintained by the National Automatic Merchandising |
23 | | * Association (NAMA). As of August 2023, the current version of the MDB |
24 | | * specification is 4.3. It is available from |
25 | | * https://namanow.org/nama-releases-mdb-version-4-3/ |
26 | | * |
27 | | * The pcap input format for this dissector is documented at |
28 | | * https://www.kaiser.cx/pcap-mdb.html |
29 | | */ |
30 | | |
31 | | #include "config.h" |
32 | | #include <epan/expert.h> |
33 | | #include <epan/packet.h> |
34 | | #include <epan/conversation.h> |
35 | | #include <epan/tfs.h> |
36 | | #include <wsutil/array.h> |
37 | | #include <wiretap/wtap.h> |
38 | | |
39 | | void proto_reg_handoff_mdb(void); |
40 | | void proto_register_mdb(void); |
41 | | |
42 | | static int proto_mdb; |
43 | | |
44 | | static int ett_mdb; |
45 | | static int ett_mdb_hdr; |
46 | | static int ett_mdb_cl; |
47 | | static int ett_mdb_cgw; |
48 | | static int ett_mdb_bv; |
49 | | |
50 | | static int hf_mdb_hdr_ver; |
51 | | static int hf_mdb_event; |
52 | | static int hf_mdb_addr; |
53 | | static int hf_mdb_cmd; |
54 | | static int hf_mdb_cl_setup_sub; |
55 | | static int hf_mdb_cl_feat_lvl; |
56 | | static int hf_mdb_cl_cols; |
57 | | static int hf_mdb_cl_rows; |
58 | | static int hf_mdb_cl_disp_info; |
59 | | static int hf_mdb_cl_max_price; |
60 | | static int hf_mdb_cl_min_price; |
61 | | static int hf_mdb_cl_vend_sub; |
62 | | static int hf_mdb_cl_item_price; |
63 | | static int hf_mdb_cl_item_num; |
64 | | static int hf_mdb_cl_reader_sub; |
65 | | static int hf_mdb_cl_resp; |
66 | | static int hf_mdb_cl_scale; |
67 | | static int hf_mdb_cl_dec_pl; |
68 | | static int hf_mdb_cl_max_rsp_time; |
69 | | static int hf_mdb_cl_vend_amt; |
70 | | static int hf_mdb_cl_expns_sub; |
71 | | static int hf_mdb_cl_manuf_code; |
72 | | static int hf_mdb_cl_ser_num; |
73 | | static int hf_mdb_cl_mod_num; |
74 | | static int hf_mdb_cl_opt_feat; |
75 | | static int hf_mdb_cgw_feat_lvl; |
76 | | static int hf_mdb_cgw_scale; |
77 | | static int hf_mdb_cgw_dec_pl; |
78 | | static int hf_mdb_cgw_resp; |
79 | | static int hf_mdb_cgw_max_rsp_time; |
80 | | static int hf_mdb_cgw_report_sub; |
81 | | static int hf_mdb_cgw_dts_evt_code; |
82 | | static int hf_mdb_cgw_duration; |
83 | | static int hf_mdb_cgw_activity; |
84 | | static int hf_mdb_cgw_expns_sub; |
85 | | static int hf_mdb_cgw_opt_feat; |
86 | | static int hf_mdb_cgw_manuf_code; |
87 | | static int hf_mdb_cgw_ser_num; |
88 | | static int hf_mdb_cgw_mod_num; |
89 | | static int hf_mdb_bv_setup_bill_val_feature; |
90 | | static int hf_mdb_bv_setup_ctry_currency_code; |
91 | | static int hf_mdb_bv_setup_bill_scal_fac; |
92 | | static int hf_mdb_bv_setup_dec_places; |
93 | | static int hf_mdb_bv_setup_bill_stacker_cap; |
94 | | static int hf_mdb_bv_setup_bill_sec_lvls; |
95 | | static int hf_mdb_bv_setup_escrow; |
96 | | static int hf_mdb_bv_setup_bill_type_cred; |
97 | | static int hf_mdb_bv_bill_enable; |
98 | | static int hf_mdb_bv_bill_escrow_enable; |
99 | | static int hf_mdb_bv_poll_state; |
100 | | static int hf_mdb_bv_poll_bill_routing_state; |
101 | | static int hf_mdb_bv_poll_bill_type; |
102 | | static int hf_mdb_bv_escrow_state; |
103 | | static int hf_mdb_bv_stacker; |
104 | | static int hf_mdb_bv_exp_cmd; |
105 | | static int hf_mdb_bv_exp_opt_feat; |
106 | | static int hf_mdb_bv_exp_opt_feat_enable; |
107 | | static int hf_mdb_bv_exp_manufact_code; |
108 | | static int hf_mdb_bv_exp_serial_num; |
109 | | static int hf_mdb_bv_exp_model_tuning_num; |
110 | | static int hf_mdb_bv_exp_software_version; |
111 | | static int hf_mdb_bv_exp_bill_type_routing; |
112 | | static int hf_mdb_bv_exp_manual_dispense_enable; |
113 | | static int hf_mdb_bv_exp_bill_recycler_enabled; |
114 | | static int hf_mdb_bv_exp_bill_count; |
115 | | static int hf_mdb_bv_exp_dispenser_full_state; |
116 | | static int hf_mdb_bv_exp_bill_type_dispensed; |
117 | | static int hf_mdb_bv_exp_bill_type_number_bills; |
118 | | static int hf_mdb_bv_exp_dispense_value_bills; |
119 | | static int hf_mdb_bv_exp_payout_state; |
120 | | static int hf_mdb_bv_exp_dispenser_payout_activity; |
121 | | |
122 | | static int hf_mdb_ack; |
123 | | static int hf_mdb_data; |
124 | | static int hf_mdb_chk; |
125 | | static int hf_mdb_chk_status; |
126 | | static int hf_mdb_response_in; |
127 | | static int hf_mdb_response_to; |
128 | | static int hf_mdb_time; |
129 | | |
130 | | static expert_field ei_mdb_short_packet; |
131 | | static expert_field ei_mdb_bad_checksum; |
132 | | |
133 | | static dissector_handle_t mdb_handle; |
134 | | |
135 | | /* MDB is a master slave protocol, so per request, there is exactly one response */ |
136 | | typedef struct { |
137 | | uint32_t req_num, rep_num; |
138 | | nstime_t req_time; |
139 | | uint16_t cmd; // In case of expanse cmd, 2 byte are used |
140 | | } mdb_transaction_t; |
141 | | |
142 | | typedef struct { |
143 | | wmem_tree_t* transactions; |
144 | | uint32_t last_req_packet; |
145 | | uint16_t last_cmd; |
146 | | } mdb_conv_info_t; |
147 | | |
148 | | static mdb_conv_info_t* get_mdb_conv_info(packet_info* pinfo) |
149 | 0 | { |
150 | 0 | conversation_t* conversation; |
151 | 0 | mdb_conv_info_t* conv_info; |
152 | |
|
153 | 0 | conversation = find_or_create_conversation(pinfo); |
154 | 0 | conv_info = (mdb_conv_info_t*)conversation_get_proto_data(conversation, proto_mdb); |
155 | 0 | if (!conv_info) { |
156 | 0 | conv_info = wmem_new0(wmem_file_scope(), mdb_conv_info_t); |
157 | 0 | conv_info->transactions = wmem_tree_new(wmem_file_scope()); |
158 | 0 | conversation_add_proto_data(conversation, proto_mdb, conv_info); |
159 | 0 | } |
160 | 0 | return conv_info; |
161 | 0 | } |
162 | | |
163 | 0 | #define MDB_EVT_DATA_MST_PER 0xFF |
164 | 0 | #define MDB_EVT_DATA_PER_MST 0xFE |
165 | 0 | #define MDB_EVT_BUS_RESET 0xFD |
166 | | |
167 | | #define MDB_PSEUDO_HDR_LEN 2 |
168 | | |
169 | 0 | static bool is_mdb_reply(uint8_t byte) { |
170 | 0 | return (byte == 0x00 || byte == 0xAA || byte == 0xFF); |
171 | 0 | } |
172 | | |
173 | | static const value_string mdb_event[] = { |
174 | | { MDB_EVT_DATA_MST_PER, "Data transfer Master -> Peripheral" }, |
175 | | { MDB_EVT_DATA_PER_MST, "Data transfer Peripheral -> Master" }, |
176 | | { MDB_EVT_BUS_RESET, "Bus reset" }, |
177 | | { 0, NULL } |
178 | | }; |
179 | | |
180 | 0 | #define ADDR_VMC "VMC" |
181 | | |
182 | 0 | #define ADDR_CASHLESS1 0x10 |
183 | 0 | #define ADDR_COMMS_GW 0x18 |
184 | 0 | #define ADDR_BILL_VALIDATOR 0x30 |
185 | | |
186 | 0 | #define ADDR_MASK 0xF8 |
187 | 0 | #define CMD_MASK 0x07 |
188 | 0 | #define SUB_CMD_OFFSET 8 |
189 | | |
190 | | static const value_string mdb_addr[] = { |
191 | | { 0x00, "Reserved for VMC" }, |
192 | | { 0x08, "Changer" }, |
193 | | { ADDR_CASHLESS1, "Cashless #1" }, |
194 | | { ADDR_COMMS_GW, "Communications Gateway" }, |
195 | | { 0x20, "Display" }, |
196 | | { 0x28, "Energy Management System" }, |
197 | | { ADDR_BILL_VALIDATOR, "Bill Validator" }, |
198 | | { 0x38, "Reserved for Future Standard Peripheral" }, |
199 | | { 0x40, "Universal Satellite Device #1" }, |
200 | | { 0x48, "Universal Satellite Device #2" }, |
201 | | { 0x50, "Universal Satellite Device #3" }, |
202 | | { 0x58, "Coin Hopper or Tube - Dispenser 1" }, |
203 | | { 0x60, "Cashless #2" }, |
204 | | { 0x68, "Age Verification Device" }, |
205 | | { 0x70, "Coin Hopper or Tube - Dispenser 2" }, |
206 | | { 0xF0, "Vending Machine Specific Peripheral #1" }, |
207 | | { 0xF8, "Vending Machine Specific Peripheral #2" }, |
208 | | { 0, NULL } |
209 | | }; |
210 | | |
211 | | static const value_string mdb_ack[] = { |
212 | | { 0x00, "ACK" }, |
213 | | { 0xAA, "RET" }, |
214 | | { 0xFF, "NAK" }, |
215 | | { 0, NULL } |
216 | | }; |
217 | | |
218 | | /* |
219 | | * These are just the command bits in the address + command byte. MDB supports |
220 | | * two Cashless peripherals (Cashless #1 and #2) with different addresses, |
221 | | * both use the same commands. |
222 | | */ |
223 | 0 | #define MDB_CL_CMD_SETUP 0x01 |
224 | 0 | #define MDB_CL_CMD_VEND 0x03 |
225 | 0 | #define MDB_CL_CMD_READER 0x04 |
226 | 0 | #define MDB_CL_CMD_EXPNS 0x07 |
227 | | |
228 | | static const value_string mdb_cl_cmd[] = { |
229 | | { 0x00, "Reset" }, |
230 | | { MDB_CL_CMD_SETUP, "Setup" }, |
231 | | { 0x02, "Poll" }, |
232 | | { MDB_CL_CMD_VEND, "Vend" }, |
233 | | { MDB_CL_CMD_READER, "Reader" }, |
234 | | { MDB_CL_CMD_EXPNS, "Expansion" }, |
235 | | { 0, NULL } |
236 | | }; |
237 | | |
238 | 0 | #define MDB_CL_SETUP_CFG_DATA 0x00 |
239 | 0 | #define MDB_CL_SETUP_MAX_MIN 0x01 |
240 | | |
241 | | static const value_string mdb_cl_setup_sub_cmd[] = { |
242 | | { MDB_CL_SETUP_CFG_DATA, "Config Data" }, |
243 | | { MDB_CL_SETUP_MAX_MIN, "Max/Min Prices" }, |
244 | | { 0, NULL } |
245 | | }; |
246 | | |
247 | 0 | #define MDB_CL_VEND_REQ 0x00 |
248 | 0 | #define MDB_CL_VEND_SUC 0x02 |
249 | | |
250 | | static const value_string mdb_cl_vend_sub_cmd[] = { |
251 | | { MDB_CL_VEND_REQ, "Vend Request" }, |
252 | | { MDB_CL_VEND_SUC, "Vend Success" }, |
253 | | { 0x04, "Session Complete" }, |
254 | | { 0, NULL } |
255 | | }; |
256 | | |
257 | | static const value_string mdb_cl_reader_sub_cmd[] = { |
258 | | { 0x00, "Reader Disable" }, |
259 | | { 0x01, "Reader Enable" }, |
260 | | { 0, NULL } |
261 | | }; |
262 | | |
263 | 0 | #define MDB_CL_EXPNS_REQ_ID 0x00 |
264 | 0 | #define MDB_CL_EXPNS_OPT_ENA 0x04 |
265 | | |
266 | | static const value_string mdb_cl_expns_sub_cmd[] = { |
267 | | { MDB_CL_EXPNS_REQ_ID, "Request ID" }, |
268 | | { MDB_CL_EXPNS_OPT_ENA, "Optional Feature Enabled" }, |
269 | | { 0, NULL } |
270 | | }; |
271 | | |
272 | 0 | #define MDB_CL_RESP_RD_CFG_DATA 0x01 |
273 | 0 | #define MDB_CL_RESP_VEND_APRV 0x05 |
274 | 0 | #define MDB_CL_RESP_PER_ID 0x09 |
275 | | |
276 | | static const value_string mdb_cl_resp[] = { |
277 | | { 0x00, "Just Reset" }, |
278 | | { MDB_CL_RESP_RD_CFG_DATA, "Reader Config Data" }, |
279 | | { 0x03, "Begin Session" }, |
280 | | { MDB_CL_RESP_VEND_APRV, "Vend Approved" }, |
281 | | { 0x06, "Vend Denied" }, |
282 | | { 0x07, "End Session" }, |
283 | | { MDB_CL_RESP_PER_ID, "Peripheral ID" }, |
284 | | { 0x0b, "Cmd Out Of Sequence" }, |
285 | | { 0, NULL } |
286 | | }; |
287 | | |
288 | | /* |
289 | | * For the Communications Gateway, we use the complete address + command byte |
290 | | * as value for the value string. The values here match those in the MDB |
291 | | * specification. |
292 | | * |
293 | | * There's only one Communications Gateway, the address bits are always the |
294 | | * same. (This is different from the Cashless peripherals, see above.) |
295 | | */ |
296 | 0 | #define MDB_CGW_ADDR_CMD_SETUP 0x19 |
297 | 0 | #define MDB_CGW_ADDR_CMD_REPORT 0x1B |
298 | 0 | #define MDB_CGW_ADDR_CMD_EXPNS 0x1F |
299 | | |
300 | | static const value_string mdb_cgw_addr_cmd[] = { |
301 | | { 0x18, "Reset" }, |
302 | | { MDB_CGW_ADDR_CMD_SETUP, "Setup" }, |
303 | | { 0x1A, "Poll" }, |
304 | | { MDB_CGW_ADDR_CMD_REPORT, "Report" }, |
305 | | { MDB_CGW_ADDR_CMD_EXPNS, "Expansion" }, |
306 | | { 0, NULL } |
307 | | }; |
308 | | |
309 | 0 | #define MDB_CGW_REPORT_DTS_EVT 0x02 |
310 | | |
311 | | static const value_string mdb_cgw_report_sub_cmd[] = { |
312 | | { 0x01, "Transaction" }, |
313 | | { MDB_CGW_REPORT_DTS_EVT, "DTS Event" }, |
314 | | { 0, NULL } |
315 | | }; |
316 | | |
317 | 0 | #define MDB_CGW_EXPNS_FEAT_ENA 0x01 |
318 | | |
319 | | static const value_string mdb_cgw_expns_sub_cmd[] = { |
320 | | { 0x00, "Identification" }, |
321 | | { MDB_CGW_EXPNS_FEAT_ENA, "Feature enable" }, |
322 | | { 0x02, "Time/Date Request" }, |
323 | | { 0, NULL } |
324 | | }; |
325 | | |
326 | 0 | #define MDB_CGW_RESP_CFG 0x01 |
327 | 0 | #define MDB_CGW_RESP_PER_ID 0x06 |
328 | | |
329 | | static const value_string mdb_cgw_resp[] = { |
330 | | { 0x00, "Just Reset" }, |
331 | | { MDB_CGW_RESP_CFG, "Comms Gateway Config" }, |
332 | | { 0x05, "DTS Event Acknowledge" }, |
333 | | { MDB_CGW_RESP_PER_ID, "Peripheral ID" }, |
334 | | { 0, NULL } |
335 | | }; |
336 | | |
337 | | /* |
338 | | * Commands for Bill Validator |
339 | | */ |
340 | 0 | #define MDB_BV_CMD_SETUP 0x01 |
341 | 0 | #define MDB_BV_CMD_SECURITY 0x02 |
342 | 0 | #define MDB_BV_CMD_POLL 0x03 |
343 | 0 | #define MDB_BV_CMD_BILL_TYPE 0x04 |
344 | 0 | #define MDB_BV_CMD_ESCROW 0x05 |
345 | 0 | #define MDB_BV_CMD_STACKER 0x06 |
346 | 0 | #define MDB_BV_CMD_EXPNS 0x07 |
347 | | #define MDB_BV_CMD_NONE 0xFF |
348 | | |
349 | | static const value_string mdb_bv_cmd[] = { |
350 | | { 0x00, "Reset" }, |
351 | | { MDB_BV_CMD_SETUP, "Setup" }, |
352 | | { MDB_BV_CMD_SECURITY, "Security" }, |
353 | | { MDB_BV_CMD_POLL, "Poll" }, |
354 | | { MDB_BV_CMD_BILL_TYPE, "Bill type" }, |
355 | | { MDB_BV_CMD_ESCROW, "Escrow" }, |
356 | | { MDB_BV_CMD_STACKER, "Stacker" }, |
357 | | { MDB_BV_CMD_EXPNS, "Expansion" }, |
358 | | { 0, NULL } |
359 | | }; |
360 | | |
361 | 0 | #define MDB_BV_LVL1_WITHOUT_OPT_BITS 0x00 |
362 | 0 | #define MDB_BV_LVL2_FEATURE_ENABLE 0x01 |
363 | 0 | #define MDB_BV_LVL2_ID_WITH_OPTION_BITS 0x02 |
364 | 0 | #define MDB_BV_RECYCL_SETUP 0x03 |
365 | 0 | #define MDB_BV_RECYCL_ENABLE 0x04 |
366 | 0 | #define MDB_BV_BILL_DISPENSE_STAT 0x05 |
367 | 0 | #define MDB_BV_DISPENSE_BILL 0x06 |
368 | 0 | #define MDB_BV_DISPENSE_VAL 0x07 |
369 | 0 | #define MDB_BV_PAYOUT_STAT 0x08 |
370 | 0 | #define MDB_BV_PAYOUT_VALUE_POLL 0x09 |
371 | 0 | #define MDB_BV_PAYOUT_CANCEL 0x0A |
372 | | |
373 | | static const value_string mdb_bv_exp_cmd[] = { |
374 | | { MDB_BV_LVL1_WITHOUT_OPT_BITS, "Level1 Identification without option bits" }, |
375 | | { MDB_BV_LVL2_FEATURE_ENABLE, "Level2+ Feature Enable" }, |
376 | | { MDB_BV_LVL2_ID_WITH_OPTION_BITS, "ID with Option Bits" }, |
377 | | { MDB_BV_RECYCL_SETUP, "Recycler Setup" }, |
378 | | { MDB_BV_RECYCL_ENABLE, "Recycler Enable" }, |
379 | | { MDB_BV_BILL_DISPENSE_STAT, "Bill Dispense Status" }, |
380 | | { MDB_BV_DISPENSE_BILL, "Dispense Bill" }, |
381 | | { MDB_BV_DISPENSE_VAL, "Dispense Value" }, |
382 | | { MDB_BV_PAYOUT_STAT, "Payout Status" }, |
383 | | { MDB_BV_PAYOUT_VALUE_POLL, "Payout Value Poll" }, |
384 | | { MDB_BV_PAYOUT_CANCEL, "Payout Cancel" }, |
385 | | { 0, NULL } |
386 | | }; |
387 | | |
388 | | static const true_false_string mdb_bv_escrow_state = { "Escrow Stack Bill", "Escrow Return Bill" }; |
389 | | |
390 | | // Format: 1yyyxxxx, where yyy = Bill routing, xxxx = Bill type (0 to 15) |
391 | | static const value_string mdb_bv_poll_bill_routing_state[] = { |
392 | | { 0x00, "Bill Stacked" }, |
393 | | { 0x01, "Escrow Position" }, |
394 | | { 0x02, "Bill Returned" }, |
395 | | { 0x03, "Bill to Recycler" }, |
396 | | { 0x04, "Disabled Bill Rejected" }, |
397 | | { 0x05, "Bill to Recycler" }, |
398 | | { 0x06, "Manual Dispense" }, |
399 | | { 0x07, "Transferred from Recycler to Cashbox" }, |
400 | | { 0, NULL } |
401 | | }; |
402 | | |
403 | | |
404 | | static const value_string mdb_bv_poll_state[] = { |
405 | | /* Bill Validator (Only) */ |
406 | | { 0x01, "Defective Motor" }, // One of the motors has failed to perform its expected assignment. |
407 | | { 0x02, "Sensor Problem" }, // One of the sensors has failed to provide its response. |
408 | | { 0x03, "Validator Busy" }, // The validator is busy and can not answer a detailed command right now. |
409 | | { 0x04, "ROM Checksum Error" }, // The validators internal checksum does not match the calculated checksum. |
410 | | { 0x05, "Validator Jammed" }, // A bill(s) has jammed in the acceptance path. |
411 | | { 0x06, "Validator was reset" }, // The validator has been reset since the last POLL. |
412 | | { 0x07, "Bill removed" }, // A bill in the escrow position has been removed by an unknown means. A BILL RETURNED message should also be sent. |
413 | | { 0x08, "Cash Box out of position" }, // The validator has detected the cash box to be open or removed. |
414 | | { 0x09, "Validator disabled" }, // The validator has been disabled, by the VMC or because of internal conditions. |
415 | | { 0x0A, "Invalid Escrow request" }, // An ESCROW command was requested for a bill not in the escrow position. |
416 | | { 0x0B, "Bill rejected" }, // A bill was detected, but rejected because it could not be identified. |
417 | | { 0x0C, "Possible Credited Bill Removal" }, // There has been an attempt to remove a credited (stacked) bill. |
418 | | { 0x40, "Disabled validator, number of attempts to input bill" }, // Format: 010xxxxx |
419 | | /* Bill Recycler (Only) */ |
420 | | { 0x21, "Escrow request" }, // An escrow lever activation has been detected. If a button is present and activated. |
421 | | { 0x22, "Dispenser Payout Busy" }, // The dispenser is busy activating payout devices. |
422 | | { 0x23, "Dispenser Busy" }, // The dispenser is busy and can not answer a detailed command right now |
423 | | { 0x24, "Defective Dispenser Sensor" }, // The dispenser has detected one of the dispenser sensors behaving abnormally |
424 | | |
425 | | { 0x26, "Dispenser did not start / motor problem" }, |
426 | | { 0x27, "Dispenser Jam" }, // A dispenser payout attempt has resulted in jammed condition. |
427 | | { 0x28, "ROM Checksum Error" }, // The dispensers internal checksum does not match the calculated checksum. |
428 | | // (If separate from validator microprocessor.) |
429 | | { 0x29, "Dispenser Disabled" }, // dispenser disabled because of error or bill in escrow position |
430 | | { 0x2A, "Bill Waiting" }, // waiting for customer removal |
431 | | { 0x2F, "Filled key pressed" }, // The VMC should request a new DISPENSER STATUS |
432 | | { 0, NULL } |
433 | | }; |
434 | | |
435 | | static const value_string mdb_bv_exp_bills_recyc_enabled[] = { |
436 | | { 0x00, "Bill type disabled" }, |
437 | | { 0x01, "Only High quality bills are used" }, |
438 | | { 0x02, "Only High and Medium quality bills are used" }, |
439 | | { 0x03, "Use all possible bills" }, |
440 | | { 0, NULL } |
441 | | }; |
442 | | |
443 | | static void dissect_mdb_ack(tvbuff_t *tvb, int offset, |
444 | | packet_info *pinfo, proto_tree *tree) |
445 | 0 | { |
446 | 0 | uint32_t ack; |
447 | |
|
448 | 0 | proto_tree_add_item_ret_uint(tree, hf_mdb_ack, tvb, offset, 1, ENC_BIG_ENDIAN, &ack); |
449 | 0 | col_set_str(pinfo->cinfo, COL_INFO, |
450 | 0 | val_to_str_const(ack, mdb_ack, "Invalid ack byte")); |
451 | 0 | } |
452 | | |
453 | | static void mdb_set_addrs(uint8_t event, uint8_t addr, packet_info *pinfo) |
454 | 0 | { |
455 | 0 | const char *periph = val_to_str(pinfo->pool, addr, mdb_addr, "Unknown (0x%02x)"); |
456 | | |
457 | | /* pinfo->p2p_dir is from the perspective of the master (VMC) */ |
458 | |
|
459 | 0 | if (event == MDB_EVT_DATA_MST_PER) { |
460 | 0 | set_address(&pinfo->src, AT_STRINGZ, (int)strlen(ADDR_VMC)+1, ADDR_VMC); |
461 | 0 | set_address(&pinfo->dst, AT_STRINGZ, (int)strlen(periph)+1, periph); |
462 | 0 | pinfo->p2p_dir = P2P_DIR_SENT; |
463 | 0 | } |
464 | 0 | else if (event == MDB_EVT_DATA_PER_MST) { |
465 | 0 | set_address(&pinfo->src, AT_STRINGZ, (int)strlen(periph)+1, periph); |
466 | 0 | set_address(&pinfo->dst, AT_STRINGZ, (int)strlen(ADDR_VMC)+1, ADDR_VMC); |
467 | 0 | pinfo->p2p_dir = P2P_DIR_RECV; |
468 | 0 | } |
469 | 0 | } |
470 | | |
471 | | static void mdb_add_checksum(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int total_len) |
472 | 0 | { |
473 | 0 | if (total_len <= 1) return; |
474 | 0 | uint8_t calculated_checksum = 0; |
475 | |
|
476 | 0 | for (int i = 0; i < total_len - 1; i++) { |
477 | 0 | uint8_t val = tvb_get_uint8(tvb, offset + i); |
478 | | /* The MDB checksum is a simple sum modulo 256. Using uint8_t |
479 | | * causes an intentional wrap-around that perfectly matches the modulo. |
480 | | */ |
481 | 0 | calculated_checksum += val; |
482 | 0 | } |
483 | |
|
484 | 0 | proto_tree_add_checksum(tree, tvb, offset + total_len - 1, hf_mdb_chk, hf_mdb_chk_status, &ei_mdb_bad_checksum, pinfo, calculated_checksum, ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY); |
485 | 0 | } |
486 | | |
487 | | static void dissect_mdb_cl_setup(tvbuff_t *tvb, int offset, |
488 | | packet_info *pinfo, proto_tree *tree) |
489 | 0 | { |
490 | 0 | uint32_t sub_cmd, price; |
491 | 0 | const char *s; |
492 | 0 | proto_item *pi; |
493 | |
|
494 | 0 | proto_tree_add_item_ret_uint(tree, hf_mdb_cl_setup_sub, |
495 | 0 | tvb, offset, 1, ENC_BIG_ENDIAN, &sub_cmd); |
496 | 0 | s = try_val_to_str(sub_cmd, mdb_cl_setup_sub_cmd); |
497 | 0 | if (s) { |
498 | 0 | col_set_str(pinfo->cinfo, COL_INFO, s); |
499 | 0 | } |
500 | 0 | offset++; |
501 | |
|
502 | 0 | switch (sub_cmd) { |
503 | 0 | case MDB_CL_SETUP_CFG_DATA: |
504 | 0 | proto_tree_add_item(tree, hf_mdb_cl_feat_lvl, tvb, offset, 1, |
505 | 0 | ENC_BIG_ENDIAN); |
506 | 0 | offset++; |
507 | 0 | proto_tree_add_item(tree, hf_mdb_cl_cols, tvb, offset, 1, |
508 | 0 | ENC_BIG_ENDIAN); |
509 | 0 | offset++; |
510 | 0 | proto_tree_add_item(tree, hf_mdb_cl_rows, tvb, offset, 1, |
511 | 0 | ENC_BIG_ENDIAN); |
512 | 0 | offset++; |
513 | 0 | proto_tree_add_item(tree, hf_mdb_cl_disp_info, tvb, offset, 1, |
514 | 0 | ENC_BIG_ENDIAN); |
515 | 0 | break; |
516 | | |
517 | 0 | case MDB_CL_SETUP_MAX_MIN: |
518 | 0 | if (tvb_reported_length_remaining(tvb, offset) == 5) { |
519 | | /* This is the "default version" of Max/Min Prices. */ |
520 | | |
521 | | /* XXX - convert the scaled prices into actual amounts */ |
522 | 0 | pi = proto_tree_add_item_ret_uint(tree, hf_mdb_cl_max_price, |
523 | 0 | tvb, offset, 2, ENC_BIG_ENDIAN, &price); |
524 | 0 | if (price == 0xFFFF) { |
525 | 0 | proto_item_append_text(pi, " (unknown)"); |
526 | 0 | } |
527 | 0 | offset += 2; |
528 | |
|
529 | 0 | pi = proto_tree_add_item_ret_uint(tree, hf_mdb_cl_min_price, |
530 | 0 | tvb, offset, 2, ENC_BIG_ENDIAN, &price); |
531 | 0 | if (price == 0x0000) { |
532 | 0 | proto_item_append_text(pi, " (unknown)"); |
533 | 0 | } |
534 | 0 | } |
535 | 0 | else if (tvb_reported_length_remaining(tvb, offset) == 11) { |
536 | | /* This is the "expanded currency version" of Max/Min Prices. */ |
537 | |
|
538 | 0 | proto_tree_add_item(tree, hf_mdb_cl_max_price, tvb, offset, 4, |
539 | 0 | ENC_BIG_ENDIAN); |
540 | 0 | offset += 4; |
541 | 0 | proto_tree_add_item(tree, hf_mdb_cl_min_price, tvb, offset, 4, |
542 | 0 | ENC_BIG_ENDIAN); |
543 | 0 | } |
544 | | /* XXX - expert info for other lengths */ |
545 | 0 | break; |
546 | 0 | } |
547 | 0 | } |
548 | | |
549 | | static void dissect_mdb_cl_vend(tvbuff_t *tvb, int offset, |
550 | | packet_info *pinfo, proto_tree *tree) |
551 | 0 | { |
552 | 0 | uint32_t sub_cmd, price, item; |
553 | 0 | const char *s; |
554 | |
|
555 | 0 | proto_tree_add_item_ret_uint(tree, hf_mdb_cl_vend_sub, tvb, offset, 1, |
556 | 0 | ENC_BIG_ENDIAN, &sub_cmd); |
557 | 0 | s = try_val_to_str(sub_cmd, mdb_cl_vend_sub_cmd); |
558 | 0 | if (s) { |
559 | 0 | col_set_str(pinfo->cinfo, COL_INFO, s); |
560 | 0 | } |
561 | 0 | offset++; |
562 | |
|
563 | 0 | switch (sub_cmd) { |
564 | 0 | case MDB_CL_VEND_REQ: |
565 | 0 | if (tvb_reported_length_remaining(tvb, offset) == 5) { |
566 | 0 | proto_tree_add_item_ret_uint(tree, hf_mdb_cl_item_price, tvb, |
567 | 0 | offset, 2, ENC_BIG_ENDIAN, &price); |
568 | 0 | offset += 2; |
569 | 0 | proto_tree_add_item_ret_uint(tree, hf_mdb_cl_item_num, tvb, |
570 | 0 | offset, 2, ENC_BIG_ENDIAN, &item); |
571 | 0 | col_append_fstr(pinfo->cinfo, COL_INFO, " (item %d, price %d)", |
572 | 0 | item, price); |
573 | 0 | } |
574 | | /* XXX - dissect the longer request in Expanded Currency Mode */ |
575 | 0 | break; |
576 | 0 | case MDB_CL_VEND_SUC: |
577 | 0 | proto_tree_add_item(tree, hf_mdb_cl_item_num, tvb, offset, 2, |
578 | 0 | ENC_BIG_ENDIAN); |
579 | 0 | break; |
580 | 0 | } |
581 | 0 | } |
582 | | |
583 | | static int |
584 | | dissect_mdb_cl_id_fields(tvbuff_t *tvb, int offset, proto_tree *tree) |
585 | 0 | { |
586 | 0 | proto_tree_add_item(tree, hf_mdb_cl_manuf_code, tvb, offset, 3, ENC_ASCII); |
587 | 0 | offset += 3; |
588 | 0 | proto_tree_add_item(tree, hf_mdb_cl_ser_num, tvb, offset, 12, ENC_ASCII); |
589 | 0 | offset += 12; |
590 | 0 | proto_tree_add_item(tree, hf_mdb_cl_mod_num, tvb, offset, 12, ENC_ASCII); |
591 | 0 | offset += 12; |
592 | | /* XXX - dissect the Software Version bytes */ |
593 | 0 | offset += 2; |
594 | |
|
595 | 0 | return offset; |
596 | 0 | } |
597 | | |
598 | | static void dissect_mdb_cl_expns(tvbuff_t *tvb, int offset, packet_info *pinfo, |
599 | | proto_tree *tree) |
600 | 0 | { |
601 | 0 | uint32_t sub_cmd; |
602 | 0 | const char *s; |
603 | |
|
604 | 0 | proto_tree_add_item_ret_uint(tree, hf_mdb_cl_expns_sub, |
605 | 0 | tvb, offset, 1, ENC_BIG_ENDIAN, &sub_cmd); |
606 | 0 | s = try_val_to_str(sub_cmd, mdb_cl_expns_sub_cmd); |
607 | 0 | if (s) { |
608 | 0 | col_set_str(pinfo->cinfo, COL_INFO, s); |
609 | 0 | } |
610 | 0 | offset++; |
611 | |
|
612 | 0 | switch (sub_cmd) { |
613 | 0 | case MDB_CL_EXPNS_REQ_ID: |
614 | 0 | dissect_mdb_cl_id_fields(tvb, offset, tree); |
615 | 0 | break; |
616 | 0 | case MDB_CL_EXPNS_OPT_ENA: |
617 | | /* XXX - add a bitmask for the Optional Feature Bits */ |
618 | 0 | proto_tree_add_item(tree, hf_mdb_cl_opt_feat, tvb, offset, 4, |
619 | 0 | ENC_BIG_ENDIAN); |
620 | 0 | break; |
621 | 0 | } |
622 | 0 | } |
623 | | |
624 | | static void dissect_mdb_cl_rd_cfg_data(tvbuff_t *tvb, int offset, |
625 | | packet_info *pinfo _U_, proto_tree *tree) |
626 | 0 | { |
627 | 0 | proto_tree_add_item(tree, hf_mdb_cl_feat_lvl, tvb, offset, 1, |
628 | 0 | ENC_BIG_ENDIAN); |
629 | 0 | offset++; |
630 | | /* XXX - dissect Country/Currency Code */ |
631 | 0 | offset += 2; |
632 | 0 | proto_tree_add_item(tree, hf_mdb_cl_scale, tvb, offset, 1, ENC_BIG_ENDIAN); |
633 | 0 | offset++; |
634 | 0 | proto_tree_add_item(tree, hf_mdb_cl_dec_pl, tvb, offset, 1, ENC_BIG_ENDIAN); |
635 | 0 | offset++; |
636 | 0 | proto_tree_add_item(tree, hf_mdb_cl_max_rsp_time, tvb, offset, 1, |
637 | 0 | ENC_TIME_SECS | ENC_BIG_ENDIAN); |
638 | 0 | } |
639 | | |
640 | | static void dissect_mdb_mst_per_cl( tvbuff_t *tvb, int offset, int len _U_, |
641 | | packet_info *pinfo, proto_tree *tree, proto_item *cmd_it, |
642 | | uint8_t addr_byte, mdb_conv_info_t* conv_info _U_) |
643 | 0 | { |
644 | 0 | uint8_t cmd = addr_byte & 0x07; /* the 3-bit command */ |
645 | 0 | proto_tree *cl_tree; |
646 | 0 | uint32_t sub_cmd; |
647 | 0 | const char *s; |
648 | |
|
649 | 0 | s = val_to_str_const(cmd, mdb_cl_cmd, "Unknown"); |
650 | 0 | proto_item_append_text(cmd_it, " (%s)", s); |
651 | 0 | col_set_str(pinfo->cinfo, COL_INFO, s); |
652 | |
|
653 | 0 | cl_tree = proto_tree_add_subtree(tree, tvb, offset, len, ett_mdb_cl, |
654 | 0 | NULL, "Cashless"); |
655 | |
|
656 | 0 | s = NULL; |
657 | 0 | switch (cmd) { |
658 | 0 | case MDB_CL_CMD_SETUP: |
659 | 0 | dissect_mdb_cl_setup(tvb, offset, pinfo, cl_tree); |
660 | 0 | break; |
661 | 0 | case MDB_CL_CMD_VEND: |
662 | 0 | dissect_mdb_cl_vend(tvb, offset, pinfo, cl_tree); |
663 | 0 | break; |
664 | 0 | case MDB_CL_CMD_READER: |
665 | 0 | proto_tree_add_item_ret_uint(cl_tree, hf_mdb_cl_reader_sub, |
666 | 0 | tvb, offset, 1, ENC_BIG_ENDIAN, &sub_cmd); |
667 | 0 | s = try_val_to_str(sub_cmd, mdb_cl_reader_sub_cmd); |
668 | 0 | break; |
669 | 0 | case MDB_CL_CMD_EXPNS: |
670 | 0 | dissect_mdb_cl_expns(tvb, offset, pinfo, cl_tree); |
671 | 0 | break; |
672 | 0 | } |
673 | 0 | if (s) |
674 | 0 | col_set_str(pinfo->cinfo, COL_INFO, s); |
675 | 0 | } |
676 | | |
677 | | static void dissect_mdb_per_mst_cl( tvbuff_t *tvb, int offset, |
678 | | int len _U_, packet_info *pinfo, proto_tree *tree, mdb_conv_info_t* conv_info _U_) |
679 | 0 | { |
680 | 0 | proto_tree *cl_tree; |
681 | 0 | uint32_t cl_resp; |
682 | |
|
683 | 0 | cl_tree = proto_tree_add_subtree(tree, tvb, offset, len, ett_mdb_cl, |
684 | 0 | NULL, "Cashless"); |
685 | |
|
686 | 0 | proto_tree_add_item_ret_uint(cl_tree, hf_mdb_cl_resp, tvb, offset, 1, |
687 | 0 | ENC_BIG_ENDIAN, &cl_resp); |
688 | 0 | col_set_str(pinfo->cinfo, |
689 | 0 | COL_INFO, val_to_str_const(cl_resp, mdb_cl_resp, "Unknown")); |
690 | 0 | offset++; |
691 | |
|
692 | 0 | switch (cl_resp) { |
693 | 0 | case MDB_CL_RESP_RD_CFG_DATA: |
694 | 0 | dissect_mdb_cl_rd_cfg_data(tvb, offset, pinfo, cl_tree); |
695 | 0 | break; |
696 | 0 | case MDB_CL_RESP_VEND_APRV: |
697 | 0 | if (tvb_reported_length_remaining(tvb, offset) == 3) { |
698 | 0 | proto_tree_add_item(cl_tree, hf_mdb_cl_vend_amt, tvb, offset, |
699 | 0 | 2, ENC_BIG_ENDIAN); |
700 | 0 | } |
701 | | /* XXX - dissect the longer response in Expanded Currency Mode */ |
702 | 0 | break; |
703 | 0 | case MDB_CL_RESP_PER_ID: |
704 | 0 | dissect_mdb_cl_id_fields(tvb, offset, tree); |
705 | | /* XXX - check if we have Optional Feature Bits */ |
706 | 0 | break; |
707 | 0 | } |
708 | 0 | } |
709 | | |
710 | | static void dissect_mdb_cgw_report(tvbuff_t *tvb, int offset, |
711 | | packet_info *pinfo, proto_tree *tree) |
712 | 0 | { |
713 | 0 | uint32_t sub_cmd; |
714 | 0 | const char *s; |
715 | |
|
716 | 0 | proto_tree_add_item_ret_uint(tree, hf_mdb_cgw_report_sub, |
717 | 0 | tvb, offset, 1, ENC_BIG_ENDIAN, &sub_cmd); |
718 | 0 | s = try_val_to_str(sub_cmd, mdb_cgw_report_sub_cmd); |
719 | 0 | if (s) { |
720 | 0 | col_set_str(pinfo->cinfo, COL_INFO, s); |
721 | 0 | } |
722 | 0 | offset++; |
723 | |
|
724 | 0 | switch (sub_cmd) { |
725 | 0 | case MDB_CGW_REPORT_DTS_EVT: |
726 | 0 | proto_tree_add_item(tree, hf_mdb_cgw_dts_evt_code, tvb, offset, 10, |
727 | 0 | ENC_ASCII); |
728 | 0 | offset += 10; |
729 | | /* XXX - dissect Date */ |
730 | 0 | offset += 4; |
731 | | /* XXX - dissect Time */ |
732 | 0 | offset += 2; |
733 | 0 | proto_tree_add_item(tree, hf_mdb_cgw_duration, tvb, offset, 4, |
734 | 0 | ENC_BIG_ENDIAN); |
735 | 0 | offset += 4; |
736 | 0 | proto_tree_add_item(tree, hf_mdb_cgw_activity, tvb, offset, 1, |
737 | 0 | ENC_BIG_ENDIAN); |
738 | 0 | break; |
739 | 0 | } |
740 | 0 | } |
741 | | |
742 | | static void dissect_mdb_cgw_expns(tvbuff_t *tvb, int offset, |
743 | | packet_info *pinfo, proto_tree *tree) |
744 | 0 | { |
745 | 0 | uint32_t sub_cmd; |
746 | 0 | const char *s; |
747 | |
|
748 | 0 | proto_tree_add_item_ret_uint(tree, hf_mdb_cgw_expns_sub, |
749 | 0 | tvb, offset, 1, ENC_BIG_ENDIAN, &sub_cmd); |
750 | 0 | s = try_val_to_str(sub_cmd, mdb_cgw_expns_sub_cmd); |
751 | 0 | if (s) { |
752 | 0 | col_set_str(pinfo->cinfo, COL_INFO, s); |
753 | 0 | } |
754 | 0 | offset++; |
755 | |
|
756 | 0 | switch (sub_cmd) { |
757 | 0 | case MDB_CGW_EXPNS_FEAT_ENA: |
758 | 0 | proto_tree_add_item(tree, hf_mdb_cgw_opt_feat, tvb, offset, 4, |
759 | 0 | ENC_BIG_ENDIAN); |
760 | 0 | break; |
761 | 0 | } |
762 | 0 | } |
763 | | |
764 | | static void dissect_mdb_mst_per_cgw( tvbuff_t *tvb, int offset, int len, |
765 | | packet_info *pinfo, proto_tree *tree, proto_item *cmd_it, |
766 | | uint8_t addr_cmd_byte, mdb_conv_info_t* conv_info _U_) |
767 | 0 | { |
768 | 0 | proto_tree *cgw_tree; |
769 | 0 | const char *s; |
770 | |
|
771 | 0 | s = val_to_str_const(addr_cmd_byte, mdb_cgw_addr_cmd, "Unknown"); |
772 | 0 | proto_item_append_text(cmd_it, " (%s)", s); |
773 | 0 | col_set_str(pinfo->cinfo, COL_INFO, s); |
774 | |
|
775 | 0 | cgw_tree = proto_tree_add_subtree(tree, tvb, offset, len, ett_mdb_cgw, |
776 | 0 | NULL, "Communications Gateway"); |
777 | |
|
778 | 0 | switch (addr_cmd_byte) { |
779 | 0 | case MDB_CGW_ADDR_CMD_SETUP: |
780 | 0 | proto_tree_add_item(cgw_tree, hf_mdb_cgw_feat_lvl, tvb, offset, 1, |
781 | 0 | ENC_BIG_ENDIAN); |
782 | 0 | offset++; |
783 | 0 | proto_tree_add_item(cgw_tree, hf_mdb_cgw_scale, tvb, offset, 1, |
784 | 0 | ENC_BIG_ENDIAN); |
785 | 0 | offset++; |
786 | 0 | proto_tree_add_item(cgw_tree, hf_mdb_cgw_dec_pl, tvb, offset, 1, |
787 | 0 | ENC_BIG_ENDIAN); |
788 | 0 | break; |
789 | 0 | case MDB_CGW_ADDR_CMD_REPORT: |
790 | 0 | dissect_mdb_cgw_report(tvb, offset, pinfo, cgw_tree); |
791 | 0 | break; |
792 | 0 | case MDB_CGW_ADDR_CMD_EXPNS: |
793 | 0 | dissect_mdb_cgw_expns(tvb, offset, pinfo, cgw_tree); |
794 | 0 | break; |
795 | 0 | } |
796 | 0 | } |
797 | | |
798 | | static void dissect_mdb_per_mst_cgw( tvbuff_t *tvb, int offset, |
799 | | int len, packet_info *pinfo _U_, proto_tree *tree, mdb_conv_info_t* conv_info _U_) |
800 | 0 | { |
801 | 0 | proto_tree *cgw_tree; |
802 | 0 | uint32_t cgw_resp; |
803 | |
|
804 | 0 | cgw_tree = proto_tree_add_subtree(tree, tvb, offset, len, ett_mdb_cgw, |
805 | 0 | NULL, "Communications Gateway"); |
806 | |
|
807 | 0 | proto_tree_add_item_ret_uint(cgw_tree, hf_mdb_cgw_resp, tvb, offset, 1, |
808 | 0 | ENC_BIG_ENDIAN, &cgw_resp); |
809 | 0 | col_set_str(pinfo->cinfo, |
810 | 0 | COL_INFO, val_to_str_const(cgw_resp, mdb_cgw_resp, "Unknown")); |
811 | 0 | offset++; |
812 | |
|
813 | 0 | switch (cgw_resp) { |
814 | 0 | case MDB_CGW_RESP_CFG: |
815 | 0 | proto_tree_add_item(cgw_tree, hf_mdb_cgw_feat_lvl, tvb, offset, 1, |
816 | 0 | ENC_BIG_ENDIAN); |
817 | 0 | offset++; |
818 | 0 | proto_tree_add_item(cgw_tree, hf_mdb_cgw_max_rsp_time, tvb, offset, |
819 | 0 | 2, ENC_TIME_SECS | ENC_BIG_ENDIAN); |
820 | 0 | break; |
821 | 0 | case MDB_CGW_RESP_PER_ID: |
822 | 0 | proto_tree_add_item(tree, hf_mdb_cgw_manuf_code, tvb, offset, 3, |
823 | 0 | ENC_ASCII); |
824 | 0 | offset += 3; |
825 | 0 | proto_tree_add_item(tree, hf_mdb_cgw_ser_num, tvb, offset, 12, |
826 | 0 | ENC_ASCII); |
827 | 0 | offset += 12; |
828 | 0 | proto_tree_add_item(tree, hf_mdb_cgw_mod_num, tvb, offset, 12, |
829 | 0 | ENC_ASCII); |
830 | 0 | offset += 12; |
831 | | /* XXX - dissect the Software Version bytes */ |
832 | 0 | offset += 2; |
833 | 0 | proto_tree_add_item(tree, hf_mdb_cgw_opt_feat, tvb, offset, 4, |
834 | 0 | ENC_BIG_ENDIAN); |
835 | 0 | break; |
836 | 0 | } |
837 | 0 | } |
838 | | |
839 | | static int dissect_mdb_bv_setup_fields(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree) |
840 | 0 | { |
841 | 0 | wmem_strbuf_t* bill_str = wmem_strbuf_new(pinfo->pool, ""); |
842 | |
|
843 | 0 | proto_tree_add_item(tree, hf_mdb_bv_setup_bill_val_feature, tvb, offset, 1, ENC_BIG_ENDIAN); |
844 | 0 | offset += 1; |
845 | 0 | proto_tree_add_item(tree, hf_mdb_bv_setup_ctry_currency_code, tvb, offset, 2, ENC_BIG_ENDIAN); |
846 | 0 | offset += 2; |
847 | 0 | proto_tree_add_item(tree, hf_mdb_bv_setup_bill_scal_fac, tvb, offset, 2, ENC_BIG_ENDIAN); |
848 | 0 | offset += 2; |
849 | 0 | proto_tree_add_item(tree, hf_mdb_bv_setup_dec_places, tvb, offset, 1, ENC_BIG_ENDIAN); |
850 | 0 | offset += 1; |
851 | 0 | proto_tree_add_item(tree, hf_mdb_bv_setup_bill_stacker_cap, tvb, offset, 2, ENC_BIG_ENDIAN); |
852 | 0 | offset += 2; |
853 | 0 | proto_tree_add_item(tree, hf_mdb_bv_setup_bill_sec_lvls, tvb, offset, 2, ENC_BIG_ENDIAN); |
854 | 0 | offset += 2; |
855 | 0 | proto_tree_add_item(tree, hf_mdb_bv_setup_escrow, tvb, offset, 1, ENC_BIG_ENDIAN); |
856 | 0 | offset += 1; |
857 | |
|
858 | 0 | uint8_t bill_val; |
859 | 0 | for (int i = 0; i < 16; i++) { |
860 | 0 | bill_val = tvb_get_uint8(tvb, offset + i); |
861 | | // Append each bill value to comma separated string |
862 | 0 | wmem_strbuf_append_printf(bill_str, "%u%s", bill_val, (i < 15) ? "," : ""); |
863 | 0 | } |
864 | | // Add the formatted string to the protocol tree |
865 | 0 | proto_tree_add_string_format_value(tree, hf_mdb_bv_setup_bill_type_cred, tvb, offset, 16, |
866 | 0 | bill_str->str, "Bill values: %s", bill_str->str); |
867 | 0 | offset += 16; |
868 | |
|
869 | 0 | return offset; |
870 | 0 | } |
871 | | |
872 | | static int dissect_mdb_bv_poll_stat_bill_accept(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree) |
873 | 0 | { |
874 | 0 | uint32_t bill_routing; |
875 | |
|
876 | 0 | proto_tree_add_item_ret_uint(tree, hf_mdb_bv_poll_bill_routing_state, tvb, offset, 1, ENC_NA, &bill_routing); |
877 | 0 | proto_tree_add_item(tree, hf_mdb_bv_poll_bill_type, tvb, offset, 1, ENC_NA); |
878 | |
|
879 | 0 | col_add_str(pinfo->cinfo, COL_INFO, |
880 | 0 | val_to_str(pinfo->pool, bill_routing, mdb_bv_poll_bill_routing_state, "Unknown Bill Routing: 0x%x")); |
881 | |
|
882 | 0 | offset += 1; |
883 | |
|
884 | 0 | return offset; |
885 | 0 | } |
886 | | |
887 | | static int dissect_mdb_bv_poll_fields(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree) |
888 | 0 | { |
889 | 0 | uint8_t cmd = tvb_get_uint8(tvb, offset); |
890 | |
|
891 | 0 | if (cmd & 0x80) |
892 | 0 | { |
893 | | // Bills Accepted response |
894 | 0 | dissect_mdb_bv_poll_stat_bill_accept(tvb, offset, pinfo, tree); |
895 | 0 | offset += 1; |
896 | 0 | } |
897 | 0 | else if (cmd > 0x1A) |
898 | 0 | { |
899 | | // File transport layer response |
900 | 0 | offset += 1; |
901 | 0 | } |
902 | 0 | else |
903 | 0 | { |
904 | 0 | proto_tree_add_item(tree, hf_mdb_bv_poll_state, tvb, offset, 1, ENC_BIG_ENDIAN); |
905 | 0 | col_add_str(pinfo->cinfo, COL_INFO, |
906 | 0 | val_to_str(pinfo->pool, cmd, mdb_bv_poll_state, "Unknown Poll Response 0x%x")); |
907 | 0 | offset += 1; |
908 | 0 | } |
909 | |
|
910 | 0 | return offset; |
911 | 0 | } |
912 | | |
913 | | static int dissect_mdb_bv_bill_type(tvbuff_t *tvb, int offset, proto_tree *tree) |
914 | 0 | { |
915 | 0 | proto_tree_add_item(tree, hf_mdb_bv_bill_enable, tvb, offset, 2, ENC_BIG_ENDIAN); |
916 | 0 | offset += 2; |
917 | 0 | proto_tree_add_item(tree, hf_mdb_bv_bill_escrow_enable, tvb, offset, 2, ENC_BIG_ENDIAN); |
918 | 0 | offset += 2; |
919 | |
|
920 | 0 | return offset; |
921 | 0 | } |
922 | | |
923 | | static int dissect_mdb_bv_escrow(tvbuff_t *tvb, int offset, proto_tree *tree) |
924 | 0 | { |
925 | 0 | proto_tree_add_item(tree, hf_mdb_bv_escrow_state, tvb, offset, 1, ENC_NA); |
926 | 0 | offset += 1; |
927 | |
|
928 | 0 | return offset; |
929 | 0 | } |
930 | | |
931 | | static int dissect_mdb_bv_stacker(tvbuff_t *tvb, int offset, proto_tree *tree) |
932 | 0 | { |
933 | 0 | proto_tree_add_item(tree, hf_mdb_bv_stacker, tvb, offset, 2, ENC_BIG_ENDIAN); |
934 | 0 | offset += 2; |
935 | |
|
936 | 0 | return offset; |
937 | 0 | } |
938 | | |
939 | | static int dissect_mdb_bv_exp_id_opt_fields(tvbuff_t *tvb, int offset, |
940 | | proto_tree *tree, bool opt_features) |
941 | 0 | { |
942 | 0 | proto_tree_add_item(tree, hf_mdb_bv_exp_manufact_code, tvb, offset, 3, ENC_ASCII); |
943 | 0 | offset += 3; |
944 | 0 | proto_tree_add_item(tree, hf_mdb_bv_exp_serial_num, tvb, offset, 12, ENC_ASCII); |
945 | 0 | offset += 12; |
946 | 0 | proto_tree_add_item(tree, hf_mdb_bv_exp_model_tuning_num, tvb, offset, 12, ENC_ASCII); |
947 | 0 | offset += 12; |
948 | 0 | proto_tree_add_item(tree, hf_mdb_bv_exp_software_version, tvb, offset, 2, ENC_BIG_ENDIAN); |
949 | 0 | offset += 2; |
950 | | // Only for cmd 37 02 |
951 | 0 | if (opt_features) { |
952 | 0 | proto_tree_add_item(tree, hf_mdb_bv_exp_opt_feat, tvb, offset, 4, ENC_BIG_ENDIAN); |
953 | 0 | offset += 4; |
954 | 0 | } |
955 | |
|
956 | 0 | return offset; |
957 | 0 | } |
958 | | |
959 | | static int dissect_mdb_bv_exp_recycler_setup(tvbuff_t *tvb, int offset, proto_tree *tree) |
960 | 0 | { |
961 | 0 | proto_tree_add_item(tree, hf_mdb_bv_exp_manual_dispense_enable, tvb, offset, 2, ENC_BIG_ENDIAN); |
962 | 0 | offset += 2; |
963 | |
|
964 | 0 | return offset; |
965 | 0 | } |
966 | | |
967 | | static int dissect_mdb_bv_exp_recycler_enable(tvbuff_t *tvb, int offset, proto_tree *tree) |
968 | 0 | { |
969 | 0 | proto_tree_add_item(tree, hf_mdb_bv_exp_bill_type_routing, tvb, offset, 2, ENC_BIG_ENDIAN); |
970 | 0 | offset += 2; |
971 | |
|
972 | 0 | for (int i = 0; i < 16; i++) { |
973 | 0 | proto_tree_add_item(tree, hf_mdb_bv_exp_bill_recycler_enabled, tvb, offset, 1, ENC_BIG_ENDIAN); |
974 | 0 | offset += 1; |
975 | 0 | } |
976 | |
|
977 | 0 | return offset; |
978 | 0 | } |
979 | | |
980 | | static int dissect_mdb_bv_exp_dispense_status(tvbuff_t *tvb, int offset, proto_tree *tree) |
981 | 0 | { |
982 | 0 | proto_tree_add_item(tree, hf_mdb_bv_exp_dispenser_full_state, tvb, offset, 2, ENC_BIG_ENDIAN); |
983 | 0 | offset += 2; |
984 | 0 | for (int i = 0; i < 32; i++) { |
985 | 0 | proto_tree_add_item(tree, hf_mdb_bv_exp_bill_count, tvb, offset, 1, ENC_BIG_ENDIAN); |
986 | 0 | offset += 1; |
987 | 0 | } |
988 | |
|
989 | 0 | return offset; |
990 | 0 | } |
991 | | |
992 | | static int dissect_mdb_bv_exp_dispense_bill(tvbuff_t *tvb, int offset, proto_tree *tree) |
993 | 0 | { |
994 | 0 | proto_tree_add_item(tree, hf_mdb_bv_exp_bill_type_dispensed, tvb, offset, 1, ENC_BIG_ENDIAN); |
995 | 0 | offset += 1; |
996 | 0 | proto_tree_add_item(tree, hf_mdb_bv_exp_bill_type_number_bills, tvb, offset, 2, ENC_BIG_ENDIAN); |
997 | 0 | offset += 2; |
998 | |
|
999 | 0 | return offset; |
1000 | 0 | } |
1001 | | |
1002 | | static int dissect_mdb_bv_exp_dispense_value_bill(tvbuff_t *tvb, int offset, proto_tree *tree) |
1003 | 0 | { |
1004 | 0 | proto_tree_add_item(tree, hf_mdb_bv_exp_dispense_value_bills, tvb, offset, 2, ENC_BIG_ENDIAN); |
1005 | 0 | offset += 2; |
1006 | |
|
1007 | 0 | return offset; |
1008 | 0 | } |
1009 | | |
1010 | | static int dissect_mdb_bv_exp_payout_status(tvbuff_t *tvb, int offset, proto_tree *tree) |
1011 | 0 | { |
1012 | 0 | for (int i = 0; i < 16; i++) { |
1013 | 0 | proto_tree_add_item(tree, hf_mdb_bv_exp_payout_state, tvb, offset, 2, ENC_BIG_ENDIAN); |
1014 | 0 | offset += 2; |
1015 | 0 | } |
1016 | |
|
1017 | 0 | return offset; |
1018 | 0 | } |
1019 | | |
1020 | | static int dissect_mdb_bv_exp_payout_value_poll(tvbuff_t *tvb, int offset, proto_tree *tree) |
1021 | 0 | { |
1022 | 0 | proto_tree_add_item(tree, hf_mdb_bv_exp_dispenser_payout_activity, tvb, offset, 2, ENC_BIG_ENDIAN); |
1023 | 0 | offset += 2; |
1024 | |
|
1025 | 0 | return offset; |
1026 | 0 | } |
1027 | | |
1028 | | static void dissect_mdb_bv_expns_mst_per(tvbuff_t *tvb, int offset, packet_info *pinfo, |
1029 | | proto_tree *tree) |
1030 | 0 | { |
1031 | 0 | const char *s; |
1032 | 0 | uint32_t sub_cmd = tvb_get_uint8(tvb, offset); |
1033 | |
|
1034 | 0 | s = try_val_to_str(sub_cmd, mdb_bv_exp_cmd); |
1035 | 0 | if (s) { |
1036 | 0 | col_set_str(pinfo->cinfo, COL_INFO, s); |
1037 | 0 | } |
1038 | |
|
1039 | 0 | switch (sub_cmd) { |
1040 | 0 | case MDB_BV_LVL2_FEATURE_ENABLE: |
1041 | 0 | proto_tree_add_item(tree, hf_mdb_bv_exp_opt_feat_enable, tvb, offset, 4, |
1042 | 0 | ENC_BIG_ENDIAN); |
1043 | 0 | break; |
1044 | 0 | case MDB_BV_RECYCL_ENABLE: |
1045 | 0 | dissect_mdb_bv_exp_recycler_enable(tvb, offset, tree); |
1046 | 0 | break; |
1047 | 0 | case MDB_BV_DISPENSE_BILL: |
1048 | 0 | dissect_mdb_bv_exp_dispense_bill(tvb, offset, tree); |
1049 | 0 | break; |
1050 | 0 | case MDB_BV_DISPENSE_VAL: |
1051 | 0 | dissect_mdb_bv_exp_dispense_value_bill(tvb, offset, tree); |
1052 | 0 | break; |
1053 | 0 | case MDB_BV_PAYOUT_CANCEL: |
1054 | | // Nothing to dissect |
1055 | 0 | break; |
1056 | 0 | } |
1057 | 0 | } |
1058 | | |
1059 | | static void dissect_mdb_bv_expns_per_mst(tvbuff_t *tvb, int offset, proto_tree *tree, uint16_t cmd) |
1060 | 0 | { |
1061 | 0 | uint8_t sub_cmd = cmd >> SUB_CMD_OFFSET; |
1062 | |
|
1063 | 0 | switch (sub_cmd) { |
1064 | 0 | case MDB_BV_LVL1_WITHOUT_OPT_BITS: |
1065 | 0 | dissect_mdb_bv_exp_id_opt_fields(tvb, offset, tree, false); |
1066 | 0 | break; |
1067 | 0 | case MDB_BV_LVL2_ID_WITH_OPTION_BITS: |
1068 | 0 | dissect_mdb_bv_exp_id_opt_fields(tvb, offset, tree, true); |
1069 | 0 | break; |
1070 | 0 | case MDB_BV_RECYCL_SETUP: |
1071 | 0 | dissect_mdb_bv_exp_recycler_setup(tvb, offset, tree); |
1072 | 0 | break; |
1073 | 0 | case MDB_BV_BILL_DISPENSE_STAT: |
1074 | 0 | dissect_mdb_bv_exp_dispense_status(tvb, offset, tree); |
1075 | 0 | break; |
1076 | 0 | case MDB_BV_PAYOUT_STAT: |
1077 | 0 | dissect_mdb_bv_exp_payout_status(tvb, offset, tree); |
1078 | 0 | break; |
1079 | 0 | case MDB_BV_PAYOUT_VALUE_POLL: |
1080 | 0 | dissect_mdb_bv_exp_payout_value_poll(tvb, offset, tree); |
1081 | 0 | break; |
1082 | | // FTL Expansion commands not implemented yet |
1083 | 0 | } |
1084 | 0 | } |
1085 | | |
1086 | | static void dissect_mdb_mst_per_bv( tvbuff_t *tvb, int offset, int len, |
1087 | | packet_info *pinfo, proto_tree *tree, proto_item *cmd_it, |
1088 | | uint8_t addr_cmd_byte, mdb_conv_info_t* conv_info) |
1089 | 0 | { |
1090 | 0 | uint8_t cmd = CMD_MASK & addr_cmd_byte; /* the 3-bit command */ |
1091 | 0 | proto_tree *bv_tree; |
1092 | 0 | mdb_transaction_t* transaction; |
1093 | 0 | uint8_t sub_cmd = 0; |
1094 | 0 | const char *s; |
1095 | |
|
1096 | 0 | s = val_to_str(pinfo->pool, cmd, mdb_bv_cmd, "Unknown Command: 0x%x"); |
1097 | 0 | proto_item_append_text(cmd_it, " (%s)", s); |
1098 | 0 | col_add_fstr(pinfo->cinfo, COL_INFO, "%s (Request)", s); |
1099 | |
|
1100 | 0 | bv_tree = proto_tree_add_subtree(tree, tvb, offset, len, ett_mdb_bv, |
1101 | 0 | NULL, "Bill Validator"); |
1102 | |
|
1103 | 0 | switch (cmd) { |
1104 | 0 | case MDB_BV_CMD_SETUP: |
1105 | 0 | break; |
1106 | 0 | case MDB_BV_CMD_SECURITY: |
1107 | 0 | break; |
1108 | 0 | case MDB_BV_CMD_BILL_TYPE: |
1109 | 0 | dissect_mdb_bv_bill_type(tvb, offset, bv_tree); |
1110 | 0 | break; |
1111 | 0 | case MDB_BV_CMD_ESCROW: |
1112 | 0 | dissect_mdb_bv_escrow(tvb, offset, bv_tree); |
1113 | 0 | break; |
1114 | 0 | case MDB_BV_CMD_STACKER: |
1115 | 0 | break; |
1116 | 0 | case MDB_BV_CMD_EXPNS: |
1117 | 0 | sub_cmd = tvb_get_uint8(tvb, offset); |
1118 | 0 | dissect_mdb_bv_expns_mst_per(tvb, offset, pinfo, bv_tree); |
1119 | 0 | break; |
1120 | 0 | } |
1121 | | |
1122 | 0 | if (!pinfo->fd->visited) |
1123 | 0 | { |
1124 | | //Create the request information |
1125 | 0 | transaction = wmem_new0(wmem_file_scope(), mdb_transaction_t); |
1126 | 0 | transaction->req_num = pinfo->num; |
1127 | 0 | transaction->req_time = pinfo->abs_ts; |
1128 | | |
1129 | | // If not MDB_BV_CMD_EXPNS, then sub_cmd is just 0 |
1130 | 0 | transaction->cmd = (cmd | (sub_cmd << SUB_CMD_OFFSET)); |
1131 | 0 | wmem_tree_insert32(conv_info->transactions, pinfo->num, (void*)transaction); |
1132 | 0 | conv_info->last_cmd = transaction->cmd; |
1133 | 0 | conv_info->last_req_packet = pinfo->num; |
1134 | 0 | } |
1135 | 0 | else |
1136 | 0 | { |
1137 | 0 | transaction = (mdb_transaction_t*)wmem_tree_lookup32_le(conv_info->transactions, pinfo->num); |
1138 | 0 | } |
1139 | |
|
1140 | 0 | if ((transaction != NULL) && (transaction->rep_num)) |
1141 | 0 | { |
1142 | 0 | proto_item* it = proto_tree_add_uint(tree, hf_mdb_response_in, NULL, 0, 0, transaction->rep_num); |
1143 | 0 | proto_item_set_generated(it); |
1144 | |
|
1145 | 0 | } |
1146 | 0 | } |
1147 | | |
1148 | | |
1149 | | static void dissect_mdb_mst_per(tvbuff_t *tvb, int offset, packet_info *pinfo, |
1150 | | proto_tree *tree) |
1151 | 0 | { |
1152 | 0 | uint8_t addr_byte, addr; |
1153 | 0 | int mst_per_len; |
1154 | 0 | unsigned data_len; |
1155 | 0 | proto_item *cmd_it; |
1156 | |
|
1157 | 0 | mst_per_len = tvb_reported_length_remaining(tvb, offset); |
1158 | 0 | if (mst_per_len <= 0) { |
1159 | 0 | expert_add_info(pinfo, tree, &ei_mdb_short_packet); |
1160 | 0 | return; |
1161 | 0 | } |
1162 | | |
1163 | 0 | if (mst_per_len == 1) { |
1164 | 0 | dissect_mdb_ack(tvb, offset, pinfo, tree); |
1165 | 0 | return; |
1166 | 0 | } |
1167 | | |
1168 | | /* |
1169 | | * Our packet has one address byte, an optional data block and one |
1170 | | * checksum byte. |
1171 | | */ |
1172 | | |
1173 | 0 | data_len = mst_per_len - 2; |
1174 | 0 | int start_offset = offset; |
1175 | | |
1176 | | /* |
1177 | | * The address byte is 5-bit address | 3-bit command. |
1178 | | * |
1179 | | * The specification uses 8-bit addresses which are the address byte |
1180 | | * with the three lowest bits set to 0. |
1181 | | * |
1182 | | * The commands are defined as the complete address byte (i.e. they |
1183 | | * include the address part). This does not make much sense: Cashless #1 |
1184 | | * and #2 have different addresses but exactly the same 3-bit commands. |
1185 | | * |
1186 | | * In this dissector, we try to use the same values as the specification. |
1187 | | */ |
1188 | 0 | addr_byte = tvb_get_uint8(tvb, offset); |
1189 | 0 | addr = addr_byte & ADDR_MASK; |
1190 | 0 | proto_tree_add_uint_bits_format_value(tree, hf_mdb_addr, |
1191 | 0 | tvb, 8*offset, 5, addr, ENC_BIG_ENDIAN, "0x%02x", addr); |
1192 | 0 | cmd_it = proto_tree_add_uint(tree, hf_mdb_cmd, tvb, offset, 1, addr_byte & CMD_MASK); |
1193 | 0 | mdb_set_addrs(MDB_EVT_DATA_MST_PER, addr, pinfo); |
1194 | 0 | mdb_conv_info_t* conv_info = get_mdb_conv_info(pinfo); |
1195 | 0 | offset++; |
1196 | | |
1197 | | /* |
1198 | | * We call the peripheral functions even if data_len == 0 so they can fix |
1199 | | * up the command with peripheral-specific info. |
1200 | | */ |
1201 | 0 | switch (addr) { |
1202 | 0 | case ADDR_CASHLESS1: |
1203 | 0 | dissect_mdb_mst_per_cl(tvb, offset, data_len, pinfo, tree, |
1204 | 0 | cmd_it, addr_byte, conv_info); |
1205 | 0 | break; |
1206 | 0 | case ADDR_COMMS_GW: |
1207 | 0 | dissect_mdb_mst_per_cgw(tvb, offset, data_len, pinfo, tree, |
1208 | 0 | cmd_it, addr_byte, conv_info); |
1209 | 0 | break; |
1210 | 0 | case ADDR_BILL_VALIDATOR: |
1211 | 0 | dissect_mdb_mst_per_bv(tvb, offset, data_len, pinfo, tree, |
1212 | 0 | cmd_it, addr_byte, conv_info); |
1213 | 0 | break; |
1214 | 0 | default: |
1215 | 0 | if (data_len > 0) { |
1216 | 0 | proto_tree_add_item(tree, hf_mdb_data, |
1217 | 0 | tvb, offset, data_len, ENC_NA); |
1218 | 0 | } |
1219 | 0 | break; |
1220 | 0 | } |
1221 | | /* offset += data_len; */ |
1222 | | |
1223 | | /* Verify the checksum */ |
1224 | 0 | mdb_add_checksum(tvb, pinfo, tree, start_offset, data_len + 2); |
1225 | 0 | } |
1226 | | |
1227 | | static void dissect_mdb_per_mst_bv( tvbuff_t *tvb, int offset, |
1228 | | int len, packet_info *pinfo _U_, proto_tree *tree, mdb_conv_info_t* conv_info) |
1229 | 0 | { |
1230 | 0 | proto_tree *bv_tree; |
1231 | 0 | mdb_transaction_t* transaction; |
1232 | |
|
1233 | 0 | if (!pinfo->fd->visited) |
1234 | 0 | { |
1235 | 0 | transaction = (mdb_transaction_t*)wmem_tree_lookup32_le(conv_info->transactions, conv_info->last_req_packet); |
1236 | 0 | if (transaction) |
1237 | 0 | { |
1238 | 0 | transaction->rep_num = pinfo->num; |
1239 | 0 | } |
1240 | 0 | else |
1241 | 0 | { |
1242 | 0 | transaction = wmem_new0(wmem_file_scope(), mdb_transaction_t); |
1243 | 0 | transaction->rep_num = pinfo->num; |
1244 | 0 | } |
1245 | 0 | wmem_tree_insert32(conv_info->transactions, pinfo->num, (void*)transaction); |
1246 | 0 | } |
1247 | 0 | else |
1248 | 0 | { |
1249 | 0 | transaction = (mdb_transaction_t*)wmem_tree_lookup32_le(conv_info->transactions, pinfo->num); |
1250 | 0 | } |
1251 | | |
1252 | | //Sanity check |
1253 | 0 | if (transaction == NULL) |
1254 | 0 | return; |
1255 | | |
1256 | 0 | col_add_fstr(pinfo->cinfo, COL_INFO, "%s (Response)", |
1257 | 0 | val_to_str(pinfo->pool, transaction->cmd & CMD_MASK, mdb_bv_cmd, "Unknown Command: 0x%x")); |
1258 | |
|
1259 | 0 | switch (transaction->cmd & CMD_MASK) { |
1260 | 0 | case MDB_BV_CMD_SETUP: |
1261 | 0 | bv_tree = proto_tree_add_subtree(tree, tvb, offset, len, ett_mdb_bv, NULL, "Setup Response"); |
1262 | 0 | dissect_mdb_bv_setup_fields(tvb, offset, pinfo, bv_tree); |
1263 | 0 | break; |
1264 | 0 | case MDB_BV_CMD_SECURITY: |
1265 | 0 | /* bv_tree = */ proto_tree_add_subtree(tree, tvb, offset, len, ett_mdb_bv, NULL, "Security Response"); |
1266 | 0 | break; |
1267 | 0 | case MDB_BV_CMD_POLL: |
1268 | 0 | bv_tree = proto_tree_add_subtree(tree, tvb, offset, len, ett_mdb_bv, NULL, "Poll Response"); |
1269 | 0 | dissect_mdb_bv_poll_fields(tvb, offset, pinfo, bv_tree); |
1270 | 0 | break; |
1271 | 0 | case MDB_BV_CMD_BILL_TYPE: |
1272 | 0 | break; |
1273 | 0 | case MDB_BV_CMD_ESCROW: |
1274 | 0 | break; |
1275 | 0 | case MDB_BV_CMD_STACKER: |
1276 | 0 | bv_tree = proto_tree_add_subtree(tree, tvb, offset, len, ett_mdb_bv, NULL, "Stacker Response"); |
1277 | 0 | dissect_mdb_bv_stacker(tvb, offset, bv_tree); |
1278 | 0 | break; |
1279 | 0 | case MDB_BV_CMD_EXPNS: |
1280 | 0 | bv_tree = proto_tree_add_subtree(tree, tvb, offset, len, ett_mdb_bv, NULL, "Expansion Feature Response"); |
1281 | 0 | dissect_mdb_bv_expns_per_mst(tvb, offset, bv_tree, transaction->cmd); |
1282 | 0 | break; |
1283 | 0 | } |
1284 | | |
1285 | | // This is a reply |
1286 | 0 | if (transaction->req_num) |
1287 | 0 | { |
1288 | 0 | proto_item* it; |
1289 | 0 | nstime_t ns; |
1290 | |
|
1291 | 0 | it = proto_tree_add_uint(tree, hf_mdb_response_to, NULL, 0, 0, transaction->req_num); |
1292 | 0 | proto_item_set_generated(it); |
1293 | |
|
1294 | 0 | nstime_delta(&ns, &pinfo->abs_ts, &transaction->req_time); |
1295 | 0 | it = proto_tree_add_time(tree, hf_mdb_time, NULL, 0, 0, &ns); |
1296 | 0 | proto_item_set_generated(it); |
1297 | 0 | } |
1298 | |
|
1299 | 0 | } |
1300 | | |
1301 | | /* |
1302 | | * Peripheral-to-Master messages can be simple control replies (ACK, NAK, RET) |
1303 | | * that do not include a checksum. Master-to-Peripheral commands always |
1304 | | * require a checksum, which is why this check is only needed for |
1305 | | * Peripheral-to-Master events. |
1306 | | */ |
1307 | | static void dissect_mdb_per_mst(tvbuff_t *tvb, int offset, packet_info *pinfo, |
1308 | | proto_tree *tree, uint8_t addr) |
1309 | 0 | { |
1310 | 0 | int per_mst_len; |
1311 | 0 | unsigned data_len; |
1312 | | |
1313 | | /* |
1314 | | * A packet from peripheral to master is either a single ACK/NAK byte or |
1315 | | * a non-empty data block followed by one checksum byte. |
1316 | | */ |
1317 | |
|
1318 | 0 | per_mst_len = tvb_reported_length_remaining(tvb, offset); |
1319 | 0 | if (per_mst_len <= 0) { |
1320 | 0 | expert_add_info(pinfo, tree, &ei_mdb_short_packet); |
1321 | 0 | return; |
1322 | 0 | } |
1323 | | |
1324 | 0 | if (per_mst_len == 1) { |
1325 | 0 | dissect_mdb_ack(tvb, offset, pinfo, tree); |
1326 | 0 | return; |
1327 | 0 | } |
1328 | | |
1329 | 0 | col_set_str(pinfo->cinfo, |
1330 | 0 | COL_INFO, val_to_str_const(addr, mdb_addr, "Unknown")); |
1331 | |
|
1332 | 0 | mdb_conv_info_t* conv_info = get_mdb_conv_info(pinfo); |
1333 | |
|
1334 | 0 | data_len = per_mst_len - 1; |
1335 | 0 | int start_offset = offset; |
1336 | | |
1337 | | /* |
1338 | | * Peripheral-to-Master messages can be simple control replies (ACK, NAK, RET) |
1339 | | * that do not include a checksum. |
1340 | | */ |
1341 | 0 | bool checksum_needed = true; |
1342 | 0 | if (data_len == 1 && is_mdb_reply(tvb_get_uint8(tvb, offset))) { |
1343 | 0 | checksum_needed = false; |
1344 | 0 | } |
1345 | | |
1346 | |
|
1347 | 0 | switch (addr) { |
1348 | 0 | case ADDR_CASHLESS1: |
1349 | 0 | dissect_mdb_per_mst_cl(tvb, offset, data_len, pinfo, tree, conv_info); |
1350 | 0 | break; |
1351 | 0 | case ADDR_COMMS_GW: |
1352 | 0 | dissect_mdb_per_mst_cgw(tvb, offset, data_len, pinfo, tree, conv_info); |
1353 | 0 | break; |
1354 | 0 | case ADDR_BILL_VALIDATOR: |
1355 | 0 | dissect_mdb_per_mst_bv(tvb, offset, data_len, pinfo, tree, conv_info); |
1356 | 0 | break; |
1357 | 0 | default: |
1358 | 0 | proto_tree_add_item(tree, hf_mdb_data, tvb, offset, data_len, ENC_NA); |
1359 | 0 | break; |
1360 | 0 | } |
1361 | | /* offset += data_len; */ |
1362 | | |
1363 | 0 | if (checksum_needed) { |
1364 | 0 | mdb_add_checksum(tvb, pinfo, tree, start_offset, data_len + 1); |
1365 | 0 | } |
1366 | 0 | } |
1367 | | |
1368 | | static int dissect_mdb(tvbuff_t *tvb, |
1369 | | packet_info *pinfo, proto_tree *tree, void *data _U_) |
1370 | 1 | { |
1371 | 1 | int offset = 0, offset_ver, offset_evt; |
1372 | 1 | uint8_t version, event, addr; |
1373 | 1 | proto_tree *mdb_tree, *hdr_tree; |
1374 | 1 | proto_item *tree_ti, *hdr_ti; |
1375 | | |
1376 | | /* We need at least the shortest possible pseudo header. */ |
1377 | 1 | if (tvb_captured_length(tvb) < 3) |
1378 | 0 | return 0; |
1379 | | |
1380 | 1 | offset_ver = offset; |
1381 | 1 | version = tvb_get_uint8(tvb, offset++); |
1382 | 1 | if (version != 0) |
1383 | 0 | return 0; |
1384 | | |
1385 | 1 | offset_evt = offset; |
1386 | 1 | event = tvb_get_uint8(tvb, offset++); |
1387 | 1 | if (!try_val_to_str(event, mdb_event)) |
1388 | 1 | return 0; |
1389 | | |
1390 | 0 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "MDB"); |
1391 | 0 | col_clear(pinfo->cinfo, COL_INFO); |
1392 | |
|
1393 | 0 | tree_ti = proto_tree_add_item(tree, proto_mdb, tvb, 0, -1, ENC_NA); |
1394 | 0 | mdb_tree = proto_item_add_subtree(tree_ti, ett_mdb); |
1395 | |
|
1396 | 0 | hdr_tree = proto_tree_add_subtree(mdb_tree, tvb, 0, -1, ett_mdb_hdr, |
1397 | 0 | &hdr_ti, "Pseudo header"); |
1398 | |
|
1399 | 0 | proto_tree_add_item(hdr_tree, hf_mdb_hdr_ver, |
1400 | 0 | tvb, offset_ver, 1, ENC_BIG_ENDIAN); |
1401 | 0 | proto_tree_add_item(hdr_tree, hf_mdb_event, |
1402 | 0 | tvb, offset_evt, 1, ENC_BIG_ENDIAN); |
1403 | | |
1404 | | /* Packets from peripheral to master always have an address byte in their |
1405 | | pseudo header. */ |
1406 | 0 | if (event == MDB_EVT_DATA_PER_MST) { |
1407 | | /* See the comment in dissect_mdb_mst_per about MDB addresses. */ |
1408 | 0 | addr = tvb_get_uint8(tvb, offset) & ADDR_MASK; |
1409 | 0 | proto_tree_add_uint_bits_format_value(hdr_tree, hf_mdb_addr, |
1410 | 0 | tvb, 8*offset, 5, addr, ENC_BIG_ENDIAN, "0x%02x", addr); |
1411 | 0 | offset++; |
1412 | 0 | mdb_set_addrs(event, addr, pinfo); |
1413 | 0 | } |
1414 | | |
1415 | | /* We're now at the end of the pseudo header. */ |
1416 | 0 | proto_item_set_len(hdr_ti, offset); |
1417 | |
|
1418 | 0 | if (event == MDB_EVT_BUS_RESET) |
1419 | 0 | return offset; |
1420 | | |
1421 | 0 | if (event == MDB_EVT_DATA_MST_PER) |
1422 | 0 | dissect_mdb_mst_per(tvb, offset, pinfo, mdb_tree); |
1423 | 0 | else if (event == MDB_EVT_DATA_PER_MST) |
1424 | 0 | dissect_mdb_per_mst(tvb, offset, pinfo, mdb_tree, addr); |
1425 | |
|
1426 | 0 | return tvb_reported_length(tvb); |
1427 | 0 | } |
1428 | | |
1429 | | void proto_register_mdb(void) |
1430 | 16 | { |
1431 | 16 | expert_module_t* expert_mdb; |
1432 | | |
1433 | 16 | static int *ett[] = { |
1434 | 16 | &ett_mdb, |
1435 | 16 | &ett_mdb_hdr, |
1436 | 16 | &ett_mdb_cl, |
1437 | 16 | &ett_mdb_cgw, |
1438 | 16 | &ett_mdb_bv |
1439 | 16 | }; |
1440 | | |
1441 | 16 | static hf_register_info hf[] = { |
1442 | 16 | { &hf_mdb_hdr_ver, |
1443 | 16 | { "Version", "mdb.hdr_ver", |
1444 | 16 | FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL } |
1445 | 16 | }, |
1446 | 16 | { &hf_mdb_event, |
1447 | 16 | { "Event", "mdb.event", |
1448 | 16 | FT_UINT8, BASE_HEX, VALS(mdb_event), 0, NULL, HFILL } |
1449 | 16 | }, |
1450 | 16 | { &hf_mdb_addr, |
1451 | 16 | { "Address", "mdb.addr", |
1452 | 16 | FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL } |
1453 | 16 | }, |
1454 | 16 | { &hf_mdb_cmd, |
1455 | 16 | { "Command", "mdb.cmd", |
1456 | 16 | FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL } |
1457 | 16 | }, |
1458 | 16 | { &hf_mdb_cl_setup_sub, |
1459 | 16 | { "Sub-command", "mdb.cashless.setup_sub_cmd", |
1460 | 16 | FT_UINT8, BASE_HEX, VALS(mdb_cl_setup_sub_cmd), 0, NULL, HFILL } |
1461 | 16 | }, |
1462 | 16 | { &hf_mdb_cl_feat_lvl, |
1463 | 16 | { "Feature level", "mdb.cashless.feature_level", |
1464 | 16 | FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } |
1465 | 16 | }, |
1466 | 16 | { &hf_mdb_cl_cols, |
1467 | 16 | { "Columns on display", "mdb.cashless.columns", |
1468 | 16 | FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } |
1469 | 16 | }, |
1470 | 16 | { &hf_mdb_cl_rows, |
1471 | 16 | { "Rows on display", "mdb.cashless.rows", |
1472 | 16 | FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } |
1473 | 16 | }, |
1474 | 16 | { &hf_mdb_cl_disp_info, |
1475 | 16 | { "Display information", "mdb.cashless.disp_info", |
1476 | 16 | FT_UINT8, BASE_HEX, NULL, 0x07, NULL, HFILL } |
1477 | 16 | }, |
1478 | 16 | { &hf_mdb_cl_max_price, |
1479 | 16 | { "Maximum price", "mdb.cashless.max_price", |
1480 | 16 | FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL } |
1481 | 16 | }, |
1482 | 16 | { &hf_mdb_cl_min_price, |
1483 | 16 | { "Minimum price", "mdb.cashless.min_price", |
1484 | 16 | FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL } |
1485 | 16 | }, |
1486 | 16 | { &hf_mdb_cl_vend_sub, |
1487 | 16 | { "Sub-command", "mdb.cashless.vend_sub_cmd", |
1488 | 16 | FT_UINT8, BASE_HEX, VALS(mdb_cl_vend_sub_cmd), 0, NULL, HFILL } |
1489 | 16 | }, |
1490 | 16 | { &hf_mdb_cl_item_price, |
1491 | 16 | { "Item Price", "mdb.cashless.item_price", |
1492 | 16 | FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } |
1493 | 16 | }, |
1494 | 16 | { &hf_mdb_cl_item_num, |
1495 | 16 | { "Item Number", "mdb.cashless.item_number", |
1496 | 16 | FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } |
1497 | 16 | }, |
1498 | 16 | { &hf_mdb_cl_reader_sub, |
1499 | 16 | { "Sub-command", "mdb.cashless.reader_sub_cmd", |
1500 | 16 | FT_UINT8, BASE_HEX, VALS(mdb_cl_reader_sub_cmd), 0, NULL, HFILL } |
1501 | 16 | }, |
1502 | 16 | { &hf_mdb_cl_resp, |
1503 | 16 | { "Response", "mdb.cashless.resp", |
1504 | 16 | FT_UINT8, BASE_HEX, VALS(mdb_cl_resp), 0, NULL, HFILL } |
1505 | 16 | }, |
1506 | 16 | { &hf_mdb_cl_scale, |
1507 | 16 | { "Scale factor", "mdb.cashless.scale_factor", |
1508 | 16 | FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } |
1509 | 16 | }, |
1510 | 16 | { &hf_mdb_cl_dec_pl, |
1511 | 16 | { "Decimal places", "mdb.cashless.decimal_places", |
1512 | 16 | FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } |
1513 | 16 | }, |
1514 | 16 | { &hf_mdb_cl_max_rsp_time, |
1515 | 16 | { "Application maximum response time", "mdb.cashless.max_rsp_time", |
1516 | 16 | FT_RELATIVE_TIME, BASE_NONE, NULL, 0, NULL, HFILL } |
1517 | 16 | }, |
1518 | 16 | { &hf_mdb_cl_vend_amt, |
1519 | 16 | { "Vend Amount", "mdb.cashless.vend_amount", |
1520 | 16 | FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } |
1521 | 16 | }, |
1522 | 16 | { &hf_mdb_cl_expns_sub, |
1523 | 16 | { "Sub-command", "mdb.cashless.expansion_sub_cmd", |
1524 | 16 | FT_UINT8, BASE_HEX, VALS(mdb_cl_expns_sub_cmd), 0, NULL, HFILL } |
1525 | 16 | }, |
1526 | 16 | { &hf_mdb_cl_manuf_code, |
1527 | 16 | { "Manufacturer Code", "mdb.cashless.manuf_code", |
1528 | 16 | FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } |
1529 | 16 | }, |
1530 | 16 | { &hf_mdb_cl_ser_num, |
1531 | 16 | { "Serial Number", "mdb.cashless.serial_number", |
1532 | 16 | FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } |
1533 | 16 | }, |
1534 | 16 | { &hf_mdb_cl_mod_num, |
1535 | 16 | { "Model Number", "mdb.cashless.model_number", |
1536 | 16 | FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } |
1537 | 16 | }, |
1538 | 16 | { &hf_mdb_cl_opt_feat, |
1539 | 16 | { "Optional Feature Bits", "mdb.cashless.opt_feature_bits", |
1540 | 16 | FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL } |
1541 | 16 | }, |
1542 | 16 | { &hf_mdb_cgw_feat_lvl, |
1543 | 16 | { "Feature level", "mdb.comms_gw.feature_level", |
1544 | 16 | FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } |
1545 | 16 | }, |
1546 | 16 | { &hf_mdb_cgw_scale, |
1547 | 16 | { "Scale factor", "mdb.comms_gw.scale_factor", |
1548 | 16 | FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } |
1549 | 16 | }, |
1550 | 16 | { &hf_mdb_cgw_dec_pl, |
1551 | 16 | { "Decimal places", "mdb.comms_gw.decimal_places", |
1552 | 16 | FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } |
1553 | 16 | }, |
1554 | 16 | { &hf_mdb_cgw_resp, |
1555 | 16 | { "Response", "mdb.comms_gw.resp", |
1556 | 16 | FT_UINT8, BASE_HEX, VALS(mdb_cgw_resp), 0, NULL, HFILL } |
1557 | 16 | }, |
1558 | 16 | { &hf_mdb_cgw_max_rsp_time, |
1559 | 16 | { "Application maximum response time", "mdb.comms_gw.max_rsp_time", |
1560 | 16 | FT_RELATIVE_TIME, BASE_NONE, NULL, 0, NULL, HFILL } |
1561 | 16 | }, |
1562 | 16 | { &hf_mdb_cgw_report_sub, |
1563 | 16 | { "Sub-command", "mdb.comms_gw.report_sub_cmd", FT_UINT8, |
1564 | 16 | BASE_HEX, VALS(mdb_cgw_report_sub_cmd), 0, NULL, HFILL } |
1565 | 16 | }, |
1566 | 16 | { &hf_mdb_cgw_dts_evt_code, |
1567 | 16 | { "DTS Event Code", "mdb.comms_gw.dts_event_code", |
1568 | 16 | FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } |
1569 | 16 | }, |
1570 | 16 | { &hf_mdb_cgw_duration, |
1571 | 16 | { "Duration", "mdb.comms_gw.duration", |
1572 | 16 | FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } |
1573 | 16 | }, |
1574 | 16 | { &hf_mdb_cgw_activity, |
1575 | 16 | { "Activity", "mdb.comms_gw.activity", |
1576 | 16 | FT_BOOLEAN, 8, TFS(&tfs_active_inactive), 0x1, NULL, HFILL } |
1577 | 16 | }, |
1578 | 16 | { &hf_mdb_cgw_expns_sub, |
1579 | 16 | { "Sub-command", "mdb.comms_gw.expansion_sub_cmd", FT_UINT8, |
1580 | 16 | BASE_HEX, VALS(mdb_cgw_expns_sub_cmd), 0, NULL, HFILL } |
1581 | 16 | }, |
1582 | 16 | { &hf_mdb_cgw_opt_feat, |
1583 | 16 | { "Optional Feature Bits", "mdb.comms_gw.opt_feature_bits", |
1584 | 16 | FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL } |
1585 | 16 | }, |
1586 | 16 | { &hf_mdb_cgw_manuf_code, |
1587 | 16 | { "Manufacturer Code", "mdb.comms_gw.manuf_code", |
1588 | 16 | FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } |
1589 | 16 | }, |
1590 | 16 | { &hf_mdb_cgw_ser_num, |
1591 | 16 | { "Serial Number", "mdb.comms_gw.serial_number", |
1592 | 16 | FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } |
1593 | 16 | }, |
1594 | 16 | { &hf_mdb_cgw_mod_num, |
1595 | 16 | { "Model Number", "mdb.comms_gw.model_number", |
1596 | 16 | FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } |
1597 | 16 | }, |
1598 | 16 | { &hf_mdb_bv_setup_bill_val_feature, |
1599 | 16 | { "Bill Validator Feature Level", "mdb.bv.setup.feature_level", |
1600 | 16 | FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL } |
1601 | 16 | }, |
1602 | 16 | { &hf_mdb_bv_setup_ctry_currency_code, |
1603 | 16 | { "Country/Currency Code", "mdb.bv.setup.ctry_currency", |
1604 | 16 | FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL } |
1605 | 16 | }, |
1606 | 16 | { &hf_mdb_bv_setup_bill_scal_fac, |
1607 | 16 | { "Bill scaling factor", "mdb.bv.setup.bill_scale_factor", |
1608 | 16 | FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL } |
1609 | 16 | }, |
1610 | 16 | { &hf_mdb_bv_setup_dec_places, |
1611 | 16 | { "Decimal Places", "mdb.bv.setup.dec_places", |
1612 | 16 | FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } |
1613 | 16 | }, |
1614 | 16 | { &hf_mdb_bv_setup_bill_stacker_cap, |
1615 | 16 | { "Stacker Capacity", "mdb.bv.setup.stacker_cap", |
1616 | 16 | FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL } |
1617 | 16 | }, |
1618 | 16 | { &hf_mdb_bv_setup_bill_sec_lvls, |
1619 | 16 | { "Security Levels", "mdb.bv.setup.sec_levels", |
1620 | 16 | FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL } |
1621 | 16 | }, |
1622 | 16 | { &hf_mdb_bv_setup_escrow, |
1623 | 16 | { "Escrow capability", "mdb.bv.setup.escrow", |
1624 | 16 | FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL } |
1625 | 16 | }, |
1626 | 16 | { &hf_mdb_bv_setup_bill_type_cred, |
1627 | 16 | { "Bill Type Credit", "mdb.bv.setup.bill_type_credit", |
1628 | 16 | FT_STRING, BASE_NONE, NULL, 0, "Bill values per channel", HFILL } |
1629 | 16 | }, |
1630 | 16 | { &hf_mdb_bv_bill_enable, |
1631 | 16 | { "Bill Enable State", "mdb.bv.bill_type.enable", |
1632 | 16 | FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL } |
1633 | 16 | }, |
1634 | 16 | { &hf_mdb_bv_bill_escrow_enable, |
1635 | 16 | { "Bill Escrow Enable State", "mdb.bv.bill_type.escrow_enable", |
1636 | 16 | FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL } |
1637 | 16 | }, |
1638 | 16 | { &hf_mdb_bv_poll_bill_routing_state, |
1639 | 16 | { "Escrow", "mdb.bv.poll.routing_state", |
1640 | 16 | FT_UINT8, BASE_HEX, VALS(mdb_bv_poll_bill_routing_state), 0x70, NULL, HFILL } |
1641 | 16 | }, |
1642 | 16 | { &hf_mdb_bv_poll_bill_type, |
1643 | 16 | { "Bill Type", "mdb.bv.poll.bill_type", |
1644 | 16 | FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL } |
1645 | 16 | }, |
1646 | 16 | { &hf_mdb_bv_poll_state, |
1647 | 16 | { "Bill Accept State", "mdb.bv.poll.state", |
1648 | 16 | FT_UINT8, BASE_HEX, VALS(mdb_bv_poll_state), 0, NULL, HFILL } |
1649 | 16 | }, |
1650 | 16 | { &hf_mdb_bv_escrow_state, |
1651 | 16 | { "Escrow", "mdb.bv.escrow.state", |
1652 | 16 | FT_BOOLEAN, 8, TFS(&mdb_bv_escrow_state), 0x01, NULL, HFILL } |
1653 | 16 | }, |
1654 | 16 | { &hf_mdb_bv_stacker, |
1655 | 16 | { "Stacker Full", "mdb.bv.stacker.full_state", |
1656 | 16 | FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL } |
1657 | 16 | }, |
1658 | 16 | { &hf_mdb_bv_exp_cmd, |
1659 | 16 | { "Expansion Command", "mdb.bv.exp.cmd", FT_UINT8, |
1660 | 16 | BASE_HEX, VALS(mdb_bv_exp_cmd), 0, NULL, HFILL } |
1661 | 16 | }, |
1662 | | // EXPANSION cmd: Level 1/2 Identification with/Without Option bits |
1663 | 16 | { &hf_mdb_bv_exp_opt_feat, |
1664 | 16 | { "Bill Type Routing", "mdb.bv.exp.bill_type_routing", |
1665 | 16 | FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL } |
1666 | 16 | }, |
1667 | 16 | { &hf_mdb_bv_exp_manufact_code, |
1668 | 16 | { "Manufacturer Code", "mdb.bv.expns.manufact_code", |
1669 | 16 | FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } |
1670 | 16 | }, |
1671 | 16 | { &hf_mdb_bv_exp_serial_num, |
1672 | 16 | { "Serial Number", "mdb.bv.expns.serial_num", |
1673 | 16 | FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } |
1674 | 16 | }, |
1675 | 16 | { &hf_mdb_bv_exp_model_tuning_num, |
1676 | 16 | { "Model/Tuning number", "mdb.bv.expns.model_tuning_num", |
1677 | 16 | FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } |
1678 | 16 | }, |
1679 | 16 | { &hf_mdb_bv_exp_software_version, |
1680 | 16 | { "Software version", "mdb.bv.expns.software_version", |
1681 | 16 | FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL } |
1682 | 16 | }, |
1683 | | // EXPANSION cmd: Lvl2 Feature enable |
1684 | 16 | { &hf_mdb_bv_exp_opt_feat_enable, |
1685 | 16 | { "Level 2+ Feature enable", "mdb.bv.exp.opt_feat", |
1686 | 16 | FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL } |
1687 | 16 | }, |
1688 | | // EXPANSION cmd: Recycler Setup |
1689 | 16 | { &hf_mdb_bv_exp_bill_type_routing, |
1690 | 16 | { "Bill Type Routing", "mdb.bv.exp.bill_type_routing", |
1691 | 16 | FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL } |
1692 | 16 | }, |
1693 | | // EXPANSION cmd: Recycler Enable |
1694 | 16 | { &hf_mdb_bv_exp_manual_dispense_enable, |
1695 | 16 | { "Manual Dispense Enable", "mdb.bv.exp.manual_dispense_enable", |
1696 | 16 | FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL } |
1697 | 16 | }, |
1698 | 16 | { &hf_mdb_bv_exp_bill_recycler_enabled, |
1699 | 16 | { "Bill Recycler Enabled", "mdb.bv.exp.bill_recycler_enabled", |
1700 | 16 | FT_UINT8, BASE_HEX, VALS(mdb_bv_exp_bills_recyc_enabled), 0, NULL, HFILL } |
1701 | 16 | }, |
1702 | | // EXPANSION cmd: Bill Dispense Status |
1703 | 16 | { &hf_mdb_bv_exp_dispenser_full_state, |
1704 | 16 | { "Dispenser Full Status", "mdb.bv.exp.dispenser_full_state", |
1705 | 16 | FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL } |
1706 | 16 | }, |
1707 | 16 | { &hf_mdb_bv_exp_bill_count, |
1708 | 16 | { "Bill count", "mdb.bv.exp.bill_count", |
1709 | 16 | FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL } |
1710 | 16 | }, |
1711 | | // EXPANSION cmd: Dispense Bill |
1712 | 16 | { &hf_mdb_bv_exp_bill_type_dispensed, |
1713 | 16 | { "Bill type to be dispensed", "mdb.bv.exp.bill_type_disp", |
1714 | 16 | FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } |
1715 | 16 | }, |
1716 | 16 | { &hf_mdb_bv_exp_bill_type_number_bills, |
1717 | 16 | { "Bills type number of bills", "mdb.bv.exp.bill_type_num_bills", |
1718 | 16 | FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL } |
1719 | 16 | }, |
1720 | | // EXPANSION cmd: Dispense Value |
1721 | 16 | { &hf_mdb_bv_exp_dispense_value_bills, |
1722 | 16 | { "Bill value to be paid out", "mdb.bv.exp.dispense_value_bills", |
1723 | 16 | FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL } |
1724 | 16 | }, |
1725 | | // EXPANSION cmd: Payout Status |
1726 | 16 | { &hf_mdb_bv_exp_payout_state, |
1727 | 16 | { "Number of bills paid out", "mdb.bv.exp.payout_state_num_bills", |
1728 | 16 | FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL } |
1729 | 16 | }, |
1730 | | // EXPANSION cmd: Payout Value Poll |
1731 | 16 | { &hf_mdb_bv_exp_dispenser_payout_activity, |
1732 | 16 | { "Dispenser Payout Activity", "mdb.bv.exp.payout_value_activity", |
1733 | 16 | FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL } |
1734 | 16 | }, |
1735 | | // EXPANSION cmd: Payout Cancel |
1736 | | // No data |
1737 | | // EXPANSION cmd: FTL REQ to RCV |
1738 | | // EXPANSION cmd: FTL Send Block |
1739 | | // EXPANSION cmd: FTL OK to Send |
1740 | | // EXPANSION cmd: FTL REQ to Send |
1741 | | // EXPANSION cmd: Diagnostics |
1742 | 16 | { &hf_mdb_ack, |
1743 | 16 | { "Ack byte", "mdb.ack", |
1744 | 16 | FT_UINT8, BASE_HEX, VALS(mdb_ack), 0, NULL, HFILL } |
1745 | 16 | }, |
1746 | 16 | { &hf_mdb_data, |
1747 | 16 | { "Data", "mdb.data", |
1748 | 16 | FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } |
1749 | 16 | }, |
1750 | 16 | { &hf_mdb_chk, |
1751 | 16 | { "Checksum", "mdb.chk", |
1752 | 16 | FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL } |
1753 | 16 | }, |
1754 | 16 | { &hf_mdb_chk_status, |
1755 | 16 | { "Checksum Status", "mdb.chk.status", |
1756 | 16 | FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0, |
1757 | 16 | NULL, HFILL } |
1758 | 16 | }, |
1759 | 16 | { &hf_mdb_response_in, |
1760 | 16 | { "Response In", "mdb.response_in", |
1761 | 16 | FT_FRAMENUM, BASE_NONE, FRAMENUM_TYPE(FT_FRAMENUM_RESPONSE), 0x0, |
1762 | 16 | "The response to this request is in this frame", HFILL } |
1763 | 16 | }, |
1764 | 16 | { &hf_mdb_response_to, |
1765 | 16 | { "Request In", "mdb.response_to", |
1766 | 16 | FT_FRAMENUM, BASE_NONE, FRAMENUM_TYPE(FT_FRAMENUM_REQUEST), 0x0, |
1767 | 16 | "This is a response to the request in this frame", HFILL } |
1768 | 16 | }, |
1769 | 16 | { &hf_mdb_time, |
1770 | 16 | { "Time", "mdb.time", |
1771 | 16 | FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0, |
1772 | 16 | "The time between the Call and the Reply", HFILL } |
1773 | 16 | } |
1774 | 16 | }; |
1775 | | |
1776 | 16 | static ei_register_info ei[] = { |
1777 | 16 | { &ei_mdb_short_packet, |
1778 | 16 | { "mdb.short_packet", PI_PROTOCOL, PI_ERROR, |
1779 | 16 | "MDB packet without payload", EXPFILL }}, |
1780 | 16 | { &ei_mdb_bad_checksum, |
1781 | 16 | { "mdb.bad_checksum", PI_CHECKSUM, PI_ERROR, |
1782 | 16 | "Bad checksum", EXPFILL }} |
1783 | 16 | }; |
1784 | | |
1785 | 16 | proto_mdb = proto_register_protocol("Multi-Drop Bus", "MDB", "mdb"); |
1786 | 16 | proto_register_subtree_array(ett, array_length(ett)); |
1787 | 16 | proto_register_field_array(proto_mdb, hf, array_length(hf)); |
1788 | 16 | expert_mdb = expert_register_protocol(proto_mdb); |
1789 | 16 | expert_register_field_array(expert_mdb, ei, array_length(ei)); |
1790 | 16 | mdb_handle = register_dissector("mdb", dissect_mdb, proto_mdb); |
1791 | 16 | } |
1792 | | |
1793 | | void proto_reg_handoff_mdb(void) |
1794 | 16 | { |
1795 | 16 | dissector_add_uint("wtap_encap", WTAP_ENCAP_MDB, mdb_handle); |
1796 | 16 | } |
1797 | | |
1798 | | /* |
1799 | | * Editor modelines - https://www.wireshark.org/tools/modelines.html |
1800 | | * |
1801 | | * Local variables: |
1802 | | * c-basic-offset: 4 |
1803 | | * tab-width: 8 |
1804 | | * indent-tabs-mode: nil |
1805 | | * End: |
1806 | | * |
1807 | | * vi: set shiftwidth=4 tabstop=8 expandtab: |
1808 | | * :indentSize=4:tabSize=8:noTabs=true: |
1809 | | */ |